@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/react.d.cts CHANGED
@@ -110,6 +110,7 @@ declare class AgoClient {
110
110
  private contextRegistry;
111
111
  private eventEmitter;
112
112
  private activityLedger;
113
+ private errorWatcher;
113
114
  private lastSentPageState;
114
115
  private config;
115
116
  /** Conversations already warned about an empty reply (one warning each). */
@@ -279,6 +280,26 @@ declare class AgoClient {
279
280
  * `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
280
281
  */
281
282
  private static mapPersistedToolCalls;
283
+ /**
284
+ * The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
285
+ * agents, the ticket form the agent's `ago_ticketing` tool opens, and the
286
+ * file-attachment flag. The vanilla widget fetches it once, when a ticket
287
+ * form first appears in a conversation.
288
+ */
289
+ getConfig(): Promise<SdkConfig>;
290
+ /**
291
+ * The dashboard's home screen content. A starter card shows its
292
+ * `description` and sends its `initial_message`; one with neither is
293
+ * unusable and is dropped rather than rendered as an empty card.
294
+ */
295
+ private static mapHomePage;
296
+ private static mapTicketForm;
297
+ /**
298
+ * Create a support ticket (`POST /api/sdk/v1/tickets`, multipart). This is
299
+ * what the ticket form in the conversation does before it completes the
300
+ * `form` tool call with {@link submitToolCallForm}.
301
+ */
302
+ createTicket(input: CreateTicketInput): Promise<CreateTicketResult>;
282
303
  /**
283
304
  * Get messages for a conversation
284
305
  */
@@ -330,9 +351,40 @@ declare class AgoClient {
330
351
  */
331
352
  submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
332
353
  /**
333
- * Submit feedback for a message
354
+ * Report an answer: thumbs up/down, optionally with what went wrong.
355
+ *
356
+ * ```ts
357
+ * await client.submitFeedback(message.id, "negative", {
358
+ * reasons: ["inaccurate"],
359
+ * comment: "The price it quoted is from last year.",
360
+ * });
361
+ * ```
362
+ *
363
+ * A bare rating is a reaction (the thumbs counted in the dashboard). Adding a
364
+ * reason or a comment also files it in the feedback list, the analytics and
365
+ * the CSV export, so someone can act on it.
334
366
  */
335
- submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
367
+ submitFeedback(messageId: string, rating: FeedbackRating, details?: FeedbackDetails): Promise<void>;
368
+ /**
369
+ * Report a whole conversation ("this chat is not working").
370
+ *
371
+ * ```ts
372
+ * await client.submitConversationFeedback(conversationId, "negative", {
373
+ * reasons: ["information_not_found"],
374
+ * comment: "It never answered my question.",
375
+ * });
376
+ * ```
377
+ *
378
+ * Feedback is stored per message, so this attaches the report to the last
379
+ * answer of the conversation, which is the one the user is reacting to.
380
+ * Returns the message id it landed on.
381
+ *
382
+ * Pass `lastMessageId` when you already have it (the widget does) to skip the
383
+ * lookup round-trip.
384
+ */
385
+ submitConversationFeedback(conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
386
+ lastMessageId?: string;
387
+ }): Promise<string>;
336
388
  /**
337
389
  * Register a client-side function that AGO can call.
338
390
  * Accepts either a definition object or (name, handler, schema) args.
@@ -506,6 +558,15 @@ declare class AgoClient {
506
558
  /* Excluded from this release type: emitProactiveEvent */
507
559
  /* Excluded from this release type: getHttp */
508
560
  /* Excluded from this release type: getConfiguredAgent */
561
+ /**
562
+ * How the SDK identifies the visitor: the configured `userEmail`, and
563
+ * whether a `userJwt` is set. The ticket form asks for an email when it has
564
+ * neither.
565
+ */
566
+ getUserIdentity(): {
567
+ email?: string;
568
+ hasJwt: boolean;
569
+ };
509
570
  /**
510
571
  * Enable automatic capture of the current browser page (URL + title).
511
572
  * Injected as a dynamic context entry named `browser-page`.
@@ -528,6 +589,26 @@ declare class AgoClient {
528
589
  private addActivity;
529
590
  private recordAgentAction;
530
591
  private registerActivityContext;
592
+ /**
593
+ * Start capturing the page's JavaScript errors (uncaught exceptions,
594
+ * unhandled rejections, `console.error` calls, {@link reportError}) and send
595
+ * the recent ones as the `errors:recent` context entry on every message.
596
+ * Same as setting `errorWatcher` in the config. Calling it again replaces
597
+ * the watcher (and its options); the captured errors are not kept.
598
+ */
599
+ enableErrorWatcher(options?: ErrorWatcherOptions): void;
600
+ /** Stop capturing errors and drop the `errors:recent` context entry. */
601
+ disableErrorWatcher(): void;
602
+ /**
603
+ * Record an error the app caught itself (React error boundary, Vue
604
+ * `errorHandler`, Angular `ErrorHandler`, a try/catch) so the agent sees it
605
+ * like an uncaught one. No-op unless the error watcher is enabled. `context`
606
+ * is size-clamped before it is stored; keep it small and free of secrets.
607
+ */
608
+ reportError(error: unknown, context?: Record<string, unknown>): void;
609
+ /** Errors the watcher currently holds, oldest first (a copy). Empty when disabled. */
610
+ getRecentErrors(): CapturedError[];
611
+ clearErrors(): void;
531
612
  /**
532
613
  * Subscribe to an event
533
614
  */
@@ -722,6 +803,12 @@ declare interface AgoClientEvents {
722
803
  };
723
804
  /** A user- or agent-action was recorded into the activity ledger. */
724
805
  "activity:recorded": ActivityEntry;
806
+ /**
807
+ * The error watcher captured a JavaScript error (uncaught exception,
808
+ * unhandled rejection, `console.error` call, or `reportError`). Fires on
809
+ * repeats too, with the updated `count`. Requires `errorWatcher` in the config.
810
+ */
811
+ "error:captured": CapturedError;
725
812
  }
726
813
 
727
814
  /**
@@ -742,6 +829,8 @@ export declare interface AgoConfig {
742
829
  userEmail?: string;
743
830
  /** JWT token for authenticated users */
744
831
  userJwt?: string;
832
+ /** User metadata sent with messages. Use null to stop sending defaults. Not an authentication credential. */
833
+ metadata?: Record<string, unknown> | null;
745
834
  /** Enable debug logging */
746
835
  debug?: boolean;
747
836
  /**
@@ -801,6 +890,18 @@ export declare interface AgoConfig {
801
890
  * default otherwise.
802
891
  */
803
892
  proactive?: ProactiveOptions;
893
+ /**
894
+ * Capture the page's JavaScript errors as agent context. When set, the SDK
895
+ * listens for uncaught exceptions and unhandled promise rejections, wraps
896
+ * `console.error` (calling through; restored on `destroy`), and sends the
897
+ * recent errors (deduplicated, capped, pruned after 10 min) as the
898
+ * `errors:recent` context entry on every message. `true` uses the defaults;
899
+ * pass {@link ErrorWatcherOptions} to tune the caps or add a `filter` that
900
+ * redacts messages. Off by default: error messages can carry PII or internal
901
+ * URLs, so enabling it is the host's call. Errors also feed the proactive
902
+ * mode's `jsErrors` signal. See `client.reportError()` for caught errors.
903
+ */
904
+ errorWatcher?: boolean | ErrorWatcherOptions;
804
905
  }
805
906
 
806
907
  /**
@@ -1048,12 +1149,53 @@ export declare interface AgoStateControl<T = unknown> {
1048
1149
  enum?: (string | number)[];
1049
1150
  };
1050
1151
  };
1152
+ /** String-only: `""` means "clear" instead of being dropped as filler. */
1153
+ clearable?: boolean;
1051
1154
  /** Current value → pushed as dynamic context so the agent knows what to change. */
1052
1155
  get?: () => T;
1053
1156
  /** Apply the state change on the page. May be async. */
1054
- set: (value: T) => void | Promise<void>;
1157
+ set: (value: T) => void | AgoStateSetResult | Promise<void | AgoStateSetResult>;
1158
+ }
1159
+
1160
+ /**
1161
+ * Tagged outcome a page setter may return to reject or mark unchanged.
1162
+ *
1163
+ * Returning nothing (void) means APPLY. Returning an unrecognized JS value
1164
+ * (e.g. a string from an assignment expression) is also treated as APPLY.
1165
+ */
1166
+ declare type AgoStateSetResult = {
1167
+ result: "rejected";
1168
+ reason: string;
1169
+ } | {
1170
+ result: "unchanged";
1171
+ };
1172
+
1173
+ /** One JavaScript error captured on the page (deduplicated, see `count`). */
1174
+ declare interface CapturedError {
1175
+ type: CapturedErrorType;
1176
+ /** Error message, truncated to 500 chars. */
1177
+ message: string;
1178
+ /** Script URL the error came from, without its query string. */
1179
+ source?: string;
1180
+ line?: number;
1181
+ col?: number;
1182
+ /** Leading stack frames, truncated (see `maxStackChars`). */
1183
+ stack?: string;
1184
+ /** Pathname at capture time. */
1185
+ route: string;
1186
+ /** Epoch ms of the first occurrence. */
1187
+ firstAt: number;
1188
+ /** Epoch ms of the most recent occurrence. */
1189
+ lastAt: number;
1190
+ /** How many times this same error (type + message + source + line) fired. */
1191
+ count: number;
1192
+ /** App-provided context, manual reports only (size-clamped). */
1193
+ context?: Record<string, unknown>;
1055
1194
  }
1056
1195
 
1196
+ /** How an error reached the watcher. */
1197
+ declare type CapturedErrorType = "error" | "unhandledrejection" | "console" | "manual";
1198
+
1057
1199
  /**
1058
1200
  * Chat input component with send button
1059
1201
  */
@@ -1133,6 +1275,17 @@ export declare interface ChatWidgetProps {
1133
1275
  * fetch the definition from the backend ({@link loadFormCollector}).
1134
1276
  */
1135
1277
  forms?: Array<CreateFormCollectorOptions | LoadFormCollectorOptions>;
1278
+ /**
1279
+ * Let the user report an answer that did not work: thumbs under each finished
1280
+ * answer, and after a thumbs-down a panel to say what went wrong. Off by
1281
+ * default. `true` uses the English labels; pass the `<MessageFeedback>` props
1282
+ * to translate the strings or observe what was sent.
1283
+ *
1284
+ * ```tsx
1285
+ * <ChatWidget feedback />
1286
+ * ```
1287
+ */
1288
+ feedback?: boolean | Omit<MessageFeedbackProps, "messageId" | "client">;
1136
1289
  /**
1137
1290
  * How clicking a suggested follow-up reply behaves. Defaults to sending the
1138
1291
  * reply as a new user message. Pass a handler to override, or `false` to
@@ -1377,6 +1530,32 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
1377
1530
  */
1378
1531
  export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
1379
1532
 
1533
+ /** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
1534
+ declare interface CreateTicketInput {
1535
+ subject: string;
1536
+ body: string;
1537
+ priority?: string;
1538
+ typology?: string;
1539
+ /** Conversation the ticket is filed from. */
1540
+ conversationId?: string;
1541
+ /** Reporter email, for a visitor the SDK does not otherwise identify. */
1542
+ email?: string;
1543
+ customFields?: Array<{
1544
+ id: string;
1545
+ value: string;
1546
+ }>;
1547
+ files?: File[];
1548
+ ticketFormId?: string;
1549
+ }
1550
+
1551
+ /** Response of `AgoClient.createTicket`. */
1552
+ declare interface CreateTicketResult {
1553
+ id: string;
1554
+ url?: string;
1555
+ }
1556
+
1557
+ export declare const DEFAULT_MESSAGE_FEEDBACK_LABELS: MessageFeedbackLabels;
1558
+
1380
1559
  /**
1381
1560
  * Compute which required fields are still empty and whether the form is complete.
1382
1561
  * Pure — the single home for the "required + non-empty" rule, shared by the update
@@ -1404,6 +1583,57 @@ declare interface ElementProps {
1404
1583
  attrs: Record<string, string | null>;
1405
1584
  }
1406
1585
 
1586
+ declare interface ErrorWatcherOptions {
1587
+ /** Max distinct errors kept. Oldest dropped first. Default 10. */
1588
+ maxErrors?: number;
1589
+ /**
1590
+ * Errors older than this are pruned when the buffer is read, so a crash from
1591
+ * an hour ago does not confuse the agent. Default 600 000 (10 min).
1592
+ */
1593
+ maxAgeMs?: number;
1594
+ /** Max chars of stack kept per error. Default 2000. */
1595
+ maxStackChars?: number;
1596
+ /**
1597
+ * Redact or drop an error before it is stored. Return the (possibly edited)
1598
+ * error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
1599
+ */
1600
+ filter?: (error: CapturedError) => CapturedError | null;
1601
+ }
1602
+
1603
+ /** The four values of {@link FeedbackReason}, in dashboard order. */
1604
+ export declare const FEEDBACK_REASONS: readonly FeedbackReason[];
1605
+
1606
+ /**
1607
+ * Why the user is reporting a message (see `AgoClient.submitFeedback`).
1608
+ *
1609
+ * A rating on its own is a reaction (the thumbs count). Add a reason or a
1610
+ * comment and the report also lands in the feedback dashboard, the analytics
1611
+ * and the CSV export, where someone can act on it.
1612
+ */
1613
+ export declare interface FeedbackDetails {
1614
+ /** What went wrong. Several can apply at once. */
1615
+ reasons?: FeedbackReason[];
1616
+ /** The user's own words. Trimmed server-side; 5000 characters max. */
1617
+ comment?: string;
1618
+ }
1619
+
1620
+ /** Thumbs up / thumbs down on an answer. */
1621
+ export declare type FeedbackRating = "positive" | "negative";
1622
+
1623
+ /**
1624
+ * What went wrong with an answer. These are the four buckets the AGO feedback
1625
+ * dashboard filters and charts on.
1626
+ */
1627
+ export declare type FeedbackReason =
1628
+ /** The answer states something false. */
1629
+ "inaccurate"
1630
+ /** The answer is right but stops short. */
1631
+ | "incomplete"
1632
+ /** The agent could not find the information. */
1633
+ | "information_not_found"
1634
+ /** Something broke: the widget, a tool call, the stream. */
1635
+ | "technical_issue";
1636
+
1407
1637
  export declare interface FormCollector<V = Record<string, unknown>> {
1408
1638
  name: string;
1409
1639
  /** Observable store driving the form UI (read via `useAgoStore`). */
@@ -1656,6 +1886,60 @@ export declare interface MarkdownProps {
1656
1886
 
1657
1887
  export declare const Message: default_2.FC<MessageProps>;
1658
1888
 
1889
+ /**
1890
+ * Thumbs under an answer, and a "what went wrong?" panel after a thumbs-down.
1891
+ *
1892
+ * ```tsx
1893
+ * <MessageFeedback messageId={message.id} />
1894
+ * ```
1895
+ *
1896
+ * The thumb is sent as soon as it is clicked, so the signal survives a user who
1897
+ * ignores the panel; sending the panel then files the detailed report (reasons
1898
+ * and comment), which is what shows up in the AGO feedback dashboard.
1899
+ */
1900
+ export declare const MessageFeedback: default_2.FC<MessageFeedbackProps>;
1901
+
1902
+ /** Every string the feedback row shows, so a non-English app can translate it. */
1903
+ export declare interface MessageFeedbackLabels {
1904
+ helpful: string;
1905
+ notHelpful: string;
1906
+ whatWentWrong: string;
1907
+ reasons: Record<FeedbackReason, string>;
1908
+ commentPlaceholder: string;
1909
+ send: string;
1910
+ thanks: string;
1911
+ }
1912
+
1913
+ export declare interface MessageFeedbackProps {
1914
+ /** The answer being judged. */
1915
+ messageId: string;
1916
+ /** The AGO client. If omitted, reads from AgoProvider context. */
1917
+ client?: AgoClient;
1918
+ /**
1919
+ * After a thumbs-down, open the panel asking what went wrong. Defaults to
1920
+ * `true`; pass `false` to collect thumbs only.
1921
+ */
1922
+ askWhy?: boolean;
1923
+ /** Override any of the strings (reason labels can be overridden one by one). */
1924
+ labels?: Partial<Omit<MessageFeedbackLabels, "reasons">> & {
1925
+ reasons?: Partial<Record<FeedbackReason, string>>;
1926
+ };
1927
+ /**
1928
+ * Called after a report was accepted by the API. Fires once per accepted
1929
+ * report, so a thumbs-down followed by the panel calls it twice: first for
1930
+ * the bare thumb, then for the detailed report.
1931
+ */
1932
+ onSubmit?: (report: {
1933
+ messageId: string;
1934
+ rating: FeedbackRating;
1935
+ reasons: FeedbackReason[];
1936
+ comment?: string;
1937
+ }) => void;
1938
+ /** Called when a report could not be sent. */
1939
+ onError?: (error: Error) => void;
1940
+ className?: string;
1941
+ }
1942
+
1659
1943
  export declare interface MessageProps {
1660
1944
  message: AgoMessage;
1661
1945
  className?: string;
@@ -1678,6 +1962,11 @@ export declare interface MessageProps {
1678
1962
  * bubble is then dropped entirely rather than left as a blank box.
1679
1963
  */
1680
1964
  showStreamingDots?: boolean;
1965
+ /**
1966
+ * Rendered under an assistant bubble, above the suggested replies. Meant for
1967
+ * `<MessageFeedback messageId={message.id} />`, but takes any node.
1968
+ */
1969
+ feedback?: default_2.ReactNode;
1681
1970
  }
1682
1971
 
1683
1972
  declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
@@ -1898,6 +2187,12 @@ declare interface ProactiveTriggerWhen {
1898
2187
  pageState?: Partial<Record<string, unknown>>;
1899
2188
  /** Min rage-click bursts on the current route. */
1900
2189
  rageClicks?: number;
2190
+ /**
2191
+ * Min JavaScript errors captured on the current route. Needs the client's
2192
+ * `errorWatcher` enabled; without it the count stays at 0 and the matcher
2193
+ * never passes.
2194
+ */
2195
+ jsErrors?: number;
1901
2196
  /** Min A→B→A→B route oscillations this session. */
1902
2197
  routeBounces?: number;
1903
2198
  /** Per-field minimum error counts (field NAME → min count). */
@@ -1915,10 +2210,69 @@ declare type ResumeGate = (info: {
1915
2210
  messageId: string;
1916
2211
  }) => Promise<void> | void;
1917
2212
 
2213
+ /** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
2214
+ declare interface SdkConfig {
2215
+ permissions: SdkPermissionConfig[];
2216
+ proactive: {
2217
+ enabled: boolean;
2218
+ };
2219
+ }
2220
+
2221
+ /** The dashboard's home screen content (title, subtitle, starter cards). */
2222
+ declare interface SdkHomePageConfig {
2223
+ title?: string;
2224
+ /** Markdown. */
2225
+ subtitle?: string;
2226
+ starters: SdkHomeStarter[];
2227
+ widgetStarter?: SdkWidgetStarter;
2228
+ }
2229
+
2230
+ /**
2231
+ * A conversation starter card configured in the AGO dashboard. `label` is what
2232
+ * the card shows; clicking it sends `message`.
2233
+ */
2234
+ declare interface SdkHomeStarter {
2235
+ id: string;
2236
+ /** The card's text (the starter's `description` in the dashboard). */
2237
+ label: string;
2238
+ /** What is sent when the card is clicked. */
2239
+ message: string;
2240
+ /** Answer with this agent instead of the configured default. */
2241
+ agentId?: string;
2242
+ }
2243
+
2244
+ /** One permission's configuration in {@link SdkConfig}. */
2245
+ declare interface SdkPermissionConfig {
2246
+ id?: string;
2247
+ name?: string;
2248
+ displayName?: string;
2249
+ agents: Array<{
2250
+ id: string;
2251
+ name?: string;
2252
+ }>;
2253
+ ticketForm?: TicketForm;
2254
+ /** Home screen content, when the tenant configured one. */
2255
+ homePage?: SdkHomePageConfig;
2256
+ fileAttachmentsEnabled: boolean;
2257
+ voiceEnabled: boolean;
2258
+ }
2259
+
2260
+ /**
2261
+ * The starter the dashboard sends by itself on a fresh visit, before the
2262
+ * visitor types anything.
2263
+ */
2264
+ declare interface SdkWidgetStarter {
2265
+ id: string;
2266
+ message: string;
2267
+ agentId?: string;
2268
+ }
2269
+
1918
2270
  /**
1919
2271
  * Options for sending a message
1920
2272
  */
1921
2273
  declare interface SendMessageOptions {
2274
+ /** Replaces config.metadata for this message; null omits metadata for this message. */
2275
+ metadata?: Record<string, unknown> | null;
1922
2276
  /** Existing conversation ID */
1923
2277
  conversationId?: string;
1924
2278
  /** Override default agent */
@@ -2034,6 +2388,12 @@ declare interface SignalsSnapshot {
2034
2388
  idleMs: number;
2035
2389
  /** Rage-click bursts detected on the current route. */
2036
2390
  rageClicks: number;
2391
+ /**
2392
+ * JavaScript errors captured on the current route (count only; the messages
2393
+ * travel in `client_context` under `errors:recent`). Always `0` unless the
2394
+ * client has `errorWatcher` enabled.
2395
+ */
2396
+ jsErrors: number;
2037
2397
  /**
2038
2398
  * A→B→A→B route oscillations detected in the recent route sequence. Rolling
2039
2399
  * session counter (cross-route by nature); trigger cooldowns and dismissal
@@ -2092,6 +2452,13 @@ declare interface SSEChunkData {
2092
2452
  follow_up_replies?: string[];
2093
2453
  satisfaction_feedback?: unknown;
2094
2454
  ask_to_talk_to_human?: boolean;
2455
+ allowed_to_create_ticket?: boolean;
2456
+ ticket?: ToolCallTicketPrefill;
2457
+ mode?: "form" | "embed";
2458
+ ticket_form_id?: string;
2459
+ embed_html?: string;
2460
+ embed_description?: string;
2461
+ display_mode?: "collapsible" | "display" | "both";
2095
2462
  /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
2096
2463
  waiting_tool_call_ids?: string[];
2097
2464
  }
@@ -2166,12 +2533,82 @@ export declare type SubmitConfig<V = Record<string, unknown>> = string | {
2166
2533
  declare interface SubmitToolCallResult {
2167
2534
  status: string;
2168
2535
  result?: unknown;
2536
+ /** Set when `status` is `"error"`. */
2537
+ error?: string;
2538
+ /** The ticket a ticketing `form` tool call resolved to, when it did. */
2539
+ ticket?: {
2540
+ ticket_id: string;
2541
+ ticket_url?: string;
2542
+ [key: string]: unknown;
2543
+ };
2169
2544
  resume?: {
2170
2545
  message_id: string;
2171
2546
  ready: boolean;
2172
2547
  };
2173
2548
  }
2174
2549
 
2550
+ /** A custom field of a ticket form. */
2551
+ declare interface TicketField {
2552
+ id: string;
2553
+ /** The key the ticketing backend expects; used as the submit key when set. */
2554
+ externalId?: string;
2555
+ title?: string;
2556
+ /** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
2557
+ type?: string;
2558
+ required: boolean;
2559
+ /** Carried in the submission but never shown. */
2560
+ hidden: boolean;
2561
+ active?: boolean;
2562
+ /** Bypass progressive disclosure, while still respecting conditions. */
2563
+ alwaysVisible?: boolean;
2564
+ regexpForValidation?: string;
2565
+ position: number;
2566
+ /** Non-empty turns the field into a select. */
2567
+ options: TicketFieldOption[];
2568
+ /** Show this field only when the parent field holds `conditionalFieldValue`. */
2569
+ conditionalFieldId?: string;
2570
+ /** Legacy comma-separated condition values. */
2571
+ conditionalFieldValue?: string;
2572
+ /** Takes precedence over conditionalFieldValue when non-empty. */
2573
+ conditionalFieldValues?: string[];
2574
+ }
2575
+
2576
+ /** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
2577
+ declare interface TicketFieldOption {
2578
+ id: string;
2579
+ /** Label shown to the user. */
2580
+ name?: string;
2581
+ /** Value submitted. Falls back to `name` when absent. */
2582
+ value?: string;
2583
+ /** Preselected when the form opens. */
2584
+ default: boolean;
2585
+ /** A note shown under the field once this option is picked. */
2586
+ message?: string;
2587
+ messageType: "info" | "warning" | "danger";
2588
+ position?: number;
2589
+ group?: string;
2590
+ noDisplay?: boolean;
2591
+ conditionalFieldId?: string;
2592
+ /** Available when the parent matches any of these values. */
2593
+ conditionalFieldValues?: string[];
2594
+ }
2595
+
2596
+ /** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
2597
+ declare interface TicketForm {
2598
+ id: string;
2599
+ name?: string;
2600
+ /** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
2601
+ mode: "form" | "embed";
2602
+ showSubject: boolean;
2603
+ showBody: boolean;
2604
+ showPriority: boolean;
2605
+ showTypology: boolean;
2606
+ priorityTypologies?: string[];
2607
+ successMessageText?: string;
2608
+ successMessageUrlLabel?: string;
2609
+ fields: TicketField[];
2610
+ }
2611
+
2175
2612
  /**
2176
2613
  * Tool call data from SSE stream
2177
2614
  */
@@ -2186,6 +2623,34 @@ export declare interface ToolCallData {
2186
2623
  data?: Record<string, unknown>;
2187
2624
  functionName?: string;
2188
2625
  arguments?: Record<string, unknown>;
2626
+ /**
2627
+ * Where the hosted widget shows the call: in the collapsible "reasoning"
2628
+ * section, in the message body, or both. Absent means collapsible only.
2629
+ */
2630
+ displayMode?: "collapsible" | "display" | "both";
2631
+ /** The user asked to talk to a human. */
2632
+ askToTalkToHuman?: boolean;
2633
+ /** `false` when the tenant blocks ticket creation for this visitor. */
2634
+ allowedToCreateTicket?: boolean;
2635
+ /** Fields the agent pre-filled from the conversation. */
2636
+ ticket?: ToolCallTicketPrefill;
2637
+ /** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
2638
+ mode?: "form" | "embed";
2639
+ ticketFormId?: string;
2640
+ embedHtml?: string;
2641
+ embedDescription?: string;
2642
+ }
2643
+
2644
+ /** The ticket the agent pre-filled on a ticketing `form` tool call. */
2645
+ declare interface ToolCallTicketPrefill {
2646
+ subject?: string;
2647
+ body?: string;
2648
+ typology?: string;
2649
+ priority?: string;
2650
+ tag?: string;
2651
+ products?: string[];
2652
+ /** Keyed by the field's external id, or a lowercased, underscored title. */
2653
+ custom_fields?: Record<string, string>;
2189
2654
  }
2190
2655
 
2191
2656
  declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
@@ -2545,6 +3010,48 @@ export declare interface UseConversationResult {
2545
3010
  refreshConversations: () => Promise<void>;
2546
3011
  }
2547
3012
 
3013
+ /**
3014
+ * Hook to report answers that did not work.
3015
+ *
3016
+ * ```tsx
3017
+ * const { ratings, submitFeedback } = useFeedback();
3018
+ *
3019
+ * <button onClick={() => submitFeedback(message.id, "negative", {
3020
+ * reasons: ["inaccurate"],
3021
+ * })} aria-pressed={ratings[message.id] === "negative"}>
3022
+ * 👎
3023
+ * </button>
3024
+ * ```
3025
+ *
3026
+ * A bare rating is a reaction. Adding a reason or a comment files the report in
3027
+ * the AGO feedback dashboard, where someone can act on it.
3028
+ */
3029
+ export declare function useFeedback({ client: clientProp, }?: UseFeedbackOptions): UseFeedbackResult;
3030
+
3031
+ export declare interface UseFeedbackOptions {
3032
+ /** The AGO client instance. If omitted, reads from AgoProvider context. */
3033
+ client?: AgoClient;
3034
+ }
3035
+
3036
+ export declare interface UseFeedbackResult {
3037
+ /**
3038
+ * The rating already sent for each message, keyed by message id. Use it to
3039
+ * light up the thumb the user picked (and to re-render after a change of
3040
+ * mind: sending a new rating overwrites the previous one).
3041
+ */
3042
+ ratings: Record<string, FeedbackRating>;
3043
+ /** Report one answer. */
3044
+ submitFeedback: (messageId: string, rating: FeedbackRating, details?: FeedbackDetails) => Promise<void>;
3045
+ /** Report the conversation; lands on its last answer, whose id is returned. */
3046
+ submitConversationFeedback: (conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
3047
+ lastMessageId?: string;
3048
+ }) => Promise<string>;
3049
+ /** True while a report is in flight. */
3050
+ isSubmitting: boolean;
3051
+ /** The last failure, or null. Cleared when a new report starts. */
3052
+ error: Error | null;
3053
+ }
3054
+
2548
3055
  /**
2549
3056
  * React wiring for {@link createFormCollector}: registers the collector's client
2550
3057
  * functions + dynamic context on mount, removes them on unmount, and returns the