@ag-ui/client 0.0.44 → 0.0.45

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.d.mts CHANGED
@@ -1,409 +1,473 @@
1
- import { Message, State, RunAgentInput, BaseEvent, RunStartedEvent, RunFinishedEvent, RunErrorEvent, StepStartedEvent, StepFinishedEvent, TextMessageStartEvent, TextMessageContentEvent, TextMessageEndEvent, ToolCallStartEvent, ToolCallArgsEvent, ToolCallEndEvent, ToolCallResultEvent, StateSnapshotEvent, StateDeltaEvent, MessagesSnapshotEvent, ActivitySnapshotEvent, ActivityMessage, ActivityDeltaEvent, RawEvent, CustomEvent, ToolCall } from '@ag-ui/core';
2
- export * from '@ag-ui/core';
3
- import { Observable } from 'rxjs';
4
- import { z } from 'zod';
1
+ import { ActivityDeltaEvent, ActivityMessage, ActivitySnapshotEvent, BaseEvent, CustomEvent, Message, MessagesSnapshotEvent, RawEvent, ReasoningEncryptedValueEvent, ReasoningEndEvent, ReasoningMessageContentEvent, ReasoningMessageEndEvent, ReasoningMessageStartEvent, ReasoningStartEvent, RunAgentInput, RunErrorEvent, RunFinishedEvent, RunStartedEvent, State, StateDeltaEvent, StateSnapshotEvent, StepFinishedEvent, StepStartedEvent, TextMessageContentEvent, TextMessageEndEvent, TextMessageStartEvent, ToolCall, ToolCallArgsEvent, ToolCallEndEvent, ToolCallResultEvent, ToolCallStartEvent } from "@ag-ui/core";
2
+ import { Observable } from "rxjs";
3
+ import { z } from "zod";
4
+ export * from "@ag-ui/core";
5
5
 
6
+ //#region src/agent/types.d.ts
6
7
  interface AgentConfig {
7
- agentId?: string;
8
- description?: string;
9
- threadId?: string;
10
- initialMessages?: Message[];
11
- initialState?: State;
12
- debug?: boolean;
8
+ agentId?: string;
9
+ description?: string;
10
+ threadId?: string;
11
+ initialMessages?: Message[];
12
+ initialState?: State;
13
+ debug?: boolean;
13
14
  }
14
15
  interface HttpAgentConfig extends AgentConfig {
15
- url: string;
16
- headers?: Record<string, string>;
16
+ url: string;
17
+ headers?: Record<string, string>;
17
18
  }
18
19
  type RunAgentParameters = Partial<Pick<RunAgentInput, "runId" | "tools" | "context" | "forwardedProps">>;
19
-
20
+ //#endregion
21
+ //#region src/legacy/types.d.ts
20
22
  declare const LegacyRuntimeProtocolEvent: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
