@linnlabs/linnkit 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/LICENSE +21 -0
  3. package/README.md +178 -0
  4. package/README.zh-CN.md +182 -0
  5. package/dist/agent-invocation-BHcNfrBV.d.cts +30 -0
  6. package/dist/agent-invocation-BznDaXDs.d.ts +30 -0
  7. package/dist/agentEvents-DEB7Fy_J.d.cts +81 -0
  8. package/dist/agentEvents-DEB7Fy_J.d.ts +81 -0
  9. package/dist/agentSpec-EkmviZjy.d.cts +2621 -0
  10. package/dist/agentSpec-EkmviZjy.d.ts +2621 -0
  11. package/dist/ai-engine.types-BpeU_XQG.d.cts +158 -0
  12. package/dist/ai-engine.types-vZRnQcJa.d.ts +158 -0
  13. package/dist/audit-BaRUGaqv.d.cts +307 -0
  14. package/dist/audit-BaRUGaqv.d.ts +307 -0
  15. package/dist/audit-CtcfART1.d.ts +33 -0
  16. package/dist/audit-LeOrm2hX.d.cts +33 -0
  17. package/dist/checkpointMarker-DAI3wUQu.d.cts +8 -0
  18. package/dist/checkpointMarker-DAI3wUQu.d.ts +8 -0
  19. package/dist/cli.cjs +8028 -0
  20. package/dist/cli.cjs.map +1 -0
  21. package/dist/cli.d.cts +4 -0
  22. package/dist/cli.d.ts +4 -0
  23. package/dist/cli.js +8025 -0
  24. package/dist/cli.js.map +1 -0
  25. package/dist/context-manager.cjs +8704 -0
  26. package/dist/context-manager.cjs.map +1 -0
  27. package/dist/context-manager.d.cts +2190 -0
  28. package/dist/context-manager.d.ts +2190 -0
  29. package/dist/context-manager.js +8650 -0
  30. package/dist/context-manager.js.map +1 -0
  31. package/dist/context-trace-DRi5M4lX.d.ts +239 -0
  32. package/dist/context-trace-HE2qY5Q-.d.cts +239 -0
  33. package/dist/contracts.cjs +1333 -0
  34. package/dist/contracts.cjs.map +1 -0
  35. package/dist/contracts.d.cts +8 -0
  36. package/dist/contracts.d.ts +8 -0
  37. package/dist/contracts.js +1214 -0
  38. package/dist/contracts.js.map +1 -0
  39. package/dist/defaultGraphExecutor-BBswR8wn.d.ts +624 -0
  40. package/dist/defaultGraphExecutor-BIjJj7WF.d.cts +624 -0
  41. package/dist/execution-CAIypb41.d.cts +129 -0
  42. package/dist/execution-CAIypb41.d.ts +129 -0
  43. package/dist/index-CHqwkvGp.d.ts +149 -0
  44. package/dist/index-CJeWHopy.d.ts +584 -0
  45. package/dist/index-Cm-JbzTH.d.cts +1450 -0
  46. package/dist/index-Cvr23YCl.d.cts +23 -0
  47. package/dist/index-DDzuSb0n.d.ts +23 -0
  48. package/dist/index-DO4dQgf2.d.cts +584 -0
  49. package/dist/index-DRBWi1fy.d.ts +1450 -0
  50. package/dist/index-Dl5PLgAv.d.cts +149 -0
  51. package/dist/index.cjs +9577 -0
  52. package/dist/index.cjs.map +1 -0
  53. package/dist/index.d.cts +89 -0
  54. package/dist/index.d.ts +89 -0
  55. package/dist/index.js +9563 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/messages-XthmnHZ3.d.cts +8007 -0
  58. package/dist/messages-XthmnHZ3.d.ts +8007 -0
  59. package/dist/ports-DaatKJXp.d.cts +90 -0
  60. package/dist/ports-DnLuKfpE.d.ts +90 -0
  61. package/dist/ports.cjs +4 -0
  62. package/dist/ports.cjs.map +1 -0
  63. package/dist/ports.d.cts +7 -0
  64. package/dist/ports.d.ts +7 -0
  65. package/dist/ports.js +3 -0
  66. package/dist/ports.js.map +1 -0
  67. package/dist/quickstart.cjs +7697 -0
  68. package/dist/quickstart.cjs.map +1 -0
  69. package/dist/quickstart.d.cts +24 -0
  70. package/dist/quickstart.d.ts +24 -0
  71. package/dist/quickstart.js +7691 -0
  72. package/dist/quickstart.js.map +1 -0
  73. package/dist/runAgent-CPj_9e58.d.ts +88 -0
  74. package/dist/runAgent-HYKlXbVr.d.cts +88 -0
  75. package/dist/runHandle-CyXvzgzk.d.ts +239 -0
  76. package/dist/runHandle-D3gPsD7B.d.cts +239 -0
  77. package/dist/runtime-kernel/events.cjs +1485 -0
  78. package/dist/runtime-kernel/events.cjs.map +1 -0
  79. package/dist/runtime-kernel/events.d.cts +8 -0
  80. package/dist/runtime-kernel/events.d.ts +8 -0
  81. package/dist/runtime-kernel/events.js +1475 -0
  82. package/dist/runtime-kernel/events.js.map +1 -0
  83. package/dist/runtime-kernel.cjs +8656 -0
  84. package/dist/runtime-kernel.cjs.map +1 -0
  85. package/dist/runtime-kernel.d.cts +19 -0
  86. package/dist/runtime-kernel.d.ts +19 -0
  87. package/dist/runtime-kernel.js +8568 -0
  88. package/dist/runtime-kernel.js.map +1 -0
  89. package/dist/sse-vPyrOPa0.d.cts +1687 -0
  90. package/dist/sse-vPyrOPa0.d.ts +1687 -0
  91. package/dist/testkit.cjs +10613 -0
  92. package/dist/testkit.cjs.map +1 -0
  93. package/dist/testkit.d.cts +284 -0
  94. package/dist/testkit.d.ts +284 -0
  95. package/dist/testkit.js +10593 -0
  96. package/dist/testkit.js.map +1 -0
  97. package/dist/todo-B1PmDlp3.d.cts +2253 -0
  98. package/dist/todo-B1PmDlp3.d.ts +2253 -0
  99. package/dist/tokenizer-DFL4I7-I.d.ts +28 -0
  100. package/dist/tokenizer-DH_JXv-H.d.cts +28 -0
  101. package/dist/toolContracts-Blll0241.d.ts +463 -0
  102. package/dist/toolContracts-CLkQmhTG.d.cts +463 -0
  103. package/docs/README.md +76 -0
  104. package/docs/integration/01-installation.md +94 -0
  105. package/docs/integration/02-quickstart.md +104 -0
  106. package/docs/integration/README.md +223 -0
  107. package/docs/integration/agent-registration-guide.md +330 -0
  108. package/docs/integration/audit.md +64 -0
  109. package/docs/integration/child-runs.md +87 -0
  110. package/docs/integration/constraints-and-pitfalls.md +87 -0
  111. package/docs/integration/context-engineering.md +650 -0
  112. package/docs/integration/context-fences.md +289 -0
  113. package/docs/integration/glossary.md +69 -0
  114. package/docs/integration/llm-provider.md +76 -0
  115. package/docs/integration/persistence.md +44 -0
  116. package/docs/integration/realtime.md +76 -0
  117. package/docs/integration/run-supervisor.md +69 -0
  118. package/docs/integration/telemetry.md +48 -0
  119. package/docs/integration/testing.md +95 -0
  120. package/docs/integration/tool-development-guide.md +362 -0
  121. package/docs/integration/tool-history.md +202 -0
  122. package/docs/integration/tools.md +188 -0
  123. package/package.json +115 -0
