@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.
- package/CHANGELOG.md +111 -4
- package/README.md +73 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +140 -38
- package/dist/angular.d.ts +140 -38
- package/dist/angular.js +7 -4
- package/dist/autoContinue-C3UsCvT5.cjs +1 -0
- package/dist/{autoContinue-CC8K9mBU.js → autoContinue-Cb4_iEbO.js} +1 -1
- package/dist/{createConversationSession-B1Qn-y0I.js → createConversationSession-D0vks-8C.js} +1 -1
- package/dist/{createConversationSession-B3v_xOU7.cjs → createConversationSession-Ri3EKIJU.cjs} +1 -1
- package/dist/{createFormCollector-m79zk_NA.js → createFormCollector-BMN-blXs.js} +1 -1
- package/dist/{createFormCollector-FvwDOqnV.cjs → createFormCollector-BNCMIUw2.cjs} +1 -1
- package/dist/createMockClient-BPt1gSve.cjs +1 -0
- package/dist/{createMockClient-Beao82tu.js → createMockClient-YoYr3pQr.js} +1 -0
- package/dist/devtools.cjs +4 -4
- package/dist/devtools.d.cts +129 -33
- package/dist/devtools.d.ts +129 -33
- package/dist/devtools.js +87 -84
- package/dist/helpers.d.cts +42 -12
- package/dist/helpers.d.ts +42 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +135 -40
- package/dist/index.d.ts +135 -40
- package/dist/index.js +44 -43
- package/dist/react.cjs +4 -4
- package/dist/react.d.cts +187 -34
- package/dist/react.d.ts +187 -34
- package/dist/react.js +822 -729
- package/dist/speechToText-BV7qxqPF.js +704 -0
- package/dist/speechToText-ZciRyyJE.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +129 -33
- package/dist/testing.d.ts +129 -33
- package/dist/testing.js +1 -1
- package/dist/types-Ck3iZG0K.cjs +10 -0
- package/dist/{types-Ct1hlKwg.js → types-fX-VoHfa.js} +1042 -759
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +143 -35
- package/dist/vue.d.ts +143 -35
- package/dist/vue.js +133 -131
- package/dist/widget.cjs +6 -6
- package/dist/widget.d.cts +161 -33
- package/dist/widget.d.ts +161 -33
- package/dist/widget.js +1702 -1757
- package/llms-full.txt +166 -1
- package/package.json +1 -1
- package/dist/autoContinue-CP9pJR-V.cjs +0 -1
- package/dist/createMockClient-BEOXI8yW.cjs +0 -1
- package/dist/sheetController-BThJRtOu.cjs +0 -1
- package/dist/sheetController-aEKXIvjk.js +0 -343
- package/dist/types-mcW8vB1U.cjs +0 -10
package/dist/index.d.cts
CHANGED
|
@@ -97,6 +97,8 @@ export declare class AgoClient {
|
|
|
97
97
|
private config;
|
|
98
98
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
99
99
|
private warnedEmptyConversations;
|
|
100
|
+
/** Client functions the backend has accepted from a WebMCP call report. */
|
|
101
|
+
private declaredExternally;
|
|
100
102
|
/** Whether the placeholder-mode page-data warning has already been logged. */
|
|
101
103
|
private warnedPageDataPlaceholder;
|
|
102
104
|
/** `readPageData` companions this SDK registered, so cleanup only removes its own. */
|
|
@@ -131,7 +133,12 @@ export declare class AgoClient {
|
|
|
131
133
|
* `null` otherwise.
|
|
132
134
|
*/
|
|
133
135
|
proactive: ProactiveController | null;
|
|
136
|
+
/** Removes the mirrored WebMCP tools; `null` when the bridge is off. */
|
|
137
|
+
private detachWebMCP;
|
|
138
|
+
/** The `listPages` companion is live. */
|
|
139
|
+
private listPagesRegistered;
|
|
134
140
|
constructor(config: AgoConfig);
|
|
141
|
+
private attachWebMCPBridge;
|
|
135
142
|
/**
|
|
136
143
|
* Send a message and receive a streaming response
|
|
137
144
|
*/
|
|
@@ -243,6 +250,12 @@ export declare class AgoClient {
|
|
|
243
250
|
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
244
251
|
*/
|
|
245
252
|
rejectFunction(invocationId: string): Promise<void>;
|
|
253
|
+
/* Excluded from this release type: runExternalFunction */
|
|
254
|
+
/**
|
|
255
|
+
* Best-effort analytics for one WebMCP call. No agent: the caller is someone
|
|
256
|
+
* else's agent and cannot be known from `execute`.
|
|
257
|
+
*/
|
|
258
|
+
private reportExternalCall;
|
|
246
259
|
/**
|
|
247
260
|
* Get a page of conversations, newest-first. `pageSize` is capped at 100 by
|
|
248
261
|
* the backend (default 50). Returns the `{ data, has_more, total }` envelope
|
|
@@ -262,11 +275,20 @@ export declare class AgoClient {
|
|
|
262
275
|
* `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
|
|
263
276
|
*/
|
|
264
277
|
private static mapPersistedToolCalls;
|
|
278
|
+
/**
|
|
279
|
+
* Transcribe an audio file into editable text (`POST /api/sdk/v1/audio/transcriptions`).
|
|
280
|
+
* Requires speech to text to be enabled for the tenant. Supports FLAC, MP3,
|
|
281
|
+
* MP4, MPEG, MPGA, M4A, OGG, WAV and WebM files up to 25 MB.
|
|
282
|
+
* The filename must include the matching extension. For a MediaRecorder blob,
|
|
283
|
+
* wrap it in a File with the recording's extension and MIME type.
|
|
284
|
+
* Show the returned text as a draft; call `sendMessage` when the user sends it.
|
|
285
|
+
*/
|
|
286
|
+
transcribeAudio(file: File, options?: TranscribeAudioOptions): Promise<AudioTranscription>;
|
|
265
287
|
/**
|
|
266
288
|
* The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
|
|
267
289
|
* agents, the ticket form the agent's `ago_ticketing` tool opens, and the
|
|
268
|
-
* file-attachment
|
|
269
|
-
* form first appears in a conversation.
|
|
290
|
+
* file-attachment and speech-to-text flags. The vanilla widget fetches it
|
|
291
|
+
* once, when a ticket form first appears in a conversation.
|
|
270
292
|
*/
|
|
271
293
|
getConfig(): Promise<SdkConfig>;
|
|
272
294
|
/**
|
|
@@ -403,6 +425,9 @@ export declare class AgoClient {
|
|
|
403
425
|
* Get all registered function schemas
|
|
404
426
|
*/
|
|
405
427
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
428
|
+
/** The callback form of `functions:changed`. Returns an unsubscribe. */
|
|
429
|
+
onFunctionsChanged(listener: () => void): () => void;
|
|
430
|
+
/* Excluded from this release type: getFunctionRegistrations */
|
|
406
431
|
/**
|
|
407
432
|
* Execute a registered client function locally, through the same
|
|
408
433
|
* FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
|
|
@@ -425,14 +450,15 @@ export declare class AgoClient {
|
|
|
425
450
|
* page of an entity. Flat arguments only: nested object parameters are not
|
|
426
451
|
* reliably rendered to the model, so placeholders must not be named `page`.
|
|
427
452
|
*
|
|
453
|
+
* For a large table, `{ catalogue: "onDemand" }` moves the route descriptions
|
|
454
|
+
* into a read-only `listPages` companion, leaving only the page names in the
|
|
455
|
+
* per-message schema. Routes may carry a `section` to group that companion.
|
|
456
|
+
*
|
|
428
457
|
* @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
|
|
429
458
|
* @param routes - Map of route names to paths, with descriptions for the LLM
|
|
459
|
+
* @param opts - Where the catalogue lives; `"inline"` by default
|
|
430
460
|
*/
|
|
431
|
-
registerNavigationFunction(navigate: (path: string) => void, routes:
|
|
432
|
-
name: string;
|
|
433
|
-
path: string;
|
|
434
|
-
description: string;
|
|
435
|
-
}>): void;
|
|
461
|
+
registerNavigationFunction(navigate: (path: string) => void, routes: NavRoute[], opts?: AgoNavigationOptions): void;
|
|
436
462
|
/**
|
|
437
463
|
* Unregister the navigation function and its `current-page` context provider.
|
|
438
464
|
*/
|
|
@@ -735,6 +761,8 @@ export declare interface AgoClientEvents {
|
|
|
735
761
|
* call running immediately.
|
|
736
762
|
*/
|
|
737
763
|
"function:awaiting-approval": ClientFunctionInvocation;
|
|
764
|
+
/** A function was registered or unregistered, or the registry cleared. */
|
|
765
|
+
"functions:changed": ClientFunctionSchema[];
|
|
738
766
|
"function:result": {
|
|
739
767
|
invocationId: string;
|
|
740
768
|
result: unknown;
|
|
@@ -807,6 +835,8 @@ export declare interface AgoConfig {
|
|
|
807
835
|
defaultAgentId?: string;
|
|
808
836
|
/** Permission name to apply to all requests (sent as `X-Widget-Permission`). Mirrors the widget's `window.AGO.permission`. */
|
|
809
837
|
permission?: string;
|
|
838
|
+
/** Interface locale selected by the host app, sent as Accept-Language. Null clears the override. */
|
|
839
|
+
language?: string | null;
|
|
810
840
|
/** User email for identification */
|
|
811
841
|
userEmail?: string;
|
|
812
842
|
/** JWT token for authenticated users */
|
|
@@ -884,6 +914,15 @@ export declare interface AgoConfig {
|
|
|
884
914
|
* mode's `jsErrors` signal. See `client.reportError()` for caught errors.
|
|
885
915
|
*/
|
|
886
916
|
errorWatcher?: boolean | ErrorWatcherOptions;
|
|
917
|
+
/** Mirror every registered client function into the browser's WebMCP registry
|
|
918
|
+
* (`document.modelContext`), so an external agent can call the same functions
|
|
919
|
+
* the in-app agent calls. Off by default; no-ops without WebMCP.
|
|
920
|
+
*
|
|
921
|
+
* A mirrored function runs immediately: the approval gate
|
|
922
|
+
* ({@link approvalPolicy}, `requiresApproval`) covers the agent loop only.
|
|
923
|
+
* Use `webmcp: false` on a definition to keep it out.
|
|
924
|
+
*/
|
|
925
|
+
webmcp?: boolean;
|
|
887
926
|
}
|
|
888
927
|
|
|
889
928
|
/**
|
|
@@ -938,6 +977,16 @@ export declare interface AgoMessage {
|
|
|
938
977
|
createdAt: Date;
|
|
939
978
|
}
|
|
940
979
|
|
|
980
|
+
/**
|
|
981
|
+
* Where the route catalogue lives: `"inline"` (default) in `navigateToPage`'s
|
|
982
|
+
* description, or `"onDemand"` in a `listPages` companion's result.
|
|
983
|
+
*/
|
|
984
|
+
export declare type AgoNavigationOptions = {
|
|
985
|
+
catalogue?: "inline";
|
|
986
|
+
} | {
|
|
987
|
+
catalogue: "onDemand";
|
|
988
|
+
};
|
|
989
|
+
|
|
941
990
|
/**
|
|
942
991
|
* Network/connection error
|
|
943
992
|
*/
|
|
@@ -1200,6 +1249,11 @@ declare interface ApiErrorResponse {
|
|
|
1200
1249
|
*/
|
|
1201
1250
|
export declare function attachAutoContinueAfterNavigation(client: AgoClient, options?: AgoAutoContinueOptions | (() => AgoAutoContinueOptions | undefined)): () => void;
|
|
1202
1251
|
|
|
1252
|
+
/** Editable text returned by `AgoClient.transcribeAudio`. */
|
|
1253
|
+
export declare interface AudioTranscription {
|
|
1254
|
+
text: string;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1203
1257
|
/**
|
|
1204
1258
|
* Auto-detect AGO configuration from the DOM environment.
|
|
1205
1259
|
*
|
|
@@ -1303,22 +1357,11 @@ export declare type ClientFunction = (args: Record<string, unknown>) => Promise<
|
|
|
1303
1357
|
* client.registerFunction(fn);
|
|
1304
1358
|
* ```
|
|
1305
1359
|
*/
|
|
1306
|
-
export declare interface ClientFunctionDefinition {
|
|
1360
|
+
export declare interface ClientFunctionDefinition extends ClientFunctionSettings {
|
|
1307
1361
|
name: string;
|
|
1308
1362
|
description: string;
|
|
1309
1363
|
parameters: ClientFunctionSchema["parameters"];
|
|
1310
1364
|
handler: ClientFunctionHandler;
|
|
1311
|
-
/**
|
|
1312
|
-
* Max serialized result size in bytes before the SDK truncates it to a
|
|
1313
|
-
* flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
|
|
1314
|
-
* `Infinity` disables the guard for this function.
|
|
1315
|
-
*/
|
|
1316
|
-
maxResultBytes?: number;
|
|
1317
|
-
/**
|
|
1318
|
-
* Require explicit user approval before this function runs. See
|
|
1319
|
-
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
1320
|
-
*/
|
|
1321
|
-
requiresApproval?: boolean;
|
|
1322
1365
|
}
|
|
1323
1366
|
|
|
1324
1367
|
/**
|
|
@@ -1337,20 +1380,7 @@ export declare interface ClientFunctionInvocation {
|
|
|
1337
1380
|
* Schema-plus-settings object accepted when registering a function: the schema
|
|
1338
1381
|
* (minus `name`) and SDK-side options that are NOT sent to the backend.
|
|
1339
1382
|
*/
|
|
1340
|
-
export declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> &
|
|
1341
|
-
/**
|
|
1342
|
-
* Max serialized result size in bytes before the SDK truncates it to a
|
|
1343
|
-
* flagged preview. Overrides the client-level default
|
|
1344
|
-
* (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
|
|
1345
|
-
* disables the guard for this function.
|
|
1346
|
-
*/
|
|
1347
|
-
maxResultBytes?: number;
|
|
1348
|
-
/**
|
|
1349
|
-
* Require explicit user approval before this function runs. See
|
|
1350
|
-
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
1351
|
-
*/
|
|
1352
|
-
requiresApproval?: boolean;
|
|
1353
|
-
};
|
|
1383
|
+
export declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & ClientFunctionSettings;
|
|
1354
1384
|
|
|
1355
1385
|
/**
|
|
1356
1386
|
* Schema for a client-side function that AGO can call
|
|
@@ -1377,6 +1407,28 @@ export declare interface ClientFunctionSchema {
|
|
|
1377
1407
|
};
|
|
1378
1408
|
}
|
|
1379
1409
|
|
|
1410
|
+
/** SDK-side function settings that are never sent to the backend. */
|
|
1411
|
+
declare interface ClientFunctionSettings {
|
|
1412
|
+
/**
|
|
1413
|
+
* Max serialized result size in bytes before the SDK truncates it to a
|
|
1414
|
+
* flagged preview. Overrides the client-level default
|
|
1415
|
+
* (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
|
|
1416
|
+
* disables the guard for this function.
|
|
1417
|
+
*/
|
|
1418
|
+
maxResultBytes?: number;
|
|
1419
|
+
/**
|
|
1420
|
+
* Require explicit user approval before this function runs. See
|
|
1421
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
1422
|
+
*/
|
|
1423
|
+
requiresApproval?: boolean;
|
|
1424
|
+
/**
|
|
1425
|
+
* WebMCP metadata, read only when the bridge is on (`AgoConfig.webmcp`).
|
|
1426
|
+
* `false` keeps this function out of WebMCP while leaving it available to the
|
|
1427
|
+
* in-app agent.
|
|
1428
|
+
*/
|
|
1429
|
+
webmcp?: WebMCPToolMeta | false;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1380
1432
|
/** See {@link AgoConfig.clientFunctionsMode}. */
|
|
1381
1433
|
export declare type ClientFunctionsMode = "placeholder" | "pause";
|
|
1382
1434
|
|
|
@@ -2045,7 +2097,11 @@ export declare interface FunctionDefinition {
|
|
|
2045
2097
|
export declare class FunctionRegistry {
|
|
2046
2098
|
private functions;
|
|
2047
2099
|
private defaultMaxResultBytes;
|
|
2100
|
+
private changeListeners;
|
|
2048
2101
|
constructor(options?: FunctionRegistryOptions);
|
|
2102
|
+
/** Fires on registrations, unregistrations and clears. */
|
|
2103
|
+
onChange(listener: () => void): () => void;
|
|
2104
|
+
private emitChange;
|
|
2049
2105
|
/** Update the client-level result-size ceiling at runtime. */
|
|
2050
2106
|
setDefaultMaxResultBytes(bytes: number): void;
|
|
2051
2107
|
/**
|
|
@@ -2076,6 +2132,13 @@ export declare class FunctionRegistry {
|
|
|
2076
2132
|
* Get all registered function schemas (for sending to backend)
|
|
2077
2133
|
*/
|
|
2078
2134
|
getSchemas(): ClientFunctionSchema[];
|
|
2135
|
+
/**
|
|
2136
|
+
* Every registration, name included, with the SDK-side settings
|
|
2137
|
+
* {@link getSchemas} drops.
|
|
2138
|
+
*/
|
|
2139
|
+
getAll(): Array<RegisteredFunction & {
|
|
2140
|
+
name: string;
|
|
2141
|
+
}>;
|
|
2079
2142
|
/**
|
|
2080
2143
|
* Execute a registered function
|
|
2081
2144
|
*/
|
|
@@ -2286,6 +2349,15 @@ export declare interface MockAgoClientOptions {
|
|
|
2286
2349
|
|
|
2287
2350
|
declare type MockFn = (...args: any[]) => any;
|
|
2288
2351
|
|
|
2352
|
+
/** A navigable page. `path` may carry `:param` placeholders. */
|
|
2353
|
+
export declare interface NavRoute {
|
|
2354
|
+
name: string;
|
|
2355
|
+
path: string;
|
|
2356
|
+
description: string;
|
|
2357
|
+
/** Only read under `catalogue: "onDemand"`. */
|
|
2358
|
+
section?: string;
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2289
2361
|
/**
|
|
2290
2362
|
* Optional action attached to a nudge. Accepting a `functionName` action
|
|
2291
2363
|
* executes the registered client function (same `FunctionRegistry` path as
|
|
@@ -2587,13 +2659,9 @@ export declare interface ProactiveTriggerWhen {
|
|
|
2587
2659
|
/**
|
|
2588
2660
|
* Registered function with handler
|
|
2589
2661
|
*/
|
|
2590
|
-
export declare interface RegisteredFunction {
|
|
2662
|
+
export declare interface RegisteredFunction extends ClientFunctionSettings {
|
|
2591
2663
|
schema: ClientFunctionSchema;
|
|
2592
2664
|
handler: ClientFunctionHandler;
|
|
2593
|
-
/** Per-function result-size ceiling; falls back to the registry default. */
|
|
2594
|
-
maxResultBytes?: number;
|
|
2595
|
-
/** Require explicit user approval before running (pause mode only). */
|
|
2596
|
-
requiresApproval?: boolean;
|
|
2597
2665
|
}
|
|
2598
2666
|
|
|
2599
2667
|
/**
|
|
@@ -2622,7 +2690,7 @@ export declare function safeAttachmentUrl(url?: string): string | undefined;
|
|
|
2622
2690
|
export declare const scrollToElement: ClientFunctionDefinition;
|
|
2623
2691
|
|
|
2624
2692
|
/** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
|
|
2625
|
-
declare interface SdkConfig {
|
|
2693
|
+
export declare interface SdkConfig {
|
|
2626
2694
|
permissions: SdkPermissionConfig[];
|
|
2627
2695
|
proactive: {
|
|
2628
2696
|
enabled: boolean;
|
|
@@ -2653,7 +2721,7 @@ declare interface SdkHomeStarter {
|
|
|
2653
2721
|
}
|
|
2654
2722
|
|
|
2655
2723
|
/** One permission's configuration in {@link SdkConfig}. */
|
|
2656
|
-
declare interface SdkPermissionConfig {
|
|
2724
|
+
export declare interface SdkPermissionConfig {
|
|
2657
2725
|
id?: string;
|
|
2658
2726
|
name?: string;
|
|
2659
2727
|
displayName?: string;
|
|
@@ -2666,6 +2734,8 @@ declare interface SdkPermissionConfig {
|
|
|
2666
2734
|
homePage?: SdkHomePageConfig;
|
|
2667
2735
|
fileAttachmentsEnabled: boolean;
|
|
2668
2736
|
voiceEnabled: boolean;
|
|
2737
|
+
/** Whether audio uploads can be transcribed. Defaults to false on older backends. */
|
|
2738
|
+
speechToTextEnabled: boolean;
|
|
2669
2739
|
}
|
|
2670
2740
|
|
|
2671
2741
|
/**
|
|
@@ -3254,6 +3324,12 @@ export declare type ToolCallType = "form" | "confirmation_input" | "status_messa
|
|
|
3254
3324
|
*/
|
|
3255
3325
|
export declare const trackEvent: ClientFunctionDefinition;
|
|
3256
3326
|
|
|
3327
|
+
/** Options for `AgoClient.transcribeAudio`. */
|
|
3328
|
+
export declare interface TranscribeAudioOptions {
|
|
3329
|
+
/** Cancel the upload or stop waiting for its transcription. */
|
|
3330
|
+
signal?: AbortSignal;
|
|
3331
|
+
}
|
|
3332
|
+
|
|
3257
3333
|
/**
|
|
3258
3334
|
* Validate an AgoConfig at the public API boundary.
|
|
3259
3335
|
*
|
|
@@ -3277,6 +3353,25 @@ export declare const trackEvent: ClientFunctionDefinition;
|
|
|
3277
3353
|
*/
|
|
3278
3354
|
export declare function validateConfig(config: unknown, context?: string): asserts config is AgoConfig;
|
|
3279
3355
|
|
|
3356
|
+
/** The MCP behavior hints AGO has no equivalent for. */
|
|
3357
|
+
export declare interface WebMCPToolMeta {
|
|
3358
|
+
/**
|
|
3359
|
+
* Both default to `false`, so only set what is true: `readOnlyHint` marks a
|
|
3360
|
+
* function that changes nothing, `untrustedContentHint` one whose result may
|
|
3361
|
+
* carry third-party text.
|
|
3362
|
+
*/
|
|
3363
|
+
annotations?: {
|
|
3364
|
+
readOnlyHint?: boolean;
|
|
3365
|
+
untrustedContentHint?: boolean;
|
|
3366
|
+
};
|
|
3367
|
+
/**
|
|
3368
|
+
* This function navigates. The WebMCP call is held open until the function
|
|
3369
|
+
* registry goes quiet, so the caller sees the destination page's tools rather
|
|
3370
|
+
* than the departing page's. Already set on the built-in `navigateToPage`.
|
|
3371
|
+
*/
|
|
3372
|
+
navigates?: boolean;
|
|
3373
|
+
}
|
|
3374
|
+
|
|
3280
3375
|
/**
|
|
3281
3376
|
* Attach a handler to a pre-built function definition.
|
|
3282
3377
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -97,6 +97,8 @@ export declare class AgoClient {
|
|
|
97
97
|
private config;
|
|
98
98
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
99
99
|
private warnedEmptyConversations;
|
|
100
|
+
/** Client functions the backend has accepted from a WebMCP call report. */
|
|
101
|
+
private declaredExternally;
|
|
100
102
|
/** Whether the placeholder-mode page-data warning has already been logged. */
|
|
101
103
|
private warnedPageDataPlaceholder;
|
|
102
104
|
/** `readPageData` companions this SDK registered, so cleanup only removes its own. */
|
|
@@ -131,7 +133,12 @@ export declare class AgoClient {
|
|
|
131
133
|
* `null` otherwise.
|
|
132
134
|
*/
|
|
133
135
|
proactive: ProactiveController | null;
|
|
136
|
+
/** Removes the mirrored WebMCP tools; `null` when the bridge is off. */
|
|
137
|
+
private detachWebMCP;
|
|
138
|
+
/** The `listPages` companion is live. */
|
|
139
|
+
private listPagesRegistered;
|
|
134
140
|
constructor(config: AgoConfig);
|
|
141
|
+
private attachWebMCPBridge;
|
|
135
142
|
/**
|
|
136
143
|
* Send a message and receive a streaming response
|
|
137
144
|
*/
|
|
@@ -243,6 +250,12 @@ export declare class AgoClient {
|
|
|
243
250
|
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
244
251
|
*/
|
|
245
252
|
rejectFunction(invocationId: string): Promise<void>;
|
|
253
|
+
/* Excluded from this release type: runExternalFunction */
|
|
254
|
+
/**
|
|
255
|
+
* Best-effort analytics for one WebMCP call. No agent: the caller is someone
|
|
256
|
+
* else's agent and cannot be known from `execute`.
|
|
257
|
+
*/
|
|
258
|
+
private reportExternalCall;
|
|
246
259
|
/**
|
|
247
260
|
* Get a page of conversations, newest-first. `pageSize` is capped at 100 by
|
|
248
261
|
* the backend (default 50). Returns the `{ data, has_more, total }` envelope
|
|
@@ -262,11 +275,20 @@ export declare class AgoClient {
|
|
|
262
275
|
* `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
|
|
263
276
|
*/
|
|
264
277
|
private static mapPersistedToolCalls;
|
|
278
|
+
/**
|
|
279
|
+
* Transcribe an audio file into editable text (`POST /api/sdk/v1/audio/transcriptions`).
|
|
280
|
+
* Requires speech to text to be enabled for the tenant. Supports FLAC, MP3,
|
|
281
|
+
* MP4, MPEG, MPGA, M4A, OGG, WAV and WebM files up to 25 MB.
|
|
282
|
+
* The filename must include the matching extension. For a MediaRecorder blob,
|
|
283
|
+
* wrap it in a File with the recording's extension and MIME type.
|
|
284
|
+
* Show the returned text as a draft; call `sendMessage` when the user sends it.
|
|
285
|
+
*/
|
|
286
|
+
transcribeAudio(file: File, options?: TranscribeAudioOptions): Promise<AudioTranscription>;
|
|
265
287
|
/**
|
|
266
288
|
* The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
|
|
267
289
|
* agents, the ticket form the agent's `ago_ticketing` tool opens, and the
|
|
268
|
-
* file-attachment
|
|
269
|
-
* form first appears in a conversation.
|
|
290
|
+
* file-attachment and speech-to-text flags. The vanilla widget fetches it
|
|
291
|
+
* once, when a ticket form first appears in a conversation.
|
|
270
292
|
*/
|
|
271
293
|
getConfig(): Promise<SdkConfig>;
|
|
272
294
|
/**
|
|
@@ -403,6 +425,9 @@ export declare class AgoClient {
|
|
|
403
425
|
* Get all registered function schemas
|
|
404
426
|
*/
|
|
405
427
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
428
|
+
/** The callback form of `functions:changed`. Returns an unsubscribe. */
|
|
429
|
+
onFunctionsChanged(listener: () => void): () => void;
|
|
430
|
+
/* Excluded from this release type: getFunctionRegistrations */
|
|
406
431
|
/**
|
|
407
432
|
* Execute a registered client function locally, through the same
|
|
408
433
|
* FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
|
|
@@ -425,14 +450,15 @@ export declare class AgoClient {
|
|
|
425
450
|
* page of an entity. Flat arguments only: nested object parameters are not
|
|
426
451
|
* reliably rendered to the model, so placeholders must not be named `page`.
|
|
427
452
|
*
|
|
453
|
+
* For a large table, `{ catalogue: "onDemand" }` moves the route descriptions
|
|
454
|
+
* into a read-only `listPages` companion, leaving only the page names in the
|
|
455
|
+
* per-message schema. Routes may carry a `section` to group that companion.
|
|
456
|
+
*
|
|
428
457
|
* @param navigate - A callback that performs the navigation (e.g. react-router's navigate)
|
|
429
458
|
* @param routes - Map of route names to paths, with descriptions for the LLM
|
|
459
|
+
* @param opts - Where the catalogue lives; `"inline"` by default
|
|
430
460
|
*/
|
|
431
|
-
registerNavigationFunction(navigate: (path: string) => void, routes:
|
|
432
|
-
name: string;
|
|
433
|
-
path: string;
|
|
434
|
-
description: string;
|
|
435
|
-
}>): void;
|
|
461
|
+
registerNavigationFunction(navigate: (path: string) => void, routes: NavRoute[], opts?: AgoNavigationOptions): void;
|
|
436
462
|
/**
|
|
437
463
|
* Unregister the navigation function and its `current-page` context provider.
|
|
438
464
|
*/
|
|
@@ -735,6 +761,8 @@ export declare interface AgoClientEvents {
|
|
|
735
761
|
* call running immediately.
|
|
736
762
|
*/
|
|
737
763
|
"function:awaiting-approval": ClientFunctionInvocation;
|
|
764
|
+
/** A function was registered or unregistered, or the registry cleared. */
|
|
765
|
+
"functions:changed": ClientFunctionSchema[];
|
|
738
766
|
"function:result": {
|
|
739
767
|
invocationId: string;
|
|
740
768
|
result: unknown;
|
|
@@ -807,6 +835,8 @@ export declare interface AgoConfig {
|
|
|
807
835
|
defaultAgentId?: string;
|
|
808
836
|
/** Permission name to apply to all requests (sent as `X-Widget-Permission`). Mirrors the widget's `window.AGO.permission`. */
|
|
809
837
|
permission?: string;
|
|
838
|
+
/** Interface locale selected by the host app, sent as Accept-Language. Null clears the override. */
|
|
839
|
+
language?: string | null;
|
|
810
840
|
/** User email for identification */
|
|
811
841
|
userEmail?: string;
|
|
812
842
|
/** JWT token for authenticated users */
|
|
@@ -884,6 +914,15 @@ export declare interface AgoConfig {
|
|
|
884
914
|
* mode's `jsErrors` signal. See `client.reportError()` for caught errors.
|
|
885
915
|
*/
|
|
886
916
|
errorWatcher?: boolean | ErrorWatcherOptions;
|
|
917
|
+
/** Mirror every registered client function into the browser's WebMCP registry
|
|
918
|
+
* (`document.modelContext`), so an external agent can call the same functions
|
|
919
|
+
* the in-app agent calls. Off by default; no-ops without WebMCP.
|
|
920
|
+
*
|
|
921
|
+
* A mirrored function runs immediately: the approval gate
|
|
922
|
+
* ({@link approvalPolicy}, `requiresApproval`) covers the agent loop only.
|
|
923
|
+
* Use `webmcp: false` on a definition to keep it out.
|
|
924
|
+
*/
|
|
925
|
+
webmcp?: boolean;
|
|
887
926
|
}
|
|
888
927
|
|
|
889
928
|
/**
|
|
@@ -938,6 +977,16 @@ export declare interface AgoMessage {
|
|
|
938
977
|
createdAt: Date;
|
|
939
978
|
}
|
|
940
979
|
|
|
980
|
+
/**
|
|
981
|
+
* Where the route catalogue lives: `"inline"` (default) in `navigateToPage`'s
|
|
982
|
+
* description, or `"onDemand"` in a `listPages` companion's result.
|
|
983
|
+
*/
|
|
984
|
+
export declare type AgoNavigationOptions = {
|
|
985
|
+
catalogue?: "inline";
|
|
986
|
+
} | {
|
|
987
|
+
catalogue: "onDemand";
|
|
988
|
+
};
|
|
989
|
+
|
|
941
990
|
/**
|
|
942
991
|
* Network/connection error
|
|
943
992
|
*/
|
|
@@ -1200,6 +1249,11 @@ declare interface ApiErrorResponse {
|
|
|
1200
1249
|
*/
|
|
1201
1250
|
export declare function attachAutoContinueAfterNavigation(client: AgoClient, options?: AgoAutoContinueOptions | (() => AgoAutoContinueOptions | undefined)): () => void;
|
|
1202
1251
|
|
|
1252
|
+
/** Editable text returned by `AgoClient.transcribeAudio`. */
|
|
1253
|
+
export declare interface AudioTranscription {
|
|
1254
|
+
text: string;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1203
1257
|
/**
|
|
1204
1258
|
* Auto-detect AGO configuration from the DOM environment.
|
|
1205
1259
|
*
|
|
@@ -1303,22 +1357,11 @@ export declare type ClientFunction = (args: Record<string, unknown>) => Promise<
|
|
|
1303
1357
|
* client.registerFunction(fn);
|
|
1304
1358
|
* ```
|
|
1305
1359
|
*/
|
|
1306
|
-
export declare interface ClientFunctionDefinition {
|
|
1360
|
+
export declare interface ClientFunctionDefinition extends ClientFunctionSettings {
|
|
1307
1361
|
name: string;
|
|
1308
1362
|
description: string;
|
|
1309
1363
|
parameters: ClientFunctionSchema["parameters"];
|
|
1310
1364
|
handler: ClientFunctionHandler;
|
|
1311
|
-
/**
|
|
1312
|
-
* Max serialized result size in bytes before the SDK truncates it to a
|
|
1313
|
-
* flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
|
|
1314
|
-
* `Infinity` disables the guard for this function.
|
|
1315
|
-
*/
|
|
1316
|
-
maxResultBytes?: number;
|
|
1317
|
-
/**
|
|
1318
|
-
* Require explicit user approval before this function runs. See
|
|
1319
|
-
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
1320
|
-
*/
|
|
1321
|
-
requiresApproval?: boolean;
|
|
1322
1365
|
}
|
|
1323
1366
|
|
|
1324
1367
|
/**
|
|
@@ -1337,20 +1380,7 @@ export declare interface ClientFunctionInvocation {
|
|
|
1337
1380
|
* Schema-plus-settings object accepted when registering a function: the schema
|
|
1338
1381
|
* (minus `name`) and SDK-side options that are NOT sent to the backend.
|
|
1339
1382
|
*/
|
|
1340
|
-
export declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> &
|
|
1341
|
-
/**
|
|
1342
|
-
* Max serialized result size in bytes before the SDK truncates it to a
|
|
1343
|
-
* flagged preview. Overrides the client-level default
|
|
1344
|
-
* (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
|
|
1345
|
-
* disables the guard for this function.
|
|
1346
|
-
*/
|
|
1347
|
-
maxResultBytes?: number;
|
|
1348
|
-
/**
|
|
1349
|
-
* Require explicit user approval before this function runs. See
|
|
1350
|
-
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
1351
|
-
*/
|
|
1352
|
-
requiresApproval?: boolean;
|
|
1353
|
-
};
|
|
1383
|
+
export declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & ClientFunctionSettings;
|
|
1354
1384
|
|
|
1355
1385
|
/**
|
|
1356
1386
|
* Schema for a client-side function that AGO can call
|
|
@@ -1377,6 +1407,28 @@ export declare interface ClientFunctionSchema {
|
|
|
1377
1407
|
};
|
|
1378
1408
|
}
|
|
1379
1409
|
|
|
1410
|
+
/** SDK-side function settings that are never sent to the backend. */
|
|
1411
|
+
declare interface ClientFunctionSettings {
|
|
1412
|
+
/**
|
|
1413
|
+
* Max serialized result size in bytes before the SDK truncates it to a
|
|
1414
|
+
* flagged preview. Overrides the client-level default
|
|
1415
|
+
* (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
|
|
1416
|
+
* disables the guard for this function.
|
|
1417
|
+
*/
|
|
1418
|
+
maxResultBytes?: number;
|
|
1419
|
+
/**
|
|
1420
|
+
* Require explicit user approval before this function runs. See
|
|
1421
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
1422
|
+
*/
|
|
1423
|
+
requiresApproval?: boolean;
|
|
1424
|
+
/**
|
|
1425
|
+
* WebMCP metadata, read only when the bridge is on (`AgoConfig.webmcp`).
|
|
1426
|
+
* `false` keeps this function out of WebMCP while leaving it available to the
|
|
1427
|
+
* in-app agent.
|
|
1428
|
+
*/
|
|
1429
|
+
webmcp?: WebMCPToolMeta | false;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1380
1432
|
/** See {@link AgoConfig.clientFunctionsMode}. */
|
|
1381
1433
|
export declare type ClientFunctionsMode = "placeholder" | "pause";
|
|
1382
1434
|
|
|
@@ -2045,7 +2097,11 @@ export declare interface FunctionDefinition {
|
|
|
2045
2097
|
export declare class FunctionRegistry {
|
|
2046
2098
|
private functions;
|
|
2047
2099
|
private defaultMaxResultBytes;
|
|
2100
|
+
private changeListeners;
|
|
2048
2101
|
constructor(options?: FunctionRegistryOptions);
|
|
2102
|
+
/** Fires on registrations, unregistrations and clears. */
|
|
2103
|
+
onChange(listener: () => void): () => void;
|
|
2104
|
+
private emitChange;
|
|
2049
2105
|
/** Update the client-level result-size ceiling at runtime. */
|
|
2050
2106
|
setDefaultMaxResultBytes(bytes: number): void;
|
|
2051
2107
|
/**
|
|
@@ -2076,6 +2132,13 @@ export declare class FunctionRegistry {
|
|
|
2076
2132
|
* Get all registered function schemas (for sending to backend)
|
|
2077
2133
|
*/
|
|
2078
2134
|
getSchemas(): ClientFunctionSchema[];
|
|
2135
|
+
/**
|
|
2136
|
+
* Every registration, name included, with the SDK-side settings
|
|
2137
|
+
* {@link getSchemas} drops.
|
|
2138
|
+
*/
|
|
2139
|
+
getAll(): Array<RegisteredFunction & {
|
|
2140
|
+
name: string;
|
|
2141
|
+
}>;
|
|
2079
2142
|
/**
|
|
2080
2143
|
* Execute a registered function
|
|
2081
2144
|
*/
|
|
@@ -2286,6 +2349,15 @@ export declare interface MockAgoClientOptions {
|
|
|
2286
2349
|
|
|
2287
2350
|
declare type MockFn = (...args: any[]) => any;
|
|
2288
2351
|
|
|
2352
|
+
/** A navigable page. `path` may carry `:param` placeholders. */
|
|
2353
|
+
export declare interface NavRoute {
|
|
2354
|
+
name: string;
|
|
2355
|
+
path: string;
|
|
2356
|
+
description: string;
|
|
2357
|
+
/** Only read under `catalogue: "onDemand"`. */
|
|
2358
|
+
section?: string;
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2289
2361
|
/**
|
|
2290
2362
|
* Optional action attached to a nudge. Accepting a `functionName` action
|
|
2291
2363
|
* executes the registered client function (same `FunctionRegistry` path as
|
|
@@ -2587,13 +2659,9 @@ export declare interface ProactiveTriggerWhen {
|
|
|
2587
2659
|
/**
|
|
2588
2660
|
* Registered function with handler
|
|
2589
2661
|
*/
|
|
2590
|
-
export declare interface RegisteredFunction {
|
|
2662
|
+
export declare interface RegisteredFunction extends ClientFunctionSettings {
|
|
2591
2663
|
schema: ClientFunctionSchema;
|
|
2592
2664
|
handler: ClientFunctionHandler;
|
|
2593
|
-
/** Per-function result-size ceiling; falls back to the registry default. */
|
|
2594
|
-
maxResultBytes?: number;
|
|
2595
|
-
/** Require explicit user approval before running (pause mode only). */
|
|
2596
|
-
requiresApproval?: boolean;
|
|
2597
2665
|
}
|
|
2598
2666
|
|
|
2599
2667
|
/**
|
|
@@ -2622,7 +2690,7 @@ export declare function safeAttachmentUrl(url?: string): string | undefined;
|
|
|
2622
2690
|
export declare const scrollToElement: ClientFunctionDefinition;
|
|
2623
2691
|
|
|
2624
2692
|
/** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
|
|
2625
|
-
declare interface SdkConfig {
|
|
2693
|
+
export declare interface SdkConfig {
|
|
2626
2694
|
permissions: SdkPermissionConfig[];
|
|
2627
2695
|
proactive: {
|
|
2628
2696
|
enabled: boolean;
|
|
@@ -2653,7 +2721,7 @@ declare interface SdkHomeStarter {
|
|
|
2653
2721
|
}
|
|
2654
2722
|
|
|
2655
2723
|
/** One permission's configuration in {@link SdkConfig}. */
|
|
2656
|
-
declare interface SdkPermissionConfig {
|
|
2724
|
+
export declare interface SdkPermissionConfig {
|
|
2657
2725
|
id?: string;
|
|
2658
2726
|
name?: string;
|
|
2659
2727
|
displayName?: string;
|
|
@@ -2666,6 +2734,8 @@ declare interface SdkPermissionConfig {
|
|
|
2666
2734
|
homePage?: SdkHomePageConfig;
|
|
2667
2735
|
fileAttachmentsEnabled: boolean;
|
|
2668
2736
|
voiceEnabled: boolean;
|
|
2737
|
+
/** Whether audio uploads can be transcribed. Defaults to false on older backends. */
|
|
2738
|
+
speechToTextEnabled: boolean;
|
|
2669
2739
|
}
|
|
2670
2740
|
|
|
2671
2741
|
/**
|
|
@@ -3254,6 +3324,12 @@ export declare type ToolCallType = "form" | "confirmation_input" | "status_messa
|
|
|
3254
3324
|
*/
|
|
3255
3325
|
export declare const trackEvent: ClientFunctionDefinition;
|
|
3256
3326
|
|
|
3327
|
+
/** Options for `AgoClient.transcribeAudio`. */
|
|
3328
|
+
export declare interface TranscribeAudioOptions {
|
|
3329
|
+
/** Cancel the upload or stop waiting for its transcription. */
|
|
3330
|
+
signal?: AbortSignal;
|
|
3331
|
+
}
|
|
3332
|
+
|
|
3257
3333
|
/**
|
|
3258
3334
|
* Validate an AgoConfig at the public API boundary.
|
|
3259
3335
|
*
|
|
@@ -3277,6 +3353,25 @@ export declare const trackEvent: ClientFunctionDefinition;
|
|
|
3277
3353
|
*/
|
|
3278
3354
|
export declare function validateConfig(config: unknown, context?: string): asserts config is AgoConfig;
|
|
3279
3355
|
|
|
3356
|
+
/** The MCP behavior hints AGO has no equivalent for. */
|
|
3357
|
+
export declare interface WebMCPToolMeta {
|
|
3358
|
+
/**
|
|
3359
|
+
* Both default to `false`, so only set what is true: `readOnlyHint` marks a
|
|
3360
|
+
* function that changes nothing, `untrustedContentHint` one whose result may
|
|
3361
|
+
* carry third-party text.
|
|
3362
|
+
*/
|
|
3363
|
+
annotations?: {
|
|
3364
|
+
readOnlyHint?: boolean;
|
|
3365
|
+
untrustedContentHint?: boolean;
|
|
3366
|
+
};
|
|
3367
|
+
/**
|
|
3368
|
+
* This function navigates. The WebMCP call is held open until the function
|
|
3369
|
+
* registry goes quiet, so the caller sees the destination page's tools rather
|
|
3370
|
+
* than the departing page's. Already set on the built-in `navigateToPage`.
|
|
3371
|
+
*/
|
|
3372
|
+
navigates?: boolean;
|
|
3373
|
+
}
|
|
3374
|
+
|
|
3280
3375
|
/**
|
|
3281
3376
|
* Attach a handler to a pre-built function definition.
|
|
3282
3377
|
*
|