@runtypelabs/persona 4.28.0 → 4.28.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 (62) hide show
  1. package/README.md +25 -0
  2. package/dist/{approval-ui-QAKWNFNM.js → approval-ui-OBBI62ES.js} +1 -1
  3. package/dist/approval-ui.cjs +2 -2
  4. package/dist/approval-ui.d.cts +7 -5
  5. package/dist/approval-ui.d.ts +7 -5
  6. package/dist/approval-ui.js +2 -2
  7. package/dist/artifacts-ui.d.cts +7 -5
  8. package/dist/artifacts-ui.d.ts +7 -5
  9. package/dist/{chunk-NQLDCJAP.js → chunk-D4TDKCT5.js} +2 -2
  10. package/dist/chunk-FNXK3VTC.js +1 -0
  11. package/dist/{client-history-LV3KHEFA.js → client-history-QGAFMCBE.js} +1 -1
  12. package/dist/client-history.js +1 -1
  13. package/dist/{client-stream-N22JHTLE.js → client-stream-WXD2FL23.js} +1 -1
  14. package/dist/client-stream.js +3 -3
  15. package/dist/codegen.cjs +4 -4
  16. package/dist/codegen.js +5 -5
  17. package/dist/context-mentions.d.cts +7 -5
  18. package/dist/context-mentions.d.ts +7 -5
  19. package/dist/event-stream-view.d.cts +7 -5
  20. package/dist/event-stream-view.d.ts +7 -5
  21. package/dist/forms-ui.d.cts +7 -5
  22. package/dist/forms-ui.d.ts +7 -5
  23. package/dist/index.cjs +40 -40
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +32 -30
  26. package/dist/index.d.ts +32 -30
  27. package/dist/index.global.js +1 -1
  28. package/dist/index.global.js.map +1 -1
  29. package/dist/index.js +41 -41
  30. package/dist/index.js.map +1 -1
  31. package/dist/session-reconnect.d.cts +7 -5
  32. package/dist/session-reconnect.d.ts +7 -5
  33. package/dist/smart-dom-reader.d.cts +7 -5
  34. package/dist/smart-dom-reader.d.ts +7 -5
  35. package/dist/theme-editor-preview.cjs +51 -51
  36. package/dist/theme-editor-preview.d.cts +7 -5
  37. package/dist/theme-editor-preview.d.ts +7 -5
  38. package/dist/theme-editor-preview.js +4 -4
  39. package/dist/theme-editor.d.cts +8 -6
  40. package/dist/theme-editor.d.ts +8 -6
  41. package/dist/{voice-runtime-LVUMPUDS.js → voice-runtime-TWFJ4UUS.js} +1 -1
  42. package/dist/voice-runtime.cjs +1 -1
  43. package/dist/voice-runtime.d.cts +7 -5
  44. package/dist/voice-runtime.d.ts +7 -5
  45. package/dist/voice-runtime.js +1 -1
  46. package/dist/webmcp-runtime-5Q3IHAHP.js +6 -0
  47. package/dist/webmcp-runtime.cjs +2 -2
  48. package/dist/webmcp-runtime.d.cts +22 -26
  49. package/dist/webmcp-runtime.d.ts +22 -26
  50. package/dist/webmcp-runtime.js +2 -2
  51. package/package.json +5 -2
  52. package/src/generated/runtype-openapi-contract.ts +3 -0
  53. package/src/theme-editor/webmcp/types.ts +1 -1
  54. package/src/types.ts +7 -5
  55. package/src/webmcp-bridge.test.ts +87 -21
  56. package/src/webmcp-bridge.ts +21 -26
  57. package/src/webmcp-polyfill.integration.test.ts +339 -0
  58. package/src/webmcp-polyfill.ts +7 -4
  59. package/src/webmcp-runtime-bundle.test.ts +1 -1
  60. package/src/webmcp-runtime-entry.ts +34 -19
  61. package/dist/chunk-AALCT54S.js +0 -1
  62. package/dist/webmcp-runtime-V6ZWW3PI.js +0 -6
package/dist/index.d.cts CHANGED
@@ -2413,6 +2413,9 @@ type RuntypeClientChatRequest = {
2413
2413
  sessionId: string;
2414
2414
  submitMode?: "normal" | "interrupt" | "steer";
2415
2415
  turnId?: string;
2416
+ voice?: {
2417
+ spoken?: boolean;
2418
+ };
2416
2419
  };
2417
2420
  type RuntypeClientChatStreamEvent = RuntypeExecutionStreamEvent;
2418
2421
  type RuntypeClientResumeRequest = {
@@ -3455,9 +3458,8 @@ type WebMcpConfirmInfo = {
3455
3458
  };
3456
3459
  /**
3457
3460
  * Why the confirm was requested. Currently always `'gate'`: the default
3458
- * confirm-by-default gate that fires before every `webmcp:*` call. (The
3459
- * `@mcp-b/webmcp-polyfill` owns the spec's `requestUserInteraction` callback
3460
- * internally, so Persona no longer surfaces a nested in-tool confirm.)
3461
+ * confirm-by-default gate that fires before every `webmcp:*` call. Tool
3462
+ * callbacks on v6 receive an AbortSignal, not a nested confirmation API.
3461
3463
  */
3462
3464
  reason: 'gate';
3463
3465
  };
@@ -9948,8 +9950,11 @@ type AgentWidgetConfig = {
9948
9950
  /**
9949
9951
  * WebMCP: consume page-registered tools (`document.modelContext.registerTool`).
9950
9952
  * When `enabled`, the widget installs `@mcp-b/webmcp-polyfill`, snapshots the
9951
- * registry on every dispatch, ships it as `clientTools[]`, and executes
9952
- * returned `webmcp:*` tool calls with confirm-by-default gating.
9953
+ * current document's registry on every dispatch, ships it as `clientTools[]`,
9954
+ * and executes returned `webmcp:*` calls with confirm-by-default gating.
9955
+ * Supports host-installed v5 JSON-string and v6 object-input contracts.
9956
+ * The automatic fallback stays on v5 to preserve existing browser support
9957
+ * and callback-result behavior.
9953
9958
  *
9954
9959
  * Server-side policy on the chat surface is the source of truth: these
9955
9960
  * fields layer on top.
@@ -12677,26 +12682,19 @@ declare const createWidgetHostLayout: (target: HTMLElement, config?: AgentWidget
12677
12682
  * enforcement live on the Runtype API; this bridge mirrors those checks
12678
12683
  * client-side as a usability convenience, not a security boundary.
12679
12684
  *
12680
- * About `@mcp-b/webmcp-polyfill`: it polyfills the *strict standard surface*
12681
- * only (`registerTool` / `getTools` / `executeTool` on `document.modelContext`),
12682
- * with no MCP-B-only extensions. The spec standardizes the *producer* side;
12683
- * Persona is an in-page *consumer*, so it reads the registry via the
12684
- * producer-facing preview API:
12685
- * - `getTools()`: async; returns `{ name, description, inputSchema }` where
12686
- * `inputSchema` is a JSON *string*. Annotations are not exposed here.
12687
- * - `executeTool(toolInfo, inputArgsJson, { signal })`: async; validates args
12688
- * against the tool's schema, runs `execute()`, and returns the raw result as
12689
- * a JSON *string* (or `null` for `undefined`). Honors `signal` for abort.
12690
- *
12691
- * The polyfill auto-installs `document.modelContext` at module-evaluation time,
12692
- * so it is imported *dynamically* and only when `config.webmcp.enabled === true`
12693
- *: a static import would install the global for every widget consumer,
12694
- * including those that never opted into WebMCP.
12695
- *
12696
- * Confirm model: every `webmcp:*` call goes through one confirm gate before
12697
- * `execute()` runs, regardless of `annotations.readOnlyHint`. (The polyfill owns
12698
- * the spec's `client.requestUserInteraction` callback internally; Persona cannot
12699
- * inject a nested confirm there, so the single outer gate is the whole story.)
12685
+ * Supports v5's JSON-string input and v6's object input with a single call:
12686
+ * the runtime passes a JSON object that also string-coerces to JSON text.
12687
+ * Never infer the execution contract from metadata or retry a failed call.
12688
+ * Only tools owned by this document are exposed: the wire addresses tools by
12689
+ * name, not by frame. Callbacks must validate their own input.
12690
+ *
12691
+ * The automatic fallback stays on v5 to preserve its browser requirements and
12692
+ * result semantics. Host pages may install v5 or v6 themselves; Persona does
12693
+ * not replace an existing context. v5's initializeWebMCPPolyfill() and v6's
12694
+ * installWebMCP() are both accepted by custom loaders.
12695
+ *
12696
+ * Every call passes one confirm gate before execution, regardless of
12697
+ * annotations.readOnlyHint. v6 callbacks also receive an invocation signal.
12700
12698
  */
12701
12699
 
12702
12700
  /** Server-applied wire prefix; strip when looking up registry entries. */
@@ -12719,18 +12717,20 @@ interface ModelContextToolInfo {
12719
12717
  * object. `@mcp-b/webmcp-polyfill` made the switch in v5, and Chrome ships it
12720
12718
  * from 154.0.8013 (cross-document tools first) -- but Chrome 149-153, most of
12721
12719
  * the Origin Trial population, and 154's same-document tools still emit the
12722
- * string. Both are live in the field, so we accept both.
12720
+ * string. Both input execution contracts are supported independently of
12721
+ * schema representation.
12723
12722
  *
12724
12723
  * Absent when the tool registered no schema: v5 omits the member, where v4
12725
12724
  * always emitted a `{"type":"object"}` string.
12726
12725
  */
12727
12726
  inputSchema?: object | string;
12727
+ /** Owning frame and origin, when supplied by the registry. Never sent on the wire. */
12728
+ window?: Window;
12729
+ origin?: string;
12728
12730
  /**
12729
12731
  * Display title declared on the tool (`ToolDescriptor.title` in the WebMCP
12730
12732
  * spec). The polyfill returns `""` when the tool didn't declare one. Note:
12731
- * `annotations` (incl. the legacy `annotations.title`) are NOT exposed on
12732
- * this strict consumer surface: top-level `title` is the only display-name
12733
- * channel available to us.
12733
+ * top-level `title` is the display-name channel, not `annotations.title`.
12734
12734
  */
12735
12735
  title?: string;
12736
12736
  /**
@@ -12747,6 +12747,8 @@ interface ModelContextToolInfo {
12747
12747
  /** The slice of `@mcp-b/webmcp-polyfill` the bridge consumes on install. */
12748
12748
  type WebMcpPolyfillModule = {
12749
12749
  initializeWebMCPPolyfill: () => void;
12750
+ } | {
12751
+ installWebMCP: () => void;
12750
12752
  };
12751
12753
  /**
12752
12754
  * Strip the server-applied `webmcp:` prefix from a wire-format tool name.
@@ -14543,7 +14545,7 @@ declare class WebMcpBridge$1 {
14543
14545
  * - tool not in registry (e.g. unmounted between snapshot and call)
14544
14546
  * - tool excluded by the client allowlist
14545
14547
  * - user declined the confirm gate
14546
- * - `execute()` threw or failed schema validation
14548
+ * - `execute()` threw or returned a non-serializable result
14547
14549
  * - `execute()` exceeded the 30s timeout
14548
14550
  * - `signal` fired (session-level `cancel()`)
14549
14551
  *
package/dist/index.d.ts CHANGED
@@ -2413,6 +2413,9 @@ type RuntypeClientChatRequest = {
2413
2413
  sessionId: string;
2414
2414
  submitMode?: "normal" | "interrupt" | "steer";
2415
2415
  turnId?: string;
2416
+ voice?: {
2417
+ spoken?: boolean;
2418
+ };
2416
2419
  };
2417
2420
  type RuntypeClientChatStreamEvent = RuntypeExecutionStreamEvent;
2418
2421
  type RuntypeClientResumeRequest = {
@@ -3455,9 +3458,8 @@ type WebMcpConfirmInfo = {
3455
3458
  };
3456
3459
  /**
3457
3460
  * Why the confirm was requested. Currently always `'gate'`: the default
3458
- * confirm-by-default gate that fires before every `webmcp:*` call. (The
3459
- * `@mcp-b/webmcp-polyfill` owns the spec's `requestUserInteraction` callback
3460
- * internally, so Persona no longer surfaces a nested in-tool confirm.)
3461
+ * confirm-by-default gate that fires before every `webmcp:*` call. Tool
3462
+ * callbacks on v6 receive an AbortSignal, not a nested confirmation API.
3461
3463
  */
3462
3464
  reason: 'gate';
3463
3465
  };
@@ -9948,8 +9950,11 @@ type AgentWidgetConfig = {
9948
9950
  /**
9949
9951
  * WebMCP: consume page-registered tools (`document.modelContext.registerTool`).
9950
9952
  * When `enabled`, the widget installs `@mcp-b/webmcp-polyfill`, snapshots the
9951
- * registry on every dispatch, ships it as `clientTools[]`, and executes
9952
- * returned `webmcp:*` tool calls with confirm-by-default gating.
9953
+ * current document's registry on every dispatch, ships it as `clientTools[]`,
9954
+ * and executes returned `webmcp:*` calls with confirm-by-default gating.
9955
+ * Supports host-installed v5 JSON-string and v6 object-input contracts.
9956
+ * The automatic fallback stays on v5 to preserve existing browser support
9957
+ * and callback-result behavior.
9953
9958
  *
9954
9959
  * Server-side policy on the chat surface is the source of truth: these
9955
9960
  * fields layer on top.
@@ -12677,26 +12682,19 @@ declare const createWidgetHostLayout: (target: HTMLElement, config?: AgentWidget
12677
12682
  * enforcement live on the Runtype API; this bridge mirrors those checks
12678
12683
  * client-side as a usability convenience, not a security boundary.
12679
12684
  *
12680
- * About `@mcp-b/webmcp-polyfill`: it polyfills the *strict standard surface*
12681
- * only (`registerTool` / `getTools` / `executeTool` on `document.modelContext`),
12682
- * with no MCP-B-only extensions. The spec standardizes the *producer* side;
12683
- * Persona is an in-page *consumer*, so it reads the registry via the
12684
- * producer-facing preview API:
12685
- * - `getTools()`: async; returns `{ name, description, inputSchema }` where
12686
- * `inputSchema` is a JSON *string*. Annotations are not exposed here.
12687
- * - `executeTool(toolInfo, inputArgsJson, { signal })`: async; validates args
12688
- * against the tool's schema, runs `execute()`, and returns the raw result as
12689
- * a JSON *string* (or `null` for `undefined`). Honors `signal` for abort.
12690
- *
12691
- * The polyfill auto-installs `document.modelContext` at module-evaluation time,
12692
- * so it is imported *dynamically* and only when `config.webmcp.enabled === true`
12693
- *: a static import would install the global for every widget consumer,
12694
- * including those that never opted into WebMCP.
12695
- *
12696
- * Confirm model: every `webmcp:*` call goes through one confirm gate before
12697
- * `execute()` runs, regardless of `annotations.readOnlyHint`. (The polyfill owns
12698
- * the spec's `client.requestUserInteraction` callback internally; Persona cannot
12699
- * inject a nested confirm there, so the single outer gate is the whole story.)
12685
+ * Supports v5's JSON-string input and v6's object input with a single call:
12686
+ * the runtime passes a JSON object that also string-coerces to JSON text.
12687
+ * Never infer the execution contract from metadata or retry a failed call.
12688
+ * Only tools owned by this document are exposed: the wire addresses tools by
12689
+ * name, not by frame. Callbacks must validate their own input.
12690
+ *
12691
+ * The automatic fallback stays on v5 to preserve its browser requirements and
12692
+ * result semantics. Host pages may install v5 or v6 themselves; Persona does
12693
+ * not replace an existing context. v5's initializeWebMCPPolyfill() and v6's
12694
+ * installWebMCP() are both accepted by custom loaders.
12695
+ *
12696
+ * Every call passes one confirm gate before execution, regardless of
12697
+ * annotations.readOnlyHint. v6 callbacks also receive an invocation signal.
12700
12698
  */
12701
12699
 
12702
12700
  /** Server-applied wire prefix; strip when looking up registry entries. */
@@ -12719,18 +12717,20 @@ interface ModelContextToolInfo {
12719
12717
  * object. `@mcp-b/webmcp-polyfill` made the switch in v5, and Chrome ships it
12720
12718
  * from 154.0.8013 (cross-document tools first) -- but Chrome 149-153, most of
12721
12719
  * the Origin Trial population, and 154's same-document tools still emit the
12722
- * string. Both are live in the field, so we accept both.
12720
+ * string. Both input execution contracts are supported independently of
12721
+ * schema representation.
12723
12722
  *
12724
12723
  * Absent when the tool registered no schema: v5 omits the member, where v4
12725
12724
  * always emitted a `{"type":"object"}` string.
12726
12725
  */
12727
12726
  inputSchema?: object | string;
12727
+ /** Owning frame and origin, when supplied by the registry. Never sent on the wire. */
12728
+ window?: Window;
12729
+ origin?: string;
12728
12730
  /**
12729
12731
  * Display title declared on the tool (`ToolDescriptor.title` in the WebMCP
12730
12732
  * spec). The polyfill returns `""` when the tool didn't declare one. Note:
12731
- * `annotations` (incl. the legacy `annotations.title`) are NOT exposed on
12732
- * this strict consumer surface: top-level `title` is the only display-name
12733
- * channel available to us.
12733
+ * top-level `title` is the display-name channel, not `annotations.title`.
12734
12734
  */
12735
12735
  title?: string;
12736
12736
  /**
@@ -12747,6 +12747,8 @@ interface ModelContextToolInfo {
12747
12747
  /** The slice of `@mcp-b/webmcp-polyfill` the bridge consumes on install. */
12748
12748
  type WebMcpPolyfillModule = {
12749
12749
  initializeWebMCPPolyfill: () => void;
12750
+ } | {
12751
+ installWebMCP: () => void;
12750
12752
  };
12751
12753
  /**
12752
12754
  * Strip the server-applied `webmcp:` prefix from a wire-format tool name.
@@ -14543,7 +14545,7 @@ declare class WebMcpBridge$1 {
14543
14545
  * - tool not in registry (e.g. unmounted between snapshot and call)
14544
14546
  * - tool excluded by the client allowlist
14545
14547
  * - user declined the confirm gate
14546
- * - `execute()` threw or failed schema validation
14548
+ * - `execute()` threw or returned a non-serializable result
14547
14549
  * - `execute()` exceeded the 30s timeout
14548
14550
  * - `signal` fired (session-level `cancel()`)
14549
14551
  *