@useago/sdk 1.7.2 → 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 (51) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/README.md +96 -1
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +402 -5
  5. package/dist/angular.d.ts +402 -5
  6. package/dist/angular.js +11 -7
  7. package/dist/{createConversationSession-DP90nY71.js → createConversationSession-B1Qn-y0I.js} +3 -3
  8. package/dist/createConversationSession-B3v_xOU7.cjs +1 -0
  9. package/dist/createFormCollector-FvwDOqnV.cjs +1 -0
  10. package/dist/{createFormCollector-BivHRIAe.js → createFormCollector-m79zk_NA.js} +1 -1
  11. package/dist/createMockClient-BEOXI8yW.cjs +1 -0
  12. package/dist/{createMockClient-BDLW6tVc.js → createMockClient-Beao82tu.js} +31 -18
  13. package/dist/devtools.cjs +61 -12
  14. package/dist/devtools.d.cts +403 -5
  15. package/dist/devtools.d.ts +403 -5
  16. package/dist/devtools.js +225 -73
  17. package/dist/errors-BLfjXnLB.js +32 -0
  18. package/dist/errors-o1IB5fEu.cjs +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +489 -7
  21. package/dist/index.d.ts +489 -7
  22. package/dist/index.js +124 -118
  23. package/dist/react.cjs +4 -4
  24. package/dist/react.d.cts +510 -3
  25. package/dist/react.d.ts +510 -3
  26. package/dist/react.js +1036 -752
  27. package/dist/sheetController-BThJRtOu.cjs +1 -0
  28. package/dist/sheetController-aEKXIvjk.js +343 -0
  29. package/dist/testing.cjs +1 -1
  30. package/dist/testing.d.cts +393 -3
  31. package/dist/testing.d.ts +393 -3
  32. package/dist/testing.js +1 -1
  33. package/dist/types-Ct1hlKwg.js +2408 -0
  34. package/dist/types-mcW8vB1U.cjs +10 -0
  35. package/dist/vue.cjs +1 -1
  36. package/dist/vue.d.cts +615 -3
  37. package/dist/vue.d.ts +615 -3
  38. package/dist/vue.js +202 -154
  39. package/dist/widget.cjs +6 -4
  40. package/dist/widget.d.cts +733 -5
  41. package/dist/widget.d.ts +733 -5
  42. package/dist/widget.js +3996 -786
  43. package/llms-full.txt +264 -31
  44. package/package.json +1 -1
  45. package/dist/AgoClient-7yXQ6R3O.cjs +0 -9
  46. package/dist/AgoClient-DTkBRGFE.js +0 -1965
  47. package/dist/createConversationSession-Bv6a15E0.cjs +0 -1
  48. package/dist/createFormCollector-CwfiYn0V.cjs +0 -1
  49. package/dist/createMockClient-BSNuN3ys.cjs +0 -1
  50. package/dist/sheetController-CBUVOroo.js +0 -205
  51. package/dist/sheetController-DY-sC13T.cjs +0 -1
package/dist/widget.d.cts 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
  */
@@ -273,9 +294,40 @@ declare class AgoClient {
273
294
  */
274
295
  submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
275
296
  /**
276
- * Submit feedback for a message
297
+ * Report an answer: thumbs up/down, optionally with what went wrong.
298
+ *
299
+ * ```ts
300
+ * await client.submitFeedback(message.id, "negative", {
301
+ * reasons: ["inaccurate"],
302
+ * comment: "The price it quoted is from last year.",
303
+ * });
304
+ * ```
305
+ *
306
+ * A bare rating is a reaction (the thumbs counted in the dashboard). Adding a
307
+ * reason or a comment also files it in the feedback list, the analytics and
308
+ * the CSV export, so someone can act on it.
277
309
  */
278
- submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
310
+ submitFeedback(messageId: string, rating: FeedbackRating, details?: FeedbackDetails): Promise<void>;
311
+ /**
312
+ * Report a whole conversation ("this chat is not working").
313
+ *
314
+ * ```ts
315
+ * await client.submitConversationFeedback(conversationId, "negative", {
316
+ * reasons: ["information_not_found"],
317
+ * comment: "It never answered my question.",
318
+ * });
319
+ * ```
320
+ *
321
+ * Feedback is stored per message, so this attaches the report to the last
322
+ * answer of the conversation, which is the one the user is reacting to.
323
+ * Returns the message id it landed on.
324
+ *
325
+ * Pass `lastMessageId` when you already have it (the widget does) to skip the
326
+ * lookup round-trip.
327
+ */
328
+ submitConversationFeedback(conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
329
+ lastMessageId?: string;
330
+ }): Promise<string>;
279
331
  /**
280
332
  * Register a client-side function that AGO can call.
281
333
  * Accepts either a definition object or (name, handler, schema) args.
@@ -449,6 +501,15 @@ declare class AgoClient {
449
501
  /* Excluded from this release type: emitProactiveEvent */
450
502
  /* Excluded from this release type: getHttp */
451
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
+ };
452
513
  /**
453
514
  * Enable automatic capture of the current browser page (URL + title).
454
515
  * Injected as a dynamic context entry named `browser-page`.
@@ -471,6 +532,26 @@ declare class AgoClient {
471
532
  private addActivity;
472
533
  private recordAgentAction;
473
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;
474
555
  /**
475
556
  * Subscribe to an event
476
557
  */
