/** * Streamable Invoke Protocol v1 — Zod schemas. * * Single source of truth for the client→agent invoke turn. Mirrors Anthropic's * Messages streaming format exactly (message_start / content_block_{start,delta,stop} * / message_delta / message_stop / ping / error). UI rendering is expressed as * plain `tool_use` blocks calling the `ggui_render` / `ggui_render_blueprint` * client tools — no ggui-specific block type. * * TS types in types/invoke.ts are derived from these via z.infer. Consumers * (@ggui-ai/server, @ggui-ai/mcp-apps-react) import schemas for runtime validation * and types for authoring. */ import { z } from 'zod'; /** Plain text content — streamed via `text_delta` events. */ export declare const textBlockSchema: z.ZodObject<{ type: z.ZodLiteral<"text">; text: z.ZodString; }, z.core.$strip>; /** Tool call initiated by the agent. Input may arrive via `input_json_delta`. */ export declare const toolUseBlockSchema: z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodRecord; }, z.core.$strip>; /** * Tool execution result (Protocol v1.1). * * Emitted inline on the assistant turn when the server executed a tool on * the agent's behalf (e.g. `ggui_render`, `ggui_handshake`). Clients pair this * with the matching `tool_use` by `tool_use_id` and render — no second * round-trip through a `ggui_render` client tool is needed. * * This extends Anthropic's shape: Anthropic puts `tool_result` in the next * user message, we also allow it on the assistant turn because the server * already has the result. The `content` shape depends on the tool. */ export declare const toolResultBlockSchema: z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodUnknown; is_error: z.ZodOptional; }, z.core.$strip>; /** Discriminated union of every legal content block type. */ export declare const contentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text">; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodRecord; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodUnknown; is_error: z.ZodOptional; }, z.core.$strip>], "type">; export declare const textDeltaSchema: z.ZodObject<{ type: z.ZodLiteral<"text_delta">; text: z.ZodString; }, z.core.$strip>; export declare const inputJsonDeltaSchema: z.ZodObject<{ type: z.ZodLiteral<"input_json_delta">; partial_json: z.ZodString; }, z.core.$strip>; export declare const contentBlockDeltaPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text_delta">; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_json_delta">; partial_json: z.ZodString; }, z.core.$strip>], "type">; /** First event of a turn. */ export declare const messageStartEventSchema: z.ZodObject<{ type: z.ZodLiteral<"message_start">; message: z.ZodObject<{ id: z.ZodString; role: z.ZodLiteral<"assistant">; model: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>; /** A new content block begins. */ export declare const contentBlockStartEventSchema: z.ZodObject<{ type: z.ZodLiteral<"content_block_start">; index: z.ZodNumber; content_block: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text">; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodRecord; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodUnknown; is_error: z.ZodOptional; }, z.core.$strip>], "type">; }, z.core.$strip>; /** Incremental update to the block at `index`. */ export declare const contentBlockDeltaEventSchema: z.ZodObject<{ type: z.ZodLiteral<"content_block_delta">; index: z.ZodNumber; delta: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text_delta">; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_json_delta">; partial_json: z.ZodString; }, z.core.$strip>], "type">; }, z.core.$strip>; /** The block at `index` is complete. */ export declare const contentBlockStopEventSchema: z.ZodObject<{ type: z.ZodLiteral<"content_block_stop">; index: z.ZodNumber; }, z.core.$strip>; /** Final metadata just before the turn ends. */ export declare const messageDeltaEventSchema: z.ZodObject<{ type: z.ZodLiteral<"message_delta">; delta: z.ZodObject<{ stop_reason: z.ZodEnum<{ error: "error"; tool_use: "tool_use"; end_turn: "end_turn"; max_tokens: "max_tokens"; }>; stop_sequence: z.ZodOptional>; }, z.core.$strip>; usage: z.ZodObject<{ input_tokens: z.ZodNumber; output_tokens: z.ZodNumber; }, z.core.$strip>; }, z.core.$strip>; /** Turn is done. No events may follow. */ export declare const messageStopEventSchema: z.ZodObject<{ type: z.ZodLiteral<"message_stop">; }, z.core.$strip>; /** Keep-alive frame. */ export declare const pingEventSchema: z.ZodObject<{ type: z.ZodLiteral<"ping">; }, z.core.$strip>; /** Terminal error. No `message_stop` follows. */ export declare const invokeErrorCodeSchema: z.ZodEnum<{ invalid_request: "invalid_request"; unauthorized: "unauthorized"; rate_limited: "rate_limited"; invoke_in_progress: "invoke_in_progress"; upstream_error: "upstream_error"; tool_error: "tool_error"; internal: "internal"; }>; export declare const errorEventSchema: z.ZodObject<{ type: z.ZodLiteral<"error">; error: z.ZodObject<{ code: z.ZodEnum<{ invalid_request: "invalid_request"; unauthorized: "unauthorized"; rate_limited: "rate_limited"; invoke_in_progress: "invoke_in_progress"; upstream_error: "upstream_error"; tool_error: "tool_error"; internal: "internal"; }>; message: z.ZodString; retryAfterMs: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>; /** * Discriminated union over every event the agent may emit. * * Parsing an incoming SSE frame: * const event = invokeEventSchema.parse(JSON.parse(frame.data)); * switch (event.type) { ... } */ export declare const invokeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"message_start">; message: z.ZodObject<{ id: z.ZodString; role: z.ZodLiteral<"assistant">; model: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"content_block_start">; index: z.ZodNumber; content_block: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text">; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodRecord; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodUnknown; is_error: z.ZodOptional; }, z.core.$strip>], "type">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"content_block_delta">; index: z.ZodNumber; delta: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"text_delta">; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"input_json_delta">; partial_json: z.ZodString; }, z.core.$strip>], "type">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"content_block_stop">; index: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"message_delta">; delta: z.ZodObject<{ stop_reason: z.ZodEnum<{ error: "error"; tool_use: "tool_use"; end_turn: "end_turn"; max_tokens: "max_tokens"; }>; stop_sequence: z.ZodOptional>; }, z.core.$strip>; usage: z.ZodObject<{ input_tokens: z.ZodNumber; output_tokens: z.ZodNumber; }, z.core.$strip>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"message_stop">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"ping">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"error">; error: z.ZodObject<{ code: z.ZodEnum<{ invalid_request: "invalid_request"; unauthorized: "unauthorized"; rate_limited: "rate_limited"; invoke_in_progress: "invoke_in_progress"; upstream_error: "upstream_error"; tool_error: "tool_error"; internal: "internal"; }>; message: z.ZodString; retryAfterMs: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>], "type">; /** * A prior conversation turn. Content is either a plain text shortcut or a * structured content block sequence (mirrors Anthropic's `messages[].content`). */ export declare const invokeTurnSchema: z.ZodObject<{ role: z.ZodEnum<{ user: "user"; assistant: "assistant"; }>; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodRecord; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodUnknown; is_error: z.ZodOptional; }, z.core.$strip>], "type">>]>; }, z.core.$strip>; /** * POST body shape for `{endpointUrl}/invoke`. * * Stateless by default — client holds history, sends full `history[]` every * turn. Agents that need server-side memory layer their own keyed on * `X-Ggui-Host-Session-Id`. */ export declare const invokeRequestSchema: z.ZodObject<{ message: z.ZodString; history: z.ZodOptional; content: z.ZodUnion; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_use">; id: z.ZodString; name: z.ZodString; input: z.ZodRecord; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result">; tool_use_id: z.ZodString; content: z.ZodUnknown; is_error: z.ZodOptional; }, z.core.$strip>], "type">>]>; }, z.core.$strip>>>; interfaceContext: z.ZodOptional; platform: z.ZodEnum<{ web: "web"; desktop: "desktop"; mobile: "mobile"; }>; deviceType: z.ZodEnum<{ desktop: "desktop"; tablet: "tablet"; phone: "phone"; }>; orientation: z.ZodEnum<{ portrait: "portrait"; landscape: "landscape"; }>; devicePixelRatio: z.ZodOptional; touchPrimary: z.ZodOptional; shellType: z.ZodOptional>; colorScheme: z.ZodOptional>; reducedMotion: z.ZodOptional; }, z.core.$loose>>; requestId: z.ZodOptional; }, z.core.$strip>; //# sourceMappingURL=invoke.d.ts.map