@runtypelabs/persona 3.30.0 → 3.31.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 (44) 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 +1 -1
  9. package/dist/codegen.js +1 -1
  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 +55 -55
  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/widget.css +19 -0
  29. package/package.json +1 -1
  30. package/src/client.ts +6 -0
  31. package/src/components/approval-bubble.test.ts +52 -0
  32. package/src/components/approval-bubble.ts +20 -0
  33. package/src/components/panel.ts +7 -1
  34. package/src/defaults.ts +14 -0
  35. package/src/generated/runtype-openapi-contract.ts +4 -0
  36. package/src/session.test.ts +62 -0
  37. package/src/session.ts +27 -0
  38. package/src/styles/widget.css +19 -0
  39. package/src/theme-reference.ts +1 -1
  40. package/src/types.ts +50 -0
  41. package/src/ui.scroll.test.ts +383 -0
  42. package/src/ui.ts +390 -40
  43. package/src/utils/auto-follow.test.ts +91 -0
  44. package/src/utils/auto-follow.ts +68 -0
package/dist/index.d.cts CHANGED
@@ -921,6 +921,7 @@ type RuntypeAgentSSEEvent = {
921
921
  };
922
922
  iteration?: number;
923
923
  parameters?: Record<string, unknown>;
924
+ reason?: string;
924
925
  seq: number;
925
926
  startedAt: string;
926
927
  timeout: number;
@@ -1192,6 +1193,7 @@ type RuntypeFlowSSEEvent = {
1192
1193
  when: string;
1193
1194
  } | {
1194
1195
  executionId?: string;
1196
+ reason?: string;
1195
1197
  seq?: number;
1196
1198
  type: "step_await";
1197
1199
  [key: string]: unknown;
@@ -1470,6 +1472,7 @@ type RuntypeDispatchSSEEvent = {
1470
1472
  };
1471
1473
  iteration?: number;
1472
1474
  parameters?: Record<string, unknown>;
1475
+ reason?: string;
1473
1476
  seq: number;
1474
1477
  startedAt: string;
1475
1478
  timeout: number;
@@ -1740,6 +1743,7 @@ type RuntypeDispatchSSEEvent = {
1740
1743
  when: string;
1741
1744
  } | {
1742
1745
  executionId?: string;
1746
+ reason?: string;
1743
1747
  seq?: number;
1744
1748
  type: "step_await";
1745
1749
  [key: string]: unknown;
@@ -2695,6 +2699,29 @@ type AgentWidgetArtifactsFeature = {
2695
2699
  defaultRenderer: () => HTMLElement;
2696
2700
  }) => HTMLElement | null;
2697
2701
  };
