@runtypelabs/persona 3.30.0 → 3.31.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 (50) hide show
  1. package/README.md +15 -2602
  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-B_Qazlm4.d.cts → types-quh7NmYD.d.cts} +9 -0
  5. package/dist/animations/{types-B_Qazlm4.d.ts → types-quh7NmYD.d.ts} +9 -0
  6. package/dist/animations/wipe.d.cts +1 -1
  7. package/dist/animations/wipe.d.ts +1 -1
  8. package/dist/codegen.cjs +4 -4
  9. package/dist/codegen.js +3 -3
  10. package/dist/index.cjs +46 -46
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +52 -0
  13. package/dist/index.d.ts +52 -0
  14. package/dist/index.global.js +77 -80
  15. package/dist/index.global.js.map +1 -1
  16. package/dist/index.js +45 -45
  17. package/dist/index.js.map +1 -1
  18. package/dist/launcher.global.js +2 -2
  19. package/dist/launcher.global.js.map +1 -1
  20. package/dist/smart-dom-reader.d.cts +50 -0
  21. package/dist/smart-dom-reader.d.ts +50 -0
  22. package/dist/theme-editor.cjs +39 -39
  23. package/dist/theme-editor.d.cts +50 -0
  24. package/dist/theme-editor.d.ts +50 -0
  25. package/dist/theme-editor.js +39 -39
  26. package/dist/theme-reference.cjs +1 -1
  27. package/dist/theme-reference.js +1 -1
  28. package/dist/webmcp-polyfill.js +4 -0
  29. package/dist/widget.css +19 -0
  30. package/package.json +4 -3
  31. package/src/client.ts +6 -0
  32. package/src/components/approval-bubble.test.ts +52 -0
  33. package/src/components/approval-bubble.ts +20 -0
  34. package/src/components/panel.ts +7 -1
  35. package/src/defaults.ts +14 -0
  36. package/src/generated/runtype-openapi-contract.ts +4 -0
  37. package/src/index-global.ts +39 -0
  38. package/src/session.test.ts +62 -0
  39. package/src/session.ts +27 -0
  40. package/src/styles/widget.css +19 -0
  41. package/src/theme-reference.ts +1 -1
  42. package/src/types.ts +50 -0
  43. package/src/ui.scroll.test.ts +383 -0
  44. package/src/ui.ts +390 -40
  45. package/src/utils/auto-follow.test.ts +91 -0
  46. package/src/utils/auto-follow.ts +68 -0
  47. package/src/version.ts +5 -2
  48. package/src/webmcp-bridge.test.ts +60 -0
  49. package/src/webmcp-bridge.ts +34 -1
  50. package/src/webmcp-polyfill.ts +16 -0
@@ -1161,6 +1161,7 @@ type RuntypeAgentSSEEvent = {
1161
1161
  };
1162
1162
  iteration?: number;
1163
1163
  parameters?: Record<string, unknown>;
1164
+ reason?: string;
1164
1165
  seq: number;
1165
1166
  startedAt: string;
1166
1167
  timeout: number;
@@ -1432,6 +1433,7 @@ type RuntypeFlowSSEEvent = {
1432
1433
  when: string;
1433
1434
  } | {
1434
1435
  executionId?: string;
1436
+ reason?: string;
1435
1437
  seq?: number;
1436
1438
  type: "step_await";
1437
1439
  [key: string]: unknown;
@@ -2164,6 +2166,29 @@ type AgentWidgetArtifactsFeature = {
2164
2166
  defaultRenderer: () => HTMLElement;
2165
2167
  }) => HTMLElement | null;
2166
2168
  };
