@useago/sdk 1.5.2 → 1.5.4

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 (45) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +10 -0
  3. package/dist/AgoClient-BW0YZsis.js +1681 -0
  4. package/dist/AgoClient-Ba3ICq4K.cjs +8 -0
  5. package/dist/angular.cjs +1 -1
  6. package/dist/angular.d.cts +352 -0
  7. package/dist/angular.d.ts +352 -0
  8. package/dist/angular.js +1 -1
  9. package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-BjsgjL-v.js} +3 -3
  10. package/dist/createConversationSession-okoz3teC.cjs +1 -0
  11. package/dist/createFormCollector-BWIh1pMl.cjs +1 -0
  12. package/dist/createFormCollector-Bay2UpRv.js +279 -0
  13. package/dist/createMockClient-DcuNlufr.js +97 -0
  14. package/dist/createMockClient-Dw-cyISN.cjs +1 -0
  15. package/dist/devtools.d.cts +352 -0
  16. package/dist/devtools.d.ts +352 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +564 -0
  19. package/dist/index.d.ts +564 -0
  20. package/dist/index.js +97 -90
  21. package/dist/react.cjs +3 -3
  22. package/dist/react.d.cts +430 -0
  23. package/dist/react.d.ts +430 -0
  24. package/dist/react.js +600 -443
  25. package/dist/testing.cjs +1 -1
  26. package/dist/testing.d.cts +352 -0
  27. package/dist/testing.d.ts +352 -0
  28. package/dist/testing.js +1 -1
  29. package/dist/vue.cjs +1 -1
  30. package/dist/vue.d.cts +373 -0
  31. package/dist/vue.d.ts +373 -0
  32. package/dist/vue.js +133 -110
  33. package/dist/widget.cjs +1 -1
  34. package/dist/widget.d.cts +349 -0
  35. package/dist/widget.d.ts +349 -0
  36. package/dist/widget.js +7 -7
  37. package/llms-full.txt +29 -0
  38. package/package.json +1 -1
  39. package/dist/AgoClient-5VGybmvz.cjs +0 -8
  40. package/dist/AgoClient-DXrH2AMi.js +0 -964
  41. package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
  42. package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
  43. package/dist/createFormCollector-DYh90kiG.js +0 -305
  44. package/dist/createMockClient-C-wrjb2C.cjs +0 -1
  45. package/dist/createMockClient-we-XoPom.js +0 -79
@@ -1,3 +1,19 @@
1
+ declare interface ActivityEntry {
2
+ ts: number;
3
+ actor: "user" | "agent";
4
+ name: string;
5
+ summary: string;
6
+ data?: Record<string, unknown>;
7
+ }
8
+
9
+ declare interface ActivityInput {
10
+ actor?: "user" | "agent";
11
+ name: string;
12
+ summary: string;
13
+ data?: Record<string, unknown>;
14
+ ts?: number;
15
+ }
16
+
1
17
  /**
2
18
  * Agent information
3
19
  */
