@ag-ui/core 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 +6041 -5002
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +6041 -5002
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +449 -442
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +392 -367
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -9
package/dist/index.mjs
CHANGED
|
@@ -1,380 +1,405 @@
|
|
|
1
|
-
// src/types.ts
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
|
|
3
|
+
//#region src/types.ts
|
|
4
|
+
const FunctionCallSchema = z.object({
|
|
5
|
+
name: z.string(),
|
|
6
|
+
arguments: z.string()
|
|
7
|
+
});
|
|
8
|
+
const ToolCallSchema = z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
type: z.literal("function"),
|
|
11
|
+
function: FunctionCallSchema,
|
|
12
|
+
encryptedValue: z.string().optional()
|
|
13
|
+
});
|
|
14
|
+
const BaseMessageSchema = z.object({
|
|
15
|
+
id: z.string(),
|
|
16
|
+
role: z.string(),
|
|
17
|
+
content: z.string().optional(),
|
|
18
|
+
name: z.string().optional(),
|
|
19
|
+
encryptedValue: z.string().optional()
|
|
20
|
+
});
|
|
21
|
+
const TextInputContentSchema = z.object({
|
|
22
|
+
type: z.literal("text"),
|
|
23
|
+
text: z.string()
|
|
24
|
+
});
|
|
25
|
+
const BinaryInputContentObjectSchema = z.object({
|
|
26
|
+
type: z.literal("binary"),
|
|
27
|
+
mimeType: z.string(),
|
|
28
|
+
id: z.string().optional(),
|
|
29
|
+
url: z.string().optional(),
|
|
30
|
+
data: z.string().optional(),
|
|
31
|
+
filename: z.string().optional()
|
|
32
|
+
});
|
|
33
|
+
const ensureBinaryPayload = (value, ctx) => {
|
|
34
|
+
if (!value.id && !value.url && !value.data) ctx.addIssue({
|
|
35
|
+
code: z.ZodIssueCode.custom,
|
|
36
|
+
message: "BinaryInputContent requires at least one of id, url, or data.",
|
|
37
|
+
path: ["id"]
|
|
38
|
+
});
|
|
38
39
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
40
|
+
const BinaryInputContentSchema = BinaryInputContentObjectSchema.superRefine((value, ctx) => {
|
|
41
|
+
ensureBinaryPayload(value, ctx);
|
|
42
|
+
});
|
|
43
|
+
const InputContentBaseSchema = z.discriminatedUnion("type", [TextInputContentSchema, BinaryInputContentObjectSchema]);
|
|
44
|
+
const InputContentSchema = InputContentBaseSchema.superRefine((value, ctx) => {
|
|
45
|
+
if (value.type === "binary") ensureBinaryPayload(value, ctx);
|
|
46
|
+
});
|
|
47
|
+
const DeveloperMessageSchema = BaseMessageSchema.extend({
|
|
48
|
+
role: z.literal("developer"),
|
|
49
|
+
content: z.string()
|
|
50
|
+
});
|
|
51
|
+
const SystemMessageSchema = BaseMessageSchema.extend({
|
|
52
|
+
role: z.literal("system"),
|
|
53
|
+
content: z.string()
|
|
54
|
+
});
|
|
55
|
+
const AssistantMessageSchema = BaseMessageSchema.extend({
|
|
56
|
+
role: z.literal("assistant"),
|
|
57
|
+
content: z.string().optional(),
|
|
58
|
+
toolCalls: z.array(ToolCallSchema).optional()
|
|
59
|
+
});
|
|
60
|
+
const UserMessageSchema = BaseMessageSchema.extend({
|
|
61
|
+
role: z.literal("user"),
|
|
62
|
+
content: z.union([z.string(), z.array(InputContentSchema)])
|
|
63
|
+
});
|
|
64
|
+
const ToolMessageSchema = z.object({
|
|
65
|
+
id: z.string(),
|
|
66
|
+
content: z.string(),
|
|
67
|
+
role: z.literal("tool"),
|
|
68
|
+
toolCallId: z.string(),
|
|
69
|
+
error: z.string().optional(),
|
|
70
|
+
encryptedValue: z.string().optional()
|
|
71
|
+
});
|
|
72
|
+
const ActivityMessageSchema = z.object({
|
|
73
|
+
id: z.string(),
|
|
74
|
+
role: z.literal("activity"),
|
|
75
|
+
activityType: z.string(),
|
|
76
|
+
content: z.record(z.any())
|
|
77
|
+
});
|
|
78
|
+
const ReasoningMessageSchema = z.object({
|
|
79
|
+
id: z.string(),
|
|
80
|
+
role: z.literal("reasoning"),
|
|
81
|
+
content: z.string(),
|
|
82
|
+
encryptedValue: z.string().optional()
|
|
83
|
+
});
|
|
84
|
+
const MessageSchema = z.discriminatedUnion("role", [
|
|
85
|
+
DeveloperMessageSchema,
|
|
86
|
+
SystemMessageSchema,
|
|
87
|
+
AssistantMessageSchema,
|
|
88
|
+
UserMessageSchema,
|
|
89
|
+
ToolMessageSchema,
|
|
90
|
+
ActivityMessageSchema,
|
|
91
|
+
ReasoningMessageSchema
|
|
88
92
|
]);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
const RoleSchema = z.union([
|
|
94
|
+
z.literal("developer"),
|
|
95
|
+
z.literal("system"),
|
|
96
|
+
z.literal("assistant"),
|
|
97
|
+
z.literal("user"),
|
|
98
|
+
z.literal("tool"),
|
|
99
|
+
z.literal("activity"),
|
|
100
|
+
z.literal("reasoning")
|
|
96
101
|
]);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var StateSchema = z.any();
|
|
102
|
+
const ContextSchema = z.object({
|
|
103
|
+
description: z.string(),
|
|
104
|
+
value: z.string()
|
|
105
|
+
});
|
|
106
|
+
const ToolSchema = z.object({
|
|
107
|
+
name: z.string(),
|
|
108
|
+
description: z.string(),
|
|
109
|
+
parameters: z.any()
|
|
110
|
+
});
|
|
111
|
+
const RunAgentInputSchema = z.object({
|
|
112
|
+
threadId: z.string(),
|
|
113
|
+
runId: z.string(),
|
|
114
|
+
parentRunId: z.string().optional(),
|
|
115
|
+
state: z.any(),
|
|
116
|
+
messages: z.array(MessageSchema),
|
|
117
|
+
tools: z.array(ToolSchema),
|
|
118
|
+
context: z.array(ContextSchema),
|
|
119
|
+
forwardedProps: z.any()
|
|
120
|
+
});
|
|
121
|
+
const StateSchema = z.any();
|
|
118
122
|
var AGUIError = class extends Error {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
constructor(message) {
|
|
124
|
+
super(message);
|
|
125
|
+
}
|
|
122
126
|
};
|
|
123
127
|
var AGUIConnectNotImplementedError = class extends AGUIError {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
constructor() {
|
|
129
|
+
super("Connect not implemented. This method is not supported by the current agent.");
|
|
130
|
+
}
|
|
127
131
|
};
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/events.ts
|
|
135
|
+
const TextMessageRoleSchema = z.union([
|
|
136
|
+
z.literal("developer"),
|
|
137
|
+
z.literal("system"),
|
|
138
|
+
z.literal("assistant"),
|
|
139
|
+
z.literal("user")
|
|
136
140
|
]);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
141
|
+
let EventType = /* @__PURE__ */ function(EventType) {
|
|
142
|
+
EventType["TEXT_MESSAGE_START"] = "TEXT_MESSAGE_START";
|
|
143
|
+
EventType["TEXT_MESSAGE_CONTENT"] = "TEXT_MESSAGE_CONTENT";
|
|
144
|
+
EventType["TEXT_MESSAGE_END"] = "TEXT_MESSAGE_END";
|
|
145
|
+
EventType["TEXT_MESSAGE_CHUNK"] = "TEXT_MESSAGE_CHUNK";
|
|
146
|
+
EventType["TOOL_CALL_START"] = "TOOL_CALL_START";
|
|
147
|
+
EventType["TOOL_CALL_ARGS"] = "TOOL_CALL_ARGS";
|
|
148
|
+
EventType["TOOL_CALL_END"] = "TOOL_CALL_END";
|
|
149
|
+
EventType["TOOL_CALL_CHUNK"] = "TOOL_CALL_CHUNK";
|
|
150
|
+
EventType["TOOL_CALL_RESULT"] = "TOOL_CALL_RESULT";
|
|
151
|
+
/**
|
|
152
|
+
* @deprecated Use REASONING_START instead. Will be removed in 1.0.0.
|
|
153
|
+
*/
|
|
154
|
+
EventType["THINKING_START"] = "THINKING_START";
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use REASONING_END instead. Will be removed in 1.0.0.
|
|
157
|
+
*/
|
|
158
|
+
EventType["THINKING_END"] = "THINKING_END";
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated Use REASONING_MESSAGE_START instead. Will be removed in 1.0.0.
|
|
161
|
+
*/
|
|
162
|
+
EventType["THINKING_TEXT_MESSAGE_START"] = "THINKING_TEXT_MESSAGE_START";
|
|
163
|
+
/**
|
|
164
|
+
* @deprecated Use REASONING_MESSAGE_CONTENT instead. Will be removed in 1.0.0.
|
|
165
|
+
*/
|
|
166
|
+
EventType["THINKING_TEXT_MESSAGE_CONTENT"] = "THINKING_TEXT_MESSAGE_CONTENT";
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated Use REASONING_MESSAGE_END instead. Will be removed in 1.0.0.
|
|
169
|
+
*/
|
|
170
|
+
EventType["THINKING_TEXT_MESSAGE_END"] = "THINKING_TEXT_MESSAGE_END";
|
|
171
|
+
EventType["STATE_SNAPSHOT"] = "STATE_SNAPSHOT";
|
|
172
|
+
EventType["STATE_DELTA"] = "STATE_DELTA";
|
|
173
|
+
EventType["MESSAGES_SNAPSHOT"] = "MESSAGES_SNAPSHOT";
|
|
174
|
+
EventType["ACTIVITY_SNAPSHOT"] = "ACTIVITY_SNAPSHOT";
|
|
175
|
+
EventType["ACTIVITY_DELTA"] = "ACTIVITY_DELTA";
|
|
176
|
+
EventType["RAW"] = "RAW";
|
|
177
|
+
EventType["CUSTOM"] = "CUSTOM";
|
|
178
|
+
EventType["RUN_STARTED"] = "RUN_STARTED";
|
|
179
|
+
EventType["RUN_FINISHED"] = "RUN_FINISHED";
|
|
180
|
+
EventType["RUN_ERROR"] = "RUN_ERROR";
|
|
181
|
+
EventType["STEP_STARTED"] = "STEP_STARTED";
|
|
182
|
+
EventType["STEP_FINISHED"] = "STEP_FINISHED";
|
|
183
|
+
EventType["REASONING_START"] = "REASONING_START";
|
|
184
|
+
EventType["REASONING_MESSAGE_START"] = "REASONING_MESSAGE_START";
|
|
185
|
+
EventType["REASONING_MESSAGE_CONTENT"] = "REASONING_MESSAGE_CONTENT";
|
|
186
|
+
EventType["REASONING_MESSAGE_END"] = "REASONING_MESSAGE_END";
|
|
187
|
+
EventType["REASONING_MESSAGE_CHUNK"] = "REASONING_MESSAGE_CHUNK";
|
|
188
|
+
EventType["REASONING_END"] = "REASONING_END";
|
|
189
|
+
EventType["REASONING_ENCRYPTED_VALUE"] = "REASONING_ENCRYPTED_VALUE";
|
|
190
|
+
return EventType;
|
|
191
|
+
}({});
|
|
192
|
+
const BaseEventSchema = z.object({
|
|
193
|
+
type: z.nativeEnum(EventType),
|
|
194
|
+
timestamp: z.number().optional(),
|
|
195
|
+
rawEvent: z.any().optional()
|
|
170
196
|
}).passthrough();
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
197
|
+
const TextMessageStartEventSchema = BaseEventSchema.extend({
|
|
198
|
+
type: z.literal(EventType.TEXT_MESSAGE_START),
|
|
199
|
+
messageId: z.string(),
|
|
200
|
+
role: TextMessageRoleSchema.default("assistant")
|
|
201
|
+
});
|
|
202
|
+
const TextMessageContentEventSchema = BaseEventSchema.extend({
|
|
203
|
+
type: z.literal(EventType.TEXT_MESSAGE_CONTENT),
|
|
204
|
+
messageId: z.string(),
|
|
205
|
+
delta: z.string().refine((s) => s.length > 0, "Delta must not be an empty string")
|
|
206
|
+
});
|
|
207
|
+
const TextMessageEndEventSchema = BaseEventSchema.extend({
|
|
208
|
+
type: z.literal(EventType.TEXT_MESSAGE_END),
|
|
209
|
+
messageId: z.string()
|
|
210
|
+
});
|
|
211
|
+
const TextMessageChunkEventSchema = BaseEventSchema.extend({
|
|
212
|
+
type: z.literal(EventType.TEXT_MESSAGE_CHUNK),
|
|
213
|
+
messageId: z.string().optional(),
|
|
214
|
+
role: TextMessageRoleSchema.optional(),
|
|
215
|
+
delta: z.string().optional()
|
|
216
|
+
});
|
|
217
|
+
/**
|
|
218
|
+
* @deprecated Use ReasoningMessageStartEventSchema instead. Will be removed in 1.0.0.
|
|
219
|
+
*/
|
|
220
|
+
const ThinkingTextMessageStartEventSchema = BaseEventSchema.extend({ type: z.literal(EventType.THINKING_TEXT_MESSAGE_START) });
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated Use ReasoningMessageContentEventSchema instead. Will be removed in 1.0.0.
|
|
223
|
+
*/
|
|
224
|
+
const ThinkingTextMessageContentEventSchema = TextMessageContentEventSchema.omit({
|
|
225
|
+
messageId: true,
|
|
226
|
+
type: true
|
|
227
|
+
}).extend({ type: z.literal(EventType.THINKING_TEXT_MESSAGE_CONTENT) });
|
|
228
|
+
/**
|
|
229
|
+
* @deprecated Use ReasoningMessageEndEventSchema instead. Will be removed in 1.0.0.
|
|
230
|
+
*/
|
|
231
|
+
const ThinkingTextMessageEndEventSchema = BaseEventSchema.extend({ type: z.literal(EventType.THINKING_TEXT_MESSAGE_END) });
|
|
232
|
+
const ToolCallStartEventSchema = BaseEventSchema.extend({
|
|
233
|
+
type: z.literal(EventType.TOOL_CALL_START),
|
|
234
|
+
toolCallId: z.string(),
|
|
235
|
+
toolCallName: z.string(),
|
|
236
|
+
parentMessageId: z.string().optional()
|
|
237
|
+
});
|
|
238
|
+
const ToolCallArgsEventSchema = BaseEventSchema.extend({
|
|
239
|
+
type: z.literal(EventType.TOOL_CALL_ARGS),
|
|
240
|
+
toolCallId: z.string(),
|
|
241
|
+
delta: z.string()
|
|
242
|
+
});
|
|
243
|
+
const ToolCallEndEventSchema = BaseEventSchema.extend({
|
|
244
|
+
type: z.literal(EventType.TOOL_CALL_END),
|
|
245
|
+
toolCallId: z.string()
|
|
246
|
+
});
|
|
247
|
+
const ToolCallResultEventSchema = BaseEventSchema.extend({
|
|
248
|
+
messageId: z.string(),
|
|
249
|
+
type: z.literal(EventType.TOOL_CALL_RESULT),
|
|
250
|
+
toolCallId: z.string(),
|
|
251
|
+
content: z.string(),
|
|
252
|
+
role: z.literal("tool").optional()
|
|
253
|
+
});
|
|
254
|
+
const ToolCallChunkEventSchema = BaseEventSchema.extend({
|
|
255
|
+
type: z.literal(EventType.TOOL_CALL_CHUNK),
|
|
256
|
+
toolCallId: z.string().optional(),
|
|
257
|
+
toolCallName: z.string().optional(),
|
|
258
|
+
parentMessageId: z.string().optional(),
|
|
259
|
+
delta: z.string().optional()
|
|
260
|
+
});
|
|
261
|
+
/**
|
|
262
|
+
* @deprecated Use ReasoningStartEventSchema instead. Will be removed in 1.0.0.
|
|
263
|
+
*/
|
|
264
|
+
const ThinkingStartEventSchema = BaseEventSchema.extend({
|
|
265
|
+
type: z.literal(EventType.THINKING_START),
|
|
266
|
+
title: z.string().optional()
|
|
267
|
+
});
|
|
268
|
+
/**
|
|
269
|
+
* @deprecated Use ReasoningEndEventSchema instead. Will be removed in 1.0.0.
|
|
270
|
+
*/
|
|
271
|
+
const ThinkingEndEventSchema = BaseEventSchema.extend({ type: z.literal(EventType.THINKING_END) });
|
|
272
|
+
const StateSnapshotEventSchema = BaseEventSchema.extend({
|
|
273
|
+
type: z.literal(EventType.STATE_SNAPSHOT),
|
|
274
|
+
snapshot: StateSchema
|
|
275
|
+
});
|
|
276
|
+
const StateDeltaEventSchema = BaseEventSchema.extend({
|
|
277
|
+
type: z.literal(EventType.STATE_DELTA),
|
|
278
|
+
delta: z.array(z.any())
|
|
279
|
+
});
|
|
280
|
+
const MessagesSnapshotEventSchema = BaseEventSchema.extend({
|
|
281
|
+
type: z.literal(EventType.MESSAGES_SNAPSHOT),
|
|
282
|
+
messages: z.array(MessageSchema)
|
|
283
|
+
});
|
|
284
|
+
const ActivitySnapshotEventSchema = BaseEventSchema.extend({
|
|
285
|
+
type: z.literal(EventType.ACTIVITY_SNAPSHOT),
|
|
286
|
+
messageId: z.string(),
|
|
287
|
+
activityType: z.string(),
|
|
288
|
+
content: z.record(z.any()),
|
|
289
|
+
replace: z.boolean().optional().default(true)
|
|
290
|
+
});
|
|
291
|
+
const ActivityDeltaEventSchema = BaseEventSchema.extend({
|
|
292
|
+
type: z.literal(EventType.ACTIVITY_DELTA),
|
|
293
|
+
messageId: z.string(),
|
|
294
|
+
activityType: z.string(),
|
|
295
|
+
patch: z.array(z.any())
|
|
296
|
+
});
|
|
297
|
+
const RawEventSchema = BaseEventSchema.extend({
|
|
298
|
+
type: z.literal(EventType.RAW),
|
|
299
|
+
event: z.any(),
|
|
300
|
+
source: z.string().optional()
|
|
301
|
+
});
|
|
302
|
+
const CustomEventSchema = BaseEventSchema.extend({
|
|
303
|
+
type: z.literal(EventType.CUSTOM),
|
|
304
|
+
name: z.string(),
|
|
305
|
+
value: z.any()
|
|
306
|
+
});
|
|
307
|
+
const RunStartedEventSchema = BaseEventSchema.extend({
|
|
308
|
+
type: z.literal(EventType.RUN_STARTED),
|
|
309
|
+
threadId: z.string(),
|
|
310
|
+
runId: z.string(),
|
|
311
|
+
parentRunId: z.string().optional(),
|
|
312
|
+
input: RunAgentInputSchema.optional()
|
|
313
|
+
});
|
|
314
|
+
const RunFinishedEventSchema = BaseEventSchema.extend({
|
|
315
|
+
type: z.literal(EventType.RUN_FINISHED),
|
|
316
|
+
threadId: z.string(),
|
|
317
|
+
runId: z.string(),
|
|
318
|
+
result: z.any().optional()
|
|
319
|
+
});
|
|
320
|
+
const RunErrorEventSchema = BaseEventSchema.extend({
|
|
321
|
+
type: z.literal(EventType.RUN_ERROR),
|
|
322
|
+
message: z.string(),
|
|
323
|
+
code: z.string().optional()
|
|
324
|
+
});
|
|
325
|
+
const StepStartedEventSchema = BaseEventSchema.extend({
|
|
326
|
+
type: z.literal(EventType.STEP_STARTED),
|
|
327
|
+
stepName: z.string()
|
|
328
|
+
});
|
|
329
|
+
const StepFinishedEventSchema = BaseEventSchema.extend({
|
|
330
|
+
type: z.literal(EventType.STEP_FINISHED),
|
|
331
|
+
stepName: z.string()
|
|
332
|
+
});
|
|
333
|
+
const ReasoningEncryptedValueSubtypeSchema = z.union([z.literal("tool-call"), z.literal("message")]);
|
|
334
|
+
const ReasoningStartEventSchema = BaseEventSchema.extend({
|
|
335
|
+
type: z.literal(EventType.REASONING_START),
|
|
336
|
+
messageId: z.string()
|
|
337
|
+
});
|
|
338
|
+
const ReasoningMessageStartEventSchema = BaseEventSchema.extend({
|
|
339
|
+
type: z.literal(EventType.REASONING_MESSAGE_START),
|
|
340
|
+
messageId: z.string(),
|
|
341
|
+
role: z.literal("reasoning")
|
|
342
|
+
});
|
|
343
|
+
const ReasoningMessageContentEventSchema = BaseEventSchema.extend({
|
|
344
|
+
type: z.literal(EventType.REASONING_MESSAGE_CONTENT),
|
|
345
|
+
messageId: z.string(),
|
|
346
|
+
delta: z.string().refine((s) => s.length > 0, "Delta must not be an empty string")
|
|
347
|
+
});
|
|
348
|
+
const ReasoningMessageEndEventSchema = BaseEventSchema.extend({
|
|
349
|
+
type: z.literal(EventType.REASONING_MESSAGE_END),
|
|
350
|
+
messageId: z.string()
|
|
351
|
+
});
|
|
352
|
+
const ReasoningMessageChunkEventSchema = BaseEventSchema.extend({
|
|
353
|
+
type: z.literal(EventType.REASONING_MESSAGE_CHUNK),
|
|
354
|
+
messageId: z.string().optional(),
|
|
355
|
+
delta: z.string().optional()
|
|
356
|
+
});
|
|
357
|
+
const ReasoningEndEventSchema = BaseEventSchema.extend({
|
|
358
|
+
type: z.literal(EventType.REASONING_END),
|
|
359
|
+
messageId: z.string()
|
|
360
|
+
});
|
|
361
|
+
const ReasoningEncryptedValueEventSchema = BaseEventSchema.extend({
|
|
362
|
+
type: z.literal(EventType.REASONING_ENCRYPTED_VALUE),
|
|
363
|
+
subtype: ReasoningEncryptedValueSubtypeSchema,
|
|
364
|
+
entityId: z.string(),
|
|
365
|
+
encryptedValue: z.string()
|
|
366
|
+
});
|
|
367
|
+
const EventSchemas = z.discriminatedUnion("type", [
|
|
368
|
+
TextMessageStartEventSchema,
|
|
369
|
+
TextMessageContentEventSchema,
|
|
370
|
+
TextMessageEndEventSchema,
|
|
371
|
+
TextMessageChunkEventSchema,
|
|
372
|
+
ThinkingStartEventSchema,
|
|
373
|
+
ThinkingEndEventSchema,
|
|
374
|
+
ThinkingTextMessageStartEventSchema,
|
|
375
|
+
ThinkingTextMessageContentEventSchema,
|
|
376
|
+
ThinkingTextMessageEndEventSchema,
|
|
377
|
+
ToolCallStartEventSchema,
|
|
378
|
+
ToolCallArgsEventSchema,
|
|
379
|
+
ToolCallEndEventSchema,
|
|
380
|
+
ToolCallChunkEventSchema,
|
|
381
|
+
ToolCallResultEventSchema,
|
|
382
|
+
StateSnapshotEventSchema,
|
|
383
|
+
StateDeltaEventSchema,
|
|
384
|
+
MessagesSnapshotEventSchema,
|
|
385
|
+
ActivitySnapshotEventSchema,
|
|
386
|
+
ActivityDeltaEventSchema,
|
|
387
|
+
RawEventSchema,
|
|
388
|
+
CustomEventSchema,
|
|
389
|
+
RunStartedEventSchema,
|
|
390
|
+
RunFinishedEventSchema,
|
|
391
|
+
RunErrorEventSchema,
|
|
392
|
+
StepStartedEventSchema,
|
|
393
|
+
StepFinishedEventSchema,
|
|
394
|
+
ReasoningStartEventSchema,
|
|
395
|
+
ReasoningMessageStartEventSchema,
|
|
396
|
+
ReasoningMessageContentEventSchema,
|
|
397
|
+
ReasoningMessageEndEventSchema,
|
|
398
|
+
ReasoningMessageChunkEventSchema,
|
|
399
|
+
ReasoningEndEventSchema,
|
|
400
|
+
ReasoningEncryptedValueEventSchema
|
|
328
401
|
]);
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
ActivityDeltaEventSchema,
|
|
333
|
-
ActivityMessageSchema,
|
|
334
|
-
ActivitySnapshotEventSchema,
|
|
335
|
-
AssistantMessageSchema,
|
|
336
|
-
BaseEventSchema,
|
|
337
|
-
BaseMessageSchema,
|
|
338
|
-
BinaryInputContentSchema,
|
|
339
|
-
ContextSchema,
|
|
340
|
-
CustomEventSchema,
|
|
341
|
-
DeveloperMessageSchema,
|
|
342
|
-
EventSchemas,
|
|
343
|
-
EventType,
|
|
344
|
-
FunctionCallSchema,
|
|
345
|
-
InputContentSchema,
|
|
346
|
-
MessageSchema,
|
|
347
|
-
MessagesSnapshotEventSchema,
|
|
348
|
-
RawEventSchema,
|
|
349
|
-
RoleSchema,
|
|
350
|
-
RunAgentInputSchema,
|
|
351
|
-
RunErrorEventSchema,
|
|
352
|
-
RunFinishedEventSchema,
|
|
353
|
-
RunStartedEventSchema,
|
|
354
|
-
StateDeltaEventSchema,
|
|
355
|
-
StateSchema,
|
|
356
|
-
StateSnapshotEventSchema,
|
|
357
|
-
StepFinishedEventSchema,
|
|
358
|
-
StepStartedEventSchema,
|
|
359
|
-
SystemMessageSchema,
|
|
360
|
-
TextInputContentSchema,
|
|
361
|
-
TextMessageChunkEventSchema,
|
|
362
|
-
TextMessageContentEventSchema,
|
|
363
|
-
TextMessageEndEventSchema,
|
|
364
|
-
TextMessageStartEventSchema,
|
|
365
|
-
ThinkingEndEventSchema,
|
|
366
|
-
ThinkingStartEventSchema,
|
|
367
|
-
ThinkingTextMessageContentEventSchema,
|
|
368
|
-
ThinkingTextMessageEndEventSchema,
|
|
369
|
-
ThinkingTextMessageStartEventSchema,
|
|
370
|
-
ToolCallArgsEventSchema,
|
|
371
|
-
ToolCallChunkEventSchema,
|
|
372
|
-
ToolCallEndEventSchema,
|
|
373
|
-
ToolCallResultEventSchema,
|
|
374
|
-
ToolCallSchema,
|
|
375
|
-
ToolCallStartEventSchema,
|
|
376
|
-
ToolMessageSchema,
|
|
377
|
-
ToolSchema,
|
|
378
|
-
UserMessageSchema
|
|
379
|
-
};
|
|
402
|
+
|
|
403
|
+
//#endregion
|
|
404
|
+
export { AGUIConnectNotImplementedError, AGUIError, ActivityDeltaEventSchema, ActivityMessageSchema, ActivitySnapshotEventSchema, AssistantMessageSchema, BaseEventSchema, BaseMessageSchema, BinaryInputContentSchema, ContextSchema, CustomEventSchema, DeveloperMessageSchema, EventSchemas, EventType, FunctionCallSchema, InputContentSchema, MessageSchema, MessagesSnapshotEventSchema, RawEventSchema, ReasoningEncryptedValueEventSchema, ReasoningEncryptedValueSubtypeSchema, ReasoningEndEventSchema, ReasoningMessageChunkEventSchema, ReasoningMessageContentEventSchema, ReasoningMessageEndEventSchema, ReasoningMessageSchema, ReasoningMessageStartEventSchema, ReasoningStartEventSchema, RoleSchema, RunAgentInputSchema, RunErrorEventSchema, RunFinishedEventSchema, RunStartedEventSchema, StateDeltaEventSchema, StateSchema, StateSnapshotEventSchema, StepFinishedEventSchema, StepStartedEventSchema, SystemMessageSchema, TextInputContentSchema, TextMessageChunkEventSchema, TextMessageContentEventSchema, TextMessageEndEventSchema, TextMessageStartEventSchema, ThinkingEndEventSchema, ThinkingStartEventSchema, ThinkingTextMessageContentEventSchema, ThinkingTextMessageEndEventSchema, ThinkingTextMessageStartEventSchema, ToolCallArgsEventSchema, ToolCallChunkEventSchema, ToolCallEndEventSchema, ToolCallResultEventSchema, ToolCallSchema, ToolCallStartEventSchema, ToolMessageSchema, ToolSchema, UserMessageSchema };
|
|
380
405
|
//# sourceMappingURL=index.mjs.map
|