@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
package/dist/testing.d.ts CHANGED
@@ -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
  *
@@ -1105,6 +1201,30 @@ declare interface Conversation {
1105
1201
  */
1106
1202
  export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
1107
1203
 
1204
+ /** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
1205
+ declare interface CreateTicketInput {
1206
+ subject: string;
1207
+ body: string;
1208
+ priority?: string;
1209
+ typology?: string;
1210
+ /** Conversation the ticket is filed from. */
1211
+ conversationId?: string;
1212
+ /** Reporter email, for a visitor the SDK does not otherwise identify. */
1213
+ email?: string;
1214
+ customFields?: Array<{
1215
+ id: string;
1216
+ value: string;
1217
+ }>;
1218
+ files?: File[];
1219
+ ticketFormId?: string;
1220
+ }
1221
+
1222
+ /** Response of `AgoClient.createTicket`. */
1223
+ declare interface CreateTicketResult {
1224
+ id: string;
1225
+ url?: string;
1226
+ }
1227
+
1108
1228
  /**
1109
1229
  * A function that returns a fresh context entry on demand.
1110
1230
  * Evaluated every time a message is sent — use it to pull data from stores,
@@ -1112,6 +1232,23 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
1112
1232
  */
1113
1233
  declare type DynamicContextProvider = () => ContextEntry | null | undefined;
1114
1234
 
1235
+ declare interface ErrorWatcherOptions {
1236
+ /** Max distinct errors kept. Oldest dropped first. Default 10. */
1237
+ maxErrors?: number;
1238
+ /**
1239
+ * Errors older than this are pruned when the buffer is read, so a crash from
1240
+ * an hour ago does not confuse the agent. Default 600 000 (10 min).
1241
+ */
1242
+ maxAgeMs?: number;
1243
+ /** Max chars of stack kept per error. Default 2000. */
1244
+ maxStackChars?: number;
1245
+ /**
1246
+ * Redact or drop an error before it is stored. Return the (possibly edited)
1247
+ * error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
1248
+ */
1249
+ filter?: (error: CapturedError) => CapturedError | null;
1250
+ }
1251
+
1115
1252
  /**
1116
1253
  * Why the user is reporting a message (see `AgoClient.submitFeedback`).
1117
1254
  *
@@ -1502,6 +1639,12 @@ declare interface ProactiveTriggerWhen {
1502
1639
  pageState?: Partial<Record<string, unknown>>;
1503
1640
  /** Min rage-click bursts on the current route. */
1504
1641
  rageClicks?: number;
1642
+ /**
1643
+ * Min JavaScript errors captured on the current route. Needs the client's
1644
+ * `errorWatcher` enabled; without it the count stays at 0 and the matcher
1645
+ * never passes.
1646
+ */
1647
+ jsErrors?: number;
1505
1648
  /** Min A→B→A→B route oscillations this session. */
1506
1649
  routeBounces?: number;
1507
1650
  /** Per-field minimum error counts (field NAME → min count). */
@@ -1519,10 +1662,69 @@ declare type ResumeGate = (info: {
1519
1662
  messageId: string;
1520
1663
  }) => Promise<void> | void;
1521
1664
 