2702
+ /**
2703
+ * How the transcript scrolls while an assistant response streams in.
2704
+ *
2705
+ * - `"follow"` (default): keep the newest content pinned to the bottom of the
2706
+ * viewport, pausing when the user scrolls up and resuming when they return
2707
+ * to the bottom.
2708
+ * - `"anchor-top"`: on send, scroll the user's message near the top of the
2709
+ * viewport and hold it there while the response streams in beneath it
2710
+ * (ChatGPT-style). The transcript never auto-scrolls during streaming.
2711
+ * - `"none"`: never auto-scroll; the scroll-to-bottom affordance is the only
2712
+ * way back to the latest content.
2713
+ */
2714
+ type AgentWidgetScrollMode = "follow" | "anchor-top" | "none";
2715
+ type AgentWidgetScrollBehaviorFeature = {
2716
+ /** Scroll behavior during streamed responses. @default "follow" */
2717
+ mode?: AgentWidgetScrollMode;
2718
+ /**
2719
+ * Gap (px) kept between the anchored user message and the top of the
2720
+ * viewport in `"anchor-top"` mode.
2721
+ * @default 16
2722
+ */
2723
+ anchorTopOffset?: number;
2724
+ };
2698
2725
  type AgentWidgetScrollToBottomFeature = {
2699
2726
  /**
2700
2727
  * When true, Persona shows a scroll-to-bottom affordance when the user breaks
@@ -2958,6 +2985,8 @@ type AgentWidgetFeatureFlags = {
2958
2985
  composerHistory?: boolean;
2959
2986
  /** Shared transcript + event stream scroll-to-bottom affordance. */
2960
2987
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
2988
+ /** Transcript scroll behavior during streamed responses. */
2989
+ scrollBehavior?: AgentWidgetScrollBehaviorFeature;
2961
2990
  /** Collapsed transcript behavior for tool call rows. */
2962
2991
  toolCallDisplay?: AgentWidgetToolCallDisplayFeature;
2963
2992
  /** Collapsed transcript behavior for reasoning rows. */
@@ -3728,6 +3757,16 @@ type AgentWidgetApprovalConfig = {
3728
3757
  approveLabel?: string;
3729
3758
  /** Label for the deny button */
3730
3759
  denyLabel?: string;
3760
+ /**
3761
+ * Color for the agent-authored reason line (the agent's per-call
3762
+ * justification, shown attributed below the summary when present).
3763
+ */
3764
+ reasonColor?: string;
3765
+ /**
3766
+ * Label prefix for the agent-authored reason line.
3767
+ * Defaults to "Agent's stated reason:".
3768
+ */
3769
+ reasonLabel?: string;
3731
3770
  /**
3732
3771
  * How the technical details (the tool's agent-facing description and the
3733
3772
  * raw parameters JSON) are presented:
@@ -3753,6 +3792,12 @@ type AgentWidgetApprovalConfig = {
3753
3792
  description: string;
3754
3793
  parameters?: unknown;
3755
3794
  displayTitle?: string;
3795
+ /**
3796
+ * Agent-authored justification for this specific call, when the agent
3797
+ * provided one. It is the agent's own claim — if you fold it into the
3798
+ * summary, keep it attributed to the agent.
3799
+ */
3800
+ reason?: string;
3756
3801
  }) => string | undefined;
3757
3802
  /**
3758
3803
  * Custom handler for approval decisions.
@@ -5627,6 +5672,13 @@ type AgentWidgetApproval = {
5627
5672
  toolName: string;
5628
5673
  toolType?: string;
5629
5674
  description: string;
5675
+ /**
5676
+ * Agent-authored justification for this specific call (the agent's own
5677
+ * claim about its intent, extracted server-side from the reserved
5678
+ * `_approvalReason` parameter). Render it attributed to the agent and as
5679
+ * plain text — it is approver context, not a system statement.
5680
+ */
5681
+ reason?: string;
5630
5682
  parameters?: unknown;
5631
5683
  resolvedAt?: number;
5632
5684
  };
package/dist/index.d.ts CHANGED
@@ -921,6 +921,7 @@ type RuntypeAgentSSEEvent = {
921
921
  };
922
922
  iteration?: number;
923
923
  parameters?: Record<string, unknown>;
924
+ reason?: string;
924
925
  seq: number;
925
926
  startedAt: string;
926
927
  timeout: number;
@@ -1192,6 +1193,7 @@ type RuntypeFlowSSEEvent = {
1192
1193
  when: string;
1193
1194
  } | {
1194
1195
  executionId?: string;
1196
+ reason?: string;
1195
1197
  seq?: number;
1196
1198
  type: "step_await";
1197
1199
  [key: string]: unknown;
@@ -1470,6 +1472,7 @@ type RuntypeDispatchSSEEvent = {
1470
1472
  };
1471
1473
  iteration?: number;
1472
1474
  parameters?: Record<string, unknown>;
1475
+ reason?: string;
1473
1476
  seq: number;
1474
1477
  startedAt: string;
1475
1478
  timeout: number;
@@ -1740,6 +1743,7 @@ type RuntypeDispatchSSEEvent = {
1740
1743
  when: string;
1741
1744
  } | {
1742
1745
  executionId?: string;
1746
+ reason?: string;
1743
1747
  seq?: number;
1744
1748
  type: "step_await";
1745
1749
  [key: string]: unknown;
@@ -2695,6 +2699,29 @@ type AgentWidgetArtifactsFeature = {
2695
2699
  defaultRenderer: () => HTMLElement;
2696
2700
  }) => HTMLElement | null;
2697
2701
  };
