@opencx/widget-react-headless 5.0.0-beta.9 → 5.1.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
@@ -39,7 +39,7 @@ These options are included in the next beta after `5.0.0-beta.1`:
39
39
  </WidgetProvider>
40
40
  ```
41
41
 
42
- `streaming: false` chooses polling without changing the server's agent version.
42
+ `streaming` defaults to `false`, preserving v4 polling without changing the server's agent version. Set `streaming: true` to opt into streaming when the backend supports it. Personal service connections also require `capabilities.connections: true`.
43
43
  The organization controls maximum activity visibility. An embed may narrow
44
44
  `toolActivity` to `status` (name and status without inputs/results) or `hidden`,
45
45
  and disable `reasoning`. It cannot override an organization restriction.
@@ -64,3 +64,33 @@ opt-outs. Changing visibility refreshes existing history; `useAgentChatUi()`
64
64
  immediately hides opted-out activity in both live and cached turns, including
65
65
  while that refresh is pending or fails. Integrations keeping a separate cache
66
66
  can use `applyPresentation(items, presentation)` to apply the same display rules.
67
+
68
+ ## React Native
69
+
70
+ Streaming in React Native needs Expo SDK 52 or later and three things from the
71
+ app:
72
+
73
+ ```tsx
74
+ import { fetch as expoFetch } from 'expo/fetch';
75
+
76
+ <WidgetProvider
77
+ components={yourComponents}
78
+ options={{
79
+ token: '<WIDGET_TOKEN>',
80
+ streaming: true,
81
+ streamingFetch: expoFetch as typeof fetch,
82
+ }}
83
+ >
84
+ <YourChat />
85
+ </WidgetProvider>;
86
+ ```
87
+
88
+ 1. `streamingFetch`: React Native's built-in fetch cannot read a response
89
+ while it arrives. Every other request keeps using the global fetch.
90
+ 2. Globals the stream reader uses: `structuredClone` and `TextDecoderStream`.
91
+ Install polyfills for them at startup, before the widget is imported.
92
+ 3. Resuming a dropped reply: browsers resume when the tab is visible again or
93
+ the network returns. React Native has neither event, so call
94
+ `useAgentChatUi().resumeInterruptedTurn()` when `AppState` becomes
95
+ `active` and when connectivity returns. It does nothing unless the last
96
+ reply was cut off.