1665
+ /** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
1666
+ declare interface SdkConfig {
1667
+ permissions: SdkPermissionConfig[];
1668
+ proactive: {
1669
+ enabled: boolean;
1670
+ };
1671
+ }
1672
+
1673
+ /** The dashboard's home screen content (title, subtitle, starter cards). */
1674
+ declare interface SdkHomePageConfig {
1675
+ title?: string;
1676
+ /** Markdown. */
1677
+ subtitle?: string;
1678
+ starters: SdkHomeStarter[];
1679
+ widgetStarter?: SdkWidgetStarter;
1680
+ }
1681
+
1682
+ /**
1683
+ * A conversation starter card configured in the AGO dashboard. `label` is what
1684
+ * the card shows; clicking it sends `message`.
1685
+ */
1686
+ declare interface SdkHomeStarter {
1687
+ id: string;
1688
+ /** The card's text (the starter's `description` in the dashboard). */
1689
+ label: string;
1690
+ /** What is sent when the card is clicked. */
1691
+ message: string;
1692
+ /** Answer with this agent instead of the configured default. */
1693
+ agentId?: string;
1694
+ }
1695
+
1696
+ /** One permission's configuration in {@link SdkConfig}. */
1697
+ declare interface SdkPermissionConfig {
1698
+ id?: string;
1699
+ name?: string;
1700
+ displayName?: string;
1701
+ agents: Array<{
1702
+ id: string;
1703
+ name?: string;
1704
+ }>;
1705
+ ticketForm?: TicketForm;
1706
+ /** Home screen content, when the tenant configured one. */
1707
+ homePage?: SdkHomePageConfig;
1708
+ fileAttachmentsEnabled: boolean;
1709
+ voiceEnabled: boolean;
1710
+ }
1711
+
1712
+ /**
1713
+ * The starter the dashboard sends by itself on a fresh visit, before the
1714
+ * visitor types anything.
1715
+ */
1716
+ declare interface SdkWidgetStarter {
1717
+ id: string;
1718
+ message: string;
1719
+ agentId?: string;
1720
+ }
1721
+
1522
1722
  /**
1523
1723
  * Options for sending a message
1524
1724
  */
1525
1725
  declare interface SendMessageOptions {
1726
+ /** Replaces config.metadata for this message; null omits metadata for this message. */
1727
+ metadata?: Record<string, unknown> | null;
1526
1728
  /** Existing conversation ID */
1527
1729
  conversationId?: string;
1528
1730
  /** Override default agent */
@@ -1571,6 +1773,12 @@ declare interface SignalsSnapshot {
1571
1773
  idleMs: number;
1572
1774
  /** Rage-click bursts detected on the current route. */
1573
1775
  rageClicks: number;
1776
+ /**
1777
+ * JavaScript errors captured on the current route (count only; the messages
1778
+ * travel in `client_context` under `errors:recent`). Always `0` unless the
1779
+ * client has `errorWatcher` enabled.
1780
+ */
1781
+ jsErrors: number;
1574
1782
  /**
1575
1783
  * A→B→A→B route oscillations detected in the recent route sequence. Rolling
1576
1784
  * session counter (cross-route by nature); trigger cooldowns and dismissal
@@ -1629,6 +1837,13 @@ declare interface SSEChunkData {
1629
1837
  follow_up_replies?: string[];
1630
1838
  satisfaction_feedback?: unknown;
1631
1839
  ask_to_talk_to_human?: boolean;
1840
+ allowed_to_create_ticket?: boolean;
1841
+ ticket?: ToolCallTicketPrefill;
1842
+ mode?: "form" | "embed";
1843
+ ticket_form_id?: string;
1844
+ embed_html?: string;
1845
+ embed_description?: string;
1846
+ display_mode?: "collapsible" | "display" | "both";
1632
1847
  /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
1633
1848
  waiting_tool_call_ids?: string[];
1634
1849
  }
@@ -1682,12 +1897,82 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
1682
1897
  declare interface SubmitToolCallResult {
1683
1898
  status: string;
1684
1899
  result?: unknown;
1900
+ /** Set when `status` is `"error"`. */
1901
+ error?: string;
1902
+ /** The ticket a ticketing `form` tool call resolved to, when it did. */
1903
+ ticket?: {
1904
+ ticket_id: string;
1905
+ ticket_url?: string;
1906
+ [key: string]: unknown;
1907
+ };
1685
1908
  resume?: {
1686
1909
  message_id: string;
1687
1910
  ready: boolean;
1688
1911
  };
1689
1912
  }
1690
1913
 
1914
+ /** A custom field of a ticket form. */
1915
+ declare interface TicketField {
1916
+ id: string;
1917
+ /** The key the ticketing backend expects; used as the submit key when set. */
1918
+ externalId?: string;
1919
+ title?: string;
1920
+ /** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
1921
+ type?: string;
1922
+ required: boolean;
1923
+ /** Carried in the submission but never shown. */
1924
+ hidden: boolean;
1925
+ active?: boolean;
1926
+ /** Bypass progressive disclosure, while still respecting conditions. */
1927
+ alwaysVisible?: boolean;
1928
+ regexpForValidation?: string;
1929
+ position: number;
1930
+ /** Non-empty turns the field into a select. */
1931
+ options: TicketFieldOption[];
1932
+ /** Show this field only when the parent field holds `conditionalFieldValue`. */
1933
+ conditionalFieldId?: string;
1934
+ /** Legacy comma-separated condition values. */
1935
+ conditionalFieldValue?: string;
1936
+ /** Takes precedence over conditionalFieldValue when non-empty. */
1937
+ conditionalFieldValues?: string[];
1938
+ }
1939
+
1940
+ /** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
1941
+ declare interface TicketFieldOption {
1942
+ id: string;
1943
+ /** Label shown to the user. */
1944
+ name?: string;
1945
+ /** Value submitted. Falls back to `name` when absent. */
1946
+ value?: string;
1947
+ /** Preselected when the form opens. */
1948
+ default: boolean;
1949
+ /** A note shown under the field once this option is picked. */
1950
+ message?: string;
1951
+ messageType: "info" | "warning" | "danger";
1952
+ position?: number;
1953
+ group?: string;
1954
+ noDisplay?: boolean;
1955
+ conditionalFieldId?: string;
1956
+ /** Available when the parent matches any of these values. */
1957
+ conditionalFieldValues?: string[];
1958
+ }
1959
+
1960
+ /** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
1961
+ declare interface TicketForm {
1962
+ id: string;
1963
+ name?: string;
1964
+ /** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
1965
+ mode: "form" | "embed";
1966
+ showSubject: boolean;
1967
+ showBody: boolean;
1968
+ showPriority: boolean;
1969
+ showTypology: boolean;
1970
+ priorityTypologies?: string[];
1971
+ successMessageText?: string;
1972
+ successMessageUrlLabel?: string;
1973
+ fields: TicketField[];
1974
+ }
1975
+
1691
1976
  /**
1692
1977
  * Tool call data from SSE stream
1693
1978
  */
