@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
@@ -892,6 +892,7 @@ type RuntypeAgentSSEEvent = {
892
892
  };
893
893
  iteration?: number;
894
894
  parameters?: Record<string, unknown>;
895
+ reason?: string;
895
896
  seq: number;
896
897
  startedAt: string;
897
898
  timeout: number;
@@ -1163,6 +1164,7 @@ type RuntypeFlowSSEEvent = {
1163
1164
  when: string;
1164
1165
  } | {
1165
1166
  executionId?: string;
1167
+ reason?: string;
1166
1168
  seq?: number;
1167
1169
  type: "step_await";
1168
1170
  [key: string]: unknown;
@@ -1942,6 +1944,29 @@ type AgentWidgetArtifactsFeature = {
1942
1944
  defaultRenderer: () => HTMLElement;
1943
1945
  }) => HTMLElement | null;
1944
1946
  };
1947
+ /**
1948
+ * How the transcript scrolls while an assistant response streams in.
1949
+ *
1950
+ * - `"follow"` (default): keep the newest content pinned to the bottom of the
1951
+ * viewport, pausing when the user scrolls up and resuming when they return
1952
+ * to the bottom.
1953
+ * - `"anchor-top"`: on send, scroll the user's message near the top of the
1954
+ * viewport and hold it there while the response streams in beneath it
1955
+ * (ChatGPT-style). The transcript never auto-scrolls during streaming.
1956
+ * - `"none"`: never auto-scroll; the scroll-to-bottom affordance is the only
1957
+ * way back to the latest content.
1958
+ */
1959
+ type AgentWidgetScrollMode = "follow" | "anchor-top" | "none";
1960
+ type AgentWidgetScrollBehaviorFeature = {
1961
+ /** Scroll behavior during streamed responses. @default "follow" */
1962
+ mode?: AgentWidgetScrollMode;
1963
+ /**
1964
+ * Gap (px) kept between the anchored user message and the top of the
1965
+ * viewport in `"anchor-top"` mode.
1966
+ * @default 16
1967
+ */
1968
+ anchorTopOffset?: number;
1969
+ };
1945
1970
  type AgentWidgetScrollToBottomFeature = {
1946
1971
  /**
1947
1972
  * When true, Persona shows a scroll-to-bottom affordance when the user breaks
@@ -2205,6 +2230,8 @@ type AgentWidgetFeatureFlags = {
2205
2230
  composerHistory?: boolean;
2206
2231
  /** Shared transcript + event stream scroll-to-bottom affordance. */
2207
2232
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
2233
+ /** Transcript scroll behavior during streamed responses. */
2234
+ scrollBehavior?: AgentWidgetScrollBehaviorFeature;
2208
2235
  /** Collapsed transcript behavior for tool call rows. */
2209
2236
  toolCallDisplay?: AgentWidgetToolCallDisplayFeature;
2210
2237
  /** Collapsed transcript behavior for reasoning rows. */
@@ -2910,6 +2937,16 @@ type AgentWidgetApprovalConfig = {
2910
2937
  approveLabel?: string;
2911
2938
  /** Label for the deny button */
2912
2939
  denyLabel?: string;
2940
+ /**
2941
+ * Color for the agent-authored reason line (the agent's per-call
2942
+ * justification, shown attributed below the summary when present).
2943
+ */
2944
+ reasonColor?: string;
2945
+ /**
2946
+ * Label prefix for the agent-authored reason line.
2947
+ * Defaults to "Agent's stated reason:".
2948
+ */
2949
+ reasonLabel?: string;
2913
2950
  /**
2914
2951
  * How the technical details (the tool's agent-facing description and the
2915
2952
  * raw parameters JSON) are presented:
@@ -2935,6 +2972,12 @@ type AgentWidgetApprovalConfig = {
2935
2972
  description: string;
2936
2973
  parameters?: unknown;
2937
2974
  displayTitle?: string;
2975
+ /**
2976
+ * Agent-authored justification for this specific call, when the agent
2977
+ * provided one. It is the agent's own claim — if you fold it into the
2978
+ * summary, keep it attributed to the agent.
2979
+ */
2980
+ reason?: string;
2938
2981
  }) => string | undefined;
2939
2982
  /**
2940
2983
  * Custom handler for approval decisions.
@@ -4744,6 +4787,13 @@ type AgentWidgetApproval = {
4744
4787
  toolName: string;
4745
4788
  toolType?: string;
4746
4789
  description: string;
4790
+ /**
4791
+ * Agent-authored justification for this specific call (the agent's own
4792
+ * claim about its intent, extracted server-side from the reserved
4793
+ * `_approvalReason` parameter). Render it attributed to the agent and as
4794
+ * plain text — it is approver context, not a system statement.
4795
+ */
4796
+ reason?: string;
4747
4797
  parameters?: unknown;
4748
4798
  resolvedAt?: number;
4749
4799
  };
