Electron And Tauri
Electron and Tauri apps should expose a narrow bridge, not raw browser backend methods. The package adapters route open/get/list/close/command/subscribe/unsubscribe through createHostBrowserBridge.
Electron Main Process
Section titled “Electron Main Process”import { registerElectronBrowserBridgeAdapter } from "@cmmd-center/agent-browser/adapters/electron";
const cleanup = registerElectronBrowserBridgeAdapter({ bridge, ipcMain, webContents: mainWindow.webContents, channel: "agent-browser", eventsChannel: "agent-browser:event"});Renderer code calls one IPC channel:
const session = await window.electron.ipcRenderer.invoke("agent-browser", { method: "openSession", params: { sessionId: "thread-123", initialUrl: "https://docs.cmmd.ai", visibility: "visible" }});
await window.electron.ipcRenderer.invoke("agent-browser", { method: "command", params: { sessionId: session.sessionId, command: { type: "snapshot" } }});Call the returned cleanup function when the window or app shuts down so IPC handlers and event subscriptions do not leak.
Tauri Commands
Section titled “Tauri Commands”import { createTauriBrowserBridgeCommands } from "@cmmd-center/agent-browser/adapters/tauri";
const commands = createTauriBrowserBridgeCommands({ bridge, emit: app.emit.bind(app), eventName: "agent-browser-event"});Expose the returned command handlers through the Tauri command layer:
await commands.browserOpenSession({ sessionId: "thread-123", initialUrl: "https://docs.cmmd.ai"});
await commands.browserCommand({ sessionId: "thread-123", command: { type: "screenshot" }});The adapter generates subscription IDs, emits bridge events through the provided emitter, and validates unsupported methods as request errors.
Host Responsibilities
Section titled “Host Responsibilities”- Keep package IPC channels private to the app shell.
- Enforce user/project/session authorization before routing commands.
- Unsubscribe listeners during window teardown and session close.
- Keep Electron/Tauri preload APIs narrow and typed.
- Store durable events and artifacts outside renderer memory when replay matters.