@@ -36,6 +52,8 @@ declare class AgoClient {
36
52
  private functionRegistry;
37
53
  private contextRegistry;
38
54
  private eventEmitter;
55
+ private activityLedger;
56
+ private lastSentPageState;
39
57
  private config;
40
58
  /** Conversations already warned about an empty reply (one warning each). */
41
59
  private warnedEmptyConversations;
@@ -49,6 +67,12 @@ declare class AgoClient {
49
67
  private pendingApprovals;
50
68
  /** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
51
69
  private resumeGate;
70
+ /**
71
+ * Proactive-mode controller, set when the client was created with
72
+ * `proactive` options or when `createAgoProactive(client, opts)` was called.
73
+ * `null` otherwise.
74
+ */
75
+ proactive: ProactiveController | null;
52
76
  constructor(config: AgoConfig);
53
77
  /**
54
78
  * Send a message and receive a streaming response
@@ -219,6 +243,14 @@ declare class AgoClient {
219
243
  * Get all registered function schemas
220
244
  */
221
245
  getRegisteredFunctions(): ClientFunctionSchema[];
246
+ /**
247
+ * Execute a registered client function locally, through the same
248
+ * FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
249
+ * calls. Used by proactive nudge actions, where the user's explicit click on
250
+ * the action button constitutes the approval — nothing is submitted to the
251
+ * backend (there is no tool call to answer).
252
+ */
253
+ executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
222
254
  /**
223
255
  * Register a navigation function that lets AGO navigate users to different pages.
224
256
  *
@@ -320,6 +352,9 @@ declare class AgoClient {
320
352
  */
321
353
  notifyContextChanged(): void;
322
354
  /* Excluded from this release type: emitFormEvent */
355
+ /* Excluded from this release type: emitProactiveEvent */
356
+ /* Excluded from this release type: getHttp */
357
+ /* Excluded from this release type: getConfiguredAgent */
323
358
  /**
324
359
  * Enable automatic capture of the current browser page (URL + title).
325
360
  * Injected as a dynamic context entry named `browser-page`.
@@ -329,6 +364,19 @@ declare class AgoClient {
329
364
  * Get the current context snapshot.
330
365
  */
331
366
  getContextSnapshot(): ContextSnapshot | null;
367
+ private buildSendContext;
368
+ /**
369
+ * Record something the user just did so the agent is aware of it on the next
370
+ * message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
371
+ * (no raw payloads, secrets, or PII).
372
+ */
373
+ recordActivity(entry: ActivityInput): void;
374
+ /** Recent user + agent actions, oldest first (a copy). */
375
+ getRecentActivity(): ActivityEntry[];
376
+ clearActivity(): void;
377
+ private addActivity;
378
+ private recordAgentAction;
379
+ private registerActivityContext;
332
380
  /**
333
381
  * Subscribe to an event
334
382
  */
@@ -364,6 +412,7 @@ declare class AgoClient {
364
412
  * Clean up resources
365
413
  */
366
414
  destroy(): void;
415
+ /* Excluded from this release type: reviveAfterDestroy */
367
416
  }
368
417
 
369
418
  /**
@@ -480,6 +529,27 @@ declare interface AgoClientEvents {
480
529
  "connection:status": {
481
530
  connected: boolean;
482
531
  };
532
+ /**
533
+ * A proactive nudge passed every governor gate and is ready to display.
534
+ * `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
535
+ * `client.proactive.shown(nudge)` when they render it (impression tracking
536
+ * + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
537
+ */
538
+ "nudge:ready": ProactiveNudgeInstance;
539
+ /** A nudge was displayed to the user (fires once per nudge). */
540
+ "nudge:shown": {
541
+ nudge: ProactiveNudgeInstance;
542
+ };
543
+ /** The user dismissed the nudge (its trigger is suppressed, see governor). */
544
+ "nudge:dismissed": {
545
+ nudge: ProactiveNudgeInstance;
546
+ };
547
+ /** The user accepted the nudge (its action ran / the chat is being seeded). */
548
+ "nudge:accepted": {
549
+ nudge: ProactiveNudgeInstance;
550
+ };
551
+ /** A user- or agent-action was recorded into the activity ledger. */
552
+ "activity:recorded": ActivityEntry;
483
553
  }
484
554
 
485
555
  /**
@@ -541,6 +611,24 @@ declare interface AgoConfig {
541
611
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
542
612
  */
543
613
  maxFunctionResultBytes?: number;
614
+ /**
615
+ * Max number of recent actions kept in the in-memory activity ledger that
616
+ * rides along as the `activity:recent` context entry. Older entries drop
617
+ * first. Default `10`. Larger values give the agent more history at the cost
618
+ * of tokens on every message. Each entry's `data` is also size-clamped (long
619
+ * strings truncated, large arrays capped) so one event can't bloat the context.
620
+ */
621
+ maxActivityEntries?: number;
622
+ /**
623
+ * Enable the proactive mode: declarative triggers evaluated client-side
624
+ * against friction signals (dwell/idle time, rage clicks, route bounces…)
625
+ * that can surface a nudge before the user opens the chat. Equivalent to
626
+ * calling `createAgoProactive(client, proactive)` — the resulting controller
627
+ * is available as `client.proactive`. Requires the tenant-level kill-switch
628
+ * (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
629
+ * default otherwise.
630
+ */
631
+ proactive?: ProactiveOptions;
544
632
  }