@@ -665,6 +746,12 @@ declare interface AgoClientEvents {
665
746
  };
666
747
  /** A user- or agent-action was recorded into the activity ledger. */
667
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;
668
755
  }
669
756
 
670
757
  /**
@@ -685,6 +772,8 @@ declare interface AgoConfig {
685
772
  userEmail?: string;
686
773
  /** JWT token for authenticated users */
687
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;
688
777
  /** Enable debug logging */
689
778
  debug?: boolean;
690
779
  /**
@@ -744,6 +833,18 @@ declare interface AgoConfig {
744
833
  * default otherwise.
745
834
  */
746
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;
747
848
  }
748
849
 
749
850
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -907,12 +1008,27 @@ declare interface AgoStateControl<T = unknown> {
907
1008
  enum?: (string | number)[];
908
1009
  };
909
1010
  };
1011
+ /** String-only: `""` means "clear" instead of being dropped as filler. */
1012
+ clearable?: boolean;
910
1013
  /** Current value → pushed as dynamic context so the agent knows what to change. */
911
1014
  get?: () => T;
912
1015
  /** Apply the state change on the page. May be async. */
913
- set: (value: T) => void | Promise<void>;
1016
+ set: (value: T) => void | AgoStateSetResult | Promise<void | AgoStateSetResult>;
914
1017
  }
915
1018
 