21
- type: z.ZodLiteral<"TextMessageStart">;
22
- messageId: z.ZodString;
23
- parentMessageId: z.ZodOptional<z.ZodString>;
24
- role: z.ZodOptional<z.ZodString>;
23
+ type: z.ZodLiteral<"TextMessageStart">;
24
+ messageId: z.ZodString;
25
+ parentMessageId: z.ZodOptional<z.ZodString>;
26
+ role: z.ZodOptional<z.ZodString>;
25
27
  }, "strip", z.ZodTypeAny, {
26
- type: "TextMessageStart";
27
- messageId: string;
28
- role?: string | undefined;
29
- parentMessageId?: string | undefined;
28
+ type: "TextMessageStart";
29
+ messageId: string;
30
+ parentMessageId?: string | undefined;
31
+ role?: string | undefined;
30
32
  }, {
31
- type: "TextMessageStart";
32
- messageId: string;
33
- role?: string | undefined;
34
- parentMessageId?: string | undefined;
33
+ type: "TextMessageStart";
34
+ messageId: string;
35
+ parentMessageId?: string | undefined;
36
+ role?: string | undefined;
35
37
  }>, z.ZodObject<{
36
- type: z.ZodLiteral<"TextMessageContent">;
37
- messageId: z.ZodString;
38
- content: z.ZodString;
38
+ type: z.ZodLiteral<"TextMessageContent">;
39
+ messageId: z.ZodString;
40
+ content: z.ZodString;
39
41
  }, "strip", z.ZodTypeAny, {
40
- type: "TextMessageContent";
41
- messageId: string;
42
- content: string;
42
+ type: "TextMessageContent";
43
+ messageId: string;
44
+ content: string;
43
45
  }, {
44
- type: "TextMessageContent";
45
- messageId: string;
46
- content: string;
46
+ type: "TextMessageContent";
47
+ messageId: string;
48
+ content: string;
47
49
  }>, z.ZodObject<{
48
- type: z.ZodLiteral<"TextMessageEnd">;
49
- messageId: z.ZodString;
50
+ type: z.ZodLiteral<"TextMessageEnd">;
51
+ messageId: z.ZodString;
50
52
  }, "strip", z.ZodTypeAny, {
51
- type: "TextMessageEnd";
52
- messageId: string;
53
+ type: "TextMessageEnd";
54
+ messageId: string;
53
55
  }, {
54
- type: "TextMessageEnd";
55
- messageId: string;
56
+ type: "TextMessageEnd";
57
+ messageId: string;
56
58
  }>, z.ZodObject<{
57
- type: z.ZodLiteral<"ActionExecutionStart">;
58
- actionExecutionId: z.ZodString;
59
- actionName: z.ZodString;
60
- parentMessageId: z.ZodOptional<z.ZodString>;
59
+ type: z.ZodLiteral<"ActionExecutionStart">;
60
+ actionExecutionId: z.ZodString;
61
+ actionName: z.ZodString;
62
+ parentMessageId: z.ZodOptional<z.ZodString>;
61
63
  }, "strip", z.ZodTypeAny, {
62
- type: "ActionExecutionStart";
63
- actionExecutionId: string;
64
- actionName: string;
65
- parentMessageId?: string | undefined;
64
+ type: "ActionExecutionStart";
65
+ actionExecutionId: string;
66
+ actionName: string;
67
+ parentMessageId?: string | undefined;
66
68
  }, {
67
- type: "ActionExecutionStart";
68
- actionExecutionId: string;
69
- actionName: string;
70
- parentMessageId?: string | undefined;
69
+ type: "ActionExecutionStart";
70
+ actionExecutionId: string;
71
+ actionName: string;
72
+ parentMessageId?: string | undefined;
71
73
  }>, z.ZodObject<{
72
- type: z.ZodLiteral<"ActionExecutionArgs">;
73
- actionExecutionId: z.ZodString;
74
- args: z.ZodString;
74
+ type: z.ZodLiteral<"ActionExecutionArgs">;
75
+ actionExecutionId: z.ZodString;
76
+ args: z.ZodString;
75
77
  }, "strip", z.ZodTypeAny, {
76
- type: "ActionExecutionArgs";
77
- actionExecutionId: string;
78
- args: string;
78
+ type: "ActionExecutionArgs";
79
+ actionExecutionId: string;
80
+ args: string;
79
81
  }, {
80
- type: "ActionExecutionArgs";
81
- actionExecutionId: string;
82
- args: string;
82
+ type: "ActionExecutionArgs";
83
+ actionExecutionId: string;
84
+ args: string;
83
85
  }>, z.ZodObject<{
84
- type: z.ZodLiteral<"ActionExecutionEnd">;
85
- actionExecutionId: z.ZodString;
86
+ type: z.ZodLiteral<"ActionExecutionEnd">;
87
+ actionExecutionId: z.ZodString;
86
88
  }, "strip", z.ZodTypeAny, {
87
- type: "ActionExecutionEnd";
88
- actionExecutionId: string;
89
+ type: "ActionExecutionEnd";
90
+ actionExecutionId: string;
89
91
  }, {
90
- type: "ActionExecutionEnd";
91
- actionExecutionId: string;
92
+ type: "ActionExecutionEnd";
93
+ actionExecutionId: string;
92
94
  }>, z.ZodObject<{
93
- type: z.ZodLiteral<"ActionExecutionResult">;
94
- actionName: z.ZodString;
95
- actionExecutionId: z.ZodString;
96
- result: z.ZodString;
95
+ type: z.ZodLiteral<"ActionExecutionResult">;
96
+ actionName: z.ZodString;
97
+ actionExecutionId: z.ZodString;
98
+ result: z.ZodString;
97
99
  }, "strip", z.ZodTypeAny, {
98
- type: "ActionExecutionResult";
99
- actionExecutionId: string;
100
- actionName: string;
101
- result: string;
100
+ type: "ActionExecutionResult";
101
+ actionExecutionId: string;
102
+ actionName: string;
103
+ result: string;
102
104
  }, {
103
- type: "ActionExecutionResult";
104
- actionExecutionId: string;
105
- actionName: string;
106
- result: string;
105
+ type: "ActionExecutionResult";
106
+ actionExecutionId: string;
107
+ actionName: string;
108
+ result: string;
107
109
  }>, z.ZodObject<{
108
- type: z.ZodLiteral<"AgentStateMessage">;
109
- threadId: z.ZodString;
110
- agentName: z.ZodString;
111
- nodeName: z.ZodString;
112
- runId: z.ZodString;
113
- active: z.ZodBoolean;
114
- role: z.ZodString;
115
- state: z.ZodString;
116
- running: z.ZodBoolean;
110
+ type: z.ZodLiteral<"AgentStateMessage">;
111
+ threadId: z.ZodString;
112
+ agentName: z.ZodString;
113
+ nodeName: z.ZodString;
114
+ runId: z.ZodString;
115
+ active: z.ZodBoolean;
116
+ role: z.ZodString;
117
+ state: z.ZodString;
118
+ running: z.ZodBoolean;
117
119
  }, "strip", z.ZodTypeAny, {
118
- role: string;
119
- runId: string;
120
- threadId: string;
121
- state: string;
122
- type: "AgentStateMessage";
123
- agentName: string;
124
- nodeName: string;
125
- active: boolean;
126
- running: boolean;
120
+ type: "AgentStateMessage";
121
+ role: string;
122
+ threadId: string;
123
+ agentName: string;
124
+ nodeName: string;
125
+ runId: string;
126
+ active: boolean;
127
+ state: string;
128
+ running: boolean;
127
129
  }, {
128
- role: string;
129
- runId: string;
130
- threadId: string;
131
- state: string;
132
- type: "AgentStateMessage";
133
- agentName: string;
134
- nodeName: string;
135
- active: boolean;
136
- running: boolean;
130
+ type: "AgentStateMessage";
131
+ role: string;
132
+ threadId: string;
133
+ agentName: string;
134
+ nodeName: string;
135
+ runId: string;
136
+ active: boolean;
137
+ state: string;
138
+ running: boolean;
137
139
  }>, z.ZodObject<{
138
- type: z.ZodLiteral<"MetaEvent">;
139
- name: z.ZodEnum<["LangGraphInterruptEvent", "PredictState", "Exit"]>;
140
- value: z.ZodAny;
140
+ type: z.ZodLiteral<"MetaEvent">;
141
+ name: z.ZodEnum<["LangGraphInterruptEvent", "PredictState", "Exit"]>;
142
+ value: z.ZodAny;
141
143
  }, "strip", z.ZodTypeAny, {
142
- type: "MetaEvent";
143
- name: "LangGraphInterruptEvent" | "PredictState" | "Exit";
144
- value?: any;
144
+ type: "MetaEvent";
145
+ name: "LangGraphInterruptEvent" | "PredictState" | "Exit";
146
+ value?: any;
145
147
  }, {
146
- type: "MetaEvent";
147
- name: "LangGraphInterruptEvent" | "PredictState" | "Exit";
148
- value?: any;
148
+ type: "MetaEvent";
149
+ name: "LangGraphInterruptEvent" | "PredictState" | "Exit";
150
+ value?: any;
149
151
  }>, z.ZodObject<{
150
- type: z.ZodLiteral<"RunError">;
151
- message: z.ZodString;
152
- code: z.ZodOptional<z.ZodString>;
152
+ type: z.ZodLiteral<"RunError">;
153
+ message: z.ZodString;
154
+ code: z.ZodOptional<z.ZodString>;
153
155
  }, "strip", z.ZodTypeAny, {
154
- type: "RunError";
155
- message: string;
156
- code?: string | undefined;
156
+ type: "RunError";
157
+ message: string;
158
+ code?: string | undefined;
157
159
  }, {
158
- type: "RunError";
159
- message: string;
160
- code?: string | undefined;
160
+ type: "RunError";
161
+ message: string;
162
+ code?: string | undefined;
161
163
  }>]>;