2702
+ /**
2703
+ * How the transcript scrolls while an assistant response streams in.
2704
+ *
2705
+ * - `"follow"` (default): keep the newest content pinned to the bottom of the
2706
+ * viewport, pausing when the user scrolls up and resuming when they return
2707
+ * to the bottom.
2708
+ * - `"anchor-top"`: on send, scroll the user's message near the top of the
2709
+ * viewport and hold it there while the response streams in beneath it
2710
+ * (ChatGPT-style). The transcript never auto-scrolls during streaming.
2711
+ * - `"none"`: never auto-scroll; the scroll-to-bottom affordance is the only
2712
+ * way back to the latest content.
2713
+ */
2714
+ type AgentWidgetScrollMode = "follow" | "anchor-top" | "none";
2715
+ type AgentWidgetScrollBehaviorFeature = {
2716
+ /** Scroll behavior during streamed responses. @default "follow" */
2717
+ mode?: AgentWidgetScrollMode;
2718
+ /**
2719
+ * Gap (px) kept between the anchored user message and the top of the
2720
+ * viewport in `"anchor-top"` mode.
2721
+ * @default 16
2722
+ */
2723
+ anchorTopOffset?: number;
2724
+ };
2698
2725
  type AgentWidgetScrollToBottomFeature = {
2699
2726
  /**
2700
2727
  * When true, Persona shows a scroll-to-bottom affordance when the user breaks
@@ -2958,6 +2985,8 @@ type AgentWidgetFeatureFlags = {
2958
2985
  composerHistory?: boolean;
2959
2986
  /** Shared transcript + event stream scroll-to-bottom affordance. */
2960
2987
  scrollToBottom?: AgentWidgetScrollToBottomFeature;
2988
+ /** Transcript scroll behavior during streamed responses. */
2989
+ scrollBehavior?: AgentWidgetScrollBehaviorFeature;
2961
2990
  /** Collapsed transcript behavior for tool call rows. */
2962
2991
  toolCallDisplay?: AgentWidgetToolCallDisplayFeature;
2963
2992
  /** Collapsed transcript behavior for reasoning rows. */
@@ -3728,6 +3757,16 @@ type AgentWidgetApprovalConfig = {
3728
3757
  approveLabel?: string;
3729
3758
  /** Label for the deny button */
3730
3759
  denyLabel?: string;
3760
+ /**
3761
+ * Color for the agent-authored reason line (the agent's per-call
3762
+ * justification, shown attributed below the summary when present).
3763
+ */
3764
+ reasonColor?: string;
3765
+ /**
3766
+ * Label prefix for the agent-authored reason line.
3767
+ * Defaults to "Agent's stated reason:".
3768
+ */
3769
+ reasonLabel?: string;
3731
3770
  /**
3732
3771
  * How the technical details (the tool's agent-facing description and the
3733
3772
  * raw parameters JSON) are presented:
@@ -3753,6 +3792,12 @@ type AgentWidgetApprovalConfig = {
3753
3792
  description: string;
3754
3793
  parameters?: unknown;
3755
3794
  displayTitle?: string;
3795
+ /**
3796
+ * Agent-authored justification for this specific call, when the agent
3797
+ * provided one. It is the agent's own claim — if you fold it into the
3798
+ * summary, keep it attributed to the agent.
3799
+ */
3800
+ reason?: string;
3756
3801
  }) => string | undefined;
3757
3802
  /**
3758
3803
  * Custom handler for approval decisions.
@@ -5627,6 +5672,13 @@ type AgentWidgetApproval = {
5627
5672
  toolName: string;
5628
5673
  toolType?: string;
5629
5674
  description: string;
5675
+ /**
5676
+ * Agent-authored justification for this specific call (the agent's own
5677
+ * claim about its intent, extracted server-side from the reserved
5678
+ * `_approvalReason` parameter). Render it attributed to the agent and as
5679
+ * plain text — it is approver context, not a system statement.
5680
+ */
5681
+ reason?: string;
5630
5682
  parameters?: unknown;
5631
5683
  resolvedAt?: number;
5632
5684
  };