@runtypelabs/persona 3.21.2 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +67 -0
  2. package/dist/animations/glyph-cycle.d.cts +1 -1
  3. package/dist/animations/glyph-cycle.d.ts +1 -1
  4. package/dist/animations/{types-CWPIj66R.d.cts → types-BZVr1YOV.d.cts} +10 -0
  5. package/dist/animations/{types-CWPIj66R.d.ts → types-BZVr1YOV.d.ts} +10 -0
  6. package/dist/animations/wipe.d.cts +1 -1
  7. package/dist/animations/wipe.d.ts +1 -1
  8. package/dist/index.cjs +50 -43
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +474 -6
  11. package/dist/index.d.ts +474 -6
  12. package/dist/index.global.js +98 -88
  13. package/dist/index.global.js.map +1 -1
  14. package/dist/index.js +48 -41
  15. package/dist/index.js.map +1 -1
  16. package/dist/smart-dom-reader.cjs +1875 -0
  17. package/dist/smart-dom-reader.d.cts +4521 -0
  18. package/dist/smart-dom-reader.d.ts +4521 -0
  19. package/dist/smart-dom-reader.js +1848 -0
  20. package/dist/theme-editor.cjs +2282 -90
  21. package/dist/theme-editor.d.cts +348 -1
  22. package/dist/theme-editor.d.ts +348 -1
  23. package/dist/theme-editor.js +2267 -90
  24. package/package.json +9 -2
  25. package/src/client.test.ts +165 -0
  26. package/src/client.ts +144 -23
  27. package/src/components/composer-parts.test.ts +34 -0
  28. package/src/components/composer-parts.ts +9 -6
  29. package/src/index.ts +26 -0
  30. package/src/session.test.ts +258 -0
  31. package/src/session.ts +886 -30
  32. package/src/session.webmcp.test.ts +815 -0
  33. package/src/smart-dom-reader.test.ts +135 -0
  34. package/src/smart-dom-reader.ts +135 -0
  35. package/src/theme-editor/color-utils.test.ts +59 -0
  36. package/src/theme-editor/color-utils.ts +38 -2
  37. package/src/theme-editor/index.ts +35 -0
  38. package/src/theme-editor/webmcp/coerce.test.ts +86 -0
  39. package/src/theme-editor/webmcp/coerce.ts +286 -0
  40. package/src/theme-editor/webmcp/index.ts +45 -0
  41. package/src/theme-editor/webmcp/summary.ts +324 -0
  42. package/src/theme-editor/webmcp/tools.test.ts +205 -0
  43. package/src/theme-editor/webmcp/tools.ts +795 -0
  44. package/src/theme-editor/webmcp/types.ts +87 -0
  45. package/src/types.ts +186 -0
  46. package/src/ui.composer-keyboard.test.ts +229 -0
  47. package/src/ui.ts +127 -5
  48. package/src/utils/composer-history.test.ts +128 -0
  49. package/src/utils/composer-history.ts +113 -0
  50. package/src/utils/message-fingerprint.test.ts +20 -0
  51. package/src/utils/message-fingerprint.ts +2 -0
  52. package/src/utils/smart-dom-adapter.test.ts +257 -0
  53. package/src/utils/smart-dom-adapter.ts +217 -0
  54. package/{LICENSE → src/vendor/smart-dom-reader/LICENSE} +2 -2
  55. package/src/vendor/smart-dom-reader/README.md +61 -0
  56. package/src/vendor/smart-dom-reader/index.d.ts +476 -0
  57. package/src/vendor/smart-dom-reader/index.js +1618 -0
  58. package/src/webmcp-bridge.test.ts +429 -0
  59. package/src/webmcp-bridge.ts +547 -0
package/dist/index.d.cts CHANGED
@@ -800,6 +800,13 @@ type AgentWidgetRequestPayload = {
800
800
  metadata?: Record<string, unknown>;
801
801
  /** Per-turn template variables for /v1/client/chat (merged as root-level {{var}} in Runtype). */
802
802
  inputs?: Record<string, unknown>;
803
+ /**
804
+ * Per-turn page-discovered tools (WebMCP). Sent to Runtype's dispatch so the
805
+ * agent can call them as `webmcp:<name>`. The widget snapshots
806
+ * `document.modelContext.__getRegisteredTools()` each turn and ships only
807
+ * the JSON-serializable surface (no `execute`).
808
+ */
809
+ clientTools?: ClientToolDefinition[];
803
810
  };
804
811
  /**
805
812
  * Configuration for agent loop behavior.
@@ -884,6 +891,114 @@ type AgentWidgetAgentRequestPayload = {
884
891
  options: AgentRequestOptions;
885
892
  context?: Record<string, unknown>;
886
893
  metadata?: Record<string, unknown>;
894
+ /**
895
+ * Per-turn page-discovered tools (WebMCP) — same shape as
896
+ * `AgentWidgetRequestPayload.clientTools`.
897
+ */
898
+ clientTools?: ClientToolDefinition[];
899
+ };
900
+ /**
901
+ * Wire shape for a single client-discovered tool sent on `dispatch.clientTools[]`.
902
+ *
903
+ * Mirrors the SDK's `ClientToolDefinition` in `@runtypelabs/sdk`. Only the
904
+ * JSON-serializable surface of a WebMCP tool — the `execute` function stays
905
+ * client-side; the server merges these into the agent's tool catalog under
906
+ * the `webmcp:` namespace.
907
+ */
908
+ type ClientToolDefinition = {
909
+ /** Bare tool name; the server prepends `webmcp:` on the wire. */
910
+ name: string;
911
+ description: string;
912
+ /** JSON Schema (per WebMCP spec) — passed through as-is. */
913
+ parametersSchema?: object;
914
+ /** Set to `'webmcp'` for tools discovered via the polyfill. */
915
+ origin?: 'webmcp' | 'local';
916
+ /** Origin of the page that registered the tool — for server-side audit. */
917
+ pageOrigin?: string;
918
+ /**
919
+ * WebMCP `Tool.annotations` (spec). Not used for gating server-side; the
920
+ * widget reads these client-side. Forwarded so traces/dashboards can show
921
+ * `readOnlyHint` / `untrustedContentHint` on tool-call records.
922
+ */
923
+ annotations?: {
924
+ readOnlyHint?: boolean;
925
+ untrustedContentHint?: boolean;
926
+ };
927
+ };
928
+ /**
929
+ * Information passed to the confirm-bubble handler before a `webmcp:*` tool
930
+ * call executes. Every WebMCP tool routes through this single gate.
931
+ */
932
+ type WebMcpConfirmInfo = {
933
+ /** Bare tool name (no `webmcp:` prefix). */
934
+ toolName: string;
935
+ args: unknown;
936
+ description?: string;
937
+ annotations?: {
938
+ readOnlyHint?: boolean;
939
+ untrustedContentHint?: boolean;
940
+ };
941
+ /**
942
+ * Why the confirm was requested. Currently always `'gate'` — the default
943
+ * confirm-by-default gate that fires before every `webmcp:*` call. (The
944
+ * `@mcp-b/webmcp-polyfill` owns the spec's `requestUserInteraction` callback
945
+ * internally, so Persona no longer surfaces a nested in-tool confirm.)
946
+ */
947
+ reason: 'gate';
948
+ };
949
+ /**
950
+ * Resolves to `true` if the user approves the tool call; `false` to decline.
951
+ */
952
+ type WebMcpConfirmHandler = (info: WebMcpConfirmInfo) => Promise<boolean>;
953
+ /**
954
+ * Persona's normalized tool-result shape sent back to the agent on `/resume`.
955
+ * Mirrors the MCP `CallToolResult` content shape; arbitrary `execute()` return
956
+ * values are wrapped as a single text block at the bridge boundary.
957
+ */
958
+ type WebMcpToolResult = {
959
+ content: Array<{
960
+ type: 'text';
961
+ text: string;
962
+ } | {
963
+ type: string;
964
+ [key: string]: unknown;
965
+ }>;
966
+ isError?: boolean;
967
+ /** Pass-through of the tool's `annotations.untrustedContentHint`. */
968
+ annotations?: {
969
+ untrustedContentHint?: boolean;
970
+ };
971
+ };
972
+ /**
973
+ * Widget-level WebMCP configuration. Set `enabled: true` to opt in. The
974
+ * surface's server-side `webmcp` policy is the source of truth for which
975
+ * tools are accepted — these client-side options are convenience filters.
976
+ */
977
+ type AgentWidgetWebMcpConfig = {
978
+ /** Master switch. Default: `false` (widget never installs the polyfill). */
979
+ enabled?: boolean;
980
+ /**
981
+ * Glob-ish name patterns to include client-side. `'*'` matches any chars
982
+ * except `:`. Patterns are matched against the bare tool name (no `webmcp:`
983
+ * prefix). If unset, all registered tools are included.
984
+ */
985
+ allowlist?: string[];
986
+ /**
987
+ * Per-tool gate policy. Called before the confirm gate for every
988
+ * `webmcp:*` call; return `true` to approve immediately and skip the
989
+ * confirmation UI entirely. Use this to auto-allow read-only tools (e.g.
990
+ * a catalog search) while still gating mutating ones. Only consulted on
991
+ * the default-UI path — a custom `onConfirm` takes full control instead.
992
+ */
993
+ autoApprove?: (info: WebMcpConfirmInfo) => boolean;
994
+ /**
995
+ * Confirm gate handler. When omitted, Persona renders its native in-panel
996
+ * approval bubble (the same chrome used for server-driven tool approvals)
997
+ * and resolves on the user's Approve/Deny click. Supply this to override
998
+ * with a custom confirmer (e.g. a route-level modal). The legacy
999
+ * `window.confirm` fallback only applies when no widget UI is attached.
1000
+ */
1001
+ onConfirm?: WebMcpConfirmHandler;
887
1002
  };
888
1003
  /**
889
1004
  * Agent execution state tracking.
@@ -925,6 +1040,16 @@ type AgentMessageMetadata = {
925
1040
  * `POST /v1/dispatch/resume` with the user's answer keyed by tool name.
926
1041
  */
927
1042
  awaitingLocalTool?: boolean;
1043
+ /**
1044
+ * The provider per-call id (`toolu_…`) carried on the `step_await` /
1045
+ * `flow_await` events for a LOCAL tool (core#3878). Present only when the
1046
+ * server emits it. Two PARALLEL calls to the same tool in one turn share a
1047
+ * `toolName` (and a collapsed `toolId`) but get DISTINCT `webMcpToolCallId`s,
1048
+ * so this is the key the widget batches a single `/resume` on — preferred
1049
+ * over tool name, which collides for same-tool parallel calls. Absent →
1050
+ * fall back to the legacy name-keyed resume contract.
1051
+ */
1052
+ webMcpToolCallId?: string;
928
1053
  /**
929
1054
  * Set to `true` once the user has picked / typed / dismissed an answer for
930
1055
  * an `ask_user_question` tool call, so renderers stop re-mounting the
@@ -1537,6 +1662,14 @@ type AgentWidgetFeatureFlags = {
1537
1662
  showReasoning?: boolean;
1538
1663
  showToolCalls?: boolean;
1539
1664
  showEventStreamToggle?: boolean;
1665
+ /**
1666
+ * Up/Down arrow navigation through previously sent user messages in the
1667
+ * composer, for quick re-entry or editing (shell / Slack style). History is
1668
+ * only entered when the caret is at the start of the input, so normal
1669
+ * multi-line cursor movement is preserved. Set to `false` to disable.
1670
+ * @default true
1671
+ */
1672
+ composerHistory?: boolean;
1540
1673
  /** Shared transcript + event stream scroll-to-bottom affordance. */
1541
1674
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
1542
1675
  /** Collapsed transcript behavior for tool call rows. */
@@ -2643,6 +2776,8 @@ type ClientChatRequest = {
2643
2776
  /** Per-turn inputs for Runtype prompt templates (e.g. {{page_url}}). */
2644
2777
  inputs?: Record<string, unknown>;
2645
2778
  context?: Record<string, unknown>;
2779
+ /** WebMCP page-discovered tools — same shape as `dispatch.clientTools[]`. */
2780
+ clientTools?: ClientToolDefinition[];
2646
2781
  };
2647
2782
  /**
2648
2783
  * Feedback types supported by the API
@@ -3438,6 +3573,31 @@ type AgentWidgetLoadingIndicatorConfig = {
3438
3573
  type AgentWidgetConfig = {
3439
3574
  apiUrl?: string;
3440
3575
  flowId?: string;
3576
+ /**
3577
+ * Override the assistant-bubble copy shown when a dispatch fails before any
3578
+ * response streams back (connection refused, CORS, 4xx/5xx, malformed
3579
+ * stream). Provide a static string, or a function of the error so you can
3580
+ * tailor the message per failure and decide whether to surface the raw
3581
+ * reason. When omitted, a default message is shown that includes the
3582
+ * underlying error detail.
3583
+ *
3584
+ * Returning an empty string suppresses the fallback bubble entirely (the
3585
+ * `onError` callback still fires).
3586
+ *
3587
+ * @example
3588
+ * ```typescript
3589
+ * config: {
3590
+ * // Static
3591
+ * errorMessage: "We're having trouble connecting. Please try again."
3592
+ * // Or dynamic
3593
+ * errorMessage: (error) =>
3594
+ * error.message.includes("Failed to fetch")
3595
+ * ? "You appear to be offline."
3596
+ * : "Something went wrong. Please try again."
3597
+ * }
3598
+ * ```
3599
+ */
3600
+ errorMessage?: string | ((error: Error) => string);
3441
3601
  /**
3442
3602
  * Agent configuration for agent execution mode.
3443
3603
  * When provided, the widget uses agent loop execution instead of flow dispatch.
@@ -3669,6 +3829,26 @@ type AgentWidgetConfig = {
3669
3829
  * ```
3670
3830
  */
3671
3831
  approval?: AgentWidgetApprovalConfig | false;
3832
+ /**
3833
+ * WebMCP — consume page-registered tools (`document.modelContext.registerTool`).
3834
+ * When `enabled`, the widget installs `@mcp-b/webmcp-polyfill`, snapshots the
3835
+ * registry on every dispatch, ships it as `clientTools[]`, and executes
3836
+ * returned `webmcp:*` tool calls with confirm-by-default gating.
3837
+ *
3838
+ * Server-side policy on the chat surface is the source of truth — these
3839
+ * fields layer on top.
3840
+ *
3841
+ * @example
3842
+ * ```typescript
3843
+ * config: {
3844
+ * webmcp: {
3845
+ * enabled: true,
3846
+ * allowlist: ['search_*', 'list_*'],
3847
+ * }
3848
+ * }
3849
+ * ```
3850
+ */
3851
+ webmcp?: AgentWidgetWebMcpConfig;
3672
3852
  postprocessMessage?: (context: {
3673
3853
  text: string;
3674
3854
  message: AgentWidgetMessage;
@@ -4448,11 +4628,36 @@ declare class AgentWidgetClient {
4448
4628
  private onSSEEvent?;
4449
4629
  private clientSession;
4450
4630
  private sessionInitPromise;
4631
+ private readonly webMcpBridge;
4451
4632
  constructor(config?: AgentWidgetConfig);
4452
4633
  /**
4453
4634
  * Set callback for capturing raw SSE events
4454
4635
  */
4455
4636
  setSSEEventCallback(callback: SSEEventCallback): void;
4637
+ /**
4638
+ * WebMCP: wire (or replace) the confirm-bubble handler. Called from
4639
+ * `ui.ts` once the widget panel is built and the approval-bubble
4640
+ * chrome is ready to render.
4641
+ */
4642
+ setWebMcpConfirmHandler(handler: WebMcpConfirmHandler | null): void;
4643
+ /**
4644
+ * WebMCP: `true` when the bridge installed the polyfill and can both
4645
+ * snapshot the page registry and execute returned `webmcp:*` tool calls.
4646
+ * `false` for any guard miss (no `document.modelContext`, polyfill not yet
4647
+ * installed, or `config.webmcp.enabled` not set).
4648
+ */
4649
+ isWebMcpOperational(): boolean;
4650
+ /**
4651
+ * WebMCP: execute a returned `webmcp:<name>` tool call against the page's
4652
+ * registry and return the normalized MCP-shaped result for `/resume`. The
4653
+ * bridge handles confirm-bubble gating, the 30s timeout, error
4654
+ * normalization, and `signal`-driven abort — callers never see throws.
4655
+ *
4656
+ * Returns `null` when WebMCP is not enabled on this client (signal to the
4657
+ * session that it should fall back to the legacy local-tool resume path,
4658
+ * if any).
4659
+ */
4660
+ executeWebMcpToolCall(wireToolName: string, args: unknown, signal?: AbortSignal): Promise<WebMcpToolResult> | null;
4456
4661
  /**
4457
4662
  * Get the current SSE event callback (used to preserve across client recreation)
4458
4663
  */
@@ -4581,16 +4786,26 @@ declare class AgentWidgetClient {
4581
4786
  * (client-executed) tools. Used by the built-in `ask_user_question`
4582
4787
  * answer-pill sheet, but generic enough for any LOCAL tool.
4583
4788
  *
4584
- * Posts to the upstream `/resume` endpoint (the dispatch URL with
4585
- * `/dispatch` replaced by `/resume` — works for both direct-to-Runtype
4586
- * and the persona proxy) and returns the raw Response so the caller can
4587
- * pipe its SSE body through `connectStream()`.
4789
+ * Routes by mode:
4790
+ * - **client-token mode**: POST `${apiBase}/v1/client/resume` (the
4791
+ * session-authenticated sibling of `/v1/client/chat`; runtypelabs/core#3889),
4792
+ * with the active `sessionId` in the body and no Bearer key — a browser
4793
+ * client-token page holds no secret. `clientTools` are already persisted
4794
+ * server-side from the dispatch turn, so only `toolOutputs` is re-sent.
4795
+ * - **dispatch / proxy mode**: POST `${apiUrl}/resume` — Runtype mounts
4796
+ * resume as a child of `/v1/dispatch`, so the URL is `${apiUrl}/resume`,
4797
+ * and proxies follow the same shape (`/api/chat/dispatch/resume`).
4798
+ *
4799
+ * Returns the raw Response so the caller can pipe its SSE body through
4800
+ * `connectStream()`.
4588
4801
  *
4589
4802
  * @param executionId - The paused execution id carried on `step_await`.
4590
- * @param toolOutputs - Map keyed by tool name → the tool's result value.
4803
+ * @param toolOutputs - Map keyed by per-call `toolCallId` (core#3878),
4804
+ * falling back to tool name for legacy servers → the tool's result value.
4591
4805
  */
4592
4806
  resumeFlow(executionId: string, toolOutputs: Record<string, unknown>, options?: {
4593
4807
  streamResponse?: boolean;
4808
+ signal?: AbortSignal;
4594
4809
  }): Promise<Response>;
4595
4810
  private buildAgentPayload;
4596
4811
  private buildPayload;
@@ -4627,6 +4842,13 @@ declare class AgentWidgetSession {
4627
4842
  private agentExecution;
4628
4843
  private artifacts;
4629
4844
  private selectedArtifactId;
4845
+ private webMcpInflightKeys;
4846
+ private webMcpResolvedKeys;
4847
+ private webMcpResolveControllers;
4848
+ private webMcpEpoch;
4849
+ private webMcpApprovalResolvers;
4850
+ private webMcpApprovalSeq;
4851
+ private webMcpAwaitBatches;
4630
4852
  private voiceProvider;
4631
4853
  private voiceActive;
4632
4854
  private voiceStatus;
@@ -4867,6 +5089,28 @@ declare class AgentWidgetSession {
4867
5089
  assistantMessageId?: string;
4868
5090
  allowReentry?: boolean;
4869
5091
  }): Promise<void>;
5092
+ /**
5093
+ * Install the native approval-bubble confirm handler on the WebMCP bridge
5094
+ * when the integrator hasn't supplied a custom `webmcp.onConfirm`. Without
5095
+ * this, the bridge falls back to a blunt `window.confirm`. Safe to call
5096
+ * repeatedly (e.g. after the client is re-created in `updateConfig`).
5097
+ */
5098
+ private wireDefaultWebMcpConfirm;
5099
+ /**
5100
+ * Default WebMCP confirm gate: render Persona's native in-panel approval
5101
+ * bubble and resolve when the user clicks Approve/Deny. Returns immediately
5102
+ * with `true` when `webmcp.autoApprove(info)` opts the tool out of the gate
5103
+ * (e.g. a read-only catalog search), so no bubble is shown. The bridge
5104
+ * awaits this Promise before executing the page tool.
5105
+ */
5106
+ requestWebMcpApproval(info: WebMcpConfirmInfo): Promise<boolean>;
5107
+ /**
5108
+ * Resolve a pending WebMCP approval bubble (from the Approve/Deny click in
5109
+ * `ui.ts`). Updates the bubble to its resolved state and unblocks the
5110
+ * bridge Promise parked in `requestWebMcpApproval`. No-op if already
5111
+ * resolved (double-click, re-render).
5112
+ */
5113
+ resolveWebMcpApproval(approvalMessageId: string, decision: "approved" | "denied"): void;
4870
5114
  /**
4871
5115
  * Resolve a tool approval request (approve or deny).
4872
5116
  * Updates the approval message status, calls the API (or custom onDecision),
@@ -4904,6 +5148,97 @@ declare class AgentWidgetSession {
4904
5148
  */
4905
5149
  markAskUserQuestionResolved(toolMessage: AgentWidgetMessage, answers?: Record<string, string | string[]>): void;
4906
5150
  resolveAskUserQuestion(toolMessage: AgentWidgetMessage, answer: string | Record<string, string | string[]>): Promise<void>;
5151
+ /**
5152
+ * Collect a `webmcp:*` LOCAL-tool `step_await` into a per-executionId batch
5153
+ * and schedule a single deferred flush. Parallel calls (core#3878) emit
5154
+ * several `step_await`s for ONE paused execution within the same stream tick;
5155
+ * buffering them and flushing once lets us post ONE `/resume` keyed by the
5156
+ * per-call `webMcpToolCallId` rather than racing N name-keyed resumes on the
5157
+ * same execution (which 404'd on the second and hung the turn).
5158
+ *
5159
+ * Deferred via `queueMicrotask` (epoch-guarded) for the same reason the old
5160
+ * direct resolve was: handleEvent must return first so the dispatch's
5161
+ * `connectStream` sees end-of-stream and releases the shared abortController
5162
+ * before a resolve grabs it.
5163
+ *
5164
+ * Awaits without an `executionId` or `toolCall.id` can't be batched (no key)
5165
+ * — route them straight to the single-call path, which surfaces the malformed
5166
+ * wire shape via `onError` / an `isError` resume.
5167
+ */
5168
+ private enqueueWebMcpAwait;
5169
+ /**
5170
+ * Flush every buffered local-tool await batch, one `/resume` per executionId.
5171
+ * Called once a stream ends (`status: idle` / `error`) — by then all parallel
5172
+ * `step_await`s the stream carried have been collected, even if split across
5173
+ * SSE chunks. Deferred via `queueMicrotask` (epoch-guarded) so the idle
5174
+ * handler returns first and the stream's end-of-stream teardown (streaming /
5175
+ * abortController) settles before a resolve grabs them — the same ordering the
5176
+ * single-call resolve always relied on.
5177
+ */
5178
+ private scheduleWebMcpBatchFlush;
5179
+ /**
5180
+ * Run a buffered batch of local-tool awaits for one executionId. Size 1
5181
+ * (single call, or distinct-tool turns that happened to arrive alone) takes
5182
+ * the original single-call path; size >1 (parallel calls) takes the batched
5183
+ * path that posts ONE `/resume`. The batch is removed from the map up front
5184
+ * so any later sibling re-emit (e.g. from a re-pause) forms a fresh batch
5185
+ * rather than mutating one already in flight.
5186
+ */
5187
+ private flushWebMcpAwaitBatch;
5188
+ /**
5189
+ * Resolve TWO OR MORE parallel local-tool awaits sharing one paused
5190
+ * executionId with a SINGLE `/resume` (core#3878). Each call is executed
5191
+ * against the page registry concurrently — every gated call renders its own
5192
+ * native approval bubble, and a sibling's confirm Promise never blocks
5193
+ * another's execution. Outputs are keyed by per-call `webMcpToolCallId`
5194
+ * (server prefers it over tool name; name-keying remains the fallback for
5195
+ * legacy single/distinct-tool turns), so two calls to the SAME tool no longer
5196
+ * collide. The server is tolerant: any call we omit (declined-after-abort,
5197
+ * dedupe, exec failure) simply re-pauses and is retried on its re-emit.
5198
+ *
5199
+ * Mirrors `resolveWebMcpToolCall`'s dedupe / abort / streaming machinery, but
5200
+ * shares one resume POST and marks every resolved key on that POST's HTTP OK.
5201
+ */
5202
+ private resolveWebMcpToolCallBatch;
5203
+ /**
5204
+ * Resolve a paused `webmcp:*` LOCAL tool call by executing it against the
5205
+ * host page's tool registry and posting the result to `/resume`.
5206
+ *
5207
+ * Triggered automatically from `handleEvent` when a `step_await`-derived
5208
+ * message arrives with a `webmcp:` prefix — the user does not click a
5209
+ * pill; the bridge's confirm-bubble gate is the only interactive surface.
5210
+ *
5211
+ * Idempotent on the message's `toolCall.id`: re-emits of the same step_await
5212
+ * (e.g. from message coalescing) won't double-fire `tool.execute`. Failure
5213
+ * modes — declined, timed out, throw, unknown tool — all resolve into a
5214
+ * `{ isError: true, content: [...] }` payload that resumes the dispatch
5215
+ * cleanly so the agent can recover.
5216
+ */
5217
+ resolveWebMcpToolCall(toolMessage: AgentWidgetMessage): Promise<void>;
5218
+ /**
5219
+ * POST `/resume` with a SINGLE tool's output and pipe the resulting SSE
5220
+ * stream back through `connectStream`. Shared by every single-call local-tool
5221
+ * resolve path (ask_user_question and single WebMCP calls). Parallel WebMCP
5222
+ * calls use `resolveWebMcpToolCallBatch`, which posts one resume for many.
5223
+ *
5224
+ * `resumeKey` is the `toolOutputs` map key: the per-call `webMcpToolCallId`
5225
+ * for WebMCP (core#3878), or the tool name for ask_user_question / legacy
5226
+ * servers. `onHttpOk` runs synchronously between the HTTP-status check and the
5227
+ * stream pipe; it lets the WebMCP resolve path commit the dedupe flag at
5228
+ * "server accepted the answer" rather than "stream finished cleanly".
5229
+ */
5230
+ private resumeWithToolOutput;
5231
+ /**
5232
+ * Tear down every in-flight WebMCP resolve and advance the epoch. Each
5233
+ * resolve owns a dedicated AbortController (chained/parallel resolves don't
5234
+ * share one), so we abort them individually; the aborts propagate into the
5235
+ * bridge's execute race and into each `/resume` fetch signal. Bumping
5236
+ * `webMcpEpoch` strands any resolve still deferred in a queued microtask —
5237
+ * it captured the prior epoch and bails before installing a fresh
5238
+ * controller, so it can't escape this teardown. Called from every stop /
5239
+ * new-turn boundary (cancel, clearMessages, hydrateMessages, sendMessage).
5240
+ */
5241
+ private abortWebMcpResolves;
4907
5242
  cancel(): void;
4908
5243
  clearMessages(): void;
4909
5244
  getArtifacts(): PersonaArtifactRecord[];
@@ -5154,6 +5489,139 @@ type WidgetHostLayout = {
5154
5489
  };
5155
5490
  declare const createWidgetHostLayout: (target: HTMLElement, config?: AgentWidgetConfig) => WidgetHostLayout;
5156
5491
 
5492
+ /**
5493
+ * WebMCP consumption bridge.
5494
+ *
5495
+ * Owns the per-widget lifecycle of `@mcp-b/webmcp-polyfill`:
5496
+ * - installs the polyfill (lazily, only when enabled) so `document.modelContext`
5497
+ * is present;
5498
+ * - snapshots the host page's tool registry per dispatch turn for
5499
+ * `dispatch.clientTools[]`;
5500
+ * - executes `webmcp:*` tool calls returned by the agent, mediating a single
5501
+ * confirm-bubble gate before invoking the page's `execute()`.
5502
+ *
5503
+ * Spec reference: WebMCP (https://webmachinelearning.github.io/webmcp/).
5504
+ * Wire-level merging, namespace prefixing, and server-side allowlist
5505
+ * enforcement live on the Runtype API; this bridge mirrors those checks
5506
+ * client-side as a usability convenience, not a security boundary.
5507
+ *
5508
+ * About `@mcp-b/webmcp-polyfill`: it polyfills the *strict standard surface*
5509
+ * only (`registerTool` / `getTools` / `executeTool` on `document.modelContext`),
5510
+ * with no MCP-B-only extensions. The spec standardizes the *producer* side;
5511
+ * Persona is an in-page *consumer*, so it reads the registry via the
5512
+ * producer-facing preview API:
5513
+ * - `getTools()` — async; returns `{ name, description, inputSchema }` where
5514
+ * `inputSchema` is a JSON *string*. Annotations are not exposed here.
5515
+ * - `executeTool(toolInfo, inputArgsJson, { signal })` — async; validates args
5516
+ * against the tool's schema, runs `execute()`, and returns the raw result as
5517
+ * a JSON *string* (or `null` for `undefined`). Honors `signal` for abort.
5518
+ *
5519
+ * The polyfill auto-installs `document.modelContext` at module-evaluation time,
5520
+ * so it is imported *dynamically* and only when `config.webmcp.enabled === true`
5521
+ * — a static import would install the global for every widget consumer,
5522
+ * including those that never opted into WebMCP.
5523
+ *
5524
+ * Confirm model: every `webmcp:*` call goes through one confirm gate before
5525
+ * `execute()` runs, regardless of `annotations.readOnlyHint`. (The polyfill owns
5526
+ * the spec's `client.requestUserInteraction` callback internally; Persona cannot
5527
+ * inject a nested confirm there, so the single outer gate is the whole story.)
5528
+ */
5529
+
5530
+ /** Server-applied wire prefix; strip when looking up registry entries. */
5531
+ declare const WEBMCP_TOOL_PREFIX = "webmcp:";
5532
+ declare class WebMcpBridge {
5533
+ private readonly config;
5534
+ private confirmHandler;
5535
+ private readonly timeoutMs;
5536
+ /** `true` once the polyfill has been (idempotently) installed. */
5537
+ private installed;
5538
+ /** Memoizes the one-shot async install so concurrent callers share it. */
5539
+ private readyPromise;
5540
+ /**
5541
+ * Warn-once latch for a present-but-incompatible `document.modelContext`
5542
+ * (some other / older WebMCP polyfill squatting the global). `getModelContext`
5543
+ * is hit on every snapshot + execute, so we log the diagnostic only once.
5544
+ */
5545
+ private incompatibleContextWarned;
5546
+ constructor(config: AgentWidgetWebMcpConfig);
5547
+ /**
5548
+ * Override the confirm handler post-construction. Used by `ui.ts` to wire
5549
+ * the in-panel approval bubble after the client has been built (the widget
5550
+ * lifecycle constructs the client before the panel renders).
5551
+ */
5552
+ setConfirmHandler(handler: WebMcpConfirmHandler | null): void;
5553
+ /**
5554
+ * `true` when the bridge can both snapshot the registry AND execute returned
5555
+ * tool calls — i.e. the polyfill is installed and `document.modelContext`
5556
+ * exposes the consumer surface (`getTools` / `executeTool`). Native browsers
5557
+ * that ship `document.modelContext` satisfy this too.
5558
+ *
5559
+ * Synchronous and best-effort: returns `false` until the lazy install has
5560
+ * resolved (see `ensureReady`). The snapshot/execute paths await readiness
5561
+ * themselves, so this is purely an advisory check for callers.
5562
+ */
5563
+ isOperational(): boolean;
5564
+ /**
5565
+ * Per-turn snapshot for `dispatch.clientTools[]`. Returns the JSON-only
5566
+ * surface — `execute` stays client-side, reached later via `executeToolCall`.
5567
+ *
5568
+ * Async because the strict polyfill's `getTools()` is async. Both payload
5569
+ * builders in `client.ts` already `await`, so this adds no new ceremony.
5570
+ */
5571
+ snapshotForDispatch(): Promise<ClientToolDefinition[]>;
5572
+ /**
5573
+ * Execute a `webmcp:<name>` tool call returned by the agent and return the
5574
+ * normalized MCP-shaped result for `/resume`.
5575
+ *
5576
+ * Failure modes — all return `{ isError: true, content: [...] }` rather than
5577
+ * throwing, so the dispatch can resume cleanly:
5578
+ * - bridge not operational
5579
+ * - tool not in registry (e.g. unmounted between snapshot and call)
5580
+ * - tool excluded by the client allowlist
5581
+ * - user declined the confirm gate
5582
+ * - `execute()` threw or failed schema validation
5583
+ * - `execute()` exceeded the 30s timeout
5584
+ * - `signal` fired (session-level `cancel()`)
5585
+ *
5586
+ * When `signal` is provided, abort is honored at three points: before the
5587
+ * confirm bubble renders, after the user approves but before `execute()`
5588
+ * runs, and (via a combined `AbortController`) during `execute()` itself.
5589
+ * Honoring abort BEFORE the confirm prevents a late approval after `cancel()`
5590
+ * from firing a host-page side effect with no matching `/resume`.
5591
+ */
5592
+ executeToolCall(wireToolName: string, args: unknown, signal?: AbortSignal): Promise<WebMcpToolResult>;
5593
+ /**
5594
+ * Lazily install `@mcp-b/webmcp-polyfill` the first time the bridge needs the
5595
+ * registry. Idempotent and memoized. Dynamic import keeps the polyfill out of
5596
+ * the main bundle and prevents it from installing `document.modelContext` for
5597
+ * widget consumers that never enable WebMCP.
5598
+ *
5599
+ * Producer pages should still install the polyfill themselves (or import it)
5600
+ * before registering tools — Persona's install is a fallback, and a page that
5601
+ * registers tools at load before Persona's first dispatch needs the global to
5602
+ * already exist.
5603
+ */
5604
+ private ensureReady;
5605
+ private install;
5606
+ /**
5607
+ * Read the consumer surface off `document.modelContext`, returning `null`
5608
+ * when it is absent or doesn't expose the producer-preview API we rely on.
5609
+ */
5610
+ private getModelContext;
5611
+ private requestConfirm;
5612
+ private passesClientAllowlist;
5613
+ }
5614
+ /**
5615
+ * Strip the server-applied `webmcp:` prefix from a wire-format tool name.
5616
+ * Exported for tests; widget code should always go through the bridge.
5617
+ */
5618
+ declare const stripWebMcpPrefix: (name: string) => string;
5619
+ /**
5620
+ * `true` when `wireToolName` carries the `webmcp:` prefix. Used by `client.ts`
5621
+ * to route `step_await` events.
5622
+ */
5623
+ declare const isWebMcpToolName: (name: string) => boolean;
5624
+
5157
5625
  declare const createLocalStorageAdapter: (key?: string) => AgentWidgetStorageAdapter;
5158
5626
 
5159
5627
  type ActionManagerProcessContext = {
@@ -6779,4 +7247,4 @@ declare function createVoiceProvider(config: VoiceConfig): VoiceProvider;
6779
7247
  declare function createBestAvailableVoiceProvider(config?: Partial<VoiceConfig>): VoiceProvider;
6780
7248
  declare function isVoiceSupported(config?: Partial<VoiceConfig>): boolean;
6781
7249
 
6782
- export { ASK_USER_QUESTION_TOOL_NAME, type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentToolsConfig, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetArtifactsFeature, type AgentWidgetArtifactsLayoutConfig, type AgentWidgetAskUserQuestionFeature, type AgentWidgetAskUserQuestionStyles, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetComposerConfig, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetControllerEventMap, type AgentWidgetCustomFetch, type AgentWidgetDockConfig, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetLoadingIndicatorConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamAnimationBuffer, type AgentWidgetStreamAnimationBuiltinType, type AgentWidgetStreamAnimationFeature, type AgentWidgetStreamAnimationPlaceholder, type AgentWidgetStreamAnimationType, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTimestampConfig, type ArtifactConfigPayload, type ArtifactPaneTokens, type ArtifactTabTokens, type ArtifactToolbarTokens, type AskUserQuestionOption, type AskUserQuestionPayload, type AskUserQuestionPrompt, AttachmentManager, type AttachmentManagerConfig, type BorderScale, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ColorPalette, type ColorShade, type ComboButtonHandle, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComponentTokens, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateComboButtonOptions, type CreateDropdownOptions, type CreateIconButtonOptions, type CreateLabelButtonOptions, type CreateStandardBubbleOptions, type CreateThemeOptions, type CreateToggleGroupOptions, DEFAULT_COMPONENTS, DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH, DEFAULT_FLOATING_LAUNCHER_WIDTH, DEFAULT_PALETTE, DEFAULT_SEMANTIC, DEFAULT_WIDGET_CONFIG, type DeepPartial, type DemoCarouselHandle, type DemoCarouselItem, type DemoCarouselOptions, type DomContextMode, type DomContextOptions, type DropdownMenuHandle, type DropdownMenuItem, type EnrichedPageElement, type EventStreamBadgeColor, type EventStreamConfig, type EventStreamPayloadRenderContext, type EventStreamRowRenderContext, type EventStreamToolbarRenderContext, type EventStreamViewRenderContext, type FormatEnrichedContextOptions, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IconButtonTokens, type IconName, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectComponentDirectiveOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LabelButtonTokens, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, PRESETS, PRESET_FULLSCREEN, PRESET_MINIMAL, PRESET_SHOP, type ParseOptionsConfig, type ParseRule, type PendingAttachment, type PersonaArtifactKind, type PersonaArtifactManualUpsert, type PersonaArtifactRecord, type PersonaTheme, type PersonaThemePlugin, type RadiusScale, type RuleScoringContext, type SSEEventCallback, type SSEEventRecord, type SanitizeFunction, type SemanticColors, type SemanticSpacing, type SemanticTypography, type ShadowScale, type SlotRenderContext, type SlotRenderer, type SpacingScale, type StreamAnimationContext, type StreamAnimationPlugin, THEME_ZONES, type TextContentPart, type ThemeValidationError, type ThemeValidationResult, type ThemeZone, type ToggleGroupHandle, type ToggleGroupItem, type ToggleGroupTokens, type TokenReference, type TypographyScale, VERSION, type VoiceConfig, type VoiceProvider, type VoiceResult, type VoiceStatus, type WidgetHostLayout, type WidgetHostLayoutMode, type WidgetLayoutSlot, type WidgetPreset, accessibilityPlugin, animationsPlugin, applyThemeVariables, attachHeaderToContainer, brandPlugin, buildComposer, buildDefaultHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, collectEnrichedPageContext, componentRegistry, createActionManager, createAgentExperience, createAskUserQuestionBubble, createBestAvailableVoiceProvider, createBubbleWithLayout, createCSATFeedback, createComboButton, createComponentMiddleware, createComponentStreamParser, createDefaultSanitizer, createDemoCarousel, createDirectivePostprocessor, createDropdownMenu, createFlexibleJsonStreamParser, createIconButton, createImagePart, createJsonStreamParser, createLabelButton, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createPlugin, createRegexJsonParser, createStandardBubble, createTextPart, createTheme, createThemeObserver, createToggleGroup, createTypingIndicator, createVoiceProvider, createWidgetHostLayout, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, defaultParseRules, detectColorScheme, directivePostprocessor, ensureAskUserQuestionSheet, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, formatEnrichedContext, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateStableSelector, generateUserMessageId, getActiveTheme, getColorScheme, getDisplayText, getHeaderLayout, getImageParts, getPreset, hasComponentDirective, hasImages, headerLayouts, highContrastPlugin, initAgentWidget, isAskUserQuestionMessage, isComponentDirectiveType, isDockedMountMode, isVoiceSupported, listRegisteredStreamAnimations, markdownPostprocessor, mergeWithDefaults, normalizeContent, parseAskUserQuestionPayload, pluginRegistry, reducedMotionPlugin, registerStreamAnimationPlugin, removeAskUserQuestionSheet, renderComponentDirective, renderLoadingIndicatorWithFallback, renderLucideIcon, resolveDockConfig, resolveSanitizer, resolveTokens, themeToCssVariables, unregisterStreamAnimationPlugin, validateImageFile, validateTheme };
7250
+ export { ASK_USER_QUESTION_TOOL_NAME, type AgentConfig, type AgentExecutionState, type AgentLoopConfig, type AgentMessageMetadata, type AgentRequestOptions, type AgentToolsConfig, type AgentWidgetActionContext, type AgentWidgetActionEventPayload, type AgentWidgetActionHandler, type AgentWidgetActionHandlerResult, type AgentWidgetActionParser, type AgentWidgetAgentRequestPayload, type AgentWidgetApproval, type AgentWidgetApprovalConfig, type AgentWidgetArtifactsFeature, type AgentWidgetArtifactsLayoutConfig, type AgentWidgetAskUserQuestionFeature, type AgentWidgetAskUserQuestionStyles, type AgentWidgetAttachmentsConfig, type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetComposerConfig, type AgentWidgetConfig, type AgentWidgetContextProvider, type AgentWidgetContextProviderContext, type AgentWidgetController, type AgentWidgetControllerEventMap, type AgentWidgetCustomFetch, type AgentWidgetDockConfig, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetLoadingIndicatorConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetParsedAction, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamAnimationBuffer, type AgentWidgetStreamAnimationBuiltinType, type AgentWidgetStreamAnimationFeature, type AgentWidgetStreamAnimationPlaceholder, type AgentWidgetStreamAnimationType, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTimestampConfig, type AgentWidgetWebMcpConfig, type ArtifactConfigPayload, type ArtifactPaneTokens, type ArtifactTabTokens, type ArtifactToolbarTokens, type AskUserQuestionOption, type AskUserQuestionPayload, type AskUserQuestionPrompt, AttachmentManager, type AttachmentManagerConfig, type BorderScale, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type ClientToolDefinition, type CodeFormat, type CodeGeneratorHooks, type CodeGeneratorOptions, type ColorPalette, type ColorShade, type ComboButtonHandle, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComponentTokens, type ComposerBuildContext, type ComposerElements, type ContentPart, type CreateComboButtonOptions, type CreateDropdownOptions, type CreateIconButtonOptions, type CreateLabelButtonOptions, type CreateStandardBubbleOptions, type CreateThemeOptions, type CreateToggleGroupOptions, DEFAULT_COMPONENTS, DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH, DEFAULT_FLOATING_LAUNCHER_WIDTH, DEFAULT_PALETTE, DEFAULT_SEMANTIC, DEFAULT_WIDGET_CONFIG, type DeepPartial, type DemoCarouselHandle, type DemoCarouselItem, type DemoCarouselOptions, type DomContextMode, type DomContextOptions, type DropdownMenuHandle, type DropdownMenuItem, type EnrichedPageElement, type EventStreamBadgeColor, type EventStreamConfig, type EventStreamPayloadRenderContext, type EventStreamRowRenderContext, type EventStreamToolbarRenderContext, type EventStreamViewRenderContext, type FormatEnrichedContextOptions, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type IconButtonTokens, type IconName, type IdleIndicatorRenderContext, type ImageContentPart, type InjectAssistantMessageOptions, type InjectComponentDirectiveOptions, type InjectMessageOptions, type InjectSystemMessageOptions, type InjectUserMessageOptions, type LabelButtonTokens, type LoadingIndicatorRenderContext, type LoadingIndicatorRenderer, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageContent, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, PRESETS, PRESET_FULLSCREEN, PRESET_MINIMAL, PRESET_SHOP, type ParseOptionsConfig, type ParseRule, type PendingAttachment, type PersonaArtifactKind, type PersonaArtifactManualUpsert, type PersonaArtifactRecord, type PersonaTheme, type PersonaThemePlugin, type RadiusScale, type RuleScoringContext, type SSEEventCallback, type SSEEventRecord, type SanitizeFunction, type SemanticColors, type SemanticSpacing, type SemanticTypography, type ShadowScale, type SlotRenderContext, type SlotRenderer, type SpacingScale, type StreamAnimationContext, type StreamAnimationPlugin, THEME_ZONES, type TextContentPart, type ThemeValidationError, type ThemeValidationResult, type ThemeZone, type ToggleGroupHandle, type ToggleGroupItem, type ToggleGroupTokens, type TokenReference, type TypographyScale, VERSION, type VoiceConfig, type VoiceProvider, type VoiceResult, type VoiceStatus, WEBMCP_TOOL_PREFIX, WebMcpBridge, type WebMcpConfirmHandler, type WebMcpConfirmInfo, type WebMcpToolResult, type WidgetHostLayout, type WidgetHostLayoutMode, type WidgetLayoutSlot, type WidgetPreset, accessibilityPlugin, animationsPlugin, applyThemeVariables, attachHeaderToContainer, brandPlugin, buildComposer, buildDefaultHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, collectEnrichedPageContext, componentRegistry, createActionManager, createAgentExperience, createAskUserQuestionBubble, createBestAvailableVoiceProvider, createBubbleWithLayout, createCSATFeedback, createComboButton, createComponentMiddleware, createComponentStreamParser, createDefaultSanitizer, createDemoCarousel, createDirectivePostprocessor, createDropdownMenu, createFlexibleJsonStreamParser, createIconButton, createImagePart, createJsonStreamParser, createLabelButton, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createPlugin, createRegexJsonParser, createStandardBubble, createTextPart, createTheme, createThemeObserver, createToggleGroup, createTypingIndicator, createVoiceProvider, createWidgetHostLayout, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, defaultParseRules, detectColorScheme, directivePostprocessor, ensureAskUserQuestionSheet, escapeHtml, extractComponentDirectiveFromMessage, fileToImagePart, formatEnrichedContext, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateStableSelector, generateUserMessageId, getActiveTheme, getColorScheme, getDisplayText, getHeaderLayout, getImageParts, getPreset, hasComponentDirective, hasImages, headerLayouts, highContrastPlugin, initAgentWidget, isAskUserQuestionMessage, isComponentDirectiveType, isDockedMountMode, isVoiceSupported, isWebMcpToolName, listRegisteredStreamAnimations, markdownPostprocessor, mergeWithDefaults, normalizeContent, parseAskUserQuestionPayload, pluginRegistry, reducedMotionPlugin, registerStreamAnimationPlugin, removeAskUserQuestionSheet, renderComponentDirective, renderLoadingIndicatorWithFallback, renderLucideIcon, resolveDockConfig, resolveSanitizer, resolveTokens, stripWebMcpPrefix, themeToCssVariables, unregisterStreamAnimationPlugin, validateImageFile, validateTheme };