@useago/sdk 1.9.0 → 1.12.0

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 +104 -0
  2. package/README.md +53 -0
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +313 -0
  5. package/dist/angular.d.ts +313 -0
  6. package/dist/angular.js +1 -1
  7. package/dist/{createConversationSession-BaaXBQ5b.js → createConversationSession-B1Qn-y0I.js} +1 -1
  8. package/dist/{createConversationSession-CU0b-t1W.cjs → createConversationSession-B3v_xOU7.cjs} +1 -1
  9. package/dist/{createFormCollector-DfN1xZBy.cjs → createFormCollector-FvwDOqnV.cjs} +1 -1
  10. package/dist/{createFormCollector-Cf7kGhCB.js → createFormCollector-m79zk_NA.js} +1 -1
  11. package/dist/createMockClient-BEOXI8yW.cjs +1 -0
  12. package/dist/{createMockClient-5YF-ZbVu.js → createMockClient-Beao82tu.js} +15 -3
  13. package/dist/devtools.d.cts +313 -0
  14. package/dist/devtools.d.ts +313 -0
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.d.cts +389 -4
  17. package/dist/index.d.ts +389 -4
  18. package/dist/index.js +118 -114
  19. package/dist/react.cjs +1 -1
  20. package/dist/react.d.cts +313 -0
  21. package/dist/react.d.ts +313 -0
  22. package/dist/react.js +8 -6
  23. package/dist/sheetController-BThJRtOu.cjs +1 -0
  24. package/dist/sheetController-aEKXIvjk.js +343 -0
  25. package/dist/testing.cjs +1 -1
  26. package/dist/testing.d.cts +313 -0
  27. package/dist/testing.d.ts +313 -0
  28. package/dist/testing.js +1 -1
  29. package/dist/types-Ct1hlKwg.js +2408 -0
  30. package/dist/types-mcW8vB1U.cjs +10 -0
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +505 -0
  33. package/dist/vue.d.ts +505 -0
  34. package/dist/vue.js +1 -1
  35. package/dist/widget.cjs +6 -4
  36. package/dist/widget.d.cts +585 -2
  37. package/dist/widget.d.ts +585 -2
  38. package/dist/widget.js +3985 -995
  39. package/llms-full.txt +125 -6
  40. package/package.json +1 -1
  41. package/dist/createMockClient-BZbOe-23.cjs +0 -1
  42. package/dist/sheetController-CBUVOroo.js +0 -205
  43. package/dist/sheetController-DY-sC13T.cjs +0 -1
  44. package/dist/types-CPga11Of.js +0 -2068
  45. package/dist/types-D3YQl1jx.cjs +0 -9
@@ -53,6 +53,7 @@ declare class AgoClient {
53
53
  private contextRegistry;
54
54
  private eventEmitter;
55
55
  private activityLedger;
56
+ private errorWatcher;
56
57
  private lastSentPageState;
57
58
  private config;
58
59
  /** Conversations already warned about an empty reply (one warning each). */
@@ -222,6 +223,26 @@ declare class AgoClient {
222
223
  * `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
223
224
  */
224
225
  private static mapPersistedToolCalls;
226
+ /**
227
+ * The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
228
+ * agents, the ticket form the agent's `ago_ticketing` tool opens, and the
229
+ * file-attachment flag. The vanilla widget fetches it once, when a ticket
230
+ * form first appears in a conversation.
231
+ */
232
+ getConfig(): Promise<SdkConfig>;
233
+ /**
234
+ * The dashboard's home screen content. A starter card shows its
235
+ * `description` and sends its `initial_message`; one with neither is
236
+ * unusable and is dropped rather than rendered as an empty card.
237
+ */
238
+ private static mapHomePage;
239
+ private static mapTicketForm;
240
+ /**
241
+ * Create a support ticket (`POST /api/sdk/v1/tickets`, multipart). This is
242
+ * what the ticket form in the conversation does before it completes the
243
+ * `form` tool call with {@link submitToolCallForm}.
244
+ */
245
+ createTicket(input: CreateTicketInput): Promise<CreateTicketResult>;
225
246
  /**
226
247
  * Get messages for a conversation
227
248
  */
@@ -480,6 +501,15 @@ declare class AgoClient {
480
501
  /* Excluded from this release type: emitProactiveEvent */
481
502
  /* Excluded from this release type: getHttp */
482
503
  /* Excluded from this release type: getConfiguredAgent */
504
+ /**
505
+ * How the SDK identifies the visitor: the configured `userEmail`, and
506
+ * whether a `userJwt` is set. The ticket form asks for an email when it has
507
+ * neither.
508
+ */
509
+ getUserIdentity(): {
510
+ email?: string;
511
+ hasJwt: boolean;
512
+ };
483
513
  /**
484
514
  * Enable automatic capture of the current browser page (URL + title).
485
515
  * Injected as a dynamic context entry named `browser-page`.
@@ -502,6 +532,26 @@ declare class AgoClient {
502
532
  private addActivity;
503
533
  private recordAgentAction;
504
534
  private registerActivityContext;
535
+ /**
536
+ * Start capturing the page's JavaScript errors (uncaught exceptions,
537
+ * unhandled rejections, `console.error` calls, {@link reportError}) and send
538
+ * the recent ones as the `errors:recent` context entry on every message.
539
+ * Same as setting `errorWatcher` in the config. Calling it again replaces
540
+ * the watcher (and its options); the captured errors are not kept.
541
+ */
542
+ enableErrorWatcher(options?: ErrorWatcherOptions): void;
543
+ /** Stop capturing errors and drop the `errors:recent` context entry. */
544
+ disableErrorWatcher(): void;
545
+ /**
546
+ * Record an error the app caught itself (React error boundary, Vue
547
+ * `errorHandler`, Angular `ErrorHandler`, a try/catch) so the agent sees it
548
+ * like an uncaught one. No-op unless the error watcher is enabled. `context`
549
+ * is size-clamped before it is stored; keep it small and free of secrets.
550
+ */
551
+ reportError(error: unknown, context?: Record<string, unknown>): void;
552
+ /** Errors the watcher currently holds, oldest first (a copy). Empty when disabled. */
553
+ getRecentErrors(): CapturedError[];
554
+ clearErrors(): void;
505
555
  /**
506
556
  * Subscribe to an event
507
557
  */
@@ -696,6 +746,12 @@ declare interface AgoClientEvents {
696
746
  };
697
747
  /** A user- or agent-action was recorded into the activity ledger. */
698
748
  "activity:recorded": ActivityEntry;
749
+ /**
750
+ * The error watcher captured a JavaScript error (uncaught exception,
751
+ * unhandled rejection, `console.error` call, or `reportError`). Fires on
752
+ * repeats too, with the updated `count`. Requires `errorWatcher` in the config.
753
+ */
754
+ "error:captured": CapturedError;
699
755
  }
700
756
 
701
757
  /**
@@ -716,6 +772,8 @@ declare interface AgoConfig {
716
772
  userEmail?: string;
717
773
  /** JWT token for authenticated users */
718
774
  userJwt?: string;
775
+ /** User metadata sent with messages. Use null to stop sending defaults. Not an authentication credential. */
776
+ metadata?: Record<string, unknown> | null;
719
777
  /** Enable debug logging */
720
778
  debug?: boolean;
721
779
  /**
@@ -775,6 +833,18 @@ declare interface AgoConfig {
775
833
  * default otherwise.
776
834
  */
777
835
  proactive?: ProactiveOptions;
836
+ /**
837
+ * Capture the page's JavaScript errors as agent context. When set, the SDK
838
+ * listens for uncaught exceptions and unhandled promise rejections, wraps
839
+ * `console.error` (calling through; restored on `destroy`), and sends the
840
+ * recent errors (deduplicated, capped, pruned after 10 min) as the
841
+ * `errors:recent` context entry on every message. `true` uses the defaults;
842
+ * pass {@link ErrorWatcherOptions} to tune the caps or add a `filter` that
843
+ * redacts messages. Off by default: error messages can carry PII or internal
844
+ * URLs, so enabling it is the host's call. Errors also feed the proactive
845
+ * mode's `jsErrors` signal. See `client.reportError()` for caught errors.
846
+ */
847
+ errorWatcher?: boolean | ErrorWatcherOptions;
778
848
  }
779
849
 
780
850
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -959,6 +1029,32 @@ declare type AgoStateSetResult = {
959
1029
  result: "unchanged";
960
1030
  };
961
1031
 
1032
+ /** One JavaScript error captured on the page (deduplicated, see `count`). */
1033
+ declare interface CapturedError {
1034
+ type: CapturedErrorType;
1035
+ /** Error message, truncated to 500 chars. */
1036
+ message: string;
1037
+ /** Script URL the error came from, without its query string. */
1038
+ source?: string;
1039
+ line?: number;
1040
+ col?: number;
1041
+ /** Leading stack frames, truncated (see `maxStackChars`). */
1042
+ stack?: string;
1043
+ /** Pathname at capture time. */
1044
+ route: string;
1045
+ /** Epoch ms of the first occurrence. */
1046
+ firstAt: number;
1047
+ /** Epoch ms of the most recent occurrence. */
1048
+ lastAt: number;
1049
+ /** How many times this same error (type + message + source + line) fired. */
1050
+ count: number;
1051
+ /** App-provided context, manual reports only (size-clamped). */
1052
+ context?: Record<string, unknown>;
1053
+ }
1054
+
1055
+ /** How an error reached the watcher. */
1056
+ declare type CapturedErrorType = "error" | "unhandledrejection" | "console" | "manual";
1057
+
962
1058
  /**
963
1059
  * Single-object function definition — combines name, schema, and handler.
964
1060
  *
@@ -1092,6 +1188,30 @@ declare interface Conversation {
1092
1188
  messages?: AgoMessage[];
1093
1189
  }
1094
1190
 
1191
+ /** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
1192
+ declare interface CreateTicketInput {
1193
+ subject: string;
1194
+ body: string;
1195
+ priority?: string;
1196
+ typology?: string;
1197
+ /** Conversation the ticket is filed from. */
1198
+ conversationId?: string;
1199
+ /** Reporter email, for a visitor the SDK does not otherwise identify. */
1200
+ email?: string;
1201
+ customFields?: Array<{
1202
+ id: string;
1203
+ value: string;
1204
+ }>;
1205
+ files?: File[];
1206
+ ticketFormId?: string;
1207
+ }
1208
+
1209
+ /** Response of `AgoClient.createTicket`. */
1210
+ declare interface CreateTicketResult {
1211
+ id: string;
1212
+ url?: string;
1213
+ }
1214
+
1095
1215
  /** Options for {@link initDevPanel}. */
1096
1216
  export declare interface DevPanelOptions {
1097
1217
  /**
@@ -1130,6 +1250,23 @@ export declare interface DevPanelOptions {
1130
1250
  */
1131
1251
  declare type DynamicContextProvider = () => ContextEntry | null | undefined;
1132
1252
 
1253
+ declare interface ErrorWatcherOptions {
1254
+ /** Max distinct errors kept. Oldest dropped first. Default 10. */
1255
+ maxErrors?: number;
1256
+ /**
1257
+ * Errors older than this are pruned when the buffer is read, so a crash from
1258
+ * an hour ago does not confuse the agent. Default 600 000 (10 min).
1259
+ */
1260
+ maxAgeMs?: number;
1261
+ /** Max chars of stack kept per error. Default 2000. */
1262
+ maxStackChars?: number;
1263
+ /**
1264
+ * Redact or drop an error before it is stored. Return the (possibly edited)
1265
+ * error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
1266
+ */
1267
+ filter?: (error: CapturedError) => CapturedError | null;
1268
+ }
1269
+
1133
1270
  /**
1134
1271
  * Why the user is reporting a message (see `AgoClient.submitFeedback`).
1135
1272
  *
@@ -1492,6 +1629,12 @@ declare interface ProactiveTriggerWhen {
1492
1629
  pageState?: Partial<Record<string, unknown>>;
1493
1630
  /** Min rage-click bursts on the current route. */
1494
1631
  rageClicks?: number;
1632
+ /**
1633
+ * Min JavaScript errors captured on the current route. Needs the client's
1634
+ * `errorWatcher` enabled; without it the count stays at 0 and the matcher
1635
+ * never passes.
1636
+ */
1637
+ jsErrors?: number;
1495
1638
  /** Min A→B→A→B route oscillations this session. */
1496
1639
  routeBounces?: number;
1497
1640
  /** Per-field minimum error counts (field NAME → min count). */
@@ -1509,10 +1652,69 @@ declare type ResumeGate = (info: {
1509
1652
  messageId: string;
1510
1653
  }) => Promise<void> | void;
1511
1654
 
1655
+ /** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
1656
+ declare interface SdkConfig {
1657
+ permissions: SdkPermissionConfig[];
1658
+ proactive: {
1659
+ enabled: boolean;
1660
+ };
1661
+ }
1662
+
1663
+ /** The dashboard's home screen content (title, subtitle, starter cards). */
1664
+ declare interface SdkHomePageConfig {
1665
+ title?: string;
1666
+ /** Markdown. */
1667
+ subtitle?: string;
1668
+ starters: SdkHomeStarter[];
1669
+ widgetStarter?: SdkWidgetStarter;
1670
+ }
1671
+
1672
+ /**
1673
+ * A conversation starter card configured in the AGO dashboard. `label` is what
1674
+ * the card shows; clicking it sends `message`.
1675
+ */
1676
+ declare interface SdkHomeStarter {
1677
+ id: string;
1678
+ /** The card's text (the starter's `description` in the dashboard). */
1679
+ label: string;
1680
+ /** What is sent when the card is clicked. */
1681
+ message: string;
1682
+ /** Answer with this agent instead of the configured default. */
1683
+ agentId?: string;
1684
+ }
1685
+
1686
+ /** One permission's configuration in {@link SdkConfig}. */
1687
+ declare interface SdkPermissionConfig {
1688
+ id?: string;
1689
+ name?: string;
1690
+ displayName?: string;
1691
+ agents: Array<{
1692
+ id: string;
1693
+ name?: string;
1694
+ }>;
1695
+ ticketForm?: TicketForm;
1696
+ /** Home screen content, when the tenant configured one. */
1697
+ homePage?: SdkHomePageConfig;
1698
+ fileAttachmentsEnabled: boolean;
1699
+ voiceEnabled: boolean;
1700
+ }
1701
+
1702
+ /**
1703
+ * The starter the dashboard sends by itself on a fresh visit, before the
1704
+ * visitor types anything.
1705
+ */
1706
+ declare interface SdkWidgetStarter {
1707
+ id: string;
1708
+ message: string;
1709
+ agentId?: string;
1710
+ }
1711
+
1512
1712
  /**
1513
1713
  * Options for sending a message
1514
1714
  */
1515
1715
  declare interface SendMessageOptions {
1716
+ /** Replaces config.metadata for this message; null omits metadata for this message. */
1717
+ metadata?: Record<string, unknown> | null;
1516
1718
  /** Existing conversation ID */
1517
1719
  conversationId?: string;
1518
1720
  /** Override default agent */
@@ -1561,6 +1763,12 @@ declare interface SignalsSnapshot {
1561
1763
  idleMs: number;
1562
1764
  /** Rage-click bursts detected on the current route. */
1563
1765
  rageClicks: number;
1766
+ /**
1767
+ * JavaScript errors captured on the current route (count only; the messages
1768
+ * travel in `client_context` under `errors:recent`). Always `0` unless the
1769
+ * client has `errorWatcher` enabled.
1770
+ */
1771
+ jsErrors: number;
1564
1772
  /**
1565
1773
  * A→B→A→B route oscillations detected in the recent route sequence. Rolling
1566
1774
  * session counter (cross-route by nature); trigger cooldowns and dismissal
@@ -1619,6 +1827,13 @@ declare interface SSEChunkData {
1619
1827
  follow_up_replies?: string[];
1620
1828
  satisfaction_feedback?: unknown;
1621
1829
  ask_to_talk_to_human?: boolean;
1830
+ allowed_to_create_ticket?: boolean;
1831
+ ticket?: ToolCallTicketPrefill;
1832
+ mode?: "form" | "embed";
1833
+ ticket_form_id?: string;
1834
+ embed_html?: string;
1835
+ embed_description?: string;
1836
+ display_mode?: "collapsible" | "display" | "both";
1622
1837
  /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
1623
1838
  waiting_tool_call_ids?: string[];
1624
1839
  }
@@ -1672,12 +1887,82 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
1672
1887
  declare interface SubmitToolCallResult {
1673
1888
  status: string;
1674
1889
  result?: unknown;
1890
+ /** Set when `status` is `"error"`. */
1891
+ error?: string;
1892
+ /** The ticket a ticketing `form` tool call resolved to, when it did. */
1893
+ ticket?: {
1894
+ ticket_id: string;
1895
+ ticket_url?: string;
1896
+ [key: string]: unknown;
1897
+ };
1675
1898
  resume?: {
1676
1899
  message_id: string;
1677
1900
  ready: boolean;
1678
1901
  };
1679
1902
  }
1680
1903
 
1904
+ /** A custom field of a ticket form. */
1905
+ declare interface TicketField {
1906
+ id: string;
1907
+ /** The key the ticketing backend expects; used as the submit key when set. */
1908
+ externalId?: string;
1909
+ title?: string;
1910
+ /** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
1911
+ type?: string;
1912
+ required: boolean;
1913
+ /** Carried in the submission but never shown. */
1914
+ hidden: boolean;
1915
+ active?: boolean;
1916
+ /** Bypass progressive disclosure, while still respecting conditions. */
1917
+ alwaysVisible?: boolean;
1918
+ regexpForValidation?: string;
1919
+ position: number;
1920
+ /** Non-empty turns the field into a select. */
1921
+ options: TicketFieldOption[];
1922
+ /** Show this field only when the parent field holds `conditionalFieldValue`. */
1923
+ conditionalFieldId?: string;
1924
+ /** Legacy comma-separated condition values. */
1925
+ conditionalFieldValue?: string;
1926
+ /** Takes precedence over conditionalFieldValue when non-empty. */
1927
+ conditionalFieldValues?: string[];
1928
+ }
1929
+
1930
+ /** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
1931
+ declare interface TicketFieldOption {
1932
+ id: string;
1933
+ /** Label shown to the user. */
1934
+ name?: string;
1935
+ /** Value submitted. Falls back to `name` when absent. */
1936
+ value?: string;
1937
+ /** Preselected when the form opens. */
1938
+ default: boolean;
1939
+ /** A note shown under the field once this option is picked. */
1940
+ message?: string;
1941
+ messageType: "info" | "warning" | "danger";
1942
+ position?: number;
1943
+ group?: string;
1944
+ noDisplay?: boolean;
1945
+ conditionalFieldId?: string;
1946
+ /** Available when the parent matches any of these values. */
1947
+ conditionalFieldValues?: string[];
1948
+ }
1949
+
1950
+ /** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
1951
+ declare interface TicketForm {
1952
+ id: string;
1953
+ name?: string;
1954
+ /** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
1955
+ mode: "form" | "embed";
1956
+ showSubject: boolean;
1957
+ showBody: boolean;
1958
+ showPriority: boolean;
1959
+ showTypology: boolean;
1960
+ priorityTypologies?: string[];
1961
+ successMessageText?: string;
1962
+ successMessageUrlLabel?: string;
1963
+ fields: TicketField[];
1964
+ }
1965
+
1681
1966
  /**
1682
1967
  * Tool call data from SSE stream
1683
1968
  */
@@ -1692,6 +1977,34 @@ declare interface ToolCallData {
1692
1977
  data?: Record<string, unknown>;
1693
1978
  functionName?: string;
1694
1979
  arguments?: Record<string, unknown>;
1980
+ /**
1981
+ * Where the hosted widget shows the call: in the collapsible "reasoning"
1982
+ * section, in the message body, or both. Absent means collapsible only.
1983
+ */
1984
+ displayMode?: "collapsible" | "display" | "both";
1985
+ /** The user asked to talk to a human. */
1986
+ askToTalkToHuman?: boolean;
1987
+ /** `false` when the tenant blocks ticket creation for this visitor. */
1988
+ allowedToCreateTicket?: boolean;
1989
+ /** Fields the agent pre-filled from the conversation. */
1990
+ ticket?: ToolCallTicketPrefill;
1991
+ /** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
1992
+ mode?: "form" | "embed";
1993
+ ticketFormId?: string;
1994
+ embedHtml?: string;
1995
+ embedDescription?: string;
1996
+ }
1997
+
1998
+ /** The ticket the agent pre-filled on a ticketing `form` tool call. */
1999
+ declare interface ToolCallTicketPrefill {
2000
+ subject?: string;
2001
+ body?: string;
2002
+ typology?: string;
2003
+ priority?: string;
2004
+ tag?: string;
2005
+ products?: string[];
2006
+ /** Keyed by the field's external id, or a lowercased, underscored title. */
2007
+ custom_fields?: Record<string, string>;
1695
2008
  }
1696
2009
 
1697
2010
  declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./types-D3YQl1jx.cjs"),m=require("./errors-o1IB5fEu.cjs"),E=require("./autoContinue-CP9pJR-V.cjs"),S=require("./createConversationSession-CU0b-t1W.cjs"),d=require("./createFormCollector-DfN1xZBy.cjs"),w=require("./createMockClient-BZbOe-23.cjs");require("./testing.cjs");const g=require("./functions-CPs7omgM.cjs");function y(e){return e}function F(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function v(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function b(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function M(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function T(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 _(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function I(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*k(e,o,l){const i=[];let n=null,a=!1;const c=s=>{i.push(s),n?.()},f=s=>c({type:"start",data:s}),r=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),a=!0,n?.()},A=s=>{c({type:"error",data:s}),a=!0,n?.()},C=s=>c({type:"toolCall",data:s}),h=()=>{a=!0,n?.()};e.on("message:start",f),e.on("message:chunk",r),e.on("message:complete",u),e.on("message:error",A),e.on("message:stopped",h),e.on("toolCall:received",C),e.sendMessage(o,l).catch(()=>{a=!0,n?.()});try{for(;!a||i.length>0;)i.length>0?yield i.shift():(await new Promise(s=>{n=s}),n=null)}finally{e.off("message:start",f),e.off("message:chunk",r),e.off("message:complete",u),e.off("message:error",A),e.off("message:stopped",h),e.off("toolCall:received",C)}}function p(e){let o,l,i,n,a,c;if(typeof window<"u"&&window.AGO){const r=window.AGO;o=r.basepath,l=r.widgetId,i=r.agent||r.defaultAgent,n=r.permission,a=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"),i=i||r("ago-agent")||r("ago-agent-id"),n=n||r("ago-permission"),a=a||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,i=i||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,n=n||u.getAttribute("data-ago-permission")||void 0,a=a||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,i=e?.agent||e?.defaultAgentId||i,n=e?.permission||n,a=e?.userEmail||a,c=e?.userJwt||c;const f=e?.debug;return o?{baseUrl:o,widgetId:l,agent:i,permission:n,userEmail:a,userJwt:c,debug:f}:null}function N(e){const o=p(e);if(!o)throw new m.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 U(e,o){return{...e,handler:o}}exports.ActivityLedger=t.ActivityLedger;exports.AgoApiError=m.AgoApiError;exports.AgoClient=t.AgoClient;exports.AgoError=m.AgoError;exports.AgoFunctionError=m.AgoFunctionError;exports.AgoNetworkError=m.AgoNetworkError;exports.AgoStreamError=m.AgoStreamError;exports.ClientContextRegistry=t.ClientContextRegistry;exports.DEFAULT_MAX_ACTIVITY_ENTRIES=t.DEFAULT_MAX_ACTIVITY_ENTRIES;exports.EventEmitter=t.EventEmitter;exports.FEEDBACK_REASONS=t.FEEDBACK_REASONS;exports.FunctionRegistry=t.FunctionRegistry;exports.SSEHandler=t.SSEHandler;exports.SignalCollector=t.SignalCollector;exports.attachAutoContinueAfterNavigation=E.attachAutoContinueAfterNavigation;exports.autoDetectConfig=p;exports.canInlineImage=t.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=N;exports.createAgoProactive=t.createAgoProactive;exports.createConversationSession=S.createConversationSession;exports.createFormCollector=d.createFormCollector;exports.createMessageStream=k;exports.createMockClient=w.createMockClient;exports.createStore=t.createStore;exports.defineFunction=y;exports.deriveFormStatus=d.deriveFormStatus;exports.formatFileSize=t.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=t.isStreamNetworkError;exports.loadFormCollector=d.loadFormCollector;exports.logger=t.logger;exports.matchesRoutePattern=t.matchesRoutePattern;exports.matchesWhen=t.matchesWhen;exports.onFormError=_;exports.onFormSubmitted=q;exports.onFunctionInvoke=I;exports.onMessage=F;exports.onMessageChunk=v;exports.onMessageError=M;exports.onMessageStart=b;exports.onToolCall=T;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=U;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./types-mcW8vB1U.cjs"),f=require("./errors-o1IB5fEu.cjs"),S=require("./autoContinue-CP9pJR-V.cjs"),p=require("./createConversationSession-B3v_xOU7.cjs"),A=require("./createFormCollector-FvwDOqnV.cjs"),w=require("./createMockClient-BEOXI8yW.cjs");require("./testing.cjs");const g=require("./functions-CPs7omgM.cjs");function F(e){return e}function _(e,t){return e.on("message:complete",t),()=>e.off("message:complete",t)}function y(e,t){return e.on("message:chunk",t),()=>e.off("message:chunk",t)}function M(e,t){return e.on("message:start",t),()=>e.off("message:start",t)}function v(e,t){return e.on("message:error",t),()=>e.off("message:error",t)}function T(e,t){return e.on("toolCall:received",t),()=>e.off("toolCall:received",t)}function R(e,t){return e.on("form:submitted",t),()=>e.off("form:submitted",t)}function b(e,t){return e.on("form:error",t),()=>e.off("form:error",t)}function q(e,t){return e.on("function:invoke",t),()=>e.off("function:invoke",t)}async function*I(e,t,c){const i=[];let n=null,a=!1;const l=s=>{i.push(s),n?.()},m=s=>l({type:"start",data:s}),d=s=>l({type:"chunk",data:s}),r=s=>{l({type:"complete",data:s}),a=!0,n?.()},u=s=>{l({type:"error",data:s}),a=!0,n?.()},E=s=>l({type:"toolCall",data:s}),h=()=>{a=!0,n?.()};e.on("message:start",m),e.on("message:chunk",d),e.on("message:complete",r),e.on("message:error",u),e.on("message:stopped",h),e.on("toolCall:received",E),e.sendMessage(t,c).catch(()=>{a=!0,n?.()});try{for(;!a||i.length>0;)i.length>0?yield i.shift():(await new Promise(s=>{n=s}),n=null)}finally{e.off("message:start",m),e.off("message:chunk",d),e.off("message:complete",r),e.off("message:error",u),e.off("message:stopped",h),e.off("toolCall:received",E)}}function C(e){let t,c,i,n,a,l,m;if(typeof window<"u"&&window.AGO){const r=window.AGO;t=r.basepath,c=r.widgetId,i=r.agent||r.defaultAgent,n=r.permission,a=r.email,l=r.jwt,m=r.metadata}if(typeof document<"u"){const r=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;t=t||r("ago-base-url"),c=c||r("ago-widget-id"),i=i||r("ago-agent")||r("ago-agent-id"),n=n||r("ago-permission"),a=a||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&&(t=t||u.getAttribute("data-ago-base-url")||void 0,c=c||u.getAttribute("data-ago-widget-id")||void 0,i=i||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,n=n||u.getAttribute("data-ago-permission")||void 0,a=a||u.getAttribute("data-ago-user-email")||void 0)}t=e?.baseUrl||t,c=e?.widgetId||c,i=e?.agent||e?.defaultAgentId||i,n=e?.permission||n,a=e?.userEmail||a,l=e?.userJwt||l,e?.metadata!==void 0&&(m=e.metadata);const d=e?.debug;return t?{baseUrl:t,widgetId:c,agent:i,permission:n,userEmail:a,userJwt:l,metadata:m,debug:d}:null}function U(e){const t=C(e);if(!t)throw new f.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 o.AgoClient(t)}function D(e,t){return{...e,handler:t}}exports.ActivityLedger=o.ActivityLedger;exports.AgoApiError=f.AgoApiError;exports.AgoClient=o.AgoClient;exports.AgoError=f.AgoError;exports.AgoFunctionError=f.AgoFunctionError;exports.AgoNetworkError=f.AgoNetworkError;exports.AgoStreamError=f.AgoStreamError;exports.ClientContextRegistry=o.ClientContextRegistry;exports.DEFAULT_MAX_ACTIVITY_ENTRIES=o.DEFAULT_MAX_ACTIVITY_ENTRIES;exports.DEFAULT_MAX_ERRORS=o.DEFAULT_MAX_ERRORS;exports.DEFAULT_MAX_ERROR_AGE_MS=o.DEFAULT_MAX_ERROR_AGE_MS;exports.ErrorWatcher=o.ErrorWatcher;exports.EventEmitter=o.EventEmitter;exports.FEEDBACK_REASONS=o.FEEDBACK_REASONS;exports.FunctionRegistry=o.FunctionRegistry;exports.SSEHandler=o.SSEHandler;exports.SignalCollector=o.SignalCollector;exports.attachAutoContinueAfterNavigation=S.attachAutoContinueAfterNavigation;exports.autoDetectConfig=C;exports.canInlineImage=o.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=U;exports.createAgoProactive=o.createAgoProactive;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=A.createFormCollector;exports.createMessageStream=I;exports.createMockClient=w.createMockClient;exports.createStore=o.createStore;exports.defineFunction=F;exports.deriveFormStatus=A.deriveFormStatus;exports.formatFileSize=o.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=o.isStreamNetworkError;exports.loadFormCollector=A.loadFormCollector;exports.logger=o.logger;exports.matchesRoutePattern=o.matchesRoutePattern;exports.matchesWhen=o.matchesWhen;exports.onFormError=b;exports.onFormSubmitted=R;exports.onFunctionInvoke=q;exports.onMessage=_;exports.onMessageChunk=y;exports.onMessageError=v;exports.onMessageStart=M;exports.onToolCall=T;exports.openUrl=g.openUrl;exports.partialDeepMatch=o.partialDeepMatch;exports.safeAttachmentUrl=o.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=o.validateConfig;exports.withHandler=D;