@runtypelabs/persona 4.21.1 → 4.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/animations/glyph-cycle.d.cts +1 -1
  2. package/dist/animations/glyph-cycle.d.ts +1 -1
  3. package/dist/animations/{types-B_JdVK9o.d.cts → types-9Vxm-PPz.d.cts} +136 -6
  4. package/dist/animations/{types-B_JdVK9o.d.ts → types-9Vxm-PPz.d.ts} +136 -6
  5. package/dist/animations/wipe.d.cts +1 -1
  6. package/dist/animations/wipe.d.ts +1 -1
  7. package/dist/animations-extra.d.cts +136 -6
  8. package/dist/animations-extra.d.ts +136 -6
  9. package/dist/{approval-ui-RNNBR5R3.js → approval-ui-K7R5Q5OC.js} +1 -1
  10. package/dist/approval-ui.cjs +2 -2
  11. package/dist/approval-ui.d.cts +221 -16
  12. package/dist/approval-ui.d.ts +221 -16
  13. package/dist/approval-ui.js +2 -2
  14. package/dist/artifacts-ui-F4N6VMKF.js +7 -0
  15. package/dist/artifacts-ui.cjs +1 -1
  16. package/dist/artifacts-ui.d.cts +221 -16
  17. package/dist/artifacts-ui.d.ts +221 -16
  18. package/dist/artifacts-ui.js +1 -1
  19. package/dist/chunk-NQLDCJAP.js +4 -0
  20. package/dist/codegen.cjs +1 -1
  21. package/dist/codegen.js +1 -1
  22. package/dist/context-mentions.d.cts +221 -16
  23. package/dist/context-mentions.d.ts +221 -16
  24. package/dist/event-stream-view-GL3ADRY2.js +1 -0
  25. package/dist/event-stream-view.cjs +1 -1
  26. package/dist/event-stream-view.d.cts +221 -16
  27. package/dist/event-stream-view.d.ts +221 -16
  28. package/dist/event-stream-view.js +1 -1
  29. package/dist/forms-ui.d.cts +234 -25
  30. package/dist/forms-ui.d.ts +234 -25
  31. package/dist/history-view.d.cts +136 -6
  32. package/dist/history-view.d.ts +136 -6
  33. package/dist/index.cjs +70 -70
  34. package/dist/index.cjs.map +1 -1
  35. package/dist/index.d.cts +302 -32
  36. package/dist/index.d.ts +302 -32
  37. package/dist/index.global.js +54 -54
  38. package/dist/index.global.js.map +1 -1
  39. package/dist/index.js +69 -69
  40. package/dist/index.js.map +1 -1
  41. package/dist/launcher.global.js +2 -2
  42. package/dist/launcher.global.js.map +1 -1
  43. package/dist/session-reconnect.d.cts +221 -16
  44. package/dist/session-reconnect.d.ts +221 -16
  45. package/dist/smart-dom-reader.d.cts +221 -16
  46. package/dist/smart-dom-reader.d.ts +221 -16
  47. package/dist/testing.cjs +3 -3
  48. package/dist/testing.d.cts +3 -4
  49. package/dist/testing.d.ts +3 -4
  50. package/dist/testing.js +3 -3
  51. package/dist/theme-editor-preview.cjs +73 -73
  52. package/dist/theme-editor-preview.d.cts +221 -16
  53. package/dist/theme-editor-preview.d.ts +221 -16
  54. package/dist/theme-editor-preview.js +51 -51
  55. package/dist/theme-editor.cjs +4 -4
  56. package/dist/theme-editor.d.cts +221 -16
  57. package/dist/theme-editor.d.ts +221 -16
  58. package/dist/theme-editor.js +2 -2
  59. package/dist/theme-reference.cjs +1 -1
  60. package/dist/theme-reference.d.cts +65 -1
  61. package/dist/theme-reference.d.ts +65 -1
  62. package/dist/theme-reference.js +1 -1
  63. package/dist/voice-runtime.d.cts +6 -2
  64. package/dist/voice-runtime.d.ts +6 -2
  65. package/dist/webmcp-polyfill.js +1 -4
  66. package/dist/webmcp-runtime-JI7T4QYF.js +6 -0
  67. package/dist/webmcp-runtime.cjs +2 -2
  68. package/dist/webmcp-runtime.d.cts +34 -2
  69. package/dist/webmcp-runtime.d.ts +34 -2
  70. package/dist/webmcp-runtime.js +2 -2
  71. package/package.json +2 -2
  72. package/src/ask-user-question-tool.ts +1 -1
  73. package/src/client-history-rest.test.ts +2 -1
  74. package/src/client-visitor-history.test.ts +20 -4
  75. package/src/client.composer-options.test.ts +1 -1
  76. package/src/client.interrupt.test.ts +2 -2
  77. package/src/client.test.ts +477 -915
  78. package/src/client.ts +134 -494
  79. package/src/client.unified-tools.test.ts +76 -0
  80. package/src/components/artifact-preview.ts +5 -0
  81. package/src/components/event-stream-badge-theming.test.ts +162 -0
  82. package/src/components/event-stream-view.test.ts +76 -76
  83. package/src/components/event-stream-view.ts +55 -20
  84. package/src/components/tool-bubble.test.ts +12 -0
  85. package/src/components/tool-bubble.ts +13 -2
  86. package/src/event-stream-view-bundle.test.ts +2 -2
  87. package/src/generated/runtype-openapi-contract.ts +137 -1
  88. package/src/index-core.ts +2 -0
  89. package/src/internal/runtype-history-provider.test.ts +2 -2
  90. package/src/runtime/init.registry.test.ts +56 -0
  91. package/src/runtime/init.ts +17 -0
  92. package/src/session-history.test.ts +1 -1
  93. package/src/session.quote.test.ts +1 -1
  94. package/src/session.resubmit-from.test.ts +1 -1
  95. package/src/session.test.ts +5 -5
  96. package/src/session.ts +95 -36
  97. package/src/suggest-replies-tool.ts +1 -1
  98. package/src/testing/mock-stream.test.ts +37 -16
  99. package/src/testing/mock-stream.ts +14 -9
  100. package/src/types/theme.ts +41 -1
  101. package/src/types.ts +57 -15
  102. package/src/ui.ask-user-question-plugin.test.ts +7 -7
  103. package/src/ui.composer-defer-one.test.ts +6 -34
  104. package/src/ui.composer-draft-persistence.test.ts +1 -1
  105. package/src/ui.composer-quote.test.ts +1 -1
  106. package/src/ui.message-history-actions.test.ts +1 -1
  107. package/src/ui.reasoning-display.test.ts +136 -2
  108. package/src/ui.streaming-coalescing.test.ts +10 -13
  109. package/src/ui.ts +101 -35
  110. package/src/ui.typing-indicator.test.ts +216 -0
  111. package/src/ui.voice-custom-provider.test.ts +211 -0
  112. package/src/utils/__snapshots__/tokens-parity.test.ts.snap +1740 -0
  113. package/src/utils/event-stream-buffer.test.ts +13 -13
  114. package/src/utils/event-stream-capture.test.ts +20 -20
  115. package/src/utils/formatting.ts +22 -0
  116. package/src/utils/theme.ts +16 -0
  117. package/src/utils/throughput-tracker.test.ts +100 -142
  118. package/src/utils/throughput-tracker.ts +18 -132
  119. package/src/utils/tokens.ts +59 -0
  120. package/src/utils/voice-support.ts +18 -1
  121. package/src/voice/voice-turn-tracker.ts +18 -0
  122. package/src/webmcp-bridge.test.ts +132 -23
  123. package/src/webmcp-bridge.ts +27 -3
  124. package/src/webmcp-runtime-entry.ts +71 -11
  125. package/dist/artifacts-ui-J6AKUGTS.js +0 -7
  126. package/dist/chunk-HBE7LFNT.js +0 -4
  127. package/dist/event-stream-view-73NWKWVQ.js +0 -1
  128. package/dist/webmcp-runtime-P3CHZRHF.js +0 -6
  129. package/src/utils/__fixtures__/unified-translator.oracle.ts +0 -717