2169
+ /**
2170
+ * How the transcript scrolls while an assistant response streams in.
2171
+ *
2172
+ * - `"follow"` (default): keep the newest content pinned to the bottom of the
2173
+ * viewport, pausing when the user scrolls up and resuming when they return
2174
+ * to the bottom.
2175
+ * - `"anchor-top"`: on send, scroll the user's message near the top of the
2176
+ * viewport and hold it there while the response streams in beneath it
2177
+ * (ChatGPT-style). The transcript never auto-scrolls during streaming.
2178
+ * - `"none"`: never auto-scroll; the scroll-to-bottom affordance is the only
2179
+ * way back to the latest content.
2180
+ */
2181
+ type AgentWidgetScrollMode = "follow" | "anchor-top" | "none";
2182
+ type AgentWidgetScrollBehaviorFeature = {
2183
+ /** Scroll behavior during streamed responses. @default "follow" */
2184
+ mode?: AgentWidgetScrollMode;
2185
+ /**
2186
+ * Gap (px) kept between the anchored user message and the top of the
2187
+ * viewport in `"anchor-top"` mode.
2188
+ * @default 16
2189
+ */
2190
+ anchorTopOffset?: number;
2191
+ };
2167
2192
  type AgentWidgetScrollToBottomFeature = {
2168
2193
  /**
2169
2194
  * When true, Persona shows a scroll-to-bottom affordance when the user breaks
@@ -2427,6 +2452,8 @@ type AgentWidgetFeatureFlags = {
2427
2452
  composerHistory?: boolean;
2428
2453
  /** Shared transcript + event stream scroll-to-bottom affordance. */
2429
2454
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
2455
+ /** Transcript scroll behavior during streamed responses. */
2456
+ scrollBehavior?: AgentWidgetScrollBehaviorFeature;
2430
2457
  /** Collapsed transcript behavior for tool call rows. */
2431
2458
  toolCallDisplay?: AgentWidgetToolCallDisplayFeature;
2432
2459
  /** Collapsed transcript behavior for reasoning rows. */
@@ -3132,6 +3159,16 @@ type AgentWidgetApprovalConfig = {
3132
3159
  approveLabel?: string;
3133
3160
  /** Label for the deny button */
3134
3161
  denyLabel?: string;
3162
+ /**
3163
+ * Color for the agent-authored reason line (the agent's per-call
3164
+ * justification, shown attributed below the summary when present).
3165
+ */
3166
+ reasonColor?: string;
3167
+ /**
3168
+ * Label prefix for the agent-authored reason line.
3169
+ * Defaults to "Agent's stated reason:".
3170
+ */
3171
+ reasonLabel?: string;
3135
3172
  /**
3136
3173
  * How the technical details (the tool's agent-facing description and the
3137
3174
  * raw parameters JSON) are presented:
@@ -3157,6 +3194,12 @@ type AgentWidgetApprovalConfig = {
3157
3194
  description: string;
3158
3195
  parameters?: unknown;
3159
3196
  displayTitle?: string;
3197
+ /**
3198
+ * Agent-authored justification for this specific call, when the agent
3199
+ * provided one. It is the agent's own claim — if you fold it into the
3200
+ * summary, keep it attributed to the agent.
3201
+ */
3202
+ reason?: string;
3160
3203
  }) => string | undefined;
3161
3204
  /**
3162
3205
  * Custom handler for approval decisions.
@@ -4966,6 +5009,13 @@ type AgentWidgetApproval = {
4966
5009
  toolName: string;
4967
5010
  toolType?: string;
4968
5011
  description: string;
5012
+ /**
5013
+ * Agent-authored justification for this specific call (the agent's own
5014
+ * claim about its intent, extracted server-side from the reserved
5015
+ * `_approvalReason` parameter). Render it attributed to the agent and as
5016
+ * plain text — it is approver context, not a system statement.
5017
+ */
5018
+ reason?: string;
4969
5019
  parameters?: unknown;
4970
5020
  resolvedAt?: number;
4971
5021
  };
@@ -1161,6 +1161,7 @@ type RuntypeAgentSSEEvent = {
1161
1161
  };
1162
1162
  iteration?: number;
1163
1163
  parameters?: Record<string, unknown>;
1164
+ reason?: string;
1164
1165
  seq: number;
1165
1166
  startedAt: string;
1166
1167
  timeout: number;
@@ -1432,6 +1433,7 @@ type RuntypeFlowSSEEvent = {
1432
1433
  when: string;
1433
1434
  } | {
1434
1435
  executionId?: string;
1436
+ reason?: string;
1435
1437
  seq?: number;
1436
1438
  type: "step_await";
1437
1439
  [key: string]: unknown;
@@ -2164,6 +2166,29 @@ type AgentWidgetArtifactsFeature = {
2164
2166
  defaultRenderer: () => HTMLElement;
2165
2167
  }) => HTMLElement | null;
