Imports

Every entry below is a real exports in package.json, so it resolves in an installed project with no build step. Page code imports none of them — a page uses the window.crust the bridge injects. crust/vite is imported by vite.config.ts, never by a page.

Command namespaces

A page reaches the backend with window.crust.invoke(plugin, command, args), or the two-argument form that routes to app.invoke. There are 34 namespaces registered on every start plus five conditional ones — app, single-instance, pty, updater and testing — for 39 in all; updater joins when the config has an updater section, pty when it has a pty one (Pty), and testing only when the process starts with CRUST_TEST=1. They are documented by area, one page each:

Each page states every command's arguments, its answer and the failure codes it can return. The bridge-level codes are on the errors page.

Failure status

A command that answers a typed failure value instead of throwing — { ok: false, code, message } from window, tray, database, updater and others — is sent with a 4xx/5xx HTTP status chosen from its code through the same table CrustError uses (invalid-label, invalid-title → 400, unknown-window → 404, unknown-adapter → 501, an unmapped code → 400). The body is unchanged: the envelope is still { ok: true, result: … } and the typed failure is still the resolved result, so a page that branches on result.code or result.ok sees exactly what it saw before and a fire-and-forget await crust.invoke(...) is never handed a new rejection. isCrustInvokeError stays the guard for the separate rejection path; these values are not errors in that sense. What changes is the transport: a caller working at the fetch level can now tell a refusal from a success without reading the body.

crust

The package root, src/index.ts.

exportsignature
appapp: App — the module-level singleton, inert until a platform and config are attached
Appclass App — the methods below
createAppcreateApp(platform: Platform, config: CrustConfig, bridgeUrl?: string): App
PUMP_INTERVAL_MSconst PUMP_INTERVAL_MS = 16
CONFIG_FILES["crust.config.ts", "crust.json"]
findConfigfindConfig(dir: string): Promise<string | undefined>
loadConfigloadConfig(options?: LoadConfigOptions): Promise<LoadedConfig>
validateConfigvalidateConfig(value: unknown, source?: string): CrustConfig
ConfigErrorclass ConfigError extends Error — carries issues: ConfigIssue[]
definePluginre-exported from crust/plugin
notImplemented, isNotImplemented, NotImplementedErrorre-exported from crust/plugin

App

methodsignature
commandcommand(name: string, handler: (args: Record<string, unknown>) => unknown | Promise<unknown>): this
useuse(plugin: PluginDefinition): this
pluginsplugins(): readonly PluginDefinition[]
onon(event: AppEvent, listener: (error?: Error) => void | Promise<void>): this — AppEvent is ready, window-all-closed, activate, before-quit, will-quit, reopen, error
runrun(): Promise<void>
quitquit(): void
invokeinvoke(name: string, args?: Record<string, unknown>): Promise<unknown>
attachattach(platform: Platform, config: CrustConfig, bridgeUrl?: string): this — internal
configureconfigure(config: CrustConfig): this — internal
deferBridgedeferBridge(factory: (config: CrustConfig) => string): this — internal

The last three are what startApp calls before importing your main.ts; they are public only because App lives in another module. Calling attach or configure yourself is correct only in a test. command and use both throw after run() has started.

Types

AppEvent, AppListener, CommandHandler, Platform, WindowHandle, WindowOptions, AppConfig, BuildConfig, ConfigIssue, CrustConfig, DevConfig, LoadedConfig, LoadConfigOptions, SecurityConfig, WindowConfig.

crust/native/<platform>

Three native adapter subpaths: src/native/darwin.ts, src/native/windows.ts and src/native/linux.ts. An app that mounts its own native set needs the platform's adapter factories; crust/plugin exports only plugin factories. There is no bare crust/native entry: a compiled bundle embeds exactly one platform's set, so a Windows build must not even resolve a module that imports AppKit.

subpathimportexports
crust/native/darwinimport { darwinDialogAdapter, darwinMenuAdapter } from "crust/native/darwin"darwinDialogAdapter, darwinMenuAdapter, darwinNotificationAdapter, darwinKeychainAdapter, createStatusBar/currentStatusBar (tray), darwinShortcutsAdapter, darwinDockAdapter, darwinThemeAdapter, listScreens/windowWorkAreas/mainScreenFrame (screen), darwinPowerAdapter, darwinAccessibilityAdapter, darwinNavigationAdapter, darwinFindAdapter, darwinDownloadsAdapter, darwinOpenerAdapter, darwinOsAdapter, darwinClipboardAdapter
crust/native/windowsimport { windowsDialogAdapter, windowsTrayAdapter } from "crust/native/windows"windowsDialogAdapter, windowsNotificationAdapter, windowsKeychainAdapter, windowsTrayAdapter, windowsClipboardAdapter, windowsOpenerAdapter, windowsOsAdapter, windowsScreenAdapter/windowsWindowWorkAreas, windowsBrowserAdapter, windowsWindowAdapter
crust/native/linuximport { linuxDialogAdapter, linuxTrayAdapter } from "crust/native/linux"linuxDialogAdapter, linuxNotificationAdapter, linuxKeychainAdapter, linuxTrayAdapter, linuxClipboardAdapter, linuxOpenerAdapter, linuxOsAdapter, linuxScreenAdapter/linuxWindowWorkAreas, linuxBrowserAdapter, linuxWindowAdapter

