@runtypelabs/persona 3.0.0 → 3.1.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.
package/dist/index.d.cts CHANGED
@@ -2797,11 +2797,15 @@ type AgentWidgetConfig = {
2797
2797
  *
2798
2798
  * This hook runs synchronously and must return the (potentially modified) state.
2799
2799
  *
2800
+ * Returning `{ state, open: true }` also signals that the widget panel should
2801
+ * open after initialization — useful when injecting a post-navigation message
2802
+ * that the user should immediately see.
2803
+ *
2800
2804
  * @example
2801
2805
  * ```typescript
2806
+ * // Plain state transform (existing form, still supported)
2802
2807
  * config: {
2803
2808
  * onStateLoaded: (state) => {
2804
- * // Check for pending navigation message
2805
2809
  * const navMessage = consumeNavigationFlag();
2806
2810
  * if (navMessage) {
2807
2811
  * return {
@@ -2818,8 +2822,36 @@ type AgentWidgetConfig = {
2818
2822
  * }
2819
2823
  * }
2820
2824
  * ```
2825
+ *
2826
+ * @example
2827
+ * ```typescript
2828
+ * // Return { state, open: true } to also open the panel
2829
+ * config: {
2830
+ * onStateLoaded: (state) => {
2831
+ * const navMessage = consumeNavigationFlag();
2832
+ * if (navMessage) {
2833
+ * return {
2834
+ * state: {
2835
+ * ...state,
2836
+ * messages: [...(state.messages || []), {
2837
+ * id: `nav-${Date.now()}`,
2838
+ * role: 'assistant',
2839
+ * content: navMessage,
2840
+ * createdAt: new Date().toISOString()
2841
+ * }]
2842
+ * },
2843
+ * open: true
2844
+ * };
2845
+ * }
2846
+ * return state;
2847
+ * }
2848
+ * }
2849
+ * ```
2821
2850
  */
2822
- onStateLoaded?: (state: AgentWidgetStoredState) => AgentWidgetStoredState;
2851
+ onStateLoaded?: (state: AgentWidgetStoredState) => AgentWidgetStoredState | {
2852
+ state: AgentWidgetStoredState;
2853
+ open?: boolean;
2854
+ };
2823
2855
  /**
2824
2856
  * Registry of custom components that can be rendered from JSON directives.
2825
2857
  * Components are registered by name and can be invoked via JSON responses
package/dist/index.d.ts CHANGED
@@ -2797,11 +2797,15 @@ type AgentWidgetConfig = {
2797
2797
  *
2798
2798
  * This hook runs synchronously and must return the (potentially modified) state.
2799
2799
  *
2800
+ * Returning `{ state, open: true }` also signals that the widget panel should
2801
+ * open after initialization — useful when injecting a post-navigation message
2802
+ * that the user should immediately see.
2803
+ *
2800
2804
  * @example
2801
2805
  * ```typescript
2806
+ * // Plain state transform (existing form, still supported)
2802
2807
  * config: {
2803
2808
  * onStateLoaded: (state) => {
2804
- * // Check for pending navigation message
2805
2809
  * const navMessage = consumeNavigationFlag();
2806
2810
  * if (navMessage) {
2807
2811
  * return {
@@ -2818,8 +2822,36 @@ type AgentWidgetConfig = {
2818
2822
  * }
2819
2823
  * }
2820
2824
  * ```
2825
+ *
2826
+ * @example
2827
+ * ```typescript
2828
+ * // Return { state, open: true } to also open the panel
2829
+ * config: {
2830
+ * onStateLoaded: (state) => {
2831
+ * const navMessage = consumeNavigationFlag();
2832
+ * if (navMessage) {
2833
+ * return {
2834
+ * state: {
2835
+ * ...state,
2836
+ * messages: [...(state.messages || []), {
2837
+ * id: `nav-${Date.now()}`,
2838
+ * role: 'assistant',
2839
+ * content: navMessage,
2840
+ * createdAt: new Date().toISOString()
2841
+ * }]
2842
+ * },
2843
+ * open: true
2844
+ * };
2845
+ * }
2846
+ * return state;
2847
+ * }
2848
+ * }
2849
+ * ```
2821
2850
  */
2822
- onStateLoaded?: (state: AgentWidgetStoredState) => AgentWidgetStoredState;
2851
+ onStateLoaded?: (state: AgentWidgetStoredState) => AgentWidgetStoredState | {
2852
+ state: AgentWidgetStoredState;
2853
+ open?: boolean;
2854
+ };
2823
2855
  /**
2824
2856
  * Registry of custom components that can be rendered from JSON directives.
2825
2857
  * Components are registered by name and can be invoked via JSON responses