@@ -619,7 +619,11 @@ interface ColorPalette {
619
619
  warning: ColorShade;
620
620
  error: ColorShade;
621
621
  info: ColorShade;
622
- [key: string]: ColorShade;
622
+ /** Event-stream tool badge family. */
623
+ purple?: ColorShade;
624
+ /** Event-stream agent badge family. */
625
+ teal?: ColorShade;
626
+ [key: string]: ColorShade | undefined;
623
627
  }
624
628
  interface SpacingScale {
625
629
  0: string;
@@ -1191,6 +1195,38 @@ interface ToolBubbleTokens {
1191
1195
  interface ReasoningBubbleTokens {
1192
1196
  shadow: string;
1193
1197
  }
1198
+ /** One event-stream badge chip: fill + text pair. The chip border derives
1199
+ * from `foreground` at ~31% alpha. */
1200
+ interface EventStreamBadgePairTokens {
1201
+ background: TokenReference<'color'>;
1202
+ foreground: TokenReference<'color'>;
1203
+ }
1204
+ /**
1205
+ * Event-stream inspector badge chips (`features.eventStream`), one pair per
1206
+ * unified event family. Materialized into every theme and emitted as
1207
+ * `--persona-event-badge-<family>-{bg,fg}`, with scheme-appropriate defaults:
1208
+ * light themes pair a 100-tone fill with a 700-tone text, the built-in dark
1209
+ * layer flips to a 900-tone fill with a 300-tone text. `badge.default` colors
1210
+ * event types no family matches.
1211
+ */
1212
+ interface EventStreamTokens {
1213
+ badge: {
1214
+ /** `flow_*` events. */
1215
+ flow: EventStreamBadgePairTokens;
1216
+ /** `step_*` events. */
1217
+ step: EventStreamBadgePairTokens;
1218
+ /** `reasoning_*` events. */
1219
+ reasoning: EventStreamBadgePairTokens;
1220
+ /** `tool_*` events. */
1221
+ tool: EventStreamBadgePairTokens;
1222
+ /** `agent_*` events. */
1223
+ agent: EventStreamBadgePairTokens;
1224
+ /** `error` / `execution_error` events. */
1225
+ error: EventStreamBadgePairTokens;
1226
+ /** Any event type no other family matches. */
1227
+ default: EventStreamBadgePairTokens;
1228
+ };
1229
+ }
1194
1230
  /** Scrollbar appearance shared by every scroller in the widget. */
1195
1231
  interface ScrollbarTokens {
1196
1232
  /** Thumb color. @default semantic.colors.border */
@@ -1539,6 +1575,8 @@ interface ComponentTokens {
1539
1575
  attachment: AttachmentTokens;
1540
1576
  toolBubble: ToolBubbleTokens;
1541
1577
  reasoningBubble: ReasoningBubbleTokens;
1578
+ /** Event-stream inspector badge chips. */
1579
+ eventStream?: EventStreamTokens;
1542
1580
  composer: ComposerChromeTokens;
1543
1581
  /** Shared motion timing for composer chrome animation. */
1544
1582
  motion?: MotionTokens;
@@ -1656,6 +1694,11 @@ type RuntypeExecutionStreamEvent = ({
1656
1694
  iteration?: number;
1657
1695
  role: "user" | "assistant" | "system";
1658
1696
  seq: number;
1697
+ subagent?: {
1698
+ agentName?: string;
1699
+ parentToolCallId?: string;
1700
+ toolName: string;
1701
+ };
1659
1702
  turnIndex?: number;
1660
1703
  type: "turn_start";
1661
1704
  }) | ({
@@ -1690,12 +1733,61 @@ type RuntypeExecutionStreamEvent = ({
1690
1733
  role: "user" | "assistant" | "system";
1691
1734
  seq: number;
1692
1735
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
1736
+ subagent?: {
1737
+ agentName?: string;
1738
+ parentToolCallId?: string;
1739
+ toolName: string;
1740
+ };
1693
1741
  tokens?: {
1694
1742
  input: number;
1695
1743
  output: number;
1696
1744
  };
1697
1745
  type: "turn_complete";
1698
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
+ } | {
1699
1791
  executionId: string;
1700
1792
  id: string;
1701
1793
  index?: number;
@@ -1704,6 +1796,11 @@ type RuntypeExecutionStreamEvent = ({
1704
1796
  seq: number;
1705
1797
  startedAt?: string;
1706
1798
  stepType?: string;
1799
+ subagent?: {
1800
+ agentName?: string;
1801
+ parentToolCallId?: string;
1802
+ toolName: string;
1803
+ };
1707
1804
  totalSteps?: number;
1708
1805
  type: "step_start";
1709
1806
  } | ({
@@ -1731,6 +1828,11 @@ type RuntypeExecutionStreamEvent = ({
1731
1828
  seq: number;
1732
1829
  stepType?: string;
1733
1830
  stopReason?: "end_turn" | "max_tool_calls" | "length" | "content_filter" | "error" | "unknown";
1831
+ subagent?: {
1832
+ agentName?: string;
1833
+ parentToolCallId?: string;
1834
+ toolName: string;
1835
+ };
1734
1836
  success?: boolean;
1735
1837
  tokensUsed?: number;
1736
1838
  type: "step_complete";
@@ -1753,6 +1855,11 @@ type RuntypeExecutionStreamEvent = ({
1753
1855
  role?: "user" | "assistant" | "system";
1754
1856
  seq: number;
1755
1857
  stepId?: string;
1858
+ subagent?: {
1859
+ agentName?: string;
1860
+ parentToolCallId?: string;
1861
+ toolName: string;
1862
+ };
1756
1863
  turnId?: string;
1757
1864
  type: "text_start";
1758
1865
  }) | {
@@ -1760,11 +1867,21 @@ type RuntypeExecutionStreamEvent = ({
1760
1867
  executionId: string;
1761
1868
  id: string;
1762
1869
  seq: number;
1870
+ subagent?: {
1871
+ agentName?: string;
1872
+ parentToolCallId?: string;
1873
+ toolName: string;
1874
+ };
1763
1875
  type: "text_delta";
1764
1876
  } | {
1765
1877
  executionId: string;
1766
1878
  id: string;
1767
1879
  seq: number;
1880
+ subagent?: {
1881
+ agentName?: string;
1882
+ parentToolCallId?: string;
1883
+ toolName: string;
1884
+ };
1768
1885
  text?: string;
1769
1886
  type: "text_complete";
1770
1887
  } | ({
@@ -1773,18 +1890,33 @@ type RuntypeExecutionStreamEvent = ({
1773
1890
  parentToolCallId?: string;
1774
1891
  scope?: "turn" | "loop";
1775
1892
  seq: number;
1893
+ subagent?: {
1894
+ agentName?: string;
1895
+ parentToolCallId?: string;
1896
+ toolName: string;
1897
+ };
1776
1898
  type: "reasoning_start";
1777
1899
  }) | {
1778
1900
  delta: string;
1779
1901
  executionId: string;
1780
1902
  id: string;
1781
1903
  seq: number;
1904
+ subagent?: {
1905
+ agentName?: string;
1906
+ parentToolCallId?: string;
1907
+ toolName: string;
1908
+ };
1782
1909
  type: "reasoning_delta";
1783
1910
  } | ({
1784
1911
  executionId: string;
1785
1912
  id: string;
1786
1913
  scope?: "turn" | "loop";
1787
1914
  seq: number;
1915
+ subagent?: {
1916
+ agentName?: string;
1917
+ parentToolCallId?: string;
1918
+ toolName: string;
1919
+ };
1788
1920
  text?: string;
1789
1921
  type: "reasoning_complete";
1790
1922
  }) | ({
@@ -1877,6 +2009,11 @@ type RuntypeExecutionStreamEvent = ({
1877
2009
  seq: number;
1878
2010
  startedAt?: string;
1879
2011
  stepId?: string;
2012
+ subagent?: {
2013
+ agentName?: string;
2014
+ parentToolCallId?: string;
2015
+ toolName: string;
2016
+ };
1880
2017
  toolCallId: string;
1881
2018
  toolName: string;
1882
2019
  toolType: string;
@@ -1885,6 +2022,11 @@ type RuntypeExecutionStreamEvent = ({
1885
2022
  delta: string;
1886
2023
  executionId: string;
1887
2024
  seq: number;
2025
+ subagent?: {
2026
+ agentName?: string;
2027
+ parentToolCallId?: string;
2028
+ toolName: string;
2029
+ };
1888
2030
  toolCallId: string;
1889
2031
  type: "tool_input_delta";
1890
2032
  } | {
@@ -1892,6 +2034,11 @@ type RuntypeExecutionStreamEvent = ({
1892
2034
  hiddenParameterNames?: Array<string>;
1893
2035
  parameters: Record<string, unknown>;
1894
2036
  seq: number;
2037
+ subagent?: {
2038
+ agentName?: string;
2039
+ parentToolCallId?: string;
2040
+ toolName: string;
2041
+ };
1895
2042
  toolCallId: string;
1896
2043
  toolName?: string;
1897
2044
  type: "tool_input_complete";
@@ -1909,6 +2056,11 @@ type RuntypeExecutionStreamEvent = ({
1909
2056
  result?: unknown;
1910
2057
  seq: number;
1911
2058
  stepId?: string;
2059
+ subagent?: {
2060
+ agentName?: string;
2061
+ parentToolCallId?: string;
2062
+ toolName: string;
2063
+ };
1912
2064
  success: boolean;
1913
2065
  toolCallId: string;
1914
2066
  toolCost?: number;
@@ -1988,6 +2140,19 @@ type RuntypeExecutionStreamEvent = ({
1988
2140
  recoverable?: boolean;
1989
2141
  seq: number;
1990
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";
1991
2156
  }) | {
1992
2157
  executionId: string;
1993
2158
  seq: number;
@@ -2986,6 +3151,14 @@ type ClientToolDefinition = {
2986
3151
  readOnlyHint?: boolean;
2987
3152
  untrustedContentHint?: boolean;
2988
3153
  };
3154
+ /**
3155
+ * Hoisted copy of `annotations.untrustedContentHint`. This is the field the
3156
+ * server actually acts on (`InlineClientToolSchema`): it spotlights the
3157
+ * tool's output before the model reads it, so instructions embedded in
3158
+ * page-provided content (reviews, comments, emails) are not treated as
3159
+ * instructions. `annotations` itself is trace/dashboard metadata only.
3160
+ */
3161
+ untrustedContentHint?: boolean;
2989
3162
  };
2990
3163
  /**
2991
3164
  * Information passed to the confirm-bubble handler before a `webmcp:*` tool
@@ -3139,15 +3312,15 @@ type AgentMessageMetadata = {
3139
3312
  */
3140
3313
  parentStepId?: string;
3141
3314
  /**
3142
- * 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`
3143
3316
  * event (`awaitReason: "local_tool_required"`). Signals to UI code that
3144
3317
  * the tool call is a LOCAL tool and the server is paused waiting for a
3145
3318
  * `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
3146
3319
  */
3147
3320
  awaitingLocalTool?: boolean;
3148
3321
  /**
3149
- * The provider per-call id (`toolu_…`) carried on the `step_await` /
3150
- * `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
3151
3324
  * server emits it. Two PARALLEL calls to the same tool in one turn share a
3152
3325
  * `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
3153
3326
  * so this is the key the widget batches a single `/resume` on: preferred
@@ -4210,6 +4383,16 @@ type AgentWidgetToolCallDisplayFeature = {
4210
4383
  * @default "stack"
4211
4384
  */
4212
4385
  groupedMode?: "stack" | "summary";
4386
+ /**
4387
+ * What happens to a tool call row once it completes.
4388
+ *
4389
+ * - `"kept"` (default): the finished row stays in the transcript.
4390
+ * - `"removed"`: no row is rendered at all, so the transcript gap closes with
4391
+ * it. The tool call stays on the message and in `getMessages()`.
4392
+ *
4393
+ * @default "kept"
4394
+ */
4395
+ completedVisibility?: AgentWidgetToolCallCompletedVisibility;
4213
4396
  /**
4214
4397
  * When false, tool call bubbles show only the collapsed summary with no
4215
4398
  * expand/collapse toggle. Users see tool awareness without full details.
@@ -4227,6 +4410,8 @@ type AgentWidgetToolCallDisplayFeature = {
4227
4410
  */
4228
4411
  loadingAnimation?: AgentWidgetToolCallLoadingAnimation;
4229
4412
  };
4413
+ /** See `features.toolCallDisplay.completedVisibility`. */
4414
+ type AgentWidgetToolCallCompletedVisibility = "kept" | "removed";
4230
4415
  type AgentWidgetReasoningDisplayFeature = {
4231
4416
  /**
4232
4417
  * When true, active collapsed reasoning rows can render a lightweight preview block.
@@ -4272,13 +4457,26 @@ type AgentWidgetReasoningDisplayFeature = {
4272
4457
  * - `"kept"` (default): the finished row stays in the transcript.
4273
4458
  * - `"removed"`: no row is rendered at all, so the transcript gap closes with
4274
4459
  * it. The reasoning text stays on the message and in `getMessages()`.
4460
+ * - `"removed-when-short"`: behaves as `"removed"` when the completed trace
4461
+ * is short (see `shortThinkThreshold`), and as `"kept"` otherwise.
4275
4462
  *
4276
4463
  * @default "kept"
4277
4464
  */
4278
4465
  completedVisibility?: AgentWidgetReasoningCompletedVisibility;
4466
+ /**
4467
+ * Thresholds used by `completedVisibility: "removed-when-short"` to decide
4468
+ * whether a completed trace counts as short. Duration is checked first when
4469
+ * the reasoning reports one; the character count is a fallback for traces
4470
+ * with no reported duration.
4471
+ * @default { durationMs: 15000, chars: 1200 }
4472
+ */
4473
+ shortThinkThreshold?: {
4474
+ durationMs?: number;
4475
+ chars?: number;
4476
+ };
4279
4477
  };
4280
4478
  /** See `features.reasoningDisplay.completedVisibility`. */
4281
- type AgentWidgetReasoningCompletedVisibility = "kept" | "removed";
4479
+ type AgentWidgetReasoningCompletedVisibility = "kept" | "removed" | "removed-when-short";
4282
4480
  /**
4283
4481
  * Reveal animation applied to assistant message text while it is streaming.
4284
4482
  *
@@ -5272,7 +5470,7 @@ type EventStreamConfig = {
5272
5470
  /**
5273
5471
  * Custom badge color mappings by event type prefix or exact type.
5274
5472
  * Keys are matched as exact match first, then prefix match (keys ending with "_").
5275
- * @example { "flow_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5473
+ * @example { "execution_": { bg: "#dcfce7", text: "#166534" }, "error": { bg: "#fecaca", text: "#991b1b" } }
5276
5474
  */
5277
5475
  badgeColors?: Record<string, EventStreamBadgeColor>;
5278
5476
  /**
@@ -6750,9 +6948,13 @@ interface VoiceProvider {
6750
6948
  * `isFinal=false` is a live interim update (user partials, or assistant deltas
6751
6949
  * on providers that stream them); `isFinal=true` finalizes that role's text.
6752
6950
  * On the realtime `runtype` path, interim updates fire for the `user` only and
6753
- * 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.
6754
6954
  */
6755
- 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;
6756
6958
  /** Register a callback for per-turn latency metrics (realtime path). */
6757
6959
  onMetrics?(callback: (metrics: VoiceMetrics) => void): void;
6758
6960
  /**
@@ -9163,16 +9365,16 @@ type AgentWidgetConfig = {
9163
9365
  *
9164
9366
  * @example
9165
9367
  * ```typescript
9166
- * // For Runtype API format
9368
+ * // For a custom backend (Runtype unified events are handled natively)
9167
9369
  * config: {
9168
9370
  * parseSSEEvent: (data) => {
9169
- * if ((data.type === 'step_delta' || data.type === 'step_chunk') && (data.delta || data.chunk)) {
9170
- * return { text: data.delta ?? data.chunk };
9371
+ * if (data.type === 'token' && typeof data.value === 'string') {
9372
+ * return { text: data.value };
9171
9373
  * }
9172
- * if (data.type === 'flow_complete') {
9374
+ * if (data.type === 'done') {
9173
9375
  * return { done: true };
9174
9376
  * }
9175
- * if (data.type === 'step_error') {
9377
+ * if (data.type === 'failure') {
9176
9378
  * return { error: data.error };
9177
9379
  * }
9178
9380
  * return null; // Ignore other events
@@ -9363,7 +9565,7 @@ type AgentWidgetReasoning = {
9363
9565
  /**
9364
9566
  * Reasoning channel scope (wire spec). `"turn"` is ordinary per-turn
9365
9567
  * thinking; `"loop"` is a cross-iteration agent reflection (the fold that
9366
- * 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.
9367
9569
  */
9368
9570
  scope?: "turn" | "loop";
9369
9571
  startedAt?: number;
@@ -9377,6 +9579,9 @@ type AgentWidgetToolCall = {
9377
9579
  args?: unknown;
9378
9580
  chunks?: string[];
9379
9581
  result?: unknown;
9582
+ /** Whether the tool succeeded; failure does not necessarily end the execution. */
9583
+ success?: boolean;
9584
+ error?: string;
9380
9585
  duration?: number;
9381
9586
  startedAt?: number;
9382
9587
  completedAt?: number;
@@ -9407,7 +9612,7 @@ type AgentWidgetApproval = {
9407
9612
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
9408
9613
  /**
9409
9614
  * Per-turn / per-step stop reason emitted by the runtime on
9410
- * `agent_turn_complete` and `step_complete` SSE events. The vocabulary is
9615
+ * `turn_complete` and `step_complete` SSE events. The vocabulary is
9411
9616
  * owned by the upstream Runtype API: do not extend without coordination.
9412
9617
  *
9413
9618
  * - `end_turn`: natural completion (no affordance needed)
@@ -9538,7 +9743,7 @@ type AgentWidgetMessage = {
9538
9743
  */
9539
9744
  agentMetadata?: AgentMessageMetadata;
9540
9745
  /**
9541
- * Per-turn stop reason reported by the runtime on `agent_turn_complete`
9746
+ * Per-turn stop reason reported by the runtime on `turn_complete`
9542
9747
  * (agent-loop path) or the last `step_complete` for a prompt step
9543
9748
  * (dispatch / flow path). Absent when the API did not report a value.
9544
9749
  *
@@ -10219,7 +10424,7 @@ declare class AgentWidgetClient {
10219
10424
  * Returns the raw Response so the caller can pipe its SSE body through
10220
10425
  * `connectStream()`.
10221
10426
  *
10222
- * @param executionId - The paused execution id carried on `step_await`.
10427
+ * @param executionId - The paused execution id carried on `await`.
10223
10428
  * @param toolOutputs - Map keyed by per-call `toolCallId` (core#3878),
10224
10429
  * falling back to tool name for legacy servers → the tool's result value.
10225
10430
  */
@@ -10505,6 +10710,8 @@ declare class AgentWidgetSession {
10505
10710
  deactivateBargeIn(): Promise<void>;
10506
10711
  private pendingVoiceUserMessageId;
10507
10712
  private pendingVoiceAssistantMessageId;
10713
+ private voiceTurns;
10714
+ private voiceDisconnectPromise;
10508
10715
  private ttsSpokenMessageIds;
10509
10716
  private readAloud;
10510
10717
  /**
@@ -10533,6 +10740,8 @@ declare class AgentWidgetSession {
10533
10740
  * Cleanup voice resources
10534
10741
  */
10535
10742
  cleanupVoice(): void;
10743
+ private disconnectVoice;
10744
+ private settlePendingVoiceTurn;
10536
10745
  /**
10537
10746
  * Extract voice configuration from widget config
10538
10747
  */
@@ -11027,7 +11236,7 @@ declare class AgentWidgetSession {
11027
11236
  /**
11028
11237
  * Resolve a paused `ask_user_question` LOCAL tool call.
11029
11238
  *
11030
- * When the server emits `step_await` for `ask_user_question`, the widget
11239
+ * When the server emits `await` for `ask_user_question`, the widget
11031
11240
  * renders the answer-pill sheet and calls this method once the user
11032
11241
  * picks. Steps:
11033
11242
  * 1. POST the answer to `/resume` via `client.resumeFlow`.
@@ -11056,10 +11265,10 @@ declare class AgentWidgetSession {
11056
11265
  markAskUserQuestionResolved(toolMessage: AgentWidgetMessage, answers?: Record<string, string | string[]>): void;
11057
11266
  resolveAskUserQuestion(toolMessage: AgentWidgetMessage, answer: string | Record<string, string | string[]>): Promise<void>;
11058
11267
  /**
11059
- * Collect an auto-resolving LOCAL-tool `step_await` (`webmcp:*` page tools
11268
+ * Collect an auto-resolving LOCAL-tool `await` (`webmcp:*` page tools
11060
11269
  * and the built-in `suggest_replies`) into a per-executionId batch
11061
11270
  * and schedule a single deferred flush. Parallel calls (core#3878) emit
11062
- * 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;
11063
11272
  * buffering them and flushing once lets us post ONE `/resume` keyed by the
11064
11273
  * per-call `webMcpToolCallId` rather than racing N name-keyed resumes on the
11065
11274
  * same execution (which 404'd on the second and hung the turn).
@@ -11077,7 +11286,7 @@ declare class AgentWidgetSession {
11077
11286
  /**
11078
11287
  * Flush every buffered local-tool await batch, one `/resume` per executionId.
11079
11288
  * Called once a stream ends (`status: idle` / `error`): by then all parallel
11080
- * `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
11081
11290
  * SSE chunks. Deferred via `queueMicrotask` (epoch-guarded) so the idle
11082
11291
  * handler returns first and the stream's end-of-stream teardown (streaming /
11083
11292
  * abortController) settles before a resolve grabs them: the same ordering the
@@ -11098,7 +11307,7 @@ declare class AgentWidgetSession {
11098
11307
  * Persisted-resolution guard for `suggest_replies`. The in-memory dedupe
11099
11308
  * sets (`webMcpInflightKeys` / `webMcpResolvedKeys`) are cleared by
11100
11309
  * hydrateMessages/clearMessages/cancel, but `suggestRepliesResolved`
11101
- * 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
11102
11311
  * hydration must not re-POST `/resume` for an already-resolved call (the
11103
11312
  * historical double-resume failure mode the batching work exists to avoid).
11104
11313
  * Checks the LIVE message first; the handleEvent snapshot is a fresh wire
@@ -11132,12 +11341,12 @@ declare class AgentWidgetSession {
11132
11341
  * resumes with a canned "shown" result (the chips render from the message
11133
11342
  * list, not from this resolve).
11134
11343
  *
11135
- * Triggered automatically from `handleEvent` when a `step_await`-derived
11344
+ * Triggered automatically from `handleEvent` when an `await`-derived
11136
11345
  * message arrives for such a tool: the user does not click a pill; the
11137
11346
  * bridge's confirm-bubble gate (WebMCP only) is the only interactive
11138
11347
  * surface.
11139
11348
  *
11140
- * 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
11141
11350
  * (e.g. from message coalescing) won't double-fire `tool.execute`. Failure
11142
11351
  * modes, declined, timed out, throw, unknown tool, all resolve into a
11143
11352
  * `{ isError: true, content: [...] }` payload that resumes the dispatch
@@ -11216,7 +11425,7 @@ declare class AgentWidgetSession {
11216
11425
  private trackCursor;
11217
11426
  /**
11218
11427
  * The drop gate: is this stream-end a dropped connection we should reconnect,
11219
- * 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
11220
11429
  * hold (see plan §Design overview keystone 3).
11221
11430
  */
11222
11431
  private isDurableDrop;