@useago/sdk 1.3.2 → 1.4.1

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.
Files changed (40) hide show
  1. package/README.md +41 -0
  2. package/dist/{AgoClient-Cwx_eYSu.js → AgoClient-BdtuHX7k.js} +150 -85
  3. package/dist/AgoClient-CRAnT4qE.cjs +8 -0
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +99 -1
  6. package/dist/angular.d.ts +99 -1
  7. package/dist/angular.js +16 -7
  8. package/dist/{createConversationSession-DV0Xp_3O.cjs → createConversationSession-B8zfTL78.cjs} +1 -1
  9. package/dist/{createConversationSession-B3h567tt.js → createConversationSession-CWpf4u6I.js} +1 -1
  10. package/dist/{createFormCollector-CyWisAkI.js → createFormCollector-B4n0_diV.js} +1 -1
  11. package/dist/{createFormCollector-BB3Uscuo.cjs → createFormCollector-BB_l0Sia.cjs} +1 -1
  12. package/dist/{createMockClient-DwdxNwEn.js → createMockClient-d-arlmCq.js} +19 -17
  13. package/dist/createMockClient-ucPENDzz.cjs +1 -0
  14. package/dist/devtools.d.cts +93 -1
  15. package/dist/devtools.d.ts +93 -1
  16. package/dist/helpers.d.cts +5 -1
  17. package/dist/helpers.d.ts +5 -1
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +93 -1
  20. package/dist/index.d.ts +93 -1
  21. package/dist/index.js +4 -4
  22. package/dist/react.cjs +3 -3
  23. package/dist/react.d.cts +158 -2
  24. package/dist/react.d.ts +158 -2
  25. package/dist/react.js +469 -391
  26. package/dist/testing.cjs +1 -1
  27. package/dist/testing.d.cts +93 -1
  28. package/dist/testing.d.ts +93 -1
  29. package/dist/testing.js +1 -1
  30. package/dist/vue.cjs +1 -1
  31. package/dist/vue.d.cts +125 -1
  32. package/dist/vue.d.ts +125 -1
  33. package/dist/vue.js +73 -64
  34. package/dist/widget.cjs +1 -1
  35. package/dist/widget.d.cts +93 -1
  36. package/dist/widget.d.ts +93 -1
  37. package/dist/widget.js +3 -3
  38. package/package.json +1 -1
  39. package/dist/AgoClient-CzSmJQxl.cjs +0 -6
  40. package/dist/createMockClient-zHQ0cjUH.cjs +0 -1
package/dist/vue.d.ts CHANGED
@@ -154,6 +154,12 @@ declare class AgoClient {
154
154
  getRegisteredFunctions(): ClientFunctionSchema[];
155
155
  /**
156
156
  * Register a navigation function that lets AGO navigate users to different pages.
157
+ *
158
+ * Also registers a dynamic context entry (`current-page`) that reports the page
159
+ * the user is currently on, by route name, on every message. This is what lets
160
+ * the agent know *where* it is after it navigates (e.g. so auto-continuation
161
+ * can apply page state on the destination), not just how to navigate away.
162
+ *
157
163
  * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
158
164
  * @param routes - Map of route names to paths, with descriptions for the LLM
159
165
  */
@@ -162,6 +168,41 @@ declare class AgoClient {
162
168
  path: string;
163
169
  description: string;
164
170
  }>): void;
171
+ /**
172
+ * Unregister the navigation function and its `current-page` context provider.
173
+ */
174
+ unregisterNavigationFunction(): void;
175
+ /**
176
+ * Register a "page state" function that lets AGO change the current page's
177
+ * state (filters, sort, view mode, selection…) and reads the current state
178
+ * back as dynamic context. This is the state-mutation mirror of
179
+ * {@link registerNavigationFunction}.
180
+ *
181
+ * It does two things:
182
+ * - Synthesizes ONE client function (default name `setPageState`) whose
183
+ * properties are the controls — all optional, so the agent sets only the
184
+ * ones the user asked for.
185
+ * - Registers a dynamic context provider (keyed `page-state:<fnName>`) that
186
+ * reports each control's current `get()` value on every message.
187
+ *
188
+ * ```ts
189
+ * client.registerPageStateFunction([
190
+ * {
191
+ * name: "statusFilter",
192
+ * description: "Filter the list by review status",
193
+ * schema: { type: "string", enum: ["all", "pending", "approved"] },
194
+ * get: () => filters.status,
195
+ * set: (v) => setFilters({ ...filters, status: v }),
196
+ * },
197
+ * ]);
198
+ * ```
199
+ */
200
+ registerPageStateFunction(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
201
+ /**
202
+ * Unregister a page state function and its dynamic context provider.
203
+ * Mirror of unregistering `navigateToPage`.
204
+ */
205
+ unregisterPageStateFunction(functionName?: string): void;
165
206
  /**
166
207
  * Register or update a piece of client-side context.
167
208
  * This context is sent with every message so the AI understands the user's situation.
@@ -394,9 +435,23 @@ export declare interface AgoMessage {
394
435
  followUpReplies?: string[];
395
436
  /** Uploaded files on this message (usually the user's). */
396
437
  attachments?: AgoAttachment[];
438
+ /**
439
+ * True when the backend flagged this message as hidden (e.g. an
440
+ * auto-continuation nudge). Kept in the model's context but not displayed;
441
+ * UI helpers like `useMessages`/`ChatWidget` filter these out.
442
+ */
443
+ hidden?: boolean;
397
444
  createdAt: Date;
398
445
  }