@@ -1702,6 +1987,34 @@ declare interface ToolCallData {
1702
1987
  data?: Record<string, unknown>;
1703
1988
  functionName?: string;
1704
1989
  arguments?: Record<string, unknown>;
1990
+ /**
1991
+ * Where the hosted widget shows the call: in the collapsible "reasoning"
1992
+ * section, in the message body, or both. Absent means collapsible only.
1993
+ */
1994
+ displayMode?: "collapsible" | "display" | "both";
1995
+ /** The user asked to talk to a human. */
1996
+ askToTalkToHuman?: boolean;
1997
+ /** `false` when the tenant blocks ticket creation for this visitor. */
1998
+ allowedToCreateTicket?: boolean;
1999
+ /** Fields the agent pre-filled from the conversation. */
2000
+ ticket?: ToolCallTicketPrefill;
2001
+ /** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
2002
+ mode?: "form" | "embed";
2003
+ ticketFormId?: string;
2004
+ embedHtml?: string;
2005
+ embedDescription?: string;
2006
+ }
2007
+
2008
+ /** The ticket the agent pre-filled on a ticketing `form` tool call. */
2009
+ declare interface ToolCallTicketPrefill {
2010
+ subject?: string;
2011
+ body?: string;
2012
+ typology?: string;
2013
+ priority?: string;
2014
+ tag?: string;
2015
+ products?: string[];
2016
+ /** Keyed by the field's external id, or a lowercased, underscored title. */
2017
+ custom_fields?: Record<string, string>;
1705
2018
  }
1706
2019
 
1707
2020
  declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e } from "./createMockClient-5YF-ZbVu.js";
1
+ import { t as e } from "./createMockClient-Beao82tu.js";
2
2
  export {
3
3
  e as createMockClient
4
4
  };