1019
+ /**
1020
+ * Tagged outcome a page setter may return to reject or mark unchanged.
1021
+ *
1022
+ * Returning nothing (void) means APPLY. Returning an unrecognized JS value
1023
+ * (e.g. a string from an assignment expression) is also treated as APPLY.
1024
+ */
1025
+ declare type AgoStateSetResult = {
1026
+ result: "rejected";
1027
+ reason: string;
1028
+ } | {
1029
+ result: "unchanged";
1030
+ };
1031
+
916
1032
  export declare interface AgoWidgetColors {
917
1033
  button?: string;
918
1034
  header?: string;
@@ -942,6 +1058,32 @@ export declare interface AgoWidgetConfig {
942
1058
  metadata?: Record<string, unknown>;
943
1059
  }
944
1060
 
1061
+ /** One JavaScript error captured on the page (deduplicated, see `count`). */
1062
+ declare interface CapturedError {
1063
+ type: CapturedErrorType;
1064
+ /** Error message, truncated to 500 chars. */
1065
+ message: string;
1066
+ /** Script URL the error came from, without its query string. */
1067
+ source?: string;
1068
+ line?: number;
1069
+ col?: number;
1070
+ /** Leading stack frames, truncated (see `maxStackChars`). */
1071
+ stack?: string;
1072
+ /** Pathname at capture time. */
1073
+ route: string;
1074
+ /** Epoch ms of the first occurrence. */
1075
+ firstAt: number;
1076
+ /** Epoch ms of the most recent occurrence. */
1077
+ lastAt: number;
1078
+ /** How many times this same error (type + message + source + line) fired. */
1079
+ count: number;
1080
+ /** App-provided context, manual reports only (size-clamped). */
1081
+ context?: Record<string, unknown>;
1082
+ }
1083
+
1084
+ /** How an error reached the watcher. */
1085
+ declare type CapturedErrorType = "error" | "unhandledrejection" | "console" | "manual";
1086
+
945
1087
  /** Handle returned by `mountChatWidget`. */
946
1088
  export declare interface ChatWidgetHandle {
947
1089
  /** The AGO client backing the widget. */
@@ -974,6 +1116,18 @@ export declare interface ChatWidgetHandle {
974
1116
  readonly threads: Conversation[];
975
1117
  /** Re-fetch the conversations list and update {@link ChatWidgetHandle.threads}. */
976
1118
  refreshThreads: () => Promise<Conversation[]>;
1119
+ /** `placement: "bubble"` only. The screen currently shown. */
1120
+ readonly screen?: WidgetScreen;
1121
+ /** `placement: "bubble"` only. Switch to the home, chat, or history screen. */
1122
+ showScreen?: (screen: WidgetScreen) => void;
1123
+ /** `placement: "bubble"` only. Open a conversation by id on the chat screen. */
1124
+ openConversation?: (conversationId: string) => Promise<void>;
1125
+ /**
1126
+ * Forget the current thread and start over, like the header's new-chat
1127
+ * button and the "New conversation" button shown once a ticket exists. The
1128
+ * bubble widget also returns to its home screen.
1129
+ */
1130
+ newConversation: () => void;
977
1131
  /** Remove listeners, uninstall forms, and clear the DOM. */
978
1132
  destroy: () => void;
979
1133
  }
@@ -1068,6 +1222,14 @@ declare interface ClientFunctionSchema {
1068
1222
  /** See {@link AgoConfig.clientFunctionsMode}. */
1069
1223
  declare type ClientFunctionsMode = "placeholder" | "pause";
1070
1224
 
1225
+ /**
1226
+ * Translate the embed snippet's `colors` object into {@link WidgetTheme} keys,
1227
+ * so `mountChatWidget({ colors })` skins the bubble widget exactly like
1228
+ * `window.AGO.colors` skins the hosted one. The header text color is derived
1229
+ * for contrast unless the theme sets it.
1230
+ */
1231
+ export declare function colorsToTheme(colors: AgoWidgetColors | undefined): WidgetTheme;
1232
+
1071
1233
  /**
1072
1234
  * Build the media query for the compact layout.
1073
1235
  *
@@ -1174,6 +1336,19 @@ export declare interface ConversationSessionOptions {
1174
1336
  ttlMs?: number;
1175
1337
  }
1176
1338
 
1339
+ /** A card on the bubble widget's home screen that starts a conversation. */
1340
+ export declare interface ConversationStarter {
1341
+ /** Text shown on the card. */
1342
+ label: string;
1343
+ /** Message sent when clicked. Defaults to `label`. */
1344
+ message?: string;
1345
+ /**
1346
+ * Answer this starter with a specific agent (id or slug) instead of the
1347
+ * client's default. Dashboard starters (`loadHomeConfig`) carry their own.
1348
+ */
1349
+ agentId?: string;
1350
+ }
1351
+
1177
1352
  export declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
1178
1353
  /** Short identifier; becomes the `update_<name>` / `submit_<name>` function names. */
1179
1354
  name: string;
@@ -1199,6 +1374,36 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
1199
1374
 
1200
1375
  export declare function createSheetController(options?: SheetOptions): SheetController;
1201
1376
 
1377
+ /** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
1378
+ declare interface CreateTicketInput {
1379
+ subject: string;
1380
+ body: string;
1381
+ priority?: string;
1382
+ typology?: string;
1383
+ /** Conversation the ticket is filed from. */
1384
+ conversationId?: string;
1385
+ /** Reporter email, for a visitor the SDK does not otherwise identify. */
1386
+ email?: string;
1387
+ customFields?: Array<{
1388
+ id: string;
1389
+ value: string;
1390
+ }>;
1391
+ files?: File[];
1392
+ ticketFormId?: string;
1393
+ }
1394
+
1395
+ /** Response of `AgoClient.createTicket`. */
1396
+ declare interface CreateTicketResult {
1397
+ id: string;
1398
+ url?: string;
1399
+ }
1400
+
1401
+ export declare const DEFAULT_FEEDBACK_LABELS: FeedbackLabels;
1402
+
1403
+ export declare const DEFAULT_TOOL_CALL_FORM_LABELS: ToolCallFormLabels;
1404
+
1405
+ export declare const DEFAULT_WIDGET_LABELS: WidgetLabels;
1406
+
1202
1407
  /**
1203
1408
  * A function that returns a fresh context entry on demand.
1204
1409
  * Evaluated every time a message is sent — use it to pull data from stores,
@@ -1213,6 +1418,72 @@ export declare interface ElementProps {
1213
1418
  attrs: Record<string, string | null>;
1214
1419
  }
1215
1420
 
1421
+ declare interface ErrorWatcherOptions {
1422
+ /** Max distinct errors kept. Oldest dropped first. Default 10. */
1423
+ maxErrors?: number;
1424
+ /**
1425
+ * Errors older than this are pruned when the buffer is read, so a crash from
1426
+ * an hour ago does not confuse the agent. Default 600 000 (10 min).
1427
+ */
1428
+ maxAgeMs?: number;
1429
+ /** Max chars of stack kept per error. Default 2000. */
1430
+ maxStackChars?: number;
1431
+ /**
1432
+ * Redact or drop an error before it is stored. Return the (possibly edited)
1433
+ * error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
1434
+ */
1435
+ filter?: (error: CapturedError) => CapturedError | null;
1436
+ }
1437
+
1438
+ /**
1439
+ * Why the user is reporting a message (see `AgoClient.submitFeedback`).
1440
+ *
1441
+ * A rating on its own is a reaction (the thumbs count). Add a reason or a
1442
+ * comment and the report also lands in the feedback dashboard, the analytics
1443
+ * and the CSV export, where someone can act on it.
1444
+ */
1445
+ declare interface FeedbackDetails {
1446
+ /** What went wrong. Several can apply at once. */
1447
+ reasons?: FeedbackReason[];
1448
+ /** The user's own words. Trimmed server-side; 5000 characters max. */
1449
+ comment?: string;
1450
+ }
1451
+
1452
+ /** Every string the feedback row shows, so a non-English app can translate it. */
1453
+ export declare interface FeedbackLabels {
1454
+ /** Accessible name of the thumbs-up button. */
1455
+ helpful: string;
1456
+ /** Accessible name of the thumbs-down button. */
1457
+ notHelpful: string;
1458
+ /** Title of the panel opened by a thumbs-down. */
1459
+ whatWentWrong: string;
1460
+ /** Label of each reason chip. */
1461
+ reasons: Record<FeedbackReason, string>;
1462
+ /** Placeholder of the free-text field. */
1463
+ commentPlaceholder: string;
1464
+ /** Label of the panel's submit button. */
1465
+ send: string;
1466
+ /** Confirmation shown once a report is sent. */
1467
+ thanks: string;
1468
+ }
1469
+
1470
+ /** Thumbs up / thumbs down on an answer. */
1471
+ declare type FeedbackRating = "positive" | "negative";
1472
+
1473
+ /**
1474
+ * What went wrong with an answer. These are the four buckets the AGO feedback
1475
+ * dashboard filters and charts on.
1476
+ */
1477
+ declare type FeedbackReason =
1478
+ /** The answer states something false. */
1479
+ "inaccurate"
1480
+ /** The answer is right but stops short. */
1481
+ | "incomplete"
1482
+ /** The agent could not find the information. */
1483
+ | "information_not_found"
1484
+ /** Something broke: the widget, a tool call, the stream. */
1485
+ | "technical_issue";
1486
+
1216
1487
  /**
1217
1488
  * The backend-stored shape returned by `GET /api/sdk/v1/forms/{name}` (see
1218
1489
  * {@link AgoClient.getFormCollector}). Mirrors the persistable subset of
@@ -1453,14 +1724,73 @@ export declare interface MountChatWidgetOptions {
1453
1724
  * closed; the target is only used as the DOM parent (pass `document.body` for
1454
1725
  * a true page overlay). In side mode `height` is ignored and the width comes
1455
1726
  * from {@link MountChatWidgetOptions.width}.
1727
+ *
1728
+ * `"bubble"` reproduces the hosted embed widget without an iframe: a floating
1729
+ * launcher bottom-right, a teaser bubble, and a 550px panel with a home
1730
+ * screen, a conversation screen, and a chat history screen. See the
1731
+ * "Floating bubble" section of `docs/general/widget.md`.
1456
1732
  */
1457
- placement?: "inline" | "left" | "right";
1733
+ placement?: "inline" | "left" | "right" | "bubble";
1458
1734
  /**
1459
1735
  * Width of the side panel for `placement: "left" | "right"` (number → px).
1460
1736
  * Capped at the viewport width so it never overflows on mobile. Ignored when
1461
- * `placement` is `"inline"`. Defaults to `400`.
1737
+ * `placement` is `"inline"`. Defaults to `400`; to `550` for `"bubble"`, where
1738
+ * it is clamped between 400px and the viewport width minus 40px.
1462
1739
  */
1463
1740
  width?: string | number;
1741
+ /**
1742
+ * `placement: "bubble"` only. The teaser speech bubble shown above the
1743
+ * launcher one second after mount, inviting the visitor in. Pass `false` to
1744
+ * skip it. Defaults to `"Hello, how can I help you today?"`.
1745
+ */
1746
+ prompt?: string | false;
1747
+ /**
1748
+ * `placement: "bubble"` only. URL of an image (32×32) shown on the launcher
1749
+ * instead of the default chat glyph.
1750
+ */
1751
+ icon?: string;
1752
+ /**
1753
+ * `placement: "bubble"` only. The same `colors` object as the embed snippet's
1754
+ * `window.AGO.colors`, mapped onto {@link WidgetTheme} keys. `theme` wins over
1755
+ * it key by key. The header text color is derived for contrast automatically.
1756
+ */
1757
+ colors?: AgoWidgetColors;
1758
+ /** `placement: "bubble"` only. Hide the Home / Chats bottom bar. Defaults to `false`. */
1759
+ hideFooter?: boolean;
1760
+ /**
1761
+ * `placement: "bubble"` only. Markdown shown under the title on the home
1762
+ * screen.
1763
+ */
1764
+ subtitle?: string;
1765
+ /**
1766
+ * `placement: "bubble"` only. Cards on the home screen that each start a
1767
+ * conversation with a preset message.
1768
+ */
1769
+ conversationStarters?: ConversationStarter[];
1770
+ /**
1771
+ * `placement: "bubble"` only. Take the home screen's title, subtitle and
1772
+ * starter cards from the AGO dashboard (`GET /config`) instead of the
1773
+ * options above, the way the hosted widget does. One request on mount; the
1774
+ * home screen renders immediately with whatever was passed in code and
1775
+ * re-renders when the config lands.
1776
+ *
1777
+ * Each part is replaced only when the dashboard has a value for it, so
1778
+ * anything the dashboard leaves empty keeps what the code set. Off by
1779
+ * default: without it the widget makes no config request on mount.
1780
+ *
1781
+ * The dashboard's *widget starter* (a first message the agent sends by
1782
+ * itself) is honored too, on a fresh visit only.
1783
+ */
1784
+ loadHomeConfig?: boolean;
1785
+ /**
1786
+ * `placement: "bubble"` only. On open, reopen the visitor's most recent
1787
+ * conversation if its last message is under two hours old. Defaults to `true`.
1788
+ */
1789
+ autoResume?: boolean;
1790
+ /** `placement: "bubble"` only. Translate the chrome's strings. */
1791
+ labels?: Partial<Omit<WidgetLabels, "timeAgo">> & {
1792
+ timeAgo?: Partial<WidgetLabels["timeAgo"]>;
1793
+ };
1464
1794
  /**
1465
1795
  * For side placements, render the built-in floating launcher button that opens
1466
1796
  * the panel (plus a close "×" in the header). Set `false` to drive open/close
@@ -1552,6 +1882,30 @@ export declare interface MountChatWidgetOptions {
1552
1882
  * nullish value to fall back to the default text.
1553
1883
  */
1554
1884
  formSubmittedMessage?: string | ((result: unknown) => string | null | undefined);
1885
+ /**
1886
+ * Let the visitor report an answer that did not work: a thumbs up/down row
1887
+ * under each finished answer, and after a thumbs-down a small panel to say
1888
+ * what went wrong (reason chips plus a free-text comment).
1889
+ *
1890
+ * `true` turns it on with English labels. Pass an object to translate the
1891
+ * strings, skip the "why" panel, or observe what was sent. Off by default.
1892
+ *
1893
+ * ```ts
1894
+ * mountChatWidget("#chat", {
1895
+ * config: { baseUrl: "https://playground.api.useago.com", agent: "generic-guide" },
1896
+ * feedback: true,
1897
+ * });
1898
+ * ```
1899
+ *
1900
+ * The thumb is sent as soon as it is clicked, so the signal is never lost if
1901
+ * the visitor ignores the panel; the panel then files the detailed report.
1902
+ */
1903
+ feedback?: boolean | WidgetFeedbackOptions;
1904
+ /**
1905
+ * The ticket form the agent can open in the conversation (labels, success
1906
+ * text, callbacks). See {@link WidgetToolCallFormOptions}.
1907
+ */
1908
+ toolCallForm?: WidgetToolCallFormOptions;
1555
1909
  /**
1556
1910
  * How clicking a suggested follow-up reply behaves. Defaults to sending the
1557
1911
  * reply as a new user message. Pass a handler to override, or `false` to
@@ -1776,12 +2130,29 @@ declare interface ProactiveTriggerWhen {
1776
2130
  pageState?: Partial<Record<string, unknown>>;
1777
2131
  /** Min rage-click bursts on the current route. */
1778
2132
  rageClicks?: number;
2133
+ /**
2134
+ * Min JavaScript errors captured on the current route. Needs the client's
2135
+ * `errorWatcher` enabled; without it the count stays at 0 and the matcher
2136
+ * never passes.
2137
+ */
2138
+ jsErrors?: number;
1779
2139
  /** Min A→B→A→B route oscillations this session. */
1780
2140
  routeBounces?: number;
1781
2141
  /** Per-field minimum error counts (field NAME → min count). */
1782
2142
  fieldErrors?: Record<string, number>;
1783
2143
  }
