/** * The agents transport: the `GET /api/agents` list schema and the * `POST /api/agents/{name}/runs` streaming run, plus the zod discriminated union * over the agent `StreamEvent` taxonomy. * * This is a SELF-CONTAINED api-client module (its own zod, not the shared * `schemas.ts`), so the agents feature owns its wire types end to end. The * `createApiClient` object wires two thin methods onto it (`listAgents`, * `streamAgentRun`) since only it holds the `ApiConfig` (base URL + auth token). * * Frame discriminator: every event carries a stable `type`, which is also the * client's switch. A frame whose `type` is unknown (a newer server event) is * NEVER dropped — it is surfaced as an `unknown` parsed event so the UI can show * it verbatim; a malformed frame is surfaced the same way rather than crashing * the stream. */ import { z } from 'zod'; import { type ApiConfig } from './http'; import { type SseFrame } from './sse'; /** One registered agent as `GET /api/agents` returns it. */ export declare const agentSummary: z.ZodObject<{ name: z.ZodString; description: z.ZodDefault; tool_name: z.ZodString; input_schema: z.ZodDefault>; spec_runnable: z.ZodDefault; }, z.core.$strip>; export declare const agentList: z.ZodObject<{ items: z.ZodArray; tool_name: z.ZodString; input_schema: z.ZodDefault>; spec_runnable: z.ZodDefault; }, z.core.$strip>>; total: z.ZodNumber; }, z.core.$strip>; export type AgentSummary = z.infer; /** The discriminated union of every KNOWN agent frame. */ export declare const agentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ type: z.ZodLiteral<"reasoning_step">; final: z.ZodDefault; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_call_step">; final: z.ZodDefault; tool: z.ZodString; args: z.ZodDefault>; call_id: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"tool_result_step">; final: z.ZodDefault; tool: z.ZodString; call_id: z.ZodString; result: z.ZodOptional; is_error: z.ZodDefault; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"message_delta">; final: z.ZodDefault; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"message_final">; final: z.ZodDefault; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"run_usage">; final: z.ZodDefault; input_tokens: z.ZodDefault>; output_tokens: z.ZodDefault>; total_tokens: z.ZodDefault>; model: z.ZodDefault>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"structured_final">; final: z.ZodDefault; data: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"interrupt_final">; final: z.ZodDefault; interrupt_id: z.ZodString; payload: z.ZodOptional; reason: z.ZodDefault>; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"stream.end">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"stream.error">; message: z.ZodString; }, z.core.$strip>], "type">; /** A known, validated agent frame. */ export type AgentEvent = z.infer; /** * A frame the client could not validate against a known event — an unrecognized * `type` (forward-compat) or a malformed payload. It is kept, never dropped, so * the UI renders it visibly as a labeled raw row. */ export interface UnknownAgentEvent { readonly type: string; readonly raw: unknown; } /** The result of parsing one SSE frame: a known event or an `unknown` fallback. */ export type ParsedAgentEvent = { readonly known: true; readonly event: AgentEvent; } | { readonly known: false; readonly unknown: UnknownAgentEvent; }; /** * Parse one SSE frame's `data` into a typed event. Unparseable JSON, a * non-object payload, an unknown `type`, or a payload that fails its schema all * resolve to an `unknown` fallback (visible, never silently skipped) rather than * throwing and tearing down the stream. */ export declare function parseAgentFrame(frame: SseFrame): ParsedAgentEvent; /** Stream a plain registered agent's run (`POST /api/agents/{name}/runs`). */ export declare function streamAgentRun(config: ApiConfig, name: string, input: unknown, signal?: AbortSignal): Promise>; /** * Stream an AUTHORED agent's run (`POST /api/agents/authored/{name}/runs`). Same * SSE framing as `streamAgentRun`; the baked spec is resolved server-side, so the * POST body carries ONLY the non-baked `ToolInput` fields (the actual query/user * input). Naming a baked field is a loud server 400, surfaced by the caller. */ export declare function streamAuthoredAgentRun(config: ApiConfig, name: string, input: unknown, signal?: AbortSignal): Promise>; /** * Parse a whole hand-authored SSE transcript into its ordered parsed events. * Reuses the wire `SseFrameParser`, so a test fixture exercises the real * frame-splitting + event-parsing path end to end. */ export declare function parseAgentTranscript(transcript: string): ParsedAgentEvent[]; //# sourceMappingURL=agents.d.ts.map