@runtypelabs/persona 4.21.1 → 4.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/animations/glyph-cycle.d.cts +1 -1
  2. package/dist/animations/glyph-cycle.d.ts +1 -1
  3. package/dist/animations/{types-B_JdVK9o.d.cts → types-9Vxm-PPz.d.cts} +136 -6
  4. package/dist/animations/{types-B_JdVK9o.d.ts → types-9Vxm-PPz.d.ts} +136 -6
  5. package/dist/animations/wipe.d.cts +1 -1
  6. package/dist/animations/wipe.d.ts +1 -1
  7. package/dist/animations-extra.d.cts +136 -6
  8. package/dist/animations-extra.d.ts +136 -6
  9. package/dist/{approval-ui-RNNBR5R3.js → approval-ui-K7R5Q5OC.js} +1 -1
  10. package/dist/approval-ui.cjs +2 -2
  11. package/dist/approval-ui.d.cts +221 -16
  12. package/dist/approval-ui.d.ts +221 -16
  13. package/dist/approval-ui.js +2 -2
  14. package/dist/artifacts-ui-F4N6VMKF.js +7 -0
  15. package/dist/artifacts-ui.cjs +1 -1
  16. package/dist/artifacts-ui.d.cts +221 -16
  17. package/dist/artifacts-ui.d.ts +221 -16
  18. package/dist/artifacts-ui.js +1 -1
  19. package/dist/chunk-NQLDCJAP.js +4 -0
  20. package/dist/codegen.cjs +1 -1
  21. package/dist/codegen.js +1 -1
  22. package/dist/context-mentions.d.cts +221 -16
  23. package/dist/context-mentions.d.ts +221 -16
  24. package/dist/event-stream-view-GL3ADRY2.js +1 -0
  25. package/dist/event-stream-view.cjs +1 -1
  26. package/dist/event-stream-view.d.cts +221 -16
  27. package/dist/event-stream-view.d.ts +221 -16
  28. package/dist/event-stream-view.js +1 -1
  29. package/dist/forms-ui.d.cts +234 -25
  30. package/dist/forms-ui.d.ts +234 -25
  31. package/dist/history-view.d.cts +136 -6
  32. package/dist/history-view.d.ts +136 -6
  33. package/dist/index.cjs +70 -70
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +302 -32
  36. package/dist/index.d.ts +302 -32
  37. package/dist/index.global.js +54 -54
  38. package/dist/index.global.js.map +1 -1
  39. package/dist/index.js +69 -69
  40. package/dist/index.js.map +1 -1
  41. package/dist/launcher.global.js +2 -2
  42. package/dist/launcher.global.js.map +1 -1
  43. package/dist/session-reconnect.d.cts +221 -16
  44. package/dist/session-reconnect.d.ts +221 -16
  45. package/dist/smart-dom-reader.d.cts +221 -16
  46. package/dist/smart-dom-reader.d.ts +221 -16
  47. package/dist/testing.cjs +3 -3
  48. package/dist/testing.d.cts +3 -4
  49. package/dist/testing.d.ts +3 -4
  50. package/dist/testing.js +3 -3
  51. package/dist/theme-editor-preview.cjs +73 -73
  52. package/dist/theme-editor-preview.d.cts +221 -16
  53. package/dist/theme-editor-preview.d.ts +221 -16
  54. package/dist/theme-editor-preview.js +51 -51
  55. package/dist/theme-editor.cjs +4 -4
  56. package/dist/theme-editor.d.cts +221 -16
  57. package/dist/theme-editor.d.ts +221 -16
  58. package/dist/theme-editor.js +2 -2
  59. package/dist/theme-reference.cjs +1 -1
  60. package/dist/theme-reference.d.cts +65 -1
  61. package/dist/theme-reference.d.ts +65 -1
  62. package/dist/theme-reference.js +1 -1
  63. package/dist/voice-runtime.d.cts +6 -2
  64. package/dist/voice-runtime.d.ts +6 -2
  65. package/dist/webmcp-polyfill.js +1 -4
  66. package/dist/webmcp-runtime-JI7T4QYF.js +6 -0
  67. package/dist/webmcp-runtime.cjs +2 -2
  68. package/dist/webmcp-runtime.d.cts +34 -2
  69. package/dist/webmcp-runtime.d.ts +34 -2
  70. package/dist/webmcp-runtime.js +2 -2
  71. package/package.json +2 -2
  72. package/src/ask-user-question-tool.ts +1 -1
  73. package/src/client-history-rest.test.ts +2 -1
  74. package/src/client-visitor-history.test.ts +20 -4
  75. package/src/client.composer-options.test.ts +1 -1
  76. package/src/client.interrupt.test.ts +2 -2
  77. package/src/client.test.ts +477 -915
  78. package/src/client.ts +134 -494
  79. package/src/client.unified-tools.test.ts +76 -0
  80. package/src/components/artifact-preview.ts +5 -0
  81. package/src/components/event-stream-badge-theming.test.ts +162 -0
  82. package/src/components/event-stream-view.test.ts +76 -76
  83. package/src/components/event-stream-view.ts +55 -20
  84. package/src/components/tool-bubble.test.ts +12 -0
  85. package/src/components/tool-bubble.ts +13 -2
  86. package/src/event-stream-view-bundle.test.ts +2 -2
  87. package/src/generated/runtype-openapi-contract.ts +137 -1
  88. package/src/index-core.ts +2 -0
  89. package/src/internal/runtype-history-provider.test.ts +2 -2
  90. package/src/runtime/init.registry.test.ts +56 -0
  91. package/src/runtime/init.ts +17 -0
  92. package/src/session-history.test.ts +1 -1
  93. package/src/session.quote.test.ts +1 -1
  94. package/src/session.resubmit-from.test.ts +1 -1
  95. package/src/session.test.ts +5 -5
  96. package/src/session.ts +95 -36
  97. package/src/suggest-replies-tool.ts +1 -1
  98. package/src/testing/mock-stream.test.ts +37 -16
  99. package/src/testing/mock-stream.ts +14 -9
  100. package/src/types/theme.ts +41 -1
  101. package/src/types.ts +57 -15
  102. package/src/ui.ask-user-question-plugin.test.ts +7 -7
  103. package/src/ui.composer-defer-one.test.ts +6 -34
  104. package/src/ui.composer-draft-persistence.test.ts +1 -1
  105. package/src/ui.composer-quote.test.ts +1 -1
  106. package/src/ui.message-history-actions.test.ts +1 -1
  107. package/src/ui.reasoning-display.test.ts +136 -2
  108. package/src/ui.streaming-coalescing.test.ts +10 -13
  109. package/src/ui.ts +101 -35
  110. package/src/ui.typing-indicator.test.ts +216 -0
  111. package/src/ui.voice-custom-provider.test.ts +211 -0
  112. package/src/utils/__snapshots__/tokens-parity.test.ts.snap +1740 -0
  113. package/src/utils/event-stream-buffer.test.ts +13 -13
  114. package/src/utils/event-stream-capture.test.ts +20 -20
  115. package/src/utils/formatting.ts +22 -0
  116. package/src/utils/theme.ts +16 -0
  117. package/src/utils/throughput-tracker.test.ts +100 -142
  118. package/src/utils/throughput-tracker.ts +18 -132
  119. package/src/utils/tokens.ts +59 -0
  120. package/src/utils/voice-support.ts +18 -1
  121. package/src/voice/voice-turn-tracker.ts +18 -0
  122. package/src/webmcp-bridge.test.ts +132 -23
  123. package/src/webmcp-bridge.ts +27 -3
  124. package/src/webmcp-runtime-entry.ts +71 -11
  125. package/dist/artifacts-ui-J6AKUGTS.js +0 -7
  126. package/dist/chunk-HBE7LFNT.js +0 -4
  127. package/dist/event-stream-view-73NWKWVQ.js +0 -1
  128. package/dist/webmcp-runtime-P3CHZRHF.js +0 -6
  129. package/src/utils/__fixtures__/unified-translator.oracle.ts +0 -717
@@ -98,6 +98,11 @@ type RuntypeExecutionStreamEvent = ({
98
98
  iteration?: number;
99
99
  role: "user" | "assistant" | "system";
100
100
  seq: number;
101
+ subagent?: {
102
+ agentName?: string;
103
+ parentToolCallId?: string;
104
+ toolName: string;
105
+ };
101
106
  turnIndex?: number;
102
107
  type: "turn_start";
103
108
  }) | ({
@@ -132,12 +137,61 @@ type RuntypeExecutionStreamEvent = ({
132
137
  role: "user" | "assistant" | "system";
133
138
  seq: number;
134
139
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
140
+ subagent?: {
141
+ agentName?: string;
142
+ parentToolCallId?: string;
143
+ toolName: string;
144
+ };
135
145
  tokens?: {
136
146
  input: number;
137
147
  output: number;
138
148
  };
139
149
  type: "turn_complete";
140
150
  }) | {
151
+ executionId: string;
152
+ id: string;
153
+ iteration?: number;
154
+ model?: string;
155
+ ordinal: number;
156
+ provider?: string;
157
+ seq: number;
158
+ startedAt?: string;
159
+ stepId?: string;
160
+ subagent?: {
161
+ agentName?: string;
162
+ parentToolCallId?: string;
163
+ toolName: string;
164
+ };
165
+ turnId?: string;
166
+ type: "model_call_start";
167
+ } | {
168
+ completedAt?: string;
169
+ cost?: number;
170
+ durationMs?: number;
171
+ executionId: string;
172
+ finishReason?: string;
173
+ id: string;
174
+ iteration?: number;
175
+ model?: string;
176
+ ordinal: number;
177
+ provider?: string;
178
+ responseModel?: string;
179
+ seq: number;
180
+ subagent?: {
181
+ agentName?: string;
182
+ parentToolCallId?: string;
183
+ toolName: string;
184
+ };
185
+ success?: boolean;
186
+ tokens?: {
187
+ cacheRead?: number;
188
+ cacheWrite?: number;
189
+ input: number;
190
+ output: number;
191
+ };
192
+ turnId?: string;
193
+ type: "model_call_complete";
194
+ } | {
141
195
  executionId: string;
142
196
  id: string;
143
197
  index?: number;
@@ -146,6 +200,11 @@ type RuntypeExecutionStreamEvent = ({
146
200
  seq: number;
147
201
  startedAt?: string;
148
202
  stepType?: string;
203
+ subagent?: {
204
+ agentName?: string;
205
+ parentToolCallId?: string;
206
+ toolName: string;
207
+ };
149
208
  totalSteps?: number;
150
209
  type: "step_start";
151
210
  } | ({
@@ -173,6 +232,11 @@ type RuntypeExecutionStreamEvent = ({
173
232
  seq: number;
174
233
  stepType?: string;
175
234
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
235
+ subagent?: {
236
+ agentName?: string;
237
+ parentToolCallId?: string;
238
+ toolName: string;
239
+ };
176
240
  success?: boolean;
177
241
  tokensUsed?: number;
178
242
  type: "step_complete";
@@ -195,6 +259,11 @@ type RuntypeExecutionStreamEvent = ({
195
259
  role?: "user" | "assistant" | "system";
196
260
  seq: number;
197
261
  stepId?: string;
262
+ subagent?: {
263
+ agentName?: string;
264
+ parentToolCallId?: string;
265
+ toolName: string;
266
+ };
198
267
  turnId?: string;
199
268
  type: "text_start";
200
269
  }) | {
@@ -202,11 +271,21 @@ type RuntypeExecutionStreamEvent = ({
202
271
  executionId: string;
203
272
  id: string;
204
273
  seq: number;
274
+ subagent?: {
275
+ agentName?: string;
276
+ parentToolCallId?: string;
277
+ toolName: string;
278
+ };
205
279
  type: "text_delta";
206
280
  } | {
207
281
  executionId: string;
208
282
  id: string;
209
283
  seq: number;
284
+ subagent?: {
285
+ agentName?: string;
286
+ parentToolCallId?: string;
287
+ toolName: string;
288
+ };
210
289
  text?: string;
211
290
  type: "text_complete";
212
291
  } | ({
@@ -215,18 +294,33 @@ type RuntypeExecutionStreamEvent = ({
215
294
  parentToolCallId?: string;
216
295
  scope?: "turn" | "loop";
217
296
  seq: number;
297
+ subagent?: {
298
+ agentName?: string;
299
+ parentToolCallId?: string;
300
+ toolName: string;
301
+ };
218
302
  type: "reasoning_start";
219
303
  }) | {
220
304
  delta: string;
221
305
  executionId: string;
222
306
  id: string;
223
307
  seq: number;
308
+ subagent?: {
309
+ agentName?: string;
310
+ parentToolCallId?: string;
311
+ toolName: string;
312
+ };
224
313
  type: "reasoning_delta";
225
314
  } | ({
226
315
  executionId: string;
227
316
  id: string;
228
317
  scope?: "turn" | "loop";
229
318
  seq: number;
319
+ subagent?: {
320
+ agentName?: string;
321
+ parentToolCallId?: string;
322
+ toolName: string;
323
+ };
230
324
  text?: string;
231
325
  type: "reasoning_complete";
232
326
  }) | ({
@@ -319,6 +413,11 @@ type RuntypeExecutionStreamEvent = ({
319
413
  seq: number;
320
414
  startedAt?: string;
321
415
  stepId?: string;
416
+ subagent?: {
417
+ agentName?: string;
418
+ parentToolCallId?: string;
419
+ toolName: string;
420
+ };
322
421
  toolCallId: string;
323
422
  toolName: string;
324
423
  toolType: string;
@@ -327,6 +426,11 @@ type RuntypeExecutionStreamEvent = ({
327
426
  delta: string;
328
427
  executionId: string;
329
428
  seq: number;
429
+ subagent?: {
430
+ agentName?: string;
431
+ parentToolCallId?: string;
432
+ toolName: string;
433
+ };
330
434
  toolCallId: string;
331
435
  type: "tool_input_delta";
332
436
  } | {
@@ -334,6 +438,11 @@ type RuntypeExecutionStreamEvent = ({
334
438
  hiddenParameterNames?: Array<string>;
335
439
  parameters: Record<string, unknown>;
336
440
  seq: number;
441
+ subagent?: {
442
+ agentName?: string;
443
+ parentToolCallId?: string;
444
+ toolName: string;
445
+ };
337
446
  toolCallId: string;
338
447
  toolName?: string;
339
448
  type: "tool_input_complete";
@@ -351,6 +460,11 @@ type RuntypeExecutionStreamEvent = ({
351
460
  result?: unknown;
352
461
  seq: number;
353
462
  stepId?: string;
463
+ subagent?: {
464
+ agentName?: string;
465
+ parentToolCallId?: string;
466
+ toolName: string;
467
+ };
354
468
  success: boolean;
355
469
  toolCallId: string;
356
470
  toolCost?: number;
@@ -430,6 +544,19 @@ type RuntypeExecutionStreamEvent = ({
430
544
  recoverable?: boolean;
431
545
  seq: number;
432
546
  type: "error";
547
+ }) | ({
548
+ epoch: number;
549
+ executionId: string;
550
+ kind: "compaction";
551
+ outcome?: "ok" | "failed" | "gap" | "skipped";
552
+ phase: "start" | "complete";
553
+ reason: "threshold" | "overflow" | "manual" | "surface_policy" | "provider_mismatch";
554
+ seq: number;
555
+ strategy: "provider_native" | "summary";
556
+ tier: number;
557
+ tokensAfter?: number;
558
+ tokensBefore?: number;
559
+ type: "context_notice";
433
560
  }) | {
434
561
  executionId: string;
435
562
  seq: number;
@@ -641,15 +768,15 @@ type AgentMessageMetadata = {
641
768
  */
642
769
  parentStepId?: string;
643
770
  /**
644
- * Set to `true` on a tool-variant message produced from a `step_await`
771
+ * Set to `true` on a tool-variant message produced from an `await`
645
772
  * event (`awaitReason: "local_tool_required"`). Signals to UI code that
646
773
  * the tool call is a LOCAL tool and the server is paused waiting for a
647
774
  * `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
648
775
  */
649
776
  awaitingLocalTool?: boolean;
650
777
  /**
651
- * The provider per-call id (`toolu_…`) carried on the `step_await` /
652
- * `flow_await` events for a LOCAL tool (core#3878). Present only when the
778
+ * The provider per-call id (`toolu_…`) carried on the `await`
779
+ * event for a LOCAL tool (core#3878). Present only when the
653
780
  * server emits it. Two PARALLEL calls to the same tool in one turn share a
654
781
  * `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
655
782
  * so this is the key the widget batches a single `/resume` on: preferred
@@ -959,7 +1086,7 @@ type AgentWidgetReasoning = {
959
1086
  /**
960
1087
  * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
961
1088
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
962
- * replaced the legacy `agent_reflection` event). Absent for legacy streams.
1089
+ * replaced the legacy `agent_reflection` event). Optional when the stream does not specify a scope.
963
1090
  */
964
1091
  scope?: "turn" | "loop";
965
1092
  startedAt?: number;
@@ -973,6 +1100,9 @@ type AgentWidgetToolCall = {
973
1100
  args?: unknown;
974
1101
  chunks?: string[];
975
1102
  result?: unknown;
1103
+ /** Whether the tool succeeded; failure does not necessarily end the execution. */
1104
+ success?: boolean;
1105
+ error?: string;
976
1106
  duration?: number;
977
1107
  startedAt?: number;
978
1108
  completedAt?: number;
@@ -1003,7 +1133,7 @@ type AgentWidgetApproval = {
1003
1133
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
1004
1134
  /**
1005
1135
  * Per-turn / per-step stop reason emitted by the runtime on
1006
- * `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
1136
+ * `turn_complete` and `step_complete` SSE events. The vocabulary is
1007
1137
  * owned by the upstream Runtype API: do not extend without coordination.
1008
1138
  *
1009
1139
  * - `end_turn`: natural completion (no affordance needed)
@@ -1134,7 +1264,7 @@ type AgentWidgetMessage = {
1134
1264
  */
1135
1265
  agentMetadata?: AgentMessageMetadata;
1136
1266
  /**
1137
- * Per-turn stop reason reported by the runtime on `agent_turn_complete`
1267
+ * Per-turn stop reason reported by the runtime on `turn_complete`
1138
1268
  * (agent-loop path) or the last `step_complete` for a prompt step
1139
1269
  * (dispatch / flow path). Absent when the API did not report a value.
1140
1270
  *
@@ -98,6 +98,11 @@ type RuntypeExecutionStreamEvent = ({
98
98
  iteration?: number;
99
99
  role: "user" | "assistant" | "system";
100
100
  seq: number;
101
+ subagent?: {
102
+ agentName?: string;
103
+ parentToolCallId?: string;
104
+ toolName: string;
105
+ };
101
106
  turnIndex?: number;
102
107
  type: "turn_start";
103
108
  }) | ({
@@ -132,12 +137,61 @@ type RuntypeExecutionStreamEvent = ({
132
137
  role: "user" | "assistant" | "system";
133
138
  seq: number;
134
139
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
140
+ subagent?: {
141
+ agentName?: string;
142
+ parentToolCallId?: string;
143
+ toolName: string;
144
+ };
135
145
  tokens?: {
136
146
  input: number;
137
147
  output: number;
138
148
  };
139
149
  type: "turn_complete";
140
150
  }) | {
151
+ executionId: string;
152
+ id: string;
153
+ iteration?: number;
154
+ model?: string;
155
+ ordinal: number;
156
+ provider?: string;
157
+ seq: number;
158
+ startedAt?: string;
159
+ stepId?: string;
160
+ subagent?: {
161
+ agentName?: string;
162
+ parentToolCallId?: string;
163
+ toolName: string;
164
+ };
165
+ turnId?: string;
166
+ type: "model_call_start";
167
+ } | {
168
+ completedAt?: string;
169
+ cost?: number;
170
+ durationMs?: number;
171
+ executionId: string;
172
+ finishReason?: string;
173
+ id: string;
174
+ iteration?: number;
175
+ model?: string;
176
+ ordinal: number;
177
+ provider?: string;
178
+ responseModel?: string;
179
+ seq: number;
180
+ subagent?: {
181
+ agentName?: string;
182
+ parentToolCallId?: string;
183
+ toolName: string;
184
+ };
185
+ success?: boolean;
186
+ tokens?: {
187
+ cacheRead?: number;
188
+ cacheWrite?: number;
189
+ input: number;
190
+ output: number;
191
+ };
192
+ turnId?: string;
193
+ type: "model_call_complete";
194
+ } | {
141
195
  executionId: string;
142
196
  id: string;
143
197
  index?: number;
@@ -146,6 +200,11 @@ type RuntypeExecutionStreamEvent = ({
146
200
  seq: number;
147
201
  startedAt?: string;
148
202
  stepType?: string;
203
+ subagent?: {
204
+ agentName?: string;
205
+ parentToolCallId?: string;
206
+ toolName: string;
207
+ };
149
208
  totalSteps?: number;
150
209
  type: "step_start";
151
210
  } | ({
@@ -173,6 +232,11 @@ type RuntypeExecutionStreamEvent = ({
173
232
  seq: number;
174
233
  stepType?: string;
175
234
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
235
+ subagent?: {
236
+ agentName?: string;
237
+ parentToolCallId?: string;
238
+ toolName: string;
239
+ };
176
240
  success?: boolean;
177
241
  tokensUsed?: number;
178
242
  type: "step_complete";
@@ -195,6 +259,11 @@ type RuntypeExecutionStreamEvent = ({
195
259
  role?: "user" | "assistant" | "system";
196
260
  seq: number;
197
261
  stepId?: string;
262
+ subagent?: {
263
+ agentName?: string;
264
+ parentToolCallId?: string;
265
+ toolName: string;
266
+ };
198
267
  turnId?: string;
199
268
  type: "text_start";
200
269
  }) | {
@@ -202,11 +271,21 @@ type RuntypeExecutionStreamEvent = ({
202
271
  executionId: string;
203
272
  id: string;
204
273
  seq: number;
274
+ subagent?: {
275
+ agentName?: string;
276
+ parentToolCallId?: string;
277
+ toolName: string;
278
+ };
205
279
  type: "text_delta";
206
280
  } | {
207
281
  executionId: string;
208
282
  id: string;
209
283
  seq: number;
284
+ subagent?: {
285
+ agentName?: string;
286
+ parentToolCallId?: string;
287
+ toolName: string;
288
+ };
210
289
  text?: string;
211
290
  type: "text_complete";
212
291
  } | ({
@@ -215,18 +294,33 @@ type RuntypeExecutionStreamEvent = ({
215
294
  parentToolCallId?: string;
216
295
  scope?: "turn" | "loop";
217
296
  seq: number;
297
+ subagent?: {
298
+ agentName?: string;
299
+ parentToolCallId?: string;
300
+ toolName: string;
301
+ };
218
302
  type: "reasoning_start";
219
303
  }) | {
220
304
  delta: string;
221
305
  executionId: string;
222
306
  id: string;
223
307
  seq: number;
308
+ subagent?: {
309
+ agentName?: string;
310
+ parentToolCallId?: string;
311
+ toolName: string;
312
+ };
224
313
  type: "reasoning_delta";
225
314
  } | ({
226
315
  executionId: string;
227
316
  id: string;
228
317
  scope?: "turn" | "loop";
229
318
  seq: number;
319
+ subagent?: {
320
+ agentName?: string;
321
+ parentToolCallId?: string;
322
+ toolName: string;
323
+ };
230
324
  text?: string;
231
325
  type: "reasoning_complete";
232
326
  }) | ({
@@ -319,6 +413,11 @@ type RuntypeExecutionStreamEvent = ({
319
413
  seq: number;
320
414
  startedAt?: string;
321
415
  stepId?: string;
416
+ subagent?: {
417
+ agentName?: string;
418
+ parentToolCallId?: string;
419
+ toolName: string;
420
+ };
322
421
  toolCallId: string;
323
422
  toolName: string;
324
423
  toolType: string;
@@ -327,6 +426,11 @@ type RuntypeExecutionStreamEvent = ({
327
426
  delta: string;
328
427
  executionId: string;
329
428
  seq: number;
429
+ subagent?: {
430
+ agentName?: string;
431
+ parentToolCallId?: string;
432
+ toolName: string;
433
+ };
330
434
  toolCallId: string;
331
435
  type: "tool_input_delta";
332
436
  } | {
@@ -334,6 +438,11 @@ type RuntypeExecutionStreamEvent = ({
334
438
  hiddenParameterNames?: Array<string>;
335
439
  parameters: Record<string, unknown>;
336
440
  seq: number;
441
+ subagent?: {
442
+ agentName?: string;
443
+ parentToolCallId?: string;
444
+ toolName: string;
445
+ };
337
446
  toolCallId: string;
338
447
  toolName?: string;
339
448
  type: "tool_input_complete";
@@ -351,6 +460,11 @@ type RuntypeExecutionStreamEvent = ({
351
460
  result?: unknown;
352
461
  seq: number;
353
462
  stepId?: string;
463
+ subagent?: {
464
+ agentName?: string;
465
+ parentToolCallId?: string;
466
+ toolName: string;
467
+ };
354
468
  success: boolean;
355
469
  toolCallId: string;
356
470
  toolCost?: number;
@@ -430,6 +544,19 @@ type RuntypeExecutionStreamEvent = ({
430
544
  recoverable?: boolean;
431
545
  seq: number;
432
546
  type: "error";
547
+ }) | ({
548
+ epoch: number;
549
+ executionId: string;
550
+ kind: "compaction";
551
+ outcome?: "ok" | "failed" | "gap" | "skipped";
552
+ phase: "start" | "complete";
553
+ reason: "threshold" | "overflow" | "manual" | "surface_policy" | "provider_mismatch";
554
+ seq: number;
555
+ strategy: "provider_native" | "summary";
556
+ tier: number;
557
+ tokensAfter?: number;
558
+ tokensBefore?: number;
559
+ type: "context_notice";
433
560
  }) | {
434
561
  executionId: string;
435
562
  seq: number;
@@ -641,15 +768,15 @@ type AgentMessageMetadata = {
641
768
  */
642
769
  parentStepId?: string;
643
770
  /**
644
- * Set to `true` on a tool-variant message produced from a `step_await`
771
+ * Set to `true` on a tool-variant message produced from an `await`
645
772
  * event (`awaitReason: "local_tool_required"`). Signals to UI code that
646
773
  * the tool call is a LOCAL tool and the server is paused waiting for a
647
774
  * `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
648
775
  */
649
776
  awaitingLocalTool?: boolean;
650
777
  /**
651
- * The provider per-call id (`toolu_…`) carried on the `step_await` /
652
- * `flow_await` events for a LOCAL tool (core#3878). Present only when the
778
+ * The provider per-call id (`toolu_…`) carried on the `await`
779
+ * event for a LOCAL tool (core#3878). Present only when the
653
780
  * server emits it. Two PARALLEL calls to the same tool in one turn share a
654
781
  * `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
655
782
  * so this is the key the widget batches a single `/resume` on: preferred
@@ -959,7 +1086,7 @@ type AgentWidgetReasoning = {
959
1086
  /**
960
1087
  * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
961
1088
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
962
- * replaced the legacy `agent_reflection` event). Absent for legacy streams.
1089
+ * replaced the legacy `agent_reflection` event). Optional when the stream does not specify a scope.
963
1090
  */
964
1091
  scope?: "turn" | "loop";
965
1092
  startedAt?: number;
@@ -973,6 +1100,9 @@ type AgentWidgetToolCall = {
973
1100
  args?: unknown;
974
1101
  chunks?: string[];
975
1102
  result?: unknown;
1103
+ /** Whether the tool succeeded; failure does not necessarily end the execution. */
1104
+ success?: boolean;
1105
+ error?: string;
976
1106
  duration?: number;
977
1107
  startedAt?: number;
978
1108
  completedAt?: number;
@@ -1003,7 +1133,7 @@ type AgentWidgetApproval = {
1003
1133
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
1004
1134
  /**
1005
1135
  * Per-turn / per-step stop reason emitted by the runtime on
1006
- * `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
1136
+ * `turn_complete` and `step_complete` SSE events. The vocabulary is
1007
1137
  * owned by the upstream Runtype API: do not extend without coordination.
1008
1138
  *
1009
1139
  * - `end_turn`: natural completion (no affordance needed)
@@ -1134,7 +1264,7 @@ type AgentWidgetMessage = {
1134
1264
  */
1135
1265
  agentMetadata?: AgentMessageMetadata;
1136
1266
  /**
1137
- * Per-turn stop reason reported by the runtime on `agent_turn_complete`
1267
+ * Per-turn stop reason reported by the runtime on `turn_complete`
1138
1268
  * (agent-loop path) or the last `step_complete` for a prompt step
1139
1269
  * (dispatch / flow path). Absent when the API did not report a value.
1140
1270
  *