import type { InteractionDiagnostic, InvokeOutcome } from "@aotter/mantle-ui/controller"; import type { FormSchema } from "@aotter/mantle-ui"; import type { FieldSchema, LocalizedText } from "@aotter/mantle-ui"; /** Result `_meta` key naming the tool, on results an App renders (`@aotter/mantle/mcp`'s `APP_TOOL_META_KEY`). */ export declare const APP_TOOL_META_KEY = "net.aotter.mantle/tool"; /** The element the host embeds the catalog in (`@aotter/mantle/mcp`'s `APP_CATALOG_ID`). */ export declare const APP_CATALOG_ID = "mantle-catalog"; /** A Procedure tool that acts on one row, as `@aotter/mantle/mcp`'s `appCatalog` describes it. */ export interface AppRowAction { readonly capability: string; readonly title?: LocalizedText; readonly inputSchema: FormSchema; readonly uiSchema?: Readonly>; readonly bind: readonly { readonly input: string; readonly field: string; }[]; readonly version?: string; readonly mutates: boolean; } export interface AppCatalogView { readonly title?: LocalizedText; readonly columns: Readonly>; readonly list: { readonly columns: readonly string[]; }; /** The `actions` a row of this View can open. */ readonly actions: readonly string[]; } /** What the server embedded in the App's HTML: View tool name → its View, Procedure tool name → how it acts on a row. */ export interface AppCatalog { readonly views: Readonly>; readonly actions: Readonly>; } /** A View the catalog does not describe: its rows as they come, nothing to open. */ export declare const BARE_VIEW: AppCatalogView; /** The shape every MCP tool result shares, independent of an SDK. */ export interface ToolResult { readonly content?: readonly { readonly type: string; readonly text?: string; }[]; readonly structuredContent?: Readonly>; readonly isError?: boolean; readonly _meta?: Readonly>; } /** Calls one server tool; the App passes `app.callServerTool`. */ export type CallTool = (name: string, args: Record, signal?: AbortSignal) => Promise; type Row = Readonly>; /** The catalog the host embedded; none is an empty catalog. */ export declare function readCatalog(doc?: Pick): AppCatalog; /** The tool a result came from: the server names it, else the host's tool info. */ export declare function toolOf(result: ToolResult, hostTool?: string): string | null; /** A View result's rows; null for a failure or any other result. */ export declare function rowsOf(result: ToolResult): Row[] | null; /** The cursor of the next page of a View result; undefined on the last page. */ export declare function nextCursorOf(result: ToolResult): string | undefined; /** The diagnostics an `isError` result carries, from either content form. */ export declare function diagnosticsOf(result: ToolResult): InteractionDiagnostic[]; /** * `structuredContent`, else the JSON text block, else the text itself. A * tool with an output schema reports failures in the text block only. */ export declare function outputOf(result: ToolResult): unknown; /** * A tool answer as the controller reads it. `isError` results carry the * runtime's `{ diagnostics }`; a thrown call (transport, host, protocol) is * rethrown, so the controller treats the write as uncertain. */ export declare function invokeTool(call: CallTool, name: string, args: Record, signal: AbortSignal): Promise; /** Inputs the form does not render: row bindings, the version, idempotency keys. */ export declare function hiddenInputs(action: AppRowAction): string[]; export declare function idempotencyInputs(action: AppRowAction): string[]; /** The row actions a row can open: it carries an id, and its version when the action locks one. */ export declare function actionsFor(catalog: AppCatalog, view: AppCatalogView, row: Row): AppRowAction[]; export {};