399
446
 
447
+ /**
448
+ * Options for {@link AgoClient.registerPageStateFunction}.
449
+ */
450
+ export declare interface AgoPageStateOptions {
451
+ /** Name of the synthesized client function. Defaults to "setPageState". */
452
+ functionName?: string;
453
+ }
454
+
400
455
  /**
401
456
  * Vue plugin that provides an AgoClient to the entire app via inject/provide.
402
457
  *
@@ -427,6 +482,32 @@ export declare interface AgoSource {
427
482
  url?: string;
428
483
  }
429
484
 
485
+ /**
486
+ * A single editable control on the current page (a filter, a sort, a view mode,
487
+ * a selection…). It becomes one optional property of the synthesized
488
+ * `setPageState` function, and its current value is surfaced back to the agent
489
+ * as dynamic context. This is the state-mutation mirror of a navigation route.
490
+ */
491
+ export declare interface AgoStateControl<T = unknown> {
492
+ /** Machine name of the control, e.g. "statusFilter". Becomes a property of the tool. */
493
+ name: string;
494
+ /** Description for the LLM, e.g. "Filter the list by review status". */
495
+ description: string;
496
+ /** JSON schema for a SINGLE field (like one property of navigateToPage). */
497
+ schema: {
498
+ type: "string" | "number" | "boolean" | "array";
499
+ enum?: (string | number)[];
500
+ items?: {
501
+ type: string;
502
+ enum?: (string | number)[];
503
+ };
504
+ };
505
+ /** Current value → pushed as dynamic context so the agent knows what to change. */
506
+ get?: () => T;
507
+ /** Apply the state change on the page. May be async. */
508
+ set: (value: T) => void | Promise<void>;
509
+ }
510
+
430
511
  /**
431
512
  * Single-object function definition — combines name, schema, and handler.
432
513
  *
@@ -473,7 +554,11 @@ declare interface ClientFunctionSchema {
473
554
  properties: Record<string, {
474
555
  type: string;
475
556
  description?: string;
476
- enum?: string[];
557
+ enum?: (string | number)[];
558
+ items?: {
559
+ type: string;
560
+ enum?: (string | number)[];
561
+ };
477
562
  default?: unknown;
478
563
  }>;
479
564
  required?: string[];
@@ -635,6 +720,13 @@ declare interface SendMessageOptions {
635
720
  agentId?: string;
636
721
  /** File attachments */
637
722
  files?: File[];
723
+ /**
724
+ * Mark this message as hidden. The backend keeps it in the model's context but
725
+ * flags it so the UI never displays it. Used by auto-continuation to nudge the
726
+ * agent after a navigation without polluting the visible transcript.
727
+ * Requires backend support for the `hidden` flag; older backends ignore it.
728
+ */
729
+ hidden?: boolean;
638
730
  }
639
731
 
640
732
  /**
@@ -798,6 +890,26 @@ export declare function useAgoFunction(name: string, options: {
798
890
  */
799
891
  export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[]): void;
800
892
 