@@ -0,0 +1,2253 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const BaseEvent: z.ZodObject<{
4
+ id: z.ZodString;
5
+ conversation_id: z.ZodString;
6
+ timestamp: z.ZodNumber;
7
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
8
+ version: z.ZodDefault<z.ZodLiteral<1>>;
9
+ turn_id: z.ZodString;
10
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ id: string;
13
+ timestamp: number;
14
+ version: 1;
15
+ conversation_id: string;
16
+ turn_id: string;
17
+ metadata?: Record<string, unknown> | undefined;
18
+ ephemeral?: boolean | undefined;
19
+ }, {
20
+ id: string;
21
+ timestamp: number;
22
+ conversation_id: string;
23
+ turn_id: string;
24
+ metadata?: Record<string, unknown> | undefined;
25
+ version?: 1 | undefined;
26
+ ephemeral?: boolean | undefined;
27
+ }>;
28
+ declare const ToolCallPhase: z.ZodEnum<["start", "update", "complete", "error"]>;
29
+ declare const Status: z.ZodEnum<["loading", "success", "error"]>;
30
+ declare const AgentTodoStatus: z.ZodEnum<["pending", "in_progress", "completed", "cancelled"]>;
31
+ declare const AgentTodoItem$1: z.ZodObject<{
32
+ id: z.ZodString;
33
+ content: z.ZodString;
34
+ status: z.ZodEnum<["pending", "in_progress", "completed", "cancelled"]>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ status: "in_progress" | "completed" | "cancelled" | "pending";
37
+ id: string;
38
+ content: string;
39
+ }, {
40
+ status: "in_progress" | "completed" | "cancelled" | "pending";
41
+ id: string;
42
+ content: string;
43
+ }>;
44
+ declare const ProviderReasoningDetailsPayload: z.ZodArray<z.ZodUnknown, "many">;
45
+ type ProviderReasoningDetailsPayload = z.infer<typeof ProviderReasoningDetailsPayload>;
46
+ declare const ToolCallDecisionPayload: z.ZodObject<{
47
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
48
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
49
+ /**
50
+ * 不透明 provider reasoning replay blocks。
51
+ *
52
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
53
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
54
+ */
55
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
56
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
57
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
58
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
59
+ /**
60
+ * 不透明 provider reasoning replay blocks。
61
+ *
62
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
63
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
64
+ */
65
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
66
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
67
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
68
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
69
+ /**
70
+ * 不透明 provider reasoning replay blocks。
71
+ *
72
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
73
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
74
+ */
75
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
76
+ }, z.ZodTypeAny, "passthrough">>;
77
+ type ToolCallDecisionPayload = z.infer<typeof ToolCallDecisionPayload>;
78
+ declare const RuntimeEvent: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
79
+ id: z.ZodString;
80
+ conversation_id: z.ZodString;
81
+ timestamp: z.ZodNumber;
82
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
83
+ version: z.ZodDefault<z.ZodLiteral<1>>;
84
+ turn_id: z.ZodString;
85
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
86
+ } & {
87
+ type: z.ZodLiteral<"user_input">;
88
+ content: z.ZodString;
89
+ raw_content: z.ZodOptional<z.ZodString>;
90
+ source: z.ZodDefault<z.ZodEnum<["user", "editor", "system"]>>;
91
+ }, "strip", z.ZodTypeAny, {
92
+ type: "user_input";
93
+ id: string;
94
+ content: string;
95
+ timestamp: number;
96
+ version: 1;
97
+ conversation_id: string;
98
+ turn_id: string;
99
+ source: "system" | "user" | "editor";
100
+ metadata?: Record<string, unknown> | undefined;
101
+ ephemeral?: boolean | undefined;
102
+ raw_content?: string | undefined;
103
+ }, {
104
+ type: "user_input";
105
+ id: string;
106
+ content: string;
107
+ timestamp: number;
108
+ conversation_id: string;
109
+ turn_id: string;
110
+ metadata?: Record<string, unknown> | undefined;
111
+ version?: 1 | undefined;
112
+ ephemeral?: boolean | undefined;
113
+ raw_content?: string | undefined;
114
+ source?: "system" | "user" | "editor" | undefined;
115
+ }>, z.ZodObject<{
116
+ id: z.ZodString;
117
+ conversation_id: z.ZodString;
118
+ timestamp: z.ZodNumber;
119
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
120
+ version: z.ZodDefault<z.ZodLiteral<1>>;
121
+ turn_id: z.ZodString;
122
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
123
+ } & {
124
+ type: z.ZodLiteral<"thought">;
125
+ content: z.ZodString;
126
+ thought_message_id: z.ZodOptional<z.ZodString>;
127
+ delta: z.ZodOptional<z.ZodString>;
128
+ is_complete: z.ZodDefault<z.ZodBoolean>;
129
+ }, "strip", z.ZodTypeAny, {
130
+ type: "thought";
131
+ id: string;
132
+ content: string;
133
+ timestamp: number;
134
+ version: 1;
135
+ conversation_id: string;
136
+ turn_id: string;
137
+ is_complete: boolean;
138
+ metadata?: Record<string, unknown> | undefined;
139
+ ephemeral?: boolean | undefined;
140
+ thought_message_id?: string | undefined;
141
+ delta?: string | undefined;
142
+ }, {
143
+ type: "thought";
144
+ id: string;
145
+ content: string;
146
+ timestamp: number;
147
+ conversation_id: string;
148
+ turn_id: string;
149
+ metadata?: Record<string, unknown> | undefined;
150
+ version?: 1 | undefined;
151
+ ephemeral?: boolean | undefined;
152
+ thought_message_id?: string | undefined;
153
+ delta?: string | undefined;
154
+ is_complete?: boolean | undefined;
155
+ }>, z.ZodObject<{
156
+ id: z.ZodString;
157
+ conversation_id: z.ZodString;
158
+ timestamp: z.ZodNumber;
159
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
160
+ version: z.ZodDefault<z.ZodLiteral<1>>;
161
+ turn_id: z.ZodString;
162
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
163
+ } & {
164
+ type: z.ZodLiteral<"tool_call_decision">;
165
+ tool_name: z.ZodString;
166
+ tool_call_id: z.ZodString;
167
+ phase: z.ZodEnum<["start", "update", "complete", "error"]>;
168
+ status: z.ZodEnum<["loading", "success", "error"]>;
169
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
170
+ payload: z.ZodOptional<z.ZodObject<{
171
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
172
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
173
+ /**
174
+ * 不透明 provider reasoning replay blocks。
175
+ *
176
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
177
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
178
+ */
179
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
180
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
181
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
182
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
183
+ /**
184
+ * 不透明 provider reasoning replay blocks。
185
+ *
186
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
187
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
188
+ */
189
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
190
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
191
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
192
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
193
+ /**
194
+ * 不透明 provider reasoning replay blocks。
195
+ *
196
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
197
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
198
+ */
199
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
200
+ }, z.ZodTypeAny, "passthrough">>>;
201
+ parent_tool_call_id: z.ZodOptional<z.ZodString>;
202
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
203
+ }, "strip", z.ZodTypeAny, {
204
+ type: "tool_call_decision";
205
+ status: "error" | "loading" | "success";
206
+ id: string;
207
+ tool_name: string;
208
+ tool_call_id: string;
209
+ timestamp: number;
210
+ version: 1;
211
+ conversation_id: string;
212
+ turn_id: string;
213
+ phase: "start" | "update" | "complete" | "error";
214
+ args?: Record<string, any> | undefined;
215
+ metadata?: Record<string, unknown> | undefined;
216
+ ephemeral?: boolean | undefined;
217
+ payload?: z.objectOutputType<{
218
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
219
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
220
+ /**
221
+ * 不透明 provider reasoning replay blocks。
222
+ *
223
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
224
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
225
+ */
226
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
227
+ }, z.ZodTypeAny, "passthrough"> | undefined;
228
+ parent_tool_call_id?: string | undefined;
229
+ meta?: Record<string, any> | undefined;
230
+ }, {
231
+ type: "tool_call_decision";
232
+ status: "error" | "loading" | "success";
233
+ id: string;
234
+ tool_name: string;
235
+ tool_call_id: string;
236
+ timestamp: number;
237
+ conversation_id: string;
238
+ turn_id: string;
239
+ phase: "start" | "update" | "complete" | "error";
240
+ args?: Record<string, any> | undefined;
241
+ metadata?: Record<string, unknown> | undefined;
242
+ version?: 1 | undefined;
243
+ ephemeral?: boolean | undefined;
244
+ payload?: z.objectInputType<{
245
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
246
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
247
+ /**
248
+ * 不透明 provider reasoning replay blocks。
249
+ *
250
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
251
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
252
+ */
253
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
254
+ }, z.ZodTypeAny, "passthrough"> | undefined;
255
+ parent_tool_call_id?: string | undefined;
256
+ meta?: Record<string, any> | undefined;
257
+ }>, z.ZodObject<{
258
+ id: z.ZodString;
259
+ conversation_id: z.ZodString;
260
+ timestamp: z.ZodNumber;
261
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
262
+ version: z.ZodDefault<z.ZodLiteral<1>>;
263
+ turn_id: z.ZodString;
264
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
265
+ } & {
266
+ type: z.ZodLiteral<"tool_process">;
267
+ tool_name: z.ZodString;
268
+ tool_call_id: z.ZodString;
269
+ phase: z.ZodEnum<["start", "update", "complete", "error"]>;
270
+ status: z.ZodEnum<["loading", "success", "error"]>;
271
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
272
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
273
+ parent_tool_call_id: z.ZodOptional<z.ZodString>;
274
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
275
+ }, "strip", z.ZodTypeAny, {
276
+ type: "tool_process";
277
+ status: "error" | "loading" | "success";
278
+ id: string;
279
+ tool_name: string;
280
+ tool_call_id: string;
281
+ timestamp: number;
282
+ version: 1;
283
+ conversation_id: string;
284
+ turn_id: string;
285
+ phase: "start" | "update" | "complete" | "error";
286
+ args?: Record<string, any> | undefined;
287
+ metadata?: Record<string, unknown> | undefined;
288
+ ephemeral?: boolean | undefined;
289
+ payload?: Record<string, any> | undefined;
290
+ parent_tool_call_id?: string | undefined;
291
+ meta?: Record<string, any> | undefined;
292
+ }, {
293
+ type: "tool_process";
294
+ status: "error" | "loading" | "success";
295
+ id: string;
296
+ tool_name: string;
297
+ tool_call_id: string;
298
+ timestamp: number;
299
+ conversation_id: string;
300
+ turn_id: string;
301
+ phase: "start" | "update" | "complete" | "error";
302
+ args?: Record<string, any> | undefined;
303
+ metadata?: Record<string, unknown> | undefined;
304
+ version?: 1 | undefined;
305
+ ephemeral?: boolean | undefined;
306
+ payload?: Record<string, any> | undefined;
307
+ parent_tool_call_id?: string | undefined;
308
+ meta?: Record<string, any> | undefined;
309
+ }>, z.ZodObject<{
310
+ id: z.ZodString;
311
+ conversation_id: z.ZodString;
312
+ timestamp: z.ZodNumber;
313
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
314
+ version: z.ZodDefault<z.ZodLiteral<1>>;
315
+ turn_id: z.ZodString;
316
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
317
+ } & {
318
+ type: z.ZodLiteral<"tool_output">;
319
+ tool_name: z.ZodString;
320
+ tool_call_id: z.ZodString;
321
+ status: z.ZodEnum<["success", "error"]>;
322
+ output: z.ZodOptional<z.ZodAny>;
323
+ payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
324
+ error: z.ZodOptional<z.ZodString>;
325
+ duration_ms: z.ZodOptional<z.ZodNumber>;
326
+ }, "strip", z.ZodTypeAny, {
327
+ type: "tool_output";
328
+ status: "error" | "success";
329
+ id: string;
330
+ tool_name: string;
331
+ tool_call_id: string;
332
+ timestamp: number;
333
+ version: 1;
334
+ conversation_id: string;
335
+ turn_id: string;
336
+ metadata?: Record<string, unknown> | undefined;
337
+ ephemeral?: boolean | undefined;
338
+ error?: string | undefined;
339
+ payload?: Record<string, any> | undefined;
340
+ output?: any;
341
+ duration_ms?: number | undefined;
342
+ }, {
343
+ type: "tool_output";
344
+ status: "error" | "success";
345
+ id: string;
346
+ tool_name: string;
347
+ tool_call_id: string;
348
+ timestamp: number;
349
+ conversation_id: string;
350
+ turn_id: string;
351
+ metadata?: Record<string, unknown> | undefined;
352
+ version?: 1 | undefined;
353
+ ephemeral?: boolean | undefined;
354
+ error?: string | undefined;
355
+ payload?: Record<string, any> | undefined;
356
+ output?: any;
357
+ duration_ms?: number | undefined;
358
+ }>, z.ZodObject<{
359
+ id: z.ZodString;
360
+ conversation_id: z.ZodString;
361
+ timestamp: z.ZodNumber;
362
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
363
+ version: z.ZodDefault<z.ZodLiteral<1>>;
364
+ turn_id: z.ZodString;
365
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
366
+ } & {
367
+ type: z.ZodLiteral<"todo_updated">;
368
+ todo_list_id: z.ZodString;
369
+ todo_list_version: z.ZodNumber;
370
+ items: z.ZodArray<z.ZodObject<{
371
+ id: z.ZodString;
372
+ content: z.ZodString;
373
+ status: z.ZodEnum<["pending", "in_progress", "completed", "cancelled"]>;
374
+ }, "strip", z.ZodTypeAny, {
375
+ status: "in_progress" | "completed" | "cancelled" | "pending";
376
+ id: string;
377
+ content: string;
378
+ }, {
379
+ status: "in_progress" | "completed" | "cancelled" | "pending";
380
+ id: string;
381
+ content: string;
382
+ }>, "many">;
383
+ }, "strip", z.ZodTypeAny, {
384
+ type: "todo_updated";
385
+ id: string;
386
+ timestamp: number;
387
+ version: 1;
388
+ conversation_id: string;
389
+ turn_id: string;
390
+ todo_list_id: string;
391
+ todo_list_version: number;
392
+ items: {
393
+ status: "in_progress" | "completed" | "cancelled" | "pending";
394
+ id: string;
395
+ content: string;
396
+ }[];
397
+ metadata?: Record<string, unknown> | undefined;
398
+ ephemeral?: boolean | undefined;
399
+ }, {
400
+ type: "todo_updated";
401
+ id: string;
402
+ timestamp: number;
403
+ conversation_id: string;
404
+ turn_id: string;
405
+ todo_list_id: string;
406
+ todo_list_version: number;
407
+ items: {
408
+ status: "in_progress" | "completed" | "cancelled" | "pending";
409
+ id: string;
410
+ content: string;
411
+ }[];
412
+ metadata?: Record<string, unknown> | undefined;
413
+ version?: 1 | undefined;
414
+ ephemeral?: boolean | undefined;
415
+ }>, z.ZodObject<{
416
+ id: z.ZodString;
417
+ conversation_id: z.ZodString;
418
+ timestamp: z.ZodNumber;
419
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
420
+ version: z.ZodDefault<z.ZodLiteral<1>>;
421
+ turn_id: z.ZodString;
422
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
423
+ } & {
424
+ type: z.ZodLiteral<"subrun_trace">;
425
+ parent_tool_call_id: z.ZodString;
426
+ subrun_id: z.ZodString;
427
+ subrun_parent_id: z.ZodOptional<z.ZodString>;
428
+ kind: z.ZodEnum<["thought_delta", "thought_complete", "tool_call_decision", "tool_process", "tool_output", "final_answer_chunk", "final_answer"]>;
429
+ delta: z.ZodOptional<z.ZodString>;
430
+ content: z.ZodOptional<z.ZodString>;
431
+ tool_name: z.ZodOptional<z.ZodString>;
432
+ tool_call_id: z.ZodOptional<z.ZodString>;
433
+ phase: z.ZodOptional<z.ZodEnum<["start", "update", "complete", "error"]>>;
434
+ status: z.ZodOptional<z.ZodEnum<["loading", "success", "error"]>>;
435
+ args: z.ZodOptional<z.ZodUnknown>;
436
+ output: z.ZodOptional<z.ZodUnknown>;
437
+ duration_ms: z.ZodOptional<z.ZodNumber>;
438
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
439
+ }, "strip", z.ZodTypeAny, {
440
+ type: "subrun_trace";
441
+ id: string;
442
+ timestamp: number;
443
+ kind: "final_answer" | "tool_output" | "tool_call_decision" | "tool_process" | "thought_delta" | "thought_complete" | "final_answer_chunk";
444
+ version: 1;
445
+ conversation_id: string;
446
+ turn_id: string;
447
+ parent_tool_call_id: string;
448
+ subrun_id: string;
449
+ status?: "error" | "loading" | "success" | undefined;
450
+ tool_name?: string | undefined;
451
+ args?: unknown;
452
+ tool_call_id?: string | undefined;
453
+ content?: string | undefined;
454
+ metadata?: Record<string, unknown> | undefined;
455
+ ephemeral?: boolean | undefined;
456
+ delta?: string | undefined;
457
+ phase?: "start" | "update" | "complete" | "error" | undefined;
458
+ meta?: Record<string, unknown> | undefined;
459
+ output?: unknown;
460
+ duration_ms?: number | undefined;
461
+ subrun_parent_id?: string | undefined;
462
+ }, {
463
+ type: "subrun_trace";
464
+ id: string;
465
+ timestamp: number;
466
+ kind: "final_answer" | "tool_output" | "tool_call_decision" | "tool_process" | "thought_delta" | "thought_complete" | "final_answer_chunk";
467
+ conversation_id: string;
468
+ turn_id: string;
469
+ parent_tool_call_id: string;
470
+ subrun_id: string;
471
+ status?: "error" | "loading" | "success" | undefined;
472
+ tool_name?: string | undefined;
473
+ args?: unknown;
474
+ tool_call_id?: string | undefined;
475
+ content?: string | undefined;
476
+ metadata?: Record<string, unknown> | undefined;
477
+ version?: 1 | undefined;
478
+ ephemeral?: boolean | undefined;
479
+ delta?: string | undefined;
480
+ phase?: "start" | "update" | "complete" | "error" | undefined;
481
+ meta?: Record<string, unknown> | undefined;
482
+ output?: unknown;
483
+ duration_ms?: number | undefined;
484
+ subrun_parent_id?: string | undefined;
485
+ }>, z.ZodObject<{
486
+ id: z.ZodString;
487
+ conversation_id: z.ZodString;
488
+ timestamp: z.ZodNumber;
489
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
490
+ version: z.ZodDefault<z.ZodLiteral<1>>;
491
+ turn_id: z.ZodString;
492
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
493
+ } & {
494
+ type: z.ZodLiteral<"requires_user_interaction">;
495
+ form: z.ZodOptional<z.ZodAny>;
496
+ interaction_type: z.ZodOptional<z.ZodString>;
497
+ prompt: z.ZodOptional<z.ZodString>;
498
+ }, "strip", z.ZodTypeAny, {
499
+ type: "requires_user_interaction";
500
+ id: string;
501
+ timestamp: number;
502
+ version: 1;
503
+ conversation_id: string;
504
+ turn_id: string;
505
+ metadata?: Record<string, unknown> | undefined;
506
+ ephemeral?: boolean | undefined;
507
+ form?: any;
508
+ interaction_type?: string | undefined;
509
+ prompt?: string | undefined;
510
+ }, {
511
+ type: "requires_user_interaction";
512
+ id: string;
513
+ timestamp: number;
514
+ conversation_id: string;
515
+ turn_id: string;
516
+ metadata?: Record<string, unknown> | undefined;
517
+ version?: 1 | undefined;
518
+ ephemeral?: boolean | undefined;
519
+ form?: any;
520
+ interaction_type?: string | undefined;
521
+ prompt?: string | undefined;
522
+ }>, z.ZodObject<{
523
+ id: z.ZodString;
524
+ conversation_id: z.ZodString;
525
+ timestamp: z.ZodNumber;
526
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
527
+ version: z.ZodDefault<z.ZodLiteral<1>>;
528
+ turn_id: z.ZodString;
529
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
530
+ } & {
531
+ type: z.ZodLiteral<"audit_envelope">;
532
+ envelope: z.ZodObject<{
533
+ envelopeId: z.ZodString;
534
+ runId: z.ZodString;
535
+ parentRunId: z.ZodOptional<z.ZodString>;
536
+ ts: z.ZodNumber;
537
+ actor: z.ZodObject<{
538
+ kind: z.ZodEnum<["system", "host", "agent", "model", "tool", "user"]>;
539
+ id: z.ZodOptional<z.ZodString>;
540
+ name: z.ZodOptional<z.ZodString>;
541
+ }, "strip", z.ZodTypeAny, {
542
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
543
+ id?: string | undefined;
544
+ name?: string | undefined;
545
+ }, {
546
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
547
+ id?: string | undefined;
548
+ name?: string | undefined;
549
+ }>;
550
+ action: z.ZodString;
551
+ decision: z.ZodOptional<z.ZodObject<{
552
+ outcome: z.ZodEnum<["allowed", "denied", "fallback", "retry", "cancelled", "paused", "resumed", "requested", "recorded"]>;
553
+ reason: z.ZodOptional<z.ZodString>;
554
+ policy: z.ZodOptional<z.ZodString>;
555
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
556
+ }, "strip", z.ZodTypeAny, {
557
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
558
+ metadata?: Record<string, unknown> | undefined;
559
+ reason?: string | undefined;
560
+ policy?: string | undefined;
561
+ }, {
562
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
563
+ metadata?: Record<string, unknown> | undefined;
564
+ reason?: string | undefined;
565
+ policy?: string | undefined;
566
+ }>>;
567
+ evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
568
+ kind: z.ZodString;
569
+ ref: z.ZodOptional<z.ZodString>;
570
+ summary: z.ZodOptional<z.ZodString>;
571
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
572
+ }, "strip", z.ZodTypeAny, {
573
+ kind: string;
574
+ summary?: string | undefined;
575
+ metadata?: Record<string, unknown> | undefined;
576
+ ref?: string | undefined;
577
+ }, {
578
+ kind: string;
579
+ summary?: string | undefined;
580
+ metadata?: Record<string, unknown> | undefined;
581
+ ref?: string | undefined;
582
+ }>, "many">>;
583
+ costDelta: z.ZodOptional<z.ZodObject<{
584
+ tokensInput: z.ZodOptional<z.ZodNumber>;
585
+ tokensOutput: z.ZodOptional<z.ZodNumber>;
586
+ totalCostUsd: z.ZodOptional<z.ZodNumber>;
587
+ latencyMs: z.ZodOptional<z.ZodNumber>;
588
+ }, "strip", z.ZodTypeAny, {
589
+ tokensInput?: number | undefined;
590
+ tokensOutput?: number | undefined;
591
+ totalCostUsd?: number | undefined;
592
+ latencyMs?: number | undefined;
593
+ }, {
594
+ tokensInput?: number | undefined;
595
+ tokensOutput?: number | undefined;
596
+ totalCostUsd?: number | undefined;
597
+ latencyMs?: number | undefined;
598
+ }>>;
599
+ scope: z.ZodOptional<z.ZodObject<{
600
+ conversationId: z.ZodOptional<z.ZodString>;
601
+ runId: z.ZodOptional<z.ZodString>;
602
+ parentRunId: z.ZodOptional<z.ZodString>;
603
+ turnId: z.ZodOptional<z.ZodString>;
604
+ traceId: z.ZodOptional<z.ZodString>;
605
+ agentSpecId: z.ZodOptional<z.ZodString>;
606
+ toolCallId: z.ZodOptional<z.ZodString>;
607
+ toolName: z.ZodOptional<z.ZodString>;
608
+ modelId: z.ZodOptional<z.ZodString>;
609
+ nodeId: z.ZodOptional<z.ZodString>;
610
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
611
+ }, "strip", z.ZodTypeAny, {
612
+ metadata?: Record<string, unknown> | undefined;
613
+ toolName?: string | undefined;
614
+ conversationId?: string | undefined;
615
+ runId?: string | undefined;
616
+ parentRunId?: string | undefined;
617
+ turnId?: string | undefined;
618
+ traceId?: string | undefined;
619
+ agentSpecId?: string | undefined;
620
+ toolCallId?: string | undefined;
621
+ modelId?: string | undefined;
622
+ nodeId?: string | undefined;
623
+ }, {
624
+ metadata?: Record<string, unknown> | undefined;
625
+ toolName?: string | undefined;
626
+ conversationId?: string | undefined;
627
+ runId?: string | undefined;
628
+ parentRunId?: string | undefined;
629
+ turnId?: string | undefined;
630
+ traceId?: string | undefined;
631
+ agentSpecId?: string | undefined;
632
+ toolCallId?: string | undefined;
633
+ modelId?: string | undefined;
634
+ nodeId?: string | undefined;
635
+ }>>;
636
+ }, "strip", z.ZodTypeAny, {
637
+ runId: string;
638
+ envelopeId: string;
639
+ ts: number;
640
+ actor: {
641
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
642
+ id?: string | undefined;
643
+ name?: string | undefined;
644
+ };
645
+ action: string;
646
+ parentRunId?: string | undefined;
647
+ decision?: {
648
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
649
+ metadata?: Record<string, unknown> | undefined;
650
+ reason?: string | undefined;
651
+ policy?: string | undefined;
652
+ } | undefined;
653
+ evidence?: {
654
+ kind: string;
655
+ summary?: string | undefined;
656
+ metadata?: Record<string, unknown> | undefined;
657
+ ref?: string | undefined;
658
+ }[] | undefined;
659
+ costDelta?: {
660
+ tokensInput?: number | undefined;
661
+ tokensOutput?: number | undefined;
662
+ totalCostUsd?: number | undefined;
663
+ latencyMs?: number | undefined;
664
+ } | undefined;
665
+ scope?: {
666
+ metadata?: Record<string, unknown> | undefined;
667
+ toolName?: string | undefined;
668
+ conversationId?: string | undefined;
669
+ runId?: string | undefined;
670
+ parentRunId?: string | undefined;
671
+ turnId?: string | undefined;
672
+ traceId?: string | undefined;
673
+ agentSpecId?: string | undefined;
674
+ toolCallId?: string | undefined;
675
+ modelId?: string | undefined;
676
+ nodeId?: string | undefined;
677
+ } | undefined;
678
+ }, {
679
+ runId: string;
680
+ envelopeId: string;
681
+ ts: number;
682
+ actor: {
683
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
684
+ id?: string | undefined;
685
+ name?: string | undefined;
686
+ };
687
+ action: string;
688
+ parentRunId?: string | undefined;
689
+ decision?: {
690
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
691
+ metadata?: Record<string, unknown> | undefined;
692
+ reason?: string | undefined;
693
+ policy?: string | undefined;
694
+ } | undefined;
695
+ evidence?: {
696
+ kind: string;
697
+ summary?: string | undefined;
698
+ metadata?: Record<string, unknown> | undefined;
699
+ ref?: string | undefined;
700
+ }[] | undefined;
701
+ costDelta?: {
702
+ tokensInput?: number | undefined;
703
+ tokensOutput?: number | undefined;
704
+ totalCostUsd?: number | undefined;
705
+ latencyMs?: number | undefined;
706
+ } | undefined;
707
+ scope?: {
708
+ metadata?: Record<string, unknown> | undefined;
709
+ toolName?: string | undefined;
710
+ conversationId?: string | undefined;
711
+ runId?: string | undefined;
712
+ parentRunId?: string | undefined;
713
+ turnId?: string | undefined;
714
+ traceId?: string | undefined;
715
+ agentSpecId?: string | undefined;
716
+ toolCallId?: string | undefined;
717
+ modelId?: string | undefined;
718
+ nodeId?: string | undefined;
719
+ } | undefined;
720
+ }>;
721
+ }, "strip", z.ZodTypeAny, {
722
+ type: "audit_envelope";
723
+ id: string;
724
+ timestamp: number;
725
+ version: 1;
726
+ conversation_id: string;
727
+ turn_id: string;
728
+ envelope: {
729
+ runId: string;
730
+ envelopeId: string;
731
+ ts: number;
732
+ actor: {
733
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
734
+ id?: string | undefined;
735
+ name?: string | undefined;
736
+ };
737
+ action: string;
738
+ parentRunId?: string | undefined;
739
+ decision?: {
740
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
741
+ metadata?: Record<string, unknown> | undefined;
742
+ reason?: string | undefined;
743
+ policy?: string | undefined;
744
+ } | undefined;
745
+ evidence?: {
746
+ kind: string;
747
+ summary?: string | undefined;
748
+ metadata?: Record<string, unknown> | undefined;
749
+ ref?: string | undefined;
750
+ }[] | undefined;
751
+ costDelta?: {
752
+ tokensInput?: number | undefined;
753
+ tokensOutput?: number | undefined;
754
+ totalCostUsd?: number | undefined;
755
+ latencyMs?: number | undefined;
756
+ } | undefined;
757
+ scope?: {
758
+ metadata?: Record<string, unknown> | undefined;
759
+ toolName?: string | undefined;
760
+ conversationId?: string | undefined;
761
+ runId?: string | undefined;
762
+ parentRunId?: string | undefined;
763
+ turnId?: string | undefined;
764
+ traceId?: string | undefined;
765
+ agentSpecId?: string | undefined;
766
+ toolCallId?: string | undefined;
767
+ modelId?: string | undefined;
768
+ nodeId?: string | undefined;
769
+ } | undefined;
770
+ };
771
+ metadata?: Record<string, unknown> | undefined;
772
+ ephemeral?: boolean | undefined;
773
+ }, {
774
+ type: "audit_envelope";
775
+ id: string;
776
+ timestamp: number;
777
+ conversation_id: string;
778
+ turn_id: string;
779
+ envelope: {
780
+ runId: string;
781
+ envelopeId: string;
782
+ ts: number;
783
+ actor: {
784
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
785
+ id?: string | undefined;
786
+ name?: string | undefined;
787
+ };
788
+ action: string;
789
+ parentRunId?: string | undefined;
790
+ decision?: {
791
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
792
+ metadata?: Record<string, unknown> | undefined;
793
+ reason?: string | undefined;
794
+ policy?: string | undefined;
795
+ } | undefined;
796
+ evidence?: {
797
+ kind: string;
798
+ summary?: string | undefined;
799
+ metadata?: Record<string, unknown> | undefined;
800
+ ref?: string | undefined;
801
+ }[] | undefined;
802
+ costDelta?: {
803
+ tokensInput?: number | undefined;
804
+ tokensOutput?: number | undefined;
805
+ totalCostUsd?: number | undefined;
806
+ latencyMs?: number | undefined;
807
+ } | undefined;
808
+ scope?: {
809
+ metadata?: Record<string, unknown> | undefined;
810
+ toolName?: string | undefined;
811
+ conversationId?: string | undefined;
812
+ runId?: string | undefined;
813
+ parentRunId?: string | undefined;
814
+ turnId?: string | undefined;
815
+ traceId?: string | undefined;
816
+ agentSpecId?: string | undefined;
817
+ toolCallId?: string | undefined;
818
+ modelId?: string | undefined;
819
+ nodeId?: string | undefined;
820
+ } | undefined;
821
+ };
822
+ metadata?: Record<string, unknown> | undefined;
823
+ version?: 1 | undefined;
824
+ ephemeral?: boolean | undefined;
825
+ }>, z.ZodObject<{
826
+ id: z.ZodString;
827
+ conversation_id: z.ZodString;
828
+ timestamp: z.ZodNumber;
829
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
830
+ version: z.ZodDefault<z.ZodLiteral<1>>;
831
+ turn_id: z.ZodString;
832
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
833
+ } & {
834
+ type: z.ZodLiteral<"final_answer">;
835
+ answer_id: z.ZodString;
836
+ content: z.ZodString;
837
+ is_complete: z.ZodDefault<z.ZodBoolean>;
838
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
839
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
840
+ }, "strip", z.ZodTypeAny, {
841
+ type: "final_answer";
842
+ id: string;
843
+ content: string;
844
+ timestamp: number;
845
+ version: 1;
846
+ conversation_id: string;
847
+ turn_id: string;
848
+ is_complete: boolean;
849
+ answer_id: string;
850
+ reasoning_details?: unknown[] | undefined;
851
+ metadata?: Record<string, unknown> | undefined;
852
+ ephemeral?: boolean | undefined;
853
+ meta?: Record<string, any> | undefined;
854
+ }, {
855
+ type: "final_answer";
856
+ id: string;
857
+ content: string;
858
+ timestamp: number;
859
+ conversation_id: string;
860
+ turn_id: string;
861
+ answer_id: string;
862
+ reasoning_details?: unknown[] | undefined;
863
+ metadata?: Record<string, unknown> | undefined;
864
+ version?: 1 | undefined;
865
+ ephemeral?: boolean | undefined;
866
+ is_complete?: boolean | undefined;
867
+ meta?: Record<string, any> | undefined;
868
+ }>, z.ZodObject<{
869
+ id: z.ZodString;
870
+ conversation_id: z.ZodString;
871
+ timestamp: z.ZodNumber;
872
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
873
+ version: z.ZodDefault<z.ZodLiteral<1>>;
874
+ turn_id: z.ZodString;
875
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
876
+ } & {
877
+ type: z.ZodLiteral<"final_answer_chunk">;
878
+ answer_id: z.ZodString;
879
+ seq: z.ZodNumber;
880
+ content: z.ZodString;
881
+ is_last: z.ZodOptional<z.ZodBoolean>;
882
+ }, "strip", z.ZodTypeAny, {
883
+ type: "final_answer_chunk";
884
+ id: string;
885
+ content: string;
886
+ timestamp: number;
887
+ version: 1;
888
+ conversation_id: string;
889
+ turn_id: string;
890
+ answer_id: string;
891
+ seq: number;
892
+ metadata?: Record<string, unknown> | undefined;
893
+ ephemeral?: boolean | undefined;
894
+ is_last?: boolean | undefined;
895
+ }, {
896
+ type: "final_answer_chunk";
897
+ id: string;
898
+ content: string;
899
+ timestamp: number;
900
+ conversation_id: string;
901
+ turn_id: string;
902
+ answer_id: string;
903
+ seq: number;
904
+ metadata?: Record<string, unknown> | undefined;
905
+ version?: 1 | undefined;
906
+ ephemeral?: boolean | undefined;
907
+ is_last?: boolean | undefined;
908
+ }>, z.ZodObject<{
909
+ id: z.ZodString;
910
+ conversation_id: z.ZodString;
911
+ timestamp: z.ZodNumber;
912
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
913
+ version: z.ZodDefault<z.ZodLiteral<1>>;
914
+ turn_id: z.ZodString;
915
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
916
+ } & {
917
+ type: z.ZodLiteral<"history_summary">;
918
+ content: z.ZodString;
919
+ replaced_message_ids: z.ZodArray<z.ZodString, "many">;
920
+ summary_seq: z.ZodNumber;
921
+ original_message_count: z.ZodOptional<z.ZodNumber>;
922
+ compression_ratio: z.ZodOptional<z.ZodNumber>;
923
+ included_old_summary: z.ZodOptional<z.ZodBoolean>;
924
+ }, "strip", z.ZodTypeAny, {
925
+ type: "history_summary";
926
+ id: string;
927
+ content: string;
928
+ timestamp: number;
929
+ version: 1;
930
+ conversation_id: string;
931
+ turn_id: string;
932
+ replaced_message_ids: string[];
933
+ summary_seq: number;
934
+ metadata?: Record<string, unknown> | undefined;
935
+ ephemeral?: boolean | undefined;
936
+ original_message_count?: number | undefined;
937
+ compression_ratio?: number | undefined;
938
+ included_old_summary?: boolean | undefined;
939
+ }, {
940
+ type: "history_summary";
941
+ id: string;
942
+ content: string;
943
+ timestamp: number;
944
+ conversation_id: string;
945
+ turn_id: string;
946
+ replaced_message_ids: string[];
947
+ summary_seq: number;
948
+ metadata?: Record<string, unknown> | undefined;
949
+ version?: 1 | undefined;
950
+ ephemeral?: boolean | undefined;
951
+ original_message_count?: number | undefined;
952
+ compression_ratio?: number | undefined;
953
+ included_old_summary?: boolean | undefined;
954
+ }>, z.ZodObject<{
955
+ id: z.ZodString;
956
+ conversation_id: z.ZodString;
957
+ timestamp: z.ZodNumber;
958
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
959
+ version: z.ZodDefault<z.ZodLiteral<1>>;
960
+ turn_id: z.ZodString;
961
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
962
+ } & {
963
+ type: z.ZodLiteral<"error">;
964
+ error: z.ZodString;
965
+ details: z.ZodOptional<z.ZodAny>;
966
+ error_code: z.ZodOptional<z.ZodString>;
967
+ retryable: z.ZodOptional<z.ZodBoolean>;
968
+ }, "strip", z.ZodTypeAny, {
969
+ type: "error";
970
+ id: string;
971
+ timestamp: number;
972
+ version: 1;
973
+ conversation_id: string;
974
+ turn_id: string;
975
+ error: string;
976
+ metadata?: Record<string, unknown> | undefined;
977
+ ephemeral?: boolean | undefined;
978
+ details?: any;
979
+ error_code?: string | undefined;
980
+ retryable?: boolean | undefined;
981
+ }, {
982
+ type: "error";
983
+ id: string;
984
+ timestamp: number;
985
+ conversation_id: string;
986
+ turn_id: string;
987
+ error: string;
988
+ metadata?: Record<string, unknown> | undefined;
989
+ version?: 1 | undefined;
990
+ ephemeral?: boolean | undefined;
991
+ details?: any;
992
+ error_code?: string | undefined;
993
+ retryable?: boolean | undefined;
994
+ }>, z.ZodObject<{
995
+ id: z.ZodString;
996
+ conversation_id: z.ZodString;
997
+ timestamp: z.ZodNumber;
998
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
999
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1000
+ turn_id: z.ZodString;
1001
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
1002
+ } & {
1003
+ type: z.ZodLiteral<"control">;
1004
+ op: z.ZodEnum<["truncate_after", "replace", "redo", "branch"]>;
1005
+ target_id: z.ZodOptional<z.ZodString>;
1006
+ reason: z.ZodOptional<z.ZodString>;
1007
+ meta: z.ZodOptional<z.ZodAny>;
1008
+ }, "strip", z.ZodTypeAny, {
1009
+ type: "control";
1010
+ id: string;
1011
+ timestamp: number;
1012
+ version: 1;
1013
+ conversation_id: string;
1014
+ turn_id: string;
1015
+ op: "truncate_after" | "replace" | "redo" | "branch";
1016
+ metadata?: Record<string, unknown> | undefined;
1017
+ reason?: string | undefined;
1018
+ ephemeral?: boolean | undefined;
1019
+ meta?: any;
1020
+ target_id?: string | undefined;
1021
+ }, {
1022
+ type: "control";
1023
+ id: string;
1024
+ timestamp: number;
1025
+ conversation_id: string;
1026
+ turn_id: string;
1027
+ op: "truncate_after" | "replace" | "redo" | "branch";
1028
+ metadata?: Record<string, unknown> | undefined;
1029
+ version?: 1 | undefined;
1030
+ reason?: string | undefined;
1031
+ ephemeral?: boolean | undefined;
1032
+ meta?: any;
1033
+ target_id?: string | undefined;
1034
+ }>, z.ZodObject<{
1035
+ id: z.ZodString;
1036
+ conversation_id: z.ZodString;
1037
+ timestamp: z.ZodNumber;
1038
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1039
+ version: z.ZodDefault<z.ZodLiteral<1>>;
1040
+ turn_id: z.ZodString;
1041
+ ephemeral: z.ZodOptional<z.ZodBoolean>;
1042
+ } & {
1043
+ type: z.ZodLiteral<"stream_end">;
1044
+ reason: z.ZodOptional<z.ZodEnum<["complete", "error", "interrupted", "timeout"]>>;
1045
+ reason_message: z.ZodOptional<z.ZodString>;
1046
+ stats: z.ZodOptional<z.ZodObject<{
1047
+ total_events: z.ZodOptional<z.ZodNumber>;
1048
+ duration_ms: z.ZodOptional<z.ZodNumber>;
1049
+ error_count: z.ZodOptional<z.ZodNumber>;
1050
+ }, "strip", z.ZodTypeAny, {
1051
+ duration_ms?: number | undefined;
1052
+ total_events?: number | undefined;
1053
+ error_count?: number | undefined;
1054
+ }, {
1055
+ duration_ms?: number | undefined;
1056
+ total_events?: number | undefined;
1057
+ error_count?: number | undefined;
1058
+ }>>;
1059
+ }, "strip", z.ZodTypeAny, {
1060
+ type: "stream_end";
1061
+ id: string;
1062
+ timestamp: number;
1063
+ version: 1;
1064
+ conversation_id: string;
1065
+ turn_id: string;
1066
+ metadata?: Record<string, unknown> | undefined;
1067
+ reason?: "complete" | "error" | "interrupted" | "timeout" | undefined;
1068
+ ephemeral?: boolean | undefined;
1069
+ reason_message?: string | undefined;
1070
+ stats?: {
1071
+ duration_ms?: number | undefined;
1072
+ total_events?: number | undefined;
1073
+ error_count?: number | undefined;
1074
+ } | undefined;
1075
+ }, {
1076
+ type: "stream_end";
1077
+ id: string;
1078
+ timestamp: number;
1079
+ conversation_id: string;
1080
+ turn_id: string;
1081
+ metadata?: Record<string, unknown> | undefined;
1082
+ version?: 1 | undefined;
1083
+ reason?: "complete" | "error" | "interrupted" | "timeout" | undefined;
1084
+ ephemeral?: boolean | undefined;
1085
+ reason_message?: string | undefined;
1086
+ stats?: {
1087
+ duration_ms?: number | undefined;
1088
+ total_events?: number | undefined;
1089
+ error_count?: number | undefined;
1090
+ } | undefined;
1091
+ }>]>;
1092
+ type RuntimeEvent = z.infer<typeof RuntimeEvent>;
1093
+ type UserInputEvent = Extract<RuntimeEvent, {
1094
+ type: 'user_input';
1095
+ }>;
1096
+ type ThoughtEvent = Extract<RuntimeEvent, {
1097
+ type: 'thought';
1098
+ }>;
1099
+ type ToolCallDecisionEvent = Extract<RuntimeEvent, {
1100
+ type: 'tool_call_decision';
1101
+ }>;
1102
+ type ToolProcessEvent = Extract<RuntimeEvent, {
1103
+ type: 'tool_process';
1104
+ }>;
1105
+ type ToolOutputEvent = Extract<RuntimeEvent, {
1106
+ type: 'tool_output';
1107
+ }>;
1108
+ type TodoUpdatedEvent = Extract<RuntimeEvent, {
1109
+ type: 'todo_updated';
1110
+ }>;
1111
+ type SubRunTraceEvent = Extract<RuntimeEvent, {
1112
+ type: 'subrun_trace';
1113
+ }>;
1114
+ type RequiresUserInteractionEvent = Extract<RuntimeEvent, {
1115
+ type: 'requires_user_interaction';
1116
+ }>;
1117
+ type AuditEnvelopeEvent = Extract<RuntimeEvent, {
1118
+ type: 'audit_envelope';
1119
+ }>;
1120
+ type FinalAnswerEvent = Extract<RuntimeEvent, {
1121
+ type: 'final_answer';
1122
+ }>;
1123
+ type FinalAnswerChunkEvent = Extract<RuntimeEvent, {
1124
+ type: 'final_answer_chunk';
1125
+ }>;
1126
+ type HistorySummaryEvent = Extract<RuntimeEvent, {
1127
+ type: 'history_summary';
1128
+ }>;
1129
+ type ErrorEvent = Extract<RuntimeEvent, {
1130
+ type: 'error';
1131
+ }>;
1132
+ type ControlEvent = Extract<RuntimeEvent, {
1133
+ type: 'control';
1134
+ }>;
1135
+ type StreamEndEvent = Extract<RuntimeEvent, {
1136
+ type: 'stream_end';
1137
+ }>;
1138
+ declare const validateRuntimeEvent: (event: unknown) => z.SafeParseReturnType<{
1139
+ type: "user_input";
1140
+ id: string;
1141
+ content: string;
1142
+ timestamp: number;
1143
+ conversation_id: string;
1144
+ turn_id: string;
1145
+ metadata?: Record<string, unknown> | undefined;
1146
+ version?: 1 | undefined;
1147
+ ephemeral?: boolean | undefined;
1148
+ raw_content?: string | undefined;
1149
+ source?: "system" | "user" | "editor" | undefined;
1150
+ } | {
1151
+ type: "thought";
1152
+ id: string;
1153
+ content: string;
1154
+ timestamp: number;
1155
+ conversation_id: string;
1156
+ turn_id: string;
1157
+ metadata?: Record<string, unknown> | undefined;
1158
+ version?: 1 | undefined;
1159
+ ephemeral?: boolean | undefined;
1160
+ thought_message_id?: string | undefined;
1161
+ delta?: string | undefined;
1162
+ is_complete?: boolean | undefined;
1163
+ } | {
1164
+ type: "tool_call_decision";
1165
+ status: "error" | "loading" | "success";
1166
+ id: string;
1167
+ tool_name: string;
1168
+ tool_call_id: string;
1169
+ timestamp: number;
1170
+ conversation_id: string;
1171
+ turn_id: string;
1172
+ phase: "start" | "update" | "complete" | "error";
1173
+ args?: Record<string, any> | undefined;
1174
+ metadata?: Record<string, unknown> | undefined;
1175
+ version?: 1 | undefined;
1176
+ ephemeral?: boolean | undefined;
1177
+ payload?: z.objectInputType<{
1178
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1179
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1180
+ /**
1181
+ * 不透明 provider reasoning replay blocks。
1182
+ *
1183
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
1184
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
1185
+ */
1186
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1187
+ }, z.ZodTypeAny, "passthrough"> | undefined;
1188
+ parent_tool_call_id?: string | undefined;
1189
+ meta?: Record<string, any> | undefined;
1190
+ } | {
1191
+ type: "tool_process";
1192
+ status: "error" | "loading" | "success";
1193
+ id: string;
1194
+ tool_name: string;
1195
+ tool_call_id: string;
1196
+ timestamp: number;
1197
+ conversation_id: string;
1198
+ turn_id: string;
1199
+ phase: "start" | "update" | "complete" | "error";
1200
+ args?: Record<string, any> | undefined;
1201
+ metadata?: Record<string, unknown> | undefined;
1202
+ version?: 1 | undefined;
1203
+ ephemeral?: boolean | undefined;
1204
+ payload?: Record<string, any> | undefined;
1205
+ parent_tool_call_id?: string | undefined;
1206
+ meta?: Record<string, any> | undefined;
1207
+ } | {
1208
+ type: "tool_output";
1209
+ status: "error" | "success";
1210
+ id: string;
1211
+ tool_name: string;
1212
+ tool_call_id: string;
1213
+ timestamp: number;
1214
+ conversation_id: string;
1215
+ turn_id: string;
1216
+ metadata?: Record<string, unknown> | undefined;
1217
+ version?: 1 | undefined;
1218
+ ephemeral?: boolean | undefined;
1219
+ error?: string | undefined;
1220
+ payload?: Record<string, any> | undefined;
1221
+ output?: any;
1222
+ duration_ms?: number | undefined;
1223
+ } | {
1224
+ type: "todo_updated";
1225
+ id: string;
1226
+ timestamp: number;
1227
+ conversation_id: string;
1228
+ turn_id: string;
1229
+ todo_list_id: string;
1230
+ todo_list_version: number;
1231
+ items: {
1232
+ status: "in_progress" | "completed" | "cancelled" | "pending";
1233
+ id: string;
1234
+ content: string;
1235
+ }[];
1236
+ metadata?: Record<string, unknown> | undefined;
1237
+ version?: 1 | undefined;
1238
+ ephemeral?: boolean | undefined;
1239
+ } | {
1240
+ type: "subrun_trace";
1241
+ id: string;
1242
+ timestamp: number;
1243
+ kind: "final_answer" | "tool_output" | "tool_call_decision" | "tool_process" | "thought_delta" | "thought_complete" | "final_answer_chunk";
1244
+ conversation_id: string;
1245
+ turn_id: string;
1246
+ parent_tool_call_id: string;
1247
+ subrun_id: string;
1248
+ status?: "error" | "loading" | "success" | undefined;
1249
+ tool_name?: string | undefined;
1250
+ args?: unknown;
1251
+ tool_call_id?: string | undefined;
1252
+ content?: string | undefined;
1253
+ metadata?: Record<string, unknown> | undefined;
1254
+ version?: 1 | undefined;
1255
+ ephemeral?: boolean | undefined;
1256
+ delta?: string | undefined;
1257
+ phase?: "start" | "update" | "complete" | "error" | undefined;
1258
+ meta?: Record<string, unknown> | undefined;
1259
+ output?: unknown;
1260
+ duration_ms?: number | undefined;
1261
+ subrun_parent_id?: string | undefined;
1262
+ } | {
1263
+ type: "requires_user_interaction";
1264
+ id: string;
1265
+ timestamp: number;
1266
+ conversation_id: string;
1267
+ turn_id: string;
1268
+ metadata?: Record<string, unknown> | undefined;
1269
+ version?: 1 | undefined;
1270
+ ephemeral?: boolean | undefined;
1271
+ form?: any;
1272
+ interaction_type?: string | undefined;
1273
+ prompt?: string | undefined;
1274
+ } | {
1275
+ type: "audit_envelope";
1276
+ id: string;
1277
+ timestamp: number;
1278
+ conversation_id: string;
1279
+ turn_id: string;
1280
+ envelope: {
1281
+ runId: string;
1282
+ envelopeId: string;
1283
+ ts: number;
1284
+ actor: {
1285
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
1286
+ id?: string | undefined;
1287
+ name?: string | undefined;
1288
+ };
1289
+ action: string;
1290
+ parentRunId?: string | undefined;
1291
+ decision?: {
1292
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
1293
+ metadata?: Record<string, unknown> | undefined;
1294
+ reason?: string | undefined;
1295
+ policy?: string | undefined;
1296
+ } | undefined;
1297
+ evidence?: {
1298
+ kind: string;
1299
+ summary?: string | undefined;
1300
+ metadata?: Record<string, unknown> | undefined;
1301
+ ref?: string | undefined;
1302
+ }[] | undefined;
1303
+ costDelta?: {
1304
+ tokensInput?: number | undefined;
1305
+ tokensOutput?: number | undefined;
1306
+ totalCostUsd?: number | undefined;
1307
+ latencyMs?: number | undefined;
1308
+ } | undefined;
1309
+ scope?: {
1310
+ metadata?: Record<string, unknown> | undefined;
1311
+ toolName?: string | undefined;
1312
+ conversationId?: string | undefined;
1313
+ runId?: string | undefined;
1314
+ parentRunId?: string | undefined;
1315
+ turnId?: string | undefined;
1316
+ traceId?: string | undefined;
1317
+ agentSpecId?: string | undefined;
1318
+ toolCallId?: string | undefined;
1319
+ modelId?: string | undefined;
1320
+ nodeId?: string | undefined;
1321
+ } | undefined;
1322
+ };
1323
+ metadata?: Record<string, unknown> | undefined;
1324
+ version?: 1 | undefined;
1325
+ ephemeral?: boolean | undefined;
1326
+ } | {
1327
+ type: "final_answer";
1328
+ id: string;
1329
+ content: string;
1330
+ timestamp: number;
1331
+ conversation_id: string;
1332
+ turn_id: string;
1333
+ answer_id: string;
1334
+ reasoning_details?: unknown[] | undefined;
1335
+ metadata?: Record<string, unknown> | undefined;
1336
+ version?: 1 | undefined;
1337
+ ephemeral?: boolean | undefined;
1338
+ is_complete?: boolean | undefined;
1339
+ meta?: Record<string, any> | undefined;
1340
+ } | {
1341
+ type: "final_answer_chunk";
1342
+ id: string;
1343
+ content: string;
1344
+ timestamp: number;
1345
+ conversation_id: string;
1346
+ turn_id: string;
1347
+ answer_id: string;
1348
+ seq: number;
1349
+ metadata?: Record<string, unknown> | undefined;
1350
+ version?: 1 | undefined;
1351
+ ephemeral?: boolean | undefined;
1352
+ is_last?: boolean | undefined;
1353
+ } | {
1354
+ type: "history_summary";
1355
+ id: string;
1356
+ content: string;
1357
+ timestamp: number;
1358
+ conversation_id: string;
1359
+ turn_id: string;
1360
+ replaced_message_ids: string[];
1361
+ summary_seq: number;
1362
+ metadata?: Record<string, unknown> | undefined;
1363
+ version?: 1 | undefined;
1364
+ ephemeral?: boolean | undefined;
1365
+ original_message_count?: number | undefined;
1366
+ compression_ratio?: number | undefined;
1367
+ included_old_summary?: boolean | undefined;
1368
+ } | {
1369
+ type: "error";
1370
+ id: string;
1371
+ timestamp: number;
1372
+ conversation_id: string;
1373
+ turn_id: string;
1374
+ error: string;
1375
+ metadata?: Record<string, unknown> | undefined;
1376
+ version?: 1 | undefined;
1377
+ ephemeral?: boolean | undefined;
1378
+ details?: any;
1379
+ error_code?: string | undefined;
1380
+ retryable?: boolean | undefined;
1381
+ } | {
1382
+ type: "control";
1383
+ id: string;
1384
+ timestamp: number;
1385
+ conversation_id: string;
1386
+ turn_id: string;
1387
+ op: "truncate_after" | "replace" | "redo" | "branch";
1388
+ metadata?: Record<string, unknown> | undefined;
1389
+ version?: 1 | undefined;
1390
+ reason?: string | undefined;
1391
+ ephemeral?: boolean | undefined;
1392
+ meta?: any;
1393
+ target_id?: string | undefined;
1394
+ } | {
1395
+ type: "stream_end";
1396
+ id: string;
1397
+ timestamp: number;
1398
+ conversation_id: string;
1399
+ turn_id: string;
1400
+ metadata?: Record<string, unknown> | undefined;
1401
+ version?: 1 | undefined;
1402
+ reason?: "complete" | "error" | "interrupted" | "timeout" | undefined;
1403
+ ephemeral?: boolean | undefined;
1404
+ reason_message?: string | undefined;
1405
+ stats?: {
1406
+ duration_ms?: number | undefined;
1407
+ total_events?: number | undefined;
1408
+ error_count?: number | undefined;
1409
+ } | undefined;
1410
+ }, {
1411
+ type: "user_input";
1412
+ id: string;
1413
+ content: string;
1414
+ timestamp: number;
1415
+ version: 1;
1416
+ conversation_id: string;
1417
+ turn_id: string;
1418
+ source: "system" | "user" | "editor";
1419
+ metadata?: Record<string, unknown> | undefined;
1420
+ ephemeral?: boolean | undefined;
1421
+ raw_content?: string | undefined;
1422
+ } | {
1423
+ type: "thought";
1424
+ id: string;
1425
+ content: string;
1426
+ timestamp: number;
1427
+ version: 1;
1428
+ conversation_id: string;
1429
+ turn_id: string;
1430
+ is_complete: boolean;
1431
+ metadata?: Record<string, unknown> | undefined;
1432
+ ephemeral?: boolean | undefined;
1433
+ thought_message_id?: string | undefined;
1434
+ delta?: string | undefined;
1435
+ } | {
1436
+ type: "tool_call_decision";
1437
+ status: "error" | "loading" | "success";
1438
+ id: string;
1439
+ tool_name: string;
1440
+ tool_call_id: string;
1441
+ timestamp: number;
1442
+ version: 1;
1443
+ conversation_id: string;
1444
+ turn_id: string;
1445
+ phase: "start" | "update" | "complete" | "error";
1446
+ args?: Record<string, any> | undefined;
1447
+ metadata?: Record<string, unknown> | undefined;
1448
+ ephemeral?: boolean | undefined;
1449
+ payload?: z.objectOutputType<{
1450
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1451
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1452
+ /**
1453
+ * 不透明 provider reasoning replay blocks。
1454
+ *
1455
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
1456
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
1457
+ */
1458
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1459
+ }, z.ZodTypeAny, "passthrough"> | undefined;
1460
+ parent_tool_call_id?: string | undefined;
1461
+ meta?: Record<string, any> | undefined;
1462
+ } | {
1463
+ type: "tool_process";
1464
+ status: "error" | "loading" | "success";
1465
+ id: string;
1466
+ tool_name: string;
1467
+ tool_call_id: string;
1468
+ timestamp: number;
1469
+ version: 1;
1470
+ conversation_id: string;
1471
+ turn_id: string;
1472
+ phase: "start" | "update" | "complete" | "error";
1473
+ args?: Record<string, any> | undefined;
1474
+ metadata?: Record<string, unknown> | undefined;
1475
+ ephemeral?: boolean | undefined;
1476
+ payload?: Record<string, any> | undefined;
1477
+ parent_tool_call_id?: string | undefined;
1478
+ meta?: Record<string, any> | undefined;
1479
+ } | {
1480
+ type: "tool_output";
1481
+ status: "error" | "success";
1482
+ id: string;
1483
+ tool_name: string;
1484
+ tool_call_id: string;
1485
+ timestamp: number;
1486
+ version: 1;
1487
+ conversation_id: string;
1488
+ turn_id: string;
1489
+ metadata?: Record<string, unknown> | undefined;
1490
+ ephemeral?: boolean | undefined;
1491
+ error?: string | undefined;
1492
+ payload?: Record<string, any> | undefined;
1493
+ output?: any;
1494
+ duration_ms?: number | undefined;
1495
+ } | {
1496
+ type: "todo_updated";
1497
+ id: string;
1498
+ timestamp: number;
1499
+ version: 1;
1500
+ conversation_id: string;
1501
+ turn_id: string;
1502
+ todo_list_id: string;
1503
+ todo_list_version: number;
1504
+ items: {
1505
+ status: "in_progress" | "completed" | "cancelled" | "pending";
1506
+ id: string;
1507
+ content: string;
1508
+ }[];
1509
+ metadata?: Record<string, unknown> | undefined;
1510
+ ephemeral?: boolean | undefined;
1511
+ } | {
1512
+ type: "subrun_trace";
1513
+ id: string;
1514
+ timestamp: number;
1515
+ kind: "final_answer" | "tool_output" | "tool_call_decision" | "tool_process" | "thought_delta" | "thought_complete" | "final_answer_chunk";
1516
+ version: 1;
1517
+ conversation_id: string;
1518
+ turn_id: string;
1519
+ parent_tool_call_id: string;
1520
+ subrun_id: string;
1521
+ status?: "error" | "loading" | "success" | undefined;
1522
+ tool_name?: string | undefined;
1523
+ args?: unknown;
1524
+ tool_call_id?: string | undefined;
1525
+ content?: string | undefined;
1526
+ metadata?: Record<string, unknown> | undefined;
1527
+ ephemeral?: boolean | undefined;
1528
+ delta?: string | undefined;
1529
+ phase?: "start" | "update" | "complete" | "error" | undefined;
1530
+ meta?: Record<string, unknown> | undefined;
1531
+ output?: unknown;
1532
+ duration_ms?: number | undefined;
1533
+ subrun_parent_id?: string | undefined;
1534
+ } | {
1535
+ type: "requires_user_interaction";
1536
+ id: string;
1537
+ timestamp: number;
1538
+ version: 1;
1539
+ conversation_id: string;
1540
+ turn_id: string;
1541
+ metadata?: Record<string, unknown> | undefined;
1542
+ ephemeral?: boolean | undefined;
1543
+ form?: any;
1544
+ interaction_type?: string | undefined;
1545
+ prompt?: string | undefined;
1546
+ } | {
1547
+ type: "audit_envelope";
1548
+ id: string;
1549
+ timestamp: number;
1550
+ version: 1;
1551
+ conversation_id: string;
1552
+ turn_id: string;
1553
+ envelope: {
1554
+ runId: string;
1555
+ envelopeId: string;
1556
+ ts: number;
1557
+ actor: {
1558
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
1559
+ id?: string | undefined;
1560
+ name?: string | undefined;
1561
+ };
1562
+ action: string;
1563
+ parentRunId?: string | undefined;
1564
+ decision?: {
1565
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
1566
+ metadata?: Record<string, unknown> | undefined;
1567
+ reason?: string | undefined;
1568
+ policy?: string | undefined;
1569
+ } | undefined;
1570
+ evidence?: {
1571
+ kind: string;
1572
+ summary?: string | undefined;
1573
+ metadata?: Record<string, unknown> | undefined;
1574
+ ref?: string | undefined;
1575
+ }[] | undefined;
1576
+ costDelta?: {
1577
+ tokensInput?: number | undefined;
1578
+ tokensOutput?: number | undefined;
1579
+ totalCostUsd?: number | undefined;
1580
+ latencyMs?: number | undefined;
1581
+ } | undefined;
1582
+ scope?: {
1583
+ metadata?: Record<string, unknown> | undefined;
1584
+ toolName?: string | undefined;
1585
+ conversationId?: string | undefined;
1586
+ runId?: string | undefined;
1587
+ parentRunId?: string | undefined;
1588
+ turnId?: string | undefined;
1589
+ traceId?: string | undefined;
1590
+ agentSpecId?: string | undefined;
1591
+ toolCallId?: string | undefined;
1592
+ modelId?: string | undefined;
1593
+ nodeId?: string | undefined;
1594
+ } | undefined;
1595
+ };
1596
+ metadata?: Record<string, unknown> | undefined;
1597
+ ephemeral?: boolean | undefined;
1598
+ } | {
1599
+ type: "final_answer";
1600
+ id: string;
1601
+ content: string;
1602
+ timestamp: number;
1603
+ version: 1;
1604
+ conversation_id: string;
1605
+ turn_id: string;
1606
+ is_complete: boolean;
1607
+ answer_id: string;
1608
+ reasoning_details?: unknown[] | undefined;
1609
+ metadata?: Record<string, unknown> | undefined;
1610
+ ephemeral?: boolean | undefined;
1611
+ meta?: Record<string, any> | undefined;
1612
+ } | {
1613
+ type: "final_answer_chunk";
1614
+ id: string;
1615
+ content: string;
1616
+ timestamp: number;
1617
+ version: 1;
1618
+ conversation_id: string;
1619
+ turn_id: string;
1620
+ answer_id: string;
1621
+ seq: number;
1622
+ metadata?: Record<string, unknown> | undefined;
1623
+ ephemeral?: boolean | undefined;
1624
+ is_last?: boolean | undefined;
1625
+ } | {
1626
+ type: "history_summary";
1627
+ id: string;
1628
+ content: string;
1629
+ timestamp: number;
1630
+ version: 1;
1631
+ conversation_id: string;
1632
+ turn_id: string;
1633
+ replaced_message_ids: string[];
1634
+ summary_seq: number;
1635
+ metadata?: Record<string, unknown> | undefined;
1636
+ ephemeral?: boolean | undefined;
1637
+ original_message_count?: number | undefined;
1638
+ compression_ratio?: number | undefined;
1639
+ included_old_summary?: boolean | undefined;
1640
+ } | {
1641
+ type: "error";
1642
+ id: string;
1643
+ timestamp: number;
1644
+ version: 1;
1645
+ conversation_id: string;
1646
+ turn_id: string;
1647
+ error: string;
1648
+ metadata?: Record<string, unknown> | undefined;
1649
+ ephemeral?: boolean | undefined;
1650
+ details?: any;
1651
+ error_code?: string | undefined;
1652
+ retryable?: boolean | undefined;
1653
+ } | {
1654
+ type: "control";
1655
+ id: string;
1656
+ timestamp: number;
1657
+ version: 1;
1658
+ conversation_id: string;
1659
+ turn_id: string;
1660
+ op: "truncate_after" | "replace" | "redo" | "branch";
1661
+ metadata?: Record<string, unknown> | undefined;
1662
+ reason?: string | undefined;
1663
+ ephemeral?: boolean | undefined;
1664
+ meta?: any;
1665
+ target_id?: string | undefined;
1666
+ } | {
1667
+ type: "stream_end";
1668
+ id: string;
1669
+ timestamp: number;
1670
+ version: 1;
1671
+ conversation_id: string;
1672
+ turn_id: string;
1673
+ metadata?: Record<string, unknown> | undefined;
1674
+ reason?: "complete" | "error" | "interrupted" | "timeout" | undefined;
1675
+ ephemeral?: boolean | undefined;
1676
+ reason_message?: string | undefined;
1677
+ stats?: {
1678
+ duration_ms?: number | undefined;
1679
+ total_events?: number | undefined;
1680
+ error_count?: number | undefined;
1681
+ } | undefined;
1682
+ }>;
1683
+ declare const validateRuntimeEvents: (events: unknown[]) => z.SafeParseReturnType<({
1684
+ type: "user_input";
1685
+ id: string;
1686
+ content: string;
1687
+ timestamp: number;
1688
+ conversation_id: string;
1689
+ turn_id: string;
1690
+ metadata?: Record<string, unknown> | undefined;
1691
+ version?: 1 | undefined;
1692
+ ephemeral?: boolean | undefined;
1693
+ raw_content?: string | undefined;
1694
+ source?: "system" | "user" | "editor" | undefined;
1695
+ } | {
1696
+ type: "thought";
1697
+ id: string;
1698
+ content: string;
1699
+ timestamp: number;
1700
+ conversation_id: string;
1701
+ turn_id: string;
1702
+ metadata?: Record<string, unknown> | undefined;
1703
+ version?: 1 | undefined;
1704
+ ephemeral?: boolean | undefined;
1705
+ thought_message_id?: string | undefined;
1706
+ delta?: string | undefined;
1707
+ is_complete?: boolean | undefined;
1708
+ } | {
1709
+ type: "tool_call_decision";
1710
+ status: "error" | "loading" | "success";
1711
+ id: string;
1712
+ tool_name: string;
1713
+ tool_call_id: string;
1714
+ timestamp: number;
1715
+ conversation_id: string;
1716
+ turn_id: string;
1717
+ phase: "start" | "update" | "complete" | "error";
1718
+ args?: Record<string, any> | undefined;
1719
+ metadata?: Record<string, unknown> | undefined;
1720
+ version?: 1 | undefined;
1721
+ ephemeral?: boolean | undefined;
1722
+ payload?: z.objectInputType<{
1723
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1724
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1725
+ /**
1726
+ * 不透明 provider reasoning replay blocks。
1727
+ *
1728
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
1729
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
1730
+ */
1731
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1732
+ }, z.ZodTypeAny, "passthrough"> | undefined;
1733
+ parent_tool_call_id?: string | undefined;
1734
+ meta?: Record<string, any> | undefined;
1735
+ } | {
1736
+ type: "tool_process";
1737
+ status: "error" | "loading" | "success";
1738
+ id: string;
1739
+ tool_name: string;
1740
+ tool_call_id: string;
1741
+ timestamp: number;
1742
+ conversation_id: string;
1743
+ turn_id: string;
1744
+ phase: "start" | "update" | "complete" | "error";
1745
+ args?: Record<string, any> | undefined;
1746
+ metadata?: Record<string, unknown> | undefined;
1747
+ version?: 1 | undefined;
1748
+ ephemeral?: boolean | undefined;
1749
+ payload?: Record<string, any> | undefined;
1750
+ parent_tool_call_id?: string | undefined;
1751
+ meta?: Record<string, any> | undefined;
1752
+ } | {
1753
+ type: "tool_output";
1754
+ status: "error" | "success";
1755
+ id: string;
1756
+ tool_name: string;
1757
+ tool_call_id: string;
1758
+ timestamp: number;
1759
+ conversation_id: string;
1760
+ turn_id: string;
1761
+ metadata?: Record<string, unknown> | undefined;
1762
+ version?: 1 | undefined;
1763
+ ephemeral?: boolean | undefined;
1764
+ error?: string | undefined;
1765
+ payload?: Record<string, any> | undefined;
1766
+ output?: any;
1767
+ duration_ms?: number | undefined;
1768
+ } | {
1769
+ type: "todo_updated";
1770
+ id: string;
1771
+ timestamp: number;
1772
+ conversation_id: string;
1773
+ turn_id: string;
1774
+ todo_list_id: string;
1775
+ todo_list_version: number;
1776
+ items: {
1777
+ status: "in_progress" | "completed" | "cancelled" | "pending";
1778
+ id: string;
1779
+ content: string;
1780
+ }[];
1781
+ metadata?: Record<string, unknown> | undefined;
1782
+ version?: 1 | undefined;
1783
+ ephemeral?: boolean | undefined;
1784
+ } | {
1785
+ type: "subrun_trace";
1786
+ id: string;
1787
+ timestamp: number;
1788
+ kind: "final_answer" | "tool_output" | "tool_call_decision" | "tool_process" | "thought_delta" | "thought_complete" | "final_answer_chunk";
1789
+ conversation_id: string;
1790
+ turn_id: string;
1791
+ parent_tool_call_id: string;
1792
+ subrun_id: string;
1793
+ status?: "error" | "loading" | "success" | undefined;
1794
+ tool_name?: string | undefined;
1795
+ args?: unknown;
1796
+ tool_call_id?: string | undefined;
1797
+ content?: string | undefined;
1798
+ metadata?: Record<string, unknown> | undefined;
1799
+ version?: 1 | undefined;
1800
+ ephemeral?: boolean | undefined;
1801
+ delta?: string | undefined;
1802
+ phase?: "start" | "update" | "complete" | "error" | undefined;
1803
+ meta?: Record<string, unknown> | undefined;
1804
+ output?: unknown;
1805
+ duration_ms?: number | undefined;
1806
+ subrun_parent_id?: string | undefined;
1807
+ } | {
1808
+ type: "requires_user_interaction";
1809
+ id: string;
1810
+ timestamp: number;
1811
+ conversation_id: string;
1812
+ turn_id: string;
1813
+ metadata?: Record<string, unknown> | undefined;
1814
+ version?: 1 | undefined;
1815
+ ephemeral?: boolean | undefined;
1816
+ form?: any;
1817
+ interaction_type?: string | undefined;
1818
+ prompt?: string | undefined;
1819
+ } | {
1820
+ type: "audit_envelope";
1821
+ id: string;
1822
+ timestamp: number;
1823
+ conversation_id: string;
1824
+ turn_id: string;
1825
+ envelope: {
1826
+ runId: string;
1827
+ envelopeId: string;
1828
+ ts: number;
1829
+ actor: {
1830
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
1831
+ id?: string | undefined;
1832
+ name?: string | undefined;
1833
+ };
1834
+ action: string;
1835
+ parentRunId?: string | undefined;
1836
+ decision?: {
1837
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
1838
+ metadata?: Record<string, unknown> | undefined;
1839
+ reason?: string | undefined;
1840
+ policy?: string | undefined;
1841
+ } | undefined;
1842
+ evidence?: {
1843
+ kind: string;
1844
+ summary?: string | undefined;
1845
+ metadata?: Record<string, unknown> | undefined;
1846
+ ref?: string | undefined;
1847
+ }[] | undefined;
1848
+ costDelta?: {
1849
+ tokensInput?: number | undefined;
1850
+ tokensOutput?: number | undefined;
1851
+ totalCostUsd?: number | undefined;
1852
+ latencyMs?: number | undefined;
1853
+ } | undefined;
1854
+ scope?: {
1855
+ metadata?: Record<string, unknown> | undefined;
1856
+ toolName?: string | undefined;
1857
+ conversationId?: string | undefined;
1858
+ runId?: string | undefined;
1859
+ parentRunId?: string | undefined;
1860
+ turnId?: string | undefined;
1861
+ traceId?: string | undefined;
1862
+ agentSpecId?: string | undefined;
1863
+ toolCallId?: string | undefined;
1864
+ modelId?: string | undefined;
1865
+ nodeId?: string | undefined;
1866
+ } | undefined;
1867
+ };
1868
+ metadata?: Record<string, unknown> | undefined;
1869
+ version?: 1 | undefined;
1870
+ ephemeral?: boolean | undefined;
1871
+ } | {
1872
+ type: "final_answer";
1873
+ id: string;
1874
+ content: string;
1875
+ timestamp: number;
1876
+ conversation_id: string;
1877
+ turn_id: string;
1878
+ answer_id: string;
1879
+ reasoning_details?: unknown[] | undefined;
1880
+ metadata?: Record<string, unknown> | undefined;
1881
+ version?: 1 | undefined;
1882
+ ephemeral?: boolean | undefined;
1883
+ is_complete?: boolean | undefined;
1884
+ meta?: Record<string, any> | undefined;
1885
+ } | {
1886
+ type: "final_answer_chunk";
1887
+ id: string;
1888
+ content: string;
1889
+ timestamp: number;
1890
+ conversation_id: string;
1891
+ turn_id: string;
1892
+ answer_id: string;
1893
+ seq: number;
1894
+ metadata?: Record<string, unknown> | undefined;
1895
+ version?: 1 | undefined;
1896
+ ephemeral?: boolean | undefined;
1897
+ is_last?: boolean | undefined;
1898
+ } | {
1899
+ type: "history_summary";
1900
+ id: string;
1901
+ content: string;
1902
+ timestamp: number;
1903
+ conversation_id: string;
1904
+ turn_id: string;
1905
+ replaced_message_ids: string[];
1906
+ summary_seq: number;
1907
+ metadata?: Record<string, unknown> | undefined;
1908
+ version?: 1 | undefined;
1909
+ ephemeral?: boolean | undefined;
1910
+ original_message_count?: number | undefined;
1911
+ compression_ratio?: number | undefined;
1912
+ included_old_summary?: boolean | undefined;
1913
+ } | {
1914
+ type: "error";
1915
+ id: string;
1916
+ timestamp: number;
1917
+ conversation_id: string;
1918
+ turn_id: string;
1919
+ error: string;
1920
+ metadata?: Record<string, unknown> | undefined;
1921
+ version?: 1 | undefined;
1922
+ ephemeral?: boolean | undefined;
1923
+ details?: any;
1924
+ error_code?: string | undefined;
1925
+ retryable?: boolean | undefined;
1926
+ } | {
1927
+ type: "control";
1928
+ id: string;
1929
+ timestamp: number;
1930
+ conversation_id: string;
1931
+ turn_id: string;
1932
+ op: "truncate_after" | "replace" | "redo" | "branch";
1933
+ metadata?: Record<string, unknown> | undefined;
1934
+ version?: 1 | undefined;
1935
+ reason?: string | undefined;
1936
+ ephemeral?: boolean | undefined;
1937
+ meta?: any;
1938
+ target_id?: string | undefined;
1939
+ } | {
1940
+ type: "stream_end";
1941
+ id: string;
1942
+ timestamp: number;
1943
+ conversation_id: string;
1944
+ turn_id: string;
1945
+ metadata?: Record<string, unknown> | undefined;
1946
+ version?: 1 | undefined;
1947
+ reason?: "complete" | "error" | "interrupted" | "timeout" | undefined;
1948
+ ephemeral?: boolean | undefined;
1949
+ reason_message?: string | undefined;
1950
+ stats?: {
1951
+ duration_ms?: number | undefined;
1952
+ total_events?: number | undefined;
1953
+ error_count?: number | undefined;
1954
+ } | undefined;
1955
+ })[], ({
1956
+ type: "user_input";
1957
+ id: string;
1958
+ content: string;
1959
+ timestamp: number;
1960
+ version: 1;
1961
+ conversation_id: string;
1962
+ turn_id: string;
1963
+ source: "system" | "user" | "editor";
1964
+ metadata?: Record<string, unknown> | undefined;
1965
+ ephemeral?: boolean | undefined;
1966
+ raw_content?: string | undefined;
1967
+ } | {
1968
+ type: "thought";
1969
+ id: string;
1970
+ content: string;
1971
+ timestamp: number;
1972
+ version: 1;
1973
+ conversation_id: string;
1974
+ turn_id: string;
1975
+ is_complete: boolean;
1976
+ metadata?: Record<string, unknown> | undefined;
1977
+ ephemeral?: boolean | undefined;
1978
+ thought_message_id?: string | undefined;
1979
+ delta?: string | undefined;
1980
+ } | {
1981
+ type: "tool_call_decision";
1982
+ status: "error" | "loading" | "success";
1983
+ id: string;
1984
+ tool_name: string;
1985
+ tool_call_id: string;
1986
+ timestamp: number;
1987
+ version: 1;
1988
+ conversation_id: string;
1989
+ turn_id: string;
1990
+ phase: "start" | "update" | "complete" | "error";
1991
+ args?: Record<string, any> | undefined;
1992
+ metadata?: Record<string, unknown> | undefined;
1993
+ ephemeral?: boolean | undefined;
1994
+ payload?: z.objectOutputType<{
1995
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1996
+ tool_calls: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1997
+ /**
1998
+ * 不透明 provider reasoning replay blocks。
1999
+ *
2000
+ * RuntimeEvent 层的标准位置是 assistant 产出事件携带 reasoning_details;
2001
+ * context-manager 会把它回放到 AiMessage.metadata.reasoning_details。
2002
+ */
2003
+ reasoning_details: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
2004
+ }, z.ZodTypeAny, "passthrough"> | undefined;
2005
+ parent_tool_call_id?: string | undefined;
2006
+ meta?: Record<string, any> | undefined;
2007
+ } | {
2008
+ type: "tool_process";
2009
+ status: "error" | "loading" | "success";
2010
+ id: string;
2011
+ tool_name: string;
2012
+ tool_call_id: string;
2013
+ timestamp: number;
2014
+ version: 1;
2015
+ conversation_id: string;
2016
+ turn_id: string;
2017
+ phase: "start" | "update" | "complete" | "error";
2018
+ args?: Record<string, any> | undefined;
2019
+ metadata?: Record<string, unknown> | undefined;
2020
+ ephemeral?: boolean | undefined;
2021
+ payload?: Record<string, any> | undefined;
2022
+ parent_tool_call_id?: string | undefined;
2023
+ meta?: Record<string, any> | undefined;
2024
+ } | {
2025
+ type: "tool_output";
2026
+ status: "error" | "success";
2027
+ id: string;
2028
+ tool_name: string;
2029
+ tool_call_id: string;
2030
+ timestamp: number;
2031
+ version: 1;
2032
+ conversation_id: string;
2033
+ turn_id: string;
2034
+ metadata?: Record<string, unknown> | undefined;
2035
+ ephemeral?: boolean | undefined;
2036
+ error?: string | undefined;
2037
+ payload?: Record<string, any> | undefined;
2038
+ output?: any;
2039
+ duration_ms?: number | undefined;
2040
+ } | {
2041
+ type: "todo_updated";
2042
+ id: string;
2043
+ timestamp: number;
2044
+ version: 1;
2045
+ conversation_id: string;
2046
+ turn_id: string;
2047
+ todo_list_id: string;
2048
+ todo_list_version: number;
2049
+ items: {
2050
+ status: "in_progress" | "completed" | "cancelled" | "pending";
2051
+ id: string;
2052
+ content: string;
2053
+ }[];
2054
+ metadata?: Record<string, unknown> | undefined;
2055
+ ephemeral?: boolean | undefined;
2056
+ } | {
2057
+ type: "subrun_trace";
2058
+ id: string;
2059
+ timestamp: number;
2060
+ kind: "final_answer" | "tool_output" | "tool_call_decision" | "tool_process" | "thought_delta" | "thought_complete" | "final_answer_chunk";
2061
+ version: 1;
2062
+ conversation_id: string;
2063
+ turn_id: string;
2064
+ parent_tool_call_id: string;
2065
+ subrun_id: string;
2066
+ status?: "error" | "loading" | "success" | undefined;
2067
+ tool_name?: string | undefined;
2068
+ args?: unknown;
2069
+ tool_call_id?: string | undefined;
2070
+ content?: string | undefined;
2071
+ metadata?: Record<string, unknown> | undefined;
2072
+ ephemeral?: boolean | undefined;
2073
+ delta?: string | undefined;
2074
+ phase?: "start" | "update" | "complete" | "error" | undefined;
2075
+ meta?: Record<string, unknown> | undefined;
2076
+ output?: unknown;
2077
+ duration_ms?: number | undefined;
2078
+ subrun_parent_id?: string | undefined;
2079
+ } | {
2080
+ type: "requires_user_interaction";
2081
+ id: string;
2082
+ timestamp: number;
2083
+ version: 1;
2084
+ conversation_id: string;
2085
+ turn_id: string;
2086
+ metadata?: Record<string, unknown> | undefined;
2087
+ ephemeral?: boolean | undefined;
2088
+ form?: any;
2089
+ interaction_type?: string | undefined;
2090
+ prompt?: string | undefined;
2091
+ } | {
2092
+ type: "audit_envelope";
2093
+ id: string;
2094
+ timestamp: number;
2095
+ version: 1;
2096
+ conversation_id: string;
2097
+ turn_id: string;
2098
+ envelope: {
2099
+ runId: string;
2100
+ envelopeId: string;
2101
+ ts: number;
2102
+ actor: {
2103
+ kind: "system" | "user" | "tool" | "agent" | "host" | "model";
2104
+ id?: string | undefined;
2105
+ name?: string | undefined;
2106
+ };
2107
+ action: string;
2108
+ parentRunId?: string | undefined;
2109
+ decision?: {
2110
+ outcome: "requested" | "allowed" | "denied" | "fallback" | "retry" | "cancelled" | "paused" | "resumed" | "recorded";
2111
+ metadata?: Record<string, unknown> | undefined;
2112
+ reason?: string | undefined;
2113
+ policy?: string | undefined;
2114
+ } | undefined;
2115
+ evidence?: {
2116
+ kind: string;
2117
+ summary?: string | undefined;
2118
+ metadata?: Record<string, unknown> | undefined;
2119
+ ref?: string | undefined;
2120
+ }[] | undefined;
2121
+ costDelta?: {
2122
+ tokensInput?: number | undefined;
2123
+ tokensOutput?: number | undefined;
2124
+ totalCostUsd?: number | undefined;
2125
+ latencyMs?: number | undefined;
2126
+ } | undefined;
2127
+ scope?: {
2128
+ metadata?: Record<string, unknown> | undefined;
2129
+ toolName?: string | undefined;
2130
+ conversationId?: string | undefined;
2131
+ runId?: string | undefined;
2132
+ parentRunId?: string | undefined;
2133
+ turnId?: string | undefined;
2134
+ traceId?: string | undefined;
2135
+ agentSpecId?: string | undefined;
2136
+ toolCallId?: string | undefined;
2137
+ modelId?: string | undefined;
2138
+ nodeId?: string | undefined;
2139
+ } | undefined;
2140
+ };
2141
+ metadata?: Record<string, unknown> | undefined;
2142
+ ephemeral?: boolean | undefined;
2143
+ } | {
2144
+ type: "final_answer";
2145
+ id: string;
2146
+ content: string;
2147
+ timestamp: number;
2148
+ version: 1;
2149
+ conversation_id: string;
2150
+ turn_id: string;
2151
+ is_complete: boolean;
2152
+ answer_id: string;
2153
+ reasoning_details?: unknown[] | undefined;
2154
+ metadata?: Record<string, unknown> | undefined;
2155
+ ephemeral?: boolean | undefined;
2156
+ meta?: Record<string, any> | undefined;
2157
+ } | {
2158
+ type: "final_answer_chunk";
2159
+ id: string;
2160
+ content: string;
2161
+ timestamp: number;
2162
+ version: 1;
2163
+ conversation_id: string;
2164
+ turn_id: string;
2165
+ answer_id: string;
2166
+ seq: number;
2167
+ metadata?: Record<string, unknown> | undefined;
2168
+ ephemeral?: boolean | undefined;
2169
+ is_last?: boolean | undefined;
2170
+ } | {
2171
+ type: "history_summary";
2172
+ id: string;
2173
+ content: string;
2174
+ timestamp: number;
2175
+ version: 1;
2176
+ conversation_id: string;
2177
+ turn_id: string;
2178
+ replaced_message_ids: string[];
2179
+ summary_seq: number;
2180
+ metadata?: Record<string, unknown> | undefined;
2181
+ ephemeral?: boolean | undefined;
2182
+ original_message_count?: number | undefined;
2183
+ compression_ratio?: number | undefined;
2184
+ included_old_summary?: boolean | undefined;
2185
+ } | {
2186
+ type: "error";
2187
+ id: string;
2188
+ timestamp: number;
2189
+ version: 1;
2190
+ conversation_id: string;
2191
+ turn_id: string;
2192
+ error: string;
2193
+ metadata?: Record<string, unknown> | undefined;
2194
+ ephemeral?: boolean | undefined;
2195
+ details?: any;
2196
+ error_code?: string | undefined;
2197
+ retryable?: boolean | undefined;
2198
+ } | {
2199
+ type: "control";
2200
+ id: string;
2201
+ timestamp: number;
2202
+ version: 1;
2203
+ conversation_id: string;
2204
+ turn_id: string;
2205
+ op: "truncate_after" | "replace" | "redo" | "branch";
2206
+ metadata?: Record<string, unknown> | undefined;
2207
+ reason?: string | undefined;
2208
+ ephemeral?: boolean | undefined;
2209
+ meta?: any;
2210
+ target_id?: string | undefined;
2211
+ } | {
2212
+ type: "stream_end";
2213
+ id: string;
2214
+ timestamp: number;
2215
+ version: 1;
2216
+ conversation_id: string;
2217
+ turn_id: string;
2218
+ metadata?: Record<string, unknown> | undefined;
2219
+ reason?: "complete" | "error" | "interrupted" | "timeout" | undefined;
2220
+ ephemeral?: boolean | undefined;
2221
+ reason_message?: string | undefined;
2222
+ stats?: {
2223
+ duration_ms?: number | undefined;
2224
+ total_events?: number | undefined;
2225
+ error_count?: number | undefined;
2226
+ } | undefined;
2227
+ })[]>;
2228
+ declare const createUserInputEvent: (id: string, conversationId: string, turnId: string, content: string, options?: Partial<UserInputEvent>) => UserInputEvent;
2229
+ declare const createThoughtEvent: (id: string, conversationId: string, turnId: string, content: string, options?: Partial<ThoughtEvent>) => ThoughtEvent;
2230
+ declare const createToolCallDecisionEvent: (id: string, conversationId: string, turnId: string, toolName: string, toolCallId: string, options?: Partial<ToolCallDecisionEvent>) => ToolCallDecisionEvent;
2231
+ declare const createToolProcessEvent: (id: string, conversationId: string, turnId: string, toolName: string, toolCallId: string, options?: Partial<ToolProcessEvent>) => ToolProcessEvent;
2232
+ declare const createSubRunTraceEvent: (id: string, conversationId: string, turnId: string, parentToolCallId: string, subrunId: string, kind: SubRunTraceEvent["kind"], options?: Partial<SubRunTraceEvent>) => SubRunTraceEvent;
2233
+ declare const createToolOutputEvent: (id: string, conversationId: string, turnId: string, toolName: string, toolCallId: string, output: unknown, status?: "success" | "error", options?: Partial<ToolOutputEvent>) => ToolOutputEvent;
2234
+ declare const createTodoUpdatedEvent: (id: string, conversationId: string, turnId: string, todoListId: string, todoListVersion: number, items: TodoUpdatedEvent["items"], options?: Partial<TodoUpdatedEvent>) => TodoUpdatedEvent;
2235
+ declare const createFinalAnswerEvent: (id: string, conversationId: string, turnId: string, answerId: string, content: string, options?: Partial<FinalAnswerEvent>) => FinalAnswerEvent;
2236
+ declare const createAuditEnvelopeEvent: (id: string, conversationId: string, turnId: string, envelope: AuditEnvelopeEvent["envelope"], options?: Partial<AuditEnvelopeEvent>) => AuditEnvelopeEvent;
2237
+ declare const createFinalAnswerChunkEvent: (id: string, conversationId: string, turnId: string, answerId: string, seq: number, content: string, options?: Partial<FinalAnswerChunkEvent>) => FinalAnswerChunkEvent;
2238
+ declare const createHistorySummaryEvent: (id: string, conversationId: string, turnId: string, content: string, replacedMessageIds: string[], summarySeq: number, options?: Partial<HistorySummaryEvent>) => HistorySummaryEvent;
2239
+ declare const createErrorEvent: (id: string, conversationId: string, turnId: string, error: string, options?: Partial<ErrorEvent>) => ErrorEvent;
2240
+ declare const createStreamEndEvent: (id: string, conversationId: string, turnId: string, options?: Partial<StreamEndEvent>) => StreamEndEvent;
2241
+
2242
+ interface AgentTodoItem {
2243
+ id: string;
2244
+ content: string;
2245
+ status: 'pending' | 'in_progress' | 'completed' | 'cancelled';
2246
+ }
2247
+ interface AgentTodoSnapshot {
2248
+ todoListId: string;
2249
+ version: number;
2250
+ items: AgentTodoItem[];
2251
+ }
2252
+
2253
+ export { AgentTodoItem$1 as A, BaseEvent as B, type ControlEvent as C, validateRuntimeEvent as D, type ErrorEvent as E, type FinalAnswerChunkEvent as F, validateRuntimeEvents as G, type HistorySummaryEvent as H, ProviderReasoningDetailsPayload as P, type RequiresUserInteractionEvent as R, Status as S, type ThoughtEvent as T, type UserInputEvent as U, type AgentTodoSnapshot as a, AgentTodoStatus as b, type AuditEnvelopeEvent as c, type FinalAnswerEvent as d, RuntimeEvent as e, type StreamEndEvent as f, type SubRunTraceEvent as g, type TodoUpdatedEvent as h, type ToolCallDecisionEvent as i, ToolCallDecisionPayload as j, ToolCallPhase as k, type ToolOutputEvent as l, type ToolProcessEvent as m, createAuditEnvelopeEvent as n, createErrorEvent as o, createFinalAnswerChunkEvent as p, createFinalAnswerEvent as q, createHistorySummaryEvent as r, createStreamEndEvent as s, createSubRunTraceEvent as t, createThoughtEvent as u, createTodoUpdatedEvent as v, createToolCallDecisionEvent as w, createToolOutputEvent as x, createToolProcessEvent as y, createUserInputEvent as z };