Config
crust.config.ts — default export, or an export named config — or crust.json holding the same object, in that order. The object is validated once at startup and unknown keys are rejected at every level, so a typo is a launch failure rather than a silently ignored option.
import type { CrustConfig } from "crust";
export default {
app: { id: "land.jyz.example", name: "Example", version: "0.1.0" },
windows: [{ label: "main", url: "/", width: 900, height: 640, title: "Example" }],
} satisfies CrustConfig;
Types are what the validator accepts. The default is what the consuming code does when the key is absent — the validator itself fills in nothing.
app
| key | type | default | what it does |
|---|---|---|---|
id | string | required | reverse-DNS bundle identifier written to Info.plist; also seeds the bridge port and is the notification identity |
name | string | required | app name, and the name platform failures print |
version | string | required | CFBundleShortVersionString |
icon | string | unset | PNG resolved against --dir by crust build; a missing file fails the build |
activate | string | "always" | when creating a window brings the app to the front: "always", "first" or "never" |
app.activate
Whether a window create raises the app, which is what puts the window on the active Space and therefore into AppKit's AXWindows. Only macOS reads it; the validator accepts it everywhere so one config serves every platform.
"always"— every window create raises the app, guarded on it not already being active. The default, and the behaviour that keeps a window in the accessibility tree."first"— only the first window create of the process.-[NSApplication isActive]is false whenever the human is in another app, so a per-windowisActivetest cannot tell "no window yet" from "the human is elsewhere": it activates on every window created from behind another app and steals their focus. One process-wide flag is what tells them apart. Cost: a later window created while the app is inactive stays off the active Space and out ofAXWindowsuntil the user clicks the app — the symptom the activation fix removed, now only for later windows."never"— no activation selector is sent at all. Every window created while the app is inactive has that same symptom: on screen, but on the Space it was created on rather than the one the user is looking at, and absent fromAXWindows, so VoiceOver cannot see it until the user activates the app. The window's collection behaviour ismoveToActiveSpace | fullScreenPrimary(setCollectionBehavior: 130):fullScreenPrimary(128) is what makes the green button the fullscreen arrows instead of a zoom+, andmoveToActiveSpace(2) moves an activated window to the Space the user is looking at, so a launch inside a fullscreen Space is not stranded on the desktop Space. It wascanJoinAllSpaces | fullScreenAuxiliary(257) up to and including 0.2.0:fullScreenAuxiliary(256) marks the window as another app's helper and disqualifies it as fullscreen-primary — which is why the button stayed a zoom — andcanJoinAllSpaces(1) contradictsfullScreenPrimary, because a window present on every Space has no single Space to transition into.
A second window of an already-active app is never re-raised, whatever the mode: the selector is guarded on -[NSApplication isActive], and the once-per-process -activate is shared with window.focus.
testing
activation (string, default "auto") — how a probe run treats activation. "auto" is an ordinary launch and app.activate decides, so the first window create brings the app forward. "none" never activates, and accessibility.elementCount then answers a typed needs-activation instead of the empty tree an inactive app gives. "on-demand" also launches without activating and raises the app once — -activateIgnoringOtherApps: — for the first accessibility read that needs it; later reads do not raise it again. Page-level testing needs no activation in any mode, because testing.* runs inside the window's own webview and window.capture renders that webview, so a probe still clicks, types, queries and captures a window that never takes the front. Pair it with window.create { activate: false } and nothing a probe does moves the human's focus.
windows
At least one entry. A missing or empty array is a config error, not a windowless app.
| key | type | default | what it does |
|---|---|---|---|
label | string | required | the handle window commands and platform.window(label) use |
url | string | "/" | appended to the bridge URL; ignored when dev.url is set |
width | positive integer | 1100 | content width in points |
height | positive integer | 760 | content height in points |
minWidth | positive integer | unset (0) | minimum width, clamped into width; no height minimum is inferred |
minHeight | positive integer | unset (0) | minimum height, clamped into height, independent of minWidth |
title | string | unset | window title, applied from C and read back; a mismatch throws |
material | string | "none" | backdrop behind the webview; see below |
Both minimums are independent: setting minWidth alone does not infer a minimum height, and a configured width/height below its own minimum is clamped up to it. Absent means 0, the no-constraint value AppKit expects.
windows[].material
A named backdrop the current OS can apply. Validation refuses a name the platform cannot use, so a typo or a cross-platform copy is a launch failure naming windows[0].material, never a grey window.
- macOS:
"vibrancy"(translucency) or"none". - Windows:
"mica","acrylic","tabbed"or"none". A named backdrop needs Windows 11 build 22621 or newer; an older or unreadable build fails at window creation naming the required build. - Linux: only
"none"; any named backdrop is refused by name.
Absent is "none" — opaque, with no backdrop call. The parity page has the comparison row.
dev
| key | type | default | what it does |
|---|---|---|---|
url | string | unset | one dev-server origin every window loads verbatim; windows[].url is then ignored, and its origin is the one extra origin the bridge allows |
beforeDevCommand | string | unset | started, not awaited, by crust dev through sh -c in the project directory |
ignore | string array | unset | extra path fragments that never restart the backend, for output the built-in rules cannot know — every entry is a substring of the changed path |
With dev.url set, crust dev waits up to 30 s for a TCP connect on that port before starting the runtime, because the window loads the URL exactly once and cannot retry. A restart rotates the bridge token, so a file written into the project while the backend runs must not look like backend code: public/, dist/, node_modules/, .next/, out/, .crust/ and frontend extensions are already ignored, and dev.ignore covers the rest. See Dev server.
singleInstance
| key | type | default | what it does |
|---|---|---|---|
id | string | the app id, plus a hash of the project directory under crust dev | names the lock file, so a probe runs beside the user's copy instead of raising it; one file-name token |
CRUST_SINGLE_INSTANCE=0 disables the check for one launch. See Single instance.
build
| key | type | default | what it does |
|---|---|---|---|
beforeBuildCommand | string | unset | run to completion before the asset directory is read; a non-zero exit aborts the build naming the command and its exit code |
assets | string | "public" | directory crust build embeds, relative to --dir; must hold index.html, and may not resolve to dist/ |
minimumSystemVersion | string | "13.0" | LSMinimumSystemVersion |
urlScheme | string | unset | custom URL scheme claimed in Info.plist as CFBundleURLTypes, so macOS hands scheme://… URLs to this app |
sidecars | string array | unset | executables crust build copies beside the binary at 0755 and sidecar.spawn may run; each must be a relative path inside the project, and the plugin refuses a name that is not in this list |
plugins
| key | type | default | what it does |
|---|---|---|---|
plugins | string array | all built-ins | built-ins to register; the crust: prefix is optional |
Absent or [] registers every built-in plugin the runtime assembles — the core set (fs, dialog, notification, tray, autostart, logging) plus stronghold, window, store, database, shell, updater when its section exists, and all the platform's native plugins. stronghold, store and database are built with this app's own data root, so two crust apps never share a vault or a store file. Naming any restricts registration to exactly those, so every other name answers unknown-command. An unknown name fails startup with crust: unknown plugin "nope" — v1 ships …, where the tail is the full list of registered built-in names for this platform, built at runtime rather than a fixed five. The app namespace and any plugin mounted with app.use are always registered — this key selects built-ins only.
extensions
| key | type | default | what it does |
|---|---|---|---|
extensions | string array | unset — discover *.ts | extension files to load, relative to the project; a relative entry that climbs out of it is refused |
Absent, the loader discovers extensions/*.ts; present, it loads exactly those files. Each is a flat non-empty string path, resolved against the project. See Extensions.
logging
| key | type | default | what it does |
|---|---|---|---|
level | string | "info" | quietest level written: trace, debug, info, warn or error; --log-level and CRUST_LOG beat it |
console | boolean | false | mirror records to the terminal, routed by level: debug/info to stdout, warn through console.warn, error to stderr; in a built app only warn and error are mirrored, while crust dev mirrors every level |
dir | string | "logs" | directory for the JSONL files, relative to the app's data directory |
generations | positive integer | 3 | rotated app.N.jsonl archives kept; the oldest is deleted last |
maxBytes | positive integer | 5242880 | size at which the live file rotates (5 MiB) |
The framework logs a run itself — app and window lifecycle, every invoke with its duration and outcome, page console and errors, platform refusals — under ~/Library/Application Support/<app.id>/logs/. See Logging.
security
| key | type | default | what it does |
|---|---|---|---|
csp | string | DEFAULT_CSP | Content-Security-Policy served with every document |
capabilities | capability array | unset — allow all | named grants a window label can hold; absent or empty allows every command |
grants | object | unset — deny all | which capability names each window label holds; once capabilities is non-empty, a label with no entry holds none |
microphone | string | unset — deny all | sentence macOS shows when this app asks for the microphone; setting it is the whole capture opt-in |
DEFAULT_CSP is default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; media-src 'self' blob:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'. script-src carries no 'unsafe-inline': the bridge mints a nonce per document, stamps its own bootstrap and any authored inline <script> with it, and an injected tag without the nonce is refused. style-src keeps 'unsafe-inline' because inline styles are not a script-injection door, and media-src admits blob: so a take recorded through MediaRecorder plays back from URL.createObjectURL — without it the fallback to default-src 'self' refuses it. Any replacement must keep connect-src 'self', or every invoke is a CSP violation, and setting csp wins whole: the bridge still mints and stamps its bootstrap nonce but never rewrites your policy to admit it — unlike the default, a custom policy cannot name that per-response nonce. Config validation resolves the effective script directive the way a browser does — script-src-elem, then script-src, then default-src — and refuses whichever one it finds when it does not admit inline scripts. A policy with no script-src is therefore not automatically fine: default-src 'self' is the effective directive and is refused. The message explains why — the inline bootstrap would be blocked, window.crust would never install and every invoke would fail silently.
A capability is { name, actions }, where each action is plugin:command with * as the one metacharacter: dialog:*, fs:read*, shell:spawn. The dotted shell.spawn is a config error rather than a second spelling. Empty actions, a duplicate capability name, and a grant naming a capability that does not exist are each a launch failure naming the key. Absent capabilities allows every command, which is what every app without this section sees; once it is non-empty the bridge denies by default, per window label. App commands take two action forms — the narrow app:<name> (e.g. app:notes.save) and the broad alias app:invoke; a grant of either authorizes, and the finest matching action is the one named in a refusal. See Permissions for the wildcard caveat and worked grants.
microphone is the whole capture opt-in: its sentence is copied verbatim into Info.plist as NSMicrophoneUsageDescription, which macOS shows in its permission prompt, so it is checked as a sentence — at least two words, ending in ., ? or ! — rather than merely non-empty. A hardened-runtime signature then seals com.apple.security.device.audio-input with it; without that entitlement a signed bundle cannot be granted the microphone at all. The page then calls navigator.mediaDevices.getUserMedia as it would anywhere — crust widens the grant and adds no recording API, so the stream, its tracks and where the bytes go are yours. Only a microphone-only request is granted: camera and mixed microphone-plus-camera requests are denied, because the bundle declares no purpose for them. Absent, every capture request is denied; crust dev denies too, since an unbundled run carries no Info.plist for macOS to read; and Windows and Linux deny today, because WebView2's PermissionRequested and WebKitGTK's permission-request each need their own handling before either can grant.
fs
| key | type | default | what it does |
|---|---|---|---|
scope | string array | unset — no boundary | absolute path prefixes every fs command must stay inside; relative paths refused |
Absent, fs has no scope and reaches any path the process can. A non-absolute entry is a config error, because a relative root would resolve against the process cwd and draw a different boundary in dev and in a built app. See Files.
shell
| key | type | default | what it does |
|---|---|---|---|
allow | string array | unset — deny all | programs a page may spawn: bare names or absolute paths; a relative path or an interpreter is respectively refused/warned |
cwdRoot | string | unset — process cwd | absolute directory every cwd and relative program path must stay inside; name it absolutely |
allow is deny-by-default: with no section every spawn is refused. cwdRoot must be absolute, because the consumer resolves it against the process cwd — the project under crust dev, but / in a built app. Allowing an interpreter (sh, node, python*, …) only warns; it stops the allow list bounding what runs. See Shell.
updater
| key | type | default | what it does |
|---|---|---|---|
endpoint | string | unset | manifest URL check falls back to when the page passes none |
pubkey | string | unset | base64 of 32 raw bytes: the only signing key this app accepts |
autoCheck | boolean | unset | whether the app wants a startup check; updater.config reports it |
allowFileUrl | boolean | unset | permit a file: artifact URL in updater.download — for a test, not a shipped app |
The section existing is what registers crust:updater; with no updater section the runtime carries no download-and-replace surface. pubkey is checked by shape at startup, so a wrong-size key fails a launch rather than every signature. See Updater.
pty
| key | type | default | what it does |
|---|---|---|---|
shell | string | unset — login shell | the section existing is the opt-in; program the terminal runs, and the only one open may name — Pty |
preview
| key | type | default | what it does |
|---|---|---|---|
width | positive integer | the panel's own | default panel width in points; absent still registers the plugin. Ships in 0.2.10 — Preview |
height | positive integer | the panel's own | default panel height in points |
browser
| key | type | default | what it does |
|---|---|---|---|
origins | string array | unset — deny all | http(s) origins, scheme and host only, an embedded surface may load. Ships in 0.2.11 — Browser |
See Config rules for what app.id decides at runtime, and how a bad config is reported.