893
+ /**
894
+ * Register editable page-state controls with auto-cleanup on unmount.
895
+ * The state-mutation mirror of `useAgoNavigation`: the agent can change the
896
+ * current page's state (filters, sort, view mode…) and read it back.
897
+ *
898
+ * ```ts
899
+ * const status = ref("all");
900
+ * useAgoPageState([
901
+ * {
902
+ * name: "statusFilter",
903
+ * description: "Filter the list by review status",
904
+ * schema: { type: "string", enum: ["all", "pending", "approved"] },
905
+ * get: () => status.value,
906
+ * set: (v) => { status.value = v as string; },
907
+ * },
908
+ * ]);
909
+ * ```
910
+ */
911
+ export declare function useAgoPageState(controls: AgoStateControl[], opts?: AgoPageStateOptions): void;
912
+
801
913
  /**
802
914
  * Read a framework-agnostic AGO store (`createStore`) as a reactive Vue ref.
803
915
  *
@@ -864,6 +976,7 @@ export declare function useChat(options?: UseChatOptions): {
864
976
  url?: string | undefined;
865
977
  isSafeImage: boolean;
866
978
  }[] | undefined;
979
+ hidden?: boolean | undefined;
867
980
  createdAt: Date;
868
981
  }[], AgoMessage[] | {
869
982
  id: string;
@@ -906,6 +1019,7 @@ export declare function useChat(options?: UseChatOptions): {
906
1019
  url?: string | undefined;
907
1020
  isSafeImage: boolean;
908
1021
  }[] | undefined;
1022
+ hidden?: boolean | undefined;
909
1023
  createdAt: Date;
910
1024
  }[]>;
911
1025
  isLoading: Ref<boolean, boolean>;
@@ -958,6 +1072,7 @@ export declare function useChat(options?: UseChatOptions): {
958
1072
  url?: string | undefined;
959
1073
  isSafeImage: boolean;
960
1074
  }[] | undefined;
1075
+ hidden?: boolean | undefined;
961
1076
  createdAt: Date;
962
1077
  }[] | undefined;
963
1078
  }[], Conversation[] | {
@@ -1005,6 +1120,7 @@ export declare function useChat(options?: UseChatOptions): {
1005
1120
  url?: string | undefined;
1006
1121
  isSafeImage: boolean;
1007
1122
  }[] | undefined;
1123
+ hidden?: boolean | undefined;
1008
1124
  createdAt: Date;
1009
1125
  }[] | undefined;
1010
1126
  }[]>;
@@ -1053,6 +1169,7 @@ export declare function useChat(options?: UseChatOptions): {
1053
1169
  url?: string | undefined;
1054
1170
  isSafeImage: boolean;
1055
1171
  }[] | undefined;
1172
+ hidden?: boolean | undefined;
1056
1173
  createdAt: Date;
1057
1174
  }[] | undefined;
1058
1175
  } | null, Conversation | {
@@ -1100,6 +1217,7 @@ export declare function useChat(options?: UseChatOptions): {
1100
1217
  url?: string | undefined;
1101
1218
  isSafeImage: boolean;
1102
1219
  }[] | undefined;
1220
+ hidden?: boolean | undefined;
1103
1221
  createdAt: Date;
1104
1222
  }[] | undefined;
1105
1223
  } | null>;
@@ -1168,6 +1286,7 @@ export declare function useConversation(options?: UseConversationOptions): {
1168
1286
  url?: string | undefined;
1169
1287
  isSafeImage: boolean;
1170
1288
  }[] | undefined;
1289
+ hidden?: boolean | undefined;
1171
1290
  createdAt: Date;
1172
1291
  }[] | undefined;
1173
1292
  }[], Conversation[] | {
@@ -1215,6 +1334,7 @@ export declare function useConversation(options?: UseConversationOptions): {
1215
1334
  url?: string | undefined;
1216
1335
  isSafeImage: boolean;
1217
1336
  }[] | undefined;
1337
+ hidden?: boolean | undefined;
1218
1338
  createdAt: Date;
1219
1339
  }[] | undefined;
1220
1340
  }[]>;
@@ -1263,6 +1383,7 @@ export declare function useConversation(options?: UseConversationOptions): {
1263
1383
  url?: string | undefined;
1264
1384
  isSafeImage: boolean;
1265
1385
  }[] | undefined;
1386
+ hidden?: boolean | undefined;
1266
1387
  createdAt: Date;
1267
1388
  }[] | undefined;
1268
1389
  } | null, Conversation | {
@@ -1310,6 +1431,7 @@ export declare function useConversation(options?: UseConversationOptions): {
1310
1431
  url?: string | undefined;
1311
1432
  isSafeImage: boolean;
1312
1433
  }[] | undefined;
1434
+ hidden?: boolean | undefined;
1313
1435
  createdAt: Date;
1314
1436
  }[] | undefined;
1315
1437
  } | null>;
@@ -1374,6 +1496,7 @@ export declare function useMessages(options?: UseMessagesOptions): {
1374
1496
  url?: string | undefined;
1375
1497
  isSafeImage: boolean;
1376
1498
  }[] | undefined;
1499
+ hidden?: boolean | undefined;
1377
1500
  createdAt: Date;
1378
1501
  }[], AgoMessage[] | {
1379
1502
  id: string;
@@ -1416,6 +1539,7 @@ export declare function useMessages(options?: UseMessagesOptions): {
1416
1539
  url?: string | undefined;
1417
1540
  isSafeImage: boolean;
1418
1541
  }[] | undefined;
1542
+ hidden?: boolean | undefined;
1419
1543
  createdAt: Date;
1420
1544
  }[]>;
1421
1545
  isLoading: Ref<boolean, boolean>;
package/dist/vue.js CHANGED
@@ -1,34 +1,34 @@
1
- import { t as A } from "./AgoClient-Cwx_eYSu.js";
2
- import { computed as y, inject as F, onMounted as g, onScopeDispose as N, onUnmounted as I, ref as c, shallowRef as D } from "vue";
3
- var L = /* @__PURE__ */ Symbol("ago-client"), b = { install(t, n) {
1
+ import { t as A } from "./AgoClient-BdtuHX7k.js";
2
+ import { computed as M, inject as F, onMounted as f, onScopeDispose as S, onUnmounted as h, ref as c, shallowRef as y } from "vue";
3
+ var N = /* @__PURE__ */ Symbol("ago-client"), b = { install(t, n) {
4
4
  const e = new A(n);
5
- t.provide(L, e);
5
+ t.provide(N, e);
6
6
  } };
7
- function m(t) {
7
+ function g(t) {
8
8
  if (t) return new A(t);
9
- const n = F(L);
9
+ const n = F(N);
10
10
  if (!n) throw new Error("useAgo(): no AgoClient found. Either pass config or install AgoPlugin.");
11
11
  return n;
12
12
  }
13
- function S(t = {}) {
14
- const n = t.client ?? m(), e = c([]), s = c(t.conversationId), r = c(!1), a = c(null), u = (o) => {
13
+ function P(t = {}) {
14
+ const n = t.client ?? g(), e = c([]), s = c(t.conversationId), r = c(!1), a = c(null), l = (o) => {
15
15
  s.value || (s.value = o.conversationId);
16
- }, f = (o) => {
16
+ }, m = (o) => {
17
17
  const i = e.value.findIndex((v) => v.id === o.messageId);
18
18
  i >= 0 && (e.value[i] = {
19
19
  ...e.value[i],
20
20
  content: e.value[i].content + o.content
21
21
  });
22
- }, h = (o) => {
22
+ }, C = (o) => {
23
23
  const i = e.value.findIndex((v) => v.id === o.id);
24
24
  i >= 0 ? e.value[i] = o : e.value.push(o), r.value = !1;
25
- }, C = (o) => {
25
+ }, p = (o) => {
26
26
  a.value = new Error(o.error), r.value = !1;
27
27
  };
28
- g(() => {
29
- n.on("message:start", u), n.on("message:chunk", f), n.on("message:complete", h), n.on("message:error", C);
30
- }), I(() => {
31
- n.off("message:start", u), n.off("message:chunk", f), n.off("message:complete", h), n.off("message:error", C);
28
+ f(() => {
29
+ n.on("message:start", l), n.on("message:chunk", m), n.on("message:complete", C), n.on("message:error", p);
30
+ }), h(() => {
31
+ n.off("message:start", l), n.off("message:chunk", m), n.off("message:complete", C), n.off("message:error", p);
32
32
  });
33
33
  async function d(o, i) {
34
34
  r.value = !0, a.value = null;
@@ -39,7 +39,7 @@ function S(t = {}) {
39
39
  role: "user",
40
40
  status: "DONE",
41
41
  createdAt: /* @__PURE__ */ new Date()
42
- }, M = {
42
+ }, L = {
43
43
  id: `temp-assistant-${Date.now()}`,
44
44
  conversationId: s.value || "",
45
45
  content: "",
@@ -47,24 +47,24 @@ function S(t = {}) {
47
47
  status: "IN_PROGRESS",
48
48
  createdAt: /* @__PURE__ */ new Date()
49
49
  };
50
- e.value.push(v, M);
50
+ e.value.push(v, L);
51
51
  try {
52
- const l = await n.sendMessage(o, {
52
+ const u = await n.sendMessage(o, {
53
53
  conversationId: s.value,
54
54
  files: i
55
55
  });
56
- l.conversationId && !s.value && (s.value = l.conversationId), e.value = e.value.filter((E) => !E.id.startsWith("temp-"));
57
- const w = {
56
+ u.conversationId && !s.value && (s.value = u.conversationId), e.value = e.value.filter((E) => !E.id.startsWith("temp-"));
57
+ const I = {
58
58
  ...v,
59
59
  id: v.id.replace("temp-", "user-"),
60
- conversationId: l.conversationId
60
+ conversationId: u.conversationId
61
61
  };
62
- return e.value.some((E) => E.id === l.id) ? e.value.push(w) : e.value.push(w, l), l;
63
- } catch (l) {
64
- return a.value = l instanceof Error ? l : /* @__PURE__ */ new Error("Failed to send"), r.value = !1, e.value = e.value.filter((w) => !w.id.startsWith("temp-")), null;
62
+ return e.value.some((E) => E.id === u.id) ? e.value.push(I) : e.value.push(I, u), u;
63
+ } catch (u) {
64
+ return a.value = u instanceof Error ? u : /* @__PURE__ */ new Error("Failed to send"), r.value = !1, e.value = e.value.filter((I) => !I.id.startsWith("temp-")), null;
65
65
  }
66
66
  }
67
- function p() {
67
+ function w() {
68
68
  e.value = [], s.value = void 0, a.value = null;
69
69
  }
70
70
  return {
@@ -73,54 +73,54 @@ function S(t = {}) {
73
73
  error: a,
74
74
  conversationId: s,
75
75
  sendMessage: d,
76
- clearMessages: p
76
+ clearMessages: w
77
77
  };
78
78
  }
79
- function x(t = {}) {
80
- const n = t.client ?? m(), e = t.autoLoad ?? !0, s = c([]), r = c(null), a = c(!1), u = c(null);
81
- async function f() {
82
- a.value = !0, u.value = null;
79
+ function D(t = {}) {
80
+ const n = t.client ?? g(), e = t.autoLoad ?? !0, s = c([]), r = c(null), a = c(!1), l = c(null);
81
+ async function m() {
82
+ a.value = !0, l.value = null;
83
83
  try {
84
84
  s.value = await n.getConversations();
85
85
  } catch (d) {
86
- u.value = d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations");
86
+ l.value = d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations");
87
87
  } finally {
88
88
  a.value = !1;
89
89
  }
90
90
  }
91
- async function h(d) {
92
- a.value = !0, u.value = null;
91
+ async function C(d) {
92
+ a.value = !0, l.value = null;
93
93
  try {
94
94
  r.value = await n.getConversation(d);
95
- } catch (p) {
96
- u.value = p instanceof Error ? p : /* @__PURE__ */ new Error("Failed to load conversation");
95
+ } catch (w) {
96
+ l.value = w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation");
97
97
  } finally {
98
98
  a.value = !1;
99
99
  }
100
100
  }
101
- function C() {
101
+ function p() {
102
102
  r.value = null;
103
103
  }
104
- return g(() => {
105
- e && f();
104
+ return f(() => {
105
+ e && m();
106
106
  }), {
107
107
  conversations: s,
108
108
  currentConversation: r,
109
109
  isLoading: a,
110
- error: u,
111
- selectConversation: h,
112
- startNewConversation: C,
113
- refreshConversations: f
110
+ error: l,
111
+ selectConversation: C,
112
+ startNewConversation: p,
113
+ refreshConversations: m
114
114
  };
115
115
  }
116
116
  function k(t = {}) {
117
- const n = S({
117
+ const n = P({
118
118
  client: t.client,
119
119
  conversationId: t.conversationId
120
- }), e = x({
120
+ }), e = D({
121
121
  client: t.client,
122
122
  autoLoad: t.autoLoad
123
- }), s = y(() => n.error.value || e.error.value);
123
+ }), s = M(() => n.error.value || e.error.value);
124
124
  return {
125
125
  messages: n.messages,
126
126
  isLoading: n.isLoading,
@@ -137,47 +137,56 @@ function k(t = {}) {
137
137
  };
138
138
  }
139
139
  function O(t, n) {
140
- const e = m();
141
- g(() => {
140
+ const e = g();
141
+ f(() => {
142
142
  e.registerFunction(t, n.handler, {
143
143
  description: n.description,
144
144
  parameters: n.parameters
145
145
  });
146
- }), I(() => {
146
+ }), h(() => {
147
147
  e.unregisterFunction(t);
148
148
  });
149
149
  }
150
150
  function _(t, n) {
151
- const e = m();
152
- g(() => {
151
+ const e = g();
152
+ f(() => {
153
153
  e.registerNavigationFunction(t, n);
154
- }), I(() => {
155
- e.unregisterFunction("navigateToPage");
154
+ }), h(() => {
155
+ e.unregisterNavigationFunction();
156
156
  });
157
157
  }
158
158
  function G(t, n) {
159
- const e = m();
160
- g(() => {
159
+ const e = g(), s = n?.functionName ?? "setPageState";
160
+ f(() => {
161
+ e.registerPageStateFunction(t, { functionName: s });
162
+ }), h(() => {
163
+ e.unregisterPageStateFunction(s);
164
+ });
165
+ }
166
+ function U(t, n) {
167
+ const e = g();
168
+ f(() => {
161
169
  e.on(t, n);
162
- }), I(() => {
170
+ }), h(() => {
163
171
  e.off(t, n);
164
172
  });
165
173
  }
166
- function T(t) {
167
- const n = D(t.get());
168
- return N(t.subscribe((e) => {
174
+ function W(t) {
175
+ const n = y(t.get());
176
+ return S(t.subscribe((e) => {
169
177
  n.value = e;
170
178
  })), n;
171
179
  }
172
180
  export {
173
- L as AGO_CLIENT_KEY,
181
+ N as AGO_CLIENT_KEY,
174
182
  b as AgoPlugin,
175
- m as useAgo,
176
- G as useAgoEvents,
183
+ g as useAgo,
184
+ U as useAgoEvents,
177
185
  O as useAgoFunction,
178
186
  _ as useAgoNavigation,
179
- T as useAgoStore,
187
+ G as useAgoPageState,
188
+ W as useAgoStore,
180
189
  k as useChat,
181
- x as useConversation,
182
- S as useMessages
190
+ D as useConversation,
191
+ P as useMessages
183
192
  };
package/dist/widget.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-CzSmJQxl.cjs"),ct=require("./createFormCollector-BB3Uscuo.cjs"),Gt=require("./createConversationSession-DV0Xp_3O.cjs");var jt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Re=`var(--ago-font, ${jt})`,pt={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},Ae="var(--ago-brand-color, #03182f)",_e="var(--ago-brand-text-color, #fff)",Vt="var(--ago-header-background, var(--ago-brand-color, #03182f))",ft="var(--ago-header-text-color, #e8f0fe)",ee="var(--ago-panel-background, #fff)",xt="var(--ago-messages-background, #fbfbfb)",J="var(--ago-text-color, #30373e)",bt="var(--ago-muted-text-color, #6b6d6f)",L="var(--ago-border-color, #dee3e8)",De="var(--ago-accent-color, #1b5fc4)",ut="var(--ago-agent-bubble-background, #f1f3f5)",qt="var(--ago-radius, 16px)",ze="var(--ago-message-radius, 16px)",Kt="var(--ago-message-radius, 20px)";function Xt(n,o){if(o)for(const i of Object.keys(pt)){const r=o[i];r!=null&&n.style.setProperty(pt[i],r)}}function v(n,o){Object.assign(n.style,o)}function h(n={}){const o=document.createElement("div");return v(o,n),o}var mt="ago-chat-widget-keyframes";function Qt(){if(typeof document>"u"||document.getElementById(mt))return;const n=document.createElement("style");n.id=mt,n.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(n)}function Yt(n){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${L}`,backgroundColor:ee}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=n.placeholder,a.setAttribute("aria-label",n.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",fontSize:"16px",fontFamily:Re,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),A()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:Ae,color:_e,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const A=()=>{const s=a.value.trim()!==""||o.length>0,c=f||!s;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,_=null;n.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),_=document.createElement("button"),_.type="button",_.setAttribute("aria-label","Attach file"),_.textContent="📎",v(_,{padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",backgroundColor:ee,cursor:"pointer",fontSize:"14px"}),_.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Y()}));function Y(){r.replaceChildren(),o.forEach((s,c)=>{const y=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${L}`,borderRadius:"8px",fontSize:"12px"}),T=document.createElement("span");T.textContent=s.name;const k=document.createElement("button");k.type="button",k.setAttribute("aria-label",`Remove ${s.name}`),k.textContent="×",v(k,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),k.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Y()}),y.append(T,k),r.appendChild(y)}),A()}const D=()=>{const s=a.value,c=o;return a.value="",C(),o=[],Y(),{content:s,files:c}},g=()=>{const{content:s,files:c}=D();(s.trim()||c.length>0)&&n.onSend(s.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",s=>{s.preventDefault(),g()}),a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),g())}),_&&b.appendChild(_),b.append(a,p),R&&i.appendChild(R),i.append(r,b),A(),{inputRow:i,getValueAndClear:D,setDisabled:s=>{a.disabled=s,f=s,A()},focus:()=>a.focus()}}var Zt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(n){return n.replace(/[&<>"']/g,o=>Zt[o])}function gt(n){const o=n.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var vt='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Se="";function te(n){const o=[],i=b=>(o.push(b),`${Se}${o.length-1}${Se}`);let r=n;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${vt}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=gt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=gt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${te(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Se}(\\d+)${Se}`,"g"),(b,a)=>o[Number(a)]),r}function B(n,o,i){const r=document.createElement(n);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var yt=/^ {0,3}([-*_])( *\1){2,} *$/,wt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,Ct=/^ {0,3}(```+|~~~+)/,ke=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Jt=["20px","18px","16px","15px","14px","13px"],Fe=n=>n.match(/^\s*/)?.[0].length??0;function en(n){return n.trim()===""||yt.test(n)||wt.test(n)||Ct.test(n)||ke.test(n)||le.test(n)}function Et(n){const o=n[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=B(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<n.length;){const C=n[a].match(le),m=[];for(a++;a<n.length&&Fe(n[a])>i;)m.push(n[a]),a++;const x=B("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${te(p[2])}`):x.innerHTML=te(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(Et(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function tn(n){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=B("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=B("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(n[0]))a.appendChild(B("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},te(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of n.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(B("td",{border:"1px solid #dee3e8",padding:"6px 10px"},te(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var nn=n=>!!n&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n);function Ie(n){const o=document.createDocumentFragment(),i=n.replace(/\r\n?/g,`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const se=require("./AgoClient-CRAnT4qE.cjs"),ct=require("./createFormCollector-BB_l0Sia.cjs"),Gt=require("./createConversationSession-B8zfTL78.cjs");var jt='"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',Re=`var(--ago-font, ${jt})`,pt={font:"--ago-font",radius:"--ago-radius",messageRadius:"--ago-message-radius",brand:"--ago-brand-color",brandText:"--ago-brand-text-color",headerBg:"--ago-header-background",headerText:"--ago-header-text-color",panelBg:"--ago-panel-background",messagesBg:"--ago-messages-background",text:"--ago-text-color",mutedText:"--ago-muted-text-color",border:"--ago-border-color",accent:"--ago-accent-color",agentBubbleBg:"--ago-agent-bubble-background"},Ae="var(--ago-brand-color, #03182f)",_e="var(--ago-brand-text-color, #fff)",Vt="var(--ago-header-background, var(--ago-brand-color, #03182f))",ft="var(--ago-header-text-color, #e8f0fe)",ee="var(--ago-panel-background, #fff)",xt="var(--ago-messages-background, #fbfbfb)",J="var(--ago-text-color, #30373e)",bt="var(--ago-muted-text-color, #6b6d6f)",L="var(--ago-border-color, #dee3e8)",De="var(--ago-accent-color, #1b5fc4)",ut="var(--ago-agent-bubble-background, #f1f3f5)",qt="var(--ago-radius, 16px)",ze="var(--ago-message-radius, 16px)",Kt="var(--ago-message-radius, 20px)";function Xt(n,o){if(o)for(const i of Object.keys(pt)){const r=o[i];r!=null&&n.style.setProperty(pt[i],r)}}function v(n,o){Object.assign(n.style,o)}function h(n={}){const o=document.createElement("div");return v(o,n),o}var mt="ago-chat-widget-keyframes";function Qt(){if(typeof document>"u"||document.getElementById(mt))return;const n=document.createElement("style");n.id=mt,n.textContent="@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }",document.head.appendChild(n)}function Yt(n){let o=[];const i=document.createElement("form");v(i,{display:"flex",flexDirection:"column",gap:"8px",padding:"12px",borderTop:`1px solid ${L}`,backgroundColor:ee}),i.className="ago-chat-input";const r=h({display:"flex",flexWrap:"wrap",gap:"6px"}),b=h({display:"flex",gap:"8px",alignItems:"flex-end"}),a=document.createElement("textarea");a.placeholder=n.placeholder,a.setAttribute("aria-label",n.placeholder),a.rows=1,v(a,{flex:"1",resize:"none",boxSizing:"border-box",padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",fontSize:"16px",fontFamily:Re,lineHeight:"1.4",maxHeight:"110px",overflowY:"hidden"});const C=()=>{a.style.height="auto";const c=Math.min(a.scrollHeight+2,110);a.style.height=`${c}px`,a.style.overflowY=a.scrollHeight+2>110?"auto":"hidden"};a.addEventListener("input",()=>{C(),A()});const m='<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',x='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',p=document.createElement("button");p.type="submit",p.setAttribute("aria-label","Send"),p.innerHTML=m,v(p,{flexShrink:"0",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:Ae,color:_e,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"});let f=!1;const A=()=>{const s=a.value.trim()!==""||o.length>0,c=f||!s;p.disabled=c,p.innerHTML=f?x:m,p.style.opacity=c&&!f?"0.5":"1",p.style.cursor=c?"default":"pointer"};let R=null,_=null;n.allowFiles&&(R=document.createElement("input"),R.type="file",R.multiple=!0,v(R,{display:"none"}),_=document.createElement("button"),_.type="button",_.setAttribute("aria-label","Attach file"),_.textContent="📎",v(_,{padding:"10px 12px",border:`1px solid ${L}`,borderRadius:"12px",backgroundColor:ee,cursor:"pointer",fontSize:"14px"}),_.addEventListener("click",()=>R?.click()),R.addEventListener("change",()=>{o=[...o,...Array.from(R?.files??[])],Y()}));function Y(){r.replaceChildren(),o.forEach((s,c)=>{const y=h({display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",backgroundColor:"#f0f4ff",border:`1px solid ${L}`,borderRadius:"8px",fontSize:"12px"}),T=document.createElement("span");T.textContent=s.name;const k=document.createElement("button");k.type="button",k.setAttribute("aria-label",`Remove ${s.name}`),k.textContent="×",v(k,{border:"none",background:"transparent",cursor:"pointer",fontSize:"14px",lineHeight:"1"}),k.addEventListener("click",()=>{o=o.filter((j,V)=>V!==c),Y()}),y.append(T,k),r.appendChild(y)}),A()}const D=()=>{const s=a.value,c=o;return a.value="",C(),o=[],Y(),{content:s,files:c}},g=()=>{const{content:s,files:c}=D();(s.trim()||c.length>0)&&n.onSend(s.trim(),c.length>0?c:void 0)};return i.addEventListener("submit",s=>{s.preventDefault(),g()}),a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),g())}),_&&b.appendChild(_),b.append(a,p),R&&i.appendChild(R),i.append(r,b),A(),{inputRow:i,getValueAndClear:D,setDisabled:s=>{a.disabled=s,f=s,A()},focus:()=>a.focus()}}var Zt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ae(n){return n.replace(/[&<>"']/g,o=>Zt[o])}function gt(n){const o=n.trim();return/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o)||!/^[a-z][a-z0-9+.-]*:/i.test(o)?o:null}var vt='"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace',Se="";function te(n){const o=[],i=b=>(o.push(b),`${Se}${o.length-1}${Se}`);let r=n;return r=r.replace(/`([^`]+)`/g,(b,a)=>i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${vt}">${ae(a)}</code>`)),r=r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=gt(C);return m?i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`):b}),r=r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(b,a,C)=>{const m=gt(C);return m?i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${te(a)}</a>`):b}),r=ae(r),r=r.replace(/\*\*([^*]+?)\*\*/g,"<strong>$1</strong>").replace(/__([^_]+?)__/g,"<strong>$1</strong>").replace(/~~([^~]+?)~~/g,"<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g,"$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g,"$1<em>$2</em>"),r=r.replace(new RegExp(`${Se}(\\d+)${Se}`,"g"),(b,a)=>o[Number(a)]),r}function B(n,o,i){const r=document.createElement(n);return Object.assign(r.style,o),i!==void 0&&(r.innerHTML=i),r}var yt=/^ {0,3}([-*_])( *\1){2,} *$/,wt=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,Ct=/^ {0,3}(```+|~~~+)/,ke=/^ {0,3}>\s?/,le=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Jt=["20px","18px","16px","15px","14px","13px"],Fe=n=>n.match(/^\s*/)?.[0].length??0;function en(n){return n.trim()===""||yt.test(n)||wt.test(n)||Ct.test(n)||ke.test(n)||le.test(n)}function Et(n){const o=n[0].match(le),i=o[1].length,r=/\d/.test(o[2]),b=B(r?"ol":"ul",{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:r?"decimal":"disc",listStylePosition:"outside"});let a=0;for(;a<n.length;){const C=n[a].match(le),m=[];for(a++;a<n.length&&Fe(n[a])>i;)m.push(n[a]),a++;const x=B("li",{display:"list-item",margin:"2px 0",lineHeight:"1.6"}),p=C[3].match(/^\[([ xX])\]\s+(.*)$/);p?(x.style.listStyleType="none",x.style.marginLeft="-20px",x.innerHTML=`<span style="margin-right:6px">${p[1].toLowerCase()==="x"?"☑":"☐"}</span>${te(p[2])}`):x.innerHTML=te(C[3]),m.filter(f=>le.test(f)).length>0&&x.appendChild(Et(m.filter(f=>f.trim()!==""))),b.appendChild(x)}return b}function tn(n){const o=m=>m.replace(/^\s*\|?/,"").replace(/\|?\s*$/,"").split("|").map(x=>x.trim()),i=B("div",{overflowX:"auto",margin:"0 0 8px 0"}),r=B("table",{borderCollapse:"collapse",width:"100%",fontSize:"13px"}),b=document.createElement("thead"),a=document.createElement("tr");for(const m of o(n[0]))a.appendChild(B("th",{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:"600"},te(m)));b.appendChild(a),r.appendChild(b);const C=document.createElement("tbody");for(const m of n.slice(2)){const x=document.createElement("tr");for(const p of o(m))x.appendChild(B("td",{border:"1px solid #dee3e8",padding:"6px 10px"},te(p)));C.appendChild(x)}return r.appendChild(C),i.appendChild(r),i}var nn=n=>!!n&&/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n);function Ie(n){const o=document.createDocumentFragment(),i=n.replace(/\r\n?/g,`
2
2
  `).split(`
3
3
  `);let r=0;for(;r<i.length;){const a=i[r];if(a.trim()===""){r++;continue}const C=a.match(Ct);if(C){const p=C[1][0],f=[];for(r++;r<i.length&&!new RegExp(`^ {0,3}${p==="`"?"`{3,}":"~{3,}"}\\s*$`).test(i[r]);)f.push(i[r]),r++;r++;const A=B("pre",{margin:"0 0 8px 0"});A.appendChild(B("code",{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:vt,whiteSpace:"pre"},ae(f.join(`
4
4
  `)))),o.appendChild(A);continue}if(yt.test(a)){o.appendChild(B("hr",{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"})),r++;continue}const m=a.match(wt);if(m){const p=m[1].length;o.appendChild(B(`h${p}`,{margin:"16px 0 8px 0",fontSize:Jt[p-1],fontWeight:"600",lineHeight:"1.3"},te(m[2]))),r++;continue}if(ke.test(a)){const p=[];for(;r<i.length&&ke.test(i[r]);)p.push(i[r].replace(ke,"")),r++;const f=B("blockquote",{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"});f.appendChild(Ie(p.join(`