import { a as McpAppThemePalette, i as McpAppPresentation, n as McpAppBrand, o as NEUTRAL_APP_PRESENTATION, r as McpAppBrandColors, s as buildHubUrl, t as MCP_APP_PRESENTATION_SCRIPT_ID } from "./app-presentation-shared.js"; import { App } from "@modelcontextprotocol/ext-apps"; //#region src/app.d.ts declare const DEFINITIVE_REFUSAL_CODES: readonly ["validation_failed", "invalid_input", "invalid_ref", "invalid_cursor", "not_permitted", "permission_denied", "not_found", "state_changed", "conflict", "idempotency_conflict"]; interface SupaMcpAppInfo { name: string; version: string; } type McpAppHostContext = NonNullable>; type McpAppDisplayMode = NonNullable; type McpAppCapabilities = NonNullable[1]>; interface CreateAppWorkspaceOptions { /** Root element that should occupy the stable MCP App viewport. */ root: HTMLElement; /** Preferred inline height before the host's own maximum is applied. */ inlineHeight?: number; /** Lower bound for the preferred inline height when the host permits it. */ minInlineHeight?: number; /** Upper bound for the preferred inline height. */ maxInlineHeight?: number; /** Additional MCP App capabilities to advertise during initialization. */ capabilities?: McpAppCapabilities; /** Automatically apply server-injected presentation CSS tokens. Defaults to `true`. */ applyPresentation?: boolean; } interface AppWorkspace { /** The official MCP Apps client. Register event handlers before connect(). */ app: App; /** Sanitized tenant presentation injected into the HTML document. */ readonly presentation: McpAppPresentation; /** Construct an origin-locked deep link onto `presentation.hubUrl` (or `null` when unconfigured). */ hubUrl: (path?: string, params?: Readonly>) => string | null; /** Connect to the host, apply its context, and request one stable viewport. */ connect: (...args: Parameters) => Promise; /** Latest merged host context, including partial context updates. */ getHostContext: () => McpAppHostContext | undefined; /** Whether the current host advertises fullscreen support. */ canFullscreen: () => boolean; /** Request fullscreen, returning true only when the host entered it. */ requestFullscreen: () => Promise; /** Toggle between inline and fullscreen when the host supports both. */ toggleFullscreen: () => Promise; } interface AppCallToolResult { readonly isError?: boolean; readonly content?: ReadonlyArray<{ readonly type: string; readonly text?: string; }>; readonly structuredContent?: unknown; readonly _meta?: Readonly>; } type RawServerToolCaller = { callServerTool(params: { name: string; arguments?: Record; }): Promise; }; /** Minimal structural surface accepted by `callAppTool` (`App`, `AppWorkspace`, or test double). */ type AppToolCaller = RawServerToolCaller | { readonly app: RawServerToolCaller; }; type AppToolOutcome> = { readonly status: "applied"; readonly ok: true; readonly uncertain: false; readonly requestId?: string; readonly data: Output; readonly text: string | null; readonly raw: AppCallToolResult; } | { readonly status: "refused"; readonly ok: false; readonly uncertain: false; readonly requestId?: string; readonly code: string | null; readonly message: string; readonly cause?: unknown; readonly raw?: AppCallToolResult; } | { readonly status: "uncertain"; readonly ok: false; readonly uncertain: true; readonly requestId: string; readonly message: string; readonly cause?: unknown; readonly raw?: AppCallToolResult; /** Retry the exact same tool call, arguments, and `request_id`. */ retry(): Promise>; }; interface CallAppToolOptions> { /** * Idempotency behavior: * - `true` (default): mints `request_id = crypto.randomUUID()` once per intent and injects * `[requestIdField]: requestId` into tool arguments, preserving it across `.retry()`. * - `false`: read-only call – injects no `request_id` (safe for `.strict()` read schemas) and * classifies transport failures without `uncertain` write warnings. */ readonly idempotent?: boolean; /** Reuse an existing `request_id` for a manual retry. */ readonly requestId?: string; /** Argument key carrying the UUID. Defaults to `"request_id"`. */ readonly requestIdField?: string; /** Per-attempt timeout in milliseconds before entering `uncertain`. Defaults to `15_000`. */ readonly timeoutMs?: number; /** Narrow and validate `result.structuredContent` before reporting `"applied"`. */ readonly guard?: (value: unknown) => value is Output; /** * Error codes in `: ` that prove the server rejected BEFORE writing. * Defaults to `DEFINITIVE_REFUSAL_CODES`. */ readonly definitiveRefusalCodes?: readonly string[]; } interface AppMutationSnapshot { readonly status: "idle" | "busy" | "applied" | "refused" | "uncertain"; readonly busy: boolean; readonly uncertain: boolean; readonly requestId: string | null; readonly input: Input | null; readonly data: Output | null; readonly message: string | null; readonly canRetry: boolean; } interface CreateAppMutationOptions extends Omit, "requestId"> { readonly tool: string; readonly toArguments: (input: Input) => Record; /** Optional mount check (e.g. `() => root.isConnected`); suppresses callbacks after unmount. */ readonly isConnected?: () => boolean; readonly onStateChange?: (snapshot: AppMutationSnapshot) => void; } interface AppMutation> { getSnapshot(): AppMutationSnapshot; /** Start a new user intent (ignored if `busy` is true). Mints a fresh `request_id`. */ run(input: Input): Promise | null>; /** Re-send the pending `uncertain` intent with its original `input` and `request_id`. */ retry(): Promise | null>; /** Explicitly clear `uncertain` / `refused` state (e.g. after a full queue reload). */ reset(): void; } /** * Read and sanitize the server-injected `