@machinemetrics/agent-event-protocol 0.1.0 → 0.1.1
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/{chunk-WZD2VBMM.js → chunk-H5AXHRSE.js} +4 -2
- package/dist/chunk-H5AXHRSE.js.map +1 -0
- package/dist/{chunk-RSG7CUUT.js → chunk-VDBWUNSK.js} +2 -2
- package/dist/core.cjs +3 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +761 -176
- package/dist/core.d.ts +761 -176
- package/dist/core.js +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/sse.cjs +3 -1
- package/dist/sse.cjs.map +1 -1
- package/dist/sse.d.cts +1 -1
- package/dist/sse.d.ts +1 -1
- package/dist/sse.js +2 -2
- package/dist/{types-CttB5bnC.d.cts → types--3D3jbpT.d.cts} +6 -2
- package/dist/{types-CttB5bnC.d.ts → types--3D3jbpT.d.ts} +6 -2
- package/package.json +10 -10
- package/dist/chunk-WZD2VBMM.js.map +0 -1
- /package/dist/{chunk-RSG7CUUT.js.map → chunk-VDBWUNSK.js.map} +0 -0
package/dist/core.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { h as AbortedEvent, a as ActionResult, i as AgentEvent, b as AgentRequest, A as AssistantContentBlock, C as ContinuationEvent, D as DoneEvent, c as ErrorCode, g as ErrorEvent, E as EventStage, F as FinishReason, I as InputMessage, M as MetadataEvent, T as TextEvent, d as ThinkingEvent, e as ToolCallEvent, f as ToolResultEvent, U as UserContentBlock } from './types
|
|
1
|
+
export { h as AbortedEvent, a as ActionResult, i as AgentEvent, b as AgentRequest, A as AssistantContentBlock, C as ContinuationEvent, D as DoneEvent, c as ErrorCode, g as ErrorEvent, E as EventStage, F as FinishReason, I as InputMessage, M as MetadataEvent, T as TextEvent, d as ThinkingEvent, e as ToolCallEvent, f as ToolResultEvent, U as UserContentBlock } from './types--3D3jbpT.cjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,32 +8,72 @@ import { z } from 'zod';
|
|
|
8
8
|
declare const UserContentBlockSchema: z.ZodObject<{
|
|
9
9
|
type: z.ZodLiteral<"text">;
|
|
10
10
|
text: z.ZodString;
|
|
11
|
-
}, z.
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
text: string;
|
|
13
|
+
type: "text";
|
|
14
|
+
}, {
|
|
15
|
+
text: string;
|
|
16
|
+
type: "text";
|
|
17
|
+
}>;
|
|
12
18
|
/**
|
|
13
19
|
* Zod schema for validating assistant content blocks.
|
|
14
20
|
* Discriminated union supporting text, thinking, tool_use, and tool_result.
|
|
15
21
|
*/
|
|
16
|
-
declare const AssistantContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
22
|
+
declare const AssistantContentBlockSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
17
23
|
type: z.ZodLiteral<"text">;
|
|
18
24
|
text: z.ZodString;
|
|
19
|
-
},
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
text: string;
|
|
27
|
+
type: "text";
|
|
28
|
+
}, {
|
|
29
|
+
text: string;
|
|
30
|
+
type: "text";
|
|
31
|
+
}>, z.ZodObject<{
|
|
20
32
|
type: z.ZodLiteral<"thinking">;
|
|
21
33
|
text: z.ZodString;
|
|
22
|
-
},
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
text: string;
|
|
36
|
+
type: "thinking";
|
|
37
|
+
}, {
|
|
38
|
+
text: string;
|
|
39
|
+
type: "thinking";
|
|
40
|
+
}>, z.ZodObject<{
|
|
23
41
|
type: z.ZodLiteral<"tool_use">;
|
|
24
42
|
toolCallId: z.ZodString;
|
|
25
43
|
tool: z.ZodString;
|
|
26
44
|
args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
27
|
-
},
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
type: "tool_use";
|
|
47
|
+
toolCallId: string;
|
|
48
|
+
tool: string;
|
|
49
|
+
args: Record<string, unknown>;
|
|
50
|
+
}, {
|
|
51
|
+
type: "tool_use";
|
|
52
|
+
toolCallId: string;
|
|
53
|
+
tool: string;
|
|
54
|
+
args: Record<string, unknown>;
|
|
55
|
+
}>, z.ZodObject<{
|
|
28
56
|
type: z.ZodLiteral<"tool_result">;
|
|
29
57
|
toolCallId: z.ZodString;
|
|
30
58
|
tool: z.ZodString;
|
|
31
|
-
status: z.ZodEnum<
|
|
32
|
-
success: "success";
|
|
33
|
-
error: "error";
|
|
34
|
-
}>;
|
|
59
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
35
60
|
summary: z.ZodOptional<z.ZodString>;
|
|
36
|
-
|
|
61
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
type: "tool_result";
|
|
64
|
+
status: "success" | "error";
|
|
65
|
+
toolCallId: string;
|
|
66
|
+
tool: string;
|
|
67
|
+
summary?: string | undefined;
|
|
68
|
+
output?: Record<string, unknown> | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
type: "tool_result";
|
|
71
|
+
status: "success" | "error";
|
|
72
|
+
toolCallId: string;
|
|
73
|
+
tool: string;
|
|
74
|
+
summary?: string | undefined;
|
|
75
|
+
output?: Record<string, unknown> | undefined;
|
|
76
|
+
}>]>;
|
|
37
77
|
/**
|
|
38
78
|
* Zod schema for validating input messages.
|
|
39
79
|
*/
|
|
@@ -41,21 +81,46 @@ declare const InputMessageSchema: z.ZodObject<{
|
|
|
41
81
|
content: z.ZodArray<z.ZodObject<{
|
|
42
82
|
type: z.ZodLiteral<"text">;
|
|
43
83
|
text: z.ZodString;
|
|
44
|
-
}, z.
|
|
45
|
-
|
|
84
|
+
}, "strip", z.ZodTypeAny, {
|
|
85
|
+
text: string;
|
|
86
|
+
type: "text";
|
|
87
|
+
}, {
|
|
88
|
+
text: string;
|
|
89
|
+
type: "text";
|
|
90
|
+
}>, "many">;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
content: {
|
|
93
|
+
text: string;
|
|
94
|
+
type: "text";
|
|
95
|
+
}[];
|
|
96
|
+
}, {
|
|
97
|
+
content: {
|
|
98
|
+
text: string;
|
|
99
|
+
type: "text";
|
|
100
|
+
}[];
|
|
101
|
+
}>;
|
|
46
102
|
/**
|
|
47
103
|
* Zod schema for validating action results from continuation events.
|
|
48
104
|
*/
|
|
49
105
|
declare const ActionResultSchema: z.ZodObject<{
|
|
50
106
|
actionId: z.ZodString;
|
|
51
107
|
kind: z.ZodString;
|
|
52
|
-
status: z.ZodEnum<
|
|
53
|
-
success: "success";
|
|
54
|
-
error: "error";
|
|
55
|
-
}>;
|
|
108
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
56
109
|
data: z.ZodOptional<z.ZodUnknown>;
|
|
57
110
|
error: z.ZodOptional<z.ZodString>;
|
|
58
|
-
}, z.
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
status: "success" | "error";
|
|
113
|
+
actionId: string;
|
|
114
|
+
kind: string;
|
|
115
|
+
error?: string | undefined;
|
|
116
|
+
data?: unknown;
|
|
117
|
+
}, {
|
|
118
|
+
status: "success" | "error";
|
|
119
|
+
actionId: string;
|
|
120
|
+
kind: string;
|
|
121
|
+
error?: string | undefined;
|
|
122
|
+
data?: unknown;
|
|
123
|
+
}>;
|
|
59
124
|
/**
|
|
60
125
|
* Zod schema for validating agent request payloads.
|
|
61
126
|
* Context object uses passthrough() to allow additional fields.
|
|
@@ -65,55 +130,157 @@ declare const AgentRequestSchema: z.ZodObject<{
|
|
|
65
130
|
content: z.ZodArray<z.ZodObject<{
|
|
66
131
|
type: z.ZodLiteral<"text">;
|
|
67
132
|
text: z.ZodString;
|
|
68
|
-
}, z.
|
|
69
|
-
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
text: string;
|
|
135
|
+
type: "text";
|
|
136
|
+
}, {
|
|
137
|
+
text: string;
|
|
138
|
+
type: "text";
|
|
139
|
+
}>, "many">;
|
|
140
|
+
}, "strip", z.ZodTypeAny, {
|
|
141
|
+
content: {
|
|
142
|
+
text: string;
|
|
143
|
+
type: "text";
|
|
144
|
+
}[];
|
|
145
|
+
}, {
|
|
146
|
+
content: {
|
|
147
|
+
text: string;
|
|
148
|
+
type: "text";
|
|
149
|
+
}[];
|
|
150
|
+
}>, "many">;
|
|
70
151
|
threadId: z.ZodOptional<z.ZodString>;
|
|
71
152
|
context: z.ZodOptional<z.ZodObject<{
|
|
72
153
|
actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
73
154
|
actionId: z.ZodString;
|
|
74
155
|
kind: z.ZodString;
|
|
75
|
-
status: z.ZodEnum<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
156
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
157
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
158
|
+
error: z.ZodOptional<z.ZodString>;
|
|
159
|
+
}, "strip", z.ZodTypeAny, {
|
|
160
|
+
status: "success" | "error";
|
|
161
|
+
actionId: string;
|
|
162
|
+
kind: string;
|
|
163
|
+
error?: string | undefined;
|
|
164
|
+
data?: unknown;
|
|
165
|
+
}, {
|
|
166
|
+
status: "success" | "error";
|
|
167
|
+
actionId: string;
|
|
168
|
+
kind: string;
|
|
169
|
+
error?: string | undefined;
|
|
170
|
+
data?: unknown;
|
|
171
|
+
}>, "many">>;
|
|
172
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
173
|
+
actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
174
|
+
actionId: z.ZodString;
|
|
175
|
+
kind: z.ZodString;
|
|
176
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
177
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
178
|
+
error: z.ZodOptional<z.ZodString>;
|
|
179
|
+
}, "strip", z.ZodTypeAny, {
|
|
180
|
+
status: "success" | "error";
|
|
181
|
+
actionId: string;
|
|
182
|
+
kind: string;
|
|
183
|
+
error?: string | undefined;
|
|
184
|
+
data?: unknown;
|
|
185
|
+
}, {
|
|
186
|
+
status: "success" | "error";
|
|
187
|
+
actionId: string;
|
|
188
|
+
kind: string;
|
|
189
|
+
error?: string | undefined;
|
|
190
|
+
data?: unknown;
|
|
191
|
+
}>, "many">>;
|
|
192
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
193
|
+
actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
194
|
+
actionId: z.ZodString;
|
|
195
|
+
kind: z.ZodString;
|
|
196
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
197
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
198
|
+
error: z.ZodOptional<z.ZodString>;
|
|
199
|
+
}, "strip", z.ZodTypeAny, {
|
|
200
|
+
status: "success" | "error";
|
|
201
|
+
actionId: string;
|
|
202
|
+
kind: string;
|
|
203
|
+
error?: string | undefined;
|
|
204
|
+
data?: unknown;
|
|
205
|
+
}, {
|
|
206
|
+
status: "success" | "error";
|
|
207
|
+
actionId: string;
|
|
208
|
+
kind: string;
|
|
209
|
+
error?: string | undefined;
|
|
210
|
+
data?: unknown;
|
|
211
|
+
}>, "many">>;
|
|
212
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
213
|
+
}, "strip", z.ZodTypeAny, {
|
|
214
|
+
messages: {
|
|
215
|
+
content: {
|
|
216
|
+
text: string;
|
|
217
|
+
type: "text";
|
|
218
|
+
}[];
|
|
219
|
+
}[];
|
|
220
|
+
threadId?: string | undefined;
|
|
221
|
+
context?: z.objectOutputType<{
|
|
222
|
+
actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
223
|
+
actionId: z.ZodString;
|
|
224
|
+
kind: z.ZodString;
|
|
225
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
226
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
227
|
+
error: z.ZodOptional<z.ZodString>;
|
|
228
|
+
}, "strip", z.ZodTypeAny, {
|
|
229
|
+
status: "success" | "error";
|
|
230
|
+
actionId: string;
|
|
231
|
+
kind: string;
|
|
232
|
+
error?: string | undefined;
|
|
233
|
+
data?: unknown;
|
|
234
|
+
}, {
|
|
235
|
+
status: "success" | "error";
|
|
236
|
+
actionId: string;
|
|
237
|
+
kind: string;
|
|
238
|
+
error?: string | undefined;
|
|
239
|
+
data?: unknown;
|
|
240
|
+
}>, "many">>;
|
|
241
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
242
|
+
}, {
|
|
243
|
+
messages: {
|
|
244
|
+
content: {
|
|
245
|
+
text: string;
|
|
246
|
+
type: "text";
|
|
247
|
+
}[];
|
|
248
|
+
}[];
|
|
249
|
+
threadId?: string | undefined;
|
|
250
|
+
context?: z.objectInputType<{
|
|
251
|
+
actionResults: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
252
|
+
actionId: z.ZodString;
|
|
253
|
+
kind: z.ZodString;
|
|
254
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
79
255
|
data: z.ZodOptional<z.ZodUnknown>;
|
|
80
256
|
error: z.ZodOptional<z.ZodString>;
|
|
81
|
-
}, z.
|
|
82
|
-
|
|
83
|
-
|
|
257
|
+
}, "strip", z.ZodTypeAny, {
|
|
258
|
+
status: "success" | "error";
|
|
259
|
+
actionId: string;
|
|
260
|
+
kind: string;
|
|
261
|
+
error?: string | undefined;
|
|
262
|
+
data?: unknown;
|
|
263
|
+
}, {
|
|
264
|
+
status: "success" | "error";
|
|
265
|
+
actionId: string;
|
|
266
|
+
kind: string;
|
|
267
|
+
error?: string | undefined;
|
|
268
|
+
data?: unknown;
|
|
269
|
+
}>, "many">>;
|
|
270
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
271
|
+
}>;
|
|
84
272
|
/**
|
|
85
273
|
* Zod schema for event lifecycle stages.
|
|
86
274
|
*/
|
|
87
|
-
declare const EventStageSchema: z.ZodEnum<
|
|
88
|
-
start: "start";
|
|
89
|
-
delta: "delta";
|
|
90
|
-
stop: "stop";
|
|
91
|
-
}>;
|
|
275
|
+
declare const EventStageSchema: z.ZodEnum<["start", "delta", "stop"]>;
|
|
92
276
|
/**
|
|
93
277
|
* Zod schema for protocol error codes.
|
|
94
278
|
*/
|
|
95
|
-
declare const ErrorCodeSchema: z.ZodEnum<
|
|
96
|
-
auth_failed: "auth_failed";
|
|
97
|
-
thread_not_found: "thread_not_found";
|
|
98
|
-
thread_access_denied: "thread_access_denied";
|
|
99
|
-
invalid_message_format: "invalid_message_format";
|
|
100
|
-
message_too_large: "message_too_large";
|
|
101
|
-
rate_limit_exceeded: "rate_limit_exceeded";
|
|
102
|
-
stream_timeout: "stream_timeout";
|
|
103
|
-
agent_error: "agent_error";
|
|
104
|
-
tool_error: "tool_error";
|
|
105
|
-
internal_error: "internal_error";
|
|
106
|
-
invalid_action_id: "invalid_action_id";
|
|
107
|
-
}>;
|
|
279
|
+
declare const ErrorCodeSchema: z.ZodEnum<["auth_failed", "thread_not_found", "thread_access_denied", "invalid_message_format", "message_too_large", "rate_limit_exceeded", "stream_timeout", "agent_error", "tool_error", "internal_error", "invalid_action_id"]>;
|
|
108
280
|
/**
|
|
109
281
|
* Zod schema for stream finish reasons.
|
|
110
282
|
*/
|
|
111
|
-
declare const FinishReasonSchema: z.ZodEnum<
|
|
112
|
-
error: "error";
|
|
113
|
-
stop: "stop";
|
|
114
|
-
length: "length";
|
|
115
|
-
action_required: "action_required";
|
|
116
|
-
}>;
|
|
283
|
+
declare const FinishReasonSchema: z.ZodEnum<["stop", "length", "error", "action_required"]>;
|
|
117
284
|
/**
|
|
118
285
|
* Zod schema for metadata events.
|
|
119
286
|
* First event in every stream, provides identifiers.
|
|
@@ -124,7 +291,19 @@ declare const MetadataEventSchema: z.ZodObject<{
|
|
|
124
291
|
threadId: z.ZodString;
|
|
125
292
|
agentId: z.ZodString;
|
|
126
293
|
timestamp: z.ZodString;
|
|
127
|
-
}, z.
|
|
294
|
+
}, "strip", z.ZodTypeAny, {
|
|
295
|
+
threadId: string;
|
|
296
|
+
event: "metadata";
|
|
297
|
+
requestId: string;
|
|
298
|
+
agentId: string;
|
|
299
|
+
timestamp: string;
|
|
300
|
+
}, {
|
|
301
|
+
threadId: string;
|
|
302
|
+
event: "metadata";
|
|
303
|
+
requestId: string;
|
|
304
|
+
agentId: string;
|
|
305
|
+
timestamp: string;
|
|
306
|
+
}>;
|
|
128
307
|
/**
|
|
129
308
|
* Zod schema for text streaming events.
|
|
130
309
|
* Validates the stage lifecycle with appropriate optional fields per stage.
|
|
@@ -135,15 +314,31 @@ declare const TextEventSchema: z.ZodObject<{
|
|
|
135
314
|
messageId: z.ZodString;
|
|
136
315
|
blockId: z.ZodString;
|
|
137
316
|
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
138
|
-
stage: z.ZodEnum<
|
|
139
|
-
start: "start";
|
|
140
|
-
delta: "delta";
|
|
141
|
-
stop: "stop";
|
|
142
|
-
}>;
|
|
317
|
+
stage: z.ZodEnum<["start", "delta", "stop"]>;
|
|
143
318
|
delta: z.ZodOptional<z.ZodString>;
|
|
144
319
|
deltaIndex: z.ZodOptional<z.ZodNumber>;
|
|
145
320
|
timestamp: z.ZodString;
|
|
146
|
-
}, z.
|
|
321
|
+
}, "strip", z.ZodTypeAny, {
|
|
322
|
+
event: "text";
|
|
323
|
+
requestId: string;
|
|
324
|
+
timestamp: string;
|
|
325
|
+
messageId: string;
|
|
326
|
+
blockId: string;
|
|
327
|
+
stage: "start" | "delta" | "stop";
|
|
328
|
+
delta?: string | undefined;
|
|
329
|
+
blockIndex?: number | undefined;
|
|
330
|
+
deltaIndex?: number | undefined;
|
|
331
|
+
}, {
|
|
332
|
+
event: "text";
|
|
333
|
+
requestId: string;
|
|
334
|
+
timestamp: string;
|
|
335
|
+
messageId: string;
|
|
336
|
+
blockId: string;
|
|
337
|
+
stage: "start" | "delta" | "stop";
|
|
338
|
+
delta?: string | undefined;
|
|
339
|
+
blockIndex?: number | undefined;
|
|
340
|
+
deltaIndex?: number | undefined;
|
|
341
|
+
}>;
|
|
147
342
|
/**
|
|
148
343
|
* Zod schema for thinking/reasoning events.
|
|
149
344
|
* Structure mirrors TextEventSchema.
|
|
@@ -154,15 +349,31 @@ declare const ThinkingEventSchema: z.ZodObject<{
|
|
|
154
349
|
messageId: z.ZodString;
|
|
155
350
|
blockId: z.ZodString;
|
|
156
351
|
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
157
|
-
stage: z.ZodEnum<
|
|
158
|
-
start: "start";
|
|
159
|
-
delta: "delta";
|
|
160
|
-
stop: "stop";
|
|
161
|
-
}>;
|
|
352
|
+
stage: z.ZodEnum<["start", "delta", "stop"]>;
|
|
162
353
|
delta: z.ZodOptional<z.ZodString>;
|
|
163
354
|
deltaIndex: z.ZodOptional<z.ZodNumber>;
|
|
164
355
|
timestamp: z.ZodString;
|
|
165
|
-
}, z.
|
|
356
|
+
}, "strip", z.ZodTypeAny, {
|
|
357
|
+
event: "thinking";
|
|
358
|
+
requestId: string;
|
|
359
|
+
timestamp: string;
|
|
360
|
+
messageId: string;
|
|
361
|
+
blockId: string;
|
|
362
|
+
stage: "start" | "delta" | "stop";
|
|
363
|
+
delta?: string | undefined;
|
|
364
|
+
blockIndex?: number | undefined;
|
|
365
|
+
deltaIndex?: number | undefined;
|
|
366
|
+
}, {
|
|
367
|
+
event: "thinking";
|
|
368
|
+
requestId: string;
|
|
369
|
+
timestamp: string;
|
|
370
|
+
messageId: string;
|
|
371
|
+
blockId: string;
|
|
372
|
+
stage: "start" | "delta" | "stop";
|
|
373
|
+
delta?: string | undefined;
|
|
374
|
+
blockIndex?: number | undefined;
|
|
375
|
+
deltaIndex?: number | undefined;
|
|
376
|
+
}>;
|
|
166
377
|
/**
|
|
167
378
|
* Zod schema for tool call events.
|
|
168
379
|
* Args are optional (only present on stop stage).
|
|
@@ -173,18 +384,40 @@ declare const ToolCallEventSchema: z.ZodObject<{
|
|
|
173
384
|
messageId: z.ZodString;
|
|
174
385
|
blockId: z.ZodString;
|
|
175
386
|
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
176
|
-
stage: z.ZodEnum<
|
|
177
|
-
start: "start";
|
|
178
|
-
delta: "delta";
|
|
179
|
-
stop: "stop";
|
|
180
|
-
}>;
|
|
387
|
+
stage: z.ZodEnum<["start", "delta", "stop"]>;
|
|
181
388
|
toolCallId: z.ZodOptional<z.ZodString>;
|
|
182
389
|
tool: z.ZodOptional<z.ZodString>;
|
|
183
390
|
delta: z.ZodOptional<z.ZodString>;
|
|
184
391
|
deltaIndex: z.ZodOptional<z.ZodNumber>;
|
|
185
392
|
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
186
393
|
timestamp: z.ZodString;
|
|
187
|
-
}, z.
|
|
394
|
+
}, "strip", z.ZodTypeAny, {
|
|
395
|
+
event: "tool_call";
|
|
396
|
+
requestId: string;
|
|
397
|
+
timestamp: string;
|
|
398
|
+
messageId: string;
|
|
399
|
+
blockId: string;
|
|
400
|
+
stage: "start" | "delta" | "stop";
|
|
401
|
+
delta?: string | undefined;
|
|
402
|
+
toolCallId?: string | undefined;
|
|
403
|
+
tool?: string | undefined;
|
|
404
|
+
args?: Record<string, unknown> | undefined;
|
|
405
|
+
blockIndex?: number | undefined;
|
|
406
|
+
deltaIndex?: number | undefined;
|
|
407
|
+
}, {
|
|
408
|
+
event: "tool_call";
|
|
409
|
+
requestId: string;
|
|
410
|
+
timestamp: string;
|
|
411
|
+
messageId: string;
|
|
412
|
+
blockId: string;
|
|
413
|
+
stage: "start" | "delta" | "stop";
|
|
414
|
+
delta?: string | undefined;
|
|
415
|
+
toolCallId?: string | undefined;
|
|
416
|
+
tool?: string | undefined;
|
|
417
|
+
args?: Record<string, unknown> | undefined;
|
|
418
|
+
blockIndex?: number | undefined;
|
|
419
|
+
deltaIndex?: number | undefined;
|
|
420
|
+
}>;
|
|
188
421
|
/**
|
|
189
422
|
* Zod schema for tool result events.
|
|
190
423
|
* Status and summary only present on stop stage.
|
|
@@ -195,20 +428,40 @@ declare const ToolResultEventSchema: z.ZodObject<{
|
|
|
195
428
|
messageId: z.ZodString;
|
|
196
429
|
blockId: z.ZodString;
|
|
197
430
|
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
198
|
-
stage: z.ZodEnum<
|
|
199
|
-
start: "start";
|
|
200
|
-
delta: "delta";
|
|
201
|
-
stop: "stop";
|
|
202
|
-
}>;
|
|
431
|
+
stage: z.ZodEnum<["start", "delta", "stop"]>;
|
|
203
432
|
toolCallId: z.ZodOptional<z.ZodString>;
|
|
204
433
|
tool: z.ZodOptional<z.ZodString>;
|
|
205
|
-
status: z.ZodOptional<z.ZodEnum<
|
|
206
|
-
success: "success";
|
|
207
|
-
error: "error";
|
|
208
|
-
}>>;
|
|
434
|
+
status: z.ZodOptional<z.ZodEnum<["success", "error"]>>;
|
|
209
435
|
summary: z.ZodOptional<z.ZodString>;
|
|
436
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
210
437
|
timestamp: z.ZodString;
|
|
211
|
-
}, z.
|
|
438
|
+
}, "strip", z.ZodTypeAny, {
|
|
439
|
+
event: "tool_result";
|
|
440
|
+
requestId: string;
|
|
441
|
+
timestamp: string;
|
|
442
|
+
messageId: string;
|
|
443
|
+
blockId: string;
|
|
444
|
+
stage: "start" | "delta" | "stop";
|
|
445
|
+
status?: "success" | "error" | undefined;
|
|
446
|
+
toolCallId?: string | undefined;
|
|
447
|
+
tool?: string | undefined;
|
|
448
|
+
summary?: string | undefined;
|
|
449
|
+
output?: Record<string, unknown> | undefined;
|
|
450
|
+
blockIndex?: number | undefined;
|
|
451
|
+
}, {
|
|
452
|
+
event: "tool_result";
|
|
453
|
+
requestId: string;
|
|
454
|
+
timestamp: string;
|
|
455
|
+
messageId: string;
|
|
456
|
+
blockId: string;
|
|
457
|
+
stage: "start" | "delta" | "stop";
|
|
458
|
+
status?: "success" | "error" | undefined;
|
|
459
|
+
toolCallId?: string | undefined;
|
|
460
|
+
tool?: string | undefined;
|
|
461
|
+
summary?: string | undefined;
|
|
462
|
+
output?: Record<string, unknown> | undefined;
|
|
463
|
+
blockIndex?: number | undefined;
|
|
464
|
+
}>;
|
|
212
465
|
/**
|
|
213
466
|
* Zod schema for done events.
|
|
214
467
|
* Terminal event with complete content array.
|
|
@@ -218,40 +471,137 @@ declare const DoneEventSchema: z.ZodObject<{
|
|
|
218
471
|
requestId: z.ZodString;
|
|
219
472
|
messageId: z.ZodString;
|
|
220
473
|
threadId: z.ZodString;
|
|
221
|
-
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
474
|
+
content: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
222
475
|
type: z.ZodLiteral<"text">;
|
|
223
476
|
text: z.ZodString;
|
|
224
|
-
},
|
|
477
|
+
}, "strip", z.ZodTypeAny, {
|
|
478
|
+
text: string;
|
|
479
|
+
type: "text";
|
|
480
|
+
}, {
|
|
481
|
+
text: string;
|
|
482
|
+
type: "text";
|
|
483
|
+
}>, z.ZodObject<{
|
|
225
484
|
type: z.ZodLiteral<"thinking">;
|
|
226
485
|
text: z.ZodString;
|
|
227
|
-
},
|
|
486
|
+
}, "strip", z.ZodTypeAny, {
|
|
487
|
+
text: string;
|
|
488
|
+
type: "thinking";
|
|
489
|
+
}, {
|
|
490
|
+
text: string;
|
|
491
|
+
type: "thinking";
|
|
492
|
+
}>, z.ZodObject<{
|
|
228
493
|
type: z.ZodLiteral<"tool_use">;
|
|
229
494
|
toolCallId: z.ZodString;
|
|
230
495
|
tool: z.ZodString;
|
|
231
496
|
args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
232
|
-
},
|
|
497
|
+
}, "strip", z.ZodTypeAny, {
|
|
498
|
+
type: "tool_use";
|
|
499
|
+
toolCallId: string;
|
|
500
|
+
tool: string;
|
|
501
|
+
args: Record<string, unknown>;
|
|
502
|
+
}, {
|
|
503
|
+
type: "tool_use";
|
|
504
|
+
toolCallId: string;
|
|
505
|
+
tool: string;
|
|
506
|
+
args: Record<string, unknown>;
|
|
507
|
+
}>, z.ZodObject<{
|
|
233
508
|
type: z.ZodLiteral<"tool_result">;
|
|
234
509
|
toolCallId: z.ZodString;
|
|
235
510
|
tool: z.ZodString;
|
|
236
|
-
status: z.ZodEnum<
|
|
237
|
-
success: "success";
|
|
238
|
-
error: "error";
|
|
239
|
-
}>;
|
|
511
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
240
512
|
summary: z.ZodOptional<z.ZodString>;
|
|
241
|
-
|
|
513
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
514
|
+
}, "strip", z.ZodTypeAny, {
|
|
515
|
+
type: "tool_result";
|
|
516
|
+
status: "success" | "error";
|
|
517
|
+
toolCallId: string;
|
|
518
|
+
tool: string;
|
|
519
|
+
summary?: string | undefined;
|
|
520
|
+
output?: Record<string, unknown> | undefined;
|
|
521
|
+
}, {
|
|
522
|
+
type: "tool_result";
|
|
523
|
+
status: "success" | "error";
|
|
524
|
+
toolCallId: string;
|
|
525
|
+
tool: string;
|
|
526
|
+
summary?: string | undefined;
|
|
527
|
+
output?: Record<string, unknown> | undefined;
|
|
528
|
+
}>]>, "many">;
|
|
242
529
|
usage: z.ZodOptional<z.ZodObject<{
|
|
243
530
|
promptTokens: z.ZodNumber;
|
|
244
531
|
completionTokens: z.ZodNumber;
|
|
245
|
-
}, z.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
532
|
+
}, "strip", z.ZodTypeAny, {
|
|
533
|
+
promptTokens: number;
|
|
534
|
+
completionTokens: number;
|
|
535
|
+
}, {
|
|
536
|
+
promptTokens: number;
|
|
537
|
+
completionTokens: number;
|
|
538
|
+
}>>;
|
|
539
|
+
finishReason: z.ZodEnum<["stop", "length", "error", "action_required"]>;
|
|
252
540
|
traceId: z.ZodOptional<z.ZodString>;
|
|
253
541
|
timestamp: z.ZodString;
|
|
254
|
-
}, z.
|
|
542
|
+
}, "strip", z.ZodTypeAny, {
|
|
543
|
+
content: ({
|
|
544
|
+
text: string;
|
|
545
|
+
type: "text";
|
|
546
|
+
} | {
|
|
547
|
+
text: string;
|
|
548
|
+
type: "thinking";
|
|
549
|
+
} | {
|
|
550
|
+
type: "tool_use";
|
|
551
|
+
toolCallId: string;
|
|
552
|
+
tool: string;
|
|
553
|
+
args: Record<string, unknown>;
|
|
554
|
+
} | {
|
|
555
|
+
type: "tool_result";
|
|
556
|
+
status: "success" | "error";
|
|
557
|
+
toolCallId: string;
|
|
558
|
+
tool: string;
|
|
559
|
+
summary?: string | undefined;
|
|
560
|
+
output?: Record<string, unknown> | undefined;
|
|
561
|
+
})[];
|
|
562
|
+
threadId: string;
|
|
563
|
+
event: "done";
|
|
564
|
+
requestId: string;
|
|
565
|
+
timestamp: string;
|
|
566
|
+
messageId: string;
|
|
567
|
+
finishReason: "error" | "stop" | "length" | "action_required";
|
|
568
|
+
usage?: {
|
|
569
|
+
promptTokens: number;
|
|
570
|
+
completionTokens: number;
|
|
571
|
+
} | undefined;
|
|
572
|
+
traceId?: string | undefined;
|
|
573
|
+
}, {
|
|
574
|
+
content: ({
|
|
575
|
+
text: string;
|
|
576
|
+
type: "text";
|
|
577
|
+
} | {
|
|
578
|
+
text: string;
|
|
579
|
+
type: "thinking";
|
|
580
|
+
} | {
|
|
581
|
+
type: "tool_use";
|
|
582
|
+
toolCallId: string;
|
|
583
|
+
tool: string;
|
|
584
|
+
args: Record<string, unknown>;
|
|
585
|
+
} | {
|
|
586
|
+
type: "tool_result";
|
|
587
|
+
status: "success" | "error";
|
|
588
|
+
toolCallId: string;
|
|
589
|
+
tool: string;
|
|
590
|
+
summary?: string | undefined;
|
|
591
|
+
output?: Record<string, unknown> | undefined;
|
|
592
|
+
})[];
|
|
593
|
+
threadId: string;
|
|
594
|
+
event: "done";
|
|
595
|
+
requestId: string;
|
|
596
|
+
timestamp: string;
|
|
597
|
+
messageId: string;
|
|
598
|
+
finishReason: "error" | "stop" | "length" | "action_required";
|
|
599
|
+
usage?: {
|
|
600
|
+
promptTokens: number;
|
|
601
|
+
completionTokens: number;
|
|
602
|
+
} | undefined;
|
|
603
|
+
traceId?: string | undefined;
|
|
604
|
+
}>;
|
|
255
605
|
/**
|
|
256
606
|
* Zod schema for error events.
|
|
257
607
|
* Terminal event with error details and retry guidance.
|
|
@@ -260,22 +610,24 @@ declare const ErrorEventSchema: z.ZodObject<{
|
|
|
260
610
|
event: z.ZodLiteral<"error">;
|
|
261
611
|
requestId: z.ZodString;
|
|
262
612
|
message: z.ZodString;
|
|
263
|
-
code: z.ZodOptional<z.ZodEnum<
|
|
264
|
-
auth_failed: "auth_failed";
|
|
265
|
-
thread_not_found: "thread_not_found";
|
|
266
|
-
thread_access_denied: "thread_access_denied";
|
|
267
|
-
invalid_message_format: "invalid_message_format";
|
|
268
|
-
message_too_large: "message_too_large";
|
|
269
|
-
rate_limit_exceeded: "rate_limit_exceeded";
|
|
270
|
-
stream_timeout: "stream_timeout";
|
|
271
|
-
agent_error: "agent_error";
|
|
272
|
-
tool_error: "tool_error";
|
|
273
|
-
internal_error: "internal_error";
|
|
274
|
-
invalid_action_id: "invalid_action_id";
|
|
275
|
-
}>>;
|
|
613
|
+
code: z.ZodOptional<z.ZodEnum<["auth_failed", "thread_not_found", "thread_access_denied", "invalid_message_format", "message_too_large", "rate_limit_exceeded", "stream_timeout", "agent_error", "tool_error", "internal_error", "invalid_action_id"]>>;
|
|
276
614
|
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
277
615
|
timestamp: z.ZodString;
|
|
278
|
-
}, z.
|
|
616
|
+
}, "strip", z.ZodTypeAny, {
|
|
617
|
+
message: string;
|
|
618
|
+
event: "error";
|
|
619
|
+
requestId: string;
|
|
620
|
+
timestamp: string;
|
|
621
|
+
code?: "auth_failed" | "thread_not_found" | "thread_access_denied" | "invalid_message_format" | "message_too_large" | "rate_limit_exceeded" | "stream_timeout" | "agent_error" | "tool_error" | "internal_error" | "invalid_action_id" | undefined;
|
|
622
|
+
retryable?: boolean | undefined;
|
|
623
|
+
}, {
|
|
624
|
+
message: string;
|
|
625
|
+
event: "error";
|
|
626
|
+
requestId: string;
|
|
627
|
+
timestamp: string;
|
|
628
|
+
code?: "auth_failed" | "thread_not_found" | "thread_access_denied" | "invalid_message_format" | "message_too_large" | "rate_limit_exceeded" | "stream_timeout" | "agent_error" | "tool_error" | "internal_error" | "invalid_action_id" | undefined;
|
|
629
|
+
retryable?: boolean | undefined;
|
|
630
|
+
}>;
|
|
279
631
|
/**
|
|
280
632
|
* Zod schema for aborted events.
|
|
281
633
|
* Terminal event acknowledging client cancellation.
|
|
@@ -285,7 +637,17 @@ declare const AbortedEventSchema: z.ZodObject<{
|
|
|
285
637
|
requestId: z.ZodString;
|
|
286
638
|
messageId: z.ZodOptional<z.ZodString>;
|
|
287
639
|
timestamp: z.ZodString;
|
|
288
|
-
}, z.
|
|
640
|
+
}, "strip", z.ZodTypeAny, {
|
|
641
|
+
event: "aborted";
|
|
642
|
+
requestId: string;
|
|
643
|
+
timestamp: string;
|
|
644
|
+
messageId?: string | undefined;
|
|
645
|
+
}, {
|
|
646
|
+
event: "aborted";
|
|
647
|
+
requestId: string;
|
|
648
|
+
timestamp: string;
|
|
649
|
+
messageId?: string | undefined;
|
|
650
|
+
}>;
|
|
289
651
|
/**
|
|
290
652
|
* Zod schema for continuation events.
|
|
291
653
|
* Signals client action required before stream can continue.
|
|
@@ -297,151 +659,374 @@ declare const ContinuationEventSchema: z.ZodObject<{
|
|
|
297
659
|
kind: z.ZodString;
|
|
298
660
|
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
299
661
|
timestamp: z.ZodString;
|
|
300
|
-
}, z.
|
|
662
|
+
}, "strip", z.ZodTypeAny, {
|
|
663
|
+
actionId: string;
|
|
664
|
+
kind: string;
|
|
665
|
+
event: "continuation";
|
|
666
|
+
requestId: string;
|
|
667
|
+
timestamp: string;
|
|
668
|
+
payload: Record<string, unknown>;
|
|
669
|
+
}, {
|
|
670
|
+
actionId: string;
|
|
671
|
+
kind: string;
|
|
672
|
+
event: "continuation";
|
|
673
|
+
requestId: string;
|
|
674
|
+
timestamp: string;
|
|
675
|
+
payload: Record<string, unknown>;
|
|
676
|
+
}>;
|
|
301
677
|
/**
|
|
302
678
|
* Zod schema for all protocol events.
|
|
303
679
|
* Discriminated union on the `event` field for efficient parsing.
|
|
304
680
|
*/
|
|
305
|
-
declare const AgentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
681
|
+
declare const AgentEventSchema: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
|
|
306
682
|
event: z.ZodLiteral<"metadata">;
|
|
307
683
|
requestId: z.ZodString;
|
|
308
684
|
threadId: z.ZodString;
|
|
309
685
|
agentId: z.ZodString;
|
|
310
686
|
timestamp: z.ZodString;
|
|
311
|
-
},
|
|
687
|
+
}, "strip", z.ZodTypeAny, {
|
|
688
|
+
threadId: string;
|
|
689
|
+
event: "metadata";
|
|
690
|
+
requestId: string;
|
|
691
|
+
agentId: string;
|
|
692
|
+
timestamp: string;
|
|
693
|
+
}, {
|
|
694
|
+
threadId: string;
|
|
695
|
+
event: "metadata";
|
|
696
|
+
requestId: string;
|
|
697
|
+
agentId: string;
|
|
698
|
+
timestamp: string;
|
|
699
|
+
}>, z.ZodObject<{
|
|
312
700
|
event: z.ZodLiteral<"text">;
|
|
313
701
|
requestId: z.ZodString;
|
|
314
702
|
messageId: z.ZodString;
|
|
315
703
|
blockId: z.ZodString;
|
|
316
704
|
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
317
|
-
stage: z.ZodEnum<
|
|
318
|
-
start: "start";
|
|
319
|
-
delta: "delta";
|
|
320
|
-
stop: "stop";
|
|
321
|
-
}>;
|
|
705
|
+
stage: z.ZodEnum<["start", "delta", "stop"]>;
|
|
322
706
|
delta: z.ZodOptional<z.ZodString>;
|
|
323
707
|
deltaIndex: z.ZodOptional<z.ZodNumber>;
|
|
324
708
|
timestamp: z.ZodString;
|
|
325
|
-
},
|
|
709
|
+
}, "strip", z.ZodTypeAny, {
|
|
710
|
+
event: "text";
|
|
711
|
+
requestId: string;
|
|
712
|
+
timestamp: string;
|
|
713
|
+
messageId: string;
|
|
714
|
+
blockId: string;
|
|
715
|
+
stage: "start" | "delta" | "stop";
|
|
716
|
+
delta?: string | undefined;
|
|
717
|
+
blockIndex?: number | undefined;
|
|
718
|
+
deltaIndex?: number | undefined;
|
|
719
|
+
}, {
|
|
720
|
+
event: "text";
|
|
721
|
+
requestId: string;
|
|
722
|
+
timestamp: string;
|
|
723
|
+
messageId: string;
|
|
724
|
+
blockId: string;
|
|
725
|
+
stage: "start" | "delta" | "stop";
|
|
726
|
+
delta?: string | undefined;
|
|
727
|
+
blockIndex?: number | undefined;
|
|
728
|
+
deltaIndex?: number | undefined;
|
|
729
|
+
}>, z.ZodObject<{
|
|
326
730
|
event: z.ZodLiteral<"thinking">;
|
|
327
731
|
requestId: z.ZodString;
|
|
328
732
|
messageId: z.ZodString;
|
|
329
733
|
blockId: z.ZodString;
|
|
330
734
|
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
331
|
-
stage: z.ZodEnum<
|
|
332
|
-
start: "start";
|
|
333
|
-
delta: "delta";
|
|
334
|
-
stop: "stop";
|
|
335
|
-
}>;
|
|
735
|
+
stage: z.ZodEnum<["start", "delta", "stop"]>;
|
|
336
736
|
delta: z.ZodOptional<z.ZodString>;
|
|
337
737
|
deltaIndex: z.ZodOptional<z.ZodNumber>;
|
|
338
738
|
timestamp: z.ZodString;
|
|
339
|
-
},
|
|
739
|
+
}, "strip", z.ZodTypeAny, {
|
|
740
|
+
event: "thinking";
|
|
741
|
+
requestId: string;
|
|
742
|
+
timestamp: string;
|
|
743
|
+
messageId: string;
|
|
744
|
+
blockId: string;
|
|
745
|
+
stage: "start" | "delta" | "stop";
|
|
746
|
+
delta?: string | undefined;
|
|
747
|
+
blockIndex?: number | undefined;
|
|
748
|
+
deltaIndex?: number | undefined;
|
|
749
|
+
}, {
|
|
750
|
+
event: "thinking";
|
|
751
|
+
requestId: string;
|
|
752
|
+
timestamp: string;
|
|
753
|
+
messageId: string;
|
|
754
|
+
blockId: string;
|
|
755
|
+
stage: "start" | "delta" | "stop";
|
|
756
|
+
delta?: string | undefined;
|
|
757
|
+
blockIndex?: number | undefined;
|
|
758
|
+
deltaIndex?: number | undefined;
|
|
759
|
+
}>, z.ZodObject<{
|
|
340
760
|
event: z.ZodLiteral<"tool_call">;
|
|
341
761
|
requestId: z.ZodString;
|
|
342
762
|
messageId: z.ZodString;
|
|
343
763
|
blockId: z.ZodString;
|
|
344
764
|
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
345
|
-
stage: z.ZodEnum<
|
|
346
|
-
start: "start";
|
|
347
|
-
delta: "delta";
|
|
348
|
-
stop: "stop";
|
|
349
|
-
}>;
|
|
765
|
+
stage: z.ZodEnum<["start", "delta", "stop"]>;
|
|
350
766
|
toolCallId: z.ZodOptional<z.ZodString>;
|
|
351
767
|
tool: z.ZodOptional<z.ZodString>;
|
|
352
768
|
delta: z.ZodOptional<z.ZodString>;
|
|
353
769
|
deltaIndex: z.ZodOptional<z.ZodNumber>;
|
|
354
770
|
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
355
771
|
timestamp: z.ZodString;
|
|
356
|
-
},
|
|
772
|
+
}, "strip", z.ZodTypeAny, {
|
|
773
|
+
event: "tool_call";
|
|
774
|
+
requestId: string;
|
|
775
|
+
timestamp: string;
|
|
776
|
+
messageId: string;
|
|
777
|
+
blockId: string;
|
|
778
|
+
stage: "start" | "delta" | "stop";
|
|
779
|
+
delta?: string | undefined;
|
|
780
|
+
toolCallId?: string | undefined;
|
|
781
|
+
tool?: string | undefined;
|
|
782
|
+
args?: Record<string, unknown> | undefined;
|
|
783
|
+
blockIndex?: number | undefined;
|
|
784
|
+
deltaIndex?: number | undefined;
|
|
785
|
+
}, {
|
|
786
|
+
event: "tool_call";
|
|
787
|
+
requestId: string;
|
|
788
|
+
timestamp: string;
|
|
789
|
+
messageId: string;
|
|
790
|
+
blockId: string;
|
|
791
|
+
stage: "start" | "delta" | "stop";
|
|
792
|
+
delta?: string | undefined;
|
|
793
|
+
toolCallId?: string | undefined;
|
|
794
|
+
tool?: string | undefined;
|
|
795
|
+
args?: Record<string, unknown> | undefined;
|
|
796
|
+
blockIndex?: number | undefined;
|
|
797
|
+
deltaIndex?: number | undefined;
|
|
798
|
+
}>, z.ZodObject<{
|
|
357
799
|
event: z.ZodLiteral<"tool_result">;
|
|
358
800
|
requestId: z.ZodString;
|
|
359
801
|
messageId: z.ZodString;
|
|
360
802
|
blockId: z.ZodString;
|
|
361
803
|
blockIndex: z.ZodOptional<z.ZodNumber>;
|
|
362
|
-
stage: z.ZodEnum<
|
|
363
|
-
start: "start";
|
|
364
|
-
delta: "delta";
|
|
365
|
-
stop: "stop";
|
|
366
|
-
}>;
|
|
804
|
+
stage: z.ZodEnum<["start", "delta", "stop"]>;
|
|
367
805
|
toolCallId: z.ZodOptional<z.ZodString>;
|
|
368
806
|
tool: z.ZodOptional<z.ZodString>;
|
|
369
|
-
status: z.ZodOptional<z.ZodEnum<
|
|
370
|
-
success: "success";
|
|
371
|
-
error: "error";
|
|
372
|
-
}>>;
|
|
807
|
+
status: z.ZodOptional<z.ZodEnum<["success", "error"]>>;
|
|
373
808
|
summary: z.ZodOptional<z.ZodString>;
|
|
809
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
374
810
|
timestamp: z.ZodString;
|
|
375
|
-
},
|
|
811
|
+
}, "strip", z.ZodTypeAny, {
|
|
812
|
+
event: "tool_result";
|
|
813
|
+
requestId: string;
|
|
814
|
+
timestamp: string;
|
|
815
|
+
messageId: string;
|
|
816
|
+
blockId: string;
|
|
817
|
+
stage: "start" | "delta" | "stop";
|
|
818
|
+
status?: "success" | "error" | undefined;
|
|
819
|
+
toolCallId?: string | undefined;
|
|
820
|
+
tool?: string | undefined;
|
|
821
|
+
summary?: string | undefined;
|
|
822
|
+
output?: Record<string, unknown> | undefined;
|
|
823
|
+
blockIndex?: number | undefined;
|
|
824
|
+
}, {
|
|
825
|
+
event: "tool_result";
|
|
826
|
+
requestId: string;
|
|
827
|
+
timestamp: string;
|
|
828
|
+
messageId: string;
|
|
829
|
+
blockId: string;
|
|
830
|
+
stage: "start" | "delta" | "stop";
|
|
831
|
+
status?: "success" | "error" | undefined;
|
|
832
|
+
toolCallId?: string | undefined;
|
|
833
|
+
tool?: string | undefined;
|
|
834
|
+
summary?: string | undefined;
|
|
835
|
+
output?: Record<string, unknown> | undefined;
|
|
836
|
+
blockIndex?: number | undefined;
|
|
837
|
+
}>, z.ZodObject<{
|
|
376
838
|
event: z.ZodLiteral<"done">;
|
|
377
839
|
requestId: z.ZodString;
|
|
378
840
|
messageId: z.ZodString;
|
|
379
841
|
threadId: z.ZodString;
|
|
380
|
-
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
842
|
+
content: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
381
843
|
type: z.ZodLiteral<"text">;
|
|
382
844
|
text: z.ZodString;
|
|
383
|
-
},
|
|
845
|
+
}, "strip", z.ZodTypeAny, {
|
|
846
|
+
text: string;
|
|
847
|
+
type: "text";
|
|
848
|
+
}, {
|
|
849
|
+
text: string;
|
|
850
|
+
type: "text";
|
|
851
|
+
}>, z.ZodObject<{
|
|
384
852
|
type: z.ZodLiteral<"thinking">;
|
|
385
853
|
text: z.ZodString;
|
|
386
|
-
},
|
|
854
|
+
}, "strip", z.ZodTypeAny, {
|
|
855
|
+
text: string;
|
|
856
|
+
type: "thinking";
|
|
857
|
+
}, {
|
|
858
|
+
text: string;
|
|
859
|
+
type: "thinking";
|
|
860
|
+
}>, z.ZodObject<{
|
|
387
861
|
type: z.ZodLiteral<"tool_use">;
|
|
388
862
|
toolCallId: z.ZodString;
|
|
389
863
|
tool: z.ZodString;
|
|
390
864
|
args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
391
|
-
},
|
|
865
|
+
}, "strip", z.ZodTypeAny, {
|
|
866
|
+
type: "tool_use";
|
|
867
|
+
toolCallId: string;
|
|
868
|
+
tool: string;
|
|
869
|
+
args: Record<string, unknown>;
|
|
870
|
+
}, {
|
|
871
|
+
type: "tool_use";
|
|
872
|
+
toolCallId: string;
|
|
873
|
+
tool: string;
|
|
874
|
+
args: Record<string, unknown>;
|
|
875
|
+
}>, z.ZodObject<{
|
|
392
876
|
type: z.ZodLiteral<"tool_result">;
|
|
393
877
|
toolCallId: z.ZodString;
|
|
394
878
|
tool: z.ZodString;
|
|
395
|
-
status: z.ZodEnum<
|
|
396
|
-
success: "success";
|
|
397
|
-
error: "error";
|
|
398
|
-
}>;
|
|
879
|
+
status: z.ZodEnum<["success", "error"]>;
|
|
399
880
|
summary: z.ZodOptional<z.ZodString>;
|
|
400
|
-
|
|
881
|
+
output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
882
|
+
}, "strip", z.ZodTypeAny, {
|
|
883
|
+
type: "tool_result";
|
|
884
|
+
status: "success" | "error";
|
|
885
|
+
toolCallId: string;
|
|
886
|
+
tool: string;
|
|
887
|
+
summary?: string | undefined;
|
|
888
|
+
output?: Record<string, unknown> | undefined;
|
|
889
|
+
}, {
|
|
890
|
+
type: "tool_result";
|
|
891
|
+
status: "success" | "error";
|
|
892
|
+
toolCallId: string;
|
|
893
|
+
tool: string;
|
|
894
|
+
summary?: string | undefined;
|
|
895
|
+
output?: Record<string, unknown> | undefined;
|
|
896
|
+
}>]>, "many">;
|
|
401
897
|
usage: z.ZodOptional<z.ZodObject<{
|
|
402
898
|
promptTokens: z.ZodNumber;
|
|
403
899
|
completionTokens: z.ZodNumber;
|
|
404
|
-
}, z.
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
900
|
+
}, "strip", z.ZodTypeAny, {
|
|
901
|
+
promptTokens: number;
|
|
902
|
+
completionTokens: number;
|
|
903
|
+
}, {
|
|
904
|
+
promptTokens: number;
|
|
905
|
+
completionTokens: number;
|
|
906
|
+
}>>;
|
|
907
|
+
finishReason: z.ZodEnum<["stop", "length", "error", "action_required"]>;
|
|
411
908
|
traceId: z.ZodOptional<z.ZodString>;
|
|
412
909
|
timestamp: z.ZodString;
|
|
413
|
-
},
|
|
910
|
+
}, "strip", z.ZodTypeAny, {
|
|
911
|
+
content: ({
|
|
912
|
+
text: string;
|
|
913
|
+
type: "text";
|
|
914
|
+
} | {
|
|
915
|
+
text: string;
|
|
916
|
+
type: "thinking";
|
|
917
|
+
} | {
|
|
918
|
+
type: "tool_use";
|
|
919
|
+
toolCallId: string;
|
|
920
|
+
tool: string;
|
|
921
|
+
args: Record<string, unknown>;
|
|
922
|
+
} | {
|
|
923
|
+
type: "tool_result";
|
|
924
|
+
status: "success" | "error";
|
|
925
|
+
toolCallId: string;
|
|
926
|
+
tool: string;
|
|
927
|
+
summary?: string | undefined;
|
|
928
|
+
output?: Record<string, unknown> | undefined;
|
|
929
|
+
})[];
|
|
930
|
+
threadId: string;
|
|
931
|
+
event: "done";
|
|
932
|
+
requestId: string;
|
|
933
|
+
timestamp: string;
|
|
934
|
+
messageId: string;
|
|
935
|
+
finishReason: "error" | "stop" | "length" | "action_required";
|
|
936
|
+
usage?: {
|
|
937
|
+
promptTokens: number;
|
|
938
|
+
completionTokens: number;
|
|
939
|
+
} | undefined;
|
|
940
|
+
traceId?: string | undefined;
|
|
941
|
+
}, {
|
|
942
|
+
content: ({
|
|
943
|
+
text: string;
|
|
944
|
+
type: "text";
|
|
945
|
+
} | {
|
|
946
|
+
text: string;
|
|
947
|
+
type: "thinking";
|
|
948
|
+
} | {
|
|
949
|
+
type: "tool_use";
|
|
950
|
+
toolCallId: string;
|
|
951
|
+
tool: string;
|
|
952
|
+
args: Record<string, unknown>;
|
|
953
|
+
} | {
|
|
954
|
+
type: "tool_result";
|
|
955
|
+
status: "success" | "error";
|
|
956
|
+
toolCallId: string;
|
|
957
|
+
tool: string;
|
|
958
|
+
summary?: string | undefined;
|
|
959
|
+
output?: Record<string, unknown> | undefined;
|
|
960
|
+
})[];
|
|
961
|
+
threadId: string;
|
|
962
|
+
event: "done";
|
|
963
|
+
requestId: string;
|
|
964
|
+
timestamp: string;
|
|
965
|
+
messageId: string;
|
|
966
|
+
finishReason: "error" | "stop" | "length" | "action_required";
|
|
967
|
+
usage?: {
|
|
968
|
+
promptTokens: number;
|
|
969
|
+
completionTokens: number;
|
|
970
|
+
} | undefined;
|
|
971
|
+
traceId?: string | undefined;
|
|
972
|
+
}>, z.ZodObject<{
|
|
414
973
|
event: z.ZodLiteral<"error">;
|
|
415
974
|
requestId: z.ZodString;
|
|
416
975
|
message: z.ZodString;
|
|
417
|
-
code: z.ZodOptional<z.ZodEnum<
|
|
418
|
-
auth_failed: "auth_failed";
|
|
419
|
-
thread_not_found: "thread_not_found";
|
|
420
|
-
thread_access_denied: "thread_access_denied";
|
|
421
|
-
invalid_message_format: "invalid_message_format";
|
|
422
|
-
message_too_large: "message_too_large";
|
|
423
|
-
rate_limit_exceeded: "rate_limit_exceeded";
|
|
424
|
-
stream_timeout: "stream_timeout";
|
|
425
|
-
agent_error: "agent_error";
|
|
426
|
-
tool_error: "tool_error";
|
|
427
|
-
internal_error: "internal_error";
|
|
428
|
-
invalid_action_id: "invalid_action_id";
|
|
429
|
-
}>>;
|
|
976
|
+
code: z.ZodOptional<z.ZodEnum<["auth_failed", "thread_not_found", "thread_access_denied", "invalid_message_format", "message_too_large", "rate_limit_exceeded", "stream_timeout", "agent_error", "tool_error", "internal_error", "invalid_action_id"]>>;
|
|
430
977
|
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
431
978
|
timestamp: z.ZodString;
|
|
432
|
-
},
|
|
979
|
+
}, "strip", z.ZodTypeAny, {
|
|
980
|
+
message: string;
|
|
981
|
+
event: "error";
|
|
982
|
+
requestId: string;
|
|
983
|
+
timestamp: string;
|
|
984
|
+
code?: "auth_failed" | "thread_not_found" | "thread_access_denied" | "invalid_message_format" | "message_too_large" | "rate_limit_exceeded" | "stream_timeout" | "agent_error" | "tool_error" | "internal_error" | "invalid_action_id" | undefined;
|
|
985
|
+
retryable?: boolean | undefined;
|
|
986
|
+
}, {
|
|
987
|
+
message: string;
|
|
988
|
+
event: "error";
|
|
989
|
+
requestId: string;
|
|
990
|
+
timestamp: string;
|
|
991
|
+
code?: "auth_failed" | "thread_not_found" | "thread_access_denied" | "invalid_message_format" | "message_too_large" | "rate_limit_exceeded" | "stream_timeout" | "agent_error" | "tool_error" | "internal_error" | "invalid_action_id" | undefined;
|
|
992
|
+
retryable?: boolean | undefined;
|
|
993
|
+
}>, z.ZodObject<{
|
|
433
994
|
event: z.ZodLiteral<"aborted">;
|
|
434
995
|
requestId: z.ZodString;
|
|
435
996
|
messageId: z.ZodOptional<z.ZodString>;
|
|
436
997
|
timestamp: z.ZodString;
|
|
437
|
-
},
|
|
998
|
+
}, "strip", z.ZodTypeAny, {
|
|
999
|
+
event: "aborted";
|
|
1000
|
+
requestId: string;
|
|
1001
|
+
timestamp: string;
|
|
1002
|
+
messageId?: string | undefined;
|
|
1003
|
+
}, {
|
|
1004
|
+
event: "aborted";
|
|
1005
|
+
requestId: string;
|
|
1006
|
+
timestamp: string;
|
|
1007
|
+
messageId?: string | undefined;
|
|
1008
|
+
}>, z.ZodObject<{
|
|
438
1009
|
event: z.ZodLiteral<"continuation">;
|
|
439
1010
|
requestId: z.ZodString;
|
|
440
1011
|
actionId: z.ZodString;
|
|
441
1012
|
kind: z.ZodString;
|
|
442
1013
|
payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
443
1014
|
timestamp: z.ZodString;
|
|
444
|
-
}, z.
|
|
1015
|
+
}, "strip", z.ZodTypeAny, {
|
|
1016
|
+
actionId: string;
|
|
1017
|
+
kind: string;
|
|
1018
|
+
event: "continuation";
|
|
1019
|
+
requestId: string;
|
|
1020
|
+
timestamp: string;
|
|
1021
|
+
payload: Record<string, unknown>;
|
|
1022
|
+
}, {
|
|
1023
|
+
actionId: string;
|
|
1024
|
+
kind: string;
|
|
1025
|
+
event: "continuation";
|
|
1026
|
+
requestId: string;
|
|
1027
|
+
timestamp: string;
|
|
1028
|
+
payload: Record<string, unknown>;
|
|
1029
|
+
}>]>;
|
|
445
1030
|
|
|
446
1031
|
/**
|
|
447
1032
|
* Current protocol version.
|