/** * Cross-host UI client — types and wire constants. * * The cross-host client (`connectUI`) renders one Synapse-authored component in * any MCP Apps host (ChatGPT, Claude, NimbleBrain) and standalone. Apps code * against `synapse.*` and never touch the bridge. This is a **push-first** surface: the tool output that spawned * the widget is delivered at render (`data()` / `onData()`); `callTool()` is the * pull escape hatch, advertised per host via `capabilities()`. * * This layer intentionally has ZERO dependency on `@modelcontextprotocol/*` — the * bridge is JSON-RPC over `postMessage`, spoken by hand, so the IIFE that apps * inline stays tiny (no Zod, no ext-apps schemas). */ /** * The bridge the client resolved to, as reported by `synapse.host()`: * `"mcp-apps"` in a frame, `"generic"` standalone. It names the bridge, not the * product — every framing host speaks the same one. Apps should rarely branch on * it; `capabilities()` is the supported way to feature-detect. */ type HostKind = "mcp-apps" | "generic"; /** Resolved theme. `mode` always resolves to light or dark. `tokens` are CSS * custom properties the host publishes — the MCP Apps adapter reads them from * `hostContext.styles.variables`; where a host sends none they stay empty and the * SDK's neutral defaults back them. */ interface SynapseUITheme { mode: "light" | "dark"; tokens: Record; } /** What the active host actually supports. `data()`/`onData()`/`theme()`/ * `resize()` work everywhere; these three vary. */ interface HostCapabilities { /** `callTool()` can reach the server (widget→server fetch). */ pull: boolean; /** `sendPrompt()` reaches the agent conversation. */ sendPrompt: boolean; /** `openLink()` opens an external URL through the host. */ openLink: boolean; } /** Thrown by `callTool()` when the active host offers no widget→server call. */ declare class HostUnsupportedError extends Error { constructor(feature: string, host: HostKind); } /** * Thrown by `callTool()` when the tool result says the call failed * (`isError: true`). MCP reports a tool failure inside the result rather than as * a JSON-RPC error, and a host reports a refusal the same way — ChatGPT answers a * call to a tool the app may not see with an `isError` result — so without this a * failure would resolve as if it were data. The message is the result's first * text block; the whole result is on `result`. */ declare class ToolCallError extends Error { readonly result: unknown; constructor(name: string, result: unknown); } interface ConnectUIOptions { /** App name — informational; forwarded to hosts that accept an appInfo. */ name?: string; /** App semver — informational. */ version?: string; /** * Force a host adapter instead of auto-detecting. Used by preview harnesses, * SSR, and tests; production apps omit it and let the SDK feature-detect. * `"mcp-apps"` → MCP Apps standard adapter, `"generic"` → inline adapter. */ host?: HostKind; /** * `id` of the `