1784
2144
 
2145
+ /**
2146
+ * Pick a legible foreground for a tenant-chosen background, which may be a
2147
+ * solid color or a gradient. A gradient is judged by its least-contrasting
2148
+ * stop, since the text has to survive the whole sweep.
2149
+ *
2150
+ * Deliberately biased toward white: it flips to black only below 3:1, where
2151
+ * white stops being readable at all. Unparseable input (a `var()`, a named
2152
+ * color) keeps white, which is what the default dark header wants.
2153
+ */
2154
+ export declare function readableTextColor(background: string | undefined): string;
2155
+
1785
2156
  /**
1786
2157
  * Tiny, dependency-free markdown → DOM renderer for the vanilla chat widget.
1787
2158
  *
@@ -1821,10 +2192,69 @@ declare type ResumeGate = (info: {
1821
2192
  messageId: string;
1822
2193
  }) => Promise<void> | void;
1823
2194
 
2195
+ /** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
2196
+ declare interface SdkConfig {
2197
+ permissions: SdkPermissionConfig[];
2198
+ proactive: {
2199
+ enabled: boolean;
2200
+ };
2201
+ }
2202
+
2203
+ /** The dashboard's home screen content (title, subtitle, starter cards). */
2204
+ declare interface SdkHomePageConfig {
2205
+ title?: string;
2206
+ /** Markdown. */
2207
+ subtitle?: string;
2208
+ starters: SdkHomeStarter[];
2209
+ widgetStarter?: SdkWidgetStarter;
2210
+ }
2211
+
2212
+ /**
2213
+ * A conversation starter card configured in the AGO dashboard. `label` is what
2214
+ * the card shows; clicking it sends `message`.
2215
+ */
2216
+ declare interface SdkHomeStarter {
2217
+ id: string;
2218
+ /** The card's text (the starter's `description` in the dashboard). */
2219
+ label: string;
2220
+ /** What is sent when the card is clicked. */
2221
+ message: string;
2222
+ /** Answer with this agent instead of the configured default. */
2223
+ agentId?: string;
2224
+ }
2225
+
2226
+ /** One permission's configuration in {@link SdkConfig}. */
2227
+ declare interface SdkPermissionConfig {
2228
+ id?: string;
2229
+ name?: string;
2230
+ displayName?: string;
2231
+ agents: Array<{
2232
+ id: string;
2233
+ name?: string;
2234
+ }>;
2235
+ ticketForm?: TicketForm;
2236
+ /** Home screen content, when the tenant configured one. */
2237
+ homePage?: SdkHomePageConfig;
2238
+ fileAttachmentsEnabled: boolean;
2239
+ voiceEnabled: boolean;
2240
+ }
2241
+
2242
+ /**
2243
+ * The starter the dashboard sends by itself on a fresh visit, before the
2244
+ * visitor types anything.
2245
+ */
2246
+ declare interface SdkWidgetStarter {
2247
+ id: string;
2248
+ message: string;
2249
+ agentId?: string;
2250
+ }
2251
+
1824
2252
  /**
1825
2253
  * Options for sending a message
1826
2254
  */
