@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.
- package/.gitattributes +1 -0
- package/CHANGELOG.md +10 -37
- package/README.md +13 -33
- package/dist/index.d.mts +219 -201
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +219 -201
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1038 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1029 -3
- package/dist/index.mjs.map +1 -1
- package/dist/schemas.d.mts +2576 -1076
- package/dist/schemas.d.mts.map +1 -1
- package/dist/schemas.d.ts +2576 -1076
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +959 -483
- package/dist/schemas.js.map +1 -1
- package/dist/schemas.mjs +899 -416
- package/dist/schemas.mjs.map +1 -1
- package/dist/{events-CMtdFXWl.js → version-BIes0ykB.js} +23 -12
- package/dist/version-BIes0ykB.js.map +1 -0
- package/dist/{events-BaoNrGbE.mjs → version-CTNE2I0_.mjs} +18 -13
- package/dist/version-CTNE2I0_.mjs.map +1 -0
- package/dist/version-DEKfpZNa.d.ts +2935 -0
- package/dist/version-DEKfpZNa.d.ts.map +1 -0
- package/dist/version-Dr0GiU8W.d.mts +2935 -0
- package/dist/version-Dr0GiU8W.d.mts.map +1 -0
- package/package.json +19 -3
- package/dist/events-BaoNrGbE.mjs.map +0 -1
- package/dist/events-Bg2nO3O2.d.mts +0 -467
- package/dist/events-Bg2nO3O2.d.mts.map +0 -1
- package/dist/events-CMtdFXWl.js.map +0 -1
- package/dist/events-JPFRVbr9.d.ts +0 -467
- package/dist/events-JPFRVbr9.d.ts.map +0 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/generated/serialization.ts","../src/compat.ts","../src/metad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,OAAA;AAAA;AAAA,cAKD,8BAAA,SAAuC,SAAA;EAAA,WAAA,CAAA;AAAA;;;;;ADiQpD;;;;;;cE5aa,iBAAA;;;;;;;;ADcb;;;;;AASA;;;;;AAGA;;;;;AAGA;;;;;;;;;;;;;;;;;iBCagB,aAAA,CACd,QAAA,EAAU,QAAA,cACV,QAAA,EAAU,QAAA,eACT,QAAA;;;;;AF+XH;;;;;;;;;;;;;iBGxUgB,+BAAA,CACd,aAAA;EACE,QAAA;EAAU;AAAA;EAAW,QAAA;EAAmB,KAAA;AAAA,IACzC,UAAA;;;AFhFH;;;;;AAGA;;;;;AAGA;iBE0GgB,wBAAA,CACd,KAAA;EACE,QAAA;EAAU;AAAA;EAAW,QAAA;EAAmB,KAAA;AAAA,IACzC,UAAA;;;;;;;;;iBA+Ba,mBAAA,CAAoB,OAAA,EAAS,UAAA,KAAe,UAAA;;;;;AHmQ5D;;;;;;;;;;;;iBItagB,aAAA,CAAc,OAAA,WAAkB,WAAA;;AHQhD;;;;iBGMgB,eAAA,CAAgB,OAAA,WAAkB,WAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,233 +1,251 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ReplaceOperation, A as JsonPointer, At as TextMessageStartEvent, B as PartSource, Bt as ToolMessage, C as FunctionCall, Ct as SubagentStartedEvent, D as Interrupt, Dt as TextMessageContentEvent, E as ImagePart, Et as TextMessageChunkEvent, F as MultiAgentCapabilities, Ft as ToolCallArgsEvent, G as ReasoningEndEvent, Gt as VideoPart, H as ReasoningCapabilities, Ht as TransportCapabilities, I as MultimodalCapabilities, It as ToolCallChunkEvent, J as ReasoningMessageContentEvent, K as ReasoningMessage, L as MultimodalInputCapabilities, Lt as ToolCallEndEvent, M as MessagesSnapshotEvent, Mt as TokenUsage, N as Metadata, Nt as Tool, O as JsonPatch, Ot as TextMessageEndEvent, P as MoveOperation, Pt as ToolCall, Q as RemoveOperation, R as MultimodalOutputCapabilities, Rt as ToolCallResultEvent, S as FileSource, St as SubagentRunId, T as IdentityCapabilities, Tt as TestOperation, U as ReasoningEncryptedValueEvent, Ut as UrlSource, V as RawEvent, Vt as ToolsCapabilities, W as ReasoningEncryptedValueSubtype, Wt as UserMessage, X as ReasoningMessageStartEvent, Y as ReasoningMessageEndEvent, Z as ReasoningStartEvent, _ as DeveloperMessage, _t as SubagentFinishedEvent, a as AddOperation, at as RunFinishedEvent, b as EventType, bt as SubagentFinishedSuspendedOutcome, c as Attributable, ct as RunFinishedSuccessOutcome, d as BaseMessage, dt as StateCapabilities, et as ResumeEntry, f as ContentPart, ft as StateDeltaEvent, g as DataSource, gt as SubagentErrorEvent, h as CustomEvent, ht as StepStartedEvent, i as ActivitySnapshotEvent, it as RunFinishedCancelledOutcome, j as Message, jt as TextPart, k as JsonPatchOperation, kt as TextMessageRole, l as AudioPart, lt as RunStartedEvent, m as CopyOperation, mt as StepFinishedEvent, n as ActivityDeltaEvent, nt as RunAgentInput, o as AgentCapabilities, ot as RunFinishedInterruptOutcome, p as Context, pt as StateSnapshotEvent, q as ReasoningMessageChunkEvent, r as ActivityMessage, rt as RunErrorEvent, s as AssistantMessage, st as RunFinishedOutcome, t as PROTOCOL_VERSION, tt as Role, u as BaseEvent$1, ut as State, v as DocumentPart, vt as SubagentFinishedOutcome, w as HumanInTheLoopCapabilities, wt as SystemMessage, x as ExecutionCapabilities, xt as SubagentInfo, y as Event, yt as SubagentFinishedSuccessOutcome, z as OutputCapabilities, zt as ToolCallStartEvent } from "./version-DEKfpZNa.js";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
4
|
-
/** Describes a sub-agent that can be invoked by a parent agent. */
|
|
5
|
-
interface SubAgentInfo {
|
|
6
|
-
/** Unique name or identifier of the sub-agent. */
|
|
7
|
-
name: string;
|
|
8
|
-
/** What this sub-agent specializes in. Helps clients build agent selection UIs. */
|
|
9
|
-
description?: string;
|
|
10
|
-
}
|
|
3
|
+
//#region src/generated/serialization.d.ts
|
|
11
4
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
5
|
+
* Omits whole optional null fields before transmission. Does not validate,
|
|
6
|
+
* mutate the input, or traverse arbitrary application JSON or unknown fields.
|
|
7
|
+
* Required null payloads and null values inside opaque data remain intact.
|
|
15
8
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** The framework or platform powering this agent (e.g., "langgraph", "mastra", "crewai"). */
|
|
20
|
-
type?: string;
|
|
21
|
-
/** What this agent does — helps users and routing logic decide when to use it. */
|
|
22
|
-
description?: string;
|
|
23
|
-
/** Semantic version of the agent (e.g., "1.2.0"). Useful for compatibility checks. */
|
|
24
|
-
version?: string;
|
|
25
|
-
/** Organization or team that maintains this agent. */
|
|
26
|
-
provider?: string;
|
|
27
|
-
/** URL to the agent's documentation or homepage. */
|
|
28
|
-
documentationUrl?: string;
|
|
29
|
-
/** Arbitrary key-value pairs for integration-specific identity info. */
|
|
30
|
-
metadata?: Record<string, unknown>;
|
|
31
|
-
}
|
|
9
|
+
declare function omitOptionalNulls<T>(value: T, root: "Event" | "RunAgentInput"): T;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/compat.d.ts
|
|
32
12
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
13
|
+
* Compatibility layer: the names this package has always exported, pointed at
|
|
14
|
+
* the generated protocol source. Everything protocol-shaped lives in
|
|
15
|
+
* src/generated (regenerate with `pnpm --filter @ag-ui/spec generate`); this
|
|
16
|
+
* file only aliases, derives, and carries the package's own error types.
|
|
36
17
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
streaming?: boolean;
|
|
40
|
-
/** Set `true` if the agent accepts persistent WebSocket connections. */
|
|
41
|
-
websocket?: boolean;
|
|
42
|
-
/** Set `true` if the agent supports the AG-UI binary protocol (protobuf over HTTP). */
|
|
43
|
-
httpBinary?: boolean;
|
|
44
|
-
/** Set `true` if the agent can send async updates via webhooks after a run finishes. */
|
|
45
|
-
pushNotifications?: boolean;
|
|
46
|
-
/** Set `true` if the agent supports resuming interrupted streams via sequence numbers. */
|
|
47
|
-
resumable?: boolean;
|
|
48
|
-
}
|
|
18
|
+
/** Every protocol event, under its historic name (the generated name is Event). */
|
|
19
|
+
type AGUIEvent = Event;
|
|
49
20
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
21
|
+
* The historic BaseEvent shape: the protocol's base fields plus an open index
|
|
22
|
+
* signature. The hand-written type inherited the index signature from zod's
|
|
23
|
+
* passthrough inference, and client code reads event-specific fields straight
|
|
24
|
+
* off a BaseEvent, so the compat surface keeps it. The exact protocol shape
|
|
25
|
+
* is the generated BaseEvent; the closed union of real events is `Event`.
|
|
53
26
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
27
|
+
type BaseEvent = BaseEvent$1 & {
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
/** The fields every event carries, under their historic name. */
|
|
31
|
+
type BaseEventFields = BaseEvent;
|
|
32
|
+
/** Event type discriminator -> concrete event, derived from the union. */
|
|
33
|
+
type AGUIEventByType = { [K in EventType]: Extract<Event, {
|
|
34
|
+
type: K;
|
|
35
|
+
}> };
|
|
36
|
+
type AGUIEventOf<T extends EventType> = AGUIEventByType[T];
|
|
37
|
+
type EventPayloadOf<T extends EventType> = T extends EventType ? Omit<AGUIEventOf<T>, keyof BaseEvent$1> : never;
|
|
66
38
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
39
|
+
* What a factory takes: the event's fields, minus the discriminator the
|
|
40
|
+
* factory sets. Derived from the generated event types rather than from
|
|
41
|
+
* z.input of the loose validators — a looseObject's input type carries a
|
|
42
|
+
* string index signature, and Omit over that erases every named field, which
|
|
43
|
+
* would let `{}` or a wrong-typed field compile. The trailing open signature
|
|
44
|
+
* keeps the historic tolerance for extra keys.
|
|
69
45
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
46
|
+
type EventProps<E extends {
|
|
47
|
+
type: EventType;
|
|
48
|
+
}> = Omit<E, "type"> & {
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
};
|
|
51
|
+
type BaseEventProps = EventProps<BaseEvent$1>;
|
|
52
|
+
type TextMessageStartEventProps = EventProps<TextMessageStartEvent>;
|
|
53
|
+
type TextMessageContentEventProps = EventProps<TextMessageContentEvent>;
|
|
54
|
+
type TextMessageEndEventProps = EventProps<TextMessageEndEvent>;
|
|
55
|
+
type TextMessageChunkEventProps = EventProps<TextMessageChunkEvent>;
|
|
56
|
+
type ToolCallStartEventProps = EventProps<ToolCallStartEvent>;
|
|
57
|
+
type ToolCallArgsEventProps = EventProps<ToolCallArgsEvent>;
|
|
58
|
+
type ToolCallEndEventProps = EventProps<ToolCallEndEvent>;
|
|
59
|
+
type ToolCallChunkEventProps = EventProps<ToolCallChunkEvent>;
|
|
60
|
+
type ToolCallResultEventProps = EventProps<ToolCallResultEvent>;
|
|
61
|
+
type StateSnapshotEventProps = EventProps<StateSnapshotEvent>;
|
|
62
|
+
type StateDeltaEventProps = EventProps<StateDeltaEvent>;
|
|
63
|
+
type MessagesSnapshotEventProps = EventProps<MessagesSnapshotEvent>;
|
|
64
|
+
type ActivitySnapshotEventProps = EventProps<ActivitySnapshotEvent>;
|
|
65
|
+
type ActivityDeltaEventProps = EventProps<ActivityDeltaEvent>;
|
|
66
|
+
type RawEventProps = EventProps<RawEvent>;
|
|
67
|
+
type CustomEventProps = EventProps<CustomEvent>;
|
|
68
|
+
type RunStartedEventProps = EventProps<RunStartedEvent>;
|
|
69
|
+
type RunFinishedEventProps = EventProps<RunFinishedEvent>;
|
|
70
|
+
type RunErrorEventProps = EventProps<RunErrorEvent>;
|
|
71
|
+
type StepStartedEventProps = EventProps<StepStartedEvent>;
|
|
72
|
+
type StepFinishedEventProps = EventProps<StepFinishedEvent>;
|
|
73
|
+
type ReasoningStartEventProps = EventProps<ReasoningStartEvent>;
|
|
74
|
+
type ReasoningMessageStartEventProps = EventProps<ReasoningMessageStartEvent>;
|
|
75
|
+
type ReasoningMessageContentEventProps = EventProps<ReasoningMessageContentEvent>;
|
|
76
|
+
type ReasoningMessageEndEventProps = EventProps<ReasoningMessageEndEvent>;
|
|
77
|
+
type ReasoningMessageChunkEventProps = EventProps<ReasoningMessageChunkEvent>;
|
|
78
|
+
type ReasoningEndEventProps = EventProps<ReasoningEndEvent>;
|
|
79
|
+
type ReasoningEncryptedValueEventProps = EventProps<ReasoningEncryptedValueEvent>;
|
|
80
|
+
type SubagentStartedEventProps = EventProps<SubagentStartedEvent>;
|
|
81
|
+
type SubagentFinishedEventProps = EventProps<SubagentFinishedEvent>;
|
|
82
|
+
type SubagentErrorEventProps = EventProps<SubagentErrorEvent>;
|
|
77
83
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
84
|
+
* The names the content parts carried before 1.0 renamed them (InputContent
|
|
85
|
+
* -> ContentPart, TextInputContent -> TextPart, and so on): the same parts now
|
|
86
|
+
* sit on tool messages as well as user messages, so they are named by what
|
|
87
|
+
* they are rather than by direction. The wire is unchanged — every `type`
|
|
88
|
+
* value is the same — and so is every type behind these names; only the
|
|
89
|
+
* spelling moved. Kept for one release, see DEPRECATIONS.md. The matching
|
|
90
|
+
* validator aliases live in src/schemas.ts, which is where every runtime
|
|
91
|
+
* validator this package ships lives.
|
|
92
|
+
*
|
|
93
|
+
* @deprecated Use the ...Part names.
|
|
80
94
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
type InputContent = ContentPart;
|
|
96
|
+
/** @deprecated Use TextPart. */
|
|
97
|
+
type TextInputContent = TextPart;
|
|
98
|
+
/** @deprecated Use ImagePart. */
|
|
99
|
+
type ImageInputContent = ImagePart;
|
|
100
|
+
/** @deprecated Use AudioPart. */
|
|
101
|
+
type AudioInputContent = AudioPart;
|
|
102
|
+
/** @deprecated Use VideoPart. */
|
|
103
|
+
type VideoInputContent = VideoPart;
|
|
104
|
+
/** @deprecated Use DocumentPart. */
|
|
105
|
+
type DocumentInputContent = DocumentPart;
|
|
106
|
+
/** @deprecated Use PartSource. */
|
|
107
|
+
type InputContentSource = PartSource;
|
|
108
|
+
/** @deprecated Use DataSource. */
|
|
109
|
+
type InputContentDataSource = DataSource;
|
|
110
|
+
/** @deprecated Use UrlSource. */
|
|
111
|
+
type InputContentUrlSource = UrlSource;
|
|
112
|
+
/** Historic alias: a content part of a user message. */
|
|
113
|
+
type InputContentPart = ContentPart;
|
|
114
|
+
/** Whether an interrupt was answered or abandoned. */
|
|
115
|
+
type ResumeStatus = ResumeEntry["status"];
|
|
116
|
+
declare class AGUIError extends Error {
|
|
117
|
+
constructor(message: string);
|
|
118
|
+
}
|
|
119
|
+
declare class AGUIConnectNotImplementedError extends AGUIError {
|
|
120
|
+
constructor();
|
|
92
121
|
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/metadata.d.ts
|
|
93
124
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
125
|
+
* The key reserved for AG-UI's own use inside a metadata object. Every other
|
|
126
|
+
* key is user space.
|
|
127
|
+
*
|
|
128
|
+
* Reservation is by convention: nothing rejects a write to this key at runtime,
|
|
129
|
+
* because metadata is open by key and validating its shape would contradict
|
|
130
|
+
* that.
|
|
96
131
|
*/
|
|
97
|
-
|
|
98
|
-
/** Set `true` if the agent participates in any form of multi-agent coordination. */
|
|
99
|
-
supported?: boolean;
|
|
100
|
-
/** Set `true` if the agent can delegate subtasks to other agents while retaining control. */
|
|
101
|
-
delegation?: boolean;
|
|
102
|
-
/** Set `true` if the agent can transfer the conversation entirely to another agent. */
|
|
103
|
-
handoffs?: boolean;
|
|
104
|
-
/** List of sub-agents this agent can invoke. Helps clients build agent selection UIs. */
|
|
105
|
-
subAgents?: SubAgentInfo[];
|
|
106
|
-
}
|
|
132
|
+
declare const AGUI_METADATA_KEY = "ag-ui";
|
|
107
133
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
134
|
+
* Extra information attached to an event or a message.
|
|
135
|
+
*
|
|
136
|
+
* Open by key — any JSON value is allowed under a key, including `null`.
|
|
137
|
+
*
|
|
138
|
+
* Deliberately `z.any()` rather than a recursive JSON-value schema, which review
|
|
139
|
+
* has suggested more than once. Two reasons. Every dynamic payload in the
|
|
140
|
+
* protocol uses the permissive form — `state`, `rawEvent`, `CustomEvent.value`,
|
|
141
|
+
* `ActivityMessage.content`, and the pre-existing `Tool.metadata` and
|
|
142
|
+
* `Interrupt.metadata` — so tightening this one field would make it the sole
|
|
143
|
+
* outlier while fixing nothing elsewhere. And a recursive validation would walk
|
|
144
|
+
* every value on every event, on the streaming hot path, to catch a mistake
|
|
145
|
+
* (a function, a bigint) that already fails loudly at encode time.
|
|
146
|
+
*
|
|
147
|
+
* The schema itself now lives in the generated source (MetadataSchema in
|
|
148
|
+
* src/generated/schemas.ts); this comment survives as the recorded reasoning.
|
|
110
149
|
*/
|
|
111
|
-
interface ReasoningCapabilities {
|
|
112
|
-
/** Set `true` if the agent produces reasoning/thinking tokens visible to the client. */
|
|
113
|
-
supported?: boolean;
|
|
114
|
-
/** Set `true` if reasoning tokens are streamed incrementally (vs. returned all at once). */
|
|
115
|
-
streaming?: boolean;
|
|
116
|
-
/** Set `true` if reasoning content is encrypted (zero-data-retention mode).
|
|
117
|
-
* Clients should expect opaque `encryptedValue` fields instead of readable content. */
|
|
118
|
-
encrypted?: boolean;
|
|
119
|
-
}
|
|
120
150
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
151
|
+
* How metadata is declared on events and messages: the object is absent or an
|
|
152
|
+
* object, never `null`. The validator pinning that invariant is
|
|
153
|
+
* `OptionalMetadataSchema`, which lives in src/schemas.ts along with every
|
|
154
|
+
* other runtime validator this package ships.
|
|
123
155
|
*/
|
|
124
|
-
interface MultimodalInputCapabilities {
|
|
125
|
-
/** Set `true` if the agent can process image inputs (e.g., screenshots, photos). */
|
|
126
|
-
image?: boolean;
|
|
127
|
-
/** Set `true` if the agent can process audio inputs (speech, recordings). */
|
|
128
|
-
audio?: boolean;
|
|
129
|
-
/** Set `true` if the agent can process video inputs. */
|
|
130
|
-
video?: boolean;
|
|
131
|
-
/** Set `true` if the agent can process PDF documents. */
|
|
132
|
-
pdf?: boolean;
|
|
133
|
-
/** Set `true` if the agent can process arbitrary file uploads. */
|
|
134
|
-
file?: boolean;
|
|
135
|
-
}
|
|
136
156
|
/**
|
|
137
|
-
*
|
|
138
|
-
*
|
|
157
|
+
* Folds `incoming` metadata into `existing`, key by key, with the last write
|
|
158
|
+
* winning.
|
|
159
|
+
*
|
|
160
|
+
* A message is assembled from a sequence of events, and the interesting values
|
|
161
|
+
* — token usage and finish reason among them — are only known at the end. So
|
|
162
|
+
* metadata accumulates as the sequence arrives rather than being fixed at the
|
|
163
|
+
* start.
|
|
164
|
+
*
|
|
165
|
+
* A key's value is replaced outright. This never recurses, so an array or
|
|
166
|
+
* object under any key — including {@link AGUI_METADATA_KEY} — is replaced
|
|
167
|
+
* wholesale rather than blended with what was there before.
|
|
168
|
+
*
|
|
169
|
+
* Returns a new object rather than mutating either argument. An absent
|
|
170
|
+
* `incoming` returns `existing` untouched; an empty `incoming` changes nothing.
|
|
139
171
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
/** Set `true` if the agent can produce audio output (text-to-speech, audio files). */
|
|
144
|
-
audio?: boolean;
|
|
145
|
-
}
|
|
172
|
+
declare function mergeMetadata(existing: Metadata | undefined, incoming: Metadata | undefined): Metadata | undefined;
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/token-usage.d.ts
|
|
146
175
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
176
|
+
* Map a LangChain-family `usage_metadata` object into an AG-UI {@link TokenUsage}.
|
|
177
|
+
*
|
|
178
|
+
* LangChain and LangGraph both attach usage as `{ input_tokens, output_tokens,
|
|
179
|
+
* total_tokens, input_token_details: { cache_read, cache_creation },
|
|
180
|
+
* output_token_details: { reasoning } }`. LangChain's accounting is the
|
|
181
|
+
* protocol's — `input_tokens` already includes the cache details and
|
|
182
|
+
* `output_tokens` the reasoning detail — so every count passes through as is.
|
|
183
|
+
* This maps only those numeric counts plus optional provider/model labels —
|
|
184
|
+
* never prompt/completion content. A count the provider
|
|
185
|
+
* did not return is simply absent from `usage_metadata` and reads as
|
|
186
|
+
* `undefined` here; that is not a defect and draws no warning. Returns
|
|
187
|
+
* `undefined` when no usable count is present, so callers can omit usage rather
|
|
188
|
+
* than report zeros.
|
|
150
189
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
190
|
+
declare function tokenUsageFromLangChainMetadata(usageMetadata: unknown, {
|
|
191
|
+
provider,
|
|
192
|
+
model
|
|
193
|
+
}: {
|
|
194
|
+
provider?: string;
|
|
195
|
+
model?: string;
|
|
196
|
+
}): TokenUsage | undefined;
|
|
157
197
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
198
|
+
* Map an AI-SDK `LanguageModelUsage` object into an AG-UI {@link TokenUsage}.
|
|
199
|
+
*
|
|
200
|
+
* AI-SDK's v5 keys already match — `inputTokens`, `outputTokens`,
|
|
201
|
+
* `totalTokens`, `reasoningTokens`, `cachedInputTokens` — with the totals
|
|
202
|
+
* inclusive the way the protocol counts them. v6 adds `inputTokenDetails:
|
|
203
|
+
* { cacheReadTokens, cacheWriteTokens }` and `outputTokenDetails:
|
|
204
|
+
* { reasoningTokens }`; the cache-write count exists only there, and the two
|
|
205
|
+
* counts present in both forms are read from the top level first. AI-SDK
|
|
206
|
+
* reports `NaN`/`undefined` for counts a provider didn't return, so only finite
|
|
207
|
+
* numbers are copied. Returns `undefined` when no finite count is present (so
|
|
208
|
+
* callers omit empty usage).
|
|
160
209
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
* Helps clients display progress or set timeout expectations. */
|
|
169
|
-
maxIterations?: number;
|
|
170
|
-
/** Maximum wall-clock time (in milliseconds) the agent will run before timing out. */
|
|
171
|
-
maxExecutionTime?: number;
|
|
172
|
-
}
|
|
210
|
+
declare function tokenUsageFromAiSdkUsage(usage: unknown, {
|
|
211
|
+
provider,
|
|
212
|
+
model
|
|
213
|
+
}: {
|
|
214
|
+
provider?: string;
|
|
215
|
+
model?: string;
|
|
216
|
+
}): TokenUsage | undefined;
|
|
173
217
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
218
|
+
* Sum per-call {@link TokenUsage} entries into one entry per `(provider, model)`
|
|
219
|
+
* pair. Order follows first appearance. A count field stays `undefined` when no
|
|
220
|
+
* member of the group reported it, so "not reported" stays distinct from zero.
|
|
221
|
+
*
|
|
222
|
+
* Protocol-agnostic: works on any producer's `TokenUsage[]`, so integrations
|
|
223
|
+
* share it rather than reimplementing aggregation.
|
|
176
224
|
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
/** Set `true` if the agent can pause and request explicit approval before
|
|
181
|
-
* performing sensitive actions (e.g., sending emails, deleting data). */
|
|
182
|
-
approvals?: boolean;
|
|
183
|
-
/** Set `true` if the agent allows humans to intervene and modify its plan mid-execution. */
|
|
184
|
-
interventions?: boolean;
|
|
185
|
-
/** Set `true` if the agent can incorporate user feedback (thumbs up/down, corrections)
|
|
186
|
-
* to improve its behavior within the current session. */
|
|
187
|
-
feedback?: boolean;
|
|
188
|
-
/** Set `true` if the agent participates in the AG-UI interrupt protocol
|
|
189
|
-
* (emits RUN_FINISHED with outcome={ type: "interrupt", interrupts: [...] },
|
|
190
|
-
* accepts resume[]). */
|
|
191
|
-
interrupts?: boolean;
|
|
192
|
-
/** Set `true` if tool-call interrupts accept editedArgs in the resume payload.
|
|
193
|
-
* Only meaningful when interrupts is true. */
|
|
194
|
-
approveWithEdits?: boolean;
|
|
195
|
-
}
|
|
225
|
+
declare function aggregateTokenUsage(entries: TokenUsage[]): TokenUsage[];
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/content.d.ts
|
|
196
228
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
229
|
+
* The text of string-or-parts content, for a consumer that can only hold a
|
|
230
|
+
* string: the text parts concatenated in order, every other part dropped.
|
|
199
231
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* it
|
|
232
|
+
* This is the downgrade the specification permits for a peer that predates
|
|
233
|
+
* content parts (/spec/1.0/basic/versioning): it removes and reshapes, and
|
|
234
|
+
* it invents nothing — no placeholder stands in for a dropped image, because a
|
|
235
|
+
* downgrade MUST NOT supply a value the producer never sent. Content that is
|
|
236
|
+
* entirely media flattens to the empty string, which the same rule allows.
|
|
203
237
|
*
|
|
204
|
-
*
|
|
205
|
-
* that
|
|
238
|
+
* Losing content is never meant to be silent. This helper only reshapes; a
|
|
239
|
+
* caller that knows it is talking to an older peer warns as well, the way the
|
|
240
|
+
* era shims in `@ag-ui/client` do.
|
|
206
241
|
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
/** Output format support (structured output, MIME types). */
|
|
215
|
-
output?: OutputCapabilities;
|
|
216
|
-
/** State and memory management (snapshots, deltas, persistence). */
|
|
217
|
-
state?: StateCapabilities;
|
|
218
|
-
/** Multi-agent coordination (delegation, handoffs, sub-agents). */
|
|
219
|
-
multiAgent?: MultiAgentCapabilities;
|
|
220
|
-
/** Reasoning and thinking support (chain-of-thought, encrypted thinking). */
|
|
221
|
-
reasoning?: ReasoningCapabilities;
|
|
222
|
-
/** Multimodal input/output support (images, audio, video, files). */
|
|
223
|
-
multimodal?: MultimodalCapabilities;
|
|
224
|
-
/** Execution control and limits (code execution, timeouts, iteration caps). */
|
|
225
|
-
execution?: ExecutionCapabilities;
|
|
226
|
-
/** Human-in-the-loop support (approvals, interventions, feedback). */
|
|
227
|
-
humanInTheLoop?: HumanInTheLoopCapabilities;
|
|
228
|
-
/** Integration-specific capabilities not covered by the standard categories. */
|
|
229
|
-
custom?: Record<string, unknown>;
|
|
230
|
-
}
|
|
242
|
+
declare function contentToText(content: string | ContentPart[] | undefined): string;
|
|
243
|
+
/**
|
|
244
|
+
* Whether string-or-parts content carries anything but text — the question a
|
|
245
|
+
* caller asks before flattening, so it can warn about what the flattening
|
|
246
|
+
* would drop.
|
|
247
|
+
*/
|
|
248
|
+
declare function contentHasMedia(content: string | ContentPart[] | undefined): boolean;
|
|
231
249
|
//#endregion
|
|
232
|
-
export { AGUIConnectNotImplementedError, AGUIError, AGUIEvent, AGUIEventByType, AGUIEventOf, ActivityDeltaEvent, ActivityDeltaEventProps, ActivityMessage, ActivitySnapshotEvent, ActivitySnapshotEventProps, AgentCapabilities, AssistantMessage, AudioInputContent, AudioInputPart, BaseEvent, BaseEventFields, BaseEventProps,
|
|
250
|
+
export { AGUIConnectNotImplementedError, AGUIError, AGUIEvent, AGUIEventByType, AGUIEventOf, AGUI_METADATA_KEY, ActivityDeltaEvent, ActivityDeltaEventProps, ActivityMessage, ActivitySnapshotEvent, ActivitySnapshotEventProps, AddOperation, AgentCapabilities, AssistantMessage, Attributable, AudioInputContent, type AudioPart as AudioInputPart, AudioPart, type BaseEvent, BaseEventFields, BaseEventProps, BaseMessage, ContentPart, Context, CopyOperation, CustomEvent, CustomEventProps, DataSource, DeveloperMessage, DocumentInputContent, type DocumentPart as DocumentInputPart, DocumentPart, Event, EventPayloadOf, EventType, ExecutionCapabilities, FileSource, FunctionCall, HumanInTheLoopCapabilities, IdentityCapabilities, ImageInputContent, type ImagePart as ImageInputPart, ImagePart, InputContent, InputContentDataSource, InputContentPart, InputContentSource, InputContentUrlSource, Interrupt, JsonPatch, JsonPatchOperation, JsonPointer, Message, MessagesSnapshotEvent, MessagesSnapshotEventProps, Metadata, MoveOperation, MultiAgentCapabilities, MultimodalCapabilities, MultimodalInputCapabilities, MultimodalOutputCapabilities, OutputCapabilities, PROTOCOL_VERSION, PartSource, RawEvent, RawEventProps, ReasoningCapabilities, ReasoningEncryptedValueEvent, ReasoningEncryptedValueEventProps, ReasoningEncryptedValueSubtype, ReasoningEndEvent, ReasoningEndEventProps, ReasoningMessage, ReasoningMessageChunkEvent, ReasoningMessageChunkEventProps, ReasoningMessageContentEvent, ReasoningMessageContentEventProps, ReasoningMessageEndEvent, ReasoningMessageEndEventProps, ReasoningMessageStartEvent, ReasoningMessageStartEventProps, ReasoningStartEvent, ReasoningStartEventProps, RemoveOperation, ReplaceOperation, ResumeEntry, ResumeStatus, Role, RunAgentInput, RunErrorEvent, RunErrorEventProps, RunFinishedCancelledOutcome, RunFinishedEvent, RunFinishedEventProps, RunFinishedInterruptOutcome, RunFinishedOutcome, RunFinishedSuccessOutcome, RunStartedEvent, RunStartedEventProps, State, StateCapabilities, StateDeltaEvent, StateDeltaEventProps, StateSnapshotEvent, StateSnapshotEventProps, StepFinishedEvent, StepFinishedEventProps, StepStartedEvent, StepStartedEventProps, SubagentErrorEvent, SubagentErrorEventProps, SubagentFinishedEvent, SubagentFinishedEventProps, SubagentFinishedOutcome, SubagentFinishedSuccessOutcome, SubagentFinishedSuspendedOutcome, SubagentInfo, SubagentRunId, SubagentStartedEvent, SubagentStartedEventProps, SystemMessage, TestOperation, TextInputContent, TextMessageChunkEvent, TextMessageChunkEventProps, TextMessageContentEvent, TextMessageContentEventProps, TextMessageEndEvent, TextMessageEndEventProps, TextMessageRole, TextMessageStartEvent, TextMessageStartEventProps, TextPart, TokenUsage, Tool, ToolCall, ToolCallArgsEvent, ToolCallArgsEventProps, ToolCallChunkEvent, ToolCallChunkEventProps, ToolCallEndEvent, ToolCallEndEventProps, ToolCallResultEvent, ToolCallResultEventProps, ToolCallStartEvent, ToolCallStartEventProps, ToolMessage, ToolsCapabilities, TransportCapabilities, UrlSource, UserMessage, VideoInputContent, type VideoPart as VideoInputPart, VideoPart, aggregateTokenUsage, contentHasMedia, contentToText, mergeMetadata, omitOptionalNulls, tokenUsageFromAiSdkUsage, tokenUsageFromLangChainMetadata };
|
|
233
251
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/generated/serialization.ts","../src/compat.ts","../src/metadata.ts","../src/token-usage.ts","../src/content.ts"],"mappings":";;;;;;AAsbA;;iBAAgB,iBAAA,GAAA,CAAqB,KAAA,EAAO,CAAA,EAAG,IAAA,8BAAkC,CAAA;;;;AAAjF;;;;;;KC9ZY,SAAA,GAAY,KAAA;;;;;;;;KASZ,SAAA,GAAY,WAAA;EAAA,CAAuB,GAAA;AAAA;;KAGnC,eAAA,GAAkB,SAAA;AAH9B;AAAA,KAMY,eAAA,WACJ,SAAA,GAAY,OAAA,CAAQ,KAAA;EAAS,IAAA,EAAM,CAAA;AAAA;AAAA,KAG/B,WAAA,WAAsB,SAAA,IAAa,eAAA,CAAgB,CAAA;AAAA,KAMnD,cAAA,WAAyB,SAAA,IAAa,CAAA,SAAU,SAAA,GACxD,IAAA,CACE,WAAA,CAAY,CAAA,SAIN,WAAA;;;AAhBZ;;;;;;KA4BK,UAAA;EAAuB,IAAA,EAAM,SAAA;AAAA,KAAe,IAAA,CAAK,CAAA;EAAA,CACnD,GAAA;AAAA;AAAA,KAGS,cAAA,GAAiB,UAAA,CAAW,WAAA;AAAA,KAC5B,0BAAA,GAA6B,UAAA,CAAH,qBAAA;AAAA,KAG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