@runtypelabs/persona 3.37.0 → 4.1.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 (55) hide show
  1. package/README.md +4 -5
  2. package/dist/animations/glyph-cycle.d.cts +1 -1
  3. package/dist/animations/glyph-cycle.d.ts +1 -1
  4. package/dist/animations/{types-DgYsuwXL.d.cts → types-B_xbfvR0.d.cts} +263 -181
  5. package/dist/animations/{types-DgYsuwXL.d.ts → types-B_xbfvR0.d.ts} +263 -181
  6. package/dist/animations/wipe.d.cts +1 -1
  7. package/dist/animations/wipe.d.ts +1 -1
  8. package/dist/codegen.cjs +1 -1
  9. package/dist/codegen.js +1 -1
  10. package/dist/index.cjs +54 -52
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +328 -839
  13. package/dist/index.d.ts +328 -839
  14. package/dist/index.global.js +41 -39
  15. package/dist/index.global.js.map +1 -1
  16. package/dist/index.js +54 -52
  17. package/dist/index.js.map +1 -1
  18. package/dist/install.global.js +1 -1
  19. package/dist/install.global.js.map +1 -1
  20. package/dist/smart-dom-reader.d.cts +269 -192
  21. package/dist/smart-dom-reader.d.ts +269 -192
  22. package/dist/theme-editor-preview.cjs +55 -53
  23. package/dist/theme-editor-preview.d.cts +269 -192
  24. package/dist/theme-editor-preview.d.ts +269 -192
  25. package/dist/theme-editor-preview.js +57 -55
  26. package/dist/theme-editor.d.cts +269 -192
  27. package/dist/theme-editor.d.ts +269 -192
  28. package/dist/widget.css +14 -0
  29. package/package.json +1 -1
  30. package/src/client.test.ts +446 -1041
  31. package/src/client.ts +684 -967
  32. package/src/components/message-bubble.ts +7 -0
  33. package/src/components/tool-bubble.ts +46 -33
  34. package/src/generated/runtype-openapi-contract.ts +210 -714
  35. package/src/index-core.ts +2 -3
  36. package/src/install.test.ts +1 -34
  37. package/src/install.ts +1 -26
  38. package/src/runtime/init.test.ts +8 -67
  39. package/src/runtime/init.ts +2 -17
  40. package/src/session.test.ts +8 -8
  41. package/src/session.ts +1 -1
  42. package/src/styles/widget.css +14 -0
  43. package/src/types.ts +12 -13
  44. package/src/ui.postprocess.test.ts +107 -0
  45. package/src/ui.ts +45 -5
  46. package/src/utils/__fixtures__/unified-translator.oracle.ts +62 -14
  47. package/src/utils/copy-selection.test.ts +37 -0
  48. package/src/utils/copy-selection.ts +19 -0
  49. package/src/utils/event-stream-capture.test.ts +9 -64
  50. package/src/utils/streaming-table.test.ts +100 -0
  51. package/src/utils/streaming-table.ts +103 -0
  52. package/src/utils/sequence-buffer.test.ts +0 -256
  53. package/src/utils/sequence-buffer.ts +0 -130
  54. package/src/utils/unified-event-bridge.test.ts +0 -263
  55. package/src/utils/unified-event-bridge.ts +0 -431
@@ -7,821 +7,344 @@
7
7
  // Then regenerate this file with:
8
8
  // pnpm --filter @runtypelabs/persona generate:runtype-types
9
9
 