1827
2255
  declare interface SendMessageOptions {
2256
+ /** Replaces config.metadata for this message; null omits metadata for this message. */
2257
+ metadata?: Record<string, unknown> | null;
1828
2258
  /** Existing conversation ID */
1829
2259
  conversationId?: string;
1830
2260
  /** Override default agent */
@@ -1955,6 +2385,12 @@ declare interface SignalsSnapshot {
1955
2385
  idleMs: number;
1956
2386
  /** Rage-click bursts detected on the current route. */
1957
2387
  rageClicks: number;
2388
+ /**
2389
+ * JavaScript errors captured on the current route (count only; the messages
2390
+ * travel in `client_context` under `errors:recent`). Always `0` unless the
2391
+ * client has `errorWatcher` enabled.
2392
+ */
2393
+ jsErrors: number;
1958
2394
  /**
1959
2395
  * A→B→A→B route oscillations detected in the recent route sequence. Rolling
1960
2396
  * session counter (cross-route by nature); trigger cooldowns and dismissal
@@ -2013,6 +2449,13 @@ declare interface SSEChunkData {
2013
2449
  follow_up_replies?: string[];
2014
2450
  satisfaction_feedback?: unknown;
2015
2451
  ask_to_talk_to_human?: boolean;
2452
+ allowed_to_create_ticket?: boolean;
2453
+ ticket?: ToolCallTicketPrefill;
2454
+ mode?: "form" | "embed";
2455
+ ticket_form_id?: string;
2456
+ embed_html?: string;
2457
+ embed_description?: string;
2458
+ display_mode?: "collapsible" | "display" | "both";
2016
2459
  /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
2017
2460
  waiting_tool_call_ids?: string[];
2018
2461
  }
@@ -2066,12 +2509,82 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
2066
2509
  declare interface SubmitToolCallResult {
2067
2510
  status: string;
2068
2511
  result?: unknown;
2512
+ /** Set when `status` is `"error"`. */
2513
+ error?: string;
2514
+ /** The ticket a ticketing `form` tool call resolved to, when it did. */
2515
+ ticket?: {
2516
+ ticket_id: string;
2517
+ ticket_url?: string;
2518
+ [key: string]: unknown;
2519
+ };
2069
2520
  resume?: {
2070
2521
  message_id: string;
2071
2522
  ready: boolean;
2072
2523
  };
2073
2524
  }
2074
2525
 
2526
+ /** A custom field of a ticket form. */
2527
+ declare interface TicketField {
2528
+ id: string;
2529
+ /** The key the ticketing backend expects; used as the submit key when set. */
2530
+ externalId?: string;
2531
+ title?: string;
2532
+ /** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
2533
+ type?: string;
2534
+ required: boolean;
2535
+ /** Carried in the submission but never shown. */
2536
+ hidden: boolean;
2537
+ active?: boolean;
2538
+ /** Bypass progressive disclosure, while still respecting conditions. */
2539
+ alwaysVisible?: boolean;
2540
+ regexpForValidation?: string;
2541
+ position: number;
2542
+ /** Non-empty turns the field into a select. */
2543
+ options: TicketFieldOption[];
2544
+ /** Show this field only when the parent field holds `conditionalFieldValue`. */
2545
+ conditionalFieldId?: string;
2546
+ /** Legacy comma-separated condition values. */
2547
+ conditionalFieldValue?: string;
2548
+ /** Takes precedence over conditionalFieldValue when non-empty. */
2549
+ conditionalFieldValues?: string[];
2550
+ }
2551
+
2552
+ /** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
2553
+ declare interface TicketFieldOption {
2554
+ id: string;
2555
+ /** Label shown to the user. */
2556
+ name?: string;
2557
+ /** Value submitted. Falls back to `name` when absent. */
2558
+ value?: string;
2559
+ /** Preselected when the form opens. */
2560
+ default: boolean;
2561
+ /** A note shown under the field once this option is picked. */
2562
+ message?: string;
2563
+ messageType: "info" | "warning" | "danger";
2564
+ position?: number;
2565
+ group?: string;
2566
+ noDisplay?: boolean;
2567
+ conditionalFieldId?: string;
2568
+ /** Available when the parent matches any of these values. */
2569
+ conditionalFieldValues?: string[];
2570
+ }
2571
+
2572
+ /** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
2573
+ declare interface TicketForm {
2574
+ id: string;
2575
+ name?: string;
2576
+ /** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
2577
+ mode: "form" | "embed";
2578
+ showSubject: boolean;
2579
+ showBody: boolean;
2580
+ showPriority: boolean;
2581
+ showTypology: boolean;
2582
+ priorityTypologies?: string[];
2583
+ successMessageText?: string;
2584
+ successMessageUrlLabel?: string;
2585
+ fields: TicketField[];
2586
+ }
2587
+
2075
2588
  /**
2076
2589
  * Tool call data from SSE stream
2077
2590
  */
