@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/vue.d.ts CHANGED
@@ -61,6 +61,7 @@ declare class AgoClient {
61
61
  private contextRegistry;
62
62
  private eventEmitter;
63
63
  private activityLedger;
64
+ private errorWatcher;
64
65
  private lastSentPageState;
65
66
  private config;
66
67
  /** Conversations already warned about an empty reply (one warning each). */
@@ -230,6 +231,26 @@ declare class AgoClient {
230
231
  * `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
231
232
  */
232
233
  private static mapPersistedToolCalls;
234
+ /**
235
+ * The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
236
+ * agents, the ticket form the agent's `ago_ticketing` tool opens, and the
237
+ * file-attachment flag. The vanilla widget fetches it once, when a ticket
238
+ * form first appears in a conversation.
239
+ */
240
+ getConfig(): Promise<SdkConfig>;
241
+ /**
242
+ * The dashboard's home screen content. A starter card shows its
243
+ * `description` and sends its `initial_message`; one with neither is
244
+ * unusable and is dropped rather than rendered as an empty card.
245
+ */
246
+ private static mapHomePage;
247
+ private static mapTicketForm;
248
+ /**
249
+ * Create a support ticket (`POST /api/sdk/v1/tickets`, multipart). This is
250
+ * what the ticket form in the conversation does before it completes the
251
+ * `form` tool call with {@link submitToolCallForm}.
252
+ */
253
+ createTicket(input: CreateTicketInput): Promise<CreateTicketResult>;
233
254
  /**
234
255
  * Get messages for a conversation
235
256
  */
@@ -281,9 +302,40 @@ declare class AgoClient {
281
302
  */
282
303
  submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
283
304
  /**
284
- * Submit feedback for a message
305
+ * Report an answer: thumbs up/down, optionally with what went wrong.
306
+ *
307
+ * ```ts
308
+ * await client.submitFeedback(message.id, "negative", {
309
+ * reasons: ["inaccurate"],
310
+ * comment: "The price it quoted is from last year.",
311
+ * });
312
+ * ```
313
+ *
314
+ * A bare rating is a reaction (the thumbs counted in the dashboard). Adding a
315
+ * reason or a comment also files it in the feedback list, the analytics and
316
+ * the CSV export, so someone can act on it.
317
+ */
318
+ submitFeedback(messageId: string, rating: FeedbackRating, details?: FeedbackDetails): Promise<void>;
319
+ /**
320
+ * Report a whole conversation ("this chat is not working").
321
+ *
322
+ * ```ts
323
+ * await client.submitConversationFeedback(conversationId, "negative", {
324
+ * reasons: ["information_not_found"],
325
+ * comment: "It never answered my question.",
326
+ * });
327
+ * ```
328
+ *
329
+ * Feedback is stored per message, so this attaches the report to the last
330
+ * answer of the conversation, which is the one the user is reacting to.
331
+ * Returns the message id it landed on.
332
+ *
333
+ * Pass `lastMessageId` when you already have it (the widget does) to skip the
334
+ * lookup round-trip.
285
335
  */
286
- submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
336
+ submitConversationFeedback(conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
337
+ lastMessageId?: string;
338
+ }): Promise<string>;
287
339
  /**
288
340
  * Register a client-side function that AGO can call.
289
341
  * Accepts either a definition object or (name, handler, schema) args.
@@ -457,6 +509,15 @@ declare class AgoClient {
457
509
  /* Excluded from this release type: emitProactiveEvent */
458
510
  /* Excluded from this release type: getHttp */
459
511
  /* Excluded from this release type: getConfiguredAgent */
512
+ /**
513
+ * How the SDK identifies the visitor: the configured `userEmail`, and
514
+ * whether a `userJwt` is set. The ticket form asks for an email when it has
515
+ * neither.
516
+ */
517
+ getUserIdentity(): {
518
+ email?: string;
519
+ hasJwt: boolean;
520
+ };
460
521
  /**
461
522
  * Enable automatic capture of the current browser page (URL + title).
462
523
  * Injected as a dynamic context entry named `browser-page`.
@@ -479,6 +540,26 @@ declare class AgoClient {
479
540
  private addActivity;
480
541
  private recordAgentAction;
481
542
  private registerActivityContext;
543
+ /**
544
+ * Start capturing the page's JavaScript errors (uncaught exceptions,
545
+ * unhandled rejections, `console.error` calls, {@link reportError}) and send
546
+ * the recent ones as the `errors:recent` context entry on every message.
547
+ * Same as setting `errorWatcher` in the config. Calling it again replaces
548
+ * the watcher (and its options); the captured errors are not kept.
549
+ */
550
+ enableErrorWatcher(options?: ErrorWatcherOptions): void;
551
+ /** Stop capturing errors and drop the `errors:recent` context entry. */
552
+ disableErrorWatcher(): void;
553
+ /**
554
+ * Record an error the app caught itself (React error boundary, Vue
555
+ * `errorHandler`, Angular `ErrorHandler`, a try/catch) so the agent sees it
556
+ * like an uncaught one. No-op unless the error watcher is enabled. `context`
557
+ * is size-clamped before it is stored; keep it small and free of secrets.
558
+ */
559
+ reportError(error: unknown, context?: Record<string, unknown>): void;
560
+ /** Errors the watcher currently holds, oldest first (a copy). Empty when disabled. */
561
+ getRecentErrors(): CapturedError[];
562
+ clearErrors(): void;
482
563
  /**
483
564
  * Subscribe to an event
484
565
  */
@@ -673,6 +754,12 @@ declare interface AgoClientEvents {
673
754
  };
674
755
  /** A user- or agent-action was recorded into the activity ledger. */
675
756
  "activity:recorded": ActivityEntry;
757
+ /**
758
+ * The error watcher captured a JavaScript error (uncaught exception,
759
+ * unhandled rejection, `console.error` call, or `reportError`). Fires on
760
+ * repeats too, with the updated `count`. Requires `errorWatcher` in the config.
761
+ */
762
+ "error:captured": CapturedError;
676
763
  }
677
764
 
678
765
  /**
@@ -693,6 +780,8 @@ export declare interface AgoConfig {
693
780
  userEmail?: string;
694
781
  /** JWT token for authenticated users */
695
782
  userJwt?: string;
783
+ /** User metadata sent with messages. Use null to stop sending defaults. Not an authentication credential. */
784
+ metadata?: Record<string, unknown> | null;
696
785
  /** Enable debug logging */
697
786
  debug?: boolean;
698
787
  /**
@@ -752,6 +841,18 @@ export declare interface AgoConfig {
752
841
  * default otherwise.
753
842
  */
754
843
  proactive?: ProactiveOptions;
844
+ /**
845
+ * Capture the page's JavaScript errors as agent context. When set, the SDK
846
+ * listens for uncaught exceptions and unhandled promise rejections, wraps
847
+ * `console.error` (calling through; restored on `destroy`), and sends the
848
+ * recent errors (deduplicated, capped, pruned after 10 min) as the
849
+ * `errors:recent` context entry on every message. `true` uses the defaults;
850
+ * pass {@link ErrorWatcherOptions} to tune the caps or add a `filter` that
851
+ * redacts messages. Off by default: error messages can carry PII or internal
852
+ * URLs, so enabling it is the host's call. Errors also feed the proactive
853
+ * mode's `jsErrors` signal. See `client.reportError()` for caught errors.
854
+ */
855
+ errorWatcher?: boolean | ErrorWatcherOptions;
755
856
  }
756
857
 
757
858
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -936,12 +1037,53 @@ export declare interface AgoStateControl<T = unknown> {
936
1037
  enum?: (string | number)[];
937
1038
  };
938
1039
  };
1040
+ /** String-only: `""` means "clear" instead of being dropped as filler. */
1041
+ clearable?: boolean;
939
1042
  /** Current value → pushed as dynamic context so the agent knows what to change. */
940
1043
  get?: () => T;
941
1044
  /** Apply the state change on the page. May be async. */
942
- set: (value: T) => void | Promise<void>;
1045
+ set: (value: T) => void | AgoStateSetResult | Promise<void | AgoStateSetResult>;
943
1046
  }
944
1047
 
1048
+ /**
1049
+ * Tagged outcome a page setter may return to reject or mark unchanged.
1050
+ *
1051
+ * Returning nothing (void) means APPLY. Returning an unrecognized JS value
1052
+ * (e.g. a string from an assignment expression) is also treated as APPLY.
1053
+ */
1054
+ declare type AgoStateSetResult = {
1055
+ result: "rejected";
1056
+ reason: string;
1057
+ } | {
1058
+ result: "unchanged";
1059
+ };
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
  /**
946
1088
  * Single-object function definition — combines name, schema, and handler.
947
1089
  *
@@ -1075,6 +1217,30 @@ export declare interface Conversation {
1075
1217
  messages?: AgoMessage[];
1076
1218
  }
1077
1219
 
1220
+ /** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
1221
+ declare interface CreateTicketInput {
1222
+ subject: string;
1223
+ body: string;
1224
+ priority?: string;
1225
+ typology?: string;
1226
+ /** Conversation the ticket is filed from. */
1227
+ conversationId?: string;
1228
+ /** Reporter email, for a visitor the SDK does not otherwise identify. */
1229
+ email?: string;
1230
+ customFields?: Array<{
1231
+ id: string;
1232
+ value: string;
1233
+ }>;
1234
+ files?: File[];
1235
+ ticketFormId?: string;
1236
+ }
1237
+
1238
+ /** Response of `AgoClient.createTicket`. */
1239
+ declare interface CreateTicketResult {
1240
+ id: string;
1241
+ url?: string;
1242
+ }
1243
+
1078
1244
  /**
1079
1245
  * A function that returns a fresh context entry on demand.
1080
1246
  * Evaluated every time a message is sent — use it to pull data from stores,
@@ -1082,6 +1248,57 @@ export declare interface Conversation {
1082
1248
  */
1083
1249
  declare type DynamicContextProvider = () => ContextEntry | null | undefined;
1084
1250
 
1251
+ declare interface ErrorWatcherOptions {
1252
+ /** Max distinct errors kept. Oldest dropped first. Default 10. */
1253
+ maxErrors?: number;
1254
+ /**
1255
+ * Errors older than this are pruned when the buffer is read, so a crash from
1256
+ * an hour ago does not confuse the agent. Default 600 000 (10 min).
1257
+ */
1258
+ maxAgeMs?: number;
1259
+ /** Max chars of stack kept per error. Default 2000. */
1260
+ maxStackChars?: number;
1261
+ /**
1262
+ * Redact or drop an error before it is stored. Return the (possibly edited)
1263
+ * error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
1264
+ */
1265
+ filter?: (error: CapturedError) => CapturedError | null;
1266
+ }
1267
+
1268
+ /** The four values of {@link FeedbackReason}, in dashboard order. */
1269
+ export declare const FEEDBACK_REASONS: readonly FeedbackReason[];
1270
+
1271
+ /**
1272
+ * Why the user is reporting a message (see `AgoClient.submitFeedback`).
1273
+ *
1274
+ * A rating on its own is a reaction (the thumbs count). Add a reason or a
1275
+ * comment and the report also lands in the feedback dashboard, the analytics
1276
+ * and the CSV export, where someone can act on it.
1277
+ */
1278
+ export declare interface FeedbackDetails {
1279
+ /** What went wrong. Several can apply at once. */
1280
+ reasons?: FeedbackReason[];
1281
+ /** The user's own words. Trimmed server-side; 5000 characters max. */
1282
+ comment?: string;
1283
+ }
1284
+
1285
+ /** Thumbs up / thumbs down on an answer. */
1286
+ export declare type FeedbackRating = "positive" | "negative";
1287
+
1288
+ /**
1289
+ * What went wrong with an answer. These are the four buckets the AGO feedback
1290
+ * dashboard filters and charts on.
1291
+ */
1292
+ export declare type FeedbackReason =
1293
+ /** The answer states something false. */
1294
+ "inaccurate"
1295
+ /** The answer is right but stops short. */
1296
+ | "incomplete"
1297
+ /** The agent could not find the information. */
1298
+ | "information_not_found"
1299
+ /** Something broke: the widget, a tool call, the stream. */
1300
+ | "technical_issue";
1301
+
1085
1302
  /**
1086
1303
  * The backend-stored shape returned by `GET /api/sdk/v1/forms/{name}` (see
1087
1304
  * {@link AgoClient.getFormCollector}). Mirrors the persistable subset of
@@ -1427,6 +1644,12 @@ declare interface ProactiveTriggerWhen {
1427
1644
  pageState?: Partial<Record<string, unknown>>;
1428
1645
  /** Min rage-click bursts on the current route. */
1429
1646
  rageClicks?: number;
1647
+ /**
1648
+ * Min JavaScript errors captured on the current route. Needs the client's
1649
+ * `errorWatcher` enabled; without it the count stays at 0 and the matcher
1650
+ * never passes.
1651
+ */
1652
+ jsErrors?: number;
1430
1653
  /** Min A→B→A→B route oscillations this session. */
1431
1654
  routeBounces?: number;
1432
1655
  /** Per-field minimum error counts (field NAME → min count). */
@@ -1444,10 +1667,69 @@ declare type ResumeGate = (info: {
1444
1667
  messageId: string;
1445
1668
  }) => Promise<void> | void;
1446
1669
 
1670
+ /** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
1671
+ declare interface SdkConfig {
1672
+ permissions: SdkPermissionConfig[];
1673
+ proactive: {
1674
+ enabled: boolean;
1675
+ };
1676
+ }
1677
+
1678
+ /** The dashboard's home screen content (title, subtitle, starter cards). */
1679
+ declare interface SdkHomePageConfig {
1680
+ title?: string;
1681
+ /** Markdown. */
1682
+ subtitle?: string;
1683
+ starters: SdkHomeStarter[];
1684
+ widgetStarter?: SdkWidgetStarter;
1685
+ }
1686
+
1687
+ /**
1688
+ * A conversation starter card configured in the AGO dashboard. `label` is what
1689
+ * the card shows; clicking it sends `message`.
1690
+ */
1691
+ declare interface SdkHomeStarter {
1692
+ id: string;
1693
+ /** The card's text (the starter's `description` in the dashboard). */
1694
+ label: string;
1695
+ /** What is sent when the card is clicked. */
1696
+ message: string;
1697
+ /** Answer with this agent instead of the configured default. */
1698
+ agentId?: string;
1699
+ }
1700
+
1701
+ /** One permission's configuration in {@link SdkConfig}. */
1702
+ declare interface SdkPermissionConfig {
1703
+ id?: string;
1704
+ name?: string;
1705
+ displayName?: string;
1706
+ agents: Array<{
1707
+ id: string;
1708
+ name?: string;
1709
+ }>;
1710
+ ticketForm?: TicketForm;
1711
+ /** Home screen content, when the tenant configured one. */
1712
+ homePage?: SdkHomePageConfig;
1713
+ fileAttachmentsEnabled: boolean;
1714
+ voiceEnabled: boolean;
1715
+ }
1716
+
1717
+ /**
1718
+ * The starter the dashboard sends by itself on a fresh visit, before the
1719
+ * visitor types anything.
1720
+ */
1721
+ declare interface SdkWidgetStarter {
1722
+ id: string;
1723
+ message: string;
1724
+ agentId?: string;
1725
+ }
1726
+
1447
1727
  /**
1448
1728
  * Options for sending a message
1449
1729
  */
1450
1730
  declare interface SendMessageOptions {
1731
+ /** Replaces config.metadata for this message; null omits metadata for this message. */
1732
+ metadata?: Record<string, unknown> | null;
1451
1733
  /** Existing conversation ID */
1452
1734
  conversationId?: string;
1453
1735
  /** Override default agent */
@@ -1496,6 +1778,12 @@ declare interface SignalsSnapshot {
1496
1778
  idleMs: number;
1497
1779
  /** Rage-click bursts detected on the current route. */
1498
1780
  rageClicks: number;
1781
+ /**
1782
+ * JavaScript errors captured on the current route (count only; the messages
1783
+ * travel in `client_context` under `errors:recent`). Always `0` unless the
1784
+ * client has `errorWatcher` enabled.
1785
+ */
1786
+ jsErrors: number;
1499
1787
  /**
1500
1788
  * A→B→A→B route oscillations detected in the recent route sequence. Rolling
1501
1789
  * session counter (cross-route by nature); trigger cooldowns and dismissal
@@ -1554,6 +1842,13 @@ declare interface SSEChunkData {
1554
1842
  follow_up_replies?: string[];
1555
1843
  satisfaction_feedback?: unknown;
1556
1844
  ask_to_talk_to_human?: boolean;
1845
+ allowed_to_create_ticket?: boolean;
1846
+ ticket?: ToolCallTicketPrefill;
1847
+ mode?: "form" | "embed";
1848
+ ticket_form_id?: string;
1849
+ embed_html?: string;
1850
+ embed_description?: string;
1851
+ display_mode?: "collapsible" | "display" | "both";
1557
1852
  /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
1558
1853
  waiting_tool_call_ids?: string[];
1559
1854
  }
@@ -1628,12 +1923,82 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
1628
1923
  declare interface SubmitToolCallResult {
1629
1924
  status: string;
1630
1925
  result?: unknown;
1926
+ /** Set when `status` is `"error"`. */
1927
+ error?: string;
1928
+ /** The ticket a ticketing `form` tool call resolved to, when it did. */
1929
+ ticket?: {
1930
+ ticket_id: string;
1931
+ ticket_url?: string;
1932
+ [key: string]: unknown;
1933
+ };
1631
1934
  resume?: {
1632
1935
  message_id: string;
1633
1936
  ready: boolean;
1634
1937
  };
1635
1938
  }
1636
1939
 
1940
+ /** A custom field of a ticket form. */
1941
+ declare interface TicketField {
1942
+ id: string;
1943
+ /** The key the ticketing backend expects; used as the submit key when set. */
1944
+ externalId?: string;
1945
+ title?: string;
1946
+ /** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
1947
+ type?: string;
1948
+ required: boolean;
1949
+ /** Carried in the submission but never shown. */
1950
+ hidden: boolean;
1951
+ active?: boolean;
1952
+ /** Bypass progressive disclosure, while still respecting conditions. */
1953
+ alwaysVisible?: boolean;
1954
+ regexpForValidation?: string;
1955
+ position: number;
1956
+ /** Non-empty turns the field into a select. */
1957
+ options: TicketFieldOption[];
1958
+ /** Show this field only when the parent field holds `conditionalFieldValue`. */
1959
+ conditionalFieldId?: string;
1960
+ /** Legacy comma-separated condition values. */
1961
+ conditionalFieldValue?: string;
1962
+ /** Takes precedence over conditionalFieldValue when non-empty. */
1963
+ conditionalFieldValues?: string[];
1964
+ }
1965
+
1966
+ /** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
1967
+ declare interface TicketFieldOption {
1968
+ id: string;
1969
+ /** Label shown to the user. */
1970
+ name?: string;
1971
+ /** Value submitted. Falls back to `name` when absent. */
1972
+ value?: string;
1973
+ /** Preselected when the form opens. */
1974
+ default: boolean;
1975
+ /** A note shown under the field once this option is picked. */
1976
+ message?: string;
1977
+ messageType: "info" | "warning" | "danger";
1978
+ position?: number;
1979
+ group?: string;
1980
+ noDisplay?: boolean;
1981
+ conditionalFieldId?: string;
1982
+ /** Available when the parent matches any of these values. */
1983
+ conditionalFieldValues?: string[];
1984
+ }
1985
+
1986
+ /** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
1987
+ declare interface TicketForm {
1988
+ id: string;
1989
+ name?: string;
1990
+ /** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
1991
+ mode: "form" | "embed";
1992
+ showSubject: boolean;
1993
+ showBody: boolean;
1994
+ showPriority: boolean;
1995
+ showTypology: boolean;
1996
+ priorityTypologies?: string[];
1997
+ successMessageText?: string;
1998
+ successMessageUrlLabel?: string;
1999
+ fields: TicketField[];
2000
+ }
2001
+
1637
2002
  /**
1638
2003
  * Tool call data from SSE stream
1639
2004
  */
@@ -1648,6 +2013,34 @@ export declare interface ToolCallData {
1648
2013
  data?: Record<string, unknown>;
1649
2014
  functionName?: string;
1650
2015
  arguments?: Record<string, unknown>;
2016
+ /**
2017
+ * Where the hosted widget shows the call: in the collapsible "reasoning"
2018
+ * section, in the message body, or both. Absent means collapsible only.
2019
+ */
2020
+ displayMode?: "collapsible" | "display" | "both";
2021
+ /** The user asked to talk to a human. */
2022
+ askToTalkToHuman?: boolean;
2023
+ /** `false` when the tenant blocks ticket creation for this visitor. */
2024
+ allowedToCreateTicket?: boolean;
2025
+ /** Fields the agent pre-filled from the conversation. */
2026
+ ticket?: ToolCallTicketPrefill;
2027
+ /** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
2028
+ mode?: "form" | "embed";
2029
+ ticketFormId?: string;
2030
+ embedHtml?: string;
2031
+ embedDescription?: string;
2032
+ }
2033
+
2034
+ /** The ticket the agent pre-filled on a ticketing `form` tool call. */
2035
+ declare interface ToolCallTicketPrefill {
2036
+ subject?: string;
2037
+ body?: string;
2038
+ typology?: string;
2039
+ priority?: string;
2040
+ tag?: string;
2041
+ products?: string[];
2042
+ /** Keyed by the field's external id, or a lowercased, underscored title. */
2043
+ custom_fields?: Record<string, string>;
1651
2044
  }
1652
2045
 
1653
2046
  declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
@@ -1806,6 +2199,22 @@ export declare function useChat(options?: UseChatOptions): {
1806
2199
  data?: Record<string, unknown> | undefined;
1807
2200
  functionName?: string | undefined;
1808
2201
  arguments?: Record<string, unknown> | undefined;
2202
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2203
+ askToTalkToHuman?: boolean | undefined;
2204
+ allowedToCreateTicket?: boolean | undefined;
2205
+ ticket?: {
2206
+ subject?: string | undefined;
2207
+ body?: string | undefined;
2208
+ typology?: string | undefined;
2209
+ priority?: string | undefined;
2210
+ tag?: string | undefined;
2211
+ products?: string[] | undefined;
2212
+ custom_fields?: Record<string, string> | undefined;
2213
+ } | undefined;
2214
+ mode?: "form" | "embed" | undefined;
2215
+ ticketFormId?: string | undefined;
2216
+ embedHtml?: string | undefined;
2217
+ embedDescription?: string | undefined;
1809
2218
  }[] | undefined;
1810
2219
  followUpReplies?: string[] | undefined;
1811
2220
  attachments?: {
@@ -1849,6 +2258,22 @@ export declare function useChat(options?: UseChatOptions): {
1849
2258
  data?: Record<string, unknown> | undefined;
1850
2259
  functionName?: string | undefined;
1851
2260
  arguments?: Record<string, unknown> | undefined;
2261
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2262
+ askToTalkToHuman?: boolean | undefined;
2263
+ allowedToCreateTicket?: boolean | undefined;
2264
+ ticket?: {
2265
+ subject?: string | undefined;
2266
+ body?: string | undefined;
2267
+ typology?: string | undefined;
2268
+ priority?: string | undefined;
2269
+ tag?: string | undefined;
2270
+ products?: string[] | undefined;
2271
+ custom_fields?: Record<string, string> | undefined;
2272
+ } | undefined;
2273
+ mode?: "form" | "embed" | undefined;
2274
+ ticketFormId?: string | undefined;
2275
+ embedHtml?: string | undefined;
2276
+ embedDescription?: string | undefined;
1852
2277
  }[] | undefined;
1853
2278
  followUpReplies?: string[] | undefined;
1854
2279
  attachments?: {
@@ -1903,6 +2328,22 @@ export declare function useChat(options?: UseChatOptions): {
1903
2328
  data?: Record<string, unknown> | undefined;
1904
2329
  functionName?: string | undefined;
1905
2330
  arguments?: Record<string, unknown> | undefined;
2331
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2332
+ askToTalkToHuman?: boolean | undefined;
2333
+ allowedToCreateTicket?: boolean | undefined;
2334
+ ticket?: {
2335
+ subject?: string | undefined;
2336
+ body?: string | undefined;
2337
+ typology?: string | undefined;
2338
+ priority?: string | undefined;
2339
+ tag?: string | undefined;
2340
+ products?: string[] | undefined;
2341
+ custom_fields?: Record<string, string> | undefined;
2342
+ } | undefined;
2343
+ mode?: "form" | "embed" | undefined;
2344
+ ticketFormId?: string | undefined;
2345
+ embedHtml?: string | undefined;
2346
+ embedDescription?: string | undefined;
1906
2347
  }[] | undefined;
1907
2348
  followUpReplies?: string[] | undefined;
1908
2349
  attachments?: {
@@ -1951,6 +2392,22 @@ export declare function useChat(options?: UseChatOptions): {
1951
2392
  data?: Record<string, unknown> | undefined;
1952
2393
  functionName?: string | undefined;
1953
2394
  arguments?: Record<string, unknown> | undefined;
2395
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2396
+ askToTalkToHuman?: boolean | undefined;
2397
+ allowedToCreateTicket?: boolean | undefined;
2398
+ ticket?: {
2399
+ subject?: string | undefined;
2400
+ body?: string | undefined;
2401
+ typology?: string | undefined;
2402
+ priority?: string | undefined;
2403
+ tag?: string | undefined;
2404
+ products?: string[] | undefined;
2405
+ custom_fields?: Record<string, string> | undefined;
2406
+ } | undefined;
2407
+ mode?: "form" | "embed" | undefined;
2408
+ ticketFormId?: string | undefined;
2409
+ embedHtml?: string | undefined;
2410
+ embedDescription?: string | undefined;
1954
2411
  }[] | undefined;
1955
2412
  followUpReplies?: string[] | undefined;
1956
2413
  attachments?: {
@@ -2000,6 +2457,22 @@ export declare function useChat(options?: UseChatOptions): {
2000
2457
  data?: Record<string, unknown> | undefined;
2001
2458
  functionName?: string | undefined;
2002
2459
  arguments?: Record<string, unknown> | undefined;
2460
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2461
+ askToTalkToHuman?: boolean | undefined;
2462
+ allowedToCreateTicket?: boolean | undefined;
2463
+ ticket?: {
2464
+ subject?: string | undefined;
2465
+ body?: string | undefined;
2466
+ typology?: string | undefined;
2467
+ priority?: string | undefined;
2468
+ tag?: string | undefined;
2469
+ products?: string[] | undefined;
2470
+ custom_fields?: Record<string, string> | undefined;
2471
+ } | undefined;
2472
+ mode?: "form" | "embed" | undefined;
2473
+ ticketFormId?: string | undefined;
2474
+ embedHtml?: string | undefined;
2475
+ embedDescription?: string | undefined;
2003
2476
  }[] | undefined;
2004
2477
  followUpReplies?: string[] | undefined;
2005
2478
  attachments?: {
@@ -2048,6 +2521,22 @@ export declare function useChat(options?: UseChatOptions): {
2048
2521
  data?: Record<string, unknown> | undefined;
2049
2522
  functionName?: string | undefined;
2050
2523
  arguments?: Record<string, unknown> | undefined;
2524
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2525
+ askToTalkToHuman?: boolean | undefined;
2526
+ allowedToCreateTicket?: boolean | undefined;
2527
+ ticket?: {
2528
+ subject?: string | undefined;
2529
+ body?: string | undefined;
2530
+ typology?: string | undefined;
2531
+ priority?: string | undefined;
2532
+ tag?: string | undefined;
2533
+ products?: string[] | undefined;
2534
+ custom_fields?: Record<string, string> | undefined;
2535
+ } | undefined;
2536
+ mode?: "form" | "embed" | undefined;
2537
+ ticketFormId?: string | undefined;
2538
+ embedHtml?: string | undefined;
2539
+ embedDescription?: string | undefined;
2051
2540
  }[] | undefined;
2052
2541
  followUpReplies?: string[] | undefined;
2053
2542
  attachments?: {
@@ -2117,6 +2606,22 @@ export declare function useConversation(options?: UseConversationOptions): {
2117
2606
  data?: Record<string, unknown> | undefined;
2118
2607
  functionName?: string | undefined;
2119
2608
  arguments?: Record<string, unknown> | undefined;
2609
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2610
+ askToTalkToHuman?: boolean | undefined;
2611
+ allowedToCreateTicket?: boolean | undefined;
2612
+ ticket?: {
2613
+ subject?: string | undefined;
2614
+ body?: string | undefined;
2615
+ typology?: string | undefined;
2616
+ priority?: string | undefined;
2617
+ tag?: string | undefined;
2618
+ products?: string[] | undefined;
2619
+ custom_fields?: Record<string, string> | undefined;
2620
+ } | undefined;
2621
+ mode?: "form" | "embed" | undefined;
2622
+ ticketFormId?: string | undefined;
2623
+ embedHtml?: string | undefined;
2624
+ embedDescription?: string | undefined;
2120
2625
  }[] | undefined;
2121
2626
  followUpReplies?: string[] | undefined;
2122
2627
  attachments?: {
@@ -2165,6 +2670,22 @@ export declare function useConversation(options?: UseConversationOptions): {
2165
2670
  data?: Record<string, unknown> | undefined;
2166
2671
  functionName?: string | undefined;
2167
2672
  arguments?: Record<string, unknown> | undefined;
2673
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2674
+ askToTalkToHuman?: boolean | undefined;
2675
+ allowedToCreateTicket?: boolean | undefined;
2676
+ ticket?: {
2677
+ subject?: string | undefined;
2678
+ body?: string | undefined;
2679
+ typology?: string | undefined;
2680
+ priority?: string | undefined;
2681
+ tag?: string | undefined;
2682
+ products?: string[] | undefined;
2683
+ custom_fields?: Record<string, string> | undefined;
2684
+ } | undefined;
2685
+ mode?: "form" | "embed" | undefined;
2686
+ ticketFormId?: string | undefined;
2687
+ embedHtml?: string | undefined;
2688
+ embedDescription?: string | undefined;
2168
2689
  }[] | undefined;
2169
2690
  followUpReplies?: string[] | undefined;
2170
2691
  attachments?: {
@@ -2214,6 +2735,22 @@ export declare function useConversation(options?: UseConversationOptions): {
2214
2735
  data?: Record<string, unknown> | undefined;
2215
2736
  functionName?: string | undefined;
2216
2737
  arguments?: Record<string, unknown> | undefined;
2738
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2739
+ askToTalkToHuman?: boolean | undefined;
2740
+ allowedToCreateTicket?: boolean | undefined;
2741
+ ticket?: {
2742
+ subject?: string | undefined;
2743
+ body?: string | undefined;
2744
+ typology?: string | undefined;
2745
+ priority?: string | undefined;
2746
+ tag?: string | undefined;
2747
+ products?: string[] | undefined;
2748
+ custom_fields?: Record<string, string> | undefined;
2749
+ } | undefined;
2750
+ mode?: "form" | "embed" | undefined;
2751
+ ticketFormId?: string | undefined;
2752
+ embedHtml?: string | undefined;
2753
+ embedDescription?: string | undefined;
2217
2754
  }[] | undefined;
2218
2755
  followUpReplies?: string[] | undefined;
2219
2756
  attachments?: {
@@ -2262,6 +2799,22 @@ export declare function useConversation(options?: UseConversationOptions): {
2262
2799
  data?: Record<string, unknown> | undefined;
2263
2800
  functionName?: string | undefined;
2264
2801
  arguments?: Record<string, unknown> | undefined;
2802
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2803
+ askToTalkToHuman?: boolean | undefined;
2804
+ allowedToCreateTicket?: boolean | undefined;
2805
+ ticket?: {
2806
+ subject?: string | undefined;
2807
+ body?: string | undefined;
2808
+ typology?: string | undefined;
2809
+ priority?: string | undefined;
2810
+ tag?: string | undefined;
2811
+ products?: string[] | undefined;
2812
+ custom_fields?: Record<string, string> | undefined;
2813
+ } | undefined;
2814
+ mode?: "form" | "embed" | undefined;
2815
+ ticketFormId?: string | undefined;
2816
+ embedHtml?: string | undefined;
2817
+ embedDescription?: string | undefined;
2265
2818
  }[] | undefined;
2266
2819
  followUpReplies?: string[] | undefined;
2267
2820
  attachments?: {
@@ -2288,6 +2841,33 @@ declare interface UseConversationOptions {
2288
2841
  autoLoad?: boolean;
2289
2842
  }
2290
2843
 
2844
+ /**
2845
+ * Composable to report answers that did not work.
2846
+ *
2847
+ * ```ts
2848
+ * const { ratings, submitFeedback } = useFeedback();
2849
+ *
2850
+ * await submitFeedback(message.id, "negative", { reasons: ["inaccurate"] });
2851
+ * ```
2852
+ *
2853
+ * A bare rating is a reaction. Adding a reason or a comment files the report in
2854
+ * the AGO feedback dashboard, where someone can act on it. `ratings` holds what
2855
+ * was sent per message id, so a thumb can render as selected.
2856
+ */
2857
+ export declare function useFeedback(options?: UseFeedbackOptions): {
2858
+ ratings: Ref<Record<string, FeedbackRating>, Record<string, FeedbackRating>>;
2859
+ isSubmitting: Ref<boolean, boolean>;
2860
+ error: Ref<Error | null, Error | null>;
2861
+ submitFeedback: (messageId: string, rating: FeedbackRating, details?: FeedbackDetails) => Promise<void>;
2862
+ submitConversationFeedback: (conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
2863
+ lastMessageId?: string;
2864
+ }) => Promise<string>;
2865
+ };
2866
+
2867
+ export declare interface UseFeedbackOptions {
2868
+ client?: AgoClient;
2869
+ }
2870
+
2291
2871
  /**
2292
2872
  * Composable to manage messages in a conversation.
2293
2873
  *
@@ -2327,6 +2907,22 @@ export declare function useMessages(options?: UseMessagesOptions): {
2327
2907
  data?: Record<string, unknown> | undefined;
2328
2908
  functionName?: string | undefined;
2329
2909
  arguments?: Record<string, unknown> | undefined;
2910
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2911
+ askToTalkToHuman?: boolean | undefined;
2912
+ allowedToCreateTicket?: boolean | undefined;
2913
+ ticket?: {
2914
+ subject?: string | undefined;
2915
+ body?: string | undefined;
2916
+ typology?: string | undefined;
2917
+ priority?: string | undefined;
2918
+ tag?: string | undefined;
2919
+ products?: string[] | undefined;
2920
+ custom_fields?: Record<string, string> | undefined;
2921
+ } | undefined;
2922
+ mode?: "form" | "embed" | undefined;
2923
+ ticketFormId?: string | undefined;
2924
+ embedHtml?: string | undefined;
2925
+ embedDescription?: string | undefined;
2330
2926
  }[] | undefined;
2331
2927
  followUpReplies?: string[] | undefined;
2332
2928
  attachments?: {
@@ -2370,6 +2966,22 @@ export declare function useMessages(options?: UseMessagesOptions): {
2370
2966
  data?: Record<string, unknown> | undefined;
2371
2967
  functionName?: string | undefined;
2372
2968
  arguments?: Record<string, unknown> | undefined;
2969
+ displayMode?: "collapsible" | "display" | "both" | undefined;
2970
+ askToTalkToHuman?: boolean | undefined;
2971
+ allowedToCreateTicket?: boolean | undefined;
2972
+ ticket?: {
2973
+ subject?: string | undefined;
2974
+ body?: string | undefined;
2975
+ typology?: string | undefined;
2976
+ priority?: string | undefined;
2977
+ tag?: string | undefined;
2978
+ products?: string[] | undefined;
2979
+ custom_fields?: Record<string, string> | undefined;
2980
+ } | undefined;
2981
+ mode?: "form" | "embed" | undefined;
2982
+ ticketFormId?: string | undefined;
2983
+ embedHtml?: string | undefined;
2984
+ embedDescription?: string | undefined;
2373
2985
  }[] | undefined;
2374
2986
  followUpReplies?: string[] | undefined;
2375
2987
  attachments?: {