@ag-ui/client 0.0.45-alpha.0 → 0.0.46

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,410 +1,473 @@
1
- import { Message, State, RunAgentInput, BaseEvent, FetchRunHistoryOptions, FetchRunHistoryResult, 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
- protected fetchRunHistory(options: FetchRunHistoryOptions): Promise<FetchRunHistoryResult | undefined>;
259
- connectAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise<RunAgentResult>;
260
- abortRun(): void;
261
- detachActiveRun(): Promise<void>;
262
- protected apply(input: RunAgentInput, events$: Observable<BaseEvent>, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
263
- protected processApplyEvents(input: RunAgentInput, events$: Observable<AgentStateMutation>, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
264
- protected prepareRunAgentInput(parameters?: RunAgentParameters): RunAgentInput;
265
- protected onInitialize(input: RunAgentInput, subscribers: AgentSubscriber[]): Promise<void>;
266
- protected onError(input: RunAgentInput, error: Error, subscribers: AgentSubscriber[]): Observable<AgentStateMutation>;
267
- protected onFinalize(input: RunAgentInput, subscribers: AgentSubscriber[]): Promise<void>;
268
- clone(): any;
269
- addMessage(message: Message): void;
270
- addMessages(messages: Message[]): void;
271
- setMessages(messages: Message[]): void;
272
- setState(state: State): void;
273
- legacy_to_be_removed_runAgentBridged(config?: RunAgentParameters): Observable<LegacyRuntimeProtocolEvent>;
274
- }
275
-
276
- interface AgentStateMutation {
277
- messages?: Message[];
278
- state?: State;
279
- stopPropagation?: boolean;
280
- }
281
- interface AgentSubscriberParams {
282
- messages: Message[];
283
- state: State;
284
- agent: AbstractAgent;
285
- 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>;
286
439
  }
287
- type MaybePromise<T> = T | Promise<T>;
288
- interface AgentSubscriber {
289
- onRunInitialized?(params: AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
290
- onRunFailed?(params: {
291
- error: Error;
292
- } & AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
293
- onRunFinalized?(params: AgentSubscriberParams): MaybePromise<Omit<AgentStateMutation, "stopPropagation"> | void>;
294
- onEvent?(params: {
295
- event: BaseEvent;
296
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
297
- onRunStartedEvent?(params: {
298
- event: RunStartedEvent;
299
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
300
- onRunFinishedEvent?(params: {
301
- event: RunFinishedEvent;
302
- result?: any;
303
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
304
- onRunErrorEvent?(params: {
305
- event: RunErrorEvent;
306
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
307
- onStepStartedEvent?(params: {
308
- event: StepStartedEvent;
309
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
310
- onStepFinishedEvent?(params: {
311
- event: StepFinishedEvent;
312
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
313
- onTextMessageStartEvent?(params: {
314
- event: TextMessageStartEvent;
315
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
316
- onTextMessageContentEvent?(params: {
317
- event: TextMessageContentEvent;
318
- textMessageBuffer: string;
319
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
320
- onTextMessageEndEvent?(params: {
321
- event: TextMessageEndEvent;
322
- textMessageBuffer: string;
323
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
324
- onToolCallStartEvent?(params: {
325
- event: ToolCallStartEvent;
326
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
327
- onToolCallArgsEvent?(params: {
328
- event: ToolCallArgsEvent;
329
- toolCallBuffer: string;
330
- toolCallName: string;
331
- partialToolCallArgs: Record<string, any>;
332
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
333
- onToolCallEndEvent?(params: {
334
- event: ToolCallEndEvent;
335
- toolCallName: string;
336
- toolCallArgs: Record<string, any>;
337
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
338
- onToolCallResultEvent?(params: {
339
- event: ToolCallResultEvent;
340
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
341
- onStateSnapshotEvent?(params: {
342
- event: StateSnapshotEvent;
343
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
344
- onStateDeltaEvent?(params: {
345
- event: StateDeltaEvent;
346
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
347
- onMessagesSnapshotEvent?(params: {
348
- event: MessagesSnapshotEvent;
349
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
350
- onActivitySnapshotEvent?(params: {
351
- event: ActivitySnapshotEvent;
352
- activityMessage?: ActivityMessage;
353
- existingMessage?: Message;
354
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
355
- onActivityDeltaEvent?(params: {
356
- event: ActivityDeltaEvent;
357
- activityMessage?: ActivityMessage;
358
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
359
- onRawEvent?(params: {
360
- event: RawEvent;
361
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
362
- onCustomEvent?(params: {
363
- event: CustomEvent;
364
- } & AgentSubscriberParams): MaybePromise<AgentStateMutation | void>;
365
- onMessagesChanged?(params: Omit<AgentSubscriberParams, "input"> & {
366
- input?: RunAgentInput;
367
- }): MaybePromise<void>;
368
- onStateChanged?(params: Omit<AgentSubscriberParams, "input"> & {
369
- input?: RunAgentInput;
370
- }): MaybePromise<void>;
371
- onNewMessage?(params: {
372
- message: Message;
373
- } & Omit<AgentSubscriberParams, "input"> & {
374
- input?: RunAgentInput;
375
- }): MaybePromise<void>;
376
- onNewToolCall?(params: {
377
- toolCall: ToolCall;
378
- } & Omit<AgentSubscriberParams, "input"> & {
379
- input?: RunAgentInput;
380
- }): MaybePromise<void>;
381
- }
382
-
440
+ //#endregion
441
+ //#region src/apply/default.d.ts
383
442
  declare const defaultApplyEvents: (input: RunAgentInput, events$: Observable<BaseEvent>, agent: AbstractAgent, subscribers: AgentSubscriber[]) => Observable<AgentStateMutation>;
384
-
443
+ //#endregion
444
+ //#region src/verify/verify.d.ts
385
445
  declare const verifyEvents: (debug: boolean) => (source$: Observable<BaseEvent>) => Observable<BaseEvent>;
386
-
446
+ //#endregion
447
+ //#region src/run/http-request.d.ts
387
448
  declare enum HttpEventType {
388
- HEADERS = "headers",
389
- DATA = "data"
449
+ HEADERS = "headers",
450
+ DATA = "data"
390
451
  }
391
452
  interface HttpDataEvent {
392
- type: HttpEventType.DATA;
393
- data?: Uint8Array;
453
+ type: HttpEventType.DATA;
454
+ data?: Uint8Array;
394
455
  }
395
456
  interface HttpHeadersEvent {
396
- type: HttpEventType.HEADERS;
397
- status: number;
398
- headers: Headers;
457
+ type: HttpEventType.HEADERS;
458
+ status: number;
459
+ headers: Headers;
399
460
  }
400
461
  type HttpEvent = HttpDataEvent | HttpHeadersEvent;
401
462
  declare const runHttpRequest: (url: string, requestInit: RequestInit) => Observable<HttpEvent>;
402
-
463
+ //#endregion
464
+ //#region src/transform/http.d.ts
403
465
  /**
404
466
  * Transforms HTTP events into BaseEvents using the appropriate format parser based on content type.
405
467
  */
406
468
  declare const transformHttpEventStream: (source$: Observable<HttpEvent>) => Observable<BaseEvent>;
407
-
469
+ //#endregion
470
+ //#region src/transform/sse.d.ts
408
471
  /**
409
472
  * Parses a stream of HTTP events into a stream of JSON objects using Server-Sent Events (SSE) format.
410
473
  * Strictly follows the SSE standard where:
@@ -414,23 +477,27 @@ declare const transformHttpEventStream: (source$: Observable<HttpEvent>) => Obse
414
477
  * - Non-data fields (event, id, retry) are ignored
415
478
  */
416
479
  declare const parseSSEStream: (source$: Observable<HttpEvent>) => Observable<any>;
417
-
480
+ //#endregion
481
+ //#region src/transform/proto.d.ts
418
482
  /**
419
483
  * Parses a stream of HTTP events into a stream of BaseEvent objects using Protocol Buffer format.
420
484
  * Each message is prefixed with a 4-byte length header (uint32 in big-endian format)
421
485
  * followed by the protocol buffer encoded message.
422
486
  */
423
487
  declare const parseProtoStream: (source$: Observable<HttpEvent>) => Observable<BaseEvent>;
424
-
488
+ //#endregion
489
+ //#region src/legacy/convert.d.ts
425
490
  declare const convertToLegacyEvents: (threadId: string, runId: string, agentName: string) => (events$: Observable<BaseEvent>) => Observable<LegacyRuntimeProtocolEvent>;
426
-
491
+ //#endregion
492
+ //#region src/utils.d.ts
427
493
  declare const structuredClone_: <T>(obj: T) => T;
428
494
  /**
429
495
  * Generate a random UUID v4
430
496
  * Cross-platform compatible (Node.js, browsers, React Native)
431
497
  */
432
498
  declare function randomUUID(): string;
433
-
499
+ //#endregion
500
+ //#region src/compact/compact.d.ts
434
501
  /**
435
502
  * Compacts streaming events by consolidating multiple deltas into single events.
436
503
  * For text messages: multiple content deltas become one concatenated delta.
@@ -441,7 +508,9 @@ declare function randomUUID(): string;
441
508
  * @returns Compacted array of events
442
509
  */
443
510
  declare function compactEvents(events: BaseEvent[]): BaseEvent[];
444
-
511
+ //#endregion
512
+ //#region src/chunks/transform.d.ts
445
513
  declare const transformChunks: (debug: boolean) => (events$: Observable<BaseEvent>) => Observable<BaseEvent>;
446
-
447
- 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