@@ -892,6 +892,7 @@ type RuntypeAgentSSEEvent = {
892
892
  };
893
893
  iteration?: number;
894
894
  parameters?: Record<string, unknown>;
895
+ reason?: string;
895
896
  seq: number;
896
897
  startedAt: string;
897
898
  timeout: number;
@@ -1163,6 +1164,7 @@ type RuntypeFlowSSEEvent = {
1163
1164
  when: string;
1164
1165
  } | {
1165
1166
  executionId?: string;
1167
+ reason?: string;
1166
1168
  seq?: number;
1167
1169
  type: "step_await";
1168
1170
  [key: string]: unknown;
@@ -1942,6 +1944,29 @@ type AgentWidgetArtifactsFeature = {
1942
1944
  defaultRenderer: () => HTMLElement;
1943
1945
  }) => HTMLElement | null;
1944
1946
  };
1947
+ /**
1948
+ * How the transcript scrolls while an assistant response streams in.
1949
+ *
1950
+ * - `"follow"` (default): keep the newest content pinned to the bottom of the
1951
+ * viewport, pausing when the user scrolls up and resuming when they return
1952
+ * to the bottom.
1953
+ * - `"anchor-top"`: on send, scroll the user's message near the top of the
1954
+ * viewport and hold it there while the response streams in beneath it
1955
+ * (ChatGPT-style). The transcript never auto-scrolls during streaming.
1956
+ * - `"none"`: never auto-scroll; the scroll-to-bottom affordance is the only
1957
+ * way back to the latest content.
1958
+ */
1959
+ type AgentWidgetScrollMode = "follow" | "anchor-top" | "none";
1960
+ type AgentWidgetScrollBehaviorFeature = {
1961
+ /** Scroll behavior during streamed responses. @default "follow" */
1962
+ mode?: AgentWidgetScrollMode;
1963
+ /**
1964
+ * Gap (px) kept between the anchored user message and the top of the
1965
+ * viewport in `"anchor-top"` mode.
1966
+ * @default 16
1967
+ */
1968
+ anchorTopOffset?: number;
1969
+ };
1945
1970
  type AgentWidgetScrollToBottomFeature = {
1946
1971
  /**
1947
1972
  * When true, Persona shows a scroll-to-bottom affordance when the user breaks
@@ -2205,6 +2230,8 @@ type AgentWidgetFeatureFlags = {
2205
2230
  composerHistory?: boolean;
2206
2231
  /** Shared transcript + event stream scroll-to-bottom affordance. */
2207
2232
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
2233
+ /** Transcript scroll behavior during streamed responses. */
2234
+ scrollBehavior?: AgentWidgetScrollBehaviorFeature;
2208
2235
  /** Collapsed transcript behavior for tool call rows. */
2209
2236
  toolCallDisplay?: AgentWidgetToolCallDisplayFeature;
2210
2237
  /** Collapsed transcript behavior for reasoning rows. */
@@ -2910,6 +2937,16 @@ type AgentWidgetApprovalConfig = {
2910
2937
  approveLabel?: string;
2911
2938
  /** Label for the deny button */
2912
2939
  denyLabel?: string;
2940
+ /**
2941
+ * Color for the agent-authored reason line (the agent's per-call
2942
+ * justification, shown attributed below the summary when present).
2943
+ */
2944
+ reasonColor?: string;
2945
+ /**
2946
+ * Label prefix for the agent-authored reason line.
2947
+ * Defaults to "Agent's stated reason:".
2948
+ */
2949
+ reasonLabel?: string;
2913
2950
  /**
2914
2951
  * How the technical details (the tool's agent-facing description and the
2915
2952
  * raw parameters JSON) are presented:
@@ -2935,6 +2972,12 @@ type AgentWidgetApprovalConfig = {
2935
2972
  description: string;
2936
2973
  parameters?: unknown;
2937
2974
  displayTitle?: string;
2975
+ /**
2976
+ * Agent-authored justification for this specific call, when the agent
2977
+ * provided one. It is the agent's own claim — if you fold it into the
2978
+ * summary, keep it attributed to the agent.
2979
+ */
2980
+ reason?: string;
2938
2981
  }) => string | undefined;
2939
2982
  /**
2940
2983
  * Custom handler for approval decisions.
@@ -4744,6 +4787,13 @@ type AgentWidgetApproval = {
4744
4787
  toolName: string;
4745
4788
  toolType?: string;
4746
4789
  description: string;
4790
+ /**
4791
+ * Agent-authored justification for this specific call (the agent's own
4792
+ * claim about its intent, extracted server-side from the reserved
4793
+ * `_approvalReason` parameter). Render it attributed to the agent and as
4794
+ * plain text — it is approver context, not a system statement.
4795
+ */
4796
+ reason?: string;
4747
4797
  parameters?: unknown;
4748
4798
  resolvedAt?: number;
4749
4799
  };