@agentforge-io/chat-sdk 2.6.0 → 3.0.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/dist/react.d.ts +16 -0
- package/dist/react.js +8 -1
- package/package.json +3 -3
package/dist/react.d.ts
CHANGED
|
@@ -181,6 +181,22 @@ export interface ChatWidgetProps {
|
|
|
181
181
|
* once `agent_loaded` has fired internally.
|
|
182
182
|
*/
|
|
183
183
|
handleRef?: React.MutableRefObject<ChatWidgetHandle | null>;
|
|
184
|
+
/**
|
|
185
|
+
* Optional observer adapter. When supplied, the SDK boots it once the
|
|
186
|
+
* conversation id is known (first user message) and flushes captured
|
|
187
|
+
* DOM/WebMCP events to the AgentForge ingestion endpoint after every
|
|
188
|
+
* turn + on page unload. The adapter is a duck-typed contract — see
|
|
189
|
+
* `ObserverAdapterLike` — so the `@agentforge-io/observer` package
|
|
190
|
+
* stays an optional peer dep. Hosts that don't ship observer can
|
|
191
|
+
* omit this and chat behaves identically.
|
|
192
|
+
*
|
|
193
|
+
* Wire this from preview / playground pages where the operator
|
|
194
|
+
* wants to inspect what visitors do, or from production embeds
|
|
195
|
+
* where the agent's `observerEnabled` is true. The server-side
|
|
196
|
+
* agent config determines whether ingestion actually persists;
|
|
197
|
+
* the client-side adapter just captures.
|
|
198
|
+
*/
|
|
199
|
+
observer?: import('./observer').ObserverAdapterLike;
|
|
184
200
|
}
|
|
185
201
|
/** Imperative surface exposed via ChatWidgetProps.handleRef. Narrow
|
|
186
202
|
* on purpose — hosts get a verb, not the whole session. */
|
package/dist/react.js
CHANGED
|
@@ -228,7 +228,7 @@ function fallbackCopy(ctx) {
|
|
|
228
228
|
* SDK event. Consumers don't need to read `session.getState()` themselves.
|
|
229
229
|
*/
|
|
230
230
|
function ChatWidget(props) {
|
|
231
|
-
const { token, apiBaseUrl, inline = false, position, browserSessionId, resumeConversationId, onConversationStart, stream, className, style, onApprovalDecision, readOnlyApprovals = false, variant = 'card', greeting, personaName, shortcuts, onShortcutClick, inputPlaceholder, members, composerLeftSlot, handleRef, } = props;
|
|
231
|
+
const { token, apiBaseUrl, inline = false, position, browserSessionId, resumeConversationId, onConversationStart, stream, className, style, onApprovalDecision, readOnlyApprovals = false, variant = 'card', greeting, personaName, shortcuts, onShortcutClick, inputPlaceholder, members, composerLeftSlot, handleRef, observer, } = props;
|
|
232
232
|
// Build a lookup so MessageBubble can resolve actingAgentId → identity
|
|
233
233
|
// in O(1) per render without re-walking the members array. Stable
|
|
234
234
|
// identity per `members` prop change.
|
|
@@ -309,6 +309,12 @@ function ChatWidget(props) {
|
|
|
309
309
|
// updates to it are ignored — the SDK already owns the live
|
|
310
310
|
// conversation id internally via session.state.conversationId.
|
|
311
311
|
const resumeRef = (0, react_1.useRef)(resumeConversationId);
|
|
312
|
+
// Same rationale as `resumeRef` above — the observer adapter is
|
|
313
|
+
// captured at mount so a parent re-render with a new (but equivalent)
|
|
314
|
+
// adapter identity doesn't tear down the live ChatSession mid-
|
|
315
|
+
// conversation. Hosts that need to swap observers should remount
|
|
316
|
+
// the widget (e.g. via a `key` prop).
|
|
317
|
+
const observerRef = (0, react_1.useRef)(observer);
|
|
312
318
|
(0, react_1.useEffect)(() => {
|
|
313
319
|
let cancelled = false;
|
|
314
320
|
const s = new session_1.ChatSession({
|
|
@@ -317,6 +323,7 @@ function ChatWidget(props) {
|
|
|
317
323
|
browserSessionId,
|
|
318
324
|
resumeConversationId: resumeRef.current,
|
|
319
325
|
stream,
|
|
326
|
+
observer: observerRef.current,
|
|
320
327
|
});
|
|
321
328
|
setSession(s);
|
|
322
329
|
setMessages([]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentforge-io/chat-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Framework-free chat session SDK for AgentForge public chat tokens. Headless
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Framework-free chat session SDK for AgentForge public chat tokens. Headless \u2014 no DOM. Drop into any frontend (React, Vue, Svelte, vanilla) and listen for events.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"react": "^18.3.1",
|
|
38
38
|
"typescript": "^5.0.0"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|