@useago/sdk 1.9.0 → 1.13.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 (49) hide show
  1. package/CHANGELOG.md +173 -2
  2. package/README.md +126 -0
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +408 -26
  5. package/dist/angular.d.ts +408 -26
  6. package/dist/angular.js +4 -1
  7. package/dist/{createConversationSession-BaaXBQ5b.js → createConversationSession-BfJg0WyA.js} +1 -1
  8. package/dist/{createConversationSession-CU0b-t1W.cjs → createConversationSession-CiOXKWl0.cjs} +1 -1
  9. package/dist/{createFormCollector-Cf7kGhCB.js → createFormCollector-DN1xjAv5.js} +1 -1
  10. package/dist/{createFormCollector-DfN1xZBy.cjs → createFormCollector-DnQl77Ko.cjs} +1 -1
  11. package/dist/createMockClient-BPt1gSve.cjs +1 -0
  12. package/dist/{createMockClient-5YF-ZbVu.js → createMockClient-YoYr3pQr.js} +16 -3
  13. package/dist/devtools.cjs +4 -4
  14. package/dist/devtools.d.cts +406 -26
  15. package/dist/devtools.d.ts +406 -26
  16. package/dist/devtools.js +87 -84
  17. package/dist/helpers.d.cts +42 -12
  18. package/dist/helpers.d.ts +42 -12
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +486 -35
  21. package/dist/index.d.ts +486 -35
  22. package/dist/index.js +117 -112
  23. package/dist/react.cjs +4 -4
  24. package/dist/react.d.cts +458 -26
  25. package/dist/react.d.ts +458 -26
  26. package/dist/react.js +816 -727
  27. package/dist/speechToText-BV7qxqPF.js +704 -0
  28. package/dist/speechToText-ZciRyyJE.cjs +1 -0
  29. package/dist/testing.cjs +1 -1
  30. package/dist/testing.d.cts +406 -26
  31. package/dist/testing.d.ts +406 -26
  32. package/dist/testing.js +1 -1
  33. package/dist/types-Q7t1peH-.js +2584 -0
  34. package/dist/types-a7teDBnC.cjs +10 -0
  35. package/dist/vue.cjs +1 -1
  36. package/dist/vue.d.cts +608 -26
  37. package/dist/vue.d.ts +608 -26
  38. package/dist/vue.js +103 -101
  39. package/dist/widget.cjs +6 -4
  40. package/dist/widget.d.cts +710 -28
  41. package/dist/widget.d.ts +710 -28
  42. package/dist/widget.js +3911 -976
  43. package/llms-full.txt +254 -7
  44. package/package.json +1 -1
  45. package/dist/createMockClient-BZbOe-23.cjs +0 -1
  46. package/dist/sheetController-CBUVOroo.js +0 -205
  47. package/dist/sheetController-DY-sC13T.cjs +0 -1
  48. package/dist/types-CPga11Of.js +0 -2068
  49. package/dist/types-D3YQl1jx.cjs +0 -9
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). */
@@ -130,7 +131,10 @@ export declare class AgoClient {
130
131
  * `null` otherwise.
131
132
  */
132
133
  proactive: ProactiveController | null;
134
+ /** Removes the mirrored WebMCP tools; `null` when the bridge is off. */
135
+ private detachWebMCP;
133
136
  constructor(config: AgoConfig);
137
+ private attachWebMCPBridge;
134
138
  /**
135
139
  * Send a message and receive a streaming response
136
140
  */
@@ -242,6 +246,7 @@ export declare class AgoClient {
242
246
  * (the agent decides what to do next). No-op if the invocation is unknown.
243
247
  */
244
248
  rejectFunction(invocationId: string): Promise<void>;
249
+ /* Excluded from this release type: runExternalFunction */
245
250
  /**
246
251
  * Get a page of conversations, newest-first. `pageSize` is capped at 100 by
247
252
  * the backend (default 50). Returns the `{ data, has_more, total }` envelope
@@ -261,6 +266,35 @@ export declare class AgoClient {
261
266
  * `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
262
267
  */
263
268
  private static mapPersistedToolCalls;
269
+ /**
270
+ * Transcribe an audio file into editable text (`POST /api/sdk/v1/audio/transcriptions`).
271
+ * Requires speech to text to be enabled for the tenant. Supports FLAC, MP3,
272
+ * MP4, MPEG, MPGA, M4A, OGG, WAV and WebM files up to 25 MB.
273
+ * The filename must include the matching extension. For a MediaRecorder blob,
274
+ * wrap it in a File with the recording's extension and MIME type.
275
+ * Show the returned text as a draft; call `sendMessage` when the user sends it.
276
+ */
277
+ transcribeAudio(file: File, options?: TranscribeAudioOptions): Promise<AudioTranscription>;
278
+ /**
279
+ * The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
280
+ * agents, the ticket form the agent's `ago_ticketing` tool opens, and the
281
+ * file-attachment and speech-to-text flags. The vanilla widget fetches it
282
+ * once, when a ticket form first appears in a conversation.
283
+ */
284
+ getConfig(): Promise<SdkConfig>;
285
+ /**
286
+ * The dashboard's home screen content. A starter card shows its
287
+ * `description` and sends its `initial_message`; one with neither is
288
+ * unusable and is dropped rather than rendered as an empty card.
289
+ */
290
+ private static mapHomePage;
291
+ private static mapTicketForm;
292
+ /**
293
+ * Create a support ticket (`POST /api/sdk/v1/tickets`, multipart). This is
294
+ * what the ticket form in the conversation does before it completes the
295
+ * `form` tool call with {@link submitToolCallForm}.
296
+ */
297
+ createTicket(input: CreateTicketInput): Promise<CreateTicketResult>;
264
298
  /**
265
299
  * Get messages for a conversation
266
300
  */
@@ -382,6 +416,9 @@ export declare class AgoClient {
382
416
  * Get all registered function schemas
383
417
  */
384
418
  getRegisteredFunctions(): ClientFunctionSchema[];
419
+ /** The callback form of `functions:changed`. Returns an unsubscribe. */
420
+ onFunctionsChanged(listener: () => void): () => void;
421
+ /* Excluded from this release type: getFunctionRegistrations */
385
422
  /**
386
423
  * Execute a registered client function locally, through the same
387
424
  * FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
@@ -519,6 +556,15 @@ export declare class AgoClient {
519
556
  /* Excluded from this release type: emitProactiveEvent */
520
557
  /* Excluded from this release type: getHttp */
521
558
  /* Excluded from this release type: getConfiguredAgent */
559
+ /**
560
+ * How the SDK identifies the visitor: the configured `userEmail`, and
561
+ * whether a `userJwt` is set. The ticket form asks for an email when it has
562
+ * neither.
563
+ */
564
+ getUserIdentity(): {
565
+ email?: string;
566
+ hasJwt: boolean;
567
+ };
522
568
  /**
523
569
  * Enable automatic capture of the current browser page (URL + title).
524
570
  * Injected as a dynamic context entry named `browser-page`.
@@ -541,6 +587,26 @@ export declare class AgoClient {
541
587
  private addActivity;
542
588
  private recordAgentAction;
543
589
  private registerActivityContext;
590
+ /**
591
+ * Start capturing the page's JavaScript errors (uncaught exceptions,
592
+ * unhandled rejections, `console.error` calls, {@link reportError}) and send
593
+ * the recent ones as the `errors:recent` context entry on every message.
594
+ * Same as setting `errorWatcher` in the config. Calling it again replaces
595
+ * the watcher (and its options); the captured errors are not kept.
596
+ */
597
+ enableErrorWatcher(options?: ErrorWatcherOptions): void;
598
+ /** Stop capturing errors and drop the `errors:recent` context entry. */
599
+ disableErrorWatcher(): void;
600
+ /**
601
+ * Record an error the app caught itself (React error boundary, Vue
602
+ * `errorHandler`, Angular `ErrorHandler`, a try/catch) so the agent sees it
603
+ * like an uncaught one. No-op unless the error watcher is enabled. `context`
604
+ * is size-clamped before it is stored; keep it small and free of secrets.
605
+ */
606
+ reportError(error: unknown, context?: Record<string, unknown>): void;
607
+ /** Errors the watcher currently holds, oldest first (a copy). Empty when disabled. */
608
+ getRecentErrors(): CapturedError[];
609
+ clearErrors(): void;
544
610
  /**
545
611
  * Subscribe to an event
546
612
  */
@@ -685,6 +751,8 @@ export declare interface AgoClientEvents {
685
751
  * call running immediately.
686
752
  */
687
753
  "function:awaiting-approval": ClientFunctionInvocation;
754
+ /** A function was registered or unregistered, or the registry cleared. */
755
+ "functions:changed": ClientFunctionSchema[];
688
756
  "function:result": {
689
757
  invocationId: string;
690
758
  result: unknown;
@@ -735,6 +803,12 @@ export declare interface AgoClientEvents {
735
803
  };
736
804
  /** A user- or agent-action was recorded into the activity ledger. */
737
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;
738
812
  }
739
813
 
740
814
  /**
@@ -751,10 +825,14 @@ export declare interface AgoConfig {
751
825
  defaultAgentId?: string;
752
826
  /** Permission name to apply to all requests (sent as `X-Widget-Permission`). Mirrors the widget's `window.AGO.permission`. */
753
827
  permission?: string;
828
+ /** Interface locale selected by the host app, sent as Accept-Language. Null clears the override. */
829
+ language?: string | null;
754
830
  /** User email for identification */
755
831
  userEmail?: string;
756
832
  /** JWT token for authenticated users */
757
833
  userJwt?: string;
834
+ /** User metadata sent with messages. Use null to stop sending defaults. Not an authentication credential. */
835
+ metadata?: Record<string, unknown> | null;
758
836
  /** Enable debug logging */
759
837
  debug?: boolean;
760
838
  /**
@@ -814,6 +892,27 @@ export declare interface AgoConfig {
814
892
  * default otherwise.
815
893
  */
816
894
  proactive?: ProactiveOptions;
895
+ /**
896
+ * Capture the page's JavaScript errors as agent context. When set, the SDK
897
+ * listens for uncaught exceptions and unhandled promise rejections, wraps
898
+ * `console.error` (calling through; restored on `destroy`), and sends the
899
+ * recent errors (deduplicated, capped, pruned after 10 min) as the
900
+ * `errors:recent` context entry on every message. `true` uses the defaults;
901
+ * pass {@link ErrorWatcherOptions} to tune the caps or add a `filter` that
902
+ * redacts messages. Off by default: error messages can carry PII or internal
903
+ * URLs, so enabling it is the host's call. Errors also feed the proactive
904
+ * mode's `jsErrors` signal. See `client.reportError()` for caught errors.
905
+ */
906
+ errorWatcher?: boolean | ErrorWatcherOptions;
907
+ /** Mirror every registered client function into the browser's WebMCP registry
908
+ * (`document.modelContext`), so an external agent can call the same functions
909
+ * the in-app agent calls. Off by default; no-ops without WebMCP.
910
+ *
911
+ * A mirrored function runs immediately: the approval gate
912
+ * ({@link approvalPolicy}, `requiresApproval`) covers the agent loop only.
913
+ * Use `webmcp: false` on a definition to keep it out.
914
+ */
915
+ webmcp?: boolean;
817
916
  }
818
917
 
819
918
  /**
@@ -1130,6 +1229,11 @@ declare interface ApiErrorResponse {
1130
1229
  */
1131
1230
  export declare function attachAutoContinueAfterNavigation(client: AgoClient, options?: AgoAutoContinueOptions | (() => AgoAutoContinueOptions | undefined)): () => void;
1132
1231
 
1232
+ /** Editable text returned by `AgoClient.transcribeAudio`. */
1233
+ export declare interface AudioTranscription {
1234
+ text: string;
1235
+ }
1236
+
1133
1237
  /**
1134
1238
  * Auto-detect AGO configuration from the DOM environment.
1135
1239
  *
@@ -1151,6 +1255,32 @@ export declare function autoDetectConfig(overrides?: Partial<AgoConfig>): AgoCon
1151
1255
  */
1152
1256
  export declare function canInlineImage(attachment: AgoAttachment): boolean;
1153
1257
 
1258
+ /** One JavaScript error captured on the page (deduplicated, see `count`). */
1259
+ export declare interface CapturedError {
1260
+ type: CapturedErrorType;
1261
+ /** Error message, truncated to 500 chars. */
1262
+ message: string;
1263
+ /** Script URL the error came from, without its query string. */
1264
+ source?: string;
1265
+ line?: number;
1266
+ col?: number;
1267
+ /** Leading stack frames, truncated (see `maxStackChars`). */
1268
+ stack?: string;
1269
+ /** Pathname at capture time. */
1270
+ route: string;
1271
+ /** Epoch ms of the first occurrence. */
1272
+ firstAt: number;
1273
+ /** Epoch ms of the most recent occurrence. */
1274
+ lastAt: number;
1275
+ /** How many times this same error (type + message + source + line) fired. */
1276
+ count: number;
1277
+ /** App-provided context, manual reports only (size-clamped). */
1278
+ context?: Record<string, unknown>;
1279
+ }
1280
+
1281
+ /** How an error reached the watcher. */
1282
+ export declare type CapturedErrorType = "error" | "unhandledrejection" | "console" | "manual";
1283
+
1154
1284
  /**
1155
1285
  * Registry that collects client-side context from across the component tree.
1156
1286
  *
@@ -1207,22 +1337,11 @@ export declare type ClientFunction = (args: Record<string, unknown>) => Promise<
1207
1337
  * client.registerFunction(fn);
1208
1338
  * ```
1209
1339
  */
1210
- export declare interface ClientFunctionDefinition {
1340
+ export declare interface ClientFunctionDefinition extends ClientFunctionSettings {
1211
1341
  name: string;
1212
1342
  description: string;
1213
1343
  parameters: ClientFunctionSchema["parameters"];
1214
1344
  handler: ClientFunctionHandler;
1215
- /**
1216
- * Max serialized result size in bytes before the SDK truncates it to a
1217
- * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
1218
- * `Infinity` disables the guard for this function.
1219
- */
1220
- maxResultBytes?: number;
1221
- /**
1222
- * Require explicit user approval before this function runs. See
1223
- * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1224
- */
1225
- requiresApproval?: boolean;
1226
1345
  }
1227
1346
 
1228
1347
  /**
@@ -1241,20 +1360,7 @@ export declare interface ClientFunctionInvocation {
1241
1360
  * Schema-plus-settings object accepted when registering a function: the schema
1242
1361
  * (minus `name`) and SDK-side options that are NOT sent to the backend.
1243
1362
  */
1244
- export declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
1245
- /**
1246
- * Max serialized result size in bytes before the SDK truncates it to a
1247
- * flagged preview. Overrides the client-level default
1248
- * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
1249
- * disables the guard for this function.
1250
- */
1251
- maxResultBytes?: number;
1252
- /**
1253
- * Require explicit user approval before this function runs. See
1254
- * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1255
- */
1256
- requiresApproval?: boolean;
1257
- };
1363
+ export declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & ClientFunctionSettings;
1258
1364
 
1259
1365
  /**
1260
1366
  * Schema for a client-side function that AGO can call
@@ -1281,6 +1387,28 @@ export declare interface ClientFunctionSchema {
1281
1387
  };
1282
1388
  }
1283
1389
 
1390
+ /** SDK-side function settings that are never sent to the backend. */
1391
+ declare interface ClientFunctionSettings {
1392
+ /**
1393
+ * Max serialized result size in bytes before the SDK truncates it to a
1394
+ * flagged preview. Overrides the client-level default
1395
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
1396
+ * disables the guard for this function.
1397
+ */
1398
+ maxResultBytes?: number;
1399
+ /**
1400
+ * Require explicit user approval before this function runs. See
1401
+ * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1402
+ */
1403
+ requiresApproval?: boolean;
1404
+ /**
1405
+ * WebMCP metadata, read only when the bridge is on (`AgoConfig.webmcp`).
1406
+ * `false` keeps this function out of WebMCP while leaving it available to the
1407
+ * in-app agent.
1408
+ */
1409
+ webmcp?: WebMCPToolMeta | false;
1410
+ }
1411
+
1284
1412
  /** See {@link AgoConfig.clientFunctionsMode}. */
1285
1413
  export declare type ClientFunctionsMode = "placeholder" | "pause";
1286
1414
 
@@ -1559,8 +1687,36 @@ export declare function createMockClient(options?: MockAgoClientOptions): MockAg
1559
1687
 
1560
1688
  export declare function createStore<T>(initial: T, persist?: PersistOptions): Store<T>;
1561
1689
 
1690
+ /** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
1691
+ declare interface CreateTicketInput {
1692
+ subject: string;
1693
+ body: string;
1694
+ priority?: string;
1695
+ typology?: string;
1696
+ /** Conversation the ticket is filed from. */
1697
+ conversationId?: string;
1698
+ /** Reporter email, for a visitor the SDK does not otherwise identify. */
1699
+ email?: string;
1700
+ customFields?: Array<{
1701
+ id: string;
1702
+ value: string;
1703
+ }>;
1704
+ files?: File[];
1705
+ ticketFormId?: string;
1706
+ }
1707
+
1708
+ /** Response of `AgoClient.createTicket`. */
1709
+ declare interface CreateTicketResult {
1710
+ id: string;
1711
+ url?: string;
1712
+ }
1713
+
1562
1714
  export declare const DEFAULT_MAX_ACTIVITY_ENTRIES = 10;
1563
1715
 
1716
+ export declare const DEFAULT_MAX_ERROR_AGE_MS = 600000;
1717
+
1718
+ export declare const DEFAULT_MAX_ERRORS = 10;
1719
+
1564
1720
  /**
1565
1721
  * Create a reusable function definition.
1566
1722
  * Returns the same object — this is an identity function for discoverability and type-checking.
@@ -1603,6 +1759,83 @@ export declare function deriveFormStatus(schema: FormCollectorSchema, values: Pa
1603
1759
  */
1604
1760
  export declare type DynamicContextProvider = () => ContextEntry | null | undefined;
1605
1761
 
1762
+ /**
1763
+ * Captures the page's JavaScript errors so they can ride along as agent
1764
+ * context: uncaught exceptions (`window` `error` event), unhandled promise
1765
+ * rejections, every `console.error` call, and errors the app reports itself
1766
+ * via {@link report}.
1767
+ *
1768
+ * Errors are deduplicated by type + message + source + line (a repeat bumps
1769
+ * `count` and `lastAt`), capped at `maxErrors`, and pruned after `maxAgeMs`
1770
+ * when read. Messages and stacks are truncated so one error cannot bloat the
1771
+ * context.
1772
+ *
1773
+ * `console.error` capture wraps the console method. This is the one sanctioned
1774
+ * exception to the SDK's no-global-mutation rule: the wrapper always calls the
1775
+ * original, ignores the SDK's own `[AGO SDK]` lines, and is restored by
1776
+ * {@link destroy} when it is still installed (another library may have
1777
+ * wrapped it after us; in that case ours stays in the chain and keeps calling
1778
+ * through).
1779
+ *
1780
+ * Attached by `AgoClient` when `errorWatcher` is set in the config; usable
1781
+ * standalone. Listeners are attached only by `start()` and removed by
1782
+ * `destroy()`. No-op outside a browser (SSR).
1783
+ */
1784
+ export declare class ErrorWatcher {
1785
+ private readonly maxErrors;
1786
+ private readonly maxAgeMs;
1787
+ private readonly maxStackChars;
1788
+ private readonly filter?;
1789
+ private started;
1790
+ private teardowns;
1791
+ private errors;
1792
+ private listeners;
1793
+ /** True while a capture is being processed (a throw inside must not recurse). */
1794
+ private capturing;
1795
+ constructor(options?: ErrorWatcherOptions);
1796
+ /** Attach the listeners and wrap `console.error`. Idempotent; no-op in SSR. */
1797
+ start(): void;
1798
+ /** Remove the listeners, restore `console.error`, drop subscribers. */
1799
+ destroy(): void;
1800
+ /**
1801
+ * Record an error the app caught itself (error boundary, framework error
1802
+ * handler, try/catch). `context` is size-clamped before it is stored.
1803
+ */
1804
+ report(error: unknown, context?: Record<string, unknown>): void;
1805
+ /** Subscribe to captures (fires once per capture, repeats included). */
1806
+ subscribe(listener: (error: CapturedError) => void): () => void;
1807
+ /** Errors still within `maxAgeMs`, oldest first (a copy). */
1808
+ getErrors(): CapturedError[];
1809
+ clear(): void;
1810
+ private onErrorEvent;
1811
+ private onRejectionEvent;
1812
+ private wrapConsoleError;
1813
+ private onConsoleError;
1814
+ private capture;
1815
+ private notify;
1816
+ private prune;
1817
+ /** Drop the leading "Name: message" line stacks repeat, then cap the length. */
1818
+ private trimStack;
1819
+ private currentPathname;
1820
+ }
1821
+
1822
+ export declare interface ErrorWatcherOptions {
1823
+ /** Max distinct errors kept. Oldest dropped first. Default 10. */
1824
+ maxErrors?: number;
1825
+ /**
1826
+ * Errors older than this are pruned when the buffer is read, so a crash from
1827
+ * an hour ago does not confuse the agent. Default 600 000 (10 min).
1828
+ */
1829
+ maxAgeMs?: number;
1830
+ /** Max chars of stack kept per error. Default 2000. */
1831
+ maxStackChars?: number;
1832
+ /**
1833
+ * Redact or drop an error before it is stored. Return the (possibly edited)
1834
+ * error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
1835
+ */
1836
+ filter?: (error: CapturedError) => CapturedError | null;
1837
+ }
1838
+
1606
1839
  /**
1607
1840
  * Simple typed event emitter
1608
1841
  */
@@ -1844,7 +2077,11 @@ export declare interface FunctionDefinition {
1844
2077
  export declare class FunctionRegistry {
1845
2078
  private functions;
1846
2079
  private defaultMaxResultBytes;
2080
+ private changeListeners;
1847
2081
  constructor(options?: FunctionRegistryOptions);
2082
+ /** Fires on registrations, unregistrations and clears. */
2083
+ onChange(listener: () => void): () => void;
2084
+ private emitChange;
1848
2085
  /** Update the client-level result-size ceiling at runtime. */
1849
2086
  setDefaultMaxResultBytes(bytes: number): void;
1850
2087
  /**
@@ -1875,6 +2112,13 @@ export declare class FunctionRegistry {
1875
2112
  * Get all registered function schemas (for sending to backend)
1876
2113
  */
1877
2114
  getSchemas(): ClientFunctionSchema[];
2115
+ /**
2116
+ * Every registration, name included, with the SDK-side settings
2117
+ * {@link getSchemas} drops.
2118
+ */
2119
+ getAll(): Array<RegisteredFunction & {
2120
+ name: string;
2121
+ }>;
1878
2122
  /**
1879
2123
  * Execute a registered function
1880
2124
  */
@@ -2371,6 +2615,12 @@ export declare interface ProactiveTriggerWhen {
2371
2615
  pageState?: Partial<Record<string, unknown>>;
2372
2616
  /** Min rage-click bursts on the current route. */
2373
2617
  rageClicks?: number;
2618
+ /**
2619
+ * Min JavaScript errors captured on the current route. Needs the client's
2620
+ * `errorWatcher` enabled; without it the count stays at 0 and the matcher
2621
+ * never passes.
2622
+ */
2623
+ jsErrors?: number;
2374
2624
  /** Min A→B→A→B route oscillations this session. */
2375
2625
  routeBounces?: number;
2376
2626
  /** Per-field minimum error counts (field NAME → min count). */
@@ -2380,13 +2630,9 @@ export declare interface ProactiveTriggerWhen {
2380
2630
  /**
2381
2631
  * Registered function with handler
2382
2632
  */
2383
- export declare interface RegisteredFunction {
2633
+ export declare interface RegisteredFunction extends ClientFunctionSettings {
2384
2634
  schema: ClientFunctionSchema;
2385
2635
  handler: ClientFunctionHandler;
2386
- /** Per-function result-size ceiling; falls back to the registry default. */
2387
- maxResultBytes?: number;
2388
- /** Require explicit user approval before running (pause mode only). */
2389
- requiresApproval?: boolean;
2390
2636
  }
2391
2637
 
2392
2638
  /**
@@ -2414,10 +2660,71 @@ export declare function safeAttachmentUrl(url?: string): string | undefined;
2414
2660
  */
2415
2661
  export declare const scrollToElement: ClientFunctionDefinition;
2416
2662
 
2663
+ /** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
2664
+ export declare interface SdkConfig {
2665
+ permissions: SdkPermissionConfig[];
2666
+ proactive: {
2667
+ enabled: boolean;
2668
+ };
2669
+ }
2670
+
2671
+ /** The dashboard's home screen content (title, subtitle, starter cards). */
2672
+ declare interface SdkHomePageConfig {
2673
+ title?: string;
2674
+ /** Markdown. */
2675
+ subtitle?: string;
2676
+ starters: SdkHomeStarter[];
2677
+ widgetStarter?: SdkWidgetStarter;
2678
+ }
2679
+
2680
+ /**
2681
+ * A conversation starter card configured in the AGO dashboard. `label` is what
2682
+ * the card shows; clicking it sends `message`.
2683
+ */
2684
+ declare interface SdkHomeStarter {
2685
+ id: string;
2686
+ /** The card's text (the starter's `description` in the dashboard). */
2687
+ label: string;
2688
+ /** What is sent when the card is clicked. */
2689
+ message: string;
2690
+ /** Answer with this agent instead of the configured default. */
2691
+ agentId?: string;
2692
+ }
2693
+
2694
+ /** One permission's configuration in {@link SdkConfig}. */
2695
+ export declare interface SdkPermissionConfig {
2696
+ id?: string;
2697
+ name?: string;
2698
+ displayName?: string;
2699
+ agents: Array<{
2700
+ id: string;
2701
+ name?: string;
2702
+ }>;
2703
+ ticketForm?: TicketForm;
2704
+ /** Home screen content, when the tenant configured one. */
2705
+ homePage?: SdkHomePageConfig;
2706
+ fileAttachmentsEnabled: boolean;
2707
+ voiceEnabled: boolean;
2708
+ /** Whether audio uploads can be transcribed. Defaults to false on older backends. */
2709
+ speechToTextEnabled: boolean;
2710
+ }
2711
+
2712
+ /**
2713
+ * The starter the dashboard sends by itself on a fresh visit, before the
2714
+ * visitor types anything.
2715
+ */
2716
+ declare interface SdkWidgetStarter {
2717
+ id: string;
2718
+ message: string;
2719
+ agentId?: string;
2720
+ }
2721
+
2417
2722
  /**
2418
2723
  * Options for sending a message
2419
2724
  */
2420
2725
  export declare interface SendMessageOptions {
2726
+ /** Replaces config.metadata for this message; null omits metadata for this message. */
2727
+ metadata?: Record<string, unknown> | null;
2421
2728
  /** Existing conversation ID */
2422
2729
  conversationId?: string;
2423
2730
  /** Override default agent */
@@ -2483,8 +2790,9 @@ export declare interface Signal {
2483
2790
 
2484
2791
  /**
2485
2792
  * Framework-agnostic collector of client-side friction signals: per-route
2486
- * dwell time, idle time, route bounces (A→B→A→B), rage clicks, and app-pushed
2487
- * field error counters. Attached to an `AgoClient` by `createAgoProactive`,
2793
+ * dwell time, idle time, route bounces (A→B→A→B), rage clicks, app-pushed
2794
+ * field error counters, and JavaScript error counts (pushed by the client's
2795
+ * `ErrorWatcher` through `createAgoProactive`). Attached to an `AgoClient` by `createAgoProactive`,
2488
2796
  * the same way `ClientContextRegistry` is attached.
2489
2797
  *
2490
2798
  * Route observation is poll-on-demand rather than a `history.pushState` patch:
@@ -2516,6 +2824,7 @@ export declare class SignalCollector {
2516
2824
  private recentRoutes;
2517
2825
  private routeBounces;
2518
2826
  private rageClicks;
2827
+ private jsErrors;
2519
2828
  private fieldErrors;
2520
2829
  private recentClicks;
2521
2830
  private signals;
@@ -2533,9 +2842,15 @@ export declare class SignalCollector {
2533
2842
  * Pass the field NAME only — values are never read, so no PII is collected.
2534
2843
  */
2535
2844
  signalFieldError(fieldName: string): void;
2845
+ /**
2846
+ * Pushed signal: a JavaScript error was captured on the page. Counter only;
2847
+ * `kind` says how it was caught (`error`, `unhandledrejection`, `console`,
2848
+ * `manual`). The message itself never enters the signals channel.
2849
+ */
2850
+ signalJsError(kind: string): void;
2536
2851
  /**
2537
2852
  * Subscribe to raw signals (route changes, bounces, rage clicks, field
2538
- * errors). Returns an unsubscribe function. Used by the proactive engine to
2853
+ * errors, JS errors). Returns an unsubscribe function. Used by the proactive engine to
2539
2854
  * evaluate promptly instead of waiting for the next tick.
2540
2855
  */
2541
2856
  subscribe(listener: (signal: Signal) => void): () => void;
@@ -2605,6 +2920,12 @@ export declare interface SignalsSnapshot {
2605
2920
  idleMs: number;
2606
2921
  /** Rage-click bursts detected on the current route. */
2607
2922
  rageClicks: number;
2923
+ /**
2924
+ * JavaScript errors captured on the current route (count only; the messages
2925
+ * travel in `client_context` under `errors:recent`). Always `0` unless the
2926
+ * client has `errorWatcher` enabled.
2927
+ */
2928
+ jsErrors: number;
2608
2929
  /**
2609
2930
  * A→B→A→B route oscillations detected in the recent route sequence. Rolling
2610
2931
  * session counter (cross-route by nature); trigger cooldowns and dismissal
@@ -2628,7 +2949,7 @@ export declare interface SignalsSnapshot {
2628
2949
  * Privacy rule: signals carry **enums, counters, and paths only** — never field
2629
2950
  * values or free text — so no PII ever leaves the page through this channel.
2630
2951
  */
2631
- export declare type SignalType = "route_change" | "route_bounce" | "rage_click" | "field_error";
2952
+ export declare type SignalType = "route_change" | "route_bounce" | "rage_click" | "field_error" | "js_error";
2632
2953
 
2633
2954
  /**
2634
2955
  * SSE stream chunk data
@@ -2671,6 +2992,13 @@ export declare interface SSEChunkData {
2671
2992
  follow_up_replies?: string[];
2672
2993
  satisfaction_feedback?: unknown;
2673
2994
  ask_to_talk_to_human?: boolean;
2995
+ allowed_to_create_ticket?: boolean;
2996
+ ticket?: ToolCallTicketPrefill;
2997
+ mode?: "form" | "embed";
2998
+ ticket_form_id?: string;
2999
+ embed_html?: string;
3000
+ embed_description?: string;
3001
+ display_mode?: "collapsible" | "display" | "both";
2674
3002
  /** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
2675
3003
  waiting_tool_call_ids?: string[];
2676
3004
  }
@@ -2839,12 +3167,82 @@ export declare const submitForm: ClientFunctionDefinition;
2839
3167
  export declare interface SubmitToolCallResult {
2840
3168
  status: string;
2841
3169
  result?: unknown;
3170
+ /** Set when `status` is `"error"`. */
3171
+ error?: string;
3172
+ /** The ticket a ticketing `form` tool call resolved to, when it did. */
3173
+ ticket?: {
3174
+ ticket_id: string;
3175
+ ticket_url?: string;
3176
+ [key: string]: unknown;
3177
+ };
2842
3178
  resume?: {
2843
3179
  message_id: string;
2844
3180
  ready: boolean;
2845
3181
  };
2846
3182
  }
2847
3183
 
3184
+ /** A custom field of a ticket form. */
3185
+ declare interface TicketField {
3186
+ id: string;
3187
+ /** The key the ticketing backend expects; used as the submit key when set. */
3188
+ externalId?: string;
3189
+ title?: string;
3190
+ /** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
3191
+ type?: string;
3192
+ required: boolean;
3193
+ /** Carried in the submission but never shown. */
3194
+ hidden: boolean;
3195
+ active?: boolean;
3196
+ /** Bypass progressive disclosure, while still respecting conditions. */
3197
+ alwaysVisible?: boolean;
3198
+ regexpForValidation?: string;
3199
+ position: number;
3200
+ /** Non-empty turns the field into a select. */
3201
+ options: TicketFieldOption[];
3202
+ /** Show this field only when the parent field holds `conditionalFieldValue`. */
3203
+ conditionalFieldId?: string;
3204
+ /** Legacy comma-separated condition values. */
3205
+ conditionalFieldValue?: string;
3206
+ /** Takes precedence over conditionalFieldValue when non-empty. */
3207
+ conditionalFieldValues?: string[];
3208
+ }
3209
+
3210
+ /** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
3211
+ declare interface TicketFieldOption {
3212
+ id: string;
3213
+ /** Label shown to the user. */
3214
+ name?: string;
3215
+ /** Value submitted. Falls back to `name` when absent. */
3216
+ value?: string;
3217
+ /** Preselected when the form opens. */
3218
+ default: boolean;
3219
+ /** A note shown under the field once this option is picked. */
3220
+ message?: string;
3221
+ messageType: "info" | "warning" | "danger";
3222
+ position?: number;
3223
+ group?: string;
3224
+ noDisplay?: boolean;
3225
+ conditionalFieldId?: string;
3226
+ /** Available when the parent matches any of these values. */
3227
+ conditionalFieldValues?: string[];
3228
+ }
3229
+
3230
+ /** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
3231
+ declare interface TicketForm {
3232
+ id: string;
3233
+ name?: string;
3234
+ /** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
3235
+ mode: "form" | "embed";
3236
+ showSubject: boolean;
3237
+ showBody: boolean;
3238
+ showPriority: boolean;
3239
+ showTypology: boolean;
3240
+ priorityTypologies?: string[];
3241
+ successMessageText?: string;
3242
+ successMessageUrlLabel?: string;
3243
+ fields: TicketField[];
3244
+ }
3245
+
2848
3246
  /**
2849
3247
  * Tool call data from SSE stream
2850
3248
  */
@@ -2859,6 +3257,34 @@ export declare interface ToolCallData {
2859
3257
  data?: Record<string, unknown>;
2860
3258
  functionName?: string;
2861
3259
  arguments?: Record<string, unknown>;
3260
+ /**
3261
+ * Where the hosted widget shows the call: in the collapsible "reasoning"
3262
+ * section, in the message body, or both. Absent means collapsible only.
3263
+ */
3264
+ displayMode?: "collapsible" | "display" | "both";
3265
+ /** The user asked to talk to a human. */
3266
+ askToTalkToHuman?: boolean;
3267
+ /** `false` when the tenant blocks ticket creation for this visitor. */
3268
+ allowedToCreateTicket?: boolean;
3269
+ /** Fields the agent pre-filled from the conversation. */
3270
+ ticket?: ToolCallTicketPrefill;
3271
+ /** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
3272
+ mode?: "form" | "embed";
3273
+ ticketFormId?: string;
3274
+ embedHtml?: string;
3275
+ embedDescription?: string;
3276
+ }
3277
+
3278
+ /** The ticket the agent pre-filled on a ticketing `form` tool call. */
3279
+ declare interface ToolCallTicketPrefill {
3280
+ subject?: string;
3281
+ body?: string;
3282
+ typology?: string;
3283
+ priority?: string;
3284
+ tag?: string;
3285
+ products?: string[];
3286
+ /** Keyed by the field's external id, or a lowercased, underscored title. */
3287
+ custom_fields?: Record<string, string>;
2862
3288
  }
2863
3289
 
2864
3290
  export declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
@@ -2869,6 +3295,12 @@ export declare type ToolCallType = "form" | "confirmation_input" | "status_messa
2869
3295
  */
2870
3296
  export declare const trackEvent: ClientFunctionDefinition;
2871
3297
 
3298
+ /** Options for `AgoClient.transcribeAudio`. */
3299
+ export declare interface TranscribeAudioOptions {
3300
+ /** Cancel the upload or stop waiting for its transcription. */
3301
+ signal?: AbortSignal;
3302
+ }
3303
+
2872
3304
  /**
2873
3305
  * Validate an AgoConfig at the public API boundary.
2874
3306
  *
@@ -2892,6 +3324,25 @@ export declare const trackEvent: ClientFunctionDefinition;
2892
3324
  */
2893
3325
  export declare function validateConfig(config: unknown, context?: string): asserts config is AgoConfig;
2894
3326
 
3327
+ /** The MCP behavior hints AGO has no equivalent for. */
3328
+ export declare interface WebMCPToolMeta {
3329
+ /**
3330
+ * Both default to `false`, so only set what is true: `readOnlyHint` marks a
3331
+ * function that changes nothing, `untrustedContentHint` one whose result may
3332
+ * carry third-party text.
3333
+ */
3334
+ annotations?: {
3335
+ readOnlyHint?: boolean;
3336
+ untrustedContentHint?: boolean;
3337
+ };
3338
+ /**
3339
+ * This function navigates. The WebMCP call is held open until the function
3340
+ * registry goes quiet, so the caller sees the destination page's tools rather
3341
+ * than the departing page's. Already set on the built-in `navigateToPage`.
3342
+ */
3343
+ navigates?: boolean;
3344
+ }
3345
+
2895
3346
  /**
2896
3347
  * Attach a handler to a pre-built function definition.
2897
3348
  *