import { T as ToolHost } from '../tool-host-BBSaU7IJ.cjs'; import { B as Bridge } from '../types-D_H2f-wF.cjs'; import '../types-ITRQFAir.cjs'; /** * Loose snapshot of a screen — what's in fancy-screens' ScreenMeta plus * the host's optional activity status. Kept here so this bridge has no * hard dep on fancy-screens. */ type ScreenSnapshot = { id: string; title?: string; /** Whether this screen is the one the human / agent is looking at. */ active: boolean; /** Optional category / kind (e.g. "form", "whiteboard"). */ kind?: string; }; /** * Spec for a dynamically-created screen. The host's `createScreen` * implementation looks up `kind` in its template registry and instantiates * the matching surface (form / whiteboard / sheet / chart / markdown / etc.). */ type ScreenCreateSpec = { id: string; title?: string; /** Template kind. Hosts decide the catalog. */ kind: string; /** Template-specific config. Form: { fields }. Sheet: { headers }. etc. */ config?: Record; }; /** * What a mutating adapter method may resolve to, to acknowledge (or refuse) * a commit. `{ ok: false }` is a refusal the agent can act on: `error` is * shown to the agent verbatim, so keep it a human-readable sentence, never a * stack trace or an internal path. `code` is a machine-readable hint * (e.g. `"conflict"`) for the host's own use; it is not shown to the agent. */ type ScreensAdapterResult = { ok: true; } | { ok: false; error: string; code?: string; }; /** * Return type of every mutating adapter method. A sync `void` return keeps * the original behaviour. A Promise makes the bridge WAIT: the tool reports * success, and emits its AgentActivity event, only after the promise * resolves. A rejection or an `{ ok: false }` result becomes an error result * and emits no activity. */ type ScreensAdapterCommit = void | Promise; /** * Adapter exposes the host's screen-navigation surface to the bridge. * Hosts wire this up against react-router, a custom tab state, or the * fancy-screens registry — wherever "current screen" lives. * * The optional create / destroy / update hooks let agents author screens * dynamically against a host-defined template catalog. * * Every mutating method may be sync (`void`) or async (`Promise`); see * {@link ScreensAdapterCommit}. Return a Promise when the host's commit is * authoritative — persisted, or able to refuse or conflict — so the agent is * told the truth instead of "success" before anything was committed. * * This bridge pushes NO undo entries: `agent_undo` cannot revert a screens * tool. A host that needs undo for navigation or screen authoring must keep * its own history. */ type ScreensBridgeAdapter = { /** List every available screen. */ listScreens: () => ScreenSnapshot[]; /** Read which screen is currently active. */ getActive: () => string | null; /** Navigate to a screen by id. Host updates router / tab state. */ setActive: (screenId: string) => ScreensAdapterCommit; /** Optional: instantiate a new screen from a template + config. */ createScreen?: (spec: ScreenCreateSpec) => ScreensAdapterCommit; /** Optional: remove a previously-created screen. */ destroyScreen?: (screenId: string) => ScreensAdapterCommit; /** Optional: shallow-merge new config into an existing screen. */ updateScreenContent?: (screenId: string, partial: Record) => ScreensAdapterCommit; /** Optional: enumerate the kinds the host knows how to instantiate. */ listKinds?: () => Array<{ kind: string; label?: string; description?: string; configSchema?: unknown; }>; }; type ScreensBridgeOptions = { adapter: ScreensBridgeAdapter; agent?: { id: string; name?: string; color?: string; }; }; /** * registerScreensBridge — top-level navigation bridge so agents can * switch between screens (`screens_navigate`) and discover what surfaces * exist (`screens_list`, `screens_describe_active`). * * Pair with the per-surface bridges (whiteboard, form, sheet, etc.) so * the agent has both navigation and per-screen control. */ declare function registerScreensBridge(host: ToolHost, options: ScreensBridgeOptions): Bridge; export { type ScreenCreateSpec, type ScreenSnapshot, type ScreensAdapterCommit, type ScreensAdapterResult, type ScreensBridgeAdapter, type ScreensBridgeOptions, registerScreensBridge };