@runtypelabs/persona 4.22.0 → 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 (93) 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 +166 -27
  29. package/dist/index.d.ts +166 -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/session-reconnect.d.cts +148 -14
  35. package/dist/session-reconnect.d.ts +148 -14
  36. package/dist/smart-dom-reader.d.cts +148 -14
  37. package/dist/smart-dom-reader.d.ts +148 -14
  38. package/dist/testing.cjs +3 -3
  39. package/dist/testing.d.cts +3 -4
  40. package/dist/testing.d.ts +3 -4
  41. package/dist/testing.js +3 -3
  42. package/dist/theme-editor-preview.cjs +71 -71
  43. package/dist/theme-editor-preview.d.cts +148 -14
  44. package/dist/theme-editor-preview.d.ts +148 -14
  45. package/dist/theme-editor-preview.js +48 -48
  46. package/dist/theme-editor.d.cts +148 -14
  47. package/dist/theme-editor.d.ts +148 -14
  48. package/dist/voice-runtime.d.cts +6 -2
  49. package/dist/voice-runtime.d.ts +6 -2
  50. package/package.json +1 -1
  51. package/src/ask-user-question-tool.ts +1 -1
  52. package/src/client-history-rest.test.ts +2 -1
  53. package/src/client-visitor-history.test.ts +20 -4
  54. package/src/client.composer-options.test.ts +1 -1
  55. package/src/client.interrupt.test.ts +2 -2
  56. package/src/client.test.ts +477 -915
  57. package/src/client.ts +134 -494
  58. package/src/client.unified-tools.test.ts +76 -0
  59. package/src/components/event-stream-badge-theming.test.ts +3 -0
  60. package/src/components/event-stream-view.test.ts +76 -76
  61. package/src/components/event-stream-view.ts +5 -0
  62. package/src/components/tool-bubble.test.ts +12 -0
  63. package/src/components/tool-bubble.ts +13 -2
  64. package/src/event-stream-view-bundle.test.ts +2 -2
  65. package/src/generated/runtype-openapi-contract.ts +129 -1
  66. package/src/internal/runtype-history-provider.test.ts +2 -2
  67. package/src/session-history.test.ts +1 -1
  68. package/src/session.quote.test.ts +1 -1
  69. package/src/session.resubmit-from.test.ts +1 -1
  70. package/src/session.test.ts +5 -5
  71. package/src/session.ts +95 -36
  72. package/src/suggest-replies-tool.ts +1 -1
  73. package/src/testing/mock-stream.test.ts +37 -16
  74. package/src/testing/mock-stream.ts +14 -9
  75. package/src/types.ts +19 -14
  76. package/src/ui.ask-user-question-plugin.test.ts +7 -7
  77. package/src/ui.composer-defer-one.test.ts +6 -34
  78. package/src/ui.composer-draft-persistence.test.ts +1 -1
  79. package/src/ui.composer-quote.test.ts +1 -1
  80. package/src/ui.message-history-actions.test.ts +1 -1
  81. package/src/ui.streaming-coalescing.test.ts +10 -13
  82. package/src/ui.ts +67 -32
  83. package/src/ui.typing-indicator.test.ts +216 -0
  84. package/src/ui.voice-custom-provider.test.ts +211 -0
  85. package/src/utils/event-stream-buffer.test.ts +13 -13
  86. package/src/utils/event-stream-capture.test.ts +20 -20
  87. package/src/utils/throughput-tracker.test.ts +100 -142
  88. package/src/utils/throughput-tracker.ts +18 -132
  89. package/src/utils/voice-support.ts +18 -1
  90. package/src/voice/voice-turn-tracker.ts +18 -0
  91. package/src/webmcp-bridge.ts +1 -1
  92. package/dist/event-stream-view-FKWDY3UB.js +0 -1
  93. 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
