@useago/sdk 1.0.1 → 1.0.3

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/index.d.cts CHANGED
@@ -27,12 +27,26 @@ export declare class AgoClient {
27
27
  private contextRegistry;
28
28
  private eventEmitter;
29
29
  private config;
30
+ /** Conversations already warned about an empty reply (one warning each). */
31
+ private warnedEmptyConversations;
30
32
  constructor(config: AgoConfig);
31
33
  /**
32
34
  * Send a message and receive a streaming response
33
35
  */
34
36
  sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
35
37
  private processSSEResponse;
38
+ /**
39
+ * Detect a reply that completed as DONE with no content and no activity —
40
+ * today's backend answers an unknown `agent` slug with an empty 200, which
41
+ * otherwise fails silently. Emits `message:empty` (always) and warns on the
42
+ * console once per conversation (unless `warnOnEmptyReply: false`).
43
+ *
44
+ * Deferred with setTimeout(0) so both land AFTER `sendMessage` resolves:
45
+ * `await client.sendMessage(...)` followed by `client.waitFor("message:empty")`
46
+ * must not race. TEMPORARY heuristic: remove once the backend returns an
47
+ * explicit error for unknown agents (see TODOS.md, backend issue).
48
+ */
49
+ private maybeFlagEmptyReply;
36
50
  private handleClientFunctionInvocation;
37
51
  /**
38
52
  * Get list of conversations
@@ -75,10 +89,11 @@ export declare class AgoClient {
75
89
  * Relay a completed form collector's values to a server-configured destination.
76
90
  *
77
91
  * Used by `createFormCollector` / `useFormCollector` in `{ via: "backend" }` mode:
78
- * the browser never holds the destination URL or its secret — the backend resolves
79
- * `destination` (a named, opted-in tool) and forwards the values from the server.
92
+ * the browser never holds the destination name, URL, or its secret — the backend
93
+ * resolves the destination from the named form's stored definition and forwards
94
+ * the values from the server.
80
95
  */
81
- submitFormCollector(destination: string, values: Record<string, unknown>): Promise<unknown>;
96
+ submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
82
97
  /**
83
98
  * Submit feedback for a message
84
99
  */
@@ -205,6 +220,11 @@ export declare class AgoClient {
205
220
  }): Promise<AgoClientEvents[K]>;
206
221
  /**
207
222
  * Update client configuration
223
+ *
224
+ * Validates the MERGED config before committing: omitting a key (or passing
225
+ * it as `undefined`, common with spread-built partials) keeps the current
226
+ * value; an explicit empty/non-string `baseUrl` throws `config_missing_base_url`
227
+ * and leaves the client unchanged (no half-updated state).
208
228
  */
209
229
  updateConfig(config: Partial<AgoConfig>): void;
210
230
  /**
@@ -240,8 +260,23 @@ export declare interface AgoClientEvents {
240
260
  */
241
261
  "message:answer-complete": AgoMessage;
242
262
  "message:complete": AgoMessage;
263
+ /**
264
+ * A reply finished as `DONE` with empty content and no tool calls, client
265
+ * functions, or follow-up replies — usually an unknown `agent` slug (the
266
+ * backend currently answers those with an empty 200). Fires after
267
+ * `message:complete` AND after `sendMessage` resolves, so subscribing right
268
+ * after `await sendMessage(...)` still catches it. `messageId` and
269
+ * `conversationId` are empty strings when the stream completed without any
270
+ * message data at all (e.g. a proxy stripped the SSE stream).
271
+ */
272
+ "message:empty": {
273
+ conversationId: string;
274
+ messageId: string;
275
+ };
243
276
  "message:error": {
244
277
  error: string;
278
+ /** Stable error code (see configuration.md#error-codes) when the failure was an AgoError. */
279
+ code?: string;
245
280
  conversationId?: string;
246
281
  messageId?: string;
247
282
  };