2166
2168
  };
2169
+ /**
2170
+ * How the transcript scrolls while an assistant response streams in.
2171
+ *
2172
+ * - `"follow"` (default): keep the newest content pinned to the bottom of the
2173
+ * viewport, pausing when the user scrolls up and resuming when they return
2174
+ * to the bottom.
2175
+ * - `"anchor-top"`: on send, scroll the user's message near the top of the
2176
+ * viewport and hold it there while the response streams in beneath it
2177
+ * (ChatGPT-style). The transcript never auto-scrolls during streaming.
2178
+ * - `"none"`: never auto-scroll; the scroll-to-bottom affordance is the only
2179
+ * way back to the latest content.
2180
+ */
2181
+ type AgentWidgetScrollMode = "follow" | "anchor-top" | "none";
2182
+ type AgentWidgetScrollBehaviorFeature = {
2183
+ /** Scroll behavior during streamed responses. @default "follow" */
2184
+ mode?: AgentWidgetScrollMode;
2185
+ /**
2186
+ * Gap (px) kept between the anchored user message and the top of the
2187
+ * viewport in `"anchor-top"` mode.
2188
+ * @default 16
2189
+ */
2190
+ anchorTopOffset?: number;
2191
+ };
2167
2192
  type AgentWidgetScrollToBottomFeature = {
2168
2193
  /**
2169
2194
  * When true, Persona shows a scroll-to-bottom affordance when the user breaks
@@ -2427,6 +2452,8 @@ type AgentWidgetFeatureFlags = {
2427
2452
  composerHistory?: boolean;
2428
2453
  /** Shared transcript + event stream scroll-to-bottom affordance. */
2429
2454
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
2455
+ /** Transcript scroll behavior during streamed responses. */
2456
+ scrollBehavior?: AgentWidgetScrollBehaviorFeature;
2430
2457
  /** Collapsed transcript behavior for tool call rows. */
2431
2458
  toolCallDisplay?: AgentWidgetToolCallDisplayFeature;
2432
2459
  /** Collapsed transcript behavior for reasoning rows. */
@@ -3132,6 +3159,16 @@ type AgentWidgetApprovalConfig = {
3132
3159
  approveLabel?: string;
3133
3160
  /** Label for the deny button */
3134
3161
  denyLabel?: string;
3162
+ /**
3163
+ * Color for the agent-authored reason line (the agent's per-call
3164
+ * justification, shown attributed below the summary when present).
3165
+ */
3166
+ reasonColor?: string;
3167
+ /**
3168
+ * Label prefix for the agent-authored reason line.
3169
+ * Defaults to "Agent's stated reason:".
3170
+ */
3171
+ reasonLabel?: string;
3135
3172
  /**
3136
3173
  * How the technical details (the tool's agent-facing description and the
3137
3174
  * raw parameters JSON) are presented:
@@ -3157,6 +3194,12 @@ type AgentWidgetApprovalConfig = {
3157
3194
  description: string;
3158
3195
  parameters?: unknown;
3159
3196
  displayTitle?: string;
3197
+ /**
3198
+ * Agent-authored justification for this specific call, when the agent
3199
+ * provided one. It is the agent's own claim — if you fold it into the
3200
+ * summary, keep it attributed to the agent.
3201
+ */
3202
+ reason?: string;
3160
3203
  }) => string | undefined;
3161
3204
  /**
3162
3205
  * Custom handler for approval decisions.
@@ -4966,6 +5009,13 @@ type AgentWidgetApproval = {
4966
5009
  toolName: string;
4967
5010
  toolType?: string;
4968
5011
  description: string;
5012
+ /**
5013
+ * Agent-authored justification for this specific call (the agent's own
5014
+ * claim about its intent, extracted server-side from the reserved
5015
+ * `_approvalReason` parameter). Render it attributed to the agent and as
5016
+ * plain text — it is approver context, not a system statement.
5017
+ */
5018
+ reason?: string;
4969
5019
  parameters?: unknown;
4970
5020
  resolvedAt?: number;
4971
5021
  };