10
- export type RuntypeAgentSSEEvent = {
11
- agentId: string;
12
- agentName: string;
13
- config?: {
14
- enableReflection?: boolean;
15
- model?: string;
16
- };
10
+ export type RuntypeExecutionStreamEvent = ({
11
+ agentId?: string;
12
+ agentName?: string;
13
+ config?: Record<string, unknown>;
17
14
  executionId: string;
18
- maxTurns: number;
19
- seq: number;
20
- startedAt: string;
21
- type: "agent_start";
22
- } | {
23
- executionId: string;
24
- iteration: number;
25
- maxTurns: number;
15
+ flowId?: string;
16
+ flowName?: string;
17
+ kind: "agent" | "flow";
18
+ maxTurns?: number;
26
19
  seq: number;
20
+ source?: string;
27
21
  startedAt: string;
28
- totalCost?: number;
29
- type: "agent_iteration_start";
30
- } | ({
31
- executionId: string;
32
- iteration: number;
33
- role: "user" | "assistant" | "system";
34
- seq: number;
35
- turnId: string;
36
- turnIndex: number;
37
- type: "agent_turn_start";
38
- }) | ({
39
- contentType: "text" | "thinking" | "tool_input";
40
- delta: string;
41
- executionId: string;
42
- iteration: number;
43
- seq: number;
44
- turnId: string;
45
- type: "agent_turn_delta";
22
+ totalSteps?: number;
23
+ type: "execution_start";
46
24
  }) | ({
47
- completedAt: string;
48
- content?: string;
49
- cost?: number;
50
- estimatedContextBreakdown?: {
51
- categories: Record<string, {
52
- chars: number;
53
- estimatedTokens: number;
54
- }>;
55
- contextWindowSize?: number;
56
- estimatedTotalTokens: number;
57
- estimatedUtilizationPercent?: number;
58
- };
25
+ completedAt?: string;
26
+ durationMs?: number;
59
27
  executionId: string;
60
- iteration: number;
61
- role: "user" | "assistant" | "system";
28
+ failedSteps?: number;
29
+ finalOutput?: string;
30
+ iterations?: number;
31
+ kind: "agent" | "flow";
62
32
  seq: number;
63
- stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
64
- tokens?: {
33
+ stopReason?: string;
34
+ success: boolean;
35
+ successfulSteps?: number;
36
+ totalCost?: number;
37
+ totalSteps?: number;
38
+ totalTokens?: {
65
39
  input: number;
66
40
  output: number;
67
41
  };
68
- turnId: string;
69
- type: "agent_turn_complete";
42
+ type: "execution_complete";
70
43
  }) | ({
44
+ code?: string;
45
+ completedAt?: string;
46
+ error: string | {
47
+ code: string;
48
+ details?: Record<string, unknown>;
49
+ message: string;
50
+ };
71
51
  executionId: string;
72
- iteration: number;
73
- origin?: "webmcp" | "sdk";
74
- pageOrigin?: string;
75
- parameters?: Record<string, unknown>;
76
- seq: number;
77
- toolCallId: string;
78
- toolName: string;
79
- toolType: "flow" | "mcp" | "builtin" | "custom" | "external" | "advisor" | "subagent" | "local";
80
- type: "agent_tool_start";
81
- }) | {
82
- delta: string;
83
- executionId: string;
84
- iteration: number;
85
- seq: number;
86
- toolCallId: string;
87
- type: "agent_tool_delta";
88
- } | {
89
- delta: string;
90
- executionId: string;
91
- iteration: number;
92
- seq: number;
93
- toolCallId: string;
94
- type: "agent_tool_input_delta";
95
- } | {
96
- executionId: string;
97
- hiddenParameterNames?: Array<string>;
98
- iteration: number;
99
- parameters: Record<string, unknown>;
52
+ kind: "agent" | "flow";
100
53
  seq: number;
101
- toolCallId: string;
102
- toolName: string;
103
- type: "agent_tool_input_complete";
104
- } | {
105
- executionId: string;
106
- executionTime?: number;
107
- iteration: number;
108
- result?: unknown;
109
- seq: number;
110
- success: boolean;
111
- toolCallId: string;
112
- toolName: string;
113
- type: "agent_tool_complete";
114
- } | ({
115
- executionId?: string;
116
- iteration: number;
117
- media: Array<({
118
- annotations?: {
119
- audience?: Array<"user" | "assistant">;
120
- };
121
- data: string;
122
- mediaType: string;
123
- type: "media";
124
- }) | ({
125
- annotations?: {
126
- audience?: Array<"user" | "assistant">;
127
- };
128
- mediaType?: string;
129
- type: "image-url";
130
- url: string;
54
+ type: "execution_error";
55
+ upgradeUrl?: string;
131
56
  }) | ({
132
- annotations?: {
133
- audience?: Array<"user" | "assistant">;
134
- };
135
- mediaType: string;
136
- type: "file-url";
137
- url: string;
138
- })>;
139
- seq?: number;
140
- toolCallId: string;
141
- toolName: string;
142
- type: "agent_media";
143
- }) | {
144
- approvalId: string;
145
- description: string;
146
57
  executionId: string;
147
- externalAgent?: {
148
- contextId?: string;
149
- taskId?: string;
150
- };
58
+ id: string;
151
59
  iteration?: number;
152
- parameters?: Record<string, unknown>;
153
- reason?: string;
154
- seq: number;
155
- startedAt: string;
156
- timeout: number;
157
- toolCallId: string;
158
- toolName: string;
159
- toolType: string;
160
- type: "agent_approval_start";
161
- } | ({
162
- approvalId: string;
163
- completedAt: string;
164
- decision: "approved" | "denied" | "timeout";
165
- executionId: string;
166
- resolvedBy: "user" | "system";
60
+ role: "user" | "assistant" | "system";
167
61
  seq: number;
168
- type: "agent_approval_complete";
62
+ turnIndex?: number;
63
+ type: "turn_start";
169
64
  }) | ({
170
- awaitedAt: string;
171
- executionId: string;
172
- origin?: "webmcp" | "sdk";
173
- pageOrigin?: string;
174
- parameters?: Record<string, unknown>;
175
- seq: number;
176
- toolCallId?: string;
177
- toolId: string;
178
- toolName: string;
179
- type: "agent_await";
180
- }) | {
181
- completedAt: string;
65
+ completedAt?: string;
66
+ content?: string;
182
67
  cost?: number;
183
- duration?: number;
184
- estimatedContextBreakdown?: {
185
- categories: Record<string, {
186
- chars: number;
187
- estimatedTokens: number;
188
- }>;
189
- contextWindowSize?: number;
190
- estimatedTotalTokens: number;
191
- estimatedUtilizationPercent?: number;
192
- };
193
68
  executionId: string;
194
- iteration: number;
195
- output?: string;
196
- runningTotalCost?: number;
197
- seq: number;
198
- stopConditionMet: boolean;
199
- tokens?: {
200
- input: number;
201
- output: number;
202
- };
203
- toolCallsMade: number;
204
- type: "agent_iteration_complete";
205
- } | {
206
- executionId: string;
207
- iteration: number;
208
- reflection?: string;
209
- seq: number;
210
- timestamp?: string;
211
- type: "agent_reflection";
212
- } | {
213
- activatedCapabilities: Array<string>;
214
- executionId: string;
215
- iteration: number;
216
- seq: number;
217
- skill: string;
218
- timestamp?: string;
219
- toolCallId: string;
220
- type: "agent_skill_loaded";
221
- } | ({
222
- executionId: string;
223
- iteration: number;
224
- outcome: "pending_approval" | "auto_published";
225
- proposalId?: string;
226
- seq: number;
227
- skill: string;
228
- timestamp?: string;
229
- toolCallId: string;
230
- type: "agent_skill_proposed";
231
- }) | ({
232
- agentId: string;
233
- completedAt: string;
234
- duration?: number;
69
+ fallback?: {
70
+ attempts: Array<{
71
+ attempt: number;
235
72
  error?: string;
236
- executionId: string;
237
- externalAgent?: {
238
- contextId?: string;
239
- taskId?: string;
73
+ model?: string;
74
+ success: boolean;
75
+ type: "retry" | "model" | "message" | "flow";
76
+ }>;
77
+ exhausted: boolean;
78
+ model?: string;
79
+ reason?: string | null;
80
+ used: boolean;
240
81
  };
241
- finalOutput?: string;
242
- iterations: number;
82
+ id: string;
83
+ iteration?: number;
84
+ role: "user" | "assistant" | "system";
243
85
  seq: number;
244
- stopReason: "complete" | "end_turn" | "max_turns" | "max_cost" | "timeout" | "error";
245
- success: boolean;
246
- totalCost?: number;
247
- totalTokens?: {
86
+ stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
87
+ tokens?: {
248
88
  input: number;
249
89
  output: number;
250
90
  };
251
- type: "agent_complete";
91
+ type: "turn_complete";
252
92
  }) | {
253
- error: {
254
- code: string;
255
- details?: Record<string, unknown>;
256
- message: string;
257
- };
258
- executionId: string;
259
- iteration?: number;
260
- recoverable: boolean;
261
- seq: number;
262
- timestamp?: string;
263
- type: "agent_error";
264
- } | {
265
- executionId: string;
266
- seq: number;
267
- timestamp: string;
268
- type: "agent_ping";
269
- };
270
-
271
- export type RuntypeFlowSSEEvent = {
272
- executionContext?: Record<string, unknown>;
273
- executionId?: string;
274
- flowId: string;
275
- flowName?: string;
276
- input?: unknown;
277
- seq?: number;
278
- source?: string;
279
- startedAt: string;
280
- toolContext?: {
281
- executionId: string;
282
- stepId: string;
283
- toolId: string;
284
- };
285
- totalSteps?: number;
286
- type: "flow_start";
287
- } | {
288
- claudeManagedAgentId?: string;
289
- completedAt?: string;
290
- completedSteps?: number;
291
- duration?: number;
292
- executionContext?: Record<string, unknown>;
293
- executionId?: string;
294
- executionTime?: number;
295
- failedSteps?: number;
296
- finalOutput?: string;
297
- flowId?: string;
298
- flowName?: string;
299
- output?: unknown;
300
- seq?: number;
301
- source?: string;
302
- success?: boolean;
303
- successfulSteps?: number;
304
- toolContext?: {
305
- executionId: string;
306
- stepId: string;
307
- toolId: string;
308
- };
309
- totalSteps?: number;
310
- totalTokensUsed?: number;
311
- type: "flow_complete";
312
- } | ({
313
- code?: string;
314
- error: string | {
315
- code: string;
316
- message: string;
317
- stepId?: string;
318
- stepType?: string;
319
- };
320
- executionId?: string;
321
- executionTime?: number;
322
- flowId?: string;
323
- seq?: number;
324
- timestamp?: string;
325
- toolContext?: {
326
93
  executionId: string;
327
- stepId: string;
328
- toolId: string;
329
- };
330
- type: "flow_error";
331
- upgradeUrl?: string;
332
- }) | ({
333
- awaitedAt: string;
334
- executionId?: string;
335
- flowId: string;
336
- origin?: "webmcp" | "sdk";
337
- pageOrigin?: string;
338
- parameters?: Record<string, unknown>;
339
- seq?: number;
340
- toolCallId?: string;
341
- toolId?: string;
342
- toolName?: string;
343
- type: "flow_await";
344
- }) | {
345
- estimatedTokens?: number;
346
- executionId?: string;
347
- id?: string;
94
+ id: string;
348
95
  index?: number;
349
96
  name?: string;
350
97
  outputVariable?: string;
351
- seq?: number;
352
- startedAt: string;
353
- stepId?: string;
354
- stepName?: string;
98
+ seq: number;
99
+ startedAt?: string;
355
100
  stepType?: string;
356
- toolContext?: {
357
- executionId: string;
358
- stepId: string;
359
- toolId: string;
360
- };
361
101
  totalSteps?: number;
362
102
  type: "step_start";
363
- } | {
364
- delta?: string;
365
- executionId?: string;
366
- id?: string;
367
- messageId?: string;
368
- partId?: string;
369
- seq?: number;
370
- text?: string;
371
- toolContext?: {
372
- executionId: string;
373
- stepId: string;
374
- toolId: string;
375
- };
376
- toolId?: string;
377
- type: "step_delta";
378
103
  } | ({
379
104
  completedAt?: string;
380
- duration?: number;
381
105
  durationMs?: number;
382
106
  error?: string;
383
- executionId?: string;
384
- executionTime?: number;
385
- id?: string;
386
- index?: number;
107
+ executionId: string;
108
+ fallback?: {
109
+ attempts: Array<{
110
+ attempt: number;
111
+ error?: string;
112
+ model?: string;
113
+ success: boolean;
114
+ type: "retry" | "model" | "message" | "flow";
115
+ }>;
116
+ exhausted: boolean;
117
+ model?: string;
118
+ reason?: string | null;
119
+ used: boolean;
120
+ };
121
+ id: string;
387
122
  name?: string;
388
- output?: unknown;
389
123
  result?: unknown;
390
- seq?: number;
391
- stepId?: string;
392
- stepName?: string;
124
+ seq: number;
393
125
  stepType?: string;
394
126
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
395
127
  success?: boolean;
396
128
  tokensUsed?: number;
397
- toolContext?: {
398
- executionId: string;
399
- stepId: string;
400
- toolId: string;
401
- };
402
129
  type: "step_complete";
403
130
  unresolvedVariables?: Array<string>;
404
131
  }) | {
405
- error: string;
406
- executionId?: string;
407
- executionTime?: number;
408
- id?: string;
409
- index?: number;
410
- name?: string;
411
- seq?: number;
412
- stepType?: string;
413
- type: "step_error";
414
- } | {
415
- error?: string;
416
- executionId?: string;
132
+ executionId: string;
417
133
  id: string;
418
134
  index?: number;
419
135
  name?: string;
420
- seq?: number;
421
- skippedAt: string;
422
- stepType: string;
423
- totalSteps: number;
136
+ seq: number;
137
+ skippedAt?: string;
138
+ stepType?: string;
139
+ totalSteps?: number;
424
140
  type: "step_skip";
425
- when: string;
426
- } | {
427
- executionId?: string;
428
- reason?: string;
429
- seq?: number;
430
- type: "step_await";
431
- [key: string]: unknown;
141
+ when?: string;
432
142
  } | ({
433
- agentContext?: {
434
143
  executionId: string;
435
- iteration: number;
144
+ id: string;
145
+ parentToolCallId?: string;
146
+ role?: "user" | "assistant" | "system";
436
147
  seq: number;
437
- };
438
- executionId?: string;
439
- hiddenParameterNames?: Array<string>;
440
- name?: string;
441
- parameters?: Record<string, unknown>;
442
- providerOptions?: Record<string, unknown>;
443
- seq?: number;
444
- startedAt?: string;
445
148
  stepId?: string;
446
- toolCallId?: string;
447
- toolId?: string;
448
- toolName?: string;
449
- toolType: "flow" | "mcp" | "builtin" | "custom" | "external" | "advisor" | "subagent" | "local";
450
- type: "tool_start";
451
- [key: string]: unknown;
149
+ turnId?: string;
150
+ type: "text_start";
452
151
  }) | {
453
- delta?: string;
454
- executionId?: string;
455
- seq?: number;
456
- toolId?: string;
457
- type: "tool_delta";
458
- [key: string]: unknown;
459
- } | {
460
152
  delta: string;
461
- executionId?: string;
462
- seq?: number;
463
- stepId?: string;
464
- toolCallId?: string;
465
- toolId?: string;
466
- type: "tool_input_delta";
467
- } | {
468
- executionId?: string;
469
- hiddenParameterNames?: Array<string>;
470
- parameters: Record<string, unknown>;
471
- providerOptions?: Record<string, unknown>;
472
- seq?: number;
473
- stepId?: string;
474
- toolCallId?: string;
475
- toolId?: string;
476
- toolName?: string;
477
- type: "tool_input_complete";
153
+ executionId: string;
154
+ id: string;
155
+ seq: number;
156
+ type: "text_delta";
478
157
  } | {
479
- agentContext?: {
480
158
  executionId: string;
481
- iteration: number;
159
+ id: string;
160
+ seq: number;
161
+ text?: string;
162
+ type: "text_complete";
163
+ } | ({
164
+ executionId: string;
165
+ id: string;
166
+ parentToolCallId?: string;
167
+ scope?: "turn" | "loop";
168
+ seq: number;
169
+ type: "reasoning_start";
170
+ }) | {
171
+ delta: string;
172
+ executionId: string;
173
+ id: string;
174
+ seq: number;
175
+ type: "reasoning_delta";
176
+ } | ({
177
+ executionId: string;
178
+ id: string;
179
+ scope?: "turn" | "loop";
180
+ seq: number;
181
+ text?: string;
182
+ type: "reasoning_complete";
183
+ }) | ({
184
+ executionId: string;
185
+ id: string;
186
+ mediaType: string;
187
+ role?: "user" | "assistant" | "system";
482
188
  seq: number;
483
- };
484
- completedAt?: string;
485
- error?: string;
486
- executionId?: string;
487
- executionTime?: number;
488
- name?: string;
489
- result?: unknown;
490
- seq?: number;
491
- stepId?: string;
492
- success: boolean;
493
189
  toolCallId?: string;
494
- toolCost?: number;
495
- toolId?: string;
496
- toolName?: string;
497
- type: "tool_complete";
498
- } | {
499
- agentContext?: {
190
+ type: "media_start";
191
+ }) | {
192
+ delta: string;
500
193
  executionId: string;
501
- iteration: number;
194
+ id: string;
502
195
  seq: number;
503
- };
504
- error: string;
505
- executionId?: string;
506
- executionTime?: number;
507
- failedAt?: string;
508
- name: string;
509
- seq?: number;
510
- toolId: string;
511
- type: "tool_error";
196
+ type: "media_delta";
512
197
  } | {
513
- executionId?: string;
198
+ data?: string;
199
+ executionId: string;
514
200
  id: string;
515
- seq?: number;
516
- text: string;
517
- type: "chunk";
518
- } | {
519
- executionId?: string;
520
- seq?: number;
521
- type: "text_start";
522
- [key: string]: unknown;
523
- } | {
524
- executionId?: string;
525
- seq?: number;
526
- type: "text_end";
527
- [key: string]: unknown;
528
- } | {
529
- executionId?: string;
530
- seq?: number;
531
- type: "reason_start";
532
- [key: string]: unknown;
533
- } | {
534
- executionId?: string;
535
- seq?: number;
536
- type: "reason_delta";
537
- [key: string]: unknown;
538
- } | {
539
- executionId?: string;
540
- seq?: number;
541
- type: "reason_complete";
542
- [key: string]: unknown;
543
- } | {
201
+ mediaType?: string;
202
+ seq: number;
203
+ toolCallId?: string;
204
+ type: "media_complete";
205
+ url?: string;
206
+ } | ({
207
+ artifactType: "markdown" | "component";
208
+ component?: string;
544
209
  executionId?: string;
210
+ id: string;
545
211
  seq?: number;
546
- type: "source";
547
- [key: string]: unknown;
548
- } | {
212
+ title?: string;
213
+ type: "artifact_start";
214
+ }) | {
215
+ delta: string;
549
216
  executionId?: string;
217
+ id: string;
550
218
  seq?: number;
551
- type: "fallback_start";
552
- [key: string]: unknown;
219
+ type: "artifact_delta";
553
220
  } | {
221
+ component: string;
554
222
  executionId?: string;
223
+ id: string;
224
+ props: Record<string, unknown>;
555
225
  seq?: number;
556
- type: "fallback_complete";
557
- [key: string]: unknown;
226
+ type: "artifact_update";
558
227
  } | {
559
228
  executionId?: string;
229
+ id: string;
560
230
  seq?: number;
561
- type: "fallback_exhausted";
562
- [key: string]: unknown;
563
- };
564
-
565
- export type RuntypeDispatchSSEEvent = {
566
- agentId: string;
567
- agentName: string;
568
- config?: {
569
- enableReflection?: boolean;
570
- model?: string;
571
- };
572
- executionId: string;
573
- maxTurns: number;
574
- seq: number;
575
- startedAt: string;
576
- type: "agent_start";
231
+ type: "artifact_complete";
577
232
  } | {
578
233
  executionId: string;
579
- iteration: number;
580
- maxTurns: number;
234
+ id?: string;
581
235
  seq: number;
582
- startedAt: string;
583
- totalCost?: number;
584
- type: "agent_iteration_start";
236
+ sourceType?: string;
237
+ title?: string;
238
+ type: "source";
239
+ url?: string;
240
+ [key: string]: unknown;
585
241
  } | ({
586
242
  executionId: string;
587
- iteration: number;
588
- role: "user" | "assistant" | "system";
589
- seq: number;
590
- turnId: string;
591
- turnIndex: number;
592
- type: "agent_turn_start";
593
- }) | ({
594
- contentType: "text" | "thinking" | "tool_input";
595
- delta: string;
596
- executionId: string;
597
- iteration: number;
598
- seq: number;
599
- turnId: string;
600
- type: "agent_turn_delta";
601
- }) | ({
602
- completedAt: string;
603
- content?: string;
604
- cost?: number;
605
- estimatedContextBreakdown?: {
606
- categories: Record<string, {
607
- chars: number;
608
- estimatedTokens: number;
609
- }>;
610
- contextWindowSize?: number;
611
- estimatedTotalTokens: number;
612
- estimatedUtilizationPercent?: number;
613
- };
614
- executionId: string;
615
- iteration: number;
616
- role: "user" | "assistant" | "system";
617
- seq: number;
618
- stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
619
- tokens?: {
620
- input: number;
621
- output: number;
622
- };
623
- turnId: string;
624
- type: "agent_turn_complete";
625
- }) | ({
626
- executionId: string;
627
- iteration: number;
243
+ hiddenParameterNames?: Array<string>;
244
+ iteration?: number;
628
245
  origin?: "webmcp" | "sdk";
629
246
  pageOrigin?: string;
630
247
  parameters?: Record<string, unknown>;
631
248
  seq: number;
249
+ startedAt?: string;
250
+ stepId?: string;
632
251
  toolCallId: string;
633
252
  toolName: string;
634
- toolType: "flow" | "mcp" | "builtin" | "custom" | "external" | "advisor" | "subagent" | "local";
635
- type: "agent_tool_start";
253
+ toolType: string;
254
+ type: "tool_start";
636
255
  }) | {
637
256
  delta: string;
638
257
  executionId: string;
639
- iteration: number;
640
258
  seq: number;
641
259
  toolCallId: string;
642
- type: "agent_tool_delta";
260
+ type: "tool_input_delta";
643
261
  } | {
644
- delta: string;
645
262
  executionId: string;
646
- iteration: number;
263
+ hiddenParameterNames?: Array<string>;
264
+ parameters: Record<string, unknown>;
647
265
  seq: number;
648
266
  toolCallId: string;
649
- type: "agent_tool_input_delta";
267
+ toolName?: string;
268
+ type: "tool_input_complete";
650
269
  } | {
270
+ delta: string;
651
271
  executionId: string;
652
- hiddenParameterNames?: Array<string>;
653
- iteration: number;
654
- parameters: Record<string, unknown>;
655
272
  seq: number;
656
273
  toolCallId: string;
657
- toolName: string;
658
- type: "agent_tool_input_complete";
274
+ type: "tool_output_delta";
659
275
  } | {
276
+ error?: string;
660
277
  executionId: string;
661
278
  executionTime?: number;
662
- iteration: number;
279
+ iteration?: number;
663
280
  result?: unknown;
664
281
  seq: number;
282
+ stepId?: string;
665
283
  success: boolean;
666
284
  toolCallId: string;
667
- toolName: string;
668
- type: "agent_tool_complete";
669
- } | ({
670
- executionId?: string;
671
- iteration: number;
672
- media: Array<({
673
- annotations?: {
674
- audience?: Array<"user" | "assistant">;
675
- };
676
- data: string;
677
- mediaType: string;
678
- type: "media";
679
- }) | ({
680
- annotations?: {
681
- audience?: Array<"user" | "assistant">;
682
- };
683
- mediaType?: string;
684
- type: "image-url";
685
- url: string;
686
- }) | ({
687
- annotations?: {
688
- audience?: Array<"user" | "assistant">;
689
- };
690
- mediaType: string;
691
- type: "file-url";
692
- url: string;
693
- })>;
694
- seq?: number;
695
- toolCallId: string;
696
- toolName: string;
697
- type: "agent_media";
698
- }) | {
285
+ toolName?: string;
286
+ type: "tool_complete";
287
+ } | {
699
288
  approvalId: string;
700
- description: string;
289
+ description?: string;
701
290
  executionId: string;
702
- externalAgent?: {
703
- contextId?: string;
704
- taskId?: string;
705
- };
706
291
  iteration?: number;
707
292
  parameters?: Record<string, unknown>;
708
293
  reason?: string;
709
294
  seq: number;
710
- startedAt: string;
711
- timeout: number;
712
- toolCallId: string;
295
+ startedAt?: string;
296
+ subagent?: {
297
+ agentName?: string;
713
298
  toolName: string;
714
- toolType: string;
715
- type: "agent_approval_start";
299
+ };
300
+ timeout?: number;
301
+ toolCallId?: string;
302
+ toolName: string;
303
+ toolType?: string;
304
+ type: "approval_start";
716
305
  } | ({
717
306
  approvalId: string;
718
- completedAt: string;
307
+ completedAt?: string;
719
308
  decision: "approved" | "denied" | "timeout";
720
309
  executionId: string;
721
- resolvedBy: "user" | "system";
310
+ resolvedBy?: "user" | "system";
722
311
  seq: number;
723
- type: "agent_approval_complete";
312
+ type: "approval_complete";
724
313
  }) | ({
725
- awaitedAt: string;
314
+ awaitedAt?: string;
726
315
  executionId: string;
727
316
  origin?: "webmcp" | "sdk";
728
317
  pageOrigin?: string;
729
318
  parameters?: Record<string, unknown>;
730
319
  seq: number;
731
320
  toolCallId?: string;
732
- toolId: string;
733
- toolName: string;
734
- type: "agent_await";
735
- }) | {
736
- completedAt: string;
737
- cost?: number;
738
- duration?: number;
739
- estimatedContextBreakdown?: {
740
- categories: Record<string, {
741
- chars: number;
742
- estimatedTokens: number;
743
- }>;
744
- contextWindowSize?: number;
745
- estimatedTotalTokens: number;
746
- estimatedUtilizationPercent?: number;
747
- };
748
- executionId: string;
749
- iteration: number;
750
- output?: string;
751
- runningTotalCost?: number;
752
- seq: number;
753
- stopConditionMet: boolean;
754
- tokens?: {
755
- input: number;
756
- output: number;
757
- };
758
- toolCallsMade: number;
759
- type: "agent_iteration_complete";
760
- } | {
761
- executionId: string;
762
- iteration: number;
763
- reflection?: string;
764
- seq: number;
765
- timestamp?: string;
766
- type: "agent_reflection";
767
- } | {
768
- activatedCapabilities: Array<string>;
769
- executionId: string;
770
- iteration: number;
771
- seq: number;
772
- skill: string;
773
- timestamp?: string;
774
- toolCallId: string;
775
- type: "agent_skill_loaded";
776
- } | ({
777
- executionId: string;
778
- iteration: number;
779
- outcome: "pending_approval" | "auto_published";
780
- proposalId?: string;
781
- seq: number;
782
- skill: string;
783
- timestamp?: string;
784
- toolCallId: string;
785
- type: "agent_skill_proposed";
321
+ toolId?: string;
322
+ toolName?: string;
323
+ type: "await";
786
324
  }) | ({
787
- agentId: string;
788
- completedAt: string;
789
- duration?: number;
790
- error?: string;
791
- executionId: string;
792
- externalAgent?: {
793
- contextId?: string;
794
- taskId?: string;
795
- };
796
- finalOutput?: string;
797
- iterations: number;
798
- seq: number;
799
- stopReason: "complete" | "end_turn" | "max_turns" | "max_cost" | "timeout" | "error";
800
- success: boolean;
801
- totalCost?: number;
802
- totalTokens?: {
803
- input: number;
804
- output: number;
805
- };
806
- type: "agent_complete";
807
- }) | {
808
- error: {
325
+ error: string | {
809
326
  code: string;
810
327
  details?: Record<string, unknown>;
811
328
  message: string;
812
329
  };
813
330
  executionId: string;
814
- iteration?: number;
815
- recoverable: boolean;
331
+ recoverable?: boolean;
816
332
  seq: number;
817
- timestamp?: string;
818
- type: "agent_error";
819
- } | {
333
+ type: "error";
334
+ }) | {
820
335
  executionId: string;
821
336
  seq: number;
822
337
  timestamp: string;
823
- type: "agent_ping";
338
+ type: "ping";
824
339
  } | {
340
+ executionId?: string;
341
+ name: string;
342
+ seq?: number;
343
+ type: "custom";
344
+ value?: unknown;
345
+ };
346
+
347
+ export type RuntypeFlowSSEEvent = {
825
348
  executionContext?: Record<string, unknown>;
826
349
  executionId?: string;
827
350
  flowId: string;
@@ -1113,40 +636,13 @@ export type RuntypeDispatchSSEEvent = {
1113
636
  seq?: number;
1114
637
  type: "fallback_exhausted";
1115
638
  [key: string]: unknown;
1116
- } | ({
1117
- artifactType: "markdown" | "component";
1118
- component?: string;
1119
- id: string;
1120
- title?: string;
1121
- type: "artifact_start";
1122
- }) | {
1123
- delta: string;
1124
- id: string;
1125
- type: "artifact_delta";
1126
- } | {
1127
- component: string;
1128
- id: string;
1129
- props: Record<string, unknown>;
1130
- type: "artifact_update";
1131
- } | {
1132
- id: string;
1133
- type: "artifact_complete";
1134
- } | ({
1135
- artifactType?: "markdown" | "component";
1136
- component?: string;
1137
- content?: string;
1138
- id?: string;
1139
- props?: Record<string, unknown>;
1140
- title?: string;
1141
- type: "artifact";
1142
- [key: string]: unknown;
1143
- });
639
+ };
1144
640
 
1145
641
  export type RuntypeStreamEventOf<U, T extends string> = Extract<U, { type: T }>;
1146
642
 
1147
- export type RuntypeAgentTurnCompleteEvent = RuntypeStreamEventOf<
1148
- RuntypeAgentSSEEvent,
1149
- "agent_turn_complete"
643
+ export type RuntypeTurnCompleteEvent = RuntypeStreamEventOf<
644
+ RuntypeExecutionStreamEvent,
645
+ "turn_complete"
1150
646
  >;
1151
647
 
1152
648
  export type RuntypeStepCompleteEvent = RuntypeStreamEventOf<
@@ -1155,7 +651,7 @@ export type RuntypeStepCompleteEvent = RuntypeStreamEventOf<
1155
651
  >;
1156
652
 
1157
653
  export type RuntypeStopReasonKind = NonNullable<
1158
- RuntypeAgentTurnCompleteEvent["stopReason"] | RuntypeStepCompleteEvent["stopReason"]
654
+ RuntypeTurnCompleteEvent["stopReason"] | RuntypeStepCompleteEvent["stopReason"]
1159
655
  >;
1160
656
 
1161
657
  export type RuntypeClientInitRequest = {
@@ -1221,7 +717,7 @@ export type RuntypeClientChatRequest = {
1221
717
  turnId?: string;
1222
718
  };
1223
719
 
1224
- export type RuntypeClientChatStreamEvent = RuntypeFlowSSEEvent;
720
+ export type RuntypeClientChatStreamEvent = RuntypeExecutionStreamEvent;
1225
721
 
1226
722
  export type RuntypeClientResumeRequest = {
1227
723
  executionId: string;
@@ -1250,7 +746,7 @@ export type RuntypeClientResumeRequest = {
1250
746
  toolOutputs?: Record<string, unknown>;
1251
747
  };
1252
748
 
1253
- export type RuntypeClientResumeStreamEvent = RuntypeDispatchSSEEvent;
749
+ export type RuntypeClientResumeStreamEvent = RuntypeExecutionStreamEvent;
1254
750
 
1255
751
  export type RuntypeClientFeedbackRequest = {
1256
752
  comment?: string;