@@ -270,7 +305,7 @@ export declare interface AgoClientEvents {
270
305
  export declare interface AgoConfig {
271
306
  /** API base URL (e.g., https://YOUR-DOMAIN.useago.com) */
272
307
  baseUrl: string;
273
- /** Widget ID (X-Widget-Id header). Auto-generated if not provided. */
308
+ /** Per-visitor anonymous ID (X-User-Anon-Id header). Auto-generated if not provided. */
274
309
  widgetId?: string;
275
310
  /** Default agent (id or slug) for new conversations. Shorthand for `defaultAgentId`. */
276
311
  agent?: string;
@@ -284,10 +319,23 @@ export declare interface AgoConfig {
284
319
  userJwt?: string;
285
320
  /** Enable debug logging */
286
321
  debug?: boolean;
322
+ /**
323
+ * Warn on the console when a reply completes with empty content and no tool
324
+ * calls (the usual cause is an unknown `agent` slug, which the backend
325
+ * currently answers with an empty 200). Default `true`. The `message:empty`
326
+ * event fires regardless of this setting.
327
+ */
328
+ warnOnEmptyReply?: boolean;
287
329
  }
288
330
 
289
331
  /**
290
332
  * Base error class for AGO SDK
333
+ *
334
+ * Error convention: every throw carries a stable `code` (snake_case), a
335
+ * one-line fix hint in the message, and a doc URL/anchor when one exists.
336
+ * `code` is the compatibility surface — match on it, never on message text,
337
+ * which may be reworded in any release. The code registry lives in
338
+ * docs/general/configuration.md#error-codes.
291
339
  */
292
340
  export declare class AgoError extends Error {
293
341
  code: string;
@@ -343,9 +391,14 @@ export declare interface AgoSource {
343
391
 
344
392
  /**
345
393
  * SSE stream error
394
+ *
395
+ * `code` distinguishes failure classes without message parsing:
396
+ * - `stream_no_body`: the response had no streamable body (usually a
397
+ * misconfigured endpoint or a proxy stripping the SSE stream)
398
+ * - `stream_error` (default): the stream failed mid-flight
346
399
  */
347
400
  export declare class AgoStreamError extends AgoError {
348
- constructor(message: string);
401
+ constructor(message: string, code?: string);
349
402
  }
350
403
 
351
404
  /**
@@ -623,8 +676,8 @@ export declare const copyToClipboard: ClientFunctionDefinition;
623
676
  export declare function createAgo(overrides?: Partial<AgoConfig>): AgoClient;
624
677
 
625
678
  /**
626
- * Identify a returning visitor with a single, stable widget id — the same model as
627
- * the frontend's `getOrGenerateWidgetId` — and resume their last active thread.
679
+ * Identify a returning visitor with a single, stable anon id (one id, generated
680
+ * once and reused forever) and resume their last active thread.
628
681
  *
629
682
  * There is no per-agent conversation id: the widget id is the identity, and the last
630
683
  * active thread (its id + the time of its last message) is cached locally so resuming
@@ -1317,8 +1370,9 @@ export declare interface Store<T> {
1317
1370
  * POSTs the values to that URL.
1318
1371
  * - `{ via: "client", url }` — same, written out.
1319
1372
  * - `{ via: "client", handler }` — the browser runs your own submit logic.
1320
- * - `{ via: "backend", destination }` — the browser relays the values to the backend,
1321
- * which forwards them to the server-configured destination (URL + secret stay server-side).
1373
+ * - `{ via: "backend" }` — the browser relays the values to the backend, which resolves
1374
+ * the destination from the form's backend-stored definition (name, URL and secret all
1375
+ * stay server-side). `destination` is deprecated and ignored.
1322
1376
  * - `false` — collect only, no submit function.
1323
1377
  */
1324
1378
  export declare type SubmitConfig<V = Record<string, unknown>> = string | {
@@ -1329,7 +1383,7 @@ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
1329
1383
  handler: (values: V) => Promise<unknown> | unknown;
1330
1384
  } | {
1331
1385
  via: "backend";
1332
- destination: string;
1386
+ destination?: string;
1333
1387
  } | false;
1334
1388
 
1335
1389
  /**
@@ -1361,6 +1415,29 @@ export declare type ToolCallType = "form" | "confirmation_input" | "status_messa
1361
1415
  */
1362
1416
  export declare const trackEvent: ClientFunctionDefinition;
1363
1417
 
1418
+ /**
1419
+ * Validate an AgoConfig at the public API boundary.
1420
+ *
1421
+ * Rules:
1422
+ * - nullish / non-object config, or a missing/empty/non-string `baseUrl`,
1423
+ * throws `AgoError` with the stable code `config_missing_base_url`.
1424
+ * - Values starting with `/` are allowed (same-origin proxy paths like
1425
+ * `/ago-proxy` are a supported embed pattern).
1426
+ * - Values with any `scheme://` are allowed.
1427
+ * - Anything else (no scheme, no leading slash, e.g. "ago.api.useago.com")
1428
+ * warns once per process — it usually means a forgotten protocol. It does
1429
+ * not throw: the request fails at send time with a runtime-specific error
1430
+ * (Node: URL parse error; browser: relative fetch), and a hard throw here
1431
+ * could break embeds we cannot foresee.
1432
+ *
1433
+ * The warning never echoes the configured value: misconfigured baseUrls
1434
+ * sometimes carry credentials (e.g. `https://user:token@host`).
1435
+ *
1436
+ * @param context Prefix for the error message, naming the API the developer
1437
+ * actually called (e.g. "AgoClient", "createAgo()").
1438
+ */
1439
+ export declare function validateConfig(config: unknown, context?: string): asserts config is AgoConfig;
1440
+
1364
1441
  /**
1365
1442
  * Attach a handler to a pre-built function definition.
1366
1443
  *
package/dist/index.d.ts CHANGED
@@ -27,12 +27,26 @@ export declare class AgoClient {
27
27
  private contextRegistry;
28
28
  private eventEmitter;
29
29
  private config;
30
+ /** Conversations already warned about an empty reply (one warning each). */
31
+ private warnedEmptyConversations;
30
32
  constructor(config: AgoConfig);
31
33
  /**
32
34
  * Send a message and receive a streaming response
33
35
  */
34
36
  sendMessage(content: string, options?: SendMessageOptions): Promise<AgoMessage>;
35
37
  private processSSEResponse;
38
+ /**
39
+ * Detect a reply that completed as DONE with no content and no activity —
40
+ * today's backend answers an unknown `agent` slug with an empty 200, which
41
+ * otherwise fails silently. Emits `message:empty` (always) and warns on the
42
+ * console once per conversation (unless `warnOnEmptyReply: false`).
43
+ *
44
+ * Deferred with setTimeout(0) so both land AFTER `sendMessage` resolves:
45
+ * `await client.sendMessage(...)` followed by `client.waitFor("message:empty")`
46
+ * must not race. TEMPORARY heuristic: remove once the backend returns an
47
+ * explicit error for unknown agents (see TODOS.md, backend issue).
48
+ */
49
+ private maybeFlagEmptyReply;
36
50
  private handleClientFunctionInvocation;
37
51
  /**
38
52
  * Get list of conversations
@@ -75,10 +89,11 @@ export declare class AgoClient {
75
89
  * Relay a completed form collector's values to a server-configured destination.
76
90
  *
77
91
  * Used by `createFormCollector` / `useFormCollector` in `{ via: "backend" }` mode:
78
- * the browser never holds the destination URL or its secret — the backend resolves
79
- * `destination` (a named, opted-in tool) and forwards the values from the server.
92
+ * the browser never holds the destination name, URL, or its secret — the backend
93
+ * resolves the destination from the named form's stored definition and forwards
94
+ * the values from the server.
80
95
  */
81
- submitFormCollector(destination: string, values: Record<string, unknown>): Promise<unknown>;
96
+ submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
82
97
  /**
83
98
  * Submit feedback for a message
84
99
  */
@@ -205,6 +220,11 @@ export declare class AgoClient {
205
220
  }): Promise<AgoClientEvents[K]>;
206
221
  /**
207
222
  * Update client configuration
223
+ *
224
+ * Validates the MERGED config before committing: omitting a key (or passing
225
+ * it as `undefined`, common with spread-built partials) keeps the current
226
+ * value; an explicit empty/non-string `baseUrl` throws `config_missing_base_url`
227
+ * and leaves the client unchanged (no half-updated state).
208
228
  */
209
229
  updateConfig(config: Partial<AgoConfig>): void;
210
230
  /**
@@ -240,8 +260,23 @@ export declare interface AgoClientEvents {
240
260
  */
241
261
  "message:answer-complete": AgoMessage;
242
262
  "message:complete": AgoMessage;
263
+ /**
264
+ * A reply finished as `DONE` with empty content and no tool calls, client
265
+ * functions, or follow-up replies — usually an unknown `agent` slug (the
266
+ * backend currently answers those with an empty 200). Fires after
267
+ * `message:complete` AND after `sendMessage` resolves, so subscribing right
268
+ * after `await sendMessage(...)` still catches it. `messageId` and
269
+ * `conversationId` are empty strings when the stream completed without any
270
+ * message data at all (e.g. a proxy stripped the SSE stream).
271
+ */
272
+ "message:empty": {
273
+ conversationId: string;
274
+ messageId: string;
275
+ };
243
276
  "message:error": {
244
277
  error: string;
278
+ /** Stable error code (see configuration.md#error-codes) when the failure was an AgoError. */
279
+ code?: string;
245
280
  conversationId?: string;
246
281
  messageId?: string;
247
282
  };
@@ -270,7 +305,7 @@ export declare interface AgoClientEvents {
270
305
  export declare interface AgoConfig {
271
306
  /** API base URL (e.g., https://YOUR-DOMAIN.useago.com) */
272
307
  baseUrl: string;
273
- /** Widget ID (X-Widget-Id header). Auto-generated if not provided. */
308
+ /** Per-visitor anonymous ID (X-User-Anon-Id header). Auto-generated if not provided. */
274
309
  widgetId?: string;
275
310
  /** Default agent (id or slug) for new conversations. Shorthand for `defaultAgentId`. */
276
311
  agent?: string;
@@ -284,10 +319,23 @@ export declare interface AgoConfig {
284
319
  userJwt?: string;
285
320
  /** Enable debug logging */
286
321
  debug?: boolean;
322
+ /**
323
+ * Warn on the console when a reply completes with empty content and no tool
324
+ * calls (the usual cause is an unknown `agent` slug, which the backend
325
+ * currently answers with an empty 200). Default `true`. The `message:empty`
326
+ * event fires regardless of this setting.
327
+ */
328
+ warnOnEmptyReply?: boolean;
287
329
  }
288
330
 
289
331
  /**
290
332
  * Base error class for AGO SDK
333
+ *
334
+ * Error convention: every throw carries a stable `code` (snake_case), a
335
+ * one-line fix hint in the message, and a doc URL/anchor when one exists.
336
+ * `code` is the compatibility surface — match on it, never on message text,
337
+ * which may be reworded in any release. The code registry lives in
338
+ * docs/general/configuration.md#error-codes.
291
339
  */
292
340
  export declare class AgoError extends Error {
293
341
  code: string;
@@ -343,9 +391,14 @@ export declare interface AgoSource {
343
391
 
344
392
  /**
345
393
  * SSE stream error
394
+ *
395
+ * `code` distinguishes failure classes without message parsing:
396
+ * - `stream_no_body`: the response had no streamable body (usually a
397
+ * misconfigured endpoint or a proxy stripping the SSE stream)
398
+ * - `stream_error` (default): the stream failed mid-flight
346
399
  */
347
400
  export declare class AgoStreamError extends AgoError {
348
- constructor(message: string);
401
+ constructor(message: string, code?: string);
349
402
  }
350
403
 
351
404
  /**
@@ -623,8 +676,8 @@ export declare const copyToClipboard: ClientFunctionDefinition;
623
676
  export declare function createAgo(overrides?: Partial<AgoConfig>): AgoClient;
624
677
 
625
678
  /**
626
- * Identify a returning visitor with a single, stable widget id — the same model as
627
- * the frontend's `getOrGenerateWidgetId` — and resume their last active thread.
679
+ * Identify a returning visitor with a single, stable anon id (one id, generated
680
+ * once and reused forever) and resume their last active thread.
628
681
  *
629
682
  * There is no per-agent conversation id: the widget id is the identity, and the last
630
683
  * active thread (its id + the time of its last message) is cached locally so resuming
@@ -1317,8 +1370,9 @@ export declare interface Store<T> {
1317
1370
  * POSTs the values to that URL.
1318
1371
  * - `{ via: "client", url }` — same, written out.
1319
1372
  * - `{ via: "client", handler }` — the browser runs your own submit logic.
1320
- * - `{ via: "backend", destination }` — the browser relays the values to the backend,
1321
- * which forwards them to the server-configured destination (URL + secret stay server-side).
1373
+ * - `{ via: "backend" }` — the browser relays the values to the backend, which resolves
1374
+ * the destination from the form's backend-stored definition (name, URL and secret all
1375
+ * stay server-side). `destination` is deprecated and ignored.
1322
1376
  * - `false` — collect only, no submit function.
1323
1377
  */
1324
1378
  export declare type SubmitConfig<V = Record<string, unknown>> = string | {
@@ -1329,7 +1383,7 @@ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
1329
1383
  handler: (values: V) => Promise<unknown> | unknown;
1330
1384
  } | {
1331
1385
  via: "backend";
1332
- destination: string;
1386
+ destination?: string;
1333
1387
  } | false;
1334
1388
 
1335
1389
  /**
@@ -1361,6 +1415,29 @@ export declare type ToolCallType = "form" | "confirmation_input" | "status_messa
1361
1415
  */
1362
1416
  export declare const trackEvent: ClientFunctionDefinition;
1363
1417
 
1418
+ /**
1419
+ * Validate an AgoConfig at the public API boundary.
1420
+ *
1421
+ * Rules:
1422
+ * - nullish / non-object config, or a missing/empty/non-string `baseUrl`,
1423
+ * throws `AgoError` with the stable code `config_missing_base_url`.
1424
+ * - Values starting with `/` are allowed (same-origin proxy paths like
1425
+ * `/ago-proxy` are a supported embed pattern).
1426
+ * - Values with any `scheme://` are allowed.
1427
+ * - Anything else (no scheme, no leading slash, e.g. "ago.api.useago.com")
1428
+ * warns once per process — it usually means a forgotten protocol. It does
1429
+ * not throw: the request fails at send time with a runtime-specific error
1430
+ * (Node: URL parse error; browser: relative fetch), and a hard throw here
1431
+ * could break embeds we cannot foresee.
1432
+ *
1433
+ * The warning never echoes the configured value: misconfigured baseUrls
1434
+ * sometimes carry credentials (e.g. `https://user:token@host`).
1435
+ *
1436
+ * @param context Prefix for the error message, naming the API the developer
1437
+ * actually called (e.g. "AgoClient", "createAgo()").
1438
+ */
1439
+ export declare function validateConfig(config: unknown, context?: string): asserts config is AgoConfig;
1440
+
1364
1441
  /**
1365
1442
  * Attach a handler to a pre-built function definition.
1366
1443
  *
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { a as w, c as h, d as A, f as y, i as C, l as E, n as S, o as b, r as v, s as k, t as d, u as F } from "./AgoClient-CZYNL25R.js";
2
- import { i as T, n as I, r as U, t as G } from "./createFormCollector-Bk0DRhUf.js";
3
- import { t as q } from "./createConversationSession-Bmqj2rSS.js";
4
- import { t as L } from "./createMockClient-DwdxNwEn.js";
1
+ import { a as h, c as A, d as y, f as C, i as E, l as b, n as S, o as v, p as k, r as F, s as M, t as d, u as c } from "./AgoClient-CBLJfu90.js";
2
+ import { i as I, n as U, r as G, t as O } from "./createFormCollector-CyD7KnjG.js";
3
+ import { t as x } from "./createConversationSession-D3aHSSir.js";
4
+ import { t as N } from "./createMockClient-DwdxNwEn.js";
5
5
  import "./testing.js";
6
6
  import { a as H, c as J, d as R, f as j, i as B, l as P, m as $, o as z, p as K, r as Q, s as V, t as W, u as X } from "./functions-C1-5vadY.js";
7
7
  function Y(e) {
@@ -10,26 +10,26 @@ function Y(e) {
10
10
  function Z(e, o) {
11
11
  return e.on("message:complete", o), () => e.off("message:complete", o);
12
12
  }
13
- function _(e, o) {
13
+ function ee(e, o) {
14
14
  return e.on("message:chunk", o), () => e.off("message:chunk", o);
15
15
  }
16
- function ee(e, o) {
16
+ function oe(e, o) {
17
17
  return e.on("message:start", o), () => e.off("message:start", o);
18
18
  }
19
- function oe(e, o) {
19
+ function te(e, o) {
20
20
  return e.on("message:error", o), () => e.off("message:error", o);
21
21
  }
22
- function te(e, o) {
22
+ function ae(e, o) {
23
23
  return e.on("toolCall:received", o), () => e.off("toolCall:received", o);
24
24
  }
25
25
  function re(e, o) {
26
26
  return e.on("function:invoke", o), () => e.off("function:invoke", o);
27
27
  }
28
- async function* ae(e, o, g) {
29
- const a = [];
30
- let r = null, n = !1;
28
+ async function* ne(e, o, g) {
29
+ const r = [];
30
+ let a = null, n = !1;
31
31
  const u = (s) => {
32
- a.push(s), r?.();
32
+ r.push(s), a?.();
33
33
  }, f = (s) => u({
34
34
  type: "start",
35
35
  data: s
@@ -40,98 +40,98 @@ async function* ae(e, o, g) {
40
40
  u({
41
41
  type: "complete",
42
42
  data: s
43
- }), n = !0, r?.();
44
- }, m = (s) => {
43
+ }), n = !0, a?.();
44
+ }, l = (s) => {
45
45
  u({
46
46
  type: "error",
47
47
  data: s
48
- }), n = !0, r?.();
49
- }, l = (s) => u({
48
+ }), n = !0, a?.();
49
+ }, m = (s) => u({
50
50
  type: "toolCall",
51
51
  data: s
52
52
  });
53
- e.on("message:start", f), e.on("message:chunk", t), e.on("message:complete", i), e.on("message:error", m), e.on("toolCall:received", l), e.sendMessage(o, g).catch(() => {
54
- n = !0, r?.();
53
+ e.on("message:start", f), e.on("message:chunk", t), e.on("message:complete", i), e.on("message:error", l), e.on("toolCall:received", m), e.sendMessage(o, g).catch(() => {
54
+ n = !0, a?.();
55
55
  });
56
56
  try {
57
- for (; !n || a.length > 0; ) a.length > 0 ? yield a.shift() : (await new Promise((s) => {
58
- r = s;
59
- }), r = null);
57
+ for (; !n || r.length > 0; ) r.length > 0 ? yield r.shift() : (await new Promise((s) => {
58
+ a = s;
59
+ }), a = null);
60
60
  } finally {
61
- e.off("message:start", f), e.off("message:chunk", t), e.off("message:complete", i), e.off("message:error", m), e.off("toolCall:received", l);
61
+ e.off("message:start", f), e.off("message:chunk", t), e.off("message:complete", i), e.off("message:error", l), e.off("toolCall:received", m);
62
62
  }
63
63
  }
64
- function c(e) {
65
- let o, g, a, r, n, u;
64
+ function p(e) {
65
+ let o, g, r, a, n, u;
66
66
  if (typeof window < "u" && window.AGO) {
67
67
  const t = window.AGO;
68
- o = t.basepath, g = t.widgetId, a = t.agent || t.defaultAgent, r = t.permission, n = t.email, u = t.jwt;
68
+ o = t.basepath, g = t.widgetId, r = t.agent || t.defaultAgent, a = t.permission, n = t.email, u = t.jwt;
69
69
  }
70
70
  if (typeof document < "u") {
71
71
  const t = (i) => document.querySelector(`meta[name="${i}"]`)?.getAttribute("content") || void 0;
72
- o = o || t("ago-base-url"), g = g || t("ago-widget-id"), a = a || t("ago-agent") || t("ago-agent-id"), r = r || t("ago-permission"), n = n || t("ago-user-email");
72
+ o = o || t("ago-base-url"), g = g || t("ago-widget-id"), r = r || t("ago-agent") || t("ago-agent-id"), a = a || t("ago-permission"), n = n || t("ago-user-email");
73
73
  }
74
74
  if (typeof document < "u") {
75
75
  const t = [document.body, ...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);
76
76
  for (const i of t)
77
- i && (o = o || i.getAttribute("data-ago-base-url") || void 0, g = g || i.getAttribute("data-ago-widget-id") || void 0, a = a || i.getAttribute("data-ago-agent") || i.getAttribute("data-ago-agent-id") || void 0, r = r || i.getAttribute("data-ago-permission") || void 0, n = n || i.getAttribute("data-ago-user-email") || void 0);
77
+ i && (o = o || i.getAttribute("data-ago-base-url") || void 0, g = g || i.getAttribute("data-ago-widget-id") || void 0, r = r || i.getAttribute("data-ago-agent") || i.getAttribute("data-ago-agent-id") || void 0, a = a || i.getAttribute("data-ago-permission") || void 0, n = n || i.getAttribute("data-ago-user-email") || void 0);
78
78
  }
79
- o = e?.baseUrl || o, g = e?.widgetId || g, a = e?.agent || e?.defaultAgentId || a, r = e?.permission || r, n = e?.userEmail || n, u = e?.userJwt || u;
79
+ o = e?.baseUrl || o, g = e?.widgetId || g, r = e?.agent || e?.defaultAgentId || r, a = e?.permission || a, n = e?.userEmail || n, u = e?.userJwt || u;
80
80
  const f = e?.debug;
81
81
  return o ? {
82
82
  baseUrl: o,
83
83
  widgetId: g,
84
- agent: a,
85
- permission: r,
84
+ agent: r,
85
+ permission: a,
86
86
  userEmail: n,
87
87
  userJwt: u,
88
88
  debug: f
89
89
  } : null;
90
90
  }
91
- function ne(e) {
92
- const o = c(e);
93
- if (!o) throw new Error('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.');
91
+ function se(e) {
92
+ const o = p(e);
93
+ if (!o) throw new c('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.', "config_missing_base_url");
94
94
  return new d(o);
95
95
  }
96
- function se(e, o) {
96
+ function ie(e, o) {
97
97
  return {
98
98
  ...e,
99
99
  handler: o
100
100
  };
101
101
  }
102
102
  export {
103
- h as AgoApiError,
103
+ b as AgoApiError,
104
104
  d as AgoClient,
105
- E as AgoError,
106
- F as AgoFunctionError,
107
- A as AgoNetworkError,
108
- y as AgoStreamError,
109
- w as ClientContextRegistry,
110
- S as EventEmitter,
111
- b as FunctionRegistry,
112
- v as SSEHandler,
113
- c as autoDetectConfig,
105
+ c as AgoError,
106
+ y as AgoFunctionError,
107
+ C as AgoNetworkError,
108
+ k as AgoStreamError,
109
+ v as ClientContextRegistry,
110
+ F as EventEmitter,
111
+ M as FunctionRegistry,
112
+ E as SSEHandler,
113
+ p as autoDetectConfig,
114
114
  W as copyToClipboard,
115
- ne as createAgo,
116
- q as createConversationSession,
117
- G as createFormCollector,
118
- ae as createMessageStream,
119
- L as createMockClient,
120
- T as createStore,
115
+ se as createAgo,
116
+ x as createConversationSession,
117
+ O as createFormCollector,
118
+ ne as createMessageStream,
119
+ N as createMockClient,
120
+ I as createStore,
121
121
  Y as defineFunction,
122
- I as deriveFormStatus,
122
+ U as deriveFormStatus,
123
123
  Q as getLocalStorage,
124
124
  B as getUserLocation,
125
125
  H as highlightElement,
126
- C as isStreamNetworkError,
127
- U as loadFormCollector,
128
- k as logger,
126
+ h as isStreamNetworkError,
127
+ G as loadFormCollector,
128
+ A as logger,
129
129
  re as onFunctionInvoke,
130
130
  Z as onMessage,
131
- _ as onMessageChunk,
132
- oe as onMessageError,
133
- ee as onMessageStart,
134
- te as onToolCall,
131
+ ee as onMessageChunk,
132
+ te as onMessageError,
133
+ oe as onMessageStart,
134
+ ae as onToolCall,
135
135
  z as openUrl,
136
136
  V as scrollToElement,
137
137
  J as setLocalStorage,
@@ -141,5 +141,6 @@ export {
141
141
  j as showToast,
142
142
  K as submitForm,
143
143
  $ as trackEvent,
144
- se as withHandler
144
+ S as validateConfig,
145
+ ie as withHandler
145
146
  };