@ag-ui/core 0.1.1-canary.beta.0 → 1.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["// Canonical TypeScript types for AG-UI messages, tools, run input, and core\n// supporting types. This is the authoritative type surface of @ag-ui/core.\n\nexport interface FunctionCall {\n name: string;\n arguments: string;\n}\n\nexport interface ToolCall {\n id: string;\n type: \"function\";\n function: FunctionCall;\n encryptedValue?: string;\n}\n\nexport interface TextInputContent {\n type: \"text\";\n text: string;\n}\n\nexport interface InputContentDataSource {\n type: \"data\";\n value: string;\n mimeType: string;\n}\n\nexport interface InputContentUrlSource {\n type: \"url\";\n value: string;\n mimeType?: string;\n}\n\nexport type InputContentSource = InputContentDataSource | InputContentUrlSource;\n\nexport interface ImageInputContent {\n type: \"image\";\n source: InputContentSource;\n metadata?: unknown;\n}\n\nexport interface AudioInputContent {\n type: \"audio\";\n source: InputContentSource;\n metadata?: unknown;\n}\n\nexport interface VideoInputContent {\n type: \"video\";\n source: InputContentSource;\n metadata?: unknown;\n}\n\nexport interface DocumentInputContent {\n type: \"document\";\n source: InputContentSource;\n metadata?: unknown;\n}\n\nexport type ImageInputPart = ImageInputContent;\nexport type AudioInputPart = AudioInputContent;\nexport type VideoInputPart = VideoInputContent;\nexport type DocumentInputPart = DocumentInputContent;\n\nexport interface BinaryInputContent {\n type: \"binary\";\n mimeType: string;\n id?: string;\n url?: string;\n data?: string;\n filename?: string;\n}\n\nexport type InputContent =\n | TextInputContent\n | ImageInputContent\n | AudioInputContent\n | VideoInputContent\n | DocumentInputContent\n | BinaryInputContent;\n\nexport type InputContentPart = InputContent;\n\ninterface BaseMessageFields {\n id: string;\n name?: string;\n encryptedValue?: string;\n}\n\nexport interface DeveloperMessage extends BaseMessageFields {\n role: \"developer\";\n content: string;\n}\n\nexport interface SystemMessage extends BaseMessageFields {\n role: \"system\";\n content: string;\n}\n\nexport interface AssistantMessage extends BaseMessageFields {\n role: \"assistant\";\n content?: string;\n toolCalls?: ToolCall[];\n}\n\nexport interface UserMessage extends BaseMessageFields {\n role: \"user\";\n content: string | InputContent[];\n}\n\nexport interface ToolMessage {\n id: string;\n content: string;\n role: \"tool\";\n toolCallId: string;\n error?: string;\n encryptedValue?: string;\n}\n\nexport interface ActivityMessage {\n id: string;\n role: \"activity\";\n activityType: string;\n content: Record<string, any>;\n}\n\nexport interface ReasoningMessage {\n id: string;\n role: \"reasoning\";\n content: string;\n encryptedValue?: string;\n}\n\nexport type Message =\n | DeveloperMessage\n | SystemMessage\n | AssistantMessage\n | UserMessage\n | ToolMessage\n | ActivityMessage\n | ReasoningMessage;\n\nexport type Role =\n | \"developer\"\n | \"system\"\n | \"assistant\"\n | \"user\"\n | \"tool\"\n | \"activity\"\n | \"reasoning\";\n\nexport interface Context {\n description: string;\n value: string;\n}\n\nexport interface Tool {\n name: string;\n description: string;\n parameters?: any;\n metadata?: Record<string, any>;\n}\n\nexport interface Interrupt {\n id: string;\n reason: string;\n message?: string;\n toolCallId?: string;\n responseSchema?: Record<string, any>;\n expiresAt?: string;\n metadata?: Record<string, any>;\n}\n\nexport type ResumeStatus = \"resolved\" | \"cancelled\";\n\nexport interface ResumeEntry {\n interruptId: string;\n status: ResumeStatus;\n payload?: any;\n}\n\nexport interface RunAgentInput {\n threadId: string;\n runId: string;\n parentRunId?: string;\n state?: any;\n messages: Message[];\n tools: Tool[];\n context: Context[];\n forwardedProps?: any;\n resume?: ResumeEntry[];\n}\n\nexport type State = any;\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"],"mappings":";;;AAkMA,IAAa,YAAb,cAA+B,MAAM;CACnC,YAAY,SAAiB;AAC3B,QAAM,QAAQ;;;AAIlB,IAAa,iCAAb,cAAoD,UAAU;CAC5D,cAAc;AACZ,QAAM,8EAA8E"}
1
+ {"version":3,"file":"index.mjs","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/1.0/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/1.0/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;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