@ag-ui/core 0.0.59 → 1.0.0-canary.1789569879.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["z","z","z","z"],"sources":["../src/metadata.ts","../src/types.ts","../src/capabilities.ts","../src/events.ts","../src/token-usage.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/**\n * The key reserved for AG-UI's own use inside a metadata object. Every other\n * key is user space.\n *\n * Reservation is by convention: nothing rejects a write to this key at runtime,\n * because metadata is open by key and validating its shape would contradict\n * that.\n */\nexport const AGUI_METADATA_KEY = \"ag-ui\";\n\n/**\n * Extra information attached to an event or a message.\n *\n * Open by key — any JSON value is allowed under a key, including `null`.\n *\n * Deliberately `z.any()` rather than a recursive JSON-value schema, which review\n * has suggested more than once. Two reasons. Every dynamic payload in the\n * protocol uses the permissive form — `state`, `rawEvent`, `CustomEvent.value`,\n * `ActivityMessage.content`, and the pre-existing `Tool.metadata` and\n * `Interrupt.metadata` — so tightening this one field would make it the sole\n * outlier while fixing nothing elsewhere. And a recursive validation would walk\n * every value on every event, on the streaming hot path, to catch a mistake\n * (a function, a bigint) that already fails loudly at encode time.\n *\n * One consequence worth knowing: `z.record` drops an own `__proto__` key, which\n * is its prototype-pollution guard. Preserving it would need null-prototype\n * objects throughout parsing and protobuf conversion, handing every consumer\n * objects where `hasOwnProperty` throws — a real cost for a key that is\n * essentially only ever an attack probe. Python keeps it; TypeScript does not.\n */\nexport const MetadataSchema = z.record(z.any());\n\nexport type Metadata = z.infer<typeof MetadataSchema>;\n\n/**\n * How metadata is declared on events and messages.\n *\n * The object itself is absent or an object, never `null` — and parsing\n * enforces that invariant rather than coercing a `null` to absent.\n *\n * This is deliberately NOT the treatment `parentMessageId` and `outcome`\n * receive in `events.ts`. Those tolerate `null` because released producers\n * emitted it before the producer-side omission fix, and rejecting it would\n * break agents already in the wild. Metadata has no such history: it postdates\n * the fix that makes every official producer omit fields with no value, and no\n * released Python or .NET package has ever emitted `\"metadata\": null`. Adding\n * a tolerance here would grandfather in a fourth exception with nobody to\n * protect; enforcing from day one means there is never anything to retire.\n *\n * A `null` *value under a key* is meaningful data and is preserved. Only a\n * `null` in place of the whole object is a contract violation.\n */\nexport const OptionalMetadataSchema = MetadataSchema.optional();\n\n/**\n * Folds `incoming` metadata into `existing`, key by key, with the last write\n * winning.\n *\n * A message is assembled from a sequence of events, and the interesting values\n * — token usage and finish reason among them — are only known at the end. So\n * metadata accumulates as the sequence arrives rather than being fixed at the\n * start.\n *\n * A key's value is replaced outright. This never recurses, so an array or\n * object under any key — including {@link AGUI_METADATA_KEY} — is replaced\n * wholesale rather than blended with what was there before.\n *\n * Returns a new object rather than mutating either argument. An absent\n * `incoming` returns `existing` untouched; an empty `incoming` changes nothing.\n */\nexport function mergeMetadata(\n existing: Metadata | undefined,\n incoming: Metadata | undefined,\n): Metadata | undefined {\n if (incoming === undefined) {\n return existing;\n }\n if (existing === undefined) {\n return { ...incoming };\n }\n return { ...existing, ...incoming };\n}\n","import { z } from \"zod\";\nimport { OptionalMetadataSchema } from \"./metadata\";\n\nexport const FunctionCallSchema = z.object({\n name: z.string(),\n arguments: z.string(),\n});\n\nexport const ToolCallSchema = z.object({\n id: z.string(),\n type: z.literal(\"function\"),\n function: FunctionCallSchema,\n encryptedValue: z.string().optional(),\n // A tool call is not a message, so it carries its own metadata rather than\n // folding into the assistant message that owns it. Several tool calls can\n // share one parent, and merging them all into it would make the result depend\n // on their relative order — which stream transforms like `compactEvents` are\n // free to change.\n metadata: OptionalMetadataSchema,\n});\n\nexport const BaseMessageSchema = z.object({\n id: z.string(),\n role: z.string(),\n content: z.string().optional(),\n name: z.string().optional(),\n encryptedValue: z.string().optional(),\n subagentRunId: z.string().optional(),\n metadata: OptionalMetadataSchema,\n});\n\nexport const TextInputContentSchema = z.object({\n type: z.literal(\"text\"),\n text: z.string(),\n});\n\nexport const InputContentDataSourceSchema = z.object({\n type: z.literal(\"data\"),\n value: z.string(),\n mimeType: z.string(),\n});\n\nexport const InputContentUrlSourceSchema = z.object({\n type: z.literal(\"url\"),\n value: z.string(),\n mimeType: z.string().optional(),\n});\n\nexport const InputContentSourceSchema = z.discriminatedUnion(\"type\", [\n InputContentDataSourceSchema,\n InputContentUrlSourceSchema,\n]);\n\nexport const ImageInputContentSchema = z.object({\n type: z.literal(\"image\"),\n source: InputContentSourceSchema,\n metadata: z.unknown().optional(),\n});\n\nexport const AudioInputContentSchema = z.object({\n type: z.literal(\"audio\"),\n source: InputContentSourceSchema,\n metadata: z.unknown().optional(),\n});\n\nexport const VideoInputContentSchema = z.object({\n type: z.literal(\"video\"),\n source: InputContentSourceSchema,\n metadata: z.unknown().optional(),\n});\n\nexport const DocumentInputContentSchema = z.object({\n type: z.literal(\"document\"),\n source: InputContentSourceSchema,\n metadata: z.unknown().optional(),\n});\n\nexport const ImageInputPartSchema = ImageInputContentSchema;\nexport const AudioInputPartSchema = AudioInputContentSchema;\nexport const VideoInputPartSchema = VideoInputContentSchema;\nexport const DocumentInputPartSchema = DocumentInputContentSchema;\n\nconst LegacyBinaryInputContentObjectSchema = z.object({\n type: z.literal(\"binary\"),\n mimeType: z.string(),\n id: z.string().optional(),\n url: z.string().optional(),\n data: z.string().optional(),\n filename: z.string().optional(),\n});\n\nconst ensureBinaryPayload = (\n value: { id?: string; url?: string; data?: string },\n ctx: z.RefinementCtx,\n) => {\n if (!value.id && !value.url && !value.data) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: \"BinaryInputContent requires at least one of id, url, or data.\",\n path: [\"id\"],\n });\n }\n};\n\nexport const BinaryInputContentSchema = LegacyBinaryInputContentObjectSchema.superRefine(\n (value, ctx) => {\n ensureBinaryPayload(value, ctx);\n },\n);\n\nconst InputContentBaseSchema = z.discriminatedUnion(\"type\", [\n TextInputContentSchema,\n ImageInputContentSchema,\n AudioInputContentSchema,\n VideoInputContentSchema,\n DocumentInputContentSchema,\n LegacyBinaryInputContentObjectSchema,\n]);\n\nexport const InputContentSchema = InputContentBaseSchema.superRefine((value, ctx) => {\n if (value.type === \"binary\") {\n ensureBinaryPayload(value, ctx);\n }\n});\n\nexport const DeveloperMessageSchema = BaseMessageSchema.extend({\n role: z.literal(\"developer\"),\n content: z.string(),\n});\n\nexport const SystemMessageSchema = BaseMessageSchema.extend({\n role: z.literal(\"system\"),\n content: z.string(),\n});\n\nexport const AssistantMessageSchema = BaseMessageSchema.extend({\n role: z.literal(\"assistant\"),\n content: z.string().optional(),\n toolCalls: z.array(ToolCallSchema).optional(),\n});\n\nexport const UserMessageSchema = BaseMessageSchema.extend({\n role: z.literal(\"user\"),\n content: z.union([z.string(), z.array(InputContentSchema)]),\n});\n\n// The three schemas below stand alone rather than extending BaseMessageSchema,\n// so each declares `metadata` itself.\nexport const ToolMessageSchema = z.object({\n id: z.string(),\n content: z.string(),\n role: z.literal(\"tool\"),\n toolCallId: z.string(),\n error: z.string().optional(),\n encryptedValue: z.string().optional(),\n subagentRunId: z.string().optional(),\n metadata: OptionalMetadataSchema,\n});\n\nexport const ActivityMessageSchema = z.object({\n id: z.string(),\n role: z.literal(\"activity\"),\n activityType: z.string(),\n content: z.record(z.any()),\n subagentRunId: z.string().optional(),\n metadata: OptionalMetadataSchema,\n});\n\nexport const ReasoningMessageSchema = z.object({\n id: z.string(),\n role: z.literal(\"reasoning\"),\n content: z.string(),\n encryptedValue: z.string().optional(),\n subagentRunId: z.string().optional(),\n metadata: OptionalMetadataSchema,\n});\n\nexport const MessageSchema = z.discriminatedUnion(\"role\", [\n DeveloperMessageSchema,\n SystemMessageSchema,\n AssistantMessageSchema,\n UserMessageSchema,\n ToolMessageSchema,\n ActivityMessageSchema,\n ReasoningMessageSchema,\n]);\n\nexport const RoleSchema = z.union([\n z.literal(\"developer\"),\n z.literal(\"system\"),\n z.literal(\"assistant\"),\n z.literal(\"user\"),\n z.literal(\"tool\"),\n z.literal(\"activity\"),\n z.literal(\"reasoning\"),\n]);\n\nexport const ContextSchema = z.object({\n description: z.string(),\n value: z.string(),\n});\n\nexport const ToolSchema = z.object({\n name: z.string(),\n description: z.string(),\n parameters: z.any(), // JSON Schema for the tool parameters\n metadata: z.record(z.any()).optional(), // Arbitrary tool metadata (e.g. a2ui schema)\n});\n\nexport const InterruptSchema = z.object({\n id: z.string(),\n reason: z.string(),\n message: z.string().optional(),\n toolCallId: z.string().optional(),\n responseSchema: z.record(z.any()).optional(),\n expiresAt: z.string().optional(),\n metadata: z.record(z.any()).optional(),\n // The subagent whose work raised this interrupt, when it was raised inside\n // one — absent for a root-raised interrupt. Attribution lives on each\n // interrupt rather than on RUN_FINISHED because one run can carry\n // interrupts from several subagents. Lets a client render the approval\n // request inside that subagent's group without correlating the legacy\n // on_interrupt CUSTOM event by ordering.\n subagentRunId: z.string().optional(),\n});\n\nexport const ResumeEntrySchema = z.object({\n interruptId: z.string(),\n status: z.enum([\"resolved\", \"cancelled\"]),\n payload: z.any().optional(),\n // Envelope data about the response — signatures, routing keys — as opposed to\n // `payload`, which is the answer the agent asked for and will act on.\n metadata: OptionalMetadataSchema,\n});\n\nexport const RunAgentInputSchema = z.object({\n threadId: z.string(),\n runId: z.string(),\n parentRunId: z.string().optional(),\n // Optional by contract: absent means \"no state\", and a bare null reads as\n // absent — every consumer collapses the two, and .NET's representation cannot\n // tell them apart, so omission is the one spelling all SDKs share. This is\n // the coerce pattern (not metadata's reject) because hand-rolled clients\n // sending \"state\": null plausibly exist. Nulls INSIDE state are values.\n state: z.any().transform((v) => v ?? undefined),\n messages: z.array(MessageSchema),\n tools: z.array(ToolSchema),\n context: z.array(ContextSchema),\n forwardedProps: z.any(),\n resume: z.array(ResumeEntrySchema).optional(),\n});\n\nexport const StateSchema = z.any();\n\nexport type ToolCall = z.infer<typeof ToolCallSchema>;\nexport type FunctionCall = z.infer<typeof FunctionCallSchema>;\nexport type TextInputContent = z.infer<typeof TextInputContentSchema>;\nexport type InputContentDataSource = z.infer<typeof InputContentDataSourceSchema>;\nexport type InputContentUrlSource = z.infer<typeof InputContentUrlSourceSchema>;\nexport type InputContentSource = z.infer<typeof InputContentSourceSchema>;\nexport type ImageInputContent = z.infer<typeof ImageInputContentSchema>;\nexport type AudioInputContent = z.infer<typeof AudioInputContentSchema>;\nexport type VideoInputContent = z.infer<typeof VideoInputContentSchema>;\nexport type DocumentInputContent = z.infer<typeof DocumentInputContentSchema>;\nexport type ImageInputPart = ImageInputContent;\nexport type AudioInputPart = AudioInputContent;\nexport type VideoInputPart = VideoInputContent;\nexport type DocumentInputPart = DocumentInputContent;\nexport type BinaryInputContent = z.infer<typeof BinaryInputContentSchema>;\nexport type InputContent = z.infer<typeof InputContentSchema>;\nexport type InputContentPart = z.infer<typeof InputContentSchema>;\nexport type DeveloperMessage = z.infer<typeof DeveloperMessageSchema>;\nexport type SystemMessage = z.infer<typeof SystemMessageSchema>;\nexport type AssistantMessage = z.infer<typeof AssistantMessageSchema>;\nexport type UserMessage = z.infer<typeof UserMessageSchema>;\nexport type ToolMessage = z.infer<typeof ToolMessageSchema>;\nexport type ActivityMessage = z.infer<typeof ActivityMessageSchema>;\nexport type ReasoningMessage = z.infer<typeof ReasoningMessageSchema>;\nexport type Message = z.infer<typeof MessageSchema>;\nexport type Context = z.infer<typeof ContextSchema>;\nexport type Tool = z.infer<typeof ToolSchema>;\nexport type RunAgentInput = z.infer<typeof RunAgentInputSchema>;\nexport type State = z.infer<typeof StateSchema>;\nexport type Role = z.infer<typeof RoleSchema>;\nexport type Interrupt = z.infer<typeof InterruptSchema>;\nexport type ResumeEntry = z.infer<typeof ResumeEntrySchema>;\nexport type ResumeStatus = z.infer<typeof ResumeEntrySchema>[\"status\"];\n\nexport class AGUIError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n\nexport class AGUIConnectNotImplementedError extends AGUIError {\n constructor() {\n super(\"Connect not implemented. This method is not supported by the current agent.\");\n }\n}\n","import { z } from \"zod\";\nimport { ToolSchema } from \"./types\";\n\n/** Describes a sub-agent that can be invoked by a parent agent. */\nexport const SubAgentInfoSchema = z.object({\n /** Unique name or identifier of the sub-agent. */\n name: z.string(),\n /** What this sub-agent specializes in. Helps clients build agent selection UIs. */\n description: z.string().optional(),\n});\n\n/**\n * Basic metadata about the agent. Useful for discovery UIs, agent marketplaces,\n * and debugging. Set these when you want clients to display agent information\n * or when multiple agents are available and users need to pick one.\n */\nexport const IdentityCapabilitiesSchema = z.object({\n /** Human-readable name shown in UIs and agent selectors. */\n name: z.string().optional(),\n /** The framework or platform powering this agent (e.g., \"langgraph\", \"mastra\", \"crewai\"). */\n type: z.string().optional(),\n /** What this agent does — helps users and routing logic decide when to use it. */\n description: z.string().optional(),\n /** Semantic version of the agent (e.g., \"1.2.0\"). Useful for compatibility checks. */\n version: z.string().optional(),\n /** Organization or team that maintains this agent. */\n provider: z.string().optional(),\n /** URL to the agent's documentation or homepage. */\n documentationUrl: z.string().optional(),\n /** Arbitrary key-value pairs for integration-specific identity info. */\n metadata: z.record(z.unknown()).optional(),\n});\n\n/**\n * Declares which transport mechanisms the agent supports. Clients use this\n * to pick the best connection strategy. Only set flags to `true` for transports\n * your agent actually handles — omit or set `false` for unsupported ones.\n */\nexport const TransportCapabilitiesSchema = z.object({\n /** Set `true` if the agent streams responses via SSE. Most agents enable this. */\n streaming: z.boolean().optional(),\n /** Set `true` if the agent accepts persistent WebSocket connections. */\n websocket: z.boolean().optional(),\n /** Set `true` if the agent supports the AG-UI binary protocol (protobuf over HTTP). */\n httpBinary: z.boolean().optional(),\n /** Set `true` if the agent can send async updates via webhooks after a run finishes. */\n pushNotifications: z.boolean().optional(),\n /** Set `true` if the agent supports resuming interrupted streams via sequence numbers. */\n resumable: z.boolean().optional(),\n});\n\n/**\n * Tool calling capabilities. Distinguishes between tools the agent itself provides\n * (listed in `items`) and tools the client passes at runtime via `RunAgentInput.tools`.\n * Enable this when your agent can call functions, search the web, execute code, etc.\n */\nexport const ToolsCapabilitiesSchema = z.object({\n /** Set `true` if the agent can make tool calls at all. Set `false` to explicitly\n * signal tool calling is disabled even if items are present. */\n supported: z.boolean().optional(),\n /** The tools this agent provides on its own (full JSON Schema definitions).\n * These are distinct from client-provided tools passed in `RunAgentInput.tools`. */\n items: z.array(ToolSchema).optional(),\n /** Set `true` if the agent can invoke multiple tools concurrently within a single step. */\n parallelCalls: z.boolean().optional(),\n /** Set `true` if the agent accepts and uses tools provided by the client at runtime. */\n clientProvided: z.boolean().optional(),\n});\n\n/**\n * Output format support. Enable `structuredOutput` when your agent can return\n * responses conforming to a JSON schema, which is useful for programmatic consumption.\n */\nexport const OutputCapabilitiesSchema = z.object({\n /** Set `true` if the agent can produce structured JSON output matching a provided schema. */\n structuredOutput: z.boolean().optional(),\n /** MIME types the agent can produce (e.g., `[\"text/plain\", \"application/json\"]`).\n * Omit if the agent only produces plain text. */\n supportedMimeTypes: z.array(z.string()).optional(),\n});\n\n/**\n * State and memory management capabilities. These tell the client how the agent\n * handles shared state and whether conversation context persists across runs.\n */\nexport const StateCapabilitiesSchema = z.object({\n /** Set `true` if the agent emits `STATE_SNAPSHOT` events (full state replacement). */\n snapshots: z.boolean().optional(),\n /** Set `true` if the agent emits `STATE_DELTA` events (JSON Patch incremental updates). */\n deltas: z.boolean().optional(),\n /** Set `true` if the agent has long-term memory beyond the current thread\n * (e.g., vector store, knowledge base, or cross-session recall). */\n memory: z.boolean().optional(),\n /** Set `true` if state is preserved across multiple runs within the same thread.\n * When `false`, state resets on each run. */\n persistentState: z.boolean().optional(),\n});\n\n/**\n * Multi-agent coordination capabilities. Enable these when your agent can\n * orchestrate or hand off work to other agents.\n */\nexport const MultiAgentCapabilitiesSchema = z.object({\n /** Set `true` if the agent participates in any form of multi-agent coordination. */\n supported: z.boolean().optional(),\n /** Set `true` if the agent can delegate subtasks to other agents while retaining control. */\n delegation: z.boolean().optional(),\n /** Set `true` if the agent can transfer the conversation entirely to another agent. */\n handoffs: z.boolean().optional(),\n /** List of sub-agents this agent can invoke. Helps clients build agent selection UIs. */\n subAgents: z.array(SubAgentInfoSchema).optional(),\n});\n\n/**\n * Reasoning and thinking capabilities. Enable these when your agent exposes its\n * internal thought process (e.g., chain-of-thought, extended thinking).\n */\nexport const ReasoningCapabilitiesSchema = z.object({\n /** Set `true` if the agent produces reasoning/thinking tokens visible to the client. */\n supported: z.boolean().optional(),\n /** Set `true` if reasoning tokens are streamed incrementally (vs. returned all at once). */\n streaming: z.boolean().optional(),\n /** Set `true` if reasoning content is encrypted (zero-data-retention mode).\n * Clients should expect opaque `encryptedValue` fields instead of readable content. */\n encrypted: z.boolean().optional(),\n});\n\n/**\n * Modalities the agent can accept as input. Clients use this to show/hide\n * file upload buttons, audio recorders, image pickers, etc.\n */\nexport const MultimodalInputCapabilitiesSchema = z.object({\n /** Set `true` if the agent can process image inputs (e.g., screenshots, photos). */\n image: z.boolean().optional(),\n /** Set `true` if the agent can process audio inputs (speech, recordings). */\n audio: z.boolean().optional(),\n /** Set `true` if the agent can process video inputs. */\n video: z.boolean().optional(),\n /** Set `true` if the agent can process PDF documents. */\n pdf: z.boolean().optional(),\n /** Set `true` if the agent can process arbitrary file uploads. */\n file: z.boolean().optional(),\n});\n\n/**\n * Modalities the agent can produce as output. Clients use this to anticipate\n * rich content in the agent's response.\n */\nexport const MultimodalOutputCapabilitiesSchema = z.object({\n /** Set `true` if the agent can generate images as part of its response. */\n image: z.boolean().optional(),\n /** Set `true` if the agent can produce audio output (text-to-speech, audio files). */\n audio: z.boolean().optional(),\n});\n\n/**\n * Multimodal input and output support. Organized into `input` and `output`\n * sub-objects so clients can independently query what the agent accepts\n * versus what it produces.\n */\nexport const MultimodalCapabilitiesSchema = z.object({\n /** Modalities the agent can accept as input (images, audio, video, PDFs, files). */\n input: MultimodalInputCapabilitiesSchema.optional(),\n /** Modalities the agent can produce as output (images, audio). */\n output: MultimodalOutputCapabilitiesSchema.optional(),\n});\n\n/**\n * Execution control and limits. Declare these so clients can set expectations\n * about how long or how many steps an agent run might take.\n */\nexport const ExecutionCapabilitiesSchema = z.object({\n /** Set `true` if the agent can execute code (e.g., Python, JavaScript) during a run. */\n codeExecution: z.boolean().optional(),\n /** Set `true` if code execution happens in a sandboxed/isolated environment.\n * Only meaningful when `codeExecution` is `true`. */\n sandboxed: z.boolean().optional(),\n /** Maximum number of tool-call/reasoning iterations the agent will perform per run.\n * Helps clients display progress or set timeout expectations. */\n maxIterations: z.number().optional(),\n /** Maximum wall-clock time (in milliseconds) the agent will run before timing out. */\n maxExecutionTime: z.number().optional(),\n});\n\n/**\n * Human-in-the-loop interaction support. Enable these when your agent can pause\n * execution to request human input, approval, or feedback before continuing.\n */\nexport const HumanInTheLoopCapabilitiesSchema = z.object({\n /** Set `true` if the agent supports any form of human-in-the-loop interaction. */\n supported: z.boolean().optional(),\n /** Set `true` if the agent can pause and request explicit approval before\n * performing sensitive actions (e.g., sending emails, deleting data). */\n approvals: z.boolean().optional(),\n /** Set `true` if the agent allows humans to intervene and modify its plan mid-execution. */\n interventions: z.boolean().optional(),\n /** Set `true` if the agent can incorporate user feedback (thumbs up/down, corrections)\n * to improve its behavior within the current session. */\n feedback: z.boolean().optional(),\n /** Set `true` if the agent participates in the AG-UI interrupt protocol\n * (emits RUN_FINISHED with outcome={ type: \"interrupt\", interrupts: [...] },\n * accepts resume[]). */\n interrupts: z.boolean().optional(),\n /** Set `true` if tool-call interrupts accept editedArgs in the resume payload.\n * Only meaningful when interrupts is true. */\n approveWithEdits: z.boolean().optional(),\n});\n\n/**\n * A typed, categorized snapshot of an agent's current capabilities.\n * Returned by `getCapabilities()` on `AbstractAgent`.\n *\n * All fields are optional — agents only declare what they support.\n * Omitted fields mean the capability is not declared (unknown), not that\n * it's unsupported.\n *\n * The `custom` field is an escape hatch for integration-specific capabilities\n * that don't fit into the standard categories.\n */\nexport const AgentCapabilitiesSchema = z.object({\n /** Agent identity and metadata. */\n identity: IdentityCapabilitiesSchema.optional(),\n /** Supported transport mechanisms (SSE, WebSocket, binary, etc.). */\n transport: TransportCapabilitiesSchema.optional(),\n /** Tools the agent provides and tool calling configuration. */\n tools: ToolsCapabilitiesSchema.optional(),\n /** Output format support (structured output, MIME types). */\n output: OutputCapabilitiesSchema.optional(),\n /** State and memory management (snapshots, deltas, persistence). */\n state: StateCapabilitiesSchema.optional(),\n /** Multi-agent coordination (delegation, handoffs, sub-agents). */\n multiAgent: MultiAgentCapabilitiesSchema.optional(),\n /** Reasoning and thinking support (chain-of-thought, encrypted thinking). */\n reasoning: ReasoningCapabilitiesSchema.optional(),\n /** Multimodal input/output support (images, audio, video, files). */\n multimodal: MultimodalCapabilitiesSchema.optional(),\n /** Execution control and limits (code execution, timeouts, iteration caps). */\n execution: ExecutionCapabilitiesSchema.optional(),\n /** Human-in-the-loop support (approvals, interventions, feedback). */\n humanInTheLoop: HumanInTheLoopCapabilitiesSchema.optional(),\n /** Integration-specific capabilities not covered by the standard categories. */\n custom: z.record(z.unknown()).optional(),\n});\n\n/** Describes a sub-agent that can be invoked by a parent agent. */\nexport type SubAgentInfo = z.infer<typeof SubAgentInfoSchema>;\n/** Agent identity and metadata for discovery UIs, marketplaces, and debugging. */\nexport type IdentityCapabilities = z.infer<typeof IdentityCapabilitiesSchema>;\n/** Supported transport mechanisms (SSE, WebSocket, binary protocol, push notifications). */\nexport type TransportCapabilities = z.infer<typeof TransportCapabilitiesSchema>;\n/** Tool calling support and agent-provided tool definitions. */\nexport type ToolsCapabilities = z.infer<typeof ToolsCapabilitiesSchema>;\n/** Output format support (structured output, MIME types). */\nexport type OutputCapabilities = z.infer<typeof OutputCapabilitiesSchema>;\n/** State and memory management (snapshots, deltas, persistence, long-term memory). */\nexport type StateCapabilities = z.infer<typeof StateCapabilitiesSchema>;\n/** Multi-agent coordination (delegation, handoffs, sub-agent orchestration). */\nexport type MultiAgentCapabilities = z.infer<typeof MultiAgentCapabilitiesSchema>;\n/** Reasoning and thinking visibility (streaming, encrypted chain-of-thought). */\nexport type ReasoningCapabilities = z.infer<typeof ReasoningCapabilitiesSchema>;\n/** Modalities the agent can accept as input (images, audio, video, PDFs, files). */\nexport type MultimodalInputCapabilities = z.infer<typeof MultimodalInputCapabilitiesSchema>;\n/** Modalities the agent can produce as output (images, audio). */\nexport type MultimodalOutputCapabilities = z.infer<typeof MultimodalOutputCapabilitiesSchema>;\n/** Multimodal input/output support (images, audio, video, PDFs, file uploads). */\nexport type MultimodalCapabilities = z.infer<typeof MultimodalCapabilitiesSchema>;\n/** Execution control and limits (code execution, sandboxing, iteration caps, timeouts). */\nexport type ExecutionCapabilities = z.infer<typeof ExecutionCapabilitiesSchema>;\n/** Human-in-the-loop interaction support (approvals, interventions, feedback). */\nexport type HumanInTheLoopCapabilities = z.infer<typeof HumanInTheLoopCapabilitiesSchema>;\n/** A typed, categorized snapshot of an agent's current capabilities. Returned by `getCapabilities()`. */\nexport type AgentCapabilities = z.infer<typeof AgentCapabilitiesSchema>;\n","import { z } from \"zod\";\nimport { MessageSchema, StateSchema, RunAgentInputSchema, InterruptSchema } from \"./types\";\nimport { OptionalMetadataSchema } from \"./metadata\";\n\n// Text messages can have any role except \"tool\"\nconst TextMessageRoleSchema = z.union([\n z.literal(\"developer\"),\n z.literal(\"system\"),\n z.literal(\"assistant\"),\n z.literal(\"user\"),\n]);\n\nexport enum EventType {\n TEXT_MESSAGE_START = \"TEXT_MESSAGE_START\",\n TEXT_MESSAGE_CONTENT = \"TEXT_MESSAGE_CONTENT\",\n TEXT_MESSAGE_END = \"TEXT_MESSAGE_END\",\n TEXT_MESSAGE_CHUNK = \"TEXT_MESSAGE_CHUNK\",\n TOOL_CALL_START = \"TOOL_CALL_START\",\n TOOL_CALL_ARGS = \"TOOL_CALL_ARGS\",\n TOOL_CALL_END = \"TOOL_CALL_END\",\n TOOL_CALL_CHUNK = \"TOOL_CALL_CHUNK\",\n TOOL_CALL_RESULT = \"TOOL_CALL_RESULT\",\n /**\n * @deprecated Use REASONING_START instead. Will be removed in 1.0.0.\n */\n THINKING_START = \"THINKING_START\",\n /**\n * @deprecated Use REASONING_END instead. Will be removed in 1.0.0.\n */\n THINKING_END = \"THINKING_END\",\n /**\n * @deprecated Use REASONING_MESSAGE_START instead. Will be removed in 1.0.0.\n */\n THINKING_TEXT_MESSAGE_START = \"THINKING_TEXT_MESSAGE_START\",\n /**\n * @deprecated Use REASONING_MESSAGE_CONTENT instead. Will be removed in 1.0.0.\n */\n THINKING_TEXT_MESSAGE_CONTENT = \"THINKING_TEXT_MESSAGE_CONTENT\",\n /**\n * @deprecated Use REASONING_MESSAGE_END instead. Will be removed in 1.0.0.\n */\n THINKING_TEXT_MESSAGE_END = \"THINKING_TEXT_MESSAGE_END\",\n STATE_SNAPSHOT = \"STATE_SNAPSHOT\",\n STATE_DELTA = \"STATE_DELTA\",\n MESSAGES_SNAPSHOT = \"MESSAGES_SNAPSHOT\",\n ACTIVITY_SNAPSHOT = \"ACTIVITY_SNAPSHOT\",\n ACTIVITY_DELTA = \"ACTIVITY_DELTA\",\n RAW = \"RAW\",\n CUSTOM = \"CUSTOM\",\n RUN_STARTED = \"RUN_STARTED\",\n RUN_FINISHED = \"RUN_FINISHED\",\n RUN_ERROR = \"RUN_ERROR\",\n STEP_STARTED = \"STEP_STARTED\",\n STEP_FINISHED = \"STEP_FINISHED\",\n REASONING_START = \"REASONING_START\",\n REASONING_MESSAGE_START = \"REASONING_MESSAGE_START\",\n REASONING_MESSAGE_CONTENT = \"REASONING_MESSAGE_CONTENT\",\n REASONING_MESSAGE_END = \"REASONING_MESSAGE_END\",\n REASONING_MESSAGE_CHUNK = \"REASONING_MESSAGE_CHUNK\",\n REASONING_END = \"REASONING_END\",\n REASONING_ENCRYPTED_VALUE = \"REASONING_ENCRYPTED_VALUE\",\n SUBAGENT_STARTED = \"SUBAGENT_STARTED\",\n SUBAGENT_FINISHED = \"SUBAGENT_FINISHED\",\n SUBAGENT_ERROR = \"SUBAGENT_ERROR\",\n}\n\nexport const BaseEventSchema = z\n .object({\n type: z.nativeEnum(EventType),\n timestamp: z.number().optional(),\n rawEvent: z.any().optional(),\n // Declared once here so every event type carries it. See\n // OptionalMetadataSchema for why an explicit null is rejected rather than\n // tolerated the way parentMessageId and outcome are.\n metadata: OptionalMetadataSchema,\n })\n .passthrough();\n\nexport const TextMessageStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TEXT_MESSAGE_START),\n messageId: z.string(),\n role: TextMessageRoleSchema.default(\"assistant\"),\n name: z.string().optional(),\n subagentRunId: z.string().optional(),\n});\n\nexport const TextMessageContentEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TEXT_MESSAGE_CONTENT),\n messageId: z.string(),\n delta: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const TextMessageEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TEXT_MESSAGE_END),\n messageId: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const TextMessageChunkEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TEXT_MESSAGE_CHUNK),\n messageId: z.string().optional(),\n role: TextMessageRoleSchema.optional(),\n delta: z.string().optional(),\n name: z.string().optional(),\n subagentRunId: z.string().optional(),\n});\n\n/**\n * @deprecated Use ReasoningMessageStartEventSchema instead. Will be removed in 1.0.0.\n */\nexport const ThinkingTextMessageStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.THINKING_TEXT_MESSAGE_START),\n});\n\n/**\n * @deprecated Use ReasoningMessageContentEventSchema instead. Will be removed in 1.0.0.\n */\nexport const ThinkingTextMessageContentEventSchema = TextMessageContentEventSchema.omit({\n messageId: true,\n type: true,\n // Not an attribution carrier: the deprecated THINKING_* family predates\n // subagents and is excluded from the attribution table — Python and .NET\n // declare no such field, and inheriting it here from the text schema made\n // TypeScript silently accept what the other SDKs reject.\n subagentRunId: true,\n}).extend({\n type: z.literal(EventType.THINKING_TEXT_MESSAGE_CONTENT),\n});\n\n/**\n * @deprecated Use ReasoningMessageEndEventSchema instead. Will be removed in 1.0.0.\n */\nexport const ThinkingTextMessageEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.THINKING_TEXT_MESSAGE_END),\n});\n\nexport const ToolCallStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TOOL_CALL_START),\n toolCallId: z.string(),\n toolCallName: z.string(),\n // Accept `null` and treat it as omitted, so producers that serialize optional\n // fields as JSON `null` (e.g. the .NET Microsoft Agent Framework adapter,\n // whose System.Text.Json emits `\"parentMessageId\": null`) still validate\n // instead of aborting the run on the first tool call.\n parentMessageId: z\n .string()\n .nullable()\n .optional()\n .transform((v) => v ?? undefined),\n subagentRunId: z.string().optional(),\n});\n\nexport const ToolCallArgsEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TOOL_CALL_ARGS),\n toolCallId: z.string(),\n delta: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const ToolCallEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TOOL_CALL_END),\n toolCallId: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const ToolCallResultEventSchema = BaseEventSchema.extend({\n messageId: z.string(),\n type: z.literal(EventType.TOOL_CALL_RESULT),\n toolCallId: z.string(),\n content: z.string(),\n role: z.literal(\"tool\").optional(),\n subagentRunId: z.string().optional(),\n});\n\nexport const ToolCallChunkEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.TOOL_CALL_CHUNK),\n toolCallId: z.string().optional(),\n toolCallName: z.string().optional(),\n // Accept `null` as omitted — same cross-language quirk as TOOL_CALL_START.\n parentMessageId: z\n .string()\n .nullable()\n .optional()\n .transform((v) => v ?? undefined),\n delta: z.string().optional(),\n subagentRunId: z.string().optional(),\n});\n\n/**\n * @deprecated Use ReasoningStartEventSchema instead. Will be removed in 1.0.0.\n */\nexport const ThinkingStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.THINKING_START),\n title: z.string().optional(),\n});\n\n/**\n * @deprecated Use ReasoningEndEventSchema instead. Will be removed in 1.0.0.\n */\nexport const ThinkingEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.THINKING_END),\n});\n\nexport const StateSnapshotEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.STATE_SNAPSHOT),\n snapshot: StateSchema,\n subagentRunId: z.string().optional(),\n});\n\nexport const StateDeltaEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.STATE_DELTA),\n delta: z.array(z.any()), // JSON Patch (RFC 6902)\n subagentRunId: z.string().optional(),\n});\n\nexport const MessagesSnapshotEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.MESSAGES_SNAPSHOT),\n messages: z.array(MessageSchema),\n});\n\nexport const ActivitySnapshotEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.ACTIVITY_SNAPSHOT),\n messageId: z.string(),\n activityType: z.string(),\n content: z.record(z.any()),\n replace: z.boolean().optional().default(true),\n subagentRunId: z.string().optional(),\n});\n\nexport const ActivityDeltaEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.ACTIVITY_DELTA),\n messageId: z.string(),\n activityType: z.string(),\n patch: z.array(z.any()),\n subagentRunId: z.string().optional(),\n});\n\nexport const RawEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.RAW),\n event: z.any(),\n source: z.string().optional(),\n subagentRunId: z.string().optional(),\n});\n\nexport const CustomEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.CUSTOM),\n name: z.string(),\n value: z.any(),\n subagentRunId: z.string().optional(),\n});\n\nexport const RunStartedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.RUN_STARTED),\n threadId: z.string(),\n runId: z.string(),\n parentRunId: z.string().optional(),\n input: RunAgentInputSchema.optional(),\n});\n\nexport const RunFinishedSuccessOutcomeSchema = z\n .object({\n type: z.literal(\"success\"),\n })\n .strict();\n\nexport const RunFinishedInterruptOutcomeSchema = z\n .object({\n type: z.literal(\"interrupt\"),\n interrupts: z.array(InterruptSchema).min(1),\n })\n .strict();\n\nexport const RunFinishedOutcomeSchema = z.discriminatedUnion(\"type\", [\n RunFinishedSuccessOutcomeSchema,\n RunFinishedInterruptOutcomeSchema,\n]);\n\n// Reusable, numeric-only token usage summary. Deliberately carries no\n// content-bearing or identifying fields (no prompts, completions, messages,\n// thread/run/user IDs) — only provider/model labels and numeric token counts.\n// Unknown keys are stripped on parse, so content cannot ride along.\nexport const TokenUsageSchema = z.object({\n provider: z.string().optional(),\n model: z.string().optional(),\n // Counts are non-negative integers in every representation: proto `int64`,\n // C# `long?`, Python `int`. Constraining them here keeps TypeScript from\n // admitting values the other bindings cannot encode — `proto.encode` parses\n // against this schema and then writes via an int64 writer that throws on a\n // non-integer, so an unconstrained `z.number()` turns a bad producer value\n // into a mid-stream crash on the protobuf transport instead of a validation\n // error at the source.\n inputTokens: z.number().int().nonnegative().optional(),\n outputTokens: z.number().int().nonnegative().optional(),\n totalTokens: z.number().int().nonnegative().optional(),\n reasoningTokens: z.number().int().nonnegative().optional(),\n cachedInputTokens: z.number().int().nonnegative().optional(),\n});\n\nexport const RunFinishedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.RUN_FINISHED),\n threadId: z.string(),\n runId: z.string(),\n result: z.any().optional(),\n // Accept `null` and treat it as omitted, so producers like the Pydantic-based\n // Python SDK that serialize via `model_dump()` (without `exclude_none=True`)\n // and emit `\"outcome\": null` for the legacy no-outcome case still validate.\n outcome: RunFinishedOutcomeSchema.nullable()\n .optional()\n .transform((v) => v ?? undefined),\n // Optional per-(provider, model) token usage for the completed run. An array\n // so runs that invoke multiple models keep them separate for downstream\n // display; consumers that only need totals can sum across entries. Must be\n // declared here (not relied upon via passthrough) so it survives the\n // `EventSchemas` discriminated-union parse.\n usage: z.array(TokenUsageSchema).optional(),\n});\n\nexport const RunErrorEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.RUN_ERROR),\n message: z.string(),\n code: z.string().optional(),\n // Optional partial usage for a run that failed after one or more model calls\n // completed. Same numeric-only shape as RUN_FINISHED.\n usage: z.array(TokenUsageSchema).optional(),\n});\n\nexport const StepStartedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.STEP_STARTED),\n stepName: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const StepFinishedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.STEP_FINISHED),\n stepName: z.string(),\n subagentRunId: z.string().optional(),\n});\n\n// Schema for the encrypted signature subtype\nexport const ReasoningEncryptedValueSubtypeSchema = z.union([\n z.literal(\"tool-call\"),\n z.literal(\"message\"),\n]);\n\nexport const ReasoningStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.REASONING_START),\n messageId: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const ReasoningMessageStartEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.REASONING_MESSAGE_START),\n messageId: z.string(),\n role: z.literal(\"reasoning\"),\n subagentRunId: z.string().optional(),\n});\n\nexport const ReasoningMessageContentEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.REASONING_MESSAGE_CONTENT),\n messageId: z.string(),\n delta: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const ReasoningMessageEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.REASONING_MESSAGE_END),\n messageId: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const ReasoningMessageChunkEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.REASONING_MESSAGE_CHUNK),\n messageId: z.string().optional(),\n delta: z.string().optional(),\n subagentRunId: z.string().optional(),\n});\n\nexport const ReasoningEndEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.REASONING_END),\n messageId: z.string(),\n subagentRunId: z.string().optional(),\n});\n\nexport const ReasoningEncryptedValueEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.REASONING_ENCRYPTED_VALUE),\n subtype: ReasoningEncryptedValueSubtypeSchema,\n entityId: z.string(),\n encryptedValue: z.string(),\n subagentRunId: z.string().optional(),\n});\n\n// No null tolerance anywhere on the subagent surface: these fields are new with\n// this PR, so no producer has ever legally written `null` for them — since\n// PNI-199 the Python and .NET SDKs omit valueless fields at the source, and the\n// three legacy tolerances (TOOL_CALL_START/CHUNK.parentMessageId,\n// RUN_FINISHED.outcome) stay a closed set awaiting their middleware shim\n// (PNI-207). Absent is the only spelling; an explicit null fails the parse,\n// exactly like `metadata`.\n\nexport const SubagentStartedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.SUBAGENT_STARTED),\n subagentRunId: z.string(),\n name: z.string(),\n description: z.string().optional(),\n parentSubagentRunId: z.string().optional(),\n // Link back to the tool call (and the message that held it) that spawned this\n // subagent, for the agents-as-tools pattern (e.g. deepagents `task`). Lets a\n // consumer correlate the subagent to its spawning call without inspecting\n // rawEvent.metadata.\n parentToolCallId: z.string().optional(),\n parentMessageId: z.string().optional(),\n});\n\nexport const SubagentFinishedSuccessOutcomeSchema = z\n .object({\n type: z.literal(\"success\"),\n })\n .strict();\n\nexport const SubagentFinishedSuspendedOutcomeSchema = z\n .object({\n type: z.literal(\"suspended\"),\n // The ids of the run-level interrupts this subagent directly owns (see\n // Interrupt.subagentRunId). MAY be empty or omitted: an ancestor subagent\n // suspended because a DESCENDANT interrupted owns no interrupt itself.\n interruptIds: z.array(z.string()).optional(),\n })\n .strict();\n\n// Mirrors RunFinishedOutcome one level down: a subagent's terminal closes its\n// stream segment for THIS run either because the work completed (\"success\")\n// or because the workflow is paused awaiting outside input (\"suspended\" — the\n// run ends with an interrupt outcome, and on resume the same subagentRunId is\n// re-announced as a continuation of the suspended invocation). An omitted\n// outcome means legacy success. Without this, a paused subagent was\n// indistinguishable from a completed one and every UI had to reverse-engineer\n// \"waiting\" from a later interrupt event.\nexport const SubagentFinishedOutcomeSchema = z.discriminatedUnion(\"type\", [\n SubagentFinishedSuccessOutcomeSchema,\n SubagentFinishedSuspendedOutcomeSchema,\n]);\n\nexport const SubagentFinishedEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.SUBAGENT_FINISHED),\n subagentRunId: z.string(),\n // The subagent's completion payload, mirroring RUN_FINISHED.result.\n result: z.any().optional(),\n // Strictly optional: absent means success (the legacy reading); an explicit\n // null is rejected. RUN_FINISHED.outcome's null tolerance is legacy debt from\n // producers that shipped before PNI-199 — this field is newer than the fix,\n // so it never inherits the debt.\n outcome: SubagentFinishedOutcomeSchema.optional(),\n});\n\nexport const SubagentErrorEventSchema = BaseEventSchema.extend({\n type: z.literal(EventType.SUBAGENT_ERROR),\n subagentRunId: z.string(),\n message: z.string(),\n code: z.string().optional(),\n});\n\nexport const EventSchemas = z.discriminatedUnion(\"type\", [\n TextMessageStartEventSchema,\n TextMessageContentEventSchema,\n TextMessageEndEventSchema,\n TextMessageChunkEventSchema,\n ThinkingStartEventSchema,\n ThinkingEndEventSchema,\n ThinkingTextMessageStartEventSchema,\n ThinkingTextMessageContentEventSchema,\n ThinkingTextMessageEndEventSchema,\n ToolCallStartEventSchema,\n ToolCallArgsEventSchema,\n ToolCallEndEventSchema,\n ToolCallChunkEventSchema,\n ToolCallResultEventSchema,\n StateSnapshotEventSchema,\n StateDeltaEventSchema,\n MessagesSnapshotEventSchema,\n ActivitySnapshotEventSchema,\n ActivityDeltaEventSchema,\n RawEventSchema,\n CustomEventSchema,\n RunStartedEventSchema,\n RunFinishedEventSchema,\n RunErrorEventSchema,\n StepStartedEventSchema,\n StepFinishedEventSchema,\n ReasoningStartEventSchema,\n ReasoningMessageStartEventSchema,\n ReasoningMessageContentEventSchema,\n ReasoningMessageEndEventSchema,\n ReasoningMessageChunkEventSchema,\n ReasoningEndEventSchema,\n ReasoningEncryptedValueEventSchema,\n SubagentStartedEventSchema,\n SubagentFinishedEventSchema,\n SubagentErrorEventSchema,\n]);\n\nexport type BaseEvent = z.infer<typeof BaseEventSchema>;\nexport type AGUIEvent = z.infer<typeof EventSchemas>;\nexport type BaseEventFields = z.infer<typeof BaseEventSchema>;\nexport type AGUIEventByType = {\n [EventType.TEXT_MESSAGE_START]: TextMessageStartEvent;\n [EventType.TEXT_MESSAGE_CONTENT]: TextMessageContentEvent;\n [EventType.TEXT_MESSAGE_END]: TextMessageEndEvent;\n [EventType.TEXT_MESSAGE_CHUNK]: TextMessageChunkEvent;\n [EventType.THINKING_TEXT_MESSAGE_START]: ThinkingTextMessageStartEvent;\n [EventType.THINKING_TEXT_MESSAGE_CONTENT]: ThinkingTextMessageContentEvent;\n [EventType.THINKING_TEXT_MESSAGE_END]: ThinkingTextMessageEndEvent;\n [EventType.TOOL_CALL_START]: ToolCallStartEvent;\n [EventType.TOOL_CALL_ARGS]: ToolCallArgsEvent;\n [EventType.TOOL_CALL_END]: ToolCallEndEvent;\n [EventType.TOOL_CALL_CHUNK]: ToolCallChunkEvent;\n [EventType.TOOL_CALL_RESULT]: ToolCallResultEvent;\n [EventType.THINKING_START]: ThinkingStartEvent;\n [EventType.THINKING_END]: ThinkingEndEvent;\n [EventType.STATE_SNAPSHOT]: StateSnapshotEvent;\n [EventType.STATE_DELTA]: StateDeltaEvent;\n [EventType.MESSAGES_SNAPSHOT]: MessagesSnapshotEvent;\n [EventType.ACTIVITY_SNAPSHOT]: ActivitySnapshotEvent;\n [EventType.ACTIVITY_DELTA]: ActivityDeltaEvent;\n [EventType.RAW]: RawEvent;\n [EventType.CUSTOM]: CustomEvent;\n [EventType.RUN_STARTED]: RunStartedEvent;\n [EventType.RUN_FINISHED]: RunFinishedEvent;\n [EventType.RUN_ERROR]: RunErrorEvent;\n [EventType.STEP_STARTED]: StepStartedEvent;\n [EventType.STEP_FINISHED]: StepFinishedEvent;\n [EventType.REASONING_START]: ReasoningStartEvent;\n [EventType.REASONING_MESSAGE_START]: ReasoningMessageStartEvent;\n [EventType.REASONING_MESSAGE_CONTENT]: ReasoningMessageContentEvent;\n [EventType.REASONING_MESSAGE_END]: ReasoningMessageEndEvent;\n [EventType.REASONING_MESSAGE_CHUNK]: ReasoningMessageChunkEvent;\n [EventType.REASONING_END]: ReasoningEndEvent;\n [EventType.REASONING_ENCRYPTED_VALUE]: ReasoningEncryptedValueEvent;\n [EventType.SUBAGENT_STARTED]: SubagentStartedEvent;\n [EventType.SUBAGENT_FINISHED]: SubagentFinishedEvent;\n [EventType.SUBAGENT_ERROR]: SubagentErrorEvent;\n};\nexport type AGUIEventOf<T extends EventType> = AGUIEventByType[T];\nexport type EventPayloadOf<T extends EventType> = Omit<AGUIEventOf<T>, keyof BaseEventFields>;\n\ntype EventProps<Schema extends z.ZodTypeAny> = Omit<z.input<Schema>, \"type\">;\n\nexport type BaseEventProps = EventProps<typeof BaseEventSchema>;\n\nexport type TextMessageStartEventProps = EventProps<typeof TextMessageStartEventSchema>;\nexport type TextMessageContentEventProps = EventProps<typeof TextMessageContentEventSchema>;\nexport type TextMessageEndEventProps = EventProps<typeof TextMessageEndEventSchema>;\nexport type TextMessageChunkEventProps = EventProps<typeof TextMessageChunkEventSchema>;\nexport type ThinkingTextMessageStartEventProps = EventProps<\n typeof ThinkingTextMessageStartEventSchema\n>;\nexport type ThinkingTextMessageContentEventProps = EventProps<\n typeof ThinkingTextMessageContentEventSchema\n>;\nexport type ThinkingTextMessageEndEventProps = EventProps<typeof ThinkingTextMessageEndEventSchema>;\nexport type ToolCallStartEventProps = EventProps<typeof ToolCallStartEventSchema>;\nexport type ToolCallArgsEventProps = EventProps<typeof ToolCallArgsEventSchema>;\nexport type ToolCallEndEventProps = EventProps<typeof ToolCallEndEventSchema>;\nexport type ToolCallChunkEventProps = EventProps<typeof ToolCallChunkEventSchema>;\nexport type ToolCallResultEventProps = EventProps<typeof ToolCallResultEventSchema>;\nexport type ThinkingStartEventProps = EventProps<typeof ThinkingStartEventSchema>;\nexport type ThinkingEndEventProps = EventProps<typeof ThinkingEndEventSchema>;\nexport type StateSnapshotEventProps = EventProps<typeof StateSnapshotEventSchema>;\nexport type StateDeltaEventProps = EventProps<typeof StateDeltaEventSchema>;\nexport type MessagesSnapshotEventProps = EventProps<typeof MessagesSnapshotEventSchema>;\nexport type ActivitySnapshotEventProps = EventProps<typeof ActivitySnapshotEventSchema>;\nexport type ActivityDeltaEventProps = EventProps<typeof ActivityDeltaEventSchema>;\nexport type RawEventProps = EventProps<typeof RawEventSchema>;\nexport type CustomEventProps = EventProps<typeof CustomEventSchema>;\nexport type RunStartedEventProps = EventProps<typeof RunStartedEventSchema>;\nexport type RunFinishedEventProps = EventProps<typeof RunFinishedEventSchema>;\nexport type RunErrorEventProps = EventProps<typeof RunErrorEventSchema>;\nexport type StepStartedEventProps = EventProps<typeof StepStartedEventSchema>;\nexport type StepFinishedEventProps = EventProps<typeof StepFinishedEventSchema>;\nexport type ReasoningStartEventProps = EventProps<typeof ReasoningStartEventSchema>;\nexport type ReasoningMessageStartEventProps = EventProps<typeof ReasoningMessageStartEventSchema>;\nexport type ReasoningMessageContentEventProps = EventProps<\n typeof ReasoningMessageContentEventSchema\n>;\nexport type ReasoningMessageEndEventProps = EventProps<typeof ReasoningMessageEndEventSchema>;\nexport type ReasoningMessageChunkEventProps = EventProps<typeof ReasoningMessageChunkEventSchema>;\nexport type ReasoningEndEventProps = EventProps<typeof ReasoningEndEventSchema>;\nexport type ReasoningEncryptedValueEventProps = EventProps<\n typeof ReasoningEncryptedValueEventSchema\n>;\nexport type SubagentStartedEventProps = EventProps<typeof SubagentStartedEventSchema>;\nexport type SubagentFinishedEventProps = EventProps<typeof SubagentFinishedEventSchema>;\nexport type SubagentErrorEventProps = EventProps<typeof SubagentErrorEventSchema>;\n\nexport type TextMessageStartEvent = z.infer<typeof TextMessageStartEventSchema>;\nexport type TextMessageContentEvent = z.infer<typeof TextMessageContentEventSchema>;\nexport type TextMessageEndEvent = z.infer<typeof TextMessageEndEventSchema>;\nexport type TextMessageChunkEvent = z.infer<typeof TextMessageChunkEventSchema>;\nexport type ThinkingTextMessageStartEvent = z.infer<typeof ThinkingTextMessageStartEventSchema>;\nexport type ThinkingTextMessageContentEvent = z.infer<typeof ThinkingTextMessageContentEventSchema>;\nexport type ThinkingTextMessageEndEvent = z.infer<typeof ThinkingTextMessageEndEventSchema>;\nexport type ToolCallStartEvent = z.infer<typeof ToolCallStartEventSchema>;\nexport type ToolCallArgsEvent = z.infer<typeof ToolCallArgsEventSchema>;\nexport type ToolCallEndEvent = z.infer<typeof ToolCallEndEventSchema>;\nexport type ToolCallChunkEvent = z.infer<typeof ToolCallChunkEventSchema>;\nexport type ToolCallResultEvent = z.infer<typeof ToolCallResultEventSchema>;\nexport type ThinkingStartEvent = z.infer<typeof ThinkingStartEventSchema>;\nexport type ThinkingEndEvent = z.infer<typeof ThinkingEndEventSchema>;\nexport type StateSnapshotEvent = z.infer<typeof StateSnapshotEventSchema>;\nexport type StateDeltaEvent = z.infer<typeof StateDeltaEventSchema>;\nexport type MessagesSnapshotEvent = z.infer<typeof MessagesSnapshotEventSchema>;\nexport type ActivitySnapshotEvent = z.infer<typeof ActivitySnapshotEventSchema>;\nexport type ActivityDeltaEvent = z.infer<typeof ActivityDeltaEventSchema>;\nexport type RawEvent = z.infer<typeof RawEventSchema>;\nexport type CustomEvent = z.infer<typeof CustomEventSchema>;\nexport type RunStartedEvent = z.infer<typeof RunStartedEventSchema>;\nexport type RunFinishedEvent = z.infer<typeof RunFinishedEventSchema>;\nexport type TokenUsage = z.infer<typeof TokenUsageSchema>;\nexport type RunFinishedOutcome = z.infer<typeof RunFinishedOutcomeSchema>;\nexport type RunFinishedSuccessOutcome = z.infer<typeof RunFinishedSuccessOutcomeSchema>;\nexport type RunFinishedInterruptOutcome = z.infer<typeof RunFinishedInterruptOutcomeSchema>;\nexport type SubagentFinishedOutcome = z.infer<typeof SubagentFinishedOutcomeSchema>;\nexport type SubagentFinishedSuccessOutcome = z.infer<typeof SubagentFinishedSuccessOutcomeSchema>;\nexport type SubagentFinishedSuspendedOutcome = z.infer<typeof SubagentFinishedSuspendedOutcomeSchema>;\nexport type RunErrorEvent = z.infer<typeof RunErrorEventSchema>;\nexport type StepStartedEvent = z.infer<typeof StepStartedEventSchema>;\nexport type StepFinishedEvent = z.infer<typeof StepFinishedEventSchema>;\nexport type ReasoningStartEvent = z.infer<typeof ReasoningStartEventSchema>;\nexport type ReasoningMessageStartEvent = z.infer<typeof ReasoningMessageStartEventSchema>;\nexport type ReasoningMessageContentEvent = z.infer<typeof ReasoningMessageContentEventSchema>;\nexport type ReasoningMessageEndEvent = z.infer<typeof ReasoningMessageEndEventSchema>;\nexport type ReasoningMessageChunkEvent = z.infer<typeof ReasoningMessageChunkEventSchema>;\nexport type ReasoningEndEvent = z.infer<typeof ReasoningEndEventSchema>;\nexport type ReasoningEncryptedValueEvent = z.infer<typeof ReasoningEncryptedValueEventSchema>;\nexport type ReasoningEncryptedValueSubtype = z.infer<typeof ReasoningEncryptedValueSubtypeSchema>;\nexport type SubagentStartedEvent = z.infer<typeof SubagentStartedEventSchema>;\nexport type SubagentFinishedEvent = z.infer<typeof SubagentFinishedEventSchema>;\nexport type SubagentErrorEvent = z.infer<typeof SubagentErrorEventSchema>;\n","import { TokenUsage } from \"./events\";\n\n/**\n * Accept a value only if it is a real, finite number.\n *\n * Shared by both vendor mappers so they guard identically. Providers do hand\n * over strings, `null`s and `NaN`s in their usage metadata, and a bad value must\n * not reach the wire: consumers validate every incoming event and throw on\n * failure, so one malformed count would fail an otherwise-successful run at its\n * final event — costing the user the answer, not just the token count.\n */\nconst num = (v: unknown): number | undefined =>\n typeof v === \"number\" && Number.isFinite(v) ? v : undefined;\n\n/**\n * Read a property from a value of unknown shape, yielding `undefined` for\n * anything that is not an object. Lets the mappers take `unknown` rather than\n * `any` — vendor payloads are untrusted, so every access should be narrowed\n * rather than assumed.\n */\nconst prop = (v: unknown, key: string): unknown =>\n typeof v === \"object\" && v !== null ? (v as Record<string, unknown>)[key] : undefined;\n\nconst COUNT_KEYS = [\n \"inputTokens\",\n \"outputTokens\",\n \"totalTokens\",\n \"reasoningTokens\",\n \"cachedInputTokens\",\n] as const;\n\n/**\n * Build a {@link TokenUsage} from already-guarded counts, or `undefined` when no\n * count survived. Returning `undefined` rather than a labels-only entry keeps\n * \"the provider reported no usage\" distinct from \"the provider reported usage\",\n * so callers omit the field instead of emitting an entry that claims nothing.\n */\nfunction buildEntry(\n counts: Partial<Record<(typeof COUNT_KEYS)[number], number | undefined>>,\n { provider, model }: { provider?: string; model?: string },\n): TokenUsage | undefined {\n if (!COUNT_KEYS.some((key) => counts[key] !== undefined)) return undefined;\n\n const entry: TokenUsage = {};\n if (provider != null) entry.provider = provider;\n if (model != null) entry.model = model;\n for (const key of COUNT_KEYS) {\n const value = counts[key];\n if (value !== undefined) entry[key] = value;\n }\n return entry;\n}\n\n/**\n * Map a LangChain-family `usage_metadata` object into an AG-UI {@link TokenUsage}.\n *\n * LangChain and LangGraph both attach usage as `{ input_tokens, output_tokens,\n * total_tokens, input_token_details: { cache_read }, output_token_details:\n * { reasoning } }`. This maps only those numeric counts plus optional\n * provider/model labels — never prompt/completion content. Returns `undefined`\n * when no usable count is present, so callers can omit usage rather than\n * report zeros.\n */\nexport function tokenUsageFromLangChainMetadata(\n usageMetadata: unknown,\n { provider, model }: { provider?: string; model?: string },\n): TokenUsage | undefined {\n if (!usageMetadata) return undefined;\n\n const inputDetails = prop(usageMetadata, \"input_token_details\");\n const outputDetails = prop(usageMetadata, \"output_token_details\");\n\n return buildEntry(\n {\n inputTokens: num(prop(usageMetadata, \"input_tokens\")),\n outputTokens: num(prop(usageMetadata, \"output_tokens\")),\n totalTokens: num(prop(usageMetadata, \"total_tokens\")),\n reasoningTokens: num(prop(outputDetails, \"reasoning\")),\n cachedInputTokens: num(prop(inputDetails, \"cache_read\")),\n },\n { provider, model },\n );\n}\n\n/**\n * Map an AI-SDK (v5) `LanguageModelUsage` object into an AG-UI {@link TokenUsage}.\n *\n * AI-SDK's keys already match: `inputTokens`, `outputTokens`, `totalTokens`,\n * `reasoningTokens`, `cachedInputTokens`. AI-SDK reports `NaN`/`undefined` for\n * counts a provider didn't return, so only finite numbers are copied. Returns\n * `undefined` when no finite count is present (so callers omit empty usage).\n */\nexport function tokenUsageFromAiSdkUsage(\n usage: unknown,\n { provider, model }: { provider?: string; model?: string },\n): TokenUsage | undefined {\n if (!usage) return undefined;\n\n return buildEntry(\n {\n inputTokens: num(prop(usage, \"inputTokens\")),\n outputTokens: num(prop(usage, \"outputTokens\")),\n totalTokens: num(prop(usage, \"totalTokens\")),\n reasoningTokens: num(prop(usage, \"reasoningTokens\")),\n cachedInputTokens: num(prop(usage, \"cachedInputTokens\")),\n },\n { provider, model },\n );\n}\n\n/**\n * Sum per-call {@link TokenUsage} entries into one entry per `(provider, model)`\n * pair. Order follows first appearance. A count field stays `undefined` when no\n * member of the group reported it, so \"not reported\" stays distinct from zero.\n *\n * Protocol-agnostic: works on any producer's `TokenUsage[]`, so integrations\n * share it rather than reimplementing aggregation.\n */\nexport function aggregateTokenUsage(entries: TokenUsage[]): TokenUsage[] {\n const grouped = new Map<string, TokenUsage>();\n\n for (const entry of entries) {\n const key = `${entry.provider ?? \"\"} ${entry.model ?? \"\"}`;\n let target = grouped.get(key);\n if (!target) {\n target = { provider: entry.provider, model: entry.model };\n grouped.set(key, target);\n }\n for (const field of COUNT_KEYS) {\n const value = entry[field];\n if (value == null) continue;\n target[field] = (target[field] ?? 0) + value;\n }\n }\n\n return [...grouped.values()];\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,oBAAoB;;;;;;;;;;;;;;;;;;;;;AAsBjC,MAAa,iBAAiBA,MAAE,OAAOA,MAAE,KAAK,CAAC;;;;;;;;;;;;;;;;;;;AAsB/C,MAAa,yBAAyB,eAAe,UAAU;;;;;;;;;;;;;;;;;AAkB/D,SAAgB,cACd,UACA,UACsB;AACtB,KAAI,aAAa,OACf,QAAO;AAET,KAAI,aAAa,OACf,QAAO,EAAE,GAAG,UAAU;AAExB,QAAO;EAAE,GAAG;EAAU,GAAG;EAAU;;;;;AC/ErC,MAAa,qBAAqBC,MAAE,OAAO;CACzC,MAAMA,MAAE,QAAQ;CAChB,WAAWA,MAAE,QAAQ;CACtB,CAAC;AAEF,MAAa,iBAAiBA,MAAE,OAAO;CACrC,IAAIA,MAAE,QAAQ;CACd,MAAMA,MAAE,QAAQ,WAAW;CAC3B,UAAU;CACV,gBAAgBA,MAAE,QAAQ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AI3C,QAAO,CAAC,GAAG,QAAQ,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/generated/serialization.ts","../src/compat.ts","../src/metadata.ts","../src/token-usage.ts","../src/content.ts"],"sourcesContent":["// @generated from https://ag-ui.com/spec/draft/schema.json. DO NOT EDIT.\n// Regenerate with pnpm --filter @ag-ui/spec generate.\n\ntype Shape =\n | string\n | { array: Shape }\n | {\n optional: string[];\n fields: Record<string, Shape>;\n }\n | { discriminator: string; variants: Record<string, string> };\n\nconst shapes: Record<string, Shape> = {\n TextMessageStartEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\", \"role\", \"name\"],\n fields: {},\n },\n TextMessageContentEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n TextMessageEndEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n TextMessageChunkEvent: {\n optional: [\n \"timestamp\",\n \"rawEvent\",\n \"metadata\",\n \"subagentRunId\",\n \"messageId\",\n \"role\",\n \"delta\",\n \"name\",\n ],\n fields: {},\n },\n ToolCallStartEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\", \"parentMessageId\"],\n fields: {},\n },\n ToolCallArgsEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n ToolCallEndEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n ToolCallChunkEvent: {\n optional: [\n \"timestamp\",\n \"rawEvent\",\n \"metadata\",\n \"subagentRunId\",\n \"toolCallId\",\n \"toolCallName\",\n \"parentMessageId\",\n \"delta\",\n ],\n fields: {},\n },\n TextPart: { optional: [\"id\", \"metadata\"], fields: {} },\n DataSource: { optional: [], fields: {} },\n UrlSource: { optional: [\"mimeType\"], fields: {} },\n FileSource: { optional: [\"provider\", \"mimeType\"], fields: {} },\n PartSource: {\n discriminator: \"type\",\n variants: { data: \"DataSource\", url: \"UrlSource\", file: \"FileSource\" },\n },\n ImagePart: { optional: [\"id\", \"metadata\"], fields: { source: \"PartSource\" } },\n AudioPart: { optional: [\"id\", \"metadata\"], fields: { source: \"PartSource\" } },\n VideoPart: { optional: [\"id\", \"metadata\"], fields: { source: \"PartSource\" } },\n DocumentPart: { optional: [\"id\", \"metadata\"], fields: { source: \"PartSource\" } },\n ContentPart: {\n discriminator: \"type\",\n variants: {\n text: \"TextPart\",\n image: \"ImagePart\",\n audio: \"AudioPart\",\n video: \"VideoPart\",\n document: \"DocumentPart\",\n },\n },\n ToolCallResultEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\", \"role\"],\n fields: { content: { array: \"ContentPart\" } },\n },\n StateSnapshotEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n AddOperation: { optional: [], fields: {} },\n RemoveOperation: { optional: [], fields: {} },\n ReplaceOperation: { optional: [], fields: {} },\n MoveOperation: { optional: [], fields: {} },\n CopyOperation: { optional: [], fields: {} },\n TestOperation: { optional: [], fields: {} },\n JsonPatchOperation: {\n discriminator: \"op\",\n variants: {\n add: \"AddOperation\",\n remove: \"RemoveOperation\",\n replace: \"ReplaceOperation\",\n move: \"MoveOperation\",\n copy: \"CopyOperation\",\n test: \"TestOperation\",\n },\n },\n StateDeltaEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: { delta: { array: \"JsonPatchOperation\" } },\n },\n DeveloperMessage: {\n optional: [\"subagentRunId\", \"name\", \"encryptedValue\", \"metadata\"],\n fields: {},\n },\n SystemMessage: { optional: [\"subagentRunId\", \"name\", \"encryptedValue\", \"metadata\"], fields: {} },\n FunctionCall: { optional: [], fields: {} },\n ToolCall: { optional: [\"encryptedValue\", \"metadata\"], fields: { function: \"FunctionCall\" } },\n AssistantMessage: {\n optional: [\"subagentRunId\", \"name\", \"encryptedValue\", \"metadata\", \"content\", \"toolCalls\"],\n fields: { toolCalls: { array: \"ToolCall\" } },\n },\n UserMessage: {\n optional: [\"subagentRunId\", \"name\", \"encryptedValue\", \"metadata\"],\n fields: { content: { array: \"ContentPart\" } },\n },\n ToolMessage: {\n optional: [\"subagentRunId\", \"error\", \"encryptedValue\", \"metadata\"],\n fields: { content: { array: \"ContentPart\" } },\n },\n ActivityMessage: { optional: [\"subagentRunId\", \"metadata\"], fields: {} },\n ReasoningMessage: { optional: [\"subagentRunId\", \"encryptedValue\", \"metadata\"], fields: {} },\n Message: {\n discriminator: \"role\",\n variants: {\n developer: \"DeveloperMessage\",\n system: \"SystemMessage\",\n assistant: \"AssistantMessage\",\n user: \"UserMessage\",\n tool: \"ToolMessage\",\n activity: \"ActivityMessage\",\n reasoning: \"ReasoningMessage\",\n },\n },\n MessagesSnapshotEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\"],\n fields: { messages: { array: \"Message\" } },\n },\n ActivitySnapshotEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\", \"replace\"],\n fields: {},\n },\n ActivityDeltaEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: { patch: { array: \"JsonPatchOperation\" } },\n },\n RawEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\", \"source\"],\n fields: {},\n },\n CustomEvent: { optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"], fields: {} },\n Tool: { optional: [\"parameters\", \"metadata\"], fields: {} },\n Context: { optional: [], fields: {} },\n ResumeEntry: { optional: [\"payload\", \"metadata\"], fields: {} },\n RunAgentInput: {\n optional: [\n \"protocolVersion\",\n \"parentRunId\",\n \"state\",\n \"tools\",\n \"context\",\n \"forwardedProps\",\n \"resume\",\n ],\n fields: {\n messages: { array: \"Message\" },\n tools: { array: \"Tool\" },\n context: { array: \"Context\" },\n resume: { array: \"ResumeEntry\" },\n },\n },\n RunStartedEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"protocolVersion\", \"parentRunId\", \"input\"],\n fields: { input: \"RunAgentInput\" },\n },\n RunFinishedSuccessOutcome: { optional: [\"pendingToolCallIds\"], fields: {} },\n Interrupt: {\n optional: [\"subagentRunId\", \"message\", \"toolCallId\", \"responseSchema\", \"expiresAt\", \"metadata\"],\n fields: {},\n },\n RunFinishedInterruptOutcome: { optional: [], fields: { interrupts: { array: \"Interrupt\" } } },\n RunFinishedCancelledOutcome: { optional: [], fields: {} },\n RunFinishedOutcome: {\n discriminator: \"type\",\n variants: {\n success: \"RunFinishedSuccessOutcome\",\n interrupt: \"RunFinishedInterruptOutcome\",\n cancelled: \"RunFinishedCancelledOutcome\",\n },\n },\n TokenUsage: {\n optional: [\n \"provider\",\n \"model\",\n \"inputTokens\",\n \"outputTokens\",\n \"totalTokens\",\n \"reasoningTokens\",\n \"cachedInputTokens\",\n \"cacheWriteInputTokens\",\n ],\n fields: {},\n },\n RunFinishedEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"result\", \"outcome\", \"usage\"],\n fields: { outcome: \"RunFinishedOutcome\", usage: { array: \"TokenUsage\" } },\n },\n RunErrorEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"code\", \"usage\"],\n fields: { usage: { array: \"TokenUsage\" } },\n },\n StepStartedEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n StepFinishedEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n ReasoningStartEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n ReasoningMessageStartEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n ReasoningMessageContentEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n ReasoningMessageEndEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n ReasoningMessageChunkEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\", \"messageId\", \"delta\"],\n fields: {},\n },\n ReasoningEndEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n ReasoningEncryptedValueEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"subagentRunId\"],\n fields: {},\n },\n SubagentStartedEvent: {\n optional: [\n \"timestamp\",\n \"rawEvent\",\n \"metadata\",\n \"description\",\n \"parentSubagentRunId\",\n \"parentToolCallId\",\n \"parentMessageId\",\n ],\n fields: {},\n },\n SubagentFinishedSuccessOutcome: { optional: [], fields: {} },\n SubagentFinishedSuspendedOutcome: { optional: [\"interruptIds\"], fields: {} },\n SubagentFinishedOutcome: {\n discriminator: \"type\",\n variants: {\n success: \"SubagentFinishedSuccessOutcome\",\n suspended: \"SubagentFinishedSuspendedOutcome\",\n },\n },\n SubagentFinishedEvent: {\n optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"result\", \"outcome\"],\n fields: { outcome: \"SubagentFinishedOutcome\" },\n },\n SubagentErrorEvent: { optional: [\"timestamp\", \"rawEvent\", \"metadata\", \"code\"], fields: {} },\n Event: {\n discriminator: \"type\",\n variants: {\n TEXT_MESSAGE_START: \"TextMessageStartEvent\",\n TEXT_MESSAGE_CONTENT: \"TextMessageContentEvent\",\n TEXT_MESSAGE_END: \"TextMessageEndEvent\",\n TEXT_MESSAGE_CHUNK: \"TextMessageChunkEvent\",\n TOOL_CALL_START: \"ToolCallStartEvent\",\n TOOL_CALL_ARGS: \"ToolCallArgsEvent\",\n TOOL_CALL_END: \"ToolCallEndEvent\",\n TOOL_CALL_CHUNK: \"ToolCallChunkEvent\",\n TOOL_CALL_RESULT: \"ToolCallResultEvent\",\n STATE_SNAPSHOT: \"StateSnapshotEvent\",\n STATE_DELTA: \"StateDeltaEvent\",\n MESSAGES_SNAPSHOT: \"MessagesSnapshotEvent\",\n ACTIVITY_SNAPSHOT: \"ActivitySnapshotEvent\",\n ACTIVITY_DELTA: \"ActivityDeltaEvent\",\n RAW: \"RawEvent\",\n CUSTOM: \"CustomEvent\",\n RUN_STARTED: \"RunStartedEvent\",\n RUN_FINISHED: \"RunFinishedEvent\",\n RUN_ERROR: \"RunErrorEvent\",\n STEP_STARTED: \"StepStartedEvent\",\n STEP_FINISHED: \"StepFinishedEvent\",\n REASONING_START: \"ReasoningStartEvent\",\n REASONING_MESSAGE_START: \"ReasoningMessageStartEvent\",\n REASONING_MESSAGE_CONTENT: \"ReasoningMessageContentEvent\",\n REASONING_MESSAGE_END: \"ReasoningMessageEndEvent\",\n REASONING_MESSAGE_CHUNK: \"ReasoningMessageChunkEvent\",\n REASONING_END: \"ReasoningEndEvent\",\n REASONING_ENCRYPTED_VALUE: \"ReasoningEncryptedValueEvent\",\n SUBAGENT_STARTED: \"SubagentStartedEvent\",\n SUBAGENT_FINISHED: \"SubagentFinishedEvent\",\n SUBAGENT_ERROR: \"SubagentErrorEvent\",\n },\n },\n SubagentInfo: { optional: [\"description\"], fields: {} },\n IdentityCapabilities: {\n optional: [\n \"name\",\n \"type\",\n \"description\",\n \"version\",\n \"provider\",\n \"documentationUrl\",\n \"metadata\",\n ],\n fields: {},\n },\n TransportCapabilities: {\n optional: [\"streaming\", \"websocket\", \"httpBinary\", \"pushNotifications\", \"resumable\"],\n fields: {},\n },\n ToolsCapabilities: {\n optional: [\"supported\", \"items\", \"parallelCalls\", \"clientProvided\"],\n fields: { items: { array: \"Tool\" } },\n },\n OutputCapabilities: { optional: [\"structuredOutput\", \"supportedMimeTypes\"], fields: {} },\n StateCapabilities: { optional: [\"snapshots\", \"deltas\", \"memory\", \"persistentState\"], fields: {} },\n MultiAgentCapabilities: {\n optional: [\"supported\", \"delegation\", \"handoffs\", \"subagents\"],\n fields: { subagents: { array: \"SubagentInfo\" } },\n },\n ReasoningCapabilities: { optional: [\"supported\", \"streaming\", \"encrypted\"], fields: {} },\n MultimodalInputCapabilities: { optional: [\"image\", \"audio\", \"video\", \"pdf\", \"file\"], fields: {} },\n MultimodalOutputCapabilities: { optional: [\"image\", \"audio\"], fields: {} },\n MultimodalCapabilities: {\n optional: [\"input\", \"output\"],\n fields: { input: \"MultimodalInputCapabilities\", output: \"MultimodalOutputCapabilities\" },\n },\n ExecutionCapabilities: {\n optional: [\"codeExecution\", \"sandboxed\", \"maxIterations\", \"maxExecutionTime\"],\n fields: {},\n },\n HumanInTheLoopCapabilities: {\n optional: [\n \"supported\",\n \"approvals\",\n \"interventions\",\n \"feedback\",\n \"interrupts\",\n \"approveWithEdits\",\n ],\n fields: {},\n },\n AgentCapabilities: {\n optional: [\n \"identity\",\n \"transport\",\n \"tools\",\n \"output\",\n \"state\",\n \"multiAgent\",\n \"reasoning\",\n \"multimodal\",\n \"execution\",\n \"humanInTheLoop\",\n \"custom\",\n ],\n fields: {\n identity: \"IdentityCapabilities\",\n transport: \"TransportCapabilities\",\n tools: \"ToolsCapabilities\",\n output: \"OutputCapabilities\",\n state: \"StateCapabilities\",\n multiAgent: \"MultiAgentCapabilities\",\n reasoning: \"ReasoningCapabilities\",\n multimodal: \"MultimodalCapabilities\",\n execution: \"ExecutionCapabilities\",\n humanInTheLoop: \"HumanInTheLoopCapabilities\",\n },\n },\n};\n\nfunction omit(value: unknown, shape: Shape): unknown {\n if (typeof shape === \"string\") return omit(value, shapes[shape]);\n if (\"array\" in shape) {\n if (!Array.isArray(value)) return value;\n const result = value.map((item) => omit(item, shape.array));\n return result.every((item, index) => item === value[index]) ? value : result;\n }\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return value;\n const object = value as Record<string, unknown>;\n if (\"discriminator\" in shape) {\n const tag = object[shape.discriminator];\n return typeof tag === \"string\" && Object.prototype.hasOwnProperty.call(shape.variants, tag)\n ? omit(value, shape.variants[tag])\n : value;\n }\n let result = object;\n for (const key of shape.optional) {\n if (Object.prototype.hasOwnProperty.call(object, key) && object[key] === null) {\n if (result === object) result = { ...object };\n delete result[key];\n }\n }\n for (const [key, child] of Object.entries(shape.fields)) {\n if (!Object.prototype.hasOwnProperty.call(result, key)) continue;\n const next = omit(result[key], child);\n if (next !== result[key]) {\n if (result === object) result = { ...object };\n result[key] = next;\n }\n }\n return result;\n}\n\n/**\n * Omits whole optional null fields before transmission. Does not validate,\n * mutate the input, or traverse arbitrary application JSON or unknown fields.\n * Required null payloads and null values inside opaque data remain intact.\n */\nexport function omitOptionalNulls<T>(value: T, root: \"Event\" | \"RunAgentInput\"): T {\n return omit(value, root) as T;\n}\n","import type {\n Event,\n BaseEvent as ProtocolBaseEvent,\n ContentPart,\n TextPart,\n ImagePart,\n AudioPart,\n VideoPart,\n DocumentPart,\n PartSource,\n DataSource,\n UrlSource,\n ResumeEntry,\n} from \"./generated/types\";\nimport { EventType } from \"./generated/types\";\n\n/**\n * Compatibility layer: the names this package has always exported, pointed at\n * the generated protocol source. Everything protocol-shaped lives in\n * src/generated (regenerate with `pnpm --filter @ag-ui/spec generate`); this\n * file only aliases, derives, and carries the package's own error types.\n */\n\n/** Every protocol event, under its historic name (the generated name is Event). */\nexport type AGUIEvent = Event;\n\n/**\n * The historic BaseEvent shape: the protocol's base fields plus an open index\n * signature. The hand-written type inherited the index signature from zod's\n * passthrough inference, and client code reads event-specific fields straight\n * off a BaseEvent, so the compat surface keeps it. The exact protocol shape\n * is the generated BaseEvent; the closed union of real events is `Event`.\n */\nexport type BaseEvent = ProtocolBaseEvent & { [key: string]: unknown };\n\n/** The fields every event carries, under their historic name. */\nexport type BaseEventFields = BaseEvent;\n\n/** Event type discriminator -> concrete event, derived from the union. */\nexport type AGUIEventByType = {\n [K in EventType]: Extract<Event, { type: K }>;\n};\n\nexport type AGUIEventOf<T extends EventType> = AGUIEventByType[T];\n\n// Distributive on purpose: for a union of event types, plain Omit over the\n// union of events would keep only their COMMON keys (the base fields — which\n// are exactly what gets omitted), collapsing every payload to {}. The\n// conditional distributes so each member keeps its own fields.\nexport type EventPayloadOf<T extends EventType> = T extends EventType\n ? Omit<\n AGUIEventOf<T>,\n // The exact protocol shape's keys: the open compat BaseEvent has a\n // string index signature, and omitting `keyof` THAT would erase every\n // field.\n keyof ProtocolBaseEvent\n >\n : never;\n\n/**\n * What a factory takes: the event's fields, minus the discriminator the\n * factory sets. Derived from the generated event types rather than from\n * z.input of the loose validators — a looseObject's input type carries a\n * string index signature, and Omit over that erases every named field, which\n * would let `{}` or a wrong-typed field compile. The trailing open signature\n * keeps the historic tolerance for extra keys.\n */\ntype EventProps<E extends { type: EventType }> = Omit<E, \"type\"> & {\n [key: string]: unknown;\n};\n\nexport type BaseEventProps = EventProps<ProtocolBaseEvent>;\nexport type TextMessageStartEventProps = EventProps<\n import(\"./generated/types\").TextMessageStartEvent\n>;\nexport type TextMessageContentEventProps = EventProps<\n import(\"./generated/types\").TextMessageContentEvent\n>;\nexport type TextMessageEndEventProps = EventProps<import(\"./generated/types\").TextMessageEndEvent>;\nexport type TextMessageChunkEventProps = EventProps<\n import(\"./generated/types\").TextMessageChunkEvent\n>;\nexport type ToolCallStartEventProps = EventProps<import(\"./generated/types\").ToolCallStartEvent>;\nexport type ToolCallArgsEventProps = EventProps<import(\"./generated/types\").ToolCallArgsEvent>;\nexport type ToolCallEndEventProps = EventProps<import(\"./generated/types\").ToolCallEndEvent>;\nexport type ToolCallChunkEventProps = EventProps<import(\"./generated/types\").ToolCallChunkEvent>;\nexport type ToolCallResultEventProps = EventProps<import(\"./generated/types\").ToolCallResultEvent>;\nexport type StateSnapshotEventProps = EventProps<import(\"./generated/types\").StateSnapshotEvent>;\nexport type StateDeltaEventProps = EventProps<import(\"./generated/types\").StateDeltaEvent>;\nexport type MessagesSnapshotEventProps = EventProps<\n import(\"./generated/types\").MessagesSnapshotEvent\n>;\nexport type ActivitySnapshotEventProps = EventProps<\n import(\"./generated/types\").ActivitySnapshotEvent\n>;\nexport type ActivityDeltaEventProps = EventProps<import(\"./generated/types\").ActivityDeltaEvent>;\nexport type RawEventProps = EventProps<import(\"./generated/types\").RawEvent>;\nexport type CustomEventProps = EventProps<import(\"./generated/types\").CustomEvent>;\nexport type RunStartedEventProps = EventProps<import(\"./generated/types\").RunStartedEvent>;\nexport type RunFinishedEventProps = EventProps<import(\"./generated/types\").RunFinishedEvent>;\nexport type RunErrorEventProps = EventProps<import(\"./generated/types\").RunErrorEvent>;\nexport type StepStartedEventProps = EventProps<import(\"./generated/types\").StepStartedEvent>;\nexport type StepFinishedEventProps = EventProps<import(\"./generated/types\").StepFinishedEvent>;\nexport type ReasoningStartEventProps = EventProps<import(\"./generated/types\").ReasoningStartEvent>;\nexport type ReasoningMessageStartEventProps = EventProps<\n import(\"./generated/types\").ReasoningMessageStartEvent\n>;\nexport type ReasoningMessageContentEventProps = EventProps<\n import(\"./generated/types\").ReasoningMessageContentEvent\n>;\nexport type ReasoningMessageEndEventProps = EventProps<\n import(\"./generated/types\").ReasoningMessageEndEvent\n>;\nexport type ReasoningMessageChunkEventProps = EventProps<\n import(\"./generated/types\").ReasoningMessageChunkEvent\n>;\nexport type ReasoningEndEventProps = EventProps<import(\"./generated/types\").ReasoningEndEvent>;\nexport type ReasoningEncryptedValueEventProps = EventProps<\n import(\"./generated/types\").ReasoningEncryptedValueEvent\n>;\nexport type SubagentStartedEventProps = EventProps<\n import(\"./generated/types\").SubagentStartedEvent\n>;\nexport type SubagentFinishedEventProps = EventProps<\n import(\"./generated/types\").SubagentFinishedEvent\n>;\nexport type SubagentErrorEventProps = EventProps<import(\"./generated/types\").SubagentErrorEvent>;\n\n/**\n * The names the content parts carried before 1.0 renamed them (InputContent\n * -> ContentPart, TextInputContent -> TextPart, and so on): the same parts now\n * sit on tool messages as well as user messages, so they are named by what\n * they are rather than by direction. The wire is unchanged — every `type`\n * value is the same — and so is every type behind these names; only the\n * spelling moved. Kept for one release, see DEPRECATIONS.md. The matching\n * validator aliases live in src/schemas.ts, which is where every runtime\n * validator this package ships lives.\n *\n * @deprecated Use the ...Part names.\n */\nexport type InputContent = ContentPart;\n/** @deprecated Use TextPart. */\nexport type TextInputContent = TextPart;\n/** @deprecated Use ImagePart. */\nexport type ImageInputContent = ImagePart;\n/** @deprecated Use AudioPart. */\nexport type AudioInputContent = AudioPart;\n/** @deprecated Use VideoPart. */\nexport type VideoInputContent = VideoPart;\n/** @deprecated Use DocumentPart. */\nexport type DocumentInputContent = DocumentPart;\n/** @deprecated Use PartSource. */\nexport type InputContentSource = PartSource;\n/** @deprecated Use DataSource. */\nexport type InputContentDataSource = DataSource;\n/** @deprecated Use UrlSource. */\nexport type InputContentUrlSource = UrlSource;\n\n/**\n * Historic aliases for the media parts: this package has always also exported\n * them as ...InputPart.\n */\nexport type {\n ImagePart as ImageInputPart,\n AudioPart as AudioInputPart,\n VideoPart as VideoInputPart,\n DocumentPart as DocumentInputPart,\n} from \"./generated/types\";\n\n/** Historic alias: a content part of a user message. */\nexport type InputContentPart = ContentPart;\n\n/** Whether an interrupt was answered or abandoned. */\nexport type ResumeStatus = ResumeEntry[\"status\"];\n\nexport class AGUIError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n\nexport class AGUIConnectNotImplementedError extends AGUIError {\n constructor() {\n super(\"Connect not implemented. This method is not supported by the current agent.\");\n }\n}\n","import type { Metadata } from \"./generated/types\";\n\n/**\n * The key reserved for AG-UI's own use inside a metadata object. Every other\n * key is user space.\n *\n * Reservation is by convention: nothing rejects a write to this key at runtime,\n * because metadata is open by key and validating its shape would contradict\n * that.\n */\nexport const AGUI_METADATA_KEY = \"ag-ui\";\n\n/**\n * Extra information attached to an event or a message.\n *\n * Open by key — any JSON value is allowed under a key, including `null`.\n *\n * Deliberately `z.any()` rather than a recursive JSON-value schema, which review\n * has suggested more than once. Two reasons. Every dynamic payload in the\n * protocol uses the permissive form — `state`, `rawEvent`, `CustomEvent.value`,\n * `ActivityMessage.content`, and the pre-existing `Tool.metadata` and\n * `Interrupt.metadata` — so tightening this one field would make it the sole\n * outlier while fixing nothing elsewhere. And a recursive validation would walk\n * every value on every event, on the streaming hot path, to catch a mistake\n * (a function, a bigint) that already fails loudly at encode time.\n *\n * The schema itself now lives in the generated source (MetadataSchema in\n * src/generated/schemas.ts); this comment survives as the recorded reasoning.\n */\n/**\n * How metadata is declared on events and messages: the object is absent or an\n * object, never `null`. The validator pinning that invariant is\n * `OptionalMetadataSchema`, which lives in src/schemas.ts along with every\n * other runtime validator this package ships.\n */\n\n/**\n * Folds `incoming` metadata into `existing`, key by key, with the last write\n * winning.\n *\n * A message is assembled from a sequence of events, and the interesting values\n * — token usage and finish reason among them — are only known at the end. So\n * metadata accumulates as the sequence arrives rather than being fixed at the\n * start.\n *\n * A key's value is replaced outright. This never recurses, so an array or\n * object under any key — including {@link AGUI_METADATA_KEY} — is replaced\n * wholesale rather than blended with what was there before.\n *\n * Returns a new object rather than mutating either argument. An absent\n * `incoming` returns `existing` untouched; an empty `incoming` changes nothing.\n */\nexport function mergeMetadata(\n existing: Metadata | undefined,\n incoming: Metadata | undefined,\n): Metadata | undefined {\n if (incoming === undefined) {\n return existing;\n }\n if (existing === undefined) {\n return { ...incoming };\n }\n return { ...existing, ...incoming };\n}\n","import type { TokenUsage } from \"./generated/types\";\n\n/** The AG-UI names of the six token counts, in the order an entry lists them. */\nconst COUNT_KEYS = [\n \"inputTokens\",\n \"outputTokens\",\n \"totalTokens\",\n \"reasoningTokens\",\n \"cachedInputTokens\",\n \"cacheWriteInputTokens\",\n] as const;\n\n/**\n * The count keys already warned about, so the diagnostic below fires once per\n * process per key rather than once per event. A provider that hands over a\n * string count hands one over on every call, and a per-call warning would bury\n * the stream it is meant to annotate.\n */\nconst warnedCountKeys = new Set<string>();\n\n/** What the value WAS, said in a way that points at the provider's bug. */\nconst describeRejected = (v: unknown): string => {\n if (v === null) return \"null\";\n if (typeof v === \"string\") return `${JSON.stringify(v)} (a string)`;\n if (typeof v === \"number\") return `${String(v)} (a non-finite number)`;\n if (typeof v === \"object\") return `an object`;\n return `${String(v)} (a ${typeof v})`;\n};\n\n/**\n * Accept a value only if it is a real, finite number.\n *\n * Shared by both vendor mappers so they guard identically. Providers do hand\n * over strings, `null`s and `NaN`s in their usage metadata, and a bad value must\n * not reach the wire: consumers validate every incoming event and throw on\n * failure, so one malformed count would fail an otherwise-successful run at its\n * final event — costing the user the answer, not just the token count.\n *\n * Dropping it is right; dropping it in silence is not. The usage this run\n * reports is then simply wrong, with nothing anywhere saying which count went\n * missing or why, so a present-but-unusable value is named once per key.\n *\n * `undefined` and `NaN` are exempt because they are not defects: they are how a\n * provider spells \"did not report this count\". `undefined` covers both shapes —\n * an absent key in LangChain's `usage_metadata`, an explicit `undefined` in\n * AI-SDK's `LanguageModelUsage` — and AI-SDK uses `NaN` for the same thing,\n * which is why its mapper's docstring says so. Warning on those would fire on\n * ordinary traffic and train the reader to ignore the message.\n *\n * `key` is the AG-UI count name the value was headed for, not the vendor's\n * spelling of it, so one message reads the same whichever mapper produced it.\n */\nconst num = (v: unknown, key: (typeof COUNT_KEYS)[number]): number | undefined => {\n if (typeof v === \"number\" && Number.isFinite(v)) return v;\n const isAbsent = v === undefined || (typeof v === \"number\" && Number.isNaN(v));\n if (!isAbsent && !warnedCountKeys.has(key)) {\n warnedCountKeys.add(key);\n console.warn(\n `[ag-ui] usage.${key} was ${describeRejected(v)}, not a number — omitted from this run's usage. Reported once per key.`,\n );\n }\n return undefined;\n};\n\n/**\n * Read a property from a value of unknown shape, yielding `undefined` for\n * anything that is not an object. Lets the mappers take `unknown` rather than\n * `any` — vendor payloads are untrusted, so every access should be narrowed\n * rather than assumed.\n */\nconst prop = (v: unknown, key: string): unknown =>\n typeof v === \"object\" && v !== null ? (v as Record<string, unknown>)[key] : undefined;\n\n/**\n * Build a {@link TokenUsage} from already-guarded counts, or `undefined` when no\n * count survived. Returning `undefined` rather than a labels-only entry keeps\n * \"the provider reported no usage\" distinct from \"the provider reported usage\",\n * so callers omit the field instead of emitting an entry that claims nothing.\n */\nfunction buildEntry(\n counts: Partial<Record<(typeof COUNT_KEYS)[number], number | undefined>>,\n { provider, model }: { provider?: string; model?: string },\n): TokenUsage | undefined {\n if (!COUNT_KEYS.some((key) => counts[key] !== undefined)) return undefined;\n\n const entry: TokenUsage = {};\n if (provider != null) entry.provider = provider;\n if (model != null) entry.model = model;\n for (const key of COUNT_KEYS) {\n const value = counts[key];\n if (value !== undefined) entry[key] = value;\n }\n return entry;\n}\n\n/**\n * Map a LangChain-family `usage_metadata` object into an AG-UI {@link TokenUsage}.\n *\n * LangChain and LangGraph both attach usage as `{ input_tokens, output_tokens,\n * total_tokens, input_token_details: { cache_read, cache_creation },\n * output_token_details: { reasoning } }`. LangChain's accounting is the\n * protocol's — `input_tokens` already includes the cache details and\n * `output_tokens` the reasoning detail — so every count passes through as is.\n * This maps only those numeric counts plus optional provider/model labels —\n * never prompt/completion content. A count the provider\n * did not return is simply absent from `usage_metadata` and reads as\n * `undefined` here; that is not a defect and draws no warning. Returns\n * `undefined` when no usable count is present, so callers can omit usage rather\n * than report zeros.\n */\nexport function tokenUsageFromLangChainMetadata(\n usageMetadata: unknown,\n { provider, model }: { provider?: string; model?: string },\n): TokenUsage | undefined {\n if (!usageMetadata) return undefined;\n\n const inputDetails = prop(usageMetadata, \"input_token_details\");\n const outputDetails = prop(usageMetadata, \"output_token_details\");\n\n return buildEntry(\n {\n inputTokens: num(prop(usageMetadata, \"input_tokens\"), \"inputTokens\"),\n outputTokens: num(prop(usageMetadata, \"output_tokens\"), \"outputTokens\"),\n totalTokens: num(prop(usageMetadata, \"total_tokens\"), \"totalTokens\"),\n reasoningTokens: num(prop(outputDetails, \"reasoning\"), \"reasoningTokens\"),\n cachedInputTokens: num(prop(inputDetails, \"cache_read\"), \"cachedInputTokens\"),\n cacheWriteInputTokens: num(prop(inputDetails, \"cache_creation\"), \"cacheWriteInputTokens\"),\n },\n { provider, model },\n );\n}\n\n/**\n * Map an AI-SDK `LanguageModelUsage` object into an AG-UI {@link TokenUsage}.\n *\n * AI-SDK's v5 keys already match — `inputTokens`, `outputTokens`,\n * `totalTokens`, `reasoningTokens`, `cachedInputTokens` — with the totals\n * inclusive the way the protocol counts them. v6 adds `inputTokenDetails:\n * { cacheReadTokens, cacheWriteTokens }` and `outputTokenDetails:\n * { reasoningTokens }`; the cache-write count exists only there, and the two\n * counts present in both forms are read from the top level first. AI-SDK\n * reports `NaN`/`undefined` for counts a provider didn't return, so only finite\n * numbers are copied. Returns `undefined` when no finite count is present (so\n * callers omit empty usage).\n */\nexport function tokenUsageFromAiSdkUsage(\n usage: unknown,\n { provider, model }: { provider?: string; model?: string },\n): TokenUsage | undefined {\n if (!usage) return undefined;\n\n const inputDetails = prop(usage, \"inputTokenDetails\");\n const outputDetails = prop(usage, \"outputTokenDetails\");\n\n return buildEntry(\n {\n inputTokens: num(prop(usage, \"inputTokens\"), \"inputTokens\"),\n outputTokens: num(prop(usage, \"outputTokens\"), \"outputTokens\"),\n totalTokens: num(prop(usage, \"totalTokens\"), \"totalTokens\"),\n reasoningTokens:\n num(prop(usage, \"reasoningTokens\"), \"reasoningTokens\") ??\n num(prop(outputDetails, \"reasoningTokens\"), \"reasoningTokens\"),\n cachedInputTokens:\n num(prop(usage, \"cachedInputTokens\"), \"cachedInputTokens\") ??\n num(prop(inputDetails, \"cacheReadTokens\"), \"cachedInputTokens\"),\n cacheWriteInputTokens: num(prop(inputDetails, \"cacheWriteTokens\"), \"cacheWriteInputTokens\"),\n },\n { provider, model },\n );\n}\n\n/**\n * Sum per-call {@link TokenUsage} entries into one entry per `(provider, model)`\n * pair. Order follows first appearance. A count field stays `undefined` when no\n * member of the group reported it, so \"not reported\" stays distinct from zero.\n *\n * Protocol-agnostic: works on any producer's `TokenUsage[]`, so integrations\n * share it rather than reimplementing aggregation.\n */\nexport function aggregateTokenUsage(entries: TokenUsage[]): TokenUsage[] {\n const grouped = new Map<string, TokenUsage>();\n\n for (const entry of entries) {\n const key = `${entry.provider ?? \"\"} ${entry.model ?? \"\"}`;\n let target = grouped.get(key);\n if (!target) {\n target = { provider: entry.provider, model: entry.model };\n grouped.set(key, target);\n }\n for (const field of COUNT_KEYS) {\n const value = entry[field];\n if (value == null) continue;\n target[field] = (target[field] ?? 0) + value;\n }\n }\n\n return [...grouped.values()];\n}\n","import type { ContentPart } from \"./generated/types\";\n\n/**\n * The text of string-or-parts content, for a consumer that can only hold a\n * string: the text parts concatenated in order, every other part dropped.\n *\n * This is the downgrade the specification permits for a peer that predates\n * content parts (/spec/draft/basic/versioning): it removes and reshapes, and\n * it invents nothing — no placeholder stands in for a dropped image, because a\n * downgrade MUST NOT supply a value the producer never sent. Content that is\n * entirely media flattens to the empty string, which the same rule allows.\n *\n * Losing content is never meant to be silent. This helper only reshapes; a\n * caller that knows it is talking to an older peer warns as well, the way the\n * era shims in `@ag-ui/client` do.\n */\nexport function contentToText(content: string | ContentPart[] | undefined): string {\n if (content === undefined) return \"\";\n if (typeof content === \"string\") return content;\n return content\n .filter((part): part is Extract<ContentPart, { type: \"text\" }> => part.type === \"text\")\n .map((part) => part.text)\n .join(\"\");\n}\n\n/**\n * Whether string-or-parts content carries anything but text — the question a\n * caller asks before flattening, so it can warn about what the flattening\n * would drop.\n */\nexport function contentHasMedia(content: string | ContentPart[] | undefined): boolean {\n return Array.isArray(content) && content.some((part) => part.type !== \"text\");\n}\n"],"mappings":";;;AAYA,MAAM,SAAgC;CACpC,uBAAuB;EACrB,UAAU;GAAC;GAAa;GAAY;GAAY;GAAiB;GAAQ;GAAO;EAChF,QAAQ,EAAE;EACX;CACD,yBAAyB;EACvB,UAAU;GAAC;GAAa;GAAY;GAAY;GAAgB;EAChE,QAAQ,EAAE;EACX;CACD,qBAAqB;EACnB,UAAU;GAAC;GAAa;GAAY;GAAY;GAAgB;EAChE,QAAQ,EAAE;EACX;CACD,uBAAuB;EACrB,UAAU;GACR;GACA;GACA;GACA;GACA;GACA;GACA;GACA;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