@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/react.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { default as default_2 } from 'react';
2
2
  import { ForwardRefExoticComponent } from 'react';
3
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
3
4
  import { RefAttributes } from 'react';
4
5
 
5
6
  export declare interface ActivityEntry {
@@ -115,6 +116,8 @@ declare class AgoClient {
115
116
  private config;
116
117
  /** Conversations already warned about an empty reply (one warning each). */
117
118
  private warnedEmptyConversations;
119
+ /** Client functions the backend has accepted from a WebMCP call report. */
120
+ private declaredExternally;
118
121
  /** Whether the placeholder-mode page-data warning has already been logged. */
119
122
  private warnedPageDataPlaceholder;
120
123
  /** `readPageData` companions this SDK registered, so cleanup only removes its own. */
@@ -149,7 +152,12 @@ declare class AgoClient {
149
152
  * `null` otherwise.
150
153
  */
151
154
  proactive: ProactiveController | null;
155
+ /** Removes the mirrored WebMCP tools; `null` when the bridge is off. */
156
+ private detachWebMCP;
157
+ /** The `listPages` companion is live. */
158
+ private listPagesRegistered;
152
159
  constructor(config: AgoConfig);
160
+ private attachWebMCPBridge;
153
161
  /**
154
162
  * Send a message and receive a streaming response
155
163
  */
@@ -261,6 +269,12 @@ declare class AgoClient {
261
269
  * (the agent decides what to do next). No-op if the invocation is unknown.
262
270
  */
263
271
  rejectFunction(invocationId: string): Promise<void>;
272
+ /* Excluded from this release type: runExternalFunction */
273
+ /**
274
+ * Best-effort analytics for one WebMCP call. No agent: the caller is someone
275
+ * else's agent and cannot be known from `execute`.
276
+ */
277
+ private reportExternalCall;
264
278
  /**
265
279
  * Get a page of conversations, newest-first. `pageSize` is capped at 100 by
266
280
  * the backend (default 50). Returns the `{ data, has_more, total }` envelope
@@ -280,11 +294,20 @@ declare class AgoClient {
280
294
  * `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
281
295
  */
282
296
  private static mapPersistedToolCalls;
297
+ /**
298
+ * Transcribe an audio file into editable text (`POST /api/sdk/v1/audio/transcriptions`).
299
+ * Requires speech to text to be enabled for the tenant. Supports FLAC, MP3,
300
+ * MP4, MPEG, MPGA, M4A, OGG, WAV and WebM files up to 25 MB.
301
+ * The filename must include the matching extension. For a MediaRecorder blob,
302
+ * wrap it in a File with the recording's extension and MIME type.
303
+ * Show the returned text as a draft; call `sendMessage` when the user sends it.
304
+ */
305
+ transcribeAudio(file: File, options?: TranscribeAudioOptions): Promise<AudioTranscription>;
283
306
  /**
284
307
  * The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
285
308
  * 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.
309
+ * file-attachment and speech-to-text flags. The vanilla widget fetches it
310
+ * once, when a ticket form first appears in a conversation.
288
311
  */
289
312
  getConfig(): Promise<SdkConfig>;
290
313
  /**
@@ -421,6 +444,9 @@ declare class AgoClient {
421
444
  * Get all registered function schemas
422
445
  */
423
446
  getRegisteredFunctions(): ClientFunctionSchema[];
447
+ /** The callback form of `functions:changed`. Returns an unsubscribe. */
448
+ onFunctionsChanged(listener: () => void): () => void;
449
+ /* Excluded from this release type: getFunctionRegistrations */
424
450
  /**
425
451
  * Execute a registered client function locally, through the same
426
452
  * FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
@@ -443,14 +469,15 @@ declare class AgoClient {
443
469
  * page of an entity. Flat arguments only: nested object parameters are not
444
470
  * reliably rendered to the model, so placeholders must not be named `page`.
445
471
  *
472
+ * For a large table, `{ catalogue: "onDemand" }` moves the route descriptions
473
+ * into a read-only `listPages` companion, leaving only the page names in the
474
+ * per-message schema. Routes may carry a `section` to group that companion.
475
+ *
446
476
  * @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
447
477
  * @param routes - Map of route names to paths, with descriptions for the LLM
478
+ * @param opts - Where the catalogue lives; `"inline"` by default
448
479
  */
449
- registerNavigationFunction(navigate: (path: string) => void, routes: Array<{
450
- name: string;
451
- path: string;
452
- description: string;
453
- }>): void;
480
+ registerNavigationFunction(navigate: (path: string) => void, routes: NavRoute[], opts?: AgoNavigationOptions): void;
454
481
  /**
455
482
  * Unregister the navigation function and its `current-page` context provider.
456
483
  */
@@ -753,6 +780,8 @@ declare interface AgoClientEvents {
753
780
  * call running immediately.
754
781
  */
755
782
  "function:awaiting-approval": ClientFunctionInvocation;
783
+ /** A function was registered or unregistered, or the registry cleared. */
784
+ "functions:changed": ClientFunctionSchema[];
756
785
  "function:result": {
757
786
  invocationId: string;
758
787
  result: unknown;
@@ -825,6 +854,8 @@ export declare interface AgoConfig {
825
854
  defaultAgentId?: string;
826
855
  /** Permission name to apply to all requests (sent as `X-Widget-Permission`). Mirrors the widget's `window.AGO.permission`. */
827
856
  permission?: string;
857
+ /** Interface locale selected by the host app, sent as Accept-Language. Null clears the override. */
858
+ language?: string | null;
828
859
  /** User email for identification */
829
860
  userEmail?: string;
830
861
  /** JWT token for authenticated users */
@@ -902,6 +933,15 @@ export declare interface AgoConfig {
902
933
  * mode's `jsErrors` signal. See `client.reportError()` for caught errors.
903
934
  */
904
935
  errorWatcher?: boolean | ErrorWatcherOptions;
936
+ /** Mirror every registered client function into the browser's WebMCP registry
937
+ * (`document.modelContext`), so an external agent can call the same functions
938
+ * the in-app agent calls. Off by default; no-ops without WebMCP.
939
+ *
940
+ * A mirrored function runs immediately: the approval gate
941
+ * ({@link approvalPolicy}, `requiresApproval`) covers the agent loop only.
942
+ * Use `webmcp: false` on a definition to keep it out.
943
+ */
944
+ webmcp?: boolean;
905
945
  }
906
946
 
907
947
  /**
@@ -945,6 +985,16 @@ export declare interface AgoMessage {
945
985
  createdAt: Date;
946
986
  }
947
987
 
988
+ /**
989
+ * Where the route catalogue lives: `"inline"` (default) in `navigateToPage`'s
990
+ * description, or `"onDemand"` in a `listPages` companion's result.
991
+ */
992
+ export declare type AgoNavigationOptions = {
993
+ catalogue?: "inline";
994
+ } | {
995
+ catalogue: "onDemand";
996
+ };
997
+
948
998
  /**
949
999
  * Prebuilt proactive-nudge toast: a small, always-dismissable bubble anchored
950
1000
  * near the chat launcher. Never modal — it never blocks the page. Renders the
@@ -1118,6 +1168,8 @@ export declare interface AgoRoute {
1118
1168
  name: string;
1119
1169
  path: string;
1120
1170
  description: string;
1171
+ /** Groups this route for `catalogue: "onDemand"`. Unused otherwise. */
1172
+ section?: string;
1121
1173
  }
1122
1174
 
1123
1175
  /**
@@ -1170,6 +1222,11 @@ declare type AgoStateSetResult = {
1170
1222
  result: "unchanged";
1171
1223
  };
1172
1224
 
1225
+ /** Editable text returned by `AgoClient.transcribeAudio`. */
1226
+ declare interface AudioTranscription {
1227
+ text: string;
1228
+ }
1229
+
1173
1230
  /** One JavaScript error captured on the page (deduplicated, see `count`). */
1174
1231
  declare interface CapturedError {
1175
1232
  type: CapturedErrorType;
@@ -1217,6 +1274,12 @@ export declare interface ChatInputProps {
1217
1274
  disabled?: boolean;
1218
1275
  placeholder?: string;
1219
1276
  allowFiles?: boolean;
1277
+ /** Microphone, live waveform and draft transcription. Uses the tenant flag. */
1278
+ speechToText?: boolean | SpeechToTextOptions;
1279
+ /** For dictation; otherwise uses AgoProvider's client. */
1280
+ client?: AgoClient;
1281
+ /** Cancels dictation when the conversation or page changes. */
1282
+ scopeKey?: string;
1220
1283
  className?: string;
1221
1284
  }
1222
1285
 
@@ -1255,6 +1318,8 @@ export declare interface ChatWidgetProps {
1255
1318
  placeholder?: string;
1256
1319
  /** Enable file attachments */
1257
1320
  allowFiles?: boolean;
1321
+ /** Microphone, live waveform and draft transcription. Checks the tenant flag. */
1322
+ speechToText?: boolean | SpeechToTextOptions;
1258
1323
  /**
1259
1324
  * While the agent is answering, turn the send button into a Stop button that
1260
1325
  * interrupts the turn. Defaults to `true`.
@@ -1352,22 +1417,11 @@ export declare interface ChatWidgetProps {
1352
1417
  * client.registerFunction(fn);
1353
1418
  * ```
1354
1419
  */
1355
- declare interface ClientFunctionDefinition {
1420
+ declare interface ClientFunctionDefinition extends ClientFunctionSettings {
1356
1421
  name: string;
1357
1422
  description: string;
1358
1423
  parameters: ClientFunctionSchema["parameters"];
1359
1424
  handler: ClientFunctionHandler;
1360
- /**
1361
- * Max serialized result size in bytes before the SDK truncates it to a
1362
- * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
1363
- * `Infinity` disables the guard for this function.
1364
- */
1365
- maxResultBytes?: number;
1366
- /**
1367
- * Require explicit user approval before this function runs. See
1368
- * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1369
- */
1370
- requiresApproval?: boolean;
1371
1425
  }
1372
1426
 
1373
1427
  /**
@@ -1386,20 +1440,7 @@ declare interface ClientFunctionInvocation {
1386
1440
  * Schema-plus-settings object accepted when registering a function: the schema
1387
1441
  * (minus `name`) and SDK-side options that are NOT sent to the backend.
1388
1442
  */
1389
- declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
1390
- /**
1391
- * Max serialized result size in bytes before the SDK truncates it to a
1392
- * flagged preview. Overrides the client-level default
1393
- * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
1394
- * disables the guard for this function.
1395
- */
1396
- maxResultBytes?: number;
1397
- /**
1398
- * Require explicit user approval before this function runs. See
1399
- * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1400
- */
1401
- requiresApproval?: boolean;
1402
- };
1443
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & ClientFunctionSettings;
1403
1444
 
1404
1445
  /**
1405
1446
  * Schema for a client-side function that AGO can call
@@ -1426,6 +1467,28 @@ declare interface ClientFunctionSchema {
1426
1467
  };
1427
1468
  }
1428
1469
 
1470
+ /** SDK-side function settings that are never sent to the backend. */
1471
+ declare interface ClientFunctionSettings {
1472
+ /**
1473
+ * Max serialized result size in bytes before the SDK truncates it to a
1474
+ * flagged preview. Overrides the client-level default
1475
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
1476
+ * disables the guard for this function.
1477
+ */
1478
+ maxResultBytes?: number;
1479
+ /**
1480
+ * Require explicit user approval before this function runs. See
1481
+ * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
1482
+ */
1483
+ requiresApproval?: boolean;
1484
+ /**
1485
+ * WebMCP metadata, read only when the bridge is on (`AgoConfig.webmcp`).
1486
+ * `false` keeps this function out of WebMCP while leaving it available to the
1487
+ * in-app agent.
1488
+ */
1489
+ webmcp?: WebMCPToolMeta | false;
1490
+ }
1491
+
1429
1492
  /** See {@link AgoConfig.clientFunctionsMode}. */
1430
1493
  declare type ClientFunctionsMode = "placeholder" | "pause";
1431
1494
 
@@ -1556,6 +1619,8 @@ declare interface CreateTicketResult {
1556
1619
 
1557
1620
  export declare const DEFAULT_MESSAGE_FEEDBACK_LABELS: MessageFeedbackLabels;
1558
1621
 
1622
+ export declare const DEFAULT_SPEECH_TO_TEXT_LABELS: SpeechToTextLabels;
1623
+
1559
1624
  /**
1560
1625
  * Compute which required fields are still empty and whether the form is complete.
1561
1626
  * Pure — the single home for the "required + non-empty" rule, shared by the update
@@ -2007,6 +2072,15 @@ declare interface MockAgoClientOptions {
2007
2072
 
2008
2073
  declare type MockFn = (...args: any[]) => any;
2009
2074
 
2075
+ /** A navigable page. `path` may carry `:param` placeholders. */
2076
+ declare interface NavRoute {
2077
+ name: string;
2078
+ path: string;
2079
+ description: string;
2080
+ /** Only read under `catalogue: "onDemand"`. */
2081
+ section?: string;
2082
+ }
2083
+
2010
2084
  /**
2011
2085
  * Optional action attached to a nudge. Accepting a `functionName` action
2012
2086
  * executes the registered client function (same `FunctionRegistry` path as
@@ -2199,6 +2273,14 @@ declare interface ProactiveTriggerWhen {
2199
2273
  fieldErrors?: Record<string, number>;
2200
2274
  }
2201
2275
 
2276
+ /**
2277
+ * Registered function with handler
2278
+ */
2279
+ declare interface RegisteredFunction extends ClientFunctionSettings {
2280
+ schema: ClientFunctionSchema;
2281
+ handler: ClientFunctionHandler;
2282
+ }
2283
+
2202
2284
  /**
2203
2285
  * Hook run before a paused turn is resumed, so the app controls WHEN the
2204
2286
  * continuation fires (e.g. wait for the destination page to mount after a
@@ -2255,6 +2337,8 @@ declare interface SdkPermissionConfig {
2255
2337
  homePage?: SdkHomePageConfig;
2256
2338
  fileAttachmentsEnabled: boolean;
2257
2339
  voiceEnabled: boolean;
2340
+ /** Whether audio uploads can be transcribed. Defaults to false on older backends. */
2341
+ speechToTextEnabled: boolean;
2258
2342
  }
2259
2343
 
2260
2344
  /**
@@ -2411,6 +2495,42 @@ declare interface SignalsSnapshot {
2411
2495
  pageState: Record<string, unknown> | null;
2412
2496
  }
2413
2497
 
2498
+ /** Ready-made microphone, live waveform, cancel/confirm controls and transcription. */
2499
+ export declare function SpeechToTextButton(props: SpeechToTextButtonProps): JSX_2.Element;
2500
+
2501
+ export declare interface SpeechToTextButtonProps {
2502
+ /** Uses AgoProvider's client when omitted. */
2503
+ client?: AgoClient;
2504
+ onTranscript: (text: string) => void;
2505
+ /** Use this to hide or disable your editor while dictation is active. */
2506
+ onBusyChange?: (busy: boolean) => void;
2507
+ disabled?: boolean;
2508
+ /** Cancels dictation when the conversation or page changes. */
2509
+ scopeKey?: string;
2510
+ labels?: Partial<SpeechToTextLabels>;
2511
+ className?: string;
2512
+ }
2513
+
2514
+ /** Strings used by the microphone control in every widget. */
2515
+ export declare interface SpeechToTextLabels {
2516
+ start: string;
2517
+ finish: string;
2518
+ cancel: string;
2519
+ requesting: string;
2520
+ recording: string;
2521
+ transcribing: string;
2522
+ limitApproaching: string;
2523
+ permissionDenied: string;
2524
+ recordingFailed: string;
2525
+ tooLarge: string;
2526
+ noSpeech: string;
2527
+ transcriptionFailed: string;
2528
+ }
2529
+
2530
+ export declare interface SpeechToTextOptions {
2531
+ labels?: Partial<SpeechToTextLabels>;
2532
+ }
2533
+
2414
2534
  /**
2415
2535
  * SSE stream chunk data
2416
2536
  */
@@ -2655,6 +2775,12 @@ declare interface ToolCallTicketPrefill {
2655
2775
 
2656
2776
  declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
2657
2777
 
2778
+ /** Options for `AgoClient.transcribeAudio`. */
2779
+ declare interface TranscribeAudioOptions {
2780
+ /** Cancel the upload or stop waiting for its transcription. */
2781
+ signal?: AbortSignal;
2782
+ }
2783
+
2658
2784
  /**
2659
2785
  * Hook to create and manage an AgoClient instance
2660
2786
  *
@@ -2854,6 +2980,11 @@ export declare interface UseAgoFunctionOptions {
2854
2980
  * See `AgoConfig.approvalPolicy`.
2855
2981
  */
2856
2982
  requiresApproval?: boolean;
2983
+ /**
2984
+ * WebMCP metadata, read only when the bridge is on (`AgoConfig.webmcp`).
2985
+ * `false` keeps this function out of WebMCP.
2986
+ */
2987
+ webmcp?: WebMCPToolMeta | false;
2857
2988
  }
2858
2989
 
2859
2990
  /**
@@ -2867,8 +2998,11 @@ export declare interface UseAgoFunctionOptions {
2867
2998
  * { name: "settings", path: "/settings", description: "User settings" },
2868
2999
  * ]);
2869
3000
  * ```
3001
+ *
3002
+ * For a large route table, `{ catalogue: "onDemand" }` keeps the descriptions
3003
+ * out of every message.
2870
3004
  */
2871
- export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[]): void;
3005
+ export declare function useAgoNavigation(navigate: (path: string) => void, routes: AgoRoute[], opts?: AgoNavigationOptions): void;
2872
3006
 
2873
3007
  export declare type UseAgoOptions = AgoConfig;
2874
3008
 
@@ -3191,4 +3325,23 @@ export declare interface UseSheetResult {
3191
3325
  toggle: (cause?: SheetChangeCause) => void;
3192
3326
  }
3193
3327
 
3328
+ /** The MCP behavior hints AGO has no equivalent for. */
3329
+ declare interface WebMCPToolMeta {
3330
+ /**
3331
+ * Both default to `false`, so only set what is true: `readOnlyHint` marks a
3332
+ * function that changes nothing, `untrustedContentHint` one whose result may
3333
+ * carry third-party text.
3334
+ */
3335
+ annotations?: {
3336
+ readOnlyHint?: boolean;
3337
+ untrustedContentHint?: boolean;
3338
+ };
3339
+ /**
3340
+ * This function navigates. The WebMCP call is held open until the function
3341
+ * registry goes quiet, so the caller sees the destination page's tools rather
3342
+ * than the departing page's. Already set on the built-in `navigateToPage`.
3343
+ */
3344
+ navigates?: boolean;
3345
+ }
3346
+
3194
3347
  export { }