Every export is a literal static re-export from that platform's src/platform/<platform>/ modules, so bun build --compile embeds the adapter and a compiled app gets the same factory a dev run gets. Each subpath imports only its own platform — no darwin module is reachable from the Windows or Linux entry, and vice versa.

An app must not use import.meta.resolve("crust") or a relative require into node_modules/crust/src/platform/... to find these. Inside a compiled executable the package root is /$bunfs/root, where no package.json exists, so resolution throws and a loader that catches it answers undefined for every adapter — the panel, menu or notification then fails silently. Import the matching subpath instead.

crust/plugin

The plugin entry point, src/plugins/index.ts: the registry, the built-in plugins, and the native adapter factories.

exportsignature
definePlugindefinePlugin<Name extends string, Commands extends CommandMap>(plugin: { name: Name; commands: Commands }): PluginDefinition<Name, Commands>
notImplementednotImplemented(message: string, requires: string): NotImplemented
isNotImplementedisNotImplemented(value: unknown): value is NotImplemented
NotImplementedErrornew NotImplementedError(message: string, requires: string)
PluginRegistrynew PluginRegistry() — register, invoke(pluginName, commandName, args, ctx), has, get, names, commandsOf, handlers
handlerMaphandlerMap(source: HandlerSource): Map<string, CommandHandler>
plugin valuesfsPlugin, dialogPlugin, notificationPlugin, trayPlugin, windowPlugin, windowStatePlugin, positionerPlugin, clipboardPlugin, openerPlugin, osPlugin, shortcutsPlugin, menuPlugin, themePlugin, dockPlugin, powerPlugin, accessibilityPlugin, navigationPlugin, findinpagePlugin, downloadsPlugin, networkPlugin, crashReporterPlugin, i18nPlugin, storePlugin, strongholdPlugin, updaterPlugin, autostartPlugin, loggingPlugin, singleInstancePlugin, testingPlugin — each a PluginDefinition, built with the plugin's default adapter or with none where it needs a platform half
factoriescreateFsPlugin(options?), createDialogPlugin(native?), createNotificationPlugin(adapter?), createTrayPlugin(adapter?), createWindowPlugin(adapter?), createWindowStatePlugin(options?), createPositionerPlugin(options?), createClipboardPlugin(adapter?), createOpenerPlugin(adapter?), createOsPlugin(adapter?), createShortcutsPlugin(adapter?), createMenuPlugin(adapter?), createThemePlugin(adapter?), createDockPlugin(adapter?), createPowerPlugin(adapter?), createAccessibilityPlugin(adapter?), createNavigationPlugin(adapter?), createFindInPagePlugin(adapter?), createDownloadsPlugin(adapter?, options?), createNetworkPlugin(adapter?, options?), createCrashReporterPlugin(options?), createI18nPlugin(options?), createStorePlugin(adapter?), createShellPlugin(options?), createStrongholdPlugin(options?), createUpdaterPlugin(adapter?, options?, execPath?), createAutostartPlugin(adapter?), createLoggingPlugin(adapter?), createSingleInstancePlugin(options?), createTestingPlugin(adapter?)
corePlugins[fsPlugin, dialogPlugin, notificationPlugin, trayPlugin, autostartPlugin, loggingPlugin], plus testingPlugin when process.env.CRUST_TEST === "1". strongholdPlugin is built by the runtime with this app's data root (like storePlugin) so two apps cannot share one vault
coreRegistrycoreRegistry(): PluginRegistry
WINDOW_COMMANDS27 command names, create … capture
POWER_COMMANDS["state", "idleSeconds", "sleepPrevent", "sleepAllow", "onSleep", "onLock", "onWake", "onScreenSleep", "onScreenWake", "onUnlock"] — the four reads and the six push commands
WindowAdapterErrorclass WindowAdapterError extends Error — carries code: WindowErrorCode
deepLinka DeepLink object: .plugin (the deep-link definition), .scheme, .url(), .launch(url, ctx?), .open(url, ctx?)
updater valuesnodeUpdaterAdapter, parseManifest, verifyEd25519, signatureMismatch, readSignatureArgs, decodeBase64, isEd25519Pubkey, isSignature, ED25519_PUBKEY_BYTES, ED25519_SIGNATURE_BYTES
other constantsNETWORK_SCHEME, NETWORK_LOG_LIMIT, SHELL_OUTPUT_LINES, RING_SIZE, THEME_CHANGED, STORE_FILE, STORE_VERSION, KDF_NAME, KDF_ITERATIONS, SALT_BYTES, defaultStoreRoot, isLogLevel, parseDeepLink

Every create* factory returns a PluginDefinition. Without an adapter a plugin fails honestly rather than resolving a fake: notImplemented for dialog, notification, tray, window, window-state, positioner, clipboard, opener, os, shortcut, menu, theme, dock, power, accessibility, navigation, findinpage, downloads, network and single-instance.activate, and unknown-adapter for window.create and any optional adapter member a platform did not supply. A plugin also declares its native half as native: { requires, available }, and the registry writes one error line at startup naming every namespace whose adapter is missing — a built app with no native half says so once instead of failing each later call in silence. windowPlugin is createWindowPlugin() with no adapter, and corePlugins leaves window out because its adapter needs the running platform; the runtime appends it before plugin selection.

shellPlugin is deliberately not exported: shell needs the config's allowlist, so it is only reachable as createShellPlugin({ allow, cwdRoot }). The same holds for updater, which the runtime registers only when the config has an updater section.

Types

PluginContext, PluginDefinition, NotImplemented, CommandMap, CommandSchema, MaybePromise, ArgsOf, ResultOf, SchemaOf, CommandHandler, DialogNative, OpenPanelOptions, OpenPanelResult, SavePanelOptions, SavePanelResult, CancelPanelResult, NotificationNative, NotificationPermission, NotifyOptions, NotifyResult, TrayNative, TrayOptions, TrayResult, WindowNative, WindowCreateOptions, WindowCreateResult, WindowCloseResult, WindowFocusResult, WindowTitleResult, WindowListResult, WindowOpenResult, WindowLabelArgs, WindowLabelAnswer, WindowSetTitleArgs, WindowCreateArgs, WindowErrorCode, WindowFailure, WindowSnapshot, WindowCaptureArgs, WindowCaptureResult, WindowCaptureNative, ReadTextFileArgs, WriteTextFileArgs, WriteTextFileResult.

Every later plugin re-exports its own vocabulary from the same barrel: NetworkRule, NetworkLogEntry, DownloadEntry, DownloadsCommands, StrongholdFailure, UpdaterFailure, UpdateManifest, ThemeState, MenuFailure, TrayFailure, ClipboardFailure, ShellFailure, ShellCommands, ShortcutFailure, PowerFailure, DockFailure, NavigationState, NavigationFailure, FindOutcome, FindFailure, I18nOptions, TranslationResult, CrashReporterOptions, LastCrashResult, ClearCrashesResult, DeepLinkTarget, FsScopeOptions, FsScopeStatus, TestingAdapter, TestingCommands, TestingFailure, TestingCode, TestingArgs, TestingSelectorArgs, TestingPointArgs, TestingTypeArgs, TestingKeyArgs, TestingWaitArgs, TestingConsoleArgs, TestingModifiers, QueryResult, ConsoleEntry.

ArgsOf, ResultOf and SchemaOf are types only, for deriving a typed client from a tuple of plugin definitions; nothing is exported at runtime for them.

crust/vite

The dev-server half of the bridge: it injects window.__CRUST__ and the page client into the document a dev server serves.

exportsignature
crustcrust(options?: CrustOptions): Plugin
BRIDGE_URL_VARconst BRIDGE_URL_VAR = "CRUST_BRIDGE_URL"
BRIDGE_TOKEN_VARconst BRIDGE_TOKEN_VAR = "CRUST_BRIDGE_TOKEN"

CrustOptions is { urlVar?: string; tokenVar?: string }, defaulting to the two constants above.

import { crust } from "crust/vite";

export default defineConfig({
	server: { port: 5173, strictPort: true },
	plugins: [crust()],
});

Serve-only (apply: "serve"), and the handshake is read per document request, never at config time. strictPort is required: the bridge allows exactly the origin dev.url names, so a port that drifts makes every invoke bad-origin. With neither variable nor handshake file present it warns once and injects nothing.