@runtypelabs/persona 4.22.0 → 4.23.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 (95) 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.d.cts +148 -14
  10. package/dist/approval-ui.d.ts +148 -14
  11. package/dist/artifacts-ui.d.cts +148 -14
  12. package/dist/artifacts-ui.d.ts +148 -14
  13. package/dist/codegen.cjs +1 -1
  14. package/dist/codegen.js +1 -1
  15. package/dist/context-mentions.d.cts +148 -14
  16. package/dist/context-mentions.d.ts +148 -14
  17. package/dist/event-stream-view-GL3ADRY2.js +1 -0
  18. package/dist/event-stream-view.cjs +1 -1
  19. package/dist/event-stream-view.d.cts +148 -14
  20. package/dist/event-stream-view.d.ts +148 -14
  21. package/dist/event-stream-view.js +1 -1
  22. package/dist/forms-ui.d.cts +161 -23
  23. package/dist/forms-ui.d.ts +161 -23
  24. package/dist/history-view.d.cts +136 -6
  25. package/dist/history-view.d.ts +136 -6
  26. package/dist/index.cjs +67 -67
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +172 -27
  29. package/dist/index.d.ts +172 -27
  30. package/dist/index.global.js +51 -51
  31. package/dist/index.global.js.map +1 -1
  32. package/dist/index.js +67 -67
  33. package/dist/index.js.map +1 -1
  34. package/dist/launcher.global.js.map +1 -1
  35. package/dist/session-reconnect.d.cts +148 -14
  36. package/dist/session-reconnect.d.ts +148 -14
  37. package/dist/smart-dom-reader.d.cts +148 -14
  38. package/dist/smart-dom-reader.d.ts +148 -14
  39. package/dist/testing.cjs +3 -3
  40. package/dist/testing.d.cts +3 -4
  41. package/dist/testing.d.ts +3 -4
  42. package/dist/testing.js +3 -3
  43. package/dist/theme-editor-preview.cjs +71 -71
  44. package/dist/theme-editor-preview.d.cts +154 -14
  45. package/dist/theme-editor-preview.d.ts +154 -14
  46. package/dist/theme-editor-preview.js +48 -48
  47. package/dist/theme-editor.d.cts +148 -14
  48. package/dist/theme-editor.d.ts +148 -14
  49. package/dist/voice-runtime.d.cts +6 -2
  50. package/dist/voice-runtime.d.ts +6 -2
  51. package/package.json +1 -1
  52. package/src/ask-user-question-tool.ts +1 -1
  53. package/src/client-history-rest.test.ts +2 -1
  54. package/src/client-visitor-history.test.ts +106 -4
  55. package/src/client.composer-options.test.ts +1 -1
  56. package/src/client.interrupt.test.ts +2 -2
  57. package/src/client.test.ts +477 -915
  58. package/src/client.ts +134 -494
  59. package/src/client.unified-tools.test.ts +76 -0
  60. package/src/components/event-stream-badge-theming.test.ts +3 -0
  61. package/src/components/event-stream-view.test.ts +76 -76
  62. package/src/components/event-stream-view.ts +5 -0
  63. package/src/components/tool-bubble.test.ts +12 -0
  64. package/src/components/tool-bubble.ts +13 -2
  65. package/src/event-stream-view-bundle.test.ts +2 -2
  66. package/src/generated/runtype-openapi-contract.ts +129 -1
  67. package/src/internal/runtype-history-provider.test.ts +2 -2
  68. package/src/launcher-global.ts +1 -1
  69. package/src/session-history.test.ts +1 -1
  70. package/src/session.quote.test.ts +1 -1
  71. package/src/session.resubmit-from.test.ts +1 -1
  72. package/src/session.test.ts +5 -5
  73. package/src/session.ts +95 -36
  74. package/src/suggest-replies-tool.ts +1 -1
  75. package/src/testing/mock-stream.test.ts +37 -16
  76. package/src/testing/mock-stream.ts +14 -9
  77. package/src/types.ts +19 -14
  78. package/src/ui.ask-user-question-plugin.test.ts +7 -7
  79. package/src/ui.composer-defer-one.test.ts +6 -34
  80. package/src/ui.composer-draft-persistence.test.ts +1 -1
  81. package/src/ui.composer-quote.test.ts +1 -1
  82. package/src/ui.message-history-actions.test.ts +1 -1
  83. package/src/ui.streaming-coalescing.test.ts +10 -13
  84. package/src/ui.ts +80 -32
  85. package/src/ui.typing-indicator.test.ts +216 -0
  86. package/src/ui.voice-custom-provider.test.ts +211 -0
  87. package/src/utils/event-stream-buffer.test.ts +13 -13
  88. package/src/utils/event-stream-capture.test.ts +20 -20
  89. package/src/utils/throughput-tracker.test.ts +100 -142
  90. package/src/utils/throughput-tracker.ts +18 -132
  91. package/src/utils/voice-support.ts +18 -1
  92. package/src/voice/voice-turn-tracker.ts +18 -0
  93. package/src/webmcp-bridge.ts +1 -1
  94. package/dist/event-stream-view-FKWDY3UB.js +0 -1
  95. package/src/utils/__fixtures__/unified-translator.oracle.ts +0 -717
@@ -1694,6 +1694,11 @@ type RuntypeExecutionStreamEvent = ({
1694
1694
  iteration?: number;
1695
1695
  role: "user" | "assistant" | "system";
1696
1696
  seq: number;
1697
+ subagent?: {
1698
+ agentName?: string;
1699
+ parentToolCallId?: string;
1700
+ toolName: string;
1701
+ };
1697
1702
  turnIndex?: number;
1698
1703
  type: "turn_start";
1699
1704
  }) | ({
@@ -1728,12 +1733,61 @@ type RuntypeExecutionStreamEvent = ({
1728
1733
  role: "user" | "assistant" | "system";
1729
1734
  seq: number;
1730
1735
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
1736
+ subagent?: {
1737
+ agentName?: string;
1738
+ parentToolCallId?: string;
1739
+ toolName: string;
1740
+ };
1731
1741
  tokens?: {
1732
1742
  input: number;
1733
1743
  output: number;
1734
1744
  };
1735
1745
  type: "turn_complete";
1736
1746
  }) | {
1747
+ executionId: string;
1748
+ id: string;
1749
+ iteration?: number;
1750
+ model?: string;
1751
+ ordinal: number;
1752
+ provider?: string;
1753
+ seq: number;
1754
+ startedAt?: string;
1755
+ stepId?: string;
1756
+ subagent?: {
1757
+ agentName?: string;
1758
+ parentToolCallId?: string;
1759
+ toolName: string;
1760
+ };
1761
+ turnId?: string;
1762
+ type: "model_call_start";
1763
+ } | {
1764
+ completedAt?: string;
1765
+ cost?: number;
1766
+ durationMs?: number;
1767
+ executionId: string;
1768
+ finishReason?: string;
1769
+ id: string;
1770
+ iteration?: number;
1771
+ model?: string;
1772
+ ordinal: number;
1773
+ provider?: string;
1774
+ responseModel?: string;
1775
+ seq: number;
1776
+ subagent?: {
1777
+ agentName?: string;
1778
+ parentToolCallId?: string;
1779
+ toolName: string;
1780
+ };
1781
+ success?: boolean;
1782
+ tokens?: {
1783
+ cacheRead?: number;
1784
+ cacheWrite?: number;
1785
+ input: number;
1786
+ output: number;
1787
+ };
1788
+ turnId?: string;
1789
+ type: "model_call_complete";
1790
+ } | {
1737
1791
  executionId: string;
1738
1792
  id: string;
1739
1793
  index?: number;
@@ -1742,6 +1796,11 @@ type RuntypeExecutionStreamEvent = ({
1742
1796
  seq: number;
1743
1797
  startedAt?: string;
1744
1798
  stepType?: string;
1799
+ subagent?: {
1800
+ agentName?: string;
1801
+ parentToolCallId?: string;
1802
+ toolName: string;
1803
+ };
1745
1804
  totalSteps?: number;
1746
1805
  type: "step_start";
1747
1806
  } | ({
@@ -1769,6 +1828,11 @@ type RuntypeExecutionStreamEvent = ({
1769
1828
  seq: number;
1770
1829
  stepType?: string;
1771
1830
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
1831
+ subagent?: {
1832
+ agentName?: string;
1833
+ parentToolCallId?: string;
1834
+ toolName: string;
1835
+ };
1772
1836
  success?: boolean;
1773
1837
  tokensUsed?: number;
1774
1838
  type: "step_complete";
@@ -1791,6 +1855,11 @@ type RuntypeExecutionStreamEvent = ({
1791
1855
  role?: "user" | "assistant" | "system";
1792
1856
  seq: number;
1793
1857
  stepId?: string;
1858
+ subagent?: {
1859
+ agentName?: string;
1860
+ parentToolCallId?: string;
1861
+ toolName: string;
1862
+ };
1794
1863
  turnId?: string;
1795
1864
  type: "text_start";
1796
1865
  }) | {
@@ -1798,11 +1867,21 @@ type RuntypeExecutionStreamEvent = ({
1798
1867
  executionId: string;
1799
1868
  id: string;
1800
1869
  seq: number;
1870
+ subagent?: {
1871
+ agentName?: string;
1872
+ parentToolCallId?: string;
1873
+ toolName: string;
1874
+ };
1801
1875
  type: "text_delta";
1802
1876
  } | {
1803
1877
  executionId: string;
1804
1878
  id: string;
1805
1879
  seq: number;
1880
+ subagent?: {
1881
+ agentName?: string;
1882
+ parentToolCallId?: string;
1883
+ toolName: string;
1884
+ };
1806
1885
  text?: string;
1807
1886
  type: "text_complete";
1808
1887
  } | ({
@@ -1811,18 +1890,33 @@ type RuntypeExecutionStreamEvent = ({
1811
1890
  parentToolCallId?: string;
1812
1891
  scope?: "turn" | "loop";
1813
1892
  seq: number;
1893
+ subagent?: {
1894
+ agentName?: string;
1895
+ parentToolCallId?: string;
1896
+ toolName: string;
1897
+ };
1814
1898
  type: "reasoning_start";
1815
1899
  }) | {
1816
1900
  delta: string;
1817
1901
  executionId: string;
1818
1902
  id: string;
1819
1903
  seq: number;
1904
+ subagent?: {
1905
+ agentName?: string;
1906
+ parentToolCallId?: string;
1907
+ toolName: string;
1908
+ };
1820
1909
  type: "reasoning_delta";
1821
1910
  } | ({
1822
1911
  executionId: string;
1823
1912
  id: string;
1824
1913
  scope?: "turn" | "loop";
1825
1914
  seq: number;
1915
+ subagent?: {
1916
+ agentName?: string;
1917
+ parentToolCallId?: string;
1918
+ toolName: string;
1919
+ };
1826
1920
  text?: string;
1827
1921
  type: "reasoning_complete";
1828
1922
  }) | ({
@@ -1915,6 +2009,11 @@ type RuntypeExecutionStreamEvent = ({
1915
2009
  seq: number;
1916
2010
  startedAt?: string;
1917
2011
  stepId?: string;
2012
+ subagent?: {
2013
+ agentName?: string;
2014
+ parentToolCallId?: string;
2015
+ toolName: string;
2016
+ };
1918
2017
  toolCallId: string;
1919
2018
  toolName: string;
1920
2019
  toolType: string;
@@ -1923,6 +2022,11 @@ type RuntypeExecutionStreamEvent = ({
1923
2022
  delta: string;
1924
2023
  executionId: string;
1925
2024
  seq: number;
2025
+ subagent?: {
2026
+ agentName?: string;
2027
+ parentToolCallId?: string;
2028
+ toolName: string;
2029
+ };
1926
2030
  toolCallId: string;
1927
2031
  type: "tool_input_delta";
1928
2032
  } | {
@@ -1930,6 +2034,11 @@ type RuntypeExecutionStreamEvent = ({
1930
2034
  hiddenParameterNames?: Array<string>;
1931
2035
  parameters: Record<string, unknown>;
1932
2036
  seq: number;
2037
+ subagent?: {
2038
+ agentName?: string;
2039
+ parentToolCallId?: string;
2040
+ toolName: string;
2041
+ };
1933
2042
  toolCallId: string;
1934
2043
  toolName?: string;
1935
2044
  type: "tool_input_complete";
@@ -1947,6 +2056,11 @@ type RuntypeExecutionStreamEvent = ({
1947
2056
  result?: unknown;
1948
2057
  seq: number;
1949
2058
  stepId?: string;
2059
+ subagent?: {
2060
+ agentName?: string;
2061
+ parentToolCallId?: string;
2062
+ toolName: string;
2063
+ };
1950
2064
  success: boolean;
1951
2065
  toolCallId: string;
1952
2066
  toolCost?: number;
@@ -2026,6 +2140,19 @@ type RuntypeExecutionStreamEvent = ({
2026
2140
  recoverable?: boolean;
2027
2141
  seq: number;
2028
2142
  type: "error";
2143
+ }) | ({
2144
+ epoch: number;
2145
+ executionId: string;
2146
+ kind: "compaction";
2147
+ outcome?: "ok" | "failed" | "gap" | "skipped";
2148
+ phase: "start" | "complete";
2149
+ reason: "threshold" | "overflow" | "manual" | "surface_policy" | "provider_mismatch";
2150
+ seq: number;
2151
+ strategy: "provider_native" | "summary";
2152
+ tier: number;
2153
+ tokensAfter?: number;
2154
+ tokensBefore?: number;
2155
+ type: "context_notice";
2029
2156
  }) | {
2030
2157
  executionId: string;
2031
2158
  seq: number;
@@ -3185,15 +3312,15 @@ type AgentMessageMetadata = {
3185
3312
  */
3186
3313
  parentStepId?: string;
3187
3314
  /**
3188
- * Set to `true` on a tool-variant message produced from a `step_await`
3315
+ * Set to `true` on a tool-variant message produced from an `await`
3189
3316
  * event (`awaitReason: "local_tool_required"`). Signals to UI code that
3190
3317
  * the tool call is a LOCAL tool and the server is paused waiting for a
3191
3318
  * `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
3192
3319
  */
3193
3320
  awaitingLocalTool?: boolean;
3194
3321
  /**
3195
- * The provider per-call id (`toolu_…`) carried on the `step_await` /
3196
- * `flow_await` events for a LOCAL tool (core#3878). Present only when the
3322
+ * The provider per-call id (`toolu_…`) carried on the `await`
3323
+ * event for a LOCAL tool (core#3878). Present only when the
3197
3324
  * server emits it. Two PARALLEL calls to the same tool in one turn share a
3198
3325
  * `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
3199
3326
  * so this is the key the widget batches a single `/resume` on: preferred
@@ -5343,7 +5470,7 @@ type EventStreamConfig = {
5343
5470
  /**
5344
5471
  * Custom badge color mappings by event type prefix or exact type.
5345
5472
  * Keys are matched as exact match first, then prefix match (keys ending with "_").
5346
- * @example { "flow_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5473
+ * @example { "execution_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5347
5474
  */
5348
5475
  badgeColors?: Record<string, EventStreamBadgeColor>;
5349
5476
  /**
@@ -6821,9 +6948,13 @@ interface VoiceProvider {
6821
6948
  * `isFinal=false` is a live interim update (user partials, or assistant deltas
6822
6949
  * on providers that stream them); `isFinal=true` finalizes that role's text.
6823
6950
  * On the realtime `runtype` path, interim updates fire for the `user` only and
6824
- * the `assistant` arrives as a single final.
6951
+ * the `assistant` arrives as a single final. Providers with overlapping turns
6952
+ * must include the same turnId on user and assistant finals; without IDs,
6953
+ * providers must discard cancelled output before emitting the next user final.
6825
6954
  */
6826
- onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean) => void): void;
6955
+ onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean, metadata?: {
6956
+ turnId?: string;
6957
+ }) => void): void;
6827
6958
  /** Register a callback for per-turn latency metrics (realtime path). */
6828
6959
  onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
6829
6960
  /**
@@ -9234,16 +9365,16 @@ type AgentWidgetConfig = {
9234
9365
  *
9235
9366
  * @example
9236
9367
  * ```typescript
9237
- * // For Runtype API format
9368
+ * // For a custom backend (Runtype unified events are handled natively)
9238
9369
  * config: {
9239
9370
  * parseSSEEvent: (data) => {
9240
- * if ((data.type === 'step_delta' || data.type === 'step_chunk') && (data.delta || data.chunk)) {
9241
- * return { text: data.delta ?? data.chunk };
9371
+ * if (data.type === 'token' && typeof data.value === 'string') {
9372
+ * return { text: data.value };
9242
9373
  * }
9243
- * if (data.type === 'flow_complete') {
9374
+ * if (data.type === 'done') {
9244
9375
  * return { done: true };
9245
9376
  * }
9246
- * if (data.type === 'step_error') {
9377
+ * if (data.type === 'failure') {
9247
9378
  * return { error: data.error };
9248
9379
  * }
9249
9380
  * return null; // Ignore other events
@@ -9434,7 +9565,7 @@ type AgentWidgetReasoning = {
9434
9565
  /**
9435
9566
  * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
9436
9567
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
9437
- * replaced the legacy `agent_reflection` event). Absent for legacy streams.
9568
+ * replaced the legacy `agent_reflection` event). Optional when the stream does not specify a scope.
9438
9569
  */
9439
9570
  scope?: "turn" | "loop";
9440
9571
  startedAt?: number;
@@ -9448,6 +9579,9 @@ type AgentWidgetToolCall = {
9448
9579
  args?: unknown;
9449
9580
  chunks?: string[];
9450
9581
  result?: unknown;
9582
+ /** Whether the tool succeeded; failure does not necessarily end the execution. */
9583
+ success?: boolean;
9584
+ error?: string;
9451
9585
  duration?: number;
9452
9586
  startedAt?: number;
9453
9587
  completedAt?: number;
@@ -9478,7 +9612,7 @@ type AgentWidgetApproval = {
9478
9612
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
9479
9613
  /**
9480
9614
  * Per-turn / per-step stop reason emitted by the runtime on
9481
- * `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
9615
+ * `turn_complete` and `step_complete` SSE events. The vocabulary is
9482
9616
  * owned by the upstream Runtype API: do not extend without coordination.
9483
9617
  *
9484
9618
  * - `end_turn`: natural completion (no affordance needed)
@@ -9609,7 +9743,7 @@ type AgentWidgetMessage = {
9609
9743
  */
9610
9744
  agentMetadata?: AgentMessageMetadata;
9611
9745
  /**
9612
- * Per-turn stop reason reported by the runtime on `agent_turn_complete`
9746
+ * Per-turn stop reason reported by the runtime on `turn_complete`
9613
9747
  * (agent-loop path) or the last `step_complete` for a prompt step
9614
9748
  * (dispatch / flow path). Absent when the API did not report a value.
9615
9749
  *
@@ -10290,7 +10424,7 @@ declare class AgentWidgetClient {
10290
10424
  * Returns the raw Response so the caller can pipe its SSE body through
10291
10425
  * `connectStream()`.
10292
10426
  *
10293
- * @param executionId - The paused execution id carried on `step_await`.
10427
+ * @param executionId - The paused execution id carried on `await`.
10294
10428
  * @param toolOutputs - Map keyed by per-call `toolCallId` (core#3878),
10295
10429
  * falling back to tool name for legacy servers → the tool's result value.
10296
10430
  */
@@ -10576,6 +10710,8 @@ declare class AgentWidgetSession {
10576
10710
  deactivateBargeIn(): Promise<void>;
10577
10711
  private pendingVoiceUserMessageId;
10578
10712
  private pendingVoiceAssistantMessageId;
10713
+ private voiceTurns;
10714
+ private voiceDisconnectPromise;
10579
10715
  private ttsSpokenMessageIds;
10580
10716
  private readAloud;
10581
10717
  /**
@@ -10604,6 +10740,8 @@ declare class AgentWidgetSession {
10604
10740
  * Cleanup voice resources
10605
10741
  */
10606
10742
  cleanupVoice(): void;
10743
+ private disconnectVoice;
10744
+ private settlePendingVoiceTurn;
10607
10745
  /**
10608
10746
  * Extract voice configuration from widget config
10609
10747
  */
@@ -11098,7 +11236,7 @@ declare class AgentWidgetSession {
11098
11236
  /**
11099
11237
  * Resolve a paused `ask_user_question` LOCAL tool call.
11100
11238
  *
11101
- * When the server emits `step_await` for `ask_user_question`, the widget
11239
+ * When the server emits `await` for `ask_user_question`, the widget
11102
11240
  * renders the answer-pill sheet and calls this method once the user
11103
11241
  * picks. Steps:
11104
11242
  * 1. POST the answer to `/resume` via `client.resumeFlow`.
@@ -11127,10 +11265,10 @@ declare class AgentWidgetSession {
11127
11265
  markAskUserQuestionResolved(toolMessage: AgentWidgetMessage, answers?: Record<string, string | string[]>): void;
11128
11266
  resolveAskUserQuestion(toolMessage: AgentWidgetMessage, answer: string | Record<string, string | string[]>): Promise<void>;
11129
11267
  /**
11130
- * Collect an auto-resolving LOCAL-tool `step_await` (`webmcp:*` page tools
11268
+ * Collect an auto-resolving LOCAL-tool `await` (`webmcp:*` page tools
11131
11269
  * and the built-in `suggest_replies`) into a per-executionId batch
11132
11270
  * and schedule a single deferred flush. Parallel calls (core#3878) emit
11133
- * several `step_await`s for ONE paused execution within the same stream tick;
11271
+ * several `await`s for ONE paused execution within the same stream tick;
11134
11272
  * buffering them and flushing once lets us post ONE `/resume` keyed by the
11135
11273
  * per-call `webMcpToolCallId` rather than racing N name-keyed resumes on the
11136
11274
  * same execution (which 404'd on the second and hung the turn).
@@ -11148,7 +11286,7 @@ declare class AgentWidgetSession {
11148
11286
  /**
11149
11287
  * Flush every buffered local-tool await batch, one `/resume` per executionId.
11150
11288
  * Called once a stream ends (`status: idle` / `error`): by then all parallel
11151
- * `step_await`s the stream carried have been collected, even if split across
11289
+ * `await`s the stream carried have been collected, even if split across
11152
11290
  * SSE chunks. Deferred via `queueMicrotask` (epoch-guarded) so the idle
11153
11291
  * handler returns first and the stream's end-of-stream teardown (streaming /
11154
11292
  * abortController) settles before a resolve grabs them: the same ordering the
@@ -11169,7 +11307,7 @@ declare class AgentWidgetSession {
11169
11307
  * Persisted-resolution guard for `suggest_replies`. The in-memory dedupe
11170
11308
  * sets (`webMcpInflightKeys` / `webMcpResolvedKeys`) are cleared by
11171
11309
  * hydrateMessages/clearMessages/cancel, but `suggestRepliesResolved`
11172
- * survives on the stored message, so a stale `step_await` re-emit after a
11310
+ * survives on the stored message, so a stale `await` re-emit after a
11173
11311
  * hydration must not re-POST `/resume` for an already-resolved call (the
11174
11312
  * historical double-resume failure mode the batching work exists to avoid).
11175
11313
  * Checks the LIVE message first; the handleEvent snapshot is a fresh wire
@@ -11203,12 +11341,12 @@ declare class AgentWidgetSession {
11203
11341
  * resumes with a canned "shown" result (the chips render from the message
11204
11342
  * list, not from this resolve).
11205
11343
  *
11206
- * Triggered automatically from `handleEvent` when a `step_await`-derived
11344
+ * Triggered automatically from `handleEvent` when an `await`-derived
11207
11345
  * message arrives for such a tool: the user does not click a pill; the
11208
11346
  * bridge's confirm-bubble gate (WebMCP only) is the only interactive
11209
11347
  * surface.
11210
11348
  *
11211
- * Idempotent on the message's `toolCall.id`: re-emits of the same step_await
11349
+ * Idempotent on the message's `toolCall.id`: re-emits of the same await
11212
11350
  * (e.g. from message coalescing) won't double-fire `tool.execute`. Failure
11213
11351
  * modes, declined, timed out, throw, unknown tool, all resolve into a
11214
11352
  * `{ isError: true, content: [...] }` payload that resumes the dispatch
@@ -11287,7 +11425,7 @@ declare class AgentWidgetSession {
11287
11425
  private trackCursor;
11288
11426
  /**
11289
11427
  * The drop gate: is this stream-end a dropped connection we should reconnect,
11290
- * rather than a graceful finish or an intentional `step_await` pause? ALL must
11428
+ * rather than a graceful finish or an intentional `await` pause? ALL must
11291
11429
  * hold (see plan §Design overview keystone 3).
11292
11430
  */
11293
11431
  private isDurableDrop;
@@ -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
  *