@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/index.d.ts CHANGED
@@ -92,6 +92,7 @@ export declare class AgoClient {
92
92
  private contextRegistry;
93
93
  private eventEmitter;
94
94
  private activityLedger;
95
+ private errorWatcher;
95
96
  private lastSentPageState;
96
97
  private config;
97
98
  /** Conversations already warned about an empty reply (one warning each). */
@@ -261,6 +262,26 @@ export declare class AgoClient {
261
262
  * `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
262
263
  */
263
264
  private static mapPersistedToolCalls;
265
+ /**
266
+ * The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
267
+ * agents, the ticket form the agent's `ago_ticketing` tool opens, and the
268
+ * file-attachment flag. The vanilla widget fetches it once, when a ticket
269
+ * form first appears in a conversation.
270
+ */
271
+ getConfig(): Promise<SdkConfig>;
272
+ /**
273
+ * The dashboard's home screen content. A starter card shows its
274
+ * `description` and sends its `initial_message`; one with neither is
275
+ * unusable and is dropped rather than rendered as an empty card.
276
+ */
277
+ private static mapHomePage;
278
+ private static mapTicketForm;
279
+ /**
280
+ * Create a support ticket (`POST /api/sdk/v1/tickets`, multipart). This is
281
+ * what the ticket form in the conversation does before it completes the
282
+ * `form` tool call with {@link submitToolCallForm}.
283
+ */
284
+ createTicket(input: CreateTicketInput): Promise<CreateTicketResult>;
264
285
  /**
265
286
  * Get messages for a conversation
266
287
  */
@@ -312,9 +333,40 @@ export declare class AgoClient {
312
333
  */
313
334
  submitFormCollector(name: string, values: Record<string, unknown>): Promise<unknown>;
314
335
  /**
315
- * Submit feedback for a message
336
+ * Report an answer: thumbs up/down, optionally with what went wrong.
337
+ *
338
+ * ```ts
339
+ * await client.submitFeedback(message.id, "negative", {
340
+ * reasons: ["inaccurate"],
341
+ * comment: "The price it quoted is from last year.",
342
+ * });
343
+ * ```
344
+ *
345
+ * A bare rating is a reaction (the thumbs counted in the dashboard). Adding a
346
+ * reason or a comment also files it in the feedback list, the analytics and
347
+ * the CSV export, so someone can act on it.
316
348
  */
317
- submitFeedback(messageId: string, rating: "positive" | "negative"): Promise<void>;
349
+ submitFeedback(messageId: string, rating: FeedbackRating, details?: FeedbackDetails): Promise<void>;
350
+ /**
351
+ * Report a whole conversation ("this chat is not working").
352
+ *
353
+ * ```ts
354
+ * await client.submitConversationFeedback(conversationId, "negative", {
355
+ * reasons: ["information_not_found"],
356
+ * comment: "It never answered my question.",
357
+ * });
358
+ * ```
359
+ *
360
+ * Feedback is stored per message, so this attaches the report to the last
361
+ * answer of the conversation, which is the one the user is reacting to.
362
+ * Returns the message id it landed on.
363
+ *
364
+ * Pass `lastMessageId` when you already have it (the widget does) to skip the
365
+ * lookup round-trip.
366
+ */
367
+ submitConversationFeedback(conversationId: string, rating: FeedbackRating, details?: FeedbackDetails & {
368
+ lastMessageId?: string;
369
+ }): Promise<string>;
318
370
  /**
319
371
  * Register a client-side function that AGO can call.
320
372
  * Accepts either a definition object or (name, handler, schema) args.
@@ -488,6 +540,15 @@ export declare class AgoClient {
488
540
  /* Excluded from this release type: emitProactiveEvent */
489
541
  /* Excluded from this release type: getHttp */
490
542
  /* Excluded from this release type: getConfiguredAgent */
543
+ /**
544
+ * How the SDK identifies the visitor: the configured `userEmail`, and
545
+ * whether a `userJwt` is set. The ticket form asks for an email when it has
546
+ * neither.
547
+ */
548
+ getUserIdentity(): {
549
+ email?: string;
550
+ hasJwt: boolean;
551
+ };
491
552
  /**
492
553
  * Enable automatic capture of the current browser page (URL + title).
493
554
  * Injected as a dynamic context entry named `browser-page`.
@@ -510,6 +571,26 @@ export declare class AgoClient {
510
571
  private addActivity;
511
572
  private recordAgentAction;
512
573
  private registerActivityContext;
574
+ /**
575
+ * Start capturing the page's JavaScript errors (uncaught exceptions,
576
+ * unhandled rejections, `console.error` calls, {@link reportError}) and send
577
+ * the recent ones as the `errors:recent` context entry on every message.
578
+ * Same as setting `errorWatcher` in the config. Calling it again replaces
579
+ * the watcher (and its options); the captured errors are not kept.
580
+ */
581
+ enableErrorWatcher(options?: ErrorWatcherOptions): void;
582
+ /** Stop capturing errors and drop the `errors:recent` context entry. */
583
+ disableErrorWatcher(): void;
584
+ /**
585
+ * Record an error the app caught itself (React error boundary, Vue
586
+ * `errorHandler`, Angular `ErrorHandler`, a try/catch) so the agent sees it
587
+ * like an uncaught one. No-op unless the error watcher is enabled. `context`
588
+ * is size-clamped before it is stored; keep it small and free of secrets.
589
+ */
590
+ reportError(error: unknown, context?: Record<string, unknown>): void;
591
+ /** Errors the watcher currently holds, oldest first (a copy). Empty when disabled. */
592
+ getRecentErrors(): CapturedError[];
593
+ clearErrors(): void;
513
594
  /**
514
595
  * Subscribe to an event
515
596
  */
@@ -704,6 +785,12 @@ export declare interface AgoClientEvents {
704
785
  };
705
786
  /** A user- or agent-action was recorded into the activity ledger. */
706
787
  "activity:recorded": ActivityEntry;
788
+ /**
789
+ * The error watcher captured a JavaScript error (uncaught exception,
790
+ * unhandled rejection, `console.error` call, or `reportError`). Fires on
791
+ * repeats too, with the updated `count`. Requires `errorWatcher` in the config.
792
+ */
793
+ "error:captured": CapturedError;
707
794
  }
708
795
 
709
796
  /**
@@ -724,6 +811,8 @@ export declare interface AgoConfig {
724
811
  userEmail?: string;
725
812
  /** JWT token for authenticated users */
726
813
  userJwt?: string;
814
+ /** User metadata sent with messages. Use null to stop sending defaults. Not an authentication credential. */
815
+ metadata?: Record<string, unknown> | null;
727
816
  /** Enable debug logging */
728
817
  debug?: boolean;
729
818
  /**
@@ -783,6 +872,18 @@ export declare interface AgoConfig {
783
872
  * default otherwise.
784
873
  */
785
874
  proactive?: ProactiveOptions;
875
+ /**
876
+ * Capture the page's JavaScript errors as agent context. When set, the SDK
877
+ * listens for uncaught exceptions and unhandled promise rejections, wraps
878
+ * `console.error` (calling through; restored on `destroy`), and sends the
879
+ * recent errors (deduplicated, capped, pruned after 10 min) as the
880
+ * `errors:recent` context entry on every message. `true` uses the defaults;
881
+ * pass {@link ErrorWatcherOptions} to tune the caps or add a `filter` that
882
+ * redacts messages. Off by default: error messages can carry PII or internal
883
+ * URLs, so enabling it is the host's call. Errors also feed the proactive
884
+ * mode's `jsErrors` signal. See `client.reportError()` for caught errors.
885
+ */
886
+ errorWatcher?: boolean | ErrorWatcherOptions;
786
887
  }
787
888
 
788
889
  /**
@@ -919,6 +1020,14 @@ export declare interface AgoPageDataSource<T = unknown> {
919
1020
  maxResultBytes?: number;
920
1021
  }
921
1022
 
1023
+ /** The verdict part of a setPageState answer, without the page snapshot. */
1024
+ export declare interface AgoPageStateEnvelope {
1025
+ success: boolean;
1026
+ applied: string[];
1027
+ unchanged: string[];
1028
+ rejected?: Record<string, string>;
1029
+ }
1030
+
922
1031
  /**
923
1032
  * Options for {@link AgoClient.registerPageStateFunction}.
924
1033
  */
@@ -949,6 +1058,15 @@ export declare interface AgoPageStateOptions {
949
1058
  settleTimeoutMs?: number;
950
1059
  }
951
1060
 
1061
+ /**
1062
+ * What `setPageState` answers the agent. Every non-dropped field the agent sent
1063
+ * is accounted for by name, so it can tell a change it made from one that was
1064
+ * already true. Dropped placeholders are intentionally omitted.
1065
+ */
1066
+ export declare interface AgoPageStateResult<TData = unknown> extends AgoPageStateEnvelope {
1067
+ data?: TData;
1068
+ }
1069
+
952
1070
  /**
953
1071
  * Knowledge source citation
954
1072
  */
@@ -978,12 +1096,27 @@ export declare interface AgoStateControl<T = unknown> {
978
1096
  enum?: (string | number)[];
979
1097
  };
980
1098
  };
1099
+ /** String-only: `""` means "clear" instead of being dropped as filler. */
1100
+ clearable?: boolean;
981
1101
  /** Current value → pushed as dynamic context so the agent knows what to change. */
982
1102
  get?: () => T;
983
1103
  /** Apply the state change on the page. May be async. */
984
- set: (value: T) => void | Promise<void>;
1104
+ set: (value: T) => void | AgoStateSetResult | Promise<void | AgoStateSetResult>;
985
1105
  }
986
1106
 
1107
+ /**
1108
+ * Tagged outcome a page setter may return to reject or mark unchanged.
1109
+ *
1110
+ * Returning nothing (void) means APPLY. Returning an unrecognized JS value
1111
+ * (e.g. a string from an assignment expression) is also treated as APPLY.
1112
+ */
1113
+ export declare type AgoStateSetResult = {
1114
+ result: "rejected";
1115
+ reason: string;
1116
+ } | {
1117
+ result: "unchanged";
1118
+ };
1119
+
987
1120
  /**
988
1121
  * SSE stream error
989
1122
  *
@@ -1088,6 +1221,32 @@ export declare function autoDetectConfig(overrides?: Partial<AgoConfig>): AgoCon
1088
1221
  */
1089
1222
  export declare function canInlineImage(attachment: AgoAttachment): boolean;
1090
1223
 
1224
+ /** One JavaScript error captured on the page (deduplicated, see `count`). */
1225
+ export declare interface CapturedError {
1226
+ type: CapturedErrorType;
1227
+ /** Error message, truncated to 500 chars. */
1228
+ message: string;
1229
+ /** Script URL the error came from, without its query string. */
1230
+ source?: string;
1231
+ line?: number;
1232
+ col?: number;
1233
+ /** Leading stack frames, truncated (see `maxStackChars`). */
1234
+ stack?: string;
1235
+ /** Pathname at capture time. */
1236
+ route: string;
1237
+ /** Epoch ms of the first occurrence. */
1238
+ firstAt: number;
1239
+ /** Epoch ms of the most recent occurrence. */
1240
+ lastAt: number;
1241
+ /** How many times this same error (type + message + source + line) fired. */
1242
+ count: number;
1243
+ /** App-provided context, manual reports only (size-clamped). */
1244
+ context?: Record<string, unknown>;
1245
+ }
1246
+
1247
+ /** How an error reached the watcher. */
1248
+ export declare type CapturedErrorType = "error" | "unhandledrejection" | "console" | "manual";
1249
+
1091
1250
  /**
1092
1251
  * Registry that collects client-side context from across the component tree.
1093
1252
  *
@@ -1496,8 +1655,36 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
1496
1655
 
1497
1656
  export declare function createStore<T>(initial: T, persist?: PersistOptions): Store<T>;
1498
1657
 
1658
+ /** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
1659
+ declare interface CreateTicketInput {
1660
+ subject: string;
1661
+ body: string;
1662
+ priority?: string;
1663
+ typology?: string;
1664
+ /** Conversation the ticket is filed from. */
1665
+ conversationId?: string;
1666
+ /** Reporter email, for a visitor the SDK does not otherwise identify. */
1667
+ email?: string;
1668
+ customFields?: Array<{
1669
+ id: string;
1670
+ value: string;
1671
+ }>;
1672
+ files?: File[];
1673
+ ticketFormId?: string;
1674
+ }
1675
+
1676
+ /** Response of `AgoClient.createTicket`. */
1677
+ declare interface CreateTicketResult {
1678
+ id: string;
1679
+ url?: string;
1680
+ }
1681
+
1499
1682
  export declare const DEFAULT_MAX_ACTIVITY_ENTRIES = 10;
1500
1683
 
1684
+ export declare const DEFAULT_MAX_ERROR_AGE_MS = 600000;
1685
+
1686
+ export declare const DEFAULT_MAX_ERRORS = 10;
1687
+
1501
1688
  /**
1502
1689
  * Create a reusable function definition.
1503
1690
  * Returns the same object — this is an identity function for discoverability and type-checking.
@@ -1540,6 +1727,83 @@ export declare function deriveFormStatus(schema: FormCollectorSchema, values: Pa
1540
1727
  */
1541
1728
  export declare type DynamicContextProvider = () => ContextEntry | null | undefined;
1542
1729
 
1730
+ /**
1731
+ * Captures the page's JavaScript errors so they can ride along as agent
1732
+ * context: uncaught exceptions (`window` `error` event), unhandled promise
1733
+ * rejections, every `console.error` call, and errors the app reports itself
1734
+ * via {@link report}.
1735
+ *
1736
+ * Errors are deduplicated by type + message + source + line (a repeat bumps
1737
+ * `count` and `lastAt`), capped at `maxErrors`, and pruned after `maxAgeMs`
1738
+ * when read. Messages and stacks are truncated so one error cannot bloat the
1739
+ * context.
1740
+ *
1741
+ * `console.error` capture wraps the console method. This is the one sanctioned
1742
+ * exception to the SDK's no-global-mutation rule: the wrapper always calls the
1743
+ * original, ignores the SDK's own `[AGO SDK]` lines, and is restored by
1744
+ * {@link destroy} when it is still installed (another library may have
1745
+ * wrapped it after us; in that case ours stays in the chain and keeps calling
1746
+ * through).
1747
+ *
1748
+ * Attached by `AgoClient` when `errorWatcher` is set in the config; usable
1749
+ * standalone. Listeners are attached only by `start()` and removed by
1750
+ * `destroy()`. No-op outside a browser (SSR).
1751
+ */
1752
+ export declare class ErrorWatcher {
1753
+ private readonly maxErrors;
1754
+ private readonly maxAgeMs;
1755
+ private readonly maxStackChars;
1756
+ private readonly filter?;
1757
+ private started;
1758
+ private teardowns;
1759
+ private errors;
1760
+ private listeners;
1761
+ /** True while a capture is being processed (a throw inside must not recurse). */
1762
+ private capturing;
1763
+ constructor(options?: ErrorWatcherOptions);
1764
+ /** Attach the listeners and wrap `console.error`. Idempotent; no-op in SSR. */
1765
+ start(): void;
1766
+ /** Remove the listeners, restore `console.error`, drop subscribers. */
1767
+ destroy(): void;
1768
+ /**
1769
+ * Record an error the app caught itself (error boundary, framework error
1770
+ * handler, try/catch). `context` is size-clamped before it is stored.
1771
+ */
1772
+ report(error: unknown, context?: Record<string, unknown>): void;
1773
+ /** Subscribe to captures (fires once per capture, repeats included). */
1774
+ subscribe(listener: (error: CapturedError) => void): () => void;
1775
+ /** Errors still within `maxAgeMs`, oldest first (a copy). */
1776
+ getErrors(): CapturedError[];
1777
+ clear(): void;
1778
+ private onErrorEvent;
1779
+ private onRejectionEvent;
1780
+ private wrapConsoleError;
1781
+ private onConsoleError;
1782
+ private capture;
1783
+ private notify;
1784
+ private prune;
1785
+ /** Drop the leading "Name: message" line stacks repeat, then cap the length. */
1786
+ private trimStack;
1787
+ private currentPathname;
1788
+ }
1789
+
1790
+ export declare interface ErrorWatcherOptions {
1791
+ /** Max distinct errors kept. Oldest dropped first. Default 10. */
1792
+ maxErrors?: number;
1793
+ /**
1794
+ * Errors older than this are pruned when the buffer is read, so a crash from
1795
+ * an hour ago does not confuse the agent. Default 600 000 (10 min).
1796
+ */
1797
+ maxAgeMs?: number;
1798
+ /** Max chars of stack kept per error. Default 2000. */
1799
+ maxStackChars?: number;
1800
+ /**
1801
+ * Redact or drop an error before it is stored. Return the (possibly edited)
1802
+ * error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
1803
+ */
1804
+ filter?: (error: CapturedError) => CapturedError | null;
1805
+ }
1806
+
1543
1807
  /**
1544
1808
  * Simple typed event emitter
1545
1809
  */
@@ -1564,6 +1828,40 @@ export declare class EventEmitter<Events extends Record<string, any> = Record<st
1564
1828
 
1565
1829
  declare type EventHandler<T = unknown> = (data: T) => void;
1566
1830
 
1831
+ /** The four values of {@link FeedbackReason}, in dashboard order. */
1832
+ export declare const FEEDBACK_REASONS: readonly FeedbackReason[];
1833
+
1834
+ /**
1835
+ * Why the user is reporting a message (see `AgoClient.submitFeedback`).
1836
+ *
1837
+ * A rating on its own is a reaction (the thumbs count). Add a reason or a
1838
+ * comment and the report also lands in the feedback dashboard, the analytics
1839
+ * and the CSV export, where someone can act on it.
1840
+ */
1841
+ export declare interface FeedbackDetails {
1842
+ /** What went wrong. Several can apply at once. */
1843
+ reasons?: FeedbackReason[];
1844
+ /** The user's own words. Trimmed server-side; 5000 characters max. */
1845
+ comment?: string;
1846
+ }
1847
+
1848
+ /** Thumbs up / thumbs down on an answer. */
1849
+ export declare type FeedbackRating = "positive" | "negative";
1850
+
1851
+ /**
1852
+ * What went wrong with an answer. These are the four buckets the AGO feedback
1853
+ * dashboard filters and charts on.
1854
+ */
1855
+ export declare type FeedbackReason =
1856
+ /** The answer states something false. */
1857
+ "inaccurate"
1858
+ /** The answer is right but stops short. */
1859
+ | "incomplete"
1860
+ /** The agent could not find the information. */
1861
+ | "information_not_found"
1862
+ /** Something broke: the widget, a tool call, the stream. */
1863
+ | "technical_issue";
1864
+
1567
1865
  /** Human-readable file size (e.g. "12.3 KB"). Empty string when size is unknown. */
1568
1866
  export declare function formatFileSize(bytes?: number): string;
1569
1867
 
@@ -2274,6 +2572,12 @@ export declare interface ProactiveTriggerWhen {
2274
2572
  pageState?: Partial<Record<string, unknown>>;
2275
2573
  /** Min rage-click bursts on the current route. */
2276
2574
  rageClicks?: number;
2575
+ /**
2576
+ * Min JavaScript errors captured on the current route. Needs the client's
2577
+ * `errorWatcher` enabled; without it the count stays at 0 and the matcher
2578
+ * never passes.
2579
+ */
2580
+ jsErrors?: number;
2277
2581
  /** Min A→B→A→B route oscillations this session. */
2278
2582
  routeBounces?: number;
2279
2583
  /** Per-field minimum error counts (field NAME → min count). */
@@ -2317,10 +2621,69 @@ export declare function safeAttachmentUrl(url?: string): string | undefined;
2317
2621
  */
2318
2622
  export declare const scrollToElement: ClientFunctionDefinition;
2319
2623
 
2624
+ /** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
2625
+ declare interface SdkConfig {
2626
+ permissions: SdkPermissionConfig[];
2627
+ proactive: {
2628
+ enabled: boolean;
2629
+ };
2630
+ }
2631
+
2632
+ /** The dashboard's home screen content (title, subtitle, starter cards). */
2633
+ declare interface SdkHomePageConfig {
2634
+ title?: string;
2635
+ /** Markdown. */
2636
+ subtitle?: string;
2637
+ starters: SdkHomeStarter[];
2638
+ widgetStarter?: SdkWidgetStarter;
2639
+ }
2640
+
2641
+ /**
2642
+ * A conversation starter card configured in the AGO dashboard. `label` is what
2643
+ * the card shows; clicking it sends `message`.
2644
+ */
2645
+ declare interface SdkHomeStarter {
2646
+ id: string;
2647
+ /** The card's text (the starter's `description` in the dashboard). */
2648
+ label: string;
2649
+ /** What is sent when the card is clicked. */
2650
+ message: string;
2651
+ /** Answer with this agent instead of the configured default. */
2652
+ agentId?: string;
2653
+ }
2654
+
2655
+ /** One permission's configuration in {@link SdkConfig}. */
2656
+ declare interface SdkPermissionConfig {
2657
+ id?: string;
2658
+ name?: string;
2659
+ displayName?: string;
2660
+ agents: Array<{
2661
+ id: string;
2662
+ name?: string;
2663
+ }>;
2664
+ ticketForm?: TicketForm;
2665
+ /** Home screen content, when the tenant configured one. */
2666
+ homePage?: SdkHomePageConfig;
2667
+ fileAttachmentsEnabled: boolean;
2668
+ voiceEnabled: boolean;
2669
+ }
2670
+
2671
+ /**
2672
+ * The starter the dashboard sends by itself on a fresh visit, before the
2673
+ * visitor types anything.
2674
+ */
2675
+ declare interface SdkWidgetStarter {
2676
+ id: string;
2677
+ message: string;
2678
+ agentId?: string;
2679
+ }
2680
+
2320
2681
  /**
2321
2682
  * Options for sending a message
2322
2683
  */
2323
2684
  export declare interface SendMessageOptions {
2685
+ /** Replaces config.metadata for this message; null omits metadata for this message. */
2686
+ metadata?: Record<string, unknown> | null;
2324
2687
  /** Existing conversation ID */
2325
2688
  conversationId?: string;
2326
2689
  /** Override default agent */
@@ -2386,8 +2749,9 @@ export declare interface Signal {
2386
2749
 
2387
2750
  /**
2388
2751
  * Framework-agnostic collector of client-side friction signals: per-route
2389
- * dwell time, idle time, route bounces (A→B→A→B), rage clicks, and app-pushed
2390
- * field error counters. Attached to an `AgoClient` by `createAgoProactive`,
2752
+ * dwell time, idle time, route bounces (A→B→A→B), rage clicks, app-pushed
2753
+ * field error counters, and JavaScript error counts (pushed by the client's
2754
+ * `ErrorWatcher` through `createAgoProactive`). Attached to an `AgoClient` by `createAgoProactive`,
2391
2755
  * the same way `ClientContextRegistry` is attached.
2392
2756
  *
2393
2757
  * Route observation is poll-on-demand rather than a `history.pushState` patch:
@@ -2419,6 +2783,7 @@ export declare class SignalCollector {
2419
2783
  private recentRoutes;
2420
2784
  private routeBounces;
2421
2785
  private rageClicks;
2786
+ private jsErrors;
2422
2787
  private fieldErrors;
2423
2788
  private recentClicks;
2424
2789
  private signals;
@@ -2436,9 +2801,15 @@ export declare class SignalCollector {
2436
2801
  * Pass the field NAME only — values are never read, so no PII is collected.
2437
2802
  */
2438
2803
  signalFieldError(fieldName: string): void;
2804
+ /**
2805
+ * Pushed signal: a JavaScript error was captured on the page. Counter only;
2806
+ * `kind` says how it was caught (`error`, `unhandledrejection`, `console`,
2807
+ * `manual`). The message itself never enters the signals channel.
2808
+ */
2809
+ signalJsError(kind: string): void;
2439
2810
  /**
2440
2811
  * Subscribe to raw signals (route changes, bounces, rage clicks, field
2441
- * errors). Returns an unsubscribe function. Used by the proactive engine to
2812
+ * errors, JS errors). Returns an unsubscribe function. Used by the proactive engine to
2442
2813
  * evaluate promptly instead of waiting for the next tick.
2443
2814
  */
2444
2815
  subscribe(listener: (signal: Signal) => void): () => void;
@@ -2508,6 +2879,12 @@ export declare interface SignalsSnapshot {
2508
2879
  idleMs: number;
2509
2880
  /** Rage-click bursts detected on the current route. */
2510
2881
  rageClicks: number;
2882
+ /**
2883
+ * JavaScript errors captured on the current route (count only; the messages
2884
+ * travel in `client_context` under `errors:recent`). Always `0` unless the
2885
+ * client has `errorWatcher` enabled.
2886
+ */
2887
+ jsErrors: number;
2511
2888
  /**
2512
2889
  * A→B→A→B route oscillations detected in the recent route sequence. Rolling
2513
2890
  * session counter (cross-route by nature); trigger cooldowns and dismissal
@@ -2531,7 +2908,7 @@ export declare interface SignalsSnapshot {
2531
2908
  * Privacy rule: signals carry **enums, counters, and paths only** — never field
2532
2909
  * values or free text — so no PII ever leaves the page through this channel.
2533
2910
  */
2534
- export declare type SignalType = "route_change" | "route_bounce" | "rage_click" | "field_error";
2911
+ export declare type SignalType = "route_change" | "route_bounce" | "rage_click" | "field_error" | "js_error";
2535
2912
 
2536
2913
  /**
2537
2914
  * SSE stream chunk data
@@ -2574,6 +2951,13 @@ export declare interface SSEChunkData {
2574
2951
  follow_up_replies?: string[];
2575
2952
  satisfaction_feedback?: unknown;
2576
2953
  ask_to_talk_to_human?: boolean;
2954
+ allowed_to_create_ticket?: boolean;
2955
+ ticket?: ToolCallTicketPrefill;
2956
+ mode?: "form" | "embed";
2957
+ ticket_form_id?: string;
2958
+ embed_html?: string;
2959
+ embed_description?: string;
2960
+ display_mode?: "collapsible" | "display" | "both";
2577
2961
  /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
2578
2962
  waiting_tool_call_ids?: string[];
2579
2963
  }
@@ -2742,12 +3126,82 @@ export declare const submitForm: ClientFunctionDefinition;
2742
3126
  export declare interface SubmitToolCallResult {
2743
3127
  status: string;
2744
3128
  result?: unknown;
3129
+ /** Set when `status` is `"error"`. */
3130
+ error?: string;
3131
+ /** The ticket a ticketing `form` tool call resolved to, when it did. */
3132
+ ticket?: {
3133
+ ticket_id: string;
3134
+ ticket_url?: string;
3135
+ [key: string]: unknown;
3136
+ };
2745
3137
  resume?: {
2746
3138
  message_id: string;
2747
3139
  ready: boolean;
2748
3140
  };
2749
3141
  }
2750
3142
 
3143
+ /** A custom field of a ticket form. */
3144
+ declare interface TicketField {
3145
+ id: string;
3146
+ /** The key the ticketing backend expects; used as the submit key when set. */
3147
+ externalId?: string;
3148
+ title?: string;
3149
+ /** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
3150
+ type?: string;
3151
+ required: boolean;
3152
+ /** Carried in the submission but never shown. */
3153
+ hidden: boolean;
3154
+ active?: boolean;
3155
+ /** Bypass progressive disclosure, while still respecting conditions. */
3156
+ alwaysVisible?: boolean;
3157
+ regexpForValidation?: string;
3158
+ position: number;
3159
+ /** Non-empty turns the field into a select. */
3160
+ options: TicketFieldOption[];
3161
+ /** Show this field only when the parent field holds `conditionalFieldValue`. */
3162
+ conditionalFieldId?: string;
3163
+ /** Legacy comma-separated condition values. */
3164
+ conditionalFieldValue?: string;
3165
+ /** Takes precedence over conditionalFieldValue when non-empty. */
3166
+ conditionalFieldValues?: string[];
3167
+ }
3168
+
3169
+ /** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
3170
+ declare interface TicketFieldOption {
3171
+ id: string;
3172
+ /** Label shown to the user. */
3173
+ name?: string;
3174
+ /** Value submitted. Falls back to `name` when absent. */
3175
+ value?: string;
3176
+ /** Preselected when the form opens. */
3177
+ default: boolean;
3178
+ /** A note shown under the field once this option is picked. */
3179
+ message?: string;
3180
+ messageType: "info" | "warning" | "danger";
3181
+ position?: number;
3182
+ group?: string;
3183
+ noDisplay?: boolean;
3184
+ conditionalFieldId?: string;
3185
+ /** Available when the parent matches any of these values. */
3186
+ conditionalFieldValues?: string[];
3187
+ }
3188
+
3189
+ /** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
3190
+ declare interface TicketForm {
3191
+ id: string;
3192
+ name?: string;
3193
+ /** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
3194
+ mode: "form" | "embed";
3195
+ showSubject: boolean;
3196
+ showBody: boolean;
3197
+ showPriority: boolean;
3198
+ showTypology: boolean;
3199
+ priorityTypologies?: string[];
3200
+ successMessageText?: string;
3201
+ successMessageUrlLabel?: string;
3202
+ fields: TicketField[];
3203
+ }
3204
+
2751
3205
  /**
2752
3206
  * Tool call data from SSE stream
2753
3207
  */
@@ -2762,6 +3216,34 @@ export declare interface ToolCallData {
2762
3216
  data?: Record<string, unknown>;
2763
3217
  functionName?: string;
2764
3218
  arguments?: Record<string, unknown>;
3219
+ /**
3220
+ * Where the hosted widget shows the call: in the collapsible "reasoning"
3221
+ * section, in the message body, or both. Absent means collapsible only.
3222
+ */
3223
+ displayMode?: "collapsible" | "display" | "both";
3224
+ /** The user asked to talk to a human. */
3225
+ askToTalkToHuman?: boolean;
3226
+ /** `false` when the tenant blocks ticket creation for this visitor. */
3227
+ allowedToCreateTicket?: boolean;
3228
+ /** Fields the agent pre-filled from the conversation. */
3229
+ ticket?: ToolCallTicketPrefill;
3230
+ /** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
3231
+ mode?: "form" | "embed";
3232
+ ticketFormId?: string;
3233
+ embedHtml?: string;
3234
+ embedDescription?: string;
3235
+ }
3236
+
3237
+ /** The ticket the agent pre-filled on a ticketing `form` tool call. */
3238
+ declare interface ToolCallTicketPrefill {
3239
+ subject?: string;
3240
+ body?: string;
3241
+ typology?: string;
3242
+ priority?: string;
3243
+ tag?: string;
3244
+ products?: string[];
3245
+ /** Keyed by the field's external id, or a lowercased, underscored title. */
3246
+ custom_fields?: Record<string, string>;
2765
3247
  }
2766
3248
 
2767
3249
  export declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";