545
633
 
546
634
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -878,6 +966,43 @@ declare interface FormSchema {
878
966
  required?: string[];
879
967
  }
880
968
 
969
+ /**
970
+ * HTTP client with authentication headers
971
+ */
972
+ declare class HttpClient {
973
+ private baseUrl;
974
+ private headers;
975
+ constructor(config: AgoConfig);
976
+ /**
977
+ * Update configuration (e.g., JWT token)
978
+ */
979
+ updateConfig(config: Partial<AgoConfig>): void;
980
+ /**
981
+ * Make a GET request
982
+ */
983
+ get<T>(path: string): Promise<T>;
984
+ /**
985
+ * Make a POST request with JSON body.
986
+ *
987
+ * `keepalive: true` lets the request survive a page unload (used by the
988
+ * proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
989
+ * headers, so it's a keepalive fetch instead).
990
+ */
991
+ post<T>(path: string, body?: unknown, options?: {
992
+ keepalive?: boolean;
993
+ }): Promise<T>;
994
+ /**
995
+ * Make a POST request and return the raw Response (for streaming)
996
+ */
997
+ postStream(path: string, body?: unknown): Promise<Response>;
998
+ /**
999
+ * Make a POST request with FormData (for file uploads)
1000
+ */
1001
+ postFormData(path: string, formData: FormData): Promise<Response>;
1002
+ private request;
1003
+ private handleErrorResponse;
1004
+ }
1005
+
881
1006
  export declare function initDevPanel(options: DevPanelOptions): void;
882
1007
 
883
1008
  declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
@@ -888,6 +1013,182 @@ declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCEL
888
1013
  */
889
1014
  | "WAITING_CLIENT";
890
1015
 
1016
+ /**
1017
+ * Optional action attached to a nudge. Accepting a `functionName` action
1018
+ * executes the registered client function (same `FunctionRegistry` path as
1019
+ * agent-invoked calls); `setPageState` applies values through the registered
1020
+ * page-state controls.
1021
+ */
1022
+ declare type NudgeAction = {
1023
+ label: string;
1024
+ functionName: string;
1025
+ arguments?: Record<string, unknown>;
1026
+ } | {
1027
+ label: string;
1028
+ setPageState: Record<string, unknown>;
1029
+ };
1030
+
1031
+ /**
1032
+ * Controller returned by {@link createAgoProactive} (also available as
1033
+ * `client.proactive`).
1034
+ */
1035
+ declare interface ProactiveController {
1036
+ /** Persistently opt this browser out of proactive nudges. */
1037
+ optOut(): void;
1038
+ /** Undo {@link optOut}. */
1039
+ optIn(): void;
1040
+ isOptedOut(): boolean;
1041
+ /**
1042
+ * Tell the governor the user is already engaged (e.g. the chat widget is
1043
+ * open) — nudges are suppressed while `true`. Call from the UI layer.
1044
+ */
1045
+ setEngaged(engaged: boolean): void;
1046
+ /** App-pushed field error counter (field NAME only — never values). */
1047
+ signalFieldError(fieldName: string): void;
1048
+ /** Current aggregated friction snapshot. */
1049
+ getSignalsSnapshot(): SignalsSnapshot;
1050
+ /** The nudge currently occupying the single-nudge slot, if any. */
1051
+ getActiveNudge(): ProactiveNudgeInstance | null;
1052
+ /**
1053
+ * Mark the nudge as displayed. Idempotent per nudge; counts it against the
1054
+ * frequency caps, tracks the impression, and emits `nudge:shown`.
1055
+ */
1056
+ shown(nudge: ProactiveNudgeInstance): void;
1057
+ /**
1058
+ * Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
1059
+ * and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
1060
+ * hidden kickoff message so the agent starts the turn with full context.
1061
+ */
1062
+ accept(nudge: ProactiveNudgeInstance): Promise<void>;
1063
+ /** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
1064
+ dismiss(nudge: ProactiveNudgeInstance): void;
1065
+ /** Report a downstream conversion attributable to the nudge (analytics only). */
1066
+ markConverted(nudge: ProactiveNudgeInstance): void;
1067
+ /** Detach everything: listeners, timers, context provider, event flush. */
1068
+ destroy(): void;
1069
+ }
1070
+
1071
+ /** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
1072
+ declare interface ProactiveNudgeInstance {
1073
+ /** Client-generated uuid for this nudge instance (`client_nudge_id`). */
1074
+ id: string;
1075
+ triggerId: string;
1076
+ /** `static` = configured message; `agent` = backend LLM evaluation. */
1077
+ source: "static" | "agent";
1078
+ message: string;
1079
+ action?: NudgeAction;
1080
+ goal?: string;
1081
+ /** See {@link ProactiveTrigger.kickoff}. */
1082
+ kickoff?: string;
1083
+ createdAt: Date;
1084
+ /** Server-side nudge id (agent nudges only). */
1085
+ serverNudgeId?: string;
1086
+ }
1087
+
1088
+ /** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
1089
+ declare interface ProactiveOptions {
1090
+ triggers: ProactiveTrigger[];
1091
+ /**
1092
+ * Global caps on nudges actually shown. `perSession` is in-memory (page
1093
+ * lifetime); `perDay` is persisted in localStorage with a date rollover —
1094
+ * best-effort by design (private browsing resets it); the costly LLM path is
1095
+ * additionally capped server-side.
1096
+ */
1097
+ frequencyCap?: {
1098
+ perSession?: number;
1099
+ perDay?: number;
1100
+ };
1101
+ /** Evaluation tick, ms. Default 1000. Zero network per tick. */
1102
+ tickMs?: number;
1103
+ /** Storage backend for persisted governance state. Default `localStorage`. */
1104
+ storage?: StorageLike;
1105
+ /** Storage key for persisted governance state. Default `"ago_proactive"`. */
1106
+ storageKey?: string;
1107
+ /** Tuning of the signal detectors (rage-click window, throttles…). */
1108
+ signals?: SignalCollectorTuning;
1109
+ /**
1110
+ * Local demos and tests ONLY: bypass the remote kill-switch. When set, the
1111
+ * `GET /config` fetch is skipped and the kill-switch takes this value.
1112
+ * Leave unset in production — the tenant admin controls the feature, and
1113
+ * the evaluate endpoint stays gated server-side regardless.
1114
+ */
1115
+ enabledOverride?: boolean;
1116
+ }
1117
+
1118
+ /** A declarative proactive trigger. */
1119
+ declare interface ProactiveTrigger {
1120
+ /** Stable id, used for cooldowns, dismissal memory, and analytics. */
1121
+ id: string;
1122
+ /** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
1123
+ when: ProactiveTriggerWhen;
1124
+ /**
1125
+ * Min time between two firings of this trigger (persisted across reloads).
1126
+ * A firing is the moment the trigger passes the gates — including an agent
1127
+ * evaluation that decides NOT to intervene, so a persistent condition can't
1128
+ * hammer the evaluate endpoint. Default 60 000.
1129
+ */
1130
+ cooldownMs?: number;
1131
+ /**
1132
+ * `'agent'` asks the backend's fast-LLM second filter whether (and how) to
1133
+ * intervene; a `static` object shows the given message with no network call.
1134
+ */
1135
+ intervene: "agent" | {
1136
+ type: "static";
1137
+ message: string;
1138
+ action?: NudgeAction;
1139
+ };
1140
+ /**
1141
+ * What the agent should help with. Sent to the evaluate endpoint, and used to
1142
+ * pre-seed the chat turn when the user accepts the nudge.
1143
+ */
1144
+ goal?: string;
1145
+ /**
1146
+ * User-voice line used to OPEN the conversation when the user accepts this
1147
+ * nudge and no conversation exists yet — a hidden kickoff cannot start one
1148
+ * (the backend rejects it). Sent as a visible user message, so write it in
1149
+ * the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
1150
+ * already open, the SDK sends a hidden meta kickoff instead and this field
1151
+ * is unused. Without it, accepting with no open conversation skips the chat
1152
+ * pre-seed (the nudge action still runs).
1153
+ */
1154
+ kickoff?: string;
1155
+ /**
1156
+ * How long a dismissal of this trigger's nudge suppresses it (persisted).
1157
+ * Default 24h.
1158
+ */
1159
+ resurfaceAfterMs?: number;
1160
+ }
1161
+
1162
+ /**
1163
+ * Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
1164
+ * must pass against the current {@link SignalsSnapshot}. Numeric fields are
1165
+ * `>=` thresholds.
1166
+ */
1167
+ declare interface ProactiveTriggerWhen {
1168
+ /**
1169
+ * Route pattern the current pathname must match. Supports the SDK's route
1170
+ * styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
1171
+ * wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
1172
+ * remaining segments (`/dossier/*`).
1173
+ */
1174
+ route?: string;
1175
+ /** Min time since the last user activity, ms. */
1176
+ idleMs?: number;
1177
+ /** Min time spent on the current route, ms. */
1178
+ dwellMs?: number;
1179
+ /**
1180
+ * Partial deep match against the registered page state (funnel step,
1181
+ * filters…). Every key present here must deep-match the live value.
1182
+ */
1183
+ pageState?: Partial<Record<string, unknown>>;
1184
+ /** Min rage-click bursts on the current route. */
1185
+ rageClicks?: number;
1186
+ /** Min A→B→A→B route oscillations this session. */
1187
+ routeBounces?: number;
1188
+ /** Per-field minimum error counts (field NAME → min count). */
1189
+ fieldErrors?: Record<string, number>;
1190
+ }
1191
+
891
1192
  /**
892
1193
  * Hook run before a paused turn is resumed, so the app controls WHEN the
893
1194
  * continuation fires (e.g. wait for the destination page to mount after a
@@ -920,6 +1221,54 @@ declare interface SendMessageOptions {
920
1221
  clientFunctionsMode?: ClientFunctionsMode;
921
1222
  }
922
1223
 
1224
+ /** Tuning knobs for the collector's detectors. All optional. */
1225
+ declare interface SignalCollectorTuning {
1226
+ /** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
1227
+ activityThrottleMs?: number;
1228
+ /** Rage click: clicks needed to count a burst. Default 3. */
1229
+ rageClickCount?: number;
1230
+ /** Rage click: max time between first and last click of a burst, ms. Default 1000. */
1231
+ rageClickWindowMs?: number;
1232
+ /** Rage click: max radius between clicks of a burst, px. Default 24. */
1233
+ rageClickRadiusPx?: number;
1234
+ /** Max routes kept in the recent-route sequence. Default 10. */
1235
+ maxRecentRoutes?: number;
1236
+ /** Max typed signals kept in the ring buffer. Default 50. */
1237
+ maxSignals?: number;
1238
+ }
1239
+
1240
+ /**
1241
+ * Aggregated view of the current friction state. Registered as a dynamic
1242
+ * context provider (key `friction_signals`) so it rides along as
1243
+ * `client_context` on every message, and sent as `signals` to the proactive
1244
+ * evaluate endpoint.
1245
+ */
1246
+ declare interface SignalsSnapshot {
1247
+ /** Current pathname. */
1248
+ route: string;
1249
+ /** Time spent on the current route, ms. */
1250
+ dwellMs: number;
1251
+ /** Time since the last user activity (pointer/key/scroll/touch), ms. */
1252
+ idleMs: number;
1253
+ /** Rage-click bursts detected on the current route. */
1254
+ rageClicks: number;
1255
+ /**
1256
+ * A→B→A→B route oscillations detected in the recent route sequence. Rolling
1257
+ * session counter (cross-route by nature); trigger cooldowns and dismissal
1258
+ * memory keep it from re-firing forever.
1259
+ */
1260
+ routeBounces: number;
1261
+ /** App-pushed field error counters (field NAME → count), current route only. */
1262
+ fieldErrors: Record<string, number>;
1263
+ /** Most recent pathnames, oldest first (bounded). */
1264
+ recentRoutes: string[];
1265
+ /**
1266
+ * Merged `AgoStateControl.get()` snapshot of the registered page-state
1267
+ * controls (funnel step, filters…), or `null` when none are registered.
1268
+ */
1269
+ pageState: Record<string, unknown> | null;
1270
+ }
1271
+
923
1272
  /**
924
1273
  * SSE stream chunk data
925
1274
  */
@@ -963,6 +1312,9 @@ declare interface SSEChunkData {
963
1312
  waiting_tool_call_ids?: string[];
964
1313
  }
965
1314
 
1315
+ /** The slice of the Web Storage API that {@link createStore} relies on. */
1316
+ declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
1317
+
966
1318
  /**
967
1319
  * Where a completed form is sent.
968
1320
  * - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./AgoClient-5VGybmvz.cjs"),h=require("./autoContinue-CP9pJR-V.cjs"),f=require("./createFormCollector-1GKKwQV_.cjs"),p=require("./createConversationSession-0WTqcCLK.cjs"),w=require("./createMockClient-C-wrjb2C.cjs");require("./testing.cjs");const g=require("./functions-CPs7omgM.cjs");function S(e){return e}function E(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function y(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function F(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function v(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function b(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function q(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function M(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function k(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*T(e,o,l){const a=[];let n=null,i=!1;const c=s=>{a.push(s),n?.()},m=s=>c({type:"start",data:s}),t=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),i=!0,n?.()},d=s=>{c({type:"error",data:s}),i=!0,n?.()},A=s=>c({type:"toolCall",data:s});e.on("message:start",m),e.on("message:chunk",t),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",A),e.sendMessage(o,l).catch(()=>{i=!0,n?.()});try{for(;!i||a.length>0;)a.length>0?yield a.shift():(await new Promise(s=>{n=s}),n=null)}finally{e.off("message:start",m),e.off("message:chunk",t),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",A)}}function C(e){let o,l,a,n,i,c;if(typeof window<"u"&&window.AGO){const t=window.AGO;o=t.basepath,l=t.widgetId,a=t.agent||t.defaultAgent,n=t.permission,i=t.email,c=t.jwt}if(typeof document<"u"){const t=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||t("ago-base-url"),l=l||t("ago-widget-id"),a=a||t("ago-agent")||t("ago-agent-id"),n=n||t("ago-permission"),i=i||t("ago-user-email")}if(typeof document<"u"){const t=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of t)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,n=n||u.getAttribute("data-ago-permission")||void 0,i=i||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,a=e?.agent||e?.defaultAgentId||a,n=e?.permission||n,i=e?.userEmail||i,c=e?.userJwt||c;const m=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:n,userEmail:i,userJwt:c,debug:m}:null}function I(e){const o=C(e);if(!o)throw new r.AgoError('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.',"config_missing_base_url");return new r.AgoClient(o)}function U(e,o){return{...e,handler:o}}exports.AgoApiError=r.AgoApiError;exports.AgoClient=r.AgoClient;exports.AgoError=r.AgoError;exports.AgoFunctionError=r.AgoFunctionError;exports.AgoNetworkError=r.AgoNetworkError;exports.AgoStreamError=r.AgoStreamError;exports.ClientContextRegistry=r.ClientContextRegistry;exports.EventEmitter=r.EventEmitter;exports.FunctionRegistry=r.FunctionRegistry;exports.SSEHandler=r.SSEHandler;exports.attachAutoContinueAfterNavigation=h.attachAutoContinueAfterNavigation;exports.autoDetectConfig=C;exports.canInlineImage=r.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=I;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=T;exports.createMockClient=w.createMockClient;exports.createStore=f.createStore;exports.defineFunction=S;exports.deriveFormStatus=f.deriveFormStatus;exports.formatFileSize=r.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=r.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=r.logger;exports.onFormError=M;exports.onFormSubmitted=q;exports.onFunctionInvoke=k;exports.onMessage=E;exports.onMessageChunk=y;exports.onMessageError=v;exports.onMessageStart=F;exports.onToolCall=b;exports.openUrl=g.openUrl;exports.safeAttachmentUrl=r.safeAttachmentUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.validateConfig=r.validateConfig;exports.withHandler=U;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./AgoClient-Ba3ICq4K.cjs"),C=require("./autoContinue-CP9pJR-V.cjs"),p=require("./createConversationSession-okoz3teC.cjs"),f=require("./createFormCollector-BWIh1pMl.cjs"),E=require("./createMockClient-Dw-cyISN.cjs");require("./testing.cjs");const g=require("./functions-CPs7omgM.cjs");function S(e){return e}function w(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function y(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function v(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function F(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function b(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function M(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function T(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function q(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*I(e,o,l){const a=[];let n=null,i=!1;const c=s=>{a.push(s),n?.()},m=s=>c({type:"start",data:s}),r=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),i=!0,n?.()},d=s=>{c({type:"error",data:s}),i=!0,n?.()},A=s=>c({type:"toolCall",data:s});e.on("message:start",m),e.on("message:chunk",r),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",A),e.sendMessage(o,l).catch(()=>{i=!0,n?.()});try{for(;!i||a.length>0;)a.length>0?yield a.shift():(await new Promise(s=>{n=s}),n=null)}finally{e.off("message:start",m),e.off("message:chunk",r),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",A)}}function h(e){let o,l,a,n,i,c;if(typeof window<"u"&&window.AGO){const r=window.AGO;o=r.basepath,l=r.widgetId,a=r.agent||r.defaultAgent,n=r.permission,i=r.email,c=r.jwt}if(typeof document<"u"){const r=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||r("ago-base-url"),l=l||r("ago-widget-id"),a=a||r("ago-agent")||r("ago-agent-id"),n=n||r("ago-permission"),i=i||r("ago-user-email")}if(typeof document<"u"){const r=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of r)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,n=n||u.getAttribute("data-ago-permission")||void 0,i=i||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,a=e?.agent||e?.defaultAgentId||a,n=e?.permission||n,i=e?.userEmail||i,c=e?.userJwt||c;const m=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:n,userEmail:i,userJwt:c,debug:m}:null}function _(e){const o=h(e);if(!o)throw new t.AgoError('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.',"config_missing_base_url");return new t.AgoClient(o)}function k(e,o){return{...e,handler:o}}exports.ActivityLedger=t.ActivityLedger;exports.AgoApiError=t.AgoApiError;exports.AgoClient=t.AgoClient;exports.AgoError=t.AgoError;exports.AgoFunctionError=t.AgoFunctionError;exports.AgoNetworkError=t.AgoNetworkError;exports.AgoStreamError=t.AgoStreamError;exports.ClientContextRegistry=t.ClientContextRegistry;exports.DEFAULT_MAX_ACTIVITY_ENTRIES=t.DEFAULT_MAX_ACTIVITY_ENTRIES;exports.EventEmitter=t.EventEmitter;exports.FunctionRegistry=t.FunctionRegistry;exports.SSEHandler=t.SSEHandler;exports.SignalCollector=t.SignalCollector;exports.attachAutoContinueAfterNavigation=C.attachAutoContinueAfterNavigation;exports.autoDetectConfig=h;exports.canInlineImage=t.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=_;exports.createAgoProactive=t.createAgoProactive;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=I;exports.createMockClient=E.createMockClient;exports.createStore=t.createStore;exports.defineFunction=S;exports.deriveFormStatus=f.deriveFormStatus;exports.formatFileSize=t.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=t.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=t.logger;exports.matchesRoutePattern=t.matchesRoutePattern;exports.matchesWhen=t.matchesWhen;exports.onFormError=T;exports.onFormSubmitted=M;exports.onFunctionInvoke=q;exports.onMessage=w;exports.onMessageChunk=y;exports.onMessageError=F;exports.onMessageStart=v;exports.onToolCall=b;exports.openUrl=g.openUrl;exports.partialDeepMatch=t.partialDeepMatch;exports.safeAttachmentUrl=t.safeAttachmentUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.validateConfig=t.validateConfig;exports.withHandler=k;