162
164
  type LegacyRuntimeProtocolEvent = z.infer<typeof LegacyRuntimeProtocolEvent>;
163
-
165
+ //#endregion
166
+ //#region src/agent/subscriber.d.ts
167
+ interface AgentStateMutation {
168
+ messages?: Message[];
169
+ state?: State;
170
+ stopPropagation?: boolean;
171
+ }
172
+ interface AgentSubscriberParams {
173
+ messages: Message[];
174
+ state: State;
175
+ agent: AbstractAgent;
176
+ input: RunAgentInput;
177
+ }
178
+ type MaybePromise<T> = T | Promise<T>;
179
+ interface AgentSubscriber {
180
+ onRunInitialized?(params: AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
181
+ onRunFailed?(params: {
182
+ error: Error;
183
+ } & AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
184
+ onRunFinalized?(params: AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
185
+ onEvent?(params: {
186
+ event: BaseEvent;
187
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
188
+ onRunStartedEvent?(params: {
189
+ event: RunStartedEvent;
190
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
191
+ onRunFinishedEvent?(params: {
192
+ event: RunFinishedEvent;
193
+ result?: any;
194
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
195
+ onRunErrorEvent?(params: {
196
+ event: RunErrorEvent;
197
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
198
+ onStepStartedEvent?(params: {
199
+ event: StepStartedEvent;
200
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
201
+ onStepFinishedEvent?(params: {
202
+ event: StepFinishedEvent;
203
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
204
+ onTextMessageStartEvent?(params: {
205
+ event: TextMessageStartEvent;
206
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
207
+ onTextMessageContentEvent?(params: {
208
+ event: TextMessageContentEvent;
209
+ textMessageBuffer: string;
210
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
211
+ onTextMessageEndEvent?(params: {
212
+ event: TextMessageEndEvent;
213
+ textMessageBuffer: string;
214
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
215
+ onToolCallStartEvent?(params: {
216
+ event: ToolCallStartEvent;
217
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
218
+ onToolCallArgsEvent?(params: {
219
+ event: ToolCallArgsEvent;
220
+ toolCallBuffer: string;
221
+ toolCallName: string;
222
+ partialToolCallArgs: Record<string, any>;
223
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
224
+ onToolCallEndEvent?(params: {
225
+ event: ToolCallEndEvent;
226
+ toolCallName: string;
227
+ toolCallArgs: Record<string, any>;
228
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
229
+ onToolCallResultEvent?(params: {
230
+ event: ToolCallResultEvent;
231
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
232
+ onStateSnapshotEvent?(params: {
233
+ event: StateSnapshotEvent;
234
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
235
+ onStateDeltaEvent?(params: {
236
+ event: StateDeltaEvent;
237
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
238
+ onMessagesSnapshotEvent?(params: {
239
+ event: MessagesSnapshotEvent;
240
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
241
+ onActivitySnapshotEvent?(params: {
242
+ event: ActivitySnapshotEvent;
243
+ activityMessage?: ActivityMessage;
244
+ existingMessage?: Message;
245
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
246
+ onActivityDeltaEvent?(params: {
247
+ event: ActivityDeltaEvent;
248
+ activityMessage?: ActivityMessage;
249
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
250
+ onRawEvent?(params: {
251
+ event: RawEvent;
252
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
253
+ onCustomEvent?(params: {
254
+ event: CustomEvent;
255
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
256
+ onReasoningStartEvent?(params: {
257
+ event: ReasoningStartEvent;
258
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
259
+ onReasoningMessageStartEvent?(params: {
260
+ event: ReasoningMessageStartEvent;
261
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
262
+ onReasoningMessageContentEvent?(params: {
263
+ event: ReasoningMessageContentEvent;
264
+ reasoningMessageBuffer: string;
265
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
266
+ onReasoningMessageEndEvent?(params: {
267
+ event: ReasoningMessageEndEvent;
268
+ reasoningMessageBuffer: string;
269
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
270
+ onReasoningEndEvent?(params: {
271
+ event: ReasoningEndEvent;
272
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
273
+ onReasoningEncryptedValueEvent?(params: {
274
+ event: ReasoningEncryptedValueEvent;
275
+ } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
276
+ onMessagesChanged?(params: Omit<AgentSubscriberParams, "input"> & {
277
+ input?: RunAgentInput;
278
+ }): MaybePromise<void>;
279
+ onStateChanged?(params: Omit<AgentSubscriberParams, "input"> & {
280
+ input?: RunAgentInput;
281
+ }): MaybePromise<void>;
282
+ onNewMessage?(params: {
283
+ message: Message;
284
+ } & Omit<AgentSubscriberParams, "input"> & {
285
+ input?: RunAgentInput;
286
+ }): MaybePromise<void>;
287
+ onNewToolCall?(params: {
288
+ toolCall: ToolCall;
289
+ } & Omit<AgentSubscriberParams, "input"> & {
290
+ input?: RunAgentInput;
291
+ }): MaybePromise<void>;
292
+ }
293
+ //#endregion
294
+ //#region src/agent/http.d.ts
164
295
  interface RunHttpAgentConfig extends RunAgentParameters {
165
- abortController?: AbortController;
296
+ abortController?: AbortController;
166
297
  }
167
298
  declare class HttpAgent extends AbstractAgent {
168
- url: string;
169
- headers: Record<string, string>;
170
- abortController: AbortController;
171
- /**
172
- * Returns the fetch config for the http request.
173
- * Override this to customize the request.
174
- *
175
- * @returns The fetch config for the http request.
176
- */
177
- protected requestInit(input: RunAgentInput): RequestInit;
178
- runAgent(parameters?: RunHttpAgentConfig, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
179
- abortRun(): void;
180
- constructor(config: HttpAgentConfig);
181
- run(input: RunAgentInput): Observable<BaseEvent>;
182
- clone(): HttpAgent;
299
+ url: string;
300
+ headers: Record<string, string>;
301
+ abortController: AbortController;
302
+ /**
303
+ * Returns the fetch config for the http request.
304
+ * Override this to customize the request.
305
+ *
306
+ * @returns The fetch config for the http request.
307
+ */
308
+ protected requestInit(input: RunAgentInput): RequestInit;
309
+ runAgent(parameters?: RunHttpAgentConfig, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
310
+ abortRun(): void;
311
+ constructor(config: HttpAgentConfig);
312
+ run(input: RunAgentInput): Observable<BaseEvent>;
313
+ clone(): HttpAgent;
183
314
  }
184
-
315
+ //#endregion
316
+ //#region src/middleware/middleware.d.ts
185
317
  type MiddlewareFunction = (input: RunAgentInput, next: AbstractAgent) => Observable<BaseEvent>;
186
318
  interface EventWithState {
187
- event: BaseEvent;
188
- messages: Message[];
189
- state: any;
319
+ event: BaseEvent;
320
+ messages: Message[];
321
+ state: any;
190
322
  }
191
323
  declare abstract class Middleware {
192
- abstract run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
193
- /**
194
- * Runs the next agent in the chain with automatic chunk transformation.
195
- */
196
- protected runNext(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
197
- /**
198
- * Runs the next agent and tracks state, providing current messages and state with each event.
199
- * The messages and state represent the state AFTER the event has been applied.
200
- */
201
- protected runNextWithState(input: RunAgentInput, next: AbstractAgent): Observable<EventWithState>;
324
+ abstract run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
325
+ /**
326
+ * Runs the next agent in the chain with automatic chunk transformation.
327
+ */
328
+ protected runNext(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
329
+ /**
330
+ * Runs the next agent and tracks state, providing current messages and state with each event.
331
+ * The messages and state represent the state AFTER the event has been applied.
332
+ */
333
+ protected runNextWithState(input: RunAgentInput, next: AbstractAgent): Observable<EventWithState>;
202
334
  }
203
335
  declare class FunctionMiddleware extends Middleware {
204
- private fn;
205
- constructor(fn: MiddlewareFunction);
206
- run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
336
+ private fn;
337
+ constructor(fn: MiddlewareFunction);
338
+ run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
207
339
  }
208
-
340
+ //#endregion
341
+ //#region src/middleware/filter-tool-calls.d.ts
209
342
  type FilterToolCallsConfig = {
210
- allowedToolCalls: string[];
211
- disallowedToolCalls?: never;
343
+ allowedToolCalls: string[];
344
+ disallowedToolCalls?: never;
212
345
  } | {
213
- disallowedToolCalls: string[];
214
- allowedToolCalls?: never;
346
+ disallowedToolCalls: string[];
347
+ allowedToolCalls?: never;
215
348
  };
216
349
  declare class FilterToolCallsMiddleware extends Middleware {
217
- private blockedToolCallIds;
218
- private readonly allowedTools?;
219
- private readonly disallowedTools?;
220
- constructor(config: FilterToolCallsConfig);
221
- run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
222
- private shouldFilterTool;
350
+ private blockedToolCallIds;
351
+ private readonly allowedTools?;
352
+ private readonly disallowedTools?;
353
+ constructor(config: FilterToolCallsConfig);
354
+ run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
355
+ private shouldFilterTool;
223
356
  }
224
-
357
+ //#endregion
358
+ //#region src/middleware/backward-compatibility-0-0-39.d.ts
225
359
  /**
226
360
  * Middleware placeholder that maintains compatibility with AG-UI 0.0.39 flows.
227
361
  * Currently it simply forwards all events to the next middleware/agent.
228
362
  */
229
363
  declare class BackwardCompatibility_0_0_39 extends Middleware {
230
- run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
364
+ run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
231
365
  }
232
-
366
+ //#endregion
367
+ //#region src/middleware/backward-compatibility-0-0-45.d.ts
368
+ /**
369
+ * Middleware that maps deprecated THINKING events to the new REASONING events.
370
+ *
371
+ * This ensures backward compatibility for agents that still emit legacy THINKING
372
+ * events (THINKING_START, THINKING_END, THINKING_TEXT_MESSAGE_START, etc.)
373
+ * by transforming them into the corresponding REASONING events.
374
+ *
375
+ * Event mapping:
376
+ * - THINKING_START → REASONING_START
377
+ * - THINKING_TEXT_MESSAGE_START → REASONING_MESSAGE_START
378
+ * - THINKING_TEXT_MESSAGE_CONTENT → REASONING_MESSAGE_CONTENT
379
+ * - THINKING_TEXT_MESSAGE_END → REASONING_MESSAGE_END
380
+ * - THINKING_END → REASONING_END
381
+ *
382
+ */
383
+ declare class BackwardCompatibility_0_0_45 extends Middleware {
384
+ private currentReasoningId;
385
+ private currentMessageId;
386
+ private warnAboutTransformation;
387
+ run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
388
+ private transformEvent;
389
+ }
390
+ //#endregion
391
+ //#region src/agent/agent.d.ts
233
392
  interface RunAgentResult {
234
- result: any;
235
- newMessages: Message[];
393
+ result: any;
394
+ newMessages: Message[];
236
395
  }
237
396
  declare abstract class AbstractAgent {
238
- agentId?: string;
239
- description: string;
240
- threadId: string;
241
- messages: Message[];
242
- state: State;
243
- debug: boolean;
244
- subscribers: AgentSubscriber[];
245
- isRunning: boolean;
246
- private middlewares;
247
- private activeRunDetach$?;
248
- private activeRunCompletionPromise?;
249
- get maxVersion(): string;
250
- constructor({ agentId, description, threadId, initialMessages, initialState, debug, }?: AgentConfig);
251
- subscribe(subscriber: AgentSubscriber): {
252
- unsubscribe: () => void;
253
- };
254
- abstract run(input: RunAgentInput): Observable<BaseEvent>;
255
- use(...middlewares: (Middleware | MiddlewareFunction)[]): this;
256
- runAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
257
- protected connect(input: RunAgentInput): Observable<BaseEvent>;
258
- connectAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
259
- abortRun(): void;
260
- detachActiveRun(): Promise<void>;
261
- protected apply(input: RunAgentInput, events$: Observable<BaseEvent>, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
262
- protected processApplyEvents(input: RunAgentInput, events$: Observable<AgentStateMutation>, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
263
- protected prepareRunAgentInput(parameters?: RunAgentParameters): RunAgentInput;
264
- protected onInitialize(input: RunAgentInput, subscribers: AgentSubscriber[]): Promise<void>;
265
- protected onError(input: RunAgentInput, error: Error, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
266
- protected onFinalize(input: RunAgentInput, subscribers: AgentSubscriber[]): Promise<void>;
267
- clone(): any;
268
- addMessage(message: Message): void;
269
- addMessages(messages: Message[]): void;
270
- setMessages(messages: Message[]): void;
271
- setState(state: State): void;
272
- legacy_to_be_removed_runAgentBridged(config?: RunAgentParameters): Observable<LegacyRuntimeProtocolEvent>;
273
- }
274
-
275
- interface AgentStateMutation {
276
- messages?: Message[];
277
- state?: State;
278
- stopPropagation?: boolean;
279
- }
280
- interface AgentSubscriberParams {
281
- messages: Message[];
282
- state: State;
283
- agent: AbstractAgent;
284
- input: RunAgentInput;
397
+ agentId?: string;
398
+ description: string;
399
+ threadId: string;
400
+ messages: Message[];
401
+ state: State;
402
+ debug: boolean;
403
+ subscribers: AgentSubscriber[];
404
+ isRunning: boolean;
405
+ private middlewares;
406
+ private activeRunDetach$?;
407
+ private activeRunCompletionPromise?;
408
+ get maxVersion(): string;
409
+ constructor({
410
+ agentId,
411
+ description,
412
+ threadId,
413
+ initialMessages,
414
+ initialState,
415
+ debug
416
+ }?: AgentConfig);
417
+ subscribe(subscriber: AgentSubscriber): {
418
+ unsubscribe: () => void;
419
+ };
420
+ abstract run(input: RunAgentInput): Observable<BaseEvent>;
421
+ use(...middlewares: (Middleware | MiddlewareFunction)[]): this;
422
+ runAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
423
+ protected connect(input: RunAgentInput): Observable<BaseEvent>;
424
+ connectAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
425
+ abortRun(): void;
426
+ detachActiveRun(): Promise<void>;
427
+ protected apply(input: RunAgentInput, events$: Observable<BaseEvent>, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
428
+ protected processApplyEvents(input: RunAgentInput, events$: Observable<AgentStateMutation>, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
429
+ protected prepareRunAgentInput(parameters?: RunAgentParameters): RunAgentInput;
430
+ protected onInitialize(input: RunAgentInput, subscribers: AgentSubscriber[]): Promise<void>;
431
+ protected onError(input: RunAgentInput, error: Error, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
432
+ protected onFinalize(input: RunAgentInput, subscribers: AgentSubscriber[]): Promise<void>;
433
+ clone(): any;
434
+ addMessage(message: Message): void;
435
+ addMessages(messages: Message[]): void;
436
+ setMessages(messages: Message[]): void;
437
+ setState(state: State): void;
438
+ legacy_to_be_removed_runAgentBridged(config?: RunAgentParameters): Observable<LegacyRuntimeProtocolEvent>;
285
439
  }
286
- type MaybePromise<T> = T | Promise<T>;
287
- interface AgentSubscriber {
288
- onRunInitialized?(params: AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
289
- onRunFailed?(params: {
290
- error: Error;
291
- } & AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
292
- onRunFinalized?(params: AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
293
- onEvent?(params: {
294
- event: BaseEvent;
295
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
296
- onRunStartedEvent?(params: {
297
- event: RunStartedEvent;
298
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
299
- onRunFinishedEvent?(params: {
300
- event: RunFinishedEvent;
301
- result?: any;
302
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
303
- onRunErrorEvent?(params: {
304
- event: RunErrorEvent;
305
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
306
- onStepStartedEvent?(params: {
307
- event: StepStartedEvent;
308
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
309
- onStepFinishedEvent?(params: {
310
- event: StepFinishedEvent;
311
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
312
- onTextMessageStartEvent?(params: {
313
- event: TextMessageStartEvent;
314
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
315
- onTextMessageContentEvent?(params: {
316
- event: TextMessageContentEvent;
317
- textMessageBuffer: string;
318
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
319
- onTextMessageEndEvent?(params: {
320
- event: TextMessageEndEvent;
321
- textMessageBuffer: string;
322
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
323
- onToolCallStartEvent?(params: {
324
- event: ToolCallStartEvent;
325
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
326
- onToolCallArgsEvent?(params: {
327
- event: ToolCallArgsEvent;
328
- toolCallBuffer: string;
329
- toolCallName: string;
330
- partialToolCallArgs: Record<string, any>;
331
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
332
- onToolCallEndEvent?(params: {
333
- event: ToolCallEndEvent;
334
- toolCallName: string;
335
- toolCallArgs: Record<string, any>;
336
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
337
- onToolCallResultEvent?(params: {
338
- event: ToolCallResultEvent;
339
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
340
- onStateSnapshotEvent?(params: {
341
- event: StateSnapshotEvent;
342
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
343
- onStateDeltaEvent?(params: {
344
- event: StateDeltaEvent;
345
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
346
- onMessagesSnapshotEvent?(params: {
347
- event: MessagesSnapshotEvent;
348
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
349
- onActivitySnapshotEvent?(params: {
350
- event: ActivitySnapshotEvent;
351
- activityMessage?: ActivityMessage;
352
- existingMessage?: Message;
353
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
354
- onActivityDeltaEvent?(params: {
355
- event: ActivityDeltaEvent;
356
- activityMessage?: ActivityMessage;
357
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
358
- onRawEvent?(params: {
359
- event: RawEvent;
360
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
361
- onCustomEvent?(params: {
362
- event: CustomEvent;
363
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
364
- onMessagesChanged?(params: Omit<AgentSubscriberParams, "input"> & {
365
- input?: RunAgentInput;
366
- }): MaybePromise<void>;
367
- onStateChanged?(params: Omit<AgentSubscriberParams, "input"> & {
368
- input?: RunAgentInput;
369
- }): MaybePromise<void>;
370
- onNewMessage?(params: {
371
- message: Message;
372
- } & Omit<AgentSubscriberParams, "input"> & {
373
- input?: RunAgentInput;
374
- }): MaybePromise<void>;
375
- onNewToolCall?(params: {
376
- toolCall: ToolCall;
377
- } & Omit<AgentSubscriberParams, "input"> & {
378
- input?: RunAgentInput;
379
- }): MaybePromise<void>;
380
- }
381
-
440
+ //#endregion
441
+ //#region src/apply/default.d.ts
382
442
  declare const defaultApplyEvents: (input: RunAgentInput, events$: Observable<BaseEvent>, agent: AbstractAgent, subscribers: AgentSubscriber[]) => Observable<AgentStateMutation>;
383
-
443
+ //#endregion
444
+ //#region src/verify/verify.d.ts
384
445
  declare const verifyEvents: (debug: boolean) => (source$: Observable<BaseEvent>) => Observable<BaseEvent>;
385
-
446
+ //#endregion
447
+ //#region src/run/http-request.d.ts
386
448
  declare enum HttpEventType {
387
- HEADERS = "headers",
388
- DATA = "data"
449
+ HEADERS = "headers",
450
+ DATA = "data"
389
451
  }
390
452
  interface HttpDataEvent {
391
- type: HttpEventType.DATA;
392
- data?: Uint8Array;
453
+ type: HttpEventType.DATA;
454
+ data?: Uint8Array;
393
455
  }
394
456
  interface HttpHeadersEvent {
395
- type: HttpEventType.HEADERS;
396
- status: number;
397
- headers: Headers;
457
+ type: HttpEventType.HEADERS;
458
+ status: number;
459
+ headers: Headers;
398
460
  }
399
461
  type HttpEvent = HttpDataEvent | HttpHeadersEvent;
400
462
  declare const runHttpRequest: (url: string, requestInit: RequestInit) => Observable<HttpEvent>;
401
-
463
+ //#endregion
464
+ //#region src/transform/http.d.ts
402
465
  /**
403
466
  * Transforms HTTP events into BaseEvents using the appropriate format parser based on content type.
404
467
  */
405
468
  declare const transformHttpEventStream: (source$: Observable<HttpEvent>) => Observable<BaseEvent>;
406
-
469
+ //#endregion
470
+ //#region src/transform/sse.d.ts
407
471
  /**
408
472
  * Parses a stream of HTTP events into a stream of JSON objects using Server-Sent Events (SSE) format.
409
473
  * Strictly follows the SSE standard where:
@@ -413,23 +477,27 @@ declare const transformHttpEventStream: (source$: Observable<HttpEvent>) => Obse
413
477
  * - Non-data fields (event, id, retry) are ignored
414
478
  */
415
479
  declare const parseSSEStream: (source$: Observable<HttpEvent>) => Observable<any>;
416
-
480
+ //#endregion
481
+ //#region src/transform/proto.d.ts
417
482
  /**
418
483
  * Parses a stream of HTTP events into a stream of BaseEvent objects using Protocol Buffer format.
419
484
  * Each message is prefixed with a 4-byte length header (uint32 in big-endian format)
420
485
  * followed by the protocol buffer encoded message.
421
486
  */
422
487
  declare const parseProtoStream: (source$: Observable<HttpEvent>) => Observable<BaseEvent>;
423
-
488
+ //#endregion
489
+ //#region src/legacy/convert.d.ts
424
490
  declare const convertToLegacyEvents: (threadId: string, runId: string, agentName: string) => (events$: Observable<BaseEvent>) => Observable<LegacyRuntimeProtocolEvent>;
425
-
491
+ //#endregion
492
+ //#region src/utils.d.ts
426
493
  declare const structuredClone_: <T>(obj: T) => T;
427
494
  /**
428
495
  * Generate a random UUID v4
429
496
  * Cross-platform compatible (Node.js, browsers, React Native)
430
497
  */
431
498
  declare function randomUUID(): string;
432
-
499
+ //#endregion
500
+ //#region src/compact/compact.d.ts
433
501
  /**
434
502
  * Compacts streaming events by consolidating multiple deltas into single events.
435
503
  * For text messages: multiple content deltas become one concatenated delta.
@@ -440,7 +508,9 @@ declare function randomUUID(): string;
440
508
  * @returns Compacted array of events
441
509
  */
442
510
  declare function compactEvents(events: BaseEvent[]): BaseEvent[];
443
-
511
+ //#endregion
512
+ //#region src/chunks/transform.d.ts
444
513
  declare const transformChunks: (debug: boolean) => (events$: Observable<BaseEvent>) => Observable<BaseEvent>;
445
-
446
- export { AbstractAgent, type AgentConfig, type AgentStateMutation, type AgentSubscriber, type AgentSubscriberParams, BackwardCompatibility_0_0_39, FilterToolCallsMiddleware, FunctionMiddleware, HttpAgent, type HttpAgentConfig, Middleware, type MiddlewareFunction, type RunAgentParameters, type RunAgentResult, compactEvents, convertToLegacyEvents, defaultApplyEvents, parseProtoStream, parseSSEStream, randomUUID, runHttpRequest, structuredClone_, transformChunks, transformHttpEventStream, verifyEvents };
514
+ //#endregion
515
+ export { AbstractAgent, type AgentConfig, type AgentStateMutation, type AgentSubscriber, type AgentSubscriberParams, BackwardCompatibility_0_0_39, BackwardCompatibility_0_0_45, FilterToolCallsMiddleware, FunctionMiddleware, HttpAgent, type HttpAgentConfig, Middleware, type MiddlewareFunction, type RunAgentParameters, type RunAgentResult, compactEvents, convertToLegacyEvents, defaultApplyEvents, parseProtoStream, parseSSEStream, randomUUID, runHttpRequest, structuredClone_, transformChunks, transformHttpEventStream, verifyEvents };
516
+ //# sourceMappingURL=index.d.mts.map