@agentforge-io/chat-sdk 2.0.21 → 2.0.23

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.
@@ -131,8 +131,10 @@ export interface ChatSessionOptions {
131
131
  token: string;
132
132
  /**
133
133
  * Base URL of the AgentForge API, including scheme. Trailing slash is
134
- * stripped. Defaults to the origin the SDK was loaded from when running
135
- * inside a browser bundle of the widget; required everywhere else.
134
+ * stripped. Optional when omitted the SDK uses the baked default
135
+ * that ships with the current version. Pass this only when self-
136
+ * hosting the backend or pointing the SDK at a non-production
137
+ * deployment (e.g. localhost during development).
136
138
  */
137
139
  apiBaseUrl?: string;
138
140
  /** 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
- /** AgentForge API origin. Defaults to `window.location.origin` in the
65
- * browser set this when your site and the API live on different hosts. */
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 only when self-hosting the backend or pointing at a non-
68
+ * production deployment.
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,12 @@ 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. Self-hosted
395
+ * deployments override this via the `apiBaseUrl` constructor option.
396
+ */
397
+ const BAKED_API_BASE = 'https://api-agentforge.stupidmvp.com';
395
398
  function defaultApiBase() {
396
- if (typeof window === 'undefined')
397
- return undefined;
398
- // When the SDK is bundled into the AgentForge-served widget, it loads from
399
- // the API origin — so the same origin is the natural default. Consumers in
400
- // their own app will pass `apiBaseUrl` explicitly.
401
- return window.location.origin;
399
+ return BAKED_API_BASE;
402
400
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge-io/chat-sdk",
3
- "version": "2.0.21",
3
+ "version": "2.0.23",
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",