@runtypelabs/persona 4.23.0 → 4.23.2

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 (49) 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-9Vxm-PPz.d.cts → types-CI7OckWI.d.cts} +23 -2
  4. package/dist/animations/{types-9Vxm-PPz.d.ts → types-CI7OckWI.d.ts} +23 -2
  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 +23 -2
  8. package/dist/animations-extra.d.ts +23 -2
  9. package/dist/approval-ui.d.cts +46 -3
  10. package/dist/approval-ui.d.ts +46 -3
  11. package/dist/artifacts-ui.d.cts +46 -3
  12. package/dist/artifacts-ui.d.ts +46 -3
  13. package/dist/codegen.cjs +1 -1
  14. package/dist/codegen.js +1 -1
  15. package/dist/context-mentions.d.cts +46 -3
  16. package/dist/context-mentions.d.ts +46 -3
  17. package/dist/event-stream-view.d.cts +46 -3
  18. package/dist/event-stream-view.d.ts +46 -3
  19. package/dist/forms-ui.d.cts +46 -3
  20. package/dist/forms-ui.d.ts +46 -3
  21. package/dist/history-view.d.cts +23 -2
  22. package/dist/history-view.d.ts +23 -2
  23. package/dist/index.cjs +43 -43
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +67 -12
  26. package/dist/index.d.ts +67 -12
  27. package/dist/index.global.js +28 -28
  28. package/dist/index.global.js.map +1 -1
  29. package/dist/index.js +43 -43
  30. package/dist/index.js.map +1 -1
  31. package/dist/session-reconnect.d.cts +46 -3
  32. package/dist/session-reconnect.d.ts +46 -3
  33. package/dist/smart-dom-reader.d.cts +46 -3
  34. package/dist/smart-dom-reader.d.ts +46 -3
  35. package/dist/theme-editor-preview.cjs +49 -49
  36. package/dist/theme-editor-preview.d.cts +46 -3
  37. package/dist/theme-editor-preview.d.ts +46 -3
  38. package/dist/theme-editor-preview.js +33 -33
  39. package/dist/theme-editor.d.cts +46 -3
  40. package/dist/theme-editor.d.ts +46 -3
  41. package/package.json +1 -1
  42. package/src/client-session-renewal.test.ts +268 -0
  43. package/src/client.interrupt.test.ts +1 -1
  44. package/src/client.tool-pair-replay.test.ts +325 -0
  45. package/src/client.ts +93 -49
  46. package/src/generated/runtype-openapi-contract.ts +26 -11
  47. package/src/session.ts +32 -3
  48. package/src/types.ts +43 -1
  49. package/src/utils/tool-pair-replay.ts +100 -0
@@ -1702,6 +1702,7 @@ type RuntypeExecutionStreamEvent = ({
1702
1702
  turnIndex?: number;
1703
1703
  type: "turn_start";
1704
1704
  }) | ({
1705
+ attributes?: Record<string, string | number | boolean>;
1705
1706
  completedAt?: string;
1706
1707
  content?: string;
1707
1708
  cost?: number;
@@ -1760,7 +1761,8 @@ type RuntypeExecutionStreamEvent = ({
1760
1761
  };
1761
1762
  turnId?: string;
1762
1763
  type: "model_call_start";
1763
- } | {
1764
+ } | ({
1765
+ attributes?: Record<string, string | number | boolean>;
1764
1766
  completedAt?: string;
1765
1767
  cost?: number;
1766
1768
  durationMs?: number;
@@ -1784,10 +1786,11 @@ type RuntypeExecutionStreamEvent = ({
1784
1786
  cacheWrite?: number;
1785
1787
  input: number;
1786
1788
  output: number;
1789
+ reasoning?: number;
1787
1790
  };
1788
1791
  turnId?: string;
1789
1792
  type: "model_call_complete";
1790
- } | {
1793
+ }) | {
1791
1794
  executionId: string;
1792
1795
  id: string;
1793
1796
  index?: number;
@@ -2887,10 +2890,32 @@ type AgentWidgetContextMentionTokenRenderContext = {
2887
2890
  ref: AgentWidgetContextMentionRef;
2888
2891
  readonly: boolean;
2889
2892
  };
2893
+ /** One earlier client-tool call replayed to the model, in `/v1/dispatch` shape. */
2894
+ type AgentWidgetReplayedToolCall = {
2895
+ toolCallId: string;
2896
+ /** Model-facing (sanitized) name, e.g. `webmcp_search`. */
2897
+ toolName: string;
2898
+ args: Record<string, unknown>;
2899
+ };
2900
+ /** The browser's answer to an {@link AgentWidgetReplayedToolCall}. */
2901
+ type AgentWidgetReplayedToolResult = {
2902
+ toolCallId: string;
2903
+ toolName: string;
2904
+ result: unknown;
2905
+ };
2906
+ /**
2907
+ * A message in the proxy/agent request payload. Earlier client-tool calls the
2908
+ * browser answered replay as an assistant message carrying `toolCalls`,
2909
+ * followed by a `tool` message carrying the matching `toolResults`; both have
2910
+ * empty `content`. Client-token mode never sends them: the server replays
2911
+ * from its own stored transcript there.
2912
+ */
2890
2913
  type AgentWidgetRequestPayloadMessage = {
2891
- role: AgentWidgetMessageRole;
2914
+ role: AgentWidgetMessageRole | "tool";
2892
2915
  content: MessageContent;
2893
2916
  createdAt: string;
2917
+ toolCalls?: AgentWidgetReplayedToolCall[];
2918
+ toolResults?: AgentWidgetReplayedToolResult[];
2894
2919
  };
2895
2920
  type AgentWidgetRequestPayload = {
2896
2921
  messages: AgentWidgetRequestPayloadMessage[];
@@ -3253,6 +3278,24 @@ type AgentMessageMetadata = {
3253
3278
  * never re-resume the call.
3254
3279
  */
3255
3280
  suggestRepliesResolved?: boolean;
3281
+ /**
3282
+ * The client-tool answer the server accepted through `/resume`, kept so
3283
+ * later proxy/agent turns can replay the call and its result to the model.
3284
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
3285
+ * built-in). Set only after the resume succeeds; preserved across
3286
+ * re-emissions of the tool message.
3287
+ */
3288
+ clientToolAnswer?: {
3289
+ toolCallId: string;
3290
+ toolName: string;
3291
+ args: unknown;
3292
+ result: unknown;
3293
+ /**
3294
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
3295
+ * turn's parallel calls; a chained call gets a new batch.
3296
+ */
3297
+ batch?: string;
3298
+ };
3256
3299
  };
3257
3300
  type AgentWidgetRequestMiddlewareContext = {
3258
3301
  payload: AgentWidgetRequestPayload;
@@ -1702,6 +1702,7 @@ type RuntypeExecutionStreamEvent = ({
1702
1702
  turnIndex?: number;
1703
1703
  type: "turn_start";
1704
1704
  }) | ({
1705
+ attributes?: Record<string, string | number | boolean>;
1705
1706
  completedAt?: string;
1706
1707
  content?: string;
1707
1708
  cost?: number;
@@ -1760,7 +1761,8 @@ type RuntypeExecutionStreamEvent = ({
1760
1761
  };
1761
1762
  turnId?: string;
1762
1763
  type: "model_call_start";
1763
- } | {
1764
+ } | ({
1765
+ attributes?: Record<string, string | number | boolean>;
1764
1766
  completedAt?: string;
1765
1767
  cost?: number;
1766
1768
  durationMs?: number;
@@ -1784,10 +1786,11 @@ type RuntypeExecutionStreamEvent = ({
1784
1786
  cacheWrite?: number;
1785
1787
  input: number;
1786
1788
  output: number;
1789
+ reasoning?: number;
1787
1790
  };
1788
1791
  turnId?: string;
1789
1792
  type: "model_call_complete";
1790
- } | {
1793
+ }) | {
1791
1794
  executionId: string;
1792
1795
  id: string;
1793
1796
  index?: number;
@@ -2887,10 +2890,32 @@ type AgentWidgetContextMentionTokenRenderContext = {
2887
2890
  ref: AgentWidgetContextMentionRef;
2888
2891
  readonly: boolean;
2889
2892
  };
2893
+ /** One earlier client-tool call replayed to the model, in `/v1/dispatch` shape. */
2894
+ type AgentWidgetReplayedToolCall = {
2895
+ toolCallId: string;
2896
+ /** Model-facing (sanitized) name, e.g. `webmcp_search`. */
2897
+ toolName: string;
2898
+ args: Record<string, unknown>;
2899
+ };
2900
+ /** The browser's answer to an {@link AgentWidgetReplayedToolCall}. */
2901
+ type AgentWidgetReplayedToolResult = {
2902
+ toolCallId: string;
2903
+ toolName: string;
2904
+ result: unknown;
2905
+ };
2906
+ /**
2907
+ * A message in the proxy/agent request payload. Earlier client-tool calls the
2908
+ * browser answered replay as an assistant message carrying `toolCalls`,
2909
+ * followed by a `tool` message carrying the matching `toolResults`; both have
2910
+ * empty `content`. Client-token mode never sends them: the server replays
2911
+ * from its own stored transcript there.
2912
+ */
2890
2913
  type AgentWidgetRequestPayloadMessage = {
2891
- role: AgentWidgetMessageRole;
2914
+ role: AgentWidgetMessageRole | "tool";
2892
2915
  content: MessageContent;
2893
2916
  createdAt: string;
2917
+ toolCalls?: AgentWidgetReplayedToolCall[];
2918
+ toolResults?: AgentWidgetReplayedToolResult[];
2894
2919
  };
2895
2920
  type AgentWidgetRequestPayload = {
2896
2921
  messages: AgentWidgetRequestPayloadMessage[];
@@ -3253,6 +3278,24 @@ type AgentMessageMetadata = {
3253
3278
  * never re-resume the call.
3254
3279
  */
3255
3280
  suggestRepliesResolved?: boolean;
3281
+ /**
3282
+ * The client-tool answer the server accepted through `/resume`, kept so
3283
+ * later proxy/agent turns can replay the call and its result to the model.
3284
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
3285
+ * built-in). Set only after the resume succeeds; preserved across
3286
+ * re-emissions of the tool message.
3287
+ */
3288
+ clientToolAnswer?: {
3289
+ toolCallId: string;
3290
+ toolName: string;
3291
+ args: unknown;
3292
+ result: unknown;
3293
+ /**
3294
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
3295
+ * turn's parallel calls; a chained call gets a new batch.
3296
+ */
3297
+ batch?: string;
3298
+ };
3256
3299
  };
3257
3300
  type AgentWidgetRequestMiddlewareContext = {
3258
3301
  payload: AgentWidgetRequestPayload;
@@ -1702,6 +1702,7 @@ type RuntypeExecutionStreamEvent = ({
1702
1702
  turnIndex?: number;
1703
1703
  type: "turn_start";
1704
1704
  }) | ({
1705
+ attributes?: Record<string, string | number | boolean>;
1705
1706
  completedAt?: string;
1706
1707
  content?: string;
1707
1708
  cost?: number;
@@ -1760,7 +1761,8 @@ type RuntypeExecutionStreamEvent = ({
1760
1761
  };
1761
1762
  turnId?: string;
1762
1763
  type: "model_call_start";
1763
- } | {
1764
+ } | ({
1765
+ attributes?: Record<string, string | number | boolean>;
1764
1766
  completedAt?: string;
1765
1767
  cost?: number;
1766
1768
  durationMs?: number;
@@ -1784,10 +1786,11 @@ type RuntypeExecutionStreamEvent = ({
1784
1786
  cacheWrite?: number;
1785
1787
  input: number;
1786
1788
  output: number;
1789
+ reasoning?: number;
1787
1790
  };
1788
1791
  turnId?: string;
1789
1792
  type: "model_call_complete";
1790
- } | {
1793
+ }) | {
1791
1794
  executionId: string;
1792
1795
  id: string;
1793
1796
  index?: number;
@@ -2887,10 +2890,32 @@ type AgentWidgetContextMentionTokenRenderContext = {
2887
2890
  ref: AgentWidgetContextMentionRef;
2888
2891
  readonly: boolean;
2889
2892
  };
2893
+ /** One earlier client-tool call replayed to the model, in `/v1/dispatch` shape. */
2894
+ type AgentWidgetReplayedToolCall = {
2895
+ toolCallId: string;
2896
+ /** Model-facing (sanitized) name, e.g. `webmcp_search`. */
2897
+ toolName: string;
2898
+ args: Record<string, unknown>;
2899
+ };
2900
+ /** The browser's answer to an {@link AgentWidgetReplayedToolCall}. */
2901
+ type AgentWidgetReplayedToolResult = {
2902
+ toolCallId: string;
2903
+ toolName: string;
2904
+ result: unknown;
2905
+ };
2906
+ /**
2907
+ * A message in the proxy/agent request payload. Earlier client-tool calls the
2908
+ * browser answered replay as an assistant message carrying `toolCalls`,
2909
+ * followed by a `tool` message carrying the matching `toolResults`; both have
2910
+ * empty `content`. Client-token mode never sends them: the server replays
2911
+ * from its own stored transcript there.
2912
+ */
2890
2913
  type AgentWidgetRequestPayloadMessage = {
2891
- role: AgentWidgetMessageRole;
2914
+ role: AgentWidgetMessageRole | "tool";
2892
2915
  content: MessageContent;
2893
2916
  createdAt: string;
2917
+ toolCalls?: AgentWidgetReplayedToolCall[];
2918
+ toolResults?: AgentWidgetReplayedToolResult[];
2894
2919
  };
2895
2920
  type AgentWidgetRequestPayload = {
2896
2921
  messages: AgentWidgetRequestPayloadMessage[];
@@ -3253,6 +3278,24 @@ type AgentMessageMetadata = {
3253
3278
  * never re-resume the call.
3254
3279
  */
3255
3280
  suggestRepliesResolved?: boolean;
3281
+ /**
3282
+ * The client-tool answer the server accepted through `/resume`, kept so
3283
+ * later proxy/agent turns can replay the call and its result to the model.
3284
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
3285
+ * built-in). Set only after the resume succeeds; preserved across
3286
+ * re-emissions of the tool message.
3287
+ */
3288
+ clientToolAnswer?: {
3289
+ toolCallId: string;
3290
+ toolName: string;
3291
+ args: unknown;
3292
+ result: unknown;
3293
+ /**
3294
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
3295
+ * turn's parallel calls; a chained call gets a new batch.
3296
+ */
3297
+ batch?: string;
3298
+ };
3256
3299
  };
3257
3300
  type AgentWidgetRequestMiddlewareContext = {
3258
3301
  payload: AgentWidgetRequestPayload;
@@ -1702,6 +1702,7 @@ type RuntypeExecutionStreamEvent = ({
1702
1702
  turnIndex?: number;
1703
1703
  type: "turn_start";
1704
1704
  }) | ({
1705
+ attributes?: Record<string, string | number | boolean>;
1705
1706
  completedAt?: string;
1706
1707
  content?: string;
1707
1708
  cost?: number;
@@ -1760,7 +1761,8 @@ type RuntypeExecutionStreamEvent = ({
1760
1761
  };
1761
1762
  turnId?: string;
1762
1763
  type: "model_call_start";
1763
- } | {
1764
+ } | ({
1765
+ attributes?: Record<string, string | number | boolean>;
1764
1766
  completedAt?: string;
1765
1767
  cost?: number;
1766
1768
  durationMs?: number;
@@ -1784,10 +1786,11 @@ type RuntypeExecutionStreamEvent = ({
1784
1786
  cacheWrite?: number;
1785
1787
  input: number;
1786
1788
  output: number;
1789
+ reasoning?: number;
1787
1790
  };
1788
1791
  turnId?: string;
1789
1792
  type: "model_call_complete";
1790
- } | {
1793
+ }) | {
1791
1794
  executionId: string;
1792
1795
  id: string;
1793
1796
  index?: number;
@@ -2887,10 +2890,32 @@ type AgentWidgetContextMentionTokenRenderContext = {
2887
2890
  ref: AgentWidgetContextMentionRef;
2888
2891
  readonly: boolean;
2889
2892
  };
2893
+ /** One earlier client-tool call replayed to the model, in `/v1/dispatch` shape. */
2894
+ type AgentWidgetReplayedToolCall = {
2895
+ toolCallId: string;
2896
+ /** Model-facing (sanitized) name, e.g. `webmcp_search`. */
2897
+ toolName: string;
2898
+ args: Record<string, unknown>;
2899
+ };
2900
+ /** The browser's answer to an {@link AgentWidgetReplayedToolCall}. */
2901
+ type AgentWidgetReplayedToolResult = {
2902
+ toolCallId: string;
2903
+ toolName: string;
2904
+ result: unknown;
2905
+ };
2906
+ /**
2907
+ * A message in the proxy/agent request payload. Earlier client-tool calls the
2908
+ * browser answered replay as an assistant message carrying `toolCalls`,
2909
+ * followed by a `tool` message carrying the matching `toolResults`; both have
2910
+ * empty `content`. Client-token mode never sends them: the server replays
2911
+ * from its own stored transcript there.
2912
+ */
2890
2913
  type AgentWidgetRequestPayloadMessage = {
2891
- role: AgentWidgetMessageRole;
2914
+ role: AgentWidgetMessageRole | "tool";
2892
2915
  content: MessageContent;
2893
2916
  createdAt: string;
2917
+ toolCalls?: AgentWidgetReplayedToolCall[];
2918
+ toolResults?: AgentWidgetReplayedToolResult[];
2894
2919
  };
2895
2920
  type AgentWidgetRequestPayload = {
2896
2921
  messages: AgentWidgetRequestPayloadMessage[];
@@ -3253,6 +3278,24 @@ type AgentMessageMetadata = {
3253
3278
  * never re-resume the call.
3254
3279
  */
3255
3280
  suggestRepliesResolved?: boolean;
3281
+ /**
3282
+ * The client-tool answer the server accepted through `/resume`, kept so
3283
+ * later proxy/agent turns can replay the call and its result to the model.
3284
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
3285
+ * built-in). Set only after the resume succeeds; preserved across
3286
+ * re-emissions of the tool message.
3287
+ */
3288
+ clientToolAnswer?: {
3289
+ toolCallId: string;
3290
+ toolName: string;
3291
+ args: unknown;
3292
+ result: unknown;
3293
+ /**
3294
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
3295
+ * turn's parallel calls; a chained call gets a new batch.
3296
+ */
3297
+ batch?: string;
3298
+ };
3256
3299
  };
3257
3300
  type AgentWidgetRequestMiddlewareContext = {
3258
3301
  payload: AgentWidgetRequestPayload;
@@ -1702,6 +1702,7 @@ type RuntypeExecutionStreamEvent = ({
1702
1702
  turnIndex?: number;
1703
1703
  type: "turn_start";
1704
1704
  }) | ({
1705
+ attributes?: Record<string, string | number | boolean>;
1705
1706
  completedAt?: string;
1706
1707
  content?: string;
1707
1708
  cost?: number;
@@ -1760,7 +1761,8 @@ type RuntypeExecutionStreamEvent = ({
1760
1761
  };
1761
1762
  turnId?: string;
1762
1763
  type: "model_call_start";
1763
- } | {
1764
+ } | ({
1765
+ attributes?: Record<string, string | number | boolean>;
1764
1766
  completedAt?: string;
1765
1767
  cost?: number;
1766
1768
  durationMs?: number;
@@ -1784,10 +1786,11 @@ type RuntypeExecutionStreamEvent = ({
1784
1786
  cacheWrite?: number;
1785
1787
  input: number;
1786
1788
  output: number;
1789
+ reasoning?: number;
1787
1790
  };
1788
1791
  turnId?: string;
1789
1792
  type: "model_call_complete";
1790
- } | {
1793
+ }) | {
1791
1794
  executionId: string;
1792
1795
  id: string;
1793
1796
  index?: number;
@@ -2954,10 +2957,32 @@ type AgentWidgetContextMentionTokenRenderContext = {
2954
2957
  ref: AgentWidgetContextMentionRef;
2955
2958
  readonly: boolean;
2956
2959
  };
2960
+ /** One earlier client-tool call replayed to the model, in `/v1/dispatch` shape. */
2961
+ type AgentWidgetReplayedToolCall = {
2962
+ toolCallId: string;
2963
+ /** Model-facing (sanitized) name, e.g. `webmcp_search`. */
2964
+ toolName: string;
2965
+ args: Record<string, unknown>;
2966
+ };
2967
+ /** The browser's answer to an {@link AgentWidgetReplayedToolCall}. */
2968
+ type AgentWidgetReplayedToolResult = {
2969
+ toolCallId: string;
2970
+ toolName: string;
2971
+ result: unknown;
2972
+ };
2973
+ /**
2974
+ * A message in the proxy/agent request payload. Earlier client-tool calls the
2975
+ * browser answered replay as an assistant message carrying `toolCalls`,
2976
+ * followed by a `tool` message carrying the matching `toolResults`; both have
2977
+ * empty `content`. Client-token mode never sends them: the server replays
2978
+ * from its own stored transcript there.
2979
+ */
2957
2980
  type AgentWidgetRequestPayloadMessage = {
2958
- role: AgentWidgetMessageRole;
2981
+ role: AgentWidgetMessageRole | "tool";
2959
2982
  content: MessageContent;
2960
2983
  createdAt: string;
2984
+ toolCalls?: AgentWidgetReplayedToolCall[];
2985
+ toolResults?: AgentWidgetReplayedToolResult[];
2961
2986
  };
2962
2987
  type AgentWidgetRequestPayload = {
2963
2988
  messages: AgentWidgetRequestPayloadMessage[];
@@ -3353,6 +3378,24 @@ type AgentMessageMetadata = {
3353
3378
  * never re-resume the call.
3354
3379
  */
3355
3380
  suggestRepliesResolved?: boolean;
3381
+ /**
3382
+ * The client-tool answer the server accepted through `/resume`, kept so
3383
+ * later proxy/agent turns can replay the call and its result to the model.
3384
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
3385
+ * built-in). Set only after the resume succeeds; preserved across
3386
+ * re-emissions of the tool message.
3387
+ */
3388
+ clientToolAnswer?: {
3389
+ toolCallId: string;
3390
+ toolName: string;
3391
+ args: unknown;
3392
+ result: unknown;
3393
+ /**
3394
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
3395
+ * turn's parallel calls; a chained call gets a new batch.
3396
+ */
3397
+ batch?: string;
3398
+ };
3356
3399
  };
3357
3400
  type AgentWidgetRequestMiddlewareContext = {
3358
3401
  payload: AgentWidgetRequestPayload;
@@ -1702,6 +1702,7 @@ type RuntypeExecutionStreamEvent = ({
1702
1702
  turnIndex?: number;
1703
1703
  type: "turn_start";
1704
1704
  }) | ({
1705
+ attributes?: Record<string, string | number | boolean>;
1705
1706
  completedAt?: string;
1706
1707
  content?: string;
1707
1708
  cost?: number;
@@ -1760,7 +1761,8 @@ type RuntypeExecutionStreamEvent = ({
1760
1761
  };
1761
1762
  turnId?: string;
1762
1763
  type: "model_call_start";
1763
- } | {
1764
+ } | ({
1765
+ attributes?: Record<string, string | number | boolean>;
1764
1766
  completedAt?: string;
1765
1767
  cost?: number;
1766
1768
  durationMs?: number;
@@ -1784,10 +1786,11 @@ type RuntypeExecutionStreamEvent = ({
1784
1786
  cacheWrite?: number;
1785
1787
  input: number;
1786
1788
  output: number;
1789
+ reasoning?: number;
1787
1790
  };
1788
1791
  turnId?: string;
1789
1792
  type: "model_call_complete";
1790
- } | {
1793
+ }) | {
1791
1794
  executionId: string;
1792
1795
  id: string;
1793
1796
  index?: number;
@@ -2954,10 +2957,32 @@ type AgentWidgetContextMentionTokenRenderContext = {
2954
2957
  ref: AgentWidgetContextMentionRef;
2955
2958
  readonly: boolean;
2956
2959
  };
2960
+ /** One earlier client-tool call replayed to the model, in `/v1/dispatch` shape. */
2961
+ type AgentWidgetReplayedToolCall = {
2962
+ toolCallId: string;
2963
+ /** Model-facing (sanitized) name, e.g. `webmcp_search`. */
2964
+ toolName: string;
2965
+ args: Record<string, unknown>;
2966
+ };
2967
+ /** The browser's answer to an {@link AgentWidgetReplayedToolCall}. */
2968
+ type AgentWidgetReplayedToolResult = {
2969
+ toolCallId: string;
2970
+ toolName: string;
2971
+ result: unknown;
2972
+ };
2973
+ /**
2974
+ * A message in the proxy/agent request payload. Earlier client-tool calls the
2975
+ * browser answered replay as an assistant message carrying `toolCalls`,
2976
+ * followed by a `tool` message carrying the matching `toolResults`; both have
2977
+ * empty `content`. Client-token mode never sends them: the server replays
2978
+ * from its own stored transcript there.
2979
+ */
2957
2980
  type AgentWidgetRequestPayloadMessage = {
2958
- role: AgentWidgetMessageRole;
2981
+ role: AgentWidgetMessageRole | "tool";
2959
2982
  content: MessageContent;
2960
2983
  createdAt: string;
2984
+ toolCalls?: AgentWidgetReplayedToolCall[];
2985
+ toolResults?: AgentWidgetReplayedToolResult[];
2961
2986
  };
2962
2987
  type AgentWidgetRequestPayload = {
2963
2988
  messages: AgentWidgetRequestPayloadMessage[];
@@ -3353,6 +3378,24 @@ type AgentMessageMetadata = {
3353
3378
  * never re-resume the call.
3354
3379
  */
3355
3380
  suggestRepliesResolved?: boolean;
3381
+ /**
3382
+ * The client-tool answer the server accepted through `/resume`, kept so
3383
+ * later proxy/agent turns can replay the call and its result to the model.
3384
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
3385
+ * built-in). Set only after the resume succeeds; preserved across
3386
+ * re-emissions of the tool message.
3387
+ */
3388
+ clientToolAnswer?: {
3389
+ toolCallId: string;
3390
+ toolName: string;
3391
+ args: unknown;
3392
+ result: unknown;
3393
+ /**
3394
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
3395
+ * turn's parallel calls; a chained call gets a new batch.
3396
+ */
3397
+ batch?: string;
3398
+ };
3356
3399
  };
3357
3400
  type AgentWidgetRequestMiddlewareContext = {
3358
3401
  payload: AgentWidgetRequestPayload;
@@ -106,6 +106,7 @@ type RuntypeExecutionStreamEvent = ({
106
106
  turnIndex?: number;
107
107
  type: "turn_start";
108
108
  }) | ({
109
+ attributes?: Record<string, string | number | boolean>;
109
110
  completedAt?: string;
110
111
  content?: string;
111
112
  cost?: number;
@@ -164,7 +165,8 @@ type RuntypeExecutionStreamEvent = ({
164
165
  };
165
166
  turnId?: string;
166
167
  type: "model_call_start";
167
- } | {
168
+ } | ({
169
+ attributes?: Record<string, string | number | boolean>;
168
170
  completedAt?: string;
169
171
  cost?: number;
170
172
  durationMs?: number;
@@ -188,10 +190,11 @@ type RuntypeExecutionStreamEvent = ({
188
190
  cacheWrite?: number;
189
191
  input: number;
190
192
  output: number;
193
+ reasoning?: number;
191
194
  };
192
195
  turnId?: string;
193
196
  type: "model_call_complete";
194
- } | {
197
+ }) | {
195
198
  executionId: string;
196
199
  id: string;
197
200
  index?: number;
@@ -809,6 +812,24 @@ type AgentMessageMetadata = {
809
812
  * never re-resume the call.
810
813
  */
811
814
  suggestRepliesResolved?: boolean;
815
+ /**
816
+ * The client-tool answer the server accepted through `/resume`, kept so
817
+ * later proxy/agent turns can replay the call and its result to the model.
818
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
819
+ * built-in). Set only after the resume succeeds; preserved across
820
+ * re-emissions of the tool message.
821
+ */
822
+ clientToolAnswer?: {
823
+ toolCallId: string;
824
+ toolName: string;
825
+ args: unknown;
826
+ result: unknown;
827
+ /**
828
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
829
+ * turn's parallel calls; a chained call gets a new batch.
830
+ */
831
+ batch?: string;
832
+ };
812
833
  };
813
834
  /**
814
835
  * Copy overrides for the visitor-facing conversation history surface. These are
@@ -106,6 +106,7 @@ type RuntypeExecutionStreamEvent = ({
106
106
  turnIndex?: number;
107
107
  type: "turn_start";
108
108
  }) | ({
109
+ attributes?: Record<string, string | number | boolean>;
109
110
  completedAt?: string;
110
111
  content?: string;
111
112
  cost?: number;
@@ -164,7 +165,8 @@ type RuntypeExecutionStreamEvent = ({
164
165
  };
165
166
  turnId?: string;
166
167
  type: "model_call_start";
167
- } | {
168
+ } | ({
169
+ attributes?: Record<string, string | number | boolean>;
168
170
  completedAt?: string;
169
171
  cost?: number;
170
172
  durationMs?: number;
@@ -188,10 +190,11 @@ type RuntypeExecutionStreamEvent = ({
188
190
  cacheWrite?: number;
189
191
  input: number;
190
192
  output: number;
193
+ reasoning?: number;
191
194
  };
192
195
  turnId?: string;
193
196
  type: "model_call_complete";
194
- } | {
197
+ }) | {
195
198
  executionId: string;
196
199
  id: string;
197
200
  index?: number;
@@ -809,6 +812,24 @@ type AgentMessageMetadata = {
809
812
  * never re-resume the call.
810
813
  */
811
814
  suggestRepliesResolved?: boolean;
815
+ /**
816
+ * The client-tool answer the server accepted through `/resume`, kept so
817
+ * later proxy/agent turns can replay the call and its result to the model.
818
+ * `toolName` is the widget's internal name (`webmcp:<name>` or a bare
819
+ * built-in). Set only after the resume succeeds; preserved across
820
+ * re-emissions of the tool message.
821
+ */
822
+ clientToolAnswer?: {
823
+ toolCallId: string;
824
+ toolName: string;
825
+ args: unknown;
826
+ result: unknown;
827
+ /**
828
+ * Shared by the answers posted in one `/resume`, i.e. one assistant
829
+ * turn's parallel calls; a chained call gets a new batch.
830
+ */
831
+ batch?: string;
832
+ };
812
833
  };
813
834
  /**
814
835
  * Copy overrides for the visitor-facing conversation history surface. These are