@useago/sdk 1.12.0 → 1.13.1

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 +111 -4
  2. package/README.md +73 -0
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +140 -38
  5. package/dist/angular.d.ts +140 -38
  6. package/dist/angular.js +7 -4
  7. package/dist/autoContinue-C3UsCvT5.cjs +1 -0
  8. package/dist/{autoContinue-CC8K9mBU.js → autoContinue-Cb4_iEbO.js} +1 -1
  9. package/dist/{createConversationSession-B1Qn-y0I.js → createConversationSession-D0vks-8C.js} +1 -1
  10. package/dist/{createConversationSession-B3v_xOU7.cjs → createConversationSession-Ri3EKIJU.cjs} +1 -1
  11. package/dist/{createFormCollector-m79zk_NA.js → createFormCollector-BMN-blXs.js} +1 -1
  12. package/dist/{createFormCollector-FvwDOqnV.cjs → createFormCollector-BNCMIUw2.cjs} +1 -1
  13. package/dist/createMockClient-BPt1gSve.cjs +1 -0
  14. package/dist/{createMockClient-Beao82tu.js → createMockClient-YoYr3pQr.js} +1 -0
  15. package/dist/devtools.cjs +4 -4
  16. package/dist/devtools.d.cts +129 -33
  17. package/dist/devtools.d.ts +129 -33
  18. package/dist/devtools.js +87 -84
  19. package/dist/helpers.d.cts +42 -12
  20. package/dist/helpers.d.ts +42 -12
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.cts +135 -40
  23. package/dist/index.d.ts +135 -40
  24. package/dist/index.js +44 -43
  25. package/dist/react.cjs +4 -4
  26. package/dist/react.d.cts +187 -34
  27. package/dist/react.d.ts +187 -34
  28. package/dist/react.js +822 -729
  29. package/dist/speechToText-BV7qxqPF.js +704 -0
  30. package/dist/speechToText-ZciRyyJE.cjs +1 -0
  31. package/dist/testing.cjs +1 -1
  32. package/dist/testing.d.cts +129 -33
  33. package/dist/testing.d.ts +129 -33
  34. package/dist/testing.js +1 -1
  35. package/dist/types-Ck3iZG0K.cjs +10 -0
  36. package/dist/{types-Ct1hlKwg.js → types-fX-VoHfa.js} +1042 -759
  37. package/dist/vue.cjs +1 -1
  38. package/dist/vue.d.cts +143 -35
  39. package/dist/vue.d.ts +143 -35
  40. package/dist/vue.js +133 -131
  41. package/dist/widget.cjs +6 -6
  42. package/dist/widget.d.cts +161 -33
  43. package/dist/widget.d.ts +161 -33
  44. package/dist/widget.js +1702 -1757
  45. package/llms-full.txt +166 -1
  46. package/package.json +1 -1
  47. package/dist/autoContinue-CP9pJR-V.cjs +0 -1
  48. package/dist/createMockClient-BEOXI8yW.cjs +0 -1
  49. package/dist/sheetController-BThJRtOu.cjs +0 -1
  50. package/dist/sheetController-aEKXIvjk.js +0 -343
  51. package/dist/types-mcW8vB1U.cjs +0 -10
