@runtypelabs/persona 1.41.0 → 1.43.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.
package/README.md CHANGED
@@ -228,6 +228,31 @@ chat.injectAssistantMessage({
228
228
  });
229
229
  ```
230
230
 
231
+ #### Event Stream Control
232
+
233
+ When the `showEventStreamToggle` feature flag is enabled, you can programmatically control the event stream inspector panel:
234
+
235
+ ```ts
236
+ const chat = initAgentWidget({
237
+ target: '#launcher-root',
238
+ config: {
239
+ apiUrl: '/api/chat/dispatch',
240
+ features: { showEventStreamToggle: true }
241
+ }
242
+ })
243
+
244
+ // Open the event stream panel
245
+ chat.showEventStream()
246
+
247
+ // Close the event stream panel
248
+ chat.hideEventStream()
249
+
250
+ // Check if the event stream panel is currently visible
251
+ chat.isEventStreamVisible() // returns boolean
252
+ ```
253
+
254
+ These methods are no-ops if `showEventStreamToggle` is not enabled.
255
+
231
256
  #### Accessing from window
232
257
 
233
258
  To access the controller globally (e.g., from browser console or external scripts), use the `windowKey` option:
@@ -309,6 +334,33 @@ window.addEventListener("persona:clear-chat", (event) => {
309
334
 
310
335
  **Note:** The widget automatically clears the `"persona-chat-history"` localStorage key by default when chat is cleared. If you set `clearChatHistoryStorageKey` in the config, it will also clear that additional key. You can still listen to this event for additional custom behavior.
311
336
 
337
+ #### `persona:showEventStream` / `persona:hideEventStream`
338
+
339
+ Dispatched to programmatically open or close the event stream panel. Requires `showEventStreamToggle: true` in the widget config.
340
+
341
+ ```ts
342
+ // Open the event stream panel on all widget instances
343
+ window.dispatchEvent(new CustomEvent('persona:showEventStream'))
344
+
345
+ // Close the event stream panel on all widget instances
346
+ window.dispatchEvent(new CustomEvent('persona:hideEventStream'))
347
+ ```
348
+
349
+ **Instance scoping:** When multiple widget instances exist on the same page, use the `instanceId` detail to target a specific one. For `createAgentExperience`, the `instanceId` is the original `id` of the mount element. For `initAgentWidget`, it's the `id` of the target element.
350
+
351
+ ```ts
352
+ // Target only the widget mounted on #inline-widget
353
+ window.dispatchEvent(new CustomEvent('persona:showEventStream', {
354
+ detail: { instanceId: 'inline-widget' }
355
+ }))
356
+
357
+ // Events with a non-matching instanceId are ignored
358
+ window.dispatchEvent(new CustomEvent('persona:showEventStream', {
359
+ detail: { instanceId: 'wrong-id' }
360
+ }))
361
+ // ^ No effect — no widget has this instanceId
362
+ ```
363
+
312
364
  ### Controller Events
313
365
 
314
366
  The widget controller exposes an event system for reacting to chat events. Use `controller.on(eventName, callback)` to subscribe and `controller.off(eventName, callback)` to unsubscribe.
@@ -327,6 +379,8 @@ The widget controller exposes an event system for reacting to chat events. Use `
327
379
  | `widget:state` | `AgentWidgetStateSnapshot` | Emitted on any widget state change |
328
380
  | `message:feedback` | `AgentWidgetMessageFeedback` | Emitted when user provides feedback (upvote/downvote) |
329
381
  | `message:copy` | `AgentWidgetMessage` | Emitted when user copies a message |
382
+ | `eventStream:opened` | `{ timestamp: number }` | Emitted when the event stream panel opens |
383
+ | `eventStream:closed` | `{ timestamp: number }` | Emitted when the event stream panel closes |
330
384
 
331
385
  #### Event Payload Types
332
386
 
@@ -1196,7 +1250,7 @@ This ensures all configuration values are set to sensible defaults while allowin
1196
1250
  | `headers` | `Record<string, string>` | Extra headers forwarded to your proxy. |
1197
1251
  | `copy` | `{ welcomeTitle?, welcomeSubtitle?, inputPlaceholder?, sendButtonLabel? }` | Customize user-facing text. |
1198
1252
  | `theme` | `{ primary?, secondary?, surface?, muted?, accent?, radiusSm?, radiusMd?, radiusLg?, radiusFull? }` | Override CSS variables for the widget. Colors: `primary` (text/UI), `secondary` (unused), `surface` (backgrounds), `muted` (secondary text), `accent` (buttons/links). Border radius: `radiusSm` (0.75rem, inputs), `radiusMd` (1rem, cards), `radiusLg` (1.5rem, panels/bubbles), `radiusFull` (9999px, pills/buttons). |
1199
- | `features` | `AgentWidgetFeatureFlags` | Toggle UI features: `showReasoning?` (show thinking bubbles, default: `true`), `showToolCalls?` (show tool usage bubbles, default: `true`). |
1253
+ | `features` | `AgentWidgetFeatureFlags` | Toggle UI features: `showReasoning?` (show thinking bubbles, default: `true`), `showToolCalls?` (show tool usage bubbles, default: `true`), `showEventStreamToggle?` (show event stream inspector toggle in header, default: `false`). |
1200
1254
  | `launcher` | `{ enabled?, autoExpand?, title?, subtitle?, iconUrl?, position? }` | Controls the floating launcher button. |
1201
1255
  | `initialMessages` | `AgentWidgetMessage[]` | Seed the conversation transcript. |
1202
1256
  | `suggestionChips` | `string[]` | Render quick reply buttons above the composer. |