@agentforge-io/chat-sdk 2.0.21 → 2.0.22
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/entities.d.ts +6 -2
- package/dist/react.d.ts +6 -2
- package/dist/session.js +16 -9
- package/package.json +1 -1
package/dist/entities.d.ts
CHANGED
|
@@ -131,8 +131,12 @@ export interface ChatSessionOptions {
|
|
|
131
131
|
token: string;
|
|
132
132
|
/**
|
|
133
133
|
* Base URL of the AgentForge API, including scheme. Trailing slash is
|
|
134
|
-
* stripped.
|
|
135
|
-
*
|
|
134
|
+
* stripped. Resolution order:
|
|
135
|
+
* 1. This option (when present).
|
|
136
|
+
* 2. `window.AGENTFORGE_API_BASE_URL` (runtime override, useful when
|
|
137
|
+
* embedding via a `<script>` tag without React props).
|
|
138
|
+
* 3. The baked default that ships with the current SDK version.
|
|
139
|
+
* Hosts embedding into their own site can leave this unset.
|
|
136
140
|
*/
|
|
137
141
|
apiBaseUrl?: string;
|
|
138
142
|
/** Stable id for this end-user's browser. Persist it (localStorage etc.)
|
package/dist/react.d.ts
CHANGED
|
@@ -61,8 +61,12 @@ export interface ApprovalCopy {
|
|
|
61
61
|
export interface ChatWidgetProps {
|
|
62
62
|
/** Public chat token (`aft_*`) issued from the admin UI. */
|
|
63
63
|
token: string;
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
64
|
+
/**
|
|
65
|
+
* AgentForge API origin. Optional — the SDK ships with a built-in
|
|
66
|
+
* default that points at the hosted AgentForge deployment. Override
|
|
67
|
+
* this when you self-host the backend. A `window.AGENTFORGE_API_BASE_URL`
|
|
68
|
+
* global also overrides, useful for `<script>`-tag embeds.
|
|
69
|
+
*/
|
|
66
70
|
apiBaseUrl?: string;
|
|
67
71
|
/** Render inline (fills the parent) instead of as a floating bubble. */
|
|
68
72
|
inline?: boolean;
|
package/dist/session.js
CHANGED
|
@@ -29,9 +29,6 @@ class ChatSession {
|
|
|
29
29
|
if (!opts.token)
|
|
30
30
|
throw new Error('ChatSession: token is required');
|
|
31
31
|
const apiBaseUrl = opts.apiBaseUrl ?? defaultApiBase();
|
|
32
|
-
if (!apiBaseUrl) {
|
|
33
|
-
throw new Error('ChatSession: apiBaseUrl is required outside the browser');
|
|
34
|
-
}
|
|
35
32
|
this.transport = new transport_1.HttpTransport(apiBaseUrl, opts.token);
|
|
36
33
|
this.stream = opts.stream ?? true;
|
|
37
34
|
this.browserSessionId = opts.browserSessionId ?? generateBrowserSessionId();
|
|
@@ -392,11 +389,21 @@ function generateBrowserSessionId() {
|
|
|
392
389
|
return c.randomUUID();
|
|
393
390
|
return `${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
394
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Build-time default API origin. Bumped together with the SDK when the
|
|
394
|
+
* hosted AgentForge deployment moves to a new domain. Hosts that
|
|
395
|
+
* self-host the backend override this via the `apiBaseUrl` constructor
|
|
396
|
+
* option, or at runtime via `window.AGENTFORGE_API_BASE_URL`.
|
|
397
|
+
*/
|
|
398
|
+
const BAKED_API_BASE = 'https://api-agentforge.stupidmvp.com';
|
|
395
399
|
function defaultApiBase() {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
//
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
// Runtime override for hosts that embed via a script tag and don't
|
|
401
|
+
// want to touch React props. Set once on `window` before the widget
|
|
402
|
+
// mounts and the SDK uses it for every transport call.
|
|
403
|
+
if (typeof window !== 'undefined') {
|
|
404
|
+
const override = window.AGENTFORGE_API_BASE_URL;
|
|
405
|
+
if (override)
|
|
406
|
+
return override;
|
|
407
|
+
}
|
|
408
|
+
return BAKED_API_BASE;
|
|
402
409
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentforge-io/chat-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.22",
|
|
4
4
|
"description": "Framework-free chat session SDK for AgentForge public chat tokens. Headless — no DOM. Drop into any frontend (React, Vue, Svelte, vanilla) and listen for events.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|