package/dist/widget.d.ts CHANGED
@@ -58,6 +58,8 @@ declare class AgoClient {
58
58
  private config;
59
59
  /** Conversations already warned about an empty reply (one warning each). */
60
60
  private warnedEmptyConversations;
61
+ /** Client functions the backend has accepted from a WebMCP call report. */
62
+ private declaredExternally;
61
63
  /** Whether the placeholder-mode page-data warning has already been logged. */
62
64
  private warnedPageDataPlaceholder;
63
65
  /** `readPageData` companions this SDK registered, so cleanup only removes its own. */
@@ -92,7 +94,12 @@ declare class AgoClient {
92
94
  * `null` otherwise.
93
95
  */
94
96
  proactive: ProactiveController | null;
97
+ /** Removes the mirrored WebMCP tools; `null` when the bridge is off. */
98
+ private detachWebMCP;
99
+ /** The `listPages` companion is live. */
100
+ private listPagesRegistered;
95
101
  constructor(config: AgoConfig);
102
+ private attachWebMCPBridge;
96
103
  /**
97
104
  * Send a message and receive a streaming response
98
105
  */
@@ -204,6 +211,12 @@ declare class AgoClient {
204
211
  * (the agent decides what to do next). No-op if the invocation is unknown.
205
212
  */
206
213
  rejectFunction(invocationId: string): Promise<void>;
214
+ /* Excluded from this release type: runExternalFunction */
215
+ /**
216
+ * Best-effort analytics for one WebMCP call. No agent: the caller is someone
217
+ * else's agent and cannot be known from `execute`.
218
+ */
219
+ private reportExternalCall;
207
220
  /**
208
221
  * Get a page of conversations, newest-first. `pageSize` is capped at 100 by
209
222
  * the backend (default 50). Returns the `{ data, has_more, total }` envelope
@@ -223,11 +236,20 @@ declare class AgoClient {
223
236
  * `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
224
237
  */
225
238
  private static mapPersistedToolCalls;
239
+ /**
240
+ * Transcribe an audio file into editable text (`POST /api/sdk/v1/audio/transcriptions`).
241
+ * Requires speech to text to be enabled for the tenant. Supports FLAC, MP3,
242
+ * MP4, MPEG, MPGA, M4A, OGG, WAV and WebM files up to 25 MB.
243
+ * The filename must include the matching extension. For a MediaRecorder blob,
244
+ * wrap it in a File with the recording's extension and MIME type.
245
+ * Show the returned text as a draft; call `sendMessage` when the user sends it.
246
+ */
247
+ transcribeAudio(file: File, options?: TranscribeAudioOptions): Promise<AudioTranscription>;
226
248
  /**
227
249
  * The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
228
250
  * agents, the ticket form the agent's `ago_ticketing` tool opens, and the
229
- * file-attachment flag. The vanilla widget fetches it once, when a ticket
230
- * form first appears in a conversation.
251
+ * file-attachment and speech-to-text flags. The vanilla widget fetches it
252
+ * once, when a ticket form first appears in a conversation.
231
253
  */
232
254
  getConfig(): Promise<SdkConfig>;
233
255
  /**
@@ -364,6 +386,9 @@ declare class AgoClient {
364
386
  * Get all registered function schemas
365
387
  */
366
388
  getRegisteredFunctions(): ClientFunctionSchema[];
389
+ /** The callback form of `functions:changed`. Returns an unsubscribe. */
390
+ onFunctionsChanged(listener: () => void): () => void;
391
+ /* Excluded from this release type: getFunctionRegistrations */
367
392
  /**
368
393
  * Execute a registered client function locally, through the same
369
394
  * FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
@@ -386,14 +411,15 @@ declare class AgoClient {
386
411
  * page of an entity. Flat arguments only: nested object parameters are not
387
412
  * reliably rendered to the model, so placeholders must not be named `page`.
388
413
  *
414
+ * For a large table, `{ catalogue: "onDemand" }` moves the route descriptions
415
+ * into a read-only `listPages` companion, leaving only the page names in the
416
+ * per-message schema. Routes may carry a `section` to group that companion.
417
+ *
389
418
  * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
390
419
  * @param routes - Map of route names to paths, with descriptions for the LLM
420
+ * @param opts - Where the catalogue lives; `"inline"` by default
391
421
  */
392
- registerNavigationFunction(navigate: (path: string) => void, routes: Array<{
393
- name: string;
394
- path: string;
395
- description: string;
396
- }>): void;
422
+ registerNavigationFunction(navigate: (path: string) => void, routes: NavRoute[], opts?: AgoNavigationOptions): void;
397
423
  /**
398
424
  * Unregister the navigation function and its `current-page` context provider.
399
425
  */
@@ -696,6 +722,8 @@ declare interface AgoClientEvents {
696
722
  * call running immediately.
697
723
  */
698
724
  "function:awaiting-approval": ClientFunctionInvocation;
725
+ /** A function was registered or unregistered, or the registry cleared. */
726
+ "functions:changed": ClientFunctionSchema[];
699
727
  "function:result": {
700
728
  invocationId: string;
701
729
  result: unknown;
@@ -768,6 +796,8 @@ declare interface AgoConfig {
768
796
  defaultAgentId?: string;
769
797
  /** Permission name to apply to all requests (sent as `X-Widget-Permission`). Mirrors the widget's `window.AGO.permission`. */
770
798
  permission?: string;
799
+ /** Interface locale selected by the host app, sent as Accept-Language. Null clears the override. */
800
+ language?: string | null;
771
801
  /** User email for identification */
772
802
  userEmail?: string;
773
803
  /** JWT token for authenticated users */
@@ -845,6 +875,15 @@ declare interface AgoConfig {
845
875
  * mode's `jsErrors` signal. See `client.reportError()` for caught errors.
846
876
  */
847
877
  errorWatcher?: boolean | ErrorWatcherOptions;
878
+ /** Mirror every registered client function into the browser's WebMCP registry
879
+ * (`document.modelContext`), so an external agent can call the same functions
880
+ * the in-app agent calls. Off by default; no-ops without WebMCP.
881
+ *
882
+ * A mirrored function runs immediately: the approval gate
883
+ * ({@link approvalPolicy}, `requiresApproval`) covers the agent loop only.
884
+ * Use `webmcp: false` on a definition to keep it out.
885
+ */
886
+ webmcp?: boolean;
848
887
  }
849
888
 
850
889
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -875,6 +914,16 @@ declare interface AgoMessage {
875
914
  createdAt: Date;
876
915
  }
877
916
 
917
+ /**
918
+ * Where the route catalogue lives: `"inline"` (default) in `navigateToPage`'s
919
+ * description, or `"onDemand"` in a `listPages` companion's result.
920
+ */
921
+ declare type AgoNavigationOptions = {
922
+ catalogue?: "inline";
923
+ } | {
924
+ catalogue: "onDemand";
925
+ };
926
+
878
927
  /**
879
928
  * What the page currently displays, returned to the agent as the *result* of
880
929
  * `setPageState` instead of only as context on the next message.
@@ -1058,6 +1107,11 @@ export declare interface AgoWidgetConfig {
1058
1107
  metadata?: Record<string, unknown>;
1059
1108
  }
1060
1109
 
1110
+ /** Editable text returned by `AgoClient.transcribeAudio`. */
1111
+ declare interface AudioTranscription {
1112
+ text: string;
1113
+ }
1114
+
1061
1115
  /** One JavaScript error captured on the page (deduplicated, see `count`). */
1062
1116
  declare interface CapturedError {
1063
1117
  type: CapturedErrorType;
@@ -1145,22 +1199,11 @@ export declare interface ChatWidgetHandle {
1145
1199
  * client.registerFunction(fn);
1146
1200
  * ```
1147
1201
  */
1148
- declare interface ClientFunctionDefinition {
1202
+ declare interface ClientFunctionDefinition extends ClientFunctionSettings {
1149
1203
  name: string;
1150
1204
  description: string;
1151
1205
  parameters: ClientFunctionSchema["parameters"];
1152
1206
  handler: ClientFunctionHandler;
1153
- /**
1154
- * Max serialized result size in bytes before the SDK truncates it to a
1155
- * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
1156
- * `Infinity` disables the guard for this function.
1157
- */
1158
- maxResultBytes?: number;
1159
- /**
1160
- * Require explicit user approval before this function runs. See
1161
- * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1162
- */
1163
- requiresApproval?: boolean;
1164
1207
  }
1165
1208
 
1166
1209
  /**
@@ -1179,20 +1222,7 @@ declare interface ClientFunctionInvocation {
1179
1222
  * Schema-plus-settings object accepted when registering a function: the schema
1180
1223
  * (minus `name`) and SDK-side options that are NOT sent to the backend.
1181
1224
  */
1182
- declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
1183
- /**
1184
- * Max serialized result size in bytes before the SDK truncates it to a
1185
- * flagged preview. Overrides the client-level default
1186
- * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
1187
- * disables the guard for this function.
1188
- */
1189
- maxResultBytes?: number;
1190
- /**
1191
- * Require explicit user approval before this function runs. See
1192
- * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1193
- */
1194
- requiresApproval?: boolean;
1195
- };
1225
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & ClientFunctionSettings;
1196
1226
 
1197
1227
  /**
1198
1228
  * Schema for a client-side function that AGO can call
@@ -1219,6 +1249,28 @@ declare interface ClientFunctionSchema {
1219
1249
  };
1220
1250
  }
1221
1251
 
1252
+ /** SDK-side function settings that are never sent to the backend. */
1253
+ declare interface ClientFunctionSettings {
1254
+ /**
1255
+ * Max serialized result size in bytes before the SDK truncates it to a
1256
+ * flagged preview. Overrides the client-level default
1257
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
1258
+ * disables the guard for this function.
1259
+ */
1260
+ maxResultBytes?: number;
1261
+ /**
1262
+ * Require explicit user approval before this function runs. See
1263
+ * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1264
+ */
1265
+ requiresApproval?: boolean;
1266
+ /**
1267
+ * WebMCP metadata, read only when the bridge is on (`AgoConfig.webmcp`).
1268
+ * `false` keeps this function out of WebMCP while leaving it available to the
1269
+ * in-app agent.
1270
+ */
1271
+ webmcp?: WebMCPToolMeta | false;
1272
+ }
1273
+
1222
1274
  /** See {@link AgoConfig.clientFunctionsMode}. */
1223
1275
  declare type ClientFunctionsMode = "placeholder" | "pause";
1224
1276
 
@@ -1400,6 +1452,8 @@ declare interface CreateTicketResult {
1400
1452
 
1401
1453
  export declare const DEFAULT_FEEDBACK_LABELS: FeedbackLabels;
1402
1454
 
1455
+ export declare const DEFAULT_SPEECH_TO_TEXT_LABELS: SpeechToTextLabels;
1456
+
1403
1457
  export declare const DEFAULT_TOOL_CALL_FORM_LABELS: ToolCallFormLabels;
1404
1458
 
1405
1459
  export declare const DEFAULT_WIDGET_LABELS: WidgetLabels;
@@ -1708,12 +1762,22 @@ export declare interface MountChatWidgetOptions {
1708
1762
  placeholder?: string;
1709
1763
  /** Enable file attachments. */
1710
1764
  allowFiles?: boolean;
1765
+ /** Microphone, live waveform and draft transcription. Checks the tenant flag. Default false. */
1766
+ speechToText?: boolean | SpeechToTextOptions;
1711
1767
  /**
1712
1768
  * While the agent is answering, turn the send button into a Stop button that
1713
1769
  * interrupts the turn. Default `true`; set `false` to keep showing a disabled
1714
1770
  * spinner instead.
1715
1771
  */
1716
1772
  allowStop?: boolean;
1773
+ /**
1774
+ * Follow new messages and streamed replies while the reader is at the bottom.
1775
+ * Defaults to `true`; sending a message or clicking the jump button resumes
1776
+ * following. Set `false` to keep the scroll position during replies. Sending
1777
+ * a message or clicking the jump button still jumps to the end once, without
1778
+ * enabling follow for subsequent chunks.
1779
+ */
1780
+ autoScroll?: boolean;
1717
1781
  /** Widget height (number → px). Ignored when `placement` is `"left"`/`"right"`
1718
1782
  * (a side panel is always full-height). */
1719
1783
  height?: string | number;
@@ -1950,6 +2014,15 @@ export declare interface MountChatWidgetOptions {
1950
2014
  }) => void;
1951
2015
  }
1952
2016
 
2017
+ /** A navigable page. `path` may carry `:param` placeholders. */
2018
+ declare interface NavRoute {
2019
+ name: string;
2020
+ path: string;
2021
+ description: string;
2022
+ /** Only read under `catalogue: "onDemand"`. */
2023
+ section?: string;
2024
+ }
2025
+
1953
2026
  /**
1954
2027
  * Optional action attached to a nudge. Accepting a `functionName` action
1955
2028
  * executes the registered client function (same `FunctionRegistry` path as
@@ -2153,6 +2226,14 @@ declare interface ProactiveTriggerWhen {
2153
2226
  */
2154
2227
  export declare function readableTextColor(background: string | undefined): string;
2155
2228
 
2229
+ /**
2230
+ * Registered function with handler
2231
+ */
2232
+ declare interface RegisteredFunction extends ClientFunctionSettings {
2233
+ schema: ClientFunctionSchema;
2234
+ handler: ClientFunctionHandler;
2235
+ }
2236
+
2156
2237
  /**
2157
2238
  * Tiny, dependency-free markdown → DOM renderer for the vanilla chat widget.
2158
2239
  *
@@ -2237,6 +2318,8 @@ declare interface SdkPermissionConfig {
2237
2318
  homePage?: SdkHomePageConfig;
2238
2319
  fileAttachmentsEnabled: boolean;
2239
2320
  voiceEnabled: boolean;
2321
+ /** Whether audio uploads can be transcribed. Defaults to false on older backends. */
2322
+ speechToTextEnabled: boolean;
2240
2323
  }
2241
2324
 
2242
2325
  /**
@@ -2408,6 +2491,26 @@ declare interface SignalsSnapshot {
2408
2491
  pageState: Record<string, unknown> | null;
2409
2492
  }
2410
2493
 
2494
+ /** Strings used by the microphone control in every widget. */
2495
+ export declare interface SpeechToTextLabels {
2496
+ start: string;
2497
+ finish: string;
2498
+ cancel: string;
2499
+ requesting: string;
2500
+ recording: string;
2501
+ transcribing: string;
2502
+ limitApproaching: string;
2503
+ permissionDenied: string;
2504
+ recordingFailed: string;
2505
+ tooLarge: string;
2506
+ noSpeech: string;
2507
+ transcriptionFailed: string;
2508
+ }
2509
+
2510
+ export declare interface SpeechToTextOptions {
2511
+ labels?: Partial<SpeechToTextLabels>;
2512
+ }
2513
+
2411
2514
  /**
2412
2515
  * SSE stream chunk data
2413
2516
  */
@@ -2690,6 +2793,31 @@ declare interface ToolCallTicketPrefill {
2690
2793
 
2691
2794
  declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
2692
2795
 
2796
+ /** Options for `AgoClient.transcribeAudio`. */
2797
+ declare interface TranscribeAudioOptions {
2798
+ /** Cancel the upload or stop waiting for its transcription. */
2799
+ signal?: AbortSignal;
2800
+ }
2801
+
2802
+ /** The MCP behavior hints AGO has no equivalent for. */
2803
+ declare interface WebMCPToolMeta {
2804
+ /**
2805
+ * Both default to `false`, so only set what is true: `readOnlyHint` marks a
2806
+ * function that changes nothing, `untrustedContentHint` one whose result may
2807
+ * carry third-party text.
2808
+ */
2809
+ annotations?: {
2810
+ readOnlyHint?: boolean;
2811
+ untrustedContentHint?: boolean;
2812
+ };
2813
+ /**
2814
+ * This function navigates. The WebMCP call is held open until the function
2815
+ * registry goes quiet, so the caller sees the destination page's tools rather
2816
+ * than the departing page's. Already set on the built-in `navigateToPage`.
2817
+ */
2818
+ navigates?: boolean;
2819
+ }
2820
+
2693
2821
  /**
2694
2822
  * The greeting shown before any conversation has started. Pass a plain string
2695
2823
  * for the classic centered empty-state placeholder, or an object to control how