export { CreateTaskResult, ReadResourceRequest, ReadResourceResult, Task, TaskStatus } from '@modelcontextprotocol/sdk/types.js'; import { C as ConnectOptions, A as App, R as RequestFileOptions, F as FileResult, a as CallToolAsTaskOptions, T as TaskHandle } from './types-BxPfGHKO.js'; export { f as AppEventName, D as Dimensions, K as KeyForwardConfig, M as ModelContext, g as TasksCapability, c as Theme, b as ToolCallResult, e as ToolDefinition, d as ToolResultData } from './types-BxPfGHKO.js'; import { McpUiDownloadFileResult } from '@modelcontextprotocol/ext-apps'; export { McpUiHostContext } from '@modelcontextprotocol/ext-apps'; export { C as ConnectUIOptions, a as HostCapabilities, b as HostKind, c as HostUnsupportedError, d as SYNAPSE_DATA_ELEMENT_ID, e as SynapseUIClient, S as SynapseUITheme, T as ToolCallError, g as connectUI, h as detectHostKind } from './detect-DVGaL2bH.js'; /** * Connect to an MCP Apps host. * * The one entry point. The protocol underneath is the spec's own client, * `@modelcontextprotocol/ext-apps`'s `App`: it owns the transport, the * handshake and the wire schemas. What this adds is the framework on top — * theme injection, the parsed payloads, multi-subscriber events, resize, and * the NimbleBrain extensions — and it resolves to a ready {@link App}. * * The `App` it returns stays deliberately small. NimbleBrain's own extensions * (`action`, the file picker), `downloadFile` and the MCP tasks utility are * composable functions over it — import them from the package root. */ declare function connect(options: ConnectOptions): Promise; /** * Hand the user a file to save, over the ext-apps `ui/download-file` request. * * A function over {@link App} rather than a method on it, like the helpers in * `extensions.ts` — but unlike them this is spec surface, so it is not gated on * the host identity. Any host that advertises `downloadFile` can answer it. * * The bytes always travel embedded. The spec also allows a `ResourceLink`, which * asks the host to fetch a URI the app names; a host holding the user's session * has every reason to refuse that, and the NimbleBrain host does. */ /** * Hand the user a file to save. * * A string is sent as the resource's `text`; a `Blob` is read and sent as * base64 `blob`. Reading a `Blob` is asynchronous, which is why this returns a * promise. * * Precedence for the MIME type: the explicit argument, then the Blob's own * type, then `application/octet-stream`. An empty-string argument falls * through — a `""` MIME is effectively "no type". * * The filename is the last segment of the resource's `file:///` URI, because an * embedded resource has no name field of its own. * * Resolves with the host's result: `{ isError: true }` when the host declined * or the user cancelled. Rejects with `HostCapabilityError`, without sending, * when the host did not declare `downloadFile` — a host that does not implement * the request may never answer it, and a request has no deadline. */ declare function downloadFile(app: App, filename: string, content: string | Blob, mimeType?: string): Promise; /** * Thrown when an app asks for something the host did not declare in * `ui/initialize`. * * The request is never sent. A host that does not implement a request may never * answer it, and this SDK's requests carry no deadline, so sending anyway would * leave the caller waiting forever rather than failing. * * `capability` names what was missing, as the host would have declared it: a * `hostCapabilities` field (`serverTools`, `downloadFile`) or an extension * identifier (`ai.nimblebrain/request-file`, `io.modelcontextprotocol/tasks`). */ declare class HostCapabilityError extends Error { readonly capability: string; constructor(feature: string, capability: string); } /** * The NimbleBrain host extensions. This is the complete list; anything else an * app sends is spec. * * Each extension has one name, used both as its method and as the identifier a * host declares in `hostCapabilities.experimental` to offer it. The ext-apps * host capability type has no field for extensions, and a spec client parses * the `ui/initialize` result against that type, so `experimental` is the one * slot whose contents reach the app. The MCP tasks capability travels the same * way, for the same reason. * * The gate is the declaration, not the host's name. A host that implements an * extension says so; a host that does not is never sent it. */ declare const NIMBLEBRAIN_EXTENSIONS: { /** App → host notification: run a host action (navigate, open a panel). */ readonly action: { readonly method: "ai.nimblebrain/action"; readonly capability: "ai.nimblebrain/action"; }; /** App → host request: the host's file picker, answered `{ files }`. */ readonly requestFile: { readonly method: "ai.nimblebrain/request-file"; readonly capability: "ai.nimblebrain/request-file"; }; /** App → host notification: a keyboard shortcut pressed inside the frame. */ readonly keydown: { readonly method: "ai.nimblebrain/keydown"; readonly capability: "ai.nimblebrain/keydown"; }; }; type NimbleBrainExtension = keyof typeof NIMBLEBRAIN_EXTENSIONS; /** * Whether the host declared a NimbleBrain extension. Use it to decide what to * offer, e.g. to hide an upload button on a host with no file picker. */ declare function hostSupports(app: App, extension: NimbleBrainExtension): boolean; /** * Trigger a host-side action. * * Sends a command *to* the host (navigate, open a panel). A no-op when the host * did not declare `ai.nimblebrain/action`. */ declare function action(app: App, name: string, params?: Record): void; /** * Request one file from the user via the host's native file picker. * * Resolves `null` if the user cancels. Rejects with `HostCapabilityError` when * the host did not declare `ai.nimblebrain/request-file`. */ declare function pickFile(app: App, options?: RequestFileOptions): Promise; /** * Request several files from the user. * * Resolves `[]` if the user cancels. Rejects with `HostCapabilityError` when * the host did not declare `ai.nimblebrain/request-file`. */ declare function pickFiles(app: App, options?: RequestFileOptions): Promise; /** * Task-augment a `tools/call` per the MCP 2025-11-25 tasks utility. * * A composable helper over {@link App} rather than a method on it: the object * `connect()` returns carries the ext-apps surface, and tasks ride alongside. * The receiver answers a task-augmented call with a `CreateTaskResult` * promptly; the actual `CallToolResult` arrives later via `tasks/result`. * * ```ts * const handle = await callToolAsTask(app, "deep_research", { topic }); * handle.onStatus((t) => setStatus(t.status)); * const result = await handle.result(); * ``` * * Rejects with `HostCapabilityError` if the host did not advertise * `tasks.requests.tools.call` — per spec a requestor MUST NOT task-augment * without matching receiver capability. Check `app.supportsTasks` first, and * fall back to `app.callTool`. */ declare function callToolAsTask(app: App, toolName: string, args?: unknown, options?: CallToolAsTaskOptions): Promise>; export { App, CallToolAsTaskOptions, ConnectOptions, FileResult, HostCapabilityError, NIMBLEBRAIN_EXTENSIONS, type NimbleBrainExtension, RequestFileOptions, TaskHandle, action, callToolAsTask, connect, downloadFile, hostSupports, pickFile, pickFiles };