Skip to content

Preload bridge

The preload script exposes a curated, typed window.agentDock API instead of a raw Node or ipcRenderer surface.

AgentDock's preload script uses contextBridge to expose exactly one object, window.agentDock, typed against a shared AgentDockApi interface (src/shared/preload-api.ts) — the same type the renderer imports to call it.

What's exposed

Grouped the same way as IPC channels: workspace.open(), workspace.list(), and so on, each a thin wrapper around one ipcRenderer.invoke(IpcChannels.xxx, ...) call. Every method maps to exactly one main-process capability — there's no generic passthrough method that could be used to reach something not explicitly bridged.

What's deliberately absent

No raw ipcRenderer, no fs, no child_process, no other Node.js global is exposed to the renderer. If the renderer needs a new capability, it requires adding a new named channel and preload method — not relaxing what's already exposed.

Event subscriptions

For streaming data (agent conversation events, terminal output), the bridge exposes a subscribe method that registers a listener and returns an unsubscribe function, so the renderer can clean up a subscription when a component unmounts rather than leaking listeners across the IPC boundary.