@@ -2086,6 +2599,93 @@ declare interface ToolCallData {
2086
2599
  data?: Record<string, unknown>;
2087
2600
  functionName?: string;
2088
2601
  arguments?: Record<string, unknown>;
2602
+ /**
2603
+ * Where the hosted widget shows the call: in the collapsible "reasoning"
2604
+ * section, in the message body, or both. Absent means collapsible only.
2605
+ */
2606
+ displayMode?: "collapsible" | "display" | "both";
2607
+ /** The user asked to talk to a human. */
2608
+ askToTalkToHuman?: boolean;
2609
+ /** `false` when the tenant blocks ticket creation for this visitor. */
2610
+ allowedToCreateTicket?: boolean;
2611
+ /** Fields the agent pre-filled from the conversation. */
2612
+ ticket?: ToolCallTicketPrefill;
2613
+ /** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
2614
+ mode?: "form" | "embed";
2615
+ ticketFormId?: string;
2616
+ embedHtml?: string;
2617
+ embedDescription?: string;
2618
+ }
2619
+
2620
+ /**
2621
+ * Every string the ticket form and its surrounding chrome show, with the
2622
+ * hosted widget's English defaults, so a non-English site can translate them
2623
+ * through `toolCallForm.labels`.
2624
+ */
2625
+ export declare interface ToolCallFormLabels {
2626
+ useFormToCreateTicket: string;
2627
+ yourEmail: string;
2628
+ emailPlaceholder: string;
2629
+ emailRequired: string;
2630
+ emailInvalid: string;
2631
+ subject: string;
2632
+ subjectRequired: string;
2633
+ typology: string;
2634
+ selectTypology: string;
2635
+ typologyRequired: string;
2636
+ question: string;
2637
+ task: string;
2638
+ incident: string;
2639
+ priority: string;
2640
+ selectPriority: string;
2641
+ priorityRequired: string;
2642
+ low: string;
2643
+ normal: string;
2644
+ high: string;
2645
+ urgent: string;
2646
+ detailedContext: string;
2647
+ detailedContextRequired: string;
2648
+ /** `{fieldTitle}` is substituted. */
2649
+ fieldRequired: string;
2650
+ fieldFormatInvalid: string;
2651
+ attachments: string;
2652
+ selectFile: string;
2653
+ submit: string;
2654
+ loading: string;
2655
+ maxCharacters: string;
2656
+ ticketSubmitted: string;
2657
+ findTicketHere: string;
2658
+ noTicketForm: string;
2659
+ notAllowed: string;
2660
+ submissionFailed: string;
2661
+ submissionFailedDescription: string;
2662
+ fileTooLarge: string;
2663
+ permissionDenied: string;
2664
+ validationFailed: string;
2665
+ pleaseCheckFields: string;
2666
+ embeddedFormSubmitted: string;
2667
+ noEmbedConfigured: string;
2668
+ embedSubmitTimeout: string;
2669
+ tryAgain: string;
2670
+ contactFormCreated: string;
2671
+ contactFormRejected: string;
2672
+ genericFormComingSoon: string;
2673
+ unknownToolCall: string;
2674
+ formPending: string;
2675
+ ticketCreatedBlocked: string;
2676
+ newConversation: string;
2677
+ }
2678
+
2679
+ /** The ticket the agent pre-filled on a ticketing `form` tool call. */
2680
+ declare interface ToolCallTicketPrefill {
2681
+ subject?: string;
2682
+ body?: string;
2683
+ typology?: string;
2684
+ priority?: string;
2685
+ tag?: string;
2686
+ products?: string[];
2687
+ /** Keyed by the field's external id, or a lowercased, underscored title. */
2688
+ custom_fields?: Record<string, string>;
2089
2689
  }
2090
2690
 
2091
2691
  declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
@@ -2117,6 +2717,86 @@ export declare type WelcomeMessage = string | {
2117
2717
  followUpReplies?: string[];
2118
2718
  };
2119
2719
 
2720
+ /** Fine-tuning for {@link MountChatWidgetOptions.feedback}. */
2721
+ export declare interface WidgetFeedbackOptions {
2722
+ /**
2723
+ * After a thumbs-down, open the panel asking what went wrong. Default `true`;
2724
+ * set `false` to collect thumbs only.
2725
+ */
2726
+ askWhy?: boolean;
2727
+ /**
2728
+ * Override any of the row's strings (all English by default). Reason labels
2729
+ * can be overridden one by one.
2730
+ */
2731
+ labels?: Partial<Omit<FeedbackLabels, "reasons">> & {
2732
+ reasons?: Partial<Record<FeedbackReason, string>>;
2733
+ };
2734
+ /**
2735
+ * Called after a report was accepted by the API. Fires once per accepted
2736
+ * report, so a thumbs-down followed by the panel calls it twice: first for
2737
+ * the bare thumb, then for the detailed report.
2738
+ */
2739
+ onSubmit?: (report: {
2740
+ messageId: string;
2741
+ rating: FeedbackRating;
2742
+ reasons: FeedbackReason[];
2743
+ comment?: string;
2744
+ }) => void;
2745
+ /** Called when a report could not be sent. The row keeps its state. */
2746
+ onError?: (error: Error) => void;
2747
+ }
2748
+
2749
+ /**
2750
+ * Every string the bubble widget's chrome shows (header, footer, home,
2751
+ * history, errors), so a non-English site can translate them. Message-level
2752
+ * strings live in {@link WidgetFeedbackOptions.labels}.
2753
+ */
2754
+ export declare interface WidgetLabels {
2755
+ /** Footer tab. */
2756
+ home: string;
2757
+ /** Footer tab. */
2758
+ chats: string;
2759
+ /** Header title on the history screen. */
2760
+ history: string;
2761
+ /** The floating pill on the history screen, and a thread without a title. */
2762
+ newConversation: string;
2763
+ /** Empty history screen. */
2764
+ noHistory: string;
2765
+ /** Composer placeholder on the home screen. */
2766
+ askQuestion: string;
2767
+ /** Accessible name of the header back button. */
2768
+ back: string;
2769
+ /** Accessible name of the header close button. */
2770
+ close: string;
2771
+ /** Accessible name of the header new-chat button. */
2772
+ newChat: string;
2773
+ /** Title of the alert shown on a failed answer. */
2774
+ errorTitle: string;
2775
+ /** Body of the alert shown on a failed answer. */
2776
+ errorDescription: string;
2777
+ /** Accessible name of the scroll-to-bottom button. */
2778
+ scrollToBottom: string;
2779
+ /** Label of the button that hides a file error. */
2780
+ dismiss: string;
2781
+ /** Accessible name of the attach button. */
2782
+ attachFiles: string;
2783
+ /** Composer file errors; `{max}` / `{name}` are substituted. */
2784
+ tooManyFiles: string;
2785
+ invalidFileType: string;
2786
+ fileTooLarge: string;
2787
+ /** Relative time templates on the history screen; `{n}` is the count. */
2788
+ timeAgo: {
2789
+ minutes: string;
2790
+ hours: string;
2791
+ days: string;
2792
+ weeks: string;
2793
+ months: string;
2794
+ };
2795
+ }
2796
+
2797
+ /** The three screens of the bubble widget (`placement: "bubble"`). */
2798
+ export declare type WidgetScreen = "home" | "chat" | "history";
2799
+
2120
2800
  /**
2121
2801
  * Theme overrides for `mountChatWidget`. The keys map to `--ago-*` custom
2122
2802
  * properties (see `THEME_VARS` in `./styles`).
@@ -2151,6 +2831,54 @@ export declare interface WidgetTheme {
2151
2831
  accent?: string;
2152
2832
  /** Background of assistant message bubbles when `agentBubble` is on. Defaults to a light gray. (`--ago-agent-bubble-background`) */
2153
2833
  agentBubbleBg?: string;
2834
+ /** Text color inside assistant messages. Defaults to `text`. (`--ago-agent-bubble-text-color`) */
2835
+ agentBubbleText?: string;
2836
+ /** User message card background. `placement: "bubble"` only; defaults to white there. (`--ago-user-bubble-background`) */
2837
+ userBubbleBg?: string;
2838
+ /** User message text color. `placement: "bubble"` only. (`--ago-user-bubble-text-color`) */
2839
+ userBubbleText?: string;
2840
+ /** Floating launcher circle. `placement: "bubble"` only; defaults to `#007bff`. (`--ago-launcher-background`) */
2841
+ launcherBg?: string;
2842
+ /** Glyph color on the launcher. (`--ago-launcher-text-color`) */
2843
+ launcherText?: string;
2844
+ /** Composer send/stop button. `placement: "bubble"` only; defaults to `brand`. (`--ago-send-button-background`) */
2845
+ sendBg?: string;
2846
+ /** Panel width for `placement: "bubble"`, e.g. `"700px"`. Defaults to `550px`. (`--ago-panel-width`) */
2847
+ panelWidth?: string;
2848
+ }
2849
+
2850
+ /**
2851
+ * Fine-tuning for the ticket form the agent's `ago_ticketing` tool opens in
2852
+ * the conversation (the `form` tool call). The form is always on: a tool call
2853
+ * the widget ignored would leave the visitor stuck.
2854
+ */
2855
+ export declare interface WidgetToolCallFormOptions {
2856
+ /** Translate any of the form's strings. */
2857
+ labels?: Partial<ToolCallFormLabels>;
2858
+ /** Replace the success text once the ticket exists. */
2859
+ successMessage?: string;
2860
+ /** Replace the "You can find it here:" label before the ticket link. */
2861
+ successUrlLabel?: string;
2862
+ /**
2863
+ * Email of the visitor when the SDK has no identity for them (no `userEmail`
2864
+ * or `userJwt` in the client config). When absent, the form asks for it.
2865
+ */
2866
+ userEmail?: string;
2867
+ /** Called once the ticket exists and the tool call is completed. */
2868
+ onSubmitted?: (data: {
2869
+ toolCallId: string;
2870
+ toolName: string;
2871
+ mode: "form" | "embed";
2872
+ ticket?: {
2873
+ id: string;
2874
+ url?: string;
2875
+ };
2876
+ values: Record<string, unknown>;
2877
+ }) => void;
2878
+ /** Called when creating the ticket or completing the tool call failed. */
2879
+ onError?: (error: Error) => void;
2880
+ /** Called when the visitor starts a new conversation from the blocked composer. */
2881
+ onNewConversation?: () => void;
2154
2882
  }
2155
2883
 
2156
2884
  export { }