@@ -5386,7 +5513,7 @@ type EventStreamConfig = {
5386
5513
  /**
5387
5514
  * Custom badge color mappings by event type prefix or exact type.
5388
5515
  * Keys are matched as exact match first, then prefix match (keys ending with "_").
5389
- * @example { "flow_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5516
+ * @example { "execution_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5390
5517
  */
5391
5518
  badgeColors?: Record<string, EventStreamBadgeColor>;
5392
5519
  /**
@@ -6816,9 +6943,13 @@ interface VoiceProvider {
6816
6943
  * `isFinal=false` is a live interim update (user partials, or assistant deltas
6817
6944
  * on providers that stream them); `isFinal=true` finalizes that role's text.
6818
6945
  * On the realtime `runtype` path, interim updates fire for the `user` only and
6819
- * the `assistant` arrives as a single final.
6946
+ * the `assistant` arrives as a single final. Providers with overlapping turns
6947
+ * must include the same turnId on user and assistant finals; without IDs,
6948
+ * providers must discard cancelled output before emitting the next user final.
6820
6949
  */
6821
- onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean) => void): void;
6950
+ onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean, metadata?: {
6951
+ turnId?: string;
6952
+ }) => void): void;
6822
6953
  /** Register a callback for per-turn latency metrics (realtime path). */
6823
6954
  onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
6824
6955
  /**
@@ -9131,16 +9262,16 @@ type AgentWidgetConfig = {
9131
9262
  *
9132
9263
  * @example
9133
9264
  * ```typescript
9134
- * // For Runtype API format
9265
+ * // For a custom backend (Runtype unified events are handled natively)
9135
9266
  * config: {
9136
9267
  * parseSSEEvent: (data) => {
9137
- * if ((data.type === 'step_delta' || data.type === 'step_chunk') && (data.delta || data.chunk)) {
9138
- * return { text: data.delta ?? data.chunk };
9268
+ * if (data.type === 'token' && typeof data.value === 'string') {
9269
+ * return { text: data.value };
9139
9270
  * }
9140
- * if (data.type === 'flow_complete') {
9271
+ * if (data.type === 'done') {
9141
9272
  * return { done: true };
9142
9273
  * }
9143
- * if (data.type === 'step_error') {
9274
+ * if (data.type === 'failure') {
9144
9275
  * return { error: data.error };
9145
9276
  * }
9146
9277
  * return null; // Ignore other events
@@ -9342,7 +9473,7 @@ type AgentWidgetReasoning = {
9342
9473
  /**
9343
9474
  * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
9344
9475
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
9345
- * replaced the legacy `agent_reflection` event). Absent for legacy streams.
9476
+ * replaced the legacy `agent_reflection` event). Optional when the stream does not specify a scope.
9346
9477
  */
9347
9478
  scope?: "turn" | "loop";
9348
9479
  startedAt?: number;
@@ -9356,6 +9487,9 @@ type AgentWidgetToolCall = {
9356
9487
  args?: unknown;
9357
9488
  chunks?: string[];
9358
9489
  result?: unknown;
9490
+ /** Whether the tool succeeded; failure does not necessarily end the execution. */
9491
+ success?: boolean;
9492
+ error?: string;
9359
9493
  duration?: number;
9360
9494
  startedAt?: number;
9361
9495
  completedAt?: number;
@@ -9386,7 +9520,7 @@ type AgentWidgetApproval = {
9386
9520
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
9387
9521
  /**
9388
9522
  * Per-turn / per-step stop reason emitted by the runtime on
9389
- * `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
9523
+ * `turn_complete` and `step_complete` SSE events. The vocabulary is
9390
9524
  * owned by the upstream Runtype API: do not extend without coordination.
9391
9525
  *
9392
9526
  * - `end_turn`: natural completion (no affordance needed)
@@ -9517,7 +9651,7 @@ type AgentWidgetMessage = {
9517
9651
  */
9518
9652
  agentMetadata?: AgentMessageMetadata;
9519
9653
  /**
9520
- * Per-turn stop reason reported by the runtime on `agent_turn_complete`
9654
+ * Per-turn stop reason reported by the runtime on `turn_complete`
9521
9655
  * (agent-loop path) or the last `step_complete` for a prompt step
9522
9656
  * (dispatch / flow path). Absent when the API did not report a value.
9523
9657
  *
@@ -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
@@ -5386,7 +5513,7 @@ type EventStreamConfig = {
5386
5513
  /**
5387
5514
  * Custom badge color mappings by event type prefix or exact type.
5388
5515
  * Keys are matched as exact match first, then prefix match (keys ending with "_").
5389
- * @example { "flow_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5516
+ * @example { "execution_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5390
5517
  */
5391
5518
  badgeColors?: Record<string, EventStreamBadgeColor>;
5392
5519
  /**
@@ -6816,9 +6943,13 @@ interface VoiceProvider {
6816
6943
  * `isFinal=false` is a live interim update (user partials, or assistant deltas
6817
6944
  * on providers that stream them); `isFinal=true` finalizes that role's text.
6818
6945
  * On the realtime `runtype` path, interim updates fire for the `user` only and
6819
- * the `assistant` arrives as a single final.
6946
+ * the `assistant` arrives as a single final. Providers with overlapping turns
6947
+ * must include the same turnId on user and assistant finals; without IDs,
6948
+ * providers must discard cancelled output before emitting the next user final.
6820
6949
  */
6821
- onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean) => void): void;
6950
+ onTranscript?(callback: (role: 'user' | 'assistant', text: string, isFinal: boolean, metadata?: {
6951
+ turnId?: string;
6952
+ }) => void): void;
6822
6953
  /** Register a callback for per-turn latency metrics (realtime path). */
6823
6954
  onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
6824
6955
  /**
@@ -9131,16 +9262,16 @@ type AgentWidgetConfig = {
9131
9262
  *
9132
9263
  * @example
9133
9264
  * ```typescript
9134
- * // For Runtype API format
9265
+ * // For a custom backend (Runtype unified events are handled natively)
9135
9266
  * config: {
9136
9267
  * parseSSEEvent: (data) => {
9137
- * if ((data.type === 'step_delta' || data.type === 'step_chunk') && (data.delta || data.chunk)) {
9138
- * return { text: data.delta ?? data.chunk };
9268
+ * if (data.type === 'token' && typeof data.value === 'string') {
9269
+ * return { text: data.value };
9139
9270
  * }
9140
- * if (data.type === 'flow_complete') {
9271
+ * if (data.type === 'done') {
9141
9272
  * return { done: true };
9142
9273
  * }
9143
- * if (data.type === 'step_error') {
9274
+ * if (data.type === 'failure') {
9144
9275
  * return { error: data.error };
9145
9276
  * }
9146
9277
  * return null; // Ignore other events
@@ -9342,7 +9473,7 @@ type AgentWidgetReasoning = {
9342
9473
  /**
9343
9474
  * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
9344
9475
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
9345
- * replaced the legacy `agent_reflection` event). Absent for legacy streams.
9476
+ * replaced the legacy `agent_reflection` event). Optional when the stream does not specify a scope.
9346
9477
  */
9347
9478
  scope?: "turn" | "loop";
9348
9479
  startedAt?: number;
@@ -9356,6 +9487,9 @@ type AgentWidgetToolCall = {
9356
9487
  args?: unknown;
9357
9488
  chunks?: string[];
9358
9489
  result?: unknown;
9490
+ /** Whether the tool succeeded; failure does not necessarily end the execution. */
9491
+ success?: boolean;
9492
+ error?: string;
9359
9493
  duration?: number;
9360
9494
  startedAt?: number;
9361
9495
  completedAt?: number;
@@ -9386,7 +9520,7 @@ type AgentWidgetApproval = {
9386
9520
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
9387
9521
  /**
9388
9522
  * Per-turn / per-step stop reason emitted by the runtime on
9389
- * `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
9523
+ * `turn_complete` and `step_complete` SSE events. The vocabulary is
9390
9524
  * owned by the upstream Runtype API: do not extend without coordination.
9391
9525
  *
9392
9526
  * - `end_turn`: natural completion (no affordance needed)
@@ -9517,7 +9651,7 @@ type AgentWidgetMessage = {
9517
9651
  */
9518
9652
  agentMetadata?: AgentMessageMetadata;
9519
9653
  /**
9520
- * Per-turn stop reason reported by the runtime on `agent_turn_complete`
9654
+ * Per-turn stop reason reported by the runtime on `turn_complete`
9521
9655
  * (agent-loop path) or the last `step_complete` for a prompt step
9522
9656
  * (dispatch / flow path). Absent when the API did not report a value.
9523
9657
  *