@runtypelabs/persona 4.19.0 → 4.21.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 (77) 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-CG-bLFmk.d.cts → types-B_JdVK9o.d.cts} +2 -0
  4. package/dist/animations/{types-CG-bLFmk.d.ts → types-B_JdVK9o.d.ts} +2 -0
  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 +2 -0
  8. package/dist/animations-extra.d.ts +2 -0
  9. package/dist/approval-ui.d.cts +99 -5
  10. package/dist/approval-ui.d.ts +99 -5
  11. package/dist/artifacts-ui.d.cts +99 -5
  12. package/dist/artifacts-ui.d.ts +99 -5
  13. package/dist/codegen.cjs +1 -1
  14. package/dist/codegen.js +1 -1
  15. package/dist/context-mentions.d.cts +99 -5
  16. package/dist/context-mentions.d.ts +99 -5
  17. package/dist/event-stream-view.d.cts +99 -5
  18. package/dist/event-stream-view.d.ts +99 -5
  19. package/dist/forms-ui.d.cts +123 -9
  20. package/dist/forms-ui.d.ts +123 -9
  21. package/dist/history-view.d.cts +2 -0
  22. package/dist/history-view.d.ts +2 -0
  23. package/dist/index.cjs +51 -51
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +128 -10
  26. package/dist/index.d.ts +128 -10
  27. package/dist/index.global.js +34 -34
  28. package/dist/index.global.js.map +1 -1
  29. package/dist/index.js +51 -51
  30. package/dist/index.js.map +1 -1
  31. package/dist/launcher.global.js.map +1 -1
  32. package/dist/session-reconnect.d.cts +99 -5
  33. package/dist/session-reconnect.d.ts +99 -5
  34. package/dist/smart-dom-reader.d.cts +99 -5
  35. package/dist/smart-dom-reader.d.ts +99 -5
  36. package/dist/theme-editor-preview.cjs +53 -53
  37. package/dist/theme-editor-preview.d.cts +99 -5
  38. package/dist/theme-editor-preview.d.ts +99 -5
  39. package/dist/theme-editor-preview.js +31 -31
  40. package/dist/theme-editor.d.cts +99 -5
  41. package/dist/theme-editor.d.ts +99 -5
  42. package/dist/theme-reference.cjs +1 -1
  43. package/dist/theme-reference.d.cts +46 -5
  44. package/dist/theme-reference.d.ts +46 -5
  45. package/dist/theme-reference.js +1 -1
  46. package/dist/webmcp-runtime.d.cts +16 -0
  47. package/dist/webmcp-runtime.d.ts +16 -0
  48. package/dist/widget.css +1 -1
  49. package/package.json +1 -1
  50. package/src/client-visitor-history.test.ts +342 -3
  51. package/src/client.test.ts +141 -3
  52. package/src/client.ts +157 -39
  53. package/src/components/composer-actions.ts +27 -1
  54. package/src/components/composer-model-picker.ts +4 -14
  55. package/src/components/composer-overflow-menu.ts +14 -0
  56. package/src/components/composer-parts.ts +20 -0
  57. package/src/generated/runtype-openapi-contract.ts +2 -0
  58. package/src/index-core.ts +2 -0
  59. package/src/session.ts +139 -103
  60. package/src/session.webmcp.test.ts +48 -1
  61. package/src/styles/widget-styles.test.ts +83 -1
  62. package/src/styles/widget.css +50 -14
  63. package/src/theme-reference.ts +1 -1
  64. package/src/types/theme.ts +47 -5
  65. package/src/types.ts +63 -0
  66. package/src/ui.composer-action-visibility.test.ts +202 -0
  67. package/src/ui.composer-models.test.ts +37 -0
  68. package/src/ui.composer-modes.test.ts +82 -0
  69. package/src/ui.composer-overflow.test.ts +78 -0
  70. package/src/ui.history-lifecycle.test.ts +2 -2
  71. package/src/ui.ts +77 -6
  72. package/src/utils/__snapshots__/tokens-parity.test.ts.snap +1633 -686
  73. package/src/utils/composer-modes.test.ts +33 -0
  74. package/src/utils/composer-modes.ts +19 -2
  75. package/src/utils/tokens-parity.test.ts +20 -0
  76. package/src/utils/tokens.test.ts +76 -0
  77. package/src/utils/tokens.ts +4 -4
@@ -1224,27 +1224,66 @@ interface ComposerSegmentedTokens {
1224
1224
  itemPadding?: string;
1225
1225
  }
1226
1226
  /**
1227
- * Model picker popover (`composer.modelPicker.presentation: "popover"`).
1227
+ * Model picker chrome (`composer.models`).
1228
+ *
1229
+ * The surface keys (`background`, `hoverBackground`, `borderColor`,
1230
+ * `borderRadius`, `labelColor`) style the CLOSED control, so the native
1231
+ * `<select>` and the `presentation: "popover"` trigger share one vocabulary.
1232
+ * The `menu*`, `rowHoverBackground`, and `descriptionColor` keys style the
1233
+ * popover panel and are inert under the native select, as is `suffixColor`,
1234
+ * which a `<select>` cannot carry either.
1228
1235
  *
1229
1236
  * Every key is optional and unset ones emit nothing: the stylesheet's `var()`
1230
1237
  * fallbacks own the default look, which derives from the surface and ghost
1231
- * button tokens. Inert under the native `<select>` presentation, except
1232
- * `suffixColor`, which the native control cannot carry either.
1238
+ * button tokens.
1233
1239
  */
1234
1240
  interface ComposerModelPickerTokens {
1241
+ /** Closed control fill. @default the ghost button fill (transparent) */
1242
+ background?: TokenReference<'color'>;
1243
+ /** Closed control fill under hover. @default the ghost hover wash */
1244
+ hoverBackground?: TokenReference<'color'>;
1245
+ /**
1246
+ * Closed control outline, drawn as a 1px inset ring so setting it never
1247
+ * resizes the control. @default none
1248
+ */
1249
+ borderColor?: TokenReference<'color'>;
1250
+ /** Closed control corner radius. @default the ghost button radius */
1251
+ borderRadius?: TokenReference<'radius'>;
1235
1252
  /** Panel fill behind the rows. @default semantic.colors.surface */
1236
1253
  menuBackground?: TokenReference<'color'>;
1237
1254
  /** Panel corner radius. @default palette.radius.lg */
1238
1255
  menuBorderRadius?: TokenReference<'radius'>;
1239
1256
  /** Row fill under hover and the focused option. @default the ghost hover wash */
1240
1257
  rowHoverBackground?: TokenReference<'color'>;
1241
- /** Row label and closed-control label color. @default inherited text */
1258
+ /**
1259
+ * Row label color, plus the closed control's text and chevron in both
1260
+ * presentations. @default the ghost button foreground
1261
+ */
1242
1262
  labelColor?: TokenReference<'color'>;
1243
1263
  /** Second line under a row label. @default semantic.colors.textMuted */
1244
1264
  descriptionColor?: TokenReference<'color'>;
1245
1265
  /** `composer.modelPicker.suffix` on the closed control. @default semantic.colors.textMuted */
1246
1266
  suffixColor?: TokenReference<'color'>;
1247
1267
  }
1268
+ /**
1269
+ * Composer overflow `+` menu panel (`composer.actionOverflow`).
1270
+ *
1271
+ * Every key is optional and unset ones emit nothing: the stylesheet's `var()`
1272
+ * fallbacks own the default look. The panel is portaled outside the themed
1273
+ * mount, so the menu forwards the configured values onto it when it opens.
1274
+ */
1275
+ interface ComposerOverflowMenuTokens {
1276
+ /** Panel fill behind the rows. @default semantic.colors.surface */
1277
+ background?: TokenReference<'color'>;
1278
+ /** Panel border color. @default semantic.colors.border */
1279
+ borderColor?: TokenReference<'color'>;
1280
+ /** Panel corner radius. @default palette.radius.lg */
1281
+ borderRadius?: TokenReference<'radius'>;
1282
+ /** Row text and glyph color. @default semantic.colors.text */
1283
+ foreground?: TokenReference<'color'>;
1284
+ /** Panel elevation (raw CSS box-shadow, `none` allowed). @default palette.shadows.md */
1285
+ shadow?: string;
1286
+ }
1248
1287
  /** Composer (message input) chrome. */
1249
1288
  interface ComposerChromeTokens {
1250
1289
  /** Box-shadow on the composer form (raw CSS, e.g. `none`). */
@@ -1279,8 +1318,10 @@ interface ComposerChromeTokens {
1279
1318
  overlayBand?: string;
1280
1319
  /** Segmented mode-group track. */
1281
1320
  segmented?: ComposerSegmentedTokens;
1282
- /** Model picker popover chrome. */
1321
+ /** Model picker chrome (closed control plus popover panel). */
1283
1322
  modelPicker?: ComposerModelPickerTokens;
1323
+ /** Overflow `+` menu panel chrome. */
1324
+ overflowMenu?: ComposerOverflowMenuTokens;
1284
1325
  }
1285
1326
  /**
1286
1327
  * Motion timing shared by every composer animation.
@@ -1603,8 +1644,10 @@ type RuntypeExecutionStreamEvent = ({
1603
1644
  message: string;
1604
1645
  };
1605
1646
  executionId: string;
1647
+ finalOutput?: string;
1606
1648
  kind: "agent" | "flow";
1607
1649
  seq: number;
1650
+ stopReason?: string;
1608
1651
  type: "execution_error";
1609
1652
  upgradeUrl?: string;
1610
1653
  }) | ({
@@ -3024,6 +3067,22 @@ type AgentWidgetWebMcpConfig = {
3024
3067
  * `window.confirm` fallback only applies when no widget UI is attached.
3025
3068
  */
3026
3069
  onConfirm?: WebMcpConfirmHandler;
3070
+ /**
3071
+ * How the widget runs the `webmcp:*` calls of ONE turn when the model emits
3072
+ * several at once.
3073
+ *
3074
+ * - `'parallel'` (default): every call executes concurrently and a gated
3075
+ * sibling's approval never blocks another's execution. Right for
3076
+ * independent, order-insensitive tools (catalog lookups, add-to-cart).
3077
+ * - `'sequential'`: calls execute one at a time, in the order the model
3078
+ * emitted them; the next starts only after the previous one settles
3079
+ * (including its approval bubble). Use this when the page tools share
3080
+ * mutable state that concurrent execution would interleave, e.g. a
3081
+ * canvas where every stroke selects a color/tool before drawing.
3082
+ *
3083
+ * Either way, all outputs still return to the server in a single `/resume`.
3084
+ */
3085
+ execution?: 'parallel' | 'sequential';
3027
3086
  };
3028
3087
  /**
3029
3088
  * Agent execution state tracking.
@@ -5829,6 +5888,15 @@ type ComposerActionPlacement = "start" | "end";
5829
5888
  * it, `"overflow"` and `"auto"` both render in the bar.
5830
5889
  */
5831
5890
  type ComposerActionPresentation = "bar" | "overflow" | "auto";
5891
+ /**
5892
+ * When a composer action is mounted, as a function of the draft.
5893
+ *
5894
+ * - `"always"` (default): the control is always mounted.
5895
+ * - `"when-empty"`: hidden as soon as the draft holds text or an attachment,
5896
+ * and while a response streams.
5897
+ * - `"when-text"`: the inverse, on the same draft state the send control reads.
5898
+ */
5899
+ type ComposerActionVisibility = "always" | "when-empty" | "when-text";
5832
5900
  /**
5833
5901
  * Fields shared by every composer action.
5834
5902
  *
@@ -5844,6 +5912,13 @@ type ComposerActionBase = {
5844
5912
  presentation?: ComposerActionPresentation;
5845
5913
  order?: number;
5846
5914
  visible?: boolean | ((state: Readonly<ComposerState>) => boolean);
5915
+ /**
5916
+ * Draft-driven visibility, on the same state `sendButton.visibility` reads.
5917
+ * Hidden removes the control from layout and tab order. Combined with
5918
+ * `visible`: both must pass.
5919
+ * @default "always"
5920
+ */
5921
+ visibility?: ComposerActionVisibility;
5847
5922
  disabled?: boolean | ((state: Readonly<ComposerState>) => boolean);
5848
5923
  /** Disable while a response streams, through the composer's own mechanism. */
5849
5924
  disableWhenStreaming?: boolean;
@@ -5990,6 +6065,15 @@ type ComposerMode = {
5990
6065
  * row, never in the overflow menu.
5991
6066
  */
5992
6067
  type ComposerModeGroupPresentation = "buttons" | "segmented";
6068
+ /**
6069
+ * Whether a group's active modes also render as removable chips.
6070
+ *
6071
+ * - `"auto"` (default): one chip per active mode, except under `"segmented"`
6072
+ * presentation, where the track already shows the state.
6073
+ * - `"hidden"`: no chips for this group under any presentation. The pressed bar
6074
+ * button carries the state, and deselection stays on the button.
6075
+ */
6076
+ type ComposerModeChipVisibility = "auto" | "hidden";
5993
6077
  /**
5994
6078
  * Selection policy for a set of modes. `"single"` deselects siblings when one
5995
6079
  * is chosen; `"multiple"` toggles independently.
@@ -5999,6 +6083,12 @@ type ComposerModeGroup = {
5999
6083
  selection: "single" | "multiple";
6000
6084
  /** @default "buttons" */
6001
6085
  presentation?: ComposerModeGroupPresentation;
6086
+ /**
6087
+ * Chip row policy for this group's active modes. The chip row itself is
6088
+ * derived from its children, so a group with no other chips leaves no gap.
6089
+ * @default "auto"
6090
+ */
6091
+ chipVisibility?: ComposerModeChipVisibility;
6002
6092
  /**
6003
6093
  * Accessible name for a segmented track. With it the track is a labelled
6004
6094
  * `role="group"`; without it the segments stand on their own names.
@@ -7353,6 +7443,10 @@ type ClientSession = {
7353
7443
  targetId?: string;
7354
7444
  /** Opaque change token; differs whenever the conversation transcript mutated. */
7355
7445
  conversationRevision?: string;
7446
+ /** Server-negotiated durable reconnect support for this client-token session. */
7447
+ durableRecovery?: {
7448
+ enabled: boolean;
7449
+ };
7356
7450
  /** Visitor grant backing history. `token` appears only at mint. */
7357
7451
  visitor?: ClientVisitorGrant;
7358
7452
  /** Configuration from the server */
@@ -7452,6 +7546,17 @@ interface WidgetHistoryInternals {
7452
7546
  /** Persist the revision beside the active conversation id (internal only). */
7453
7547
  setStoredConversationRevision?: (revision: string | null) => void;
7454
7548
  getStoredConversationRevision?: () => string | null;
7549
+ /** Internal client-token durable resume handle, persisted with widget state. */
7550
+ setStoredResumableHandle?: (handle: {
7551
+ executionId: string;
7552
+ after: string;
7553
+ } | null) => void;
7554
+ getStoredResumableHandle?: () => {
7555
+ executionId: string;
7556
+ after: string;
7557
+ } | null;
7558
+ /** True only while Persona owns a persisted client-token recovery attempt. */
7559
+ shouldResumeDurableConversation?: () => boolean;
7455
7560
  /** "Show earlier messages" cursor for the persisted transcript. */
7456
7561
  setStoredMessageCursor?: (cursor: string | null) => void;
7457
7562
  getStoredMessageCursor?: () => string | null;
@@ -9834,6 +9939,12 @@ declare class AgentWidgetClient {
9834
9939
  * Get the current client session (if any)
9835
9940
  */
9836
9941
  getClientSession(): ClientSession | null;
9942
+ /** Persona's built-in reconnect transport for client-token sessions. */
9943
+ reconnectClientTokenStream(ctx: {
9944
+ executionId: string;
9945
+ after: string;
9946
+ signal: AbortSignal;
9947
+ }): Promise<Response>;
9837
9948
  /**
9838
9949
  * Initialize session for client token mode.
9839
9950
  * Called automatically on first message if not already initialized.
@@ -10148,6 +10259,7 @@ declare class AgentWidgetClient {
10148
10259
  resumeFlow(executionId: string, toolOutputs: Record<string, unknown>, options?: {
10149
10260
  streamResponse?: boolean;
10150
10261
  signal?: AbortSignal;
10262
+ after?: string;
10151
10263
  }): Promise<Response>;
10152
10264
  /**
10153
10265
  * The opt-in structured mention channel: the MOST RECENT user turn's
@@ -10998,10 +11110,12 @@ declare class AgentWidgetSession {
10998
11110
  /**
10999
11111
  * Resolve one or more parallel local-tool awaits sharing one paused
11000
11112
  * executionId with a SINGLE `/resume` (core#3878); `resolveWebMcpToolCall`
11001
- * delegates size-1 resolves here after its guards. Each call is executed
11002
- * against the page registry concurrently: every gated call renders its own
11003
- * native approval bubble, and a sibling's confirm Promise never blocks
11004
- * another's execution. Outputs are keyed by per-call `webMcpToolCallId`
11113
+ * delegates size-1 resolves here after its guards. By default each call is
11114
+ * executed against the page registry concurrently: every gated call renders
11115
+ * its own native approval bubble, and a sibling's confirm Promise never
11116
+ * blocks another's execution. With `webmcp.execution: "sequential"` the
11117
+ * calls run one at a time in emission order instead (see the config docs
11118
+ * for when that matters). Outputs are keyed by per-call `webMcpToolCallId`
11005
11119
  * (server prefers it over tool name; name-keying remains the fallback for
11006
11120
  * legacy single/distinct-tool turns), so two calls to the SAME tool no longer
11007
11121
  * collide. The server is tolerant: any call we omit (declined-after-abort,
@@ -86,8 +86,10 @@ type RuntypeExecutionStreamEvent = ({
86
86
  message: string;
87
87
  };
88
88
  executionId: string;
89
+ finalOutput?: string;
89
90
  kind: "agent" | "flow";
90
91
  seq: number;
92
+ stopReason?: string;
91
93
  type: "execution_error";
92
94
  upgradeUrl?: string;
93
95
  }) | ({
@@ -86,8 +86,10 @@ type RuntypeExecutionStreamEvent = ({
86
86
  message: string;
87
87
  };
88
88
  executionId: string;
89
+ finalOutput?: string;
89
90
  kind: "agent" | "flow";
90
91
  seq: number;
92
+ stopReason?: string;
91
93
  type: "execution_error";
92
94
  upgradeUrl?: string;
93
95
  }) | ({