@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;
@@ -3085,15 +3212,15 @@ type AgentMessageMetadata = {
3085
3212
  */
3086
3213
  parentStepId?: string;
3087
3214
  /**
3088
- * Set to `true` on a tool-variant message produced from a `step_await`
3215
+ * Set to `true` on a tool-variant message produced from an `await`
3089
3216
  * event (`awaitReason: "local_tool_required"`). Signals to UI code that
3090
3217
  * the tool call is a LOCAL tool and the server is paused waiting for a
3091
3218
  * `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
3092
3219
  */
3093
3220
  awaitingLocalTool?: boolean;
3094
3221
  /**
3095
- * The provider per-call id (`toolu_…`) carried on the `step_await` /
3096
- * `flow_await` events for a LOCAL tool (core#3878). Present only when the
3222
+ * The provider per-call id (`toolu_…`) carried on the `await`
3223
+ * event for a LOCAL tool (core#3878). Present only when the
3097
3224
  * server emits it. Two PARALLEL calls to the same tool in one turn share a
3098
3225
  * `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
3099
3226
  * so this is the key the widget batches a single `/resume` on: preferred
@@ -5243,7 +5370,7 @@ type EventStreamConfig = {
5243
5370
  /**
5244
5371
  * Custom badge color mappings by event type prefix or exact type.
5245
5372
  * Keys are matched as exact match first, then prefix match (keys ending with "_").
5246
- * @example { "flow_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5373
+ * @example { "execution_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5247
5374
  */
5248
5375
  badgeColors?: Record<string, EventStreamBadgeColor>;
5249
5376
  /**
@@ -6664,9 +6791,13 @@ interface VoiceProvider {
6664
6791
  * `isFinal=false` is a live interim update (user partials, or assistant deltas
6665
6792
  * on providers that stream them); `isFinal=true` finalizes that role's text.
6666
6793
  * On the realtime `runtype` path, interim updates fire for the `user` only and
6667
- * the `assistant` arrives as a single final.
6794
+ * the `assistant` arrives as a single final. Providers with overlapping turns
6795
+ * must include the same turnId on user and assistant finals; without IDs,
6796
+ * providers must discard cancelled output before emitting the next user final.
6668
6797
  */
6669
- onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean) => void): void;
6798
+ onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean, metadata?: {
6799
+ turnId?: string;
6800
+ }) => void): void;
6670
6801
  /** Register a callback for per-turn latency metrics (realtime path). */
6671
6802
  onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
6672
6803
  /**
@@ -8979,16 +9110,16 @@ type AgentWidgetConfig = {
8979
9110
  *
8980
9111
  * @example
8981
9112
  * ```typescript
8982
- * // For Runtype API format
9113
+ * // For a custom backend (Runtype unified events are handled natively)
8983
9114
  * config: {
8984
9115
  * parseSSEEvent: (data) => {
8985
- * if ((data.type === 'step_delta' || data.type === 'step_chunk') && (data.delta || data.chunk)) {
8986
- * return { text: data.delta ?? data.chunk };
9116
+ * if (data.type === 'token' && typeof data.value === 'string') {
9117
+ * return { text: data.value };
8987
9118
  * }
8988
- * if (data.type === 'flow_complete') {
9119
+ * if (data.type === 'done') {
8989
9120
  * return { done: true };
8990
9121
  * }
8991
- * if (data.type === 'step_error') {
9122
+ * if (data.type === 'failure') {
8992
9123
  * return { error: data.error };
8993
9124
  * }
8994
9125
  * return null; // Ignore other events
@@ -9179,7 +9310,7 @@ type AgentWidgetReasoning = {
9179
9310
  /**
9180
9311
  * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
9181
9312
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
9182
- * replaced the legacy `agent_reflection` event). Absent for legacy streams.
9313
+ * replaced the legacy `agent_reflection` event). Optional when the stream does not specify a scope.
9183
9314
  */
9184
9315
  scope?: "turn" | "loop";
9185
9316
  startedAt?: number;
@@ -9193,6 +9324,9 @@ type AgentWidgetToolCall = {
9193
9324
  args?: unknown;
9194
9325
  chunks?: string[];
9195
9326
  result?: unknown;
9327
+ /** Whether the tool succeeded; failure does not necessarily end the execution. */
9328
+ success?: boolean;
9329
+ error?: string;
9196
9330
  duration?: number;
9197
9331
  startedAt?: number;
9198
9332
  completedAt?: number;
@@ -9223,7 +9357,7 @@ type AgentWidgetApproval = {
9223
9357
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
9224
9358
  /**
9225
9359
  * Per-turn / per-step stop reason emitted by the runtime on
9226
- * `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
9360
+ * `turn_complete` and `step_complete` SSE events. The vocabulary is
9227
9361
  * owned by the upstream Runtype API: do not extend without coordination.
9228
9362
  *
9229
9363
  * - `end_turn`: natural completion (no affordance needed)
@@ -9354,7 +9488,7 @@ type AgentWidgetMessage = {
9354
9488
  */
9355
9489
  agentMetadata?: AgentMessageMetadata;
9356
9490
  /**
9357
- * Per-turn stop reason reported by the runtime on `agent_turn_complete`
9491
+ * Per-turn stop reason reported by the runtime on `turn_complete`
9358
9492
  * (agent-loop path) or the last `step_complete` for a prompt step
9359
9493
  * (dispatch / flow path). Absent when the API did not report a value.
9360
9494
  *
@@ -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;
@@ -3085,15 +3212,15 @@ type AgentMessageMetadata = {
3085
3212
  */
3086
3213
  parentStepId?: string;
3087
3214
  /**
3088
- * Set to `true` on a tool-variant message produced from a `step_await`
3215
+ * Set to `true` on a tool-variant message produced from an `await`
3089
3216
  * event (`awaitReason: "local_tool_required"`). Signals to UI code that
3090
3217
  * the tool call is a LOCAL tool and the server is paused waiting for a
3091
3218
  * `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
3092
3219
  */
3093
3220
  awaitingLocalTool?: boolean;
3094
3221
  /**
3095
- * The provider per-call id (`toolu_…`) carried on the `step_await` /
3096
- * `flow_await` events for a LOCAL tool (core#3878). Present only when the
3222
+ * The provider per-call id (`toolu_…`) carried on the `await`
3223
+ * event for a LOCAL tool (core#3878). Present only when the
3097
3224
  * server emits it. Two PARALLEL calls to the same tool in one turn share a
3098
3225
  * `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
3099
3226
  * so this is the key the widget batches a single `/resume` on: preferred
@@ -5243,7 +5370,7 @@ type EventStreamConfig = {
5243
5370
  /**
5244
5371
  * Custom badge color mappings by event type prefix or exact type.
5245
5372
  * Keys are matched as exact match first, then prefix match (keys ending with "_").
5246
- * @example { "flow_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5373
+ * @example { "execution_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5247
5374
  */
5248
5375
  badgeColors?: Record<string, EventStreamBadgeColor>;
5249
5376
  /**
@@ -6664,9 +6791,13 @@ interface VoiceProvider {
6664
6791
  * `isFinal=false` is a live interim update (user partials, or assistant deltas
6665
6792
  * on providers that stream them); `isFinal=true` finalizes that role's text.
6666
6793
  * On the realtime `runtype` path, interim updates fire for the `user` only and
6667
- * the `assistant` arrives as a single final.
6794
+ * the `assistant` arrives as a single final. Providers with overlapping turns
6795
+ * must include the same turnId on user and assistant finals; without IDs,
6796
+ * providers must discard cancelled output before emitting the next user final.
6668
6797
  */
6669
- onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean) => void): void;
6798
+ onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean, metadata?: {
6799
+ turnId?: string;
6800
+ }) => void): void;
6670
6801
  /** Register a callback for per-turn latency metrics (realtime path). */
6671
6802
  onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
6672
6803
  /**
@@ -8979,16 +9110,16 @@ type AgentWidgetConfig = {
8979
9110
  *
8980
9111
  * @example
8981
9112
  * ```typescript
8982
- * // For Runtype API format
9113
+ * // For a custom backend (Runtype unified events are handled natively)
8983
9114
  * config: {
8984
9115
  * parseSSEEvent: (data) => {
8985
- * if ((data.type === 'step_delta' || data.type === 'step_chunk') && (data.delta || data.chunk)) {
8986
- * return { text: data.delta ?? data.chunk };
9116
+ * if (data.type === 'token' && typeof data.value === 'string') {
9117
+ * return { text: data.value };
8987
9118
  * }
8988
- * if (data.type === 'flow_complete') {
9119
+ * if (data.type === 'done') {
8989
9120
  * return { done: true };
8990
9121
  * }
8991
- * if (data.type === 'step_error') {
9122
+ * if (data.type === 'failure') {
8992
9123
  * return { error: data.error };
8993
9124
  * }
8994
9125
  * return null; // Ignore other events
@@ -9179,7 +9310,7 @@ type AgentWidgetReasoning = {
9179
9310
  /**
9180
9311
  * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
9181
9312
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
9182
- * replaced the legacy `agent_reflection` event). Absent for legacy streams.
9313
+ * replaced the legacy `agent_reflection` event). Optional when the stream does not specify a scope.
9183
9314
  */
9184
9315
  scope?: "turn" | "loop";
9185
9316
  startedAt?: number;
@@ -9193,6 +9324,9 @@ type AgentWidgetToolCall = {
9193
9324
  args?: unknown;
9194
9325
  chunks?: string[];
9195
9326
  result?: unknown;
9327
+ /** Whether the tool succeeded; failure does not necessarily end the execution. */
9328
+ success?: boolean;
9329
+ error?: string;
9196
9330
  duration?: number;
9197
9331
  startedAt?: number;
9198
9332
  completedAt?: number;
@@ -9223,7 +9357,7 @@ type AgentWidgetApproval = {
9223
9357
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
9224
9358
  /**
9225
9359
  * Per-turn / per-step stop reason emitted by the runtime on
9226
- * `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
9360
+ * `turn_complete` and `step_complete` SSE events. The vocabulary is
9227
9361
  * owned by the upstream Runtype API: do not extend without coordination.
9228
9362
  *
9229
9363
  * - `end_turn`: natural completion (no affordance needed)
@@ -9354,7 +9488,7 @@ type AgentWidgetMessage = {
9354
9488
  */
9355
9489
  agentMetadata?: AgentMessageMetadata;
9356
9490
  /**
9357
- * Per-turn stop reason reported by the runtime on `agent_turn_complete`
9491
+ * Per-turn stop reason reported by the runtime on `turn_complete`
9358
9492
  * (agent-loop path) or the last `step_complete` for a prompt step
9359
9493
  * (dispatch / flow path). Absent when the API did not report a value.
9360
9494
  *