@useago/sdk 1.9.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/README.md +53 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +313 -0
- package/dist/angular.d.ts +313 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-BaaXBQ5b.js → createConversationSession-B1Qn-y0I.js} +1 -1
- package/dist/{createConversationSession-CU0b-t1W.cjs → createConversationSession-B3v_xOU7.cjs} +1 -1
- package/dist/{createFormCollector-DfN1xZBy.cjs → createFormCollector-FvwDOqnV.cjs} +1 -1
- package/dist/{createFormCollector-Cf7kGhCB.js → createFormCollector-m79zk_NA.js} +1 -1
- package/dist/createMockClient-BEOXI8yW.cjs +1 -0
- package/dist/{createMockClient-5YF-ZbVu.js → createMockClient-Beao82tu.js} +15 -3
- package/dist/devtools.d.cts +313 -0
- package/dist/devtools.d.ts +313 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +389 -4
- package/dist/index.d.ts +389 -4
- package/dist/index.js +118 -114
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +313 -0
- package/dist/react.d.ts +313 -0
- package/dist/react.js +8 -6
- package/dist/sheetController-BThJRtOu.cjs +1 -0
- package/dist/sheetController-aEKXIvjk.js +343 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +313 -0
- package/dist/testing.d.ts +313 -0
- package/dist/testing.js +1 -1
- package/dist/types-Ct1hlKwg.js +2408 -0
- package/dist/types-mcW8vB1U.cjs +10 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +505 -0
- package/dist/vue.d.ts +505 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +6 -4
- package/dist/widget.d.cts +585 -2
- package/dist/widget.d.ts +585 -2
- package/dist/widget.js +3985 -995
- package/llms-full.txt +125 -6
- package/package.json +1 -1
- package/dist/createMockClient-BZbOe-23.cjs +0 -1
- package/dist/sheetController-CBUVOroo.js +0 -205
- package/dist/sheetController-DY-sC13T.cjs +0 -1
- package/dist/types-CPga11Of.js +0 -2068
- package/dist/types-D3YQl1jx.cjs +0 -9
package/dist/widget.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ declare class AgoClient {
|
|
|
53
53
|
private contextRegistry;
|
|
54
54
|
private eventEmitter;
|
|
55
55
|
private activityLedger;
|
|
56
|
+
private errorWatcher;
|
|
56
57
|
private lastSentPageState;
|
|
57
58
|
private config;
|
|
58
59
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
@@ -222,6 +223,26 @@ declare class AgoClient {
|
|
|
222
223
|
* `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
|
|
223
224
|
*/
|
|
224
225
|
private static mapPersistedToolCalls;
|
|
226
|
+
/**
|
|
227
|
+
* The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
|
|
228
|
+
* 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.
|
|
231
|
+
*/
|
|
232
|
+
getConfig(): Promise<SdkConfig>;
|
|
233
|
+
/**
|
|
234
|
+
* The dashboard's home screen content. A starter card shows its
|
|
235
|
+
* `description` and sends its `initial_message`; one with neither is
|
|
236
|
+
* unusable and is dropped rather than rendered as an empty card.
|
|
237
|
+
*/
|
|
238
|
+
private static mapHomePage;
|
|
239
|
+
private static mapTicketForm;
|
|
240
|
+
/**
|
|
241
|
+
* Create a support ticket (`POST /api/sdk/v1/tickets`, multipart). This is
|
|
242
|
+
* what the ticket form in the conversation does before it completes the
|
|
243
|
+
* `form` tool call with {@link submitToolCallForm}.
|
|
244
|
+
*/
|
|
245
|
+
createTicket(input: CreateTicketInput): Promise<CreateTicketResult>;
|
|
225
246
|
/**
|
|
226
247
|
* Get messages for a conversation
|
|
227
248
|
*/
|
|
@@ -480,6 +501,15 @@ declare class AgoClient {
|
|
|
480
501
|
/* Excluded from this release type: emitProactiveEvent */
|
|
481
502
|
/* Excluded from this release type: getHttp */
|
|
482
503
|
/* Excluded from this release type: getConfiguredAgent */
|
|
504
|
+
/**
|
|
505
|
+
* How the SDK identifies the visitor: the configured `userEmail`, and
|
|
506
|
+
* whether a `userJwt` is set. The ticket form asks for an email when it has
|
|
507
|
+
* neither.
|
|
508
|
+
*/
|
|
509
|
+
getUserIdentity(): {
|
|
510
|
+
email?: string;
|
|
511
|
+
hasJwt: boolean;
|
|
512
|
+
};
|
|
483
513
|
/**
|
|
484
514
|
* Enable automatic capture of the current browser page (URL + title).
|
|
485
515
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -502,6 +532,26 @@ declare class AgoClient {
|
|
|
502
532
|
private addActivity;
|
|
503
533
|
private recordAgentAction;
|
|
504
534
|
private registerActivityContext;
|
|
535
|
+
/**
|
|
536
|
+
* Start capturing the page's JavaScript errors (uncaught exceptions,
|
|
537
|
+
* unhandled rejections, `console.error` calls, {@link reportError}) and send
|
|
538
|
+
* the recent ones as the `errors:recent` context entry on every message.
|
|
539
|
+
* Same as setting `errorWatcher` in the config. Calling it again replaces
|
|
540
|
+
* the watcher (and its options); the captured errors are not kept.
|
|
541
|
+
*/
|
|
542
|
+
enableErrorWatcher(options?: ErrorWatcherOptions): void;
|
|
543
|
+
/** Stop capturing errors and drop the `errors:recent` context entry. */
|
|
544
|
+
disableErrorWatcher(): void;
|
|
545
|
+
/**
|
|
546
|
+
* Record an error the app caught itself (React error boundary, Vue
|
|
547
|
+
* `errorHandler`, Angular `ErrorHandler`, a try/catch) so the agent sees it
|
|
548
|
+
* like an uncaught one. No-op unless the error watcher is enabled. `context`
|
|
549
|
+
* is size-clamped before it is stored; keep it small and free of secrets.
|
|
550
|
+
*/
|
|
551
|
+
reportError(error: unknown, context?: Record<string, unknown>): void;
|
|
552
|
+
/** Errors the watcher currently holds, oldest first (a copy). Empty when disabled. */
|
|
553
|
+
getRecentErrors(): CapturedError[];
|
|
554
|
+
clearErrors(): void;
|
|
505
555
|
/**
|
|
506
556
|
* Subscribe to an event
|
|
507
557
|
*/
|
|
@@ -696,6 +746,12 @@ declare interface AgoClientEvents {
|
|
|
696
746
|
};
|
|
697
747
|
/** A user- or agent-action was recorded into the activity ledger. */
|
|
698
748
|
"activity:recorded": ActivityEntry;
|
|
749
|
+
/**
|
|
750
|
+
* The error watcher captured a JavaScript error (uncaught exception,
|
|
751
|
+
* unhandled rejection, `console.error` call, or `reportError`). Fires on
|
|
752
|
+
* repeats too, with the updated `count`. Requires `errorWatcher` in the config.
|
|
753
|
+
*/
|
|
754
|
+
"error:captured": CapturedError;
|
|
699
755
|
}
|
|
700
756
|
|
|
701
757
|
/**
|
|
@@ -716,6 +772,8 @@ declare interface AgoConfig {
|
|
|
716
772
|
userEmail?: string;
|
|
717
773
|
/** JWT token for authenticated users */
|
|
718
774
|
userJwt?: string;
|
|
775
|
+
/** User metadata sent with messages. Use null to stop sending defaults. Not an authentication credential. */
|
|
776
|
+
metadata?: Record<string, unknown> | null;
|
|
719
777
|
/** Enable debug logging */
|
|
720
778
|
debug?: boolean;
|
|
721
779
|
/**
|
|
@@ -775,6 +833,18 @@ declare interface AgoConfig {
|
|
|
775
833
|
* default otherwise.
|
|
776
834
|
*/
|
|
777
835
|
proactive?: ProactiveOptions;
|
|
836
|
+
/**
|
|
837
|
+
* Capture the page's JavaScript errors as agent context. When set, the SDK
|
|
838
|
+
* listens for uncaught exceptions and unhandled promise rejections, wraps
|
|
839
|
+
* `console.error` (calling through; restored on `destroy`), and sends the
|
|
840
|
+
* recent errors (deduplicated, capped, pruned after 10 min) as the
|
|
841
|
+
* `errors:recent` context entry on every message. `true` uses the defaults;
|
|
842
|
+
* pass {@link ErrorWatcherOptions} to tune the caps or add a `filter` that
|
|
843
|
+
* redacts messages. Off by default: error messages can carry PII or internal
|
|
844
|
+
* URLs, so enabling it is the host's call. Errors also feed the proactive
|
|
845
|
+
* mode's `jsErrors` signal. See `client.reportError()` for caught errors.
|
|
846
|
+
*/
|
|
847
|
+
errorWatcher?: boolean | ErrorWatcherOptions;
|
|
778
848
|
}
|
|
779
849
|
|
|
780
850
|
declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
|
|
@@ -988,6 +1058,32 @@ export declare interface AgoWidgetConfig {
|
|
|
988
1058
|
metadata?: Record<string, unknown>;
|
|
989
1059
|
}
|
|
990
1060
|
|
|
1061
|
+
/** One JavaScript error captured on the page (deduplicated, see `count`). */
|
|
1062
|
+
declare interface CapturedError {
|
|
1063
|
+
type: CapturedErrorType;
|
|
1064
|
+
/** Error message, truncated to 500 chars. */
|
|
1065
|
+
message: string;
|
|
1066
|
+
/** Script URL the error came from, without its query string. */
|
|
1067
|
+
source?: string;
|
|
1068
|
+
line?: number;
|
|
1069
|
+
col?: number;
|
|
1070
|
+
/** Leading stack frames, truncated (see `maxStackChars`). */
|
|
1071
|
+
stack?: string;
|
|
1072
|
+
/** Pathname at capture time. */
|
|
1073
|
+
route: string;
|
|
1074
|
+
/** Epoch ms of the first occurrence. */
|
|
1075
|
+
firstAt: number;
|
|
1076
|
+
/** Epoch ms of the most recent occurrence. */
|
|
1077
|
+
lastAt: number;
|
|
1078
|
+
/** How many times this same error (type + message + source + line) fired. */
|
|
1079
|
+
count: number;
|
|
1080
|
+
/** App-provided context, manual reports only (size-clamped). */
|
|
1081
|
+
context?: Record<string, unknown>;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/** How an error reached the watcher. */
|
|
1085
|
+
declare type CapturedErrorType = "error" | "unhandledrejection" | "console" | "manual";
|
|
1086
|
+
|
|
991
1087
|
/** Handle returned by `mountChatWidget`. */
|
|
992
1088
|
export declare interface ChatWidgetHandle {
|
|
993
1089
|
/** The AGO client backing the widget. */
|
|
@@ -1020,6 +1116,18 @@ export declare interface ChatWidgetHandle {
|
|
|
1020
1116
|
readonly threads: Conversation[];
|
|
1021
1117
|
/** Re-fetch the conversations list and update {@link ChatWidgetHandle.threads}. */
|
|
1022
1118
|
refreshThreads: () => Promise<Conversation[]>;
|
|
1119
|
+
/** `placement: "bubble"` only. The screen currently shown. */
|
|
1120
|
+
readonly screen?: WidgetScreen;
|
|
1121
|
+
/** `placement: "bubble"` only. Switch to the home, chat, or history screen. */
|
|
1122
|
+
showScreen?: (screen: WidgetScreen) => void;
|
|
1123
|
+
/** `placement: "bubble"` only. Open a conversation by id on the chat screen. */
|
|
1124
|
+
openConversation?: (conversationId: string) => Promise<void>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Forget the current thread and start over, like the header's new-chat
|
|
1127
|
+
* button and the "New conversation" button shown once a ticket exists. The
|
|
1128
|
+
* bubble widget also returns to its home screen.
|
|
1129
|
+
*/
|
|
1130
|
+
newConversation: () => void;
|
|
1023
1131
|
/** Remove listeners, uninstall forms, and clear the DOM. */
|
|
1024
1132
|
destroy: () => void;
|
|
1025
1133
|
}
|
|
@@ -1114,6 +1222,14 @@ declare interface ClientFunctionSchema {
|
|
|
1114
1222
|
/** See {@link AgoConfig.clientFunctionsMode}. */
|
|
1115
1223
|
declare type ClientFunctionsMode = "placeholder" | "pause";
|
|
1116
1224
|
|
|
1225
|
+
/**
|
|
1226
|
+
* Translate the embed snippet's `colors` object into {@link WidgetTheme} keys,
|
|
1227
|
+
* so `mountChatWidget({ colors })` skins the bubble widget exactly like
|
|
1228
|
+
* `window.AGO.colors` skins the hosted one. The header text color is derived
|
|
1229
|
+
* for contrast unless the theme sets it.
|
|
1230
|
+
*/
|
|
1231
|
+
export declare function colorsToTheme(colors: AgoWidgetColors | undefined): WidgetTheme;
|
|
1232
|
+
|
|
1117
1233
|
/**
|
|
1118
1234
|
* Build the media query for the compact layout.
|
|
1119
1235
|
*
|
|
@@ -1220,6 +1336,19 @@ export declare interface ConversationSessionOptions {
|
|
|
1220
1336
|
ttlMs?: number;
|
|
1221
1337
|
}
|
|
1222
1338
|
|
|
1339
|
+
/** A card on the bubble widget's home screen that starts a conversation. */
|
|
1340
|
+
export declare interface ConversationStarter {
|
|
1341
|
+
/** Text shown on the card. */
|
|
1342
|
+
label: string;
|
|
1343
|
+
/** Message sent when clicked. Defaults to `label`. */
|
|
1344
|
+
message?: string;
|
|
1345
|
+
/**
|
|
1346
|
+
* Answer this starter with a specific agent (id or slug) instead of the
|
|
1347
|
+
* client's default. Dashboard starters (`loadHomeConfig`) carry their own.
|
|
1348
|
+
*/
|
|
1349
|
+
agentId?: string;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1223
1352
|
export declare interface CreateFormCollectorOptions<V = Record<string, unknown>> {
|
|
1224
1353
|
/** Short identifier; becomes the `update_<name>` / `submit_<name>` function names. */
|
|
1225
1354
|
name: string;
|
|
@@ -1245,8 +1374,36 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
|
|
|
1245
1374
|
|
|
1246
1375
|
export declare function createSheetController(options?: SheetOptions): SheetController;
|
|
1247
1376
|
|
|
1377
|
+
/** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
|
|
1378
|
+
declare interface CreateTicketInput {
|
|
1379
|
+
subject: string;
|
|
1380
|
+
body: string;
|
|
1381
|
+
priority?: string;
|
|
1382
|
+
typology?: string;
|
|
1383
|
+
/** Conversation the ticket is filed from. */
|
|
1384
|
+
conversationId?: string;
|
|
1385
|
+
/** Reporter email, for a visitor the SDK does not otherwise identify. */
|
|
1386
|
+
email?: string;
|
|
1387
|
+
customFields?: Array<{
|
|
1388
|
+
id: string;
|
|
1389
|
+
value: string;
|
|
1390
|
+
}>;
|
|
1391
|
+
files?: File[];
|
|
1392
|
+
ticketFormId?: string;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
/** Response of `AgoClient.createTicket`. */
|
|
1396
|
+
declare interface CreateTicketResult {
|
|
1397
|
+
id: string;
|
|
1398
|
+
url?: string;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1248
1401
|
export declare const DEFAULT_FEEDBACK_LABELS: FeedbackLabels;
|
|
1249
1402
|
|
|
1403
|
+
export declare const DEFAULT_TOOL_CALL_FORM_LABELS: ToolCallFormLabels;
|
|
1404
|
+
|
|
1405
|
+
export declare const DEFAULT_WIDGET_LABELS: WidgetLabels;
|
|
1406
|
+
|
|
1250
1407
|
/**
|
|
1251
1408
|
* A function that returns a fresh context entry on demand.
|
|
1252
1409
|
* Evaluated every time a message is sent — use it to pull data from stores,
|
|
@@ -1261,6 +1418,23 @@ export declare interface ElementProps {
|
|
|
1261
1418
|
attrs: Record<string, string | null>;
|
|
1262
1419
|
}
|
|
1263
1420
|
|
|
1421
|
+
declare interface ErrorWatcherOptions {
|
|
1422
|
+
/** Max distinct errors kept. Oldest dropped first. Default 10. */
|
|
1423
|
+
maxErrors?: number;
|
|
1424
|
+
/**
|
|
1425
|
+
* Errors older than this are pruned when the buffer is read, so a crash from
|
|
1426
|
+
* an hour ago does not confuse the agent. Default 600 000 (10 min).
|
|
1427
|
+
*/
|
|
1428
|
+
maxAgeMs?: number;
|
|
1429
|
+
/** Max chars of stack kept per error. Default 2000. */
|
|
1430
|
+
maxStackChars?: number;
|
|
1431
|
+
/**
|
|
1432
|
+
* Redact or drop an error before it is stored. Return the (possibly edited)
|
|
1433
|
+
* error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
|
|
1434
|
+
*/
|
|
1435
|
+
filter?: (error: CapturedError) => CapturedError | null;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1264
1438
|
/**
|
|
1265
1439
|
* Why the user is reporting a message (see `AgoClient.submitFeedback`).
|
|
1266
1440
|
*
|
|
@@ -1550,14 +1724,73 @@ export declare interface MountChatWidgetOptions {
|
|
|
1550
1724
|
* closed; the target is only used as the DOM parent (pass `document.body` for
|
|
1551
1725
|
* a true page overlay). In side mode `height` is ignored and the width comes
|
|
1552
1726
|
* from {@link MountChatWidgetOptions.width}.
|
|
1727
|
+
*
|
|
1728
|
+
* `"bubble"` reproduces the hosted embed widget without an iframe: a floating
|
|
1729
|
+
* launcher bottom-right, a teaser bubble, and a 550px panel with a home
|
|
1730
|
+
* screen, a conversation screen, and a chat history screen. See the
|
|
1731
|
+
* "Floating bubble" section of `docs/general/widget.md`.
|
|
1553
1732
|
*/
|
|
1554
|
-
placement?: "inline" | "left" | "right";
|
|
1733
|
+
placement?: "inline" | "left" | "right" | "bubble";
|
|
1555
1734
|
/**
|
|
1556
1735
|
* Width of the side panel for `placement: "left" | "right"` (number → px).
|
|
1557
1736
|
* Capped at the viewport width so it never overflows on mobile. Ignored when
|
|
1558
|
-
* `placement` is `"inline"`. Defaults to `400
|
|
1737
|
+
* `placement` is `"inline"`. Defaults to `400`; to `550` for `"bubble"`, where
|
|
1738
|
+
* it is clamped between 400px and the viewport width minus 40px.
|
|
1559
1739
|
*/
|
|
1560
1740
|
width?: string | number;
|
|
1741
|
+
/**
|
|
1742
|
+
* `placement: "bubble"` only. The teaser speech bubble shown above the
|
|
1743
|
+
* launcher one second after mount, inviting the visitor in. Pass `false` to
|
|
1744
|
+
* skip it. Defaults to `"Hello, how can I help you today?"`.
|
|
1745
|
+
*/
|
|
1746
|
+
prompt?: string | false;
|
|
1747
|
+
/**
|
|
1748
|
+
* `placement: "bubble"` only. URL of an image (32×32) shown on the launcher
|
|
1749
|
+
* instead of the default chat glyph.
|
|
1750
|
+
*/
|
|
1751
|
+
icon?: string;
|
|
1752
|
+
/**
|
|
1753
|
+
* `placement: "bubble"` only. The same `colors` object as the embed snippet's
|
|
1754
|
+
* `window.AGO.colors`, mapped onto {@link WidgetTheme} keys. `theme` wins over
|
|
1755
|
+
* it key by key. The header text color is derived for contrast automatically.
|
|
1756
|
+
*/
|
|
1757
|
+
colors?: AgoWidgetColors;
|
|
1758
|
+
/** `placement: "bubble"` only. Hide the Home / Chats bottom bar. Defaults to `false`. */
|
|
1759
|
+
hideFooter?: boolean;
|
|
1760
|
+
/**
|
|
1761
|
+
* `placement: "bubble"` only. Markdown shown under the title on the home
|
|
1762
|
+
* screen.
|
|
1763
|
+
*/
|
|
1764
|
+
subtitle?: string;
|
|
1765
|
+
/**
|
|
1766
|
+
* `placement: "bubble"` only. Cards on the home screen that each start a
|
|
1767
|
+
* conversation with a preset message.
|
|
1768
|
+
*/
|
|
1769
|
+
conversationStarters?: ConversationStarter[];
|
|
1770
|
+
/**
|
|
1771
|
+
* `placement: "bubble"` only. Take the home screen's title, subtitle and
|
|
1772
|
+
* starter cards from the AGO dashboard (`GET /config`) instead of the
|
|
1773
|
+
* options above, the way the hosted widget does. One request on mount; the
|
|
1774
|
+
* home screen renders immediately with whatever was passed in code and
|
|
1775
|
+
* re-renders when the config lands.
|
|
1776
|
+
*
|
|
1777
|
+
* Each part is replaced only when the dashboard has a value for it, so
|
|
1778
|
+
* anything the dashboard leaves empty keeps what the code set. Off by
|
|
1779
|
+
* default: without it the widget makes no config request on mount.
|
|
1780
|
+
*
|
|
1781
|
+
* The dashboard's *widget starter* (a first message the agent sends by
|
|
1782
|
+
* itself) is honored too, on a fresh visit only.
|
|
1783
|
+
*/
|
|
1784
|
+
loadHomeConfig?: boolean;
|
|
1785
|
+
/**
|
|
1786
|
+
* `placement: "bubble"` only. On open, reopen the visitor's most recent
|
|
1787
|
+
* conversation if its last message is under two hours old. Defaults to `true`.
|
|
1788
|
+
*/
|
|
1789
|
+
autoResume?: boolean;
|
|
1790
|
+
/** `placement: "bubble"` only. Translate the chrome's strings. */
|
|
1791
|
+
labels?: Partial<Omit<WidgetLabels, "timeAgo">> & {
|
|
1792
|
+
timeAgo?: Partial<WidgetLabels["timeAgo"]>;
|
|
1793
|
+
};
|
|
1561
1794
|
/**
|
|
1562
1795
|
* For side placements, render the built-in floating launcher button that opens
|
|
1563
1796
|
* the panel (plus a close "×" in the header). Set `false` to drive open/close
|
|
@@ -1668,6 +1901,11 @@ export declare interface MountChatWidgetOptions {
|
|
|
1668
1901
|
* the visitor ignores the panel; the panel then files the detailed report.
|
|
1669
1902
|
*/
|
|
1670
1903
|
feedback?: boolean | WidgetFeedbackOptions;
|
|
1904
|
+
/**
|
|
1905
|
+
* The ticket form the agent can open in the conversation (labels, success
|
|
1906
|
+
* text, callbacks). See {@link WidgetToolCallFormOptions}.
|
|
1907
|
+
*/
|
|
1908
|
+
toolCallForm?: WidgetToolCallFormOptions;
|
|
1671
1909
|
/**
|
|
1672
1910
|
* How clicking a suggested follow-up reply behaves. Defaults to sending the
|
|
1673
1911
|
* reply as a new user message. Pass a handler to override, or `false` to
|
|
@@ -1892,12 +2130,29 @@ declare interface ProactiveTriggerWhen {
|
|
|
1892
2130
|
pageState?: Partial<Record<string, unknown>>;
|
|
1893
2131
|
/** Min rage-click bursts on the current route. */
|
|
1894
2132
|
rageClicks?: number;
|
|
2133
|
+
/**
|
|
2134
|
+
* Min JavaScript errors captured on the current route. Needs the client's
|
|
2135
|
+
* `errorWatcher` enabled; without it the count stays at 0 and the matcher
|
|
2136
|
+
* never passes.
|
|
2137
|
+
*/
|
|
2138
|
+
jsErrors?: number;
|
|
1895
2139
|
/** Min A→B→A→B route oscillations this session. */
|
|
1896
2140
|
routeBounces?: number;
|
|
1897
2141
|
/** Per-field minimum error counts (field NAME → min count). */
|
|
1898
2142
|
fieldErrors?: Record<string, number>;
|
|
1899
2143
|
}
|
|
1900
2144
|
|
|
2145
|
+
/**
|
|
2146
|
+
* Pick a legible foreground for a tenant-chosen background, which may be a
|
|
2147
|
+
* solid color or a gradient. A gradient is judged by its least-contrasting
|
|
2148
|
+
* stop, since the text has to survive the whole sweep.
|
|
2149
|
+
*
|
|
2150
|
+
* Deliberately biased toward white: it flips to black only below 3:1, where
|
|
2151
|
+
* white stops being readable at all. Unparseable input (a `var()`, a named
|
|
2152
|
+
* color) keeps white, which is what the default dark header wants.
|
|
2153
|
+
*/
|
|
2154
|
+
export declare function readableTextColor(background: string | undefined): string;
|
|
2155
|
+
|
|
1901
2156
|
/**
|
|
1902
2157
|
* Tiny, dependency-free markdown → DOM renderer for the vanilla chat widget.
|
|
1903
2158
|
*
|
|
@@ -1937,10 +2192,69 @@ declare type ResumeGate = (info: {
|
|
|
1937
2192
|
messageId: string;
|
|
1938
2193
|
}) => Promise<void> | void;
|
|
1939
2194
|
|
|
2195
|
+
/** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
|
|
2196
|
+
declare interface SdkConfig {
|
|
2197
|
+
permissions: SdkPermissionConfig[];
|
|
2198
|
+
proactive: {
|
|
2199
|
+
enabled: boolean;
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
/** The dashboard's home screen content (title, subtitle, starter cards). */
|
|
2204
|
+
declare interface SdkHomePageConfig {
|
|
2205
|
+
title?: string;
|
|
2206
|
+
/** Markdown. */
|
|
2207
|
+
subtitle?: string;
|
|
2208
|
+
starters: SdkHomeStarter[];
|
|
2209
|
+
widgetStarter?: SdkWidgetStarter;
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
/**
|
|
2213
|
+
* A conversation starter card configured in the AGO dashboard. `label` is what
|
|
2214
|
+
* the card shows; clicking it sends `message`.
|
|
2215
|
+
*/
|
|
2216
|
+
declare interface SdkHomeStarter {
|
|
2217
|
+
id: string;
|
|
2218
|
+
/** The card's text (the starter's `description` in the dashboard). */
|
|
2219
|
+
label: string;
|
|
2220
|
+
/** What is sent when the card is clicked. */
|
|
2221
|
+
message: string;
|
|
2222
|
+
/** Answer with this agent instead of the configured default. */
|
|
2223
|
+
agentId?: string;
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
/** One permission's configuration in {@link SdkConfig}. */
|
|
2227
|
+
declare interface SdkPermissionConfig {
|
|
2228
|
+
id?: string;
|
|
2229
|
+
name?: string;
|
|
2230
|
+
displayName?: string;
|
|
2231
|
+
agents: Array<{
|
|
2232
|
+
id: string;
|
|
2233
|
+
name?: string;
|
|
2234
|
+
}>;
|
|
2235
|
+
ticketForm?: TicketForm;
|
|
2236
|
+
/** Home screen content, when the tenant configured one. */
|
|
2237
|
+
homePage?: SdkHomePageConfig;
|
|
2238
|
+
fileAttachmentsEnabled: boolean;
|
|
2239
|
+
voiceEnabled: boolean;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
2242
|
+
/**
|
|
2243
|
+
* The starter the dashboard sends by itself on a fresh visit, before the
|
|
2244
|
+
* visitor types anything.
|
|
2245
|
+
*/
|
|
2246
|
+
declare interface SdkWidgetStarter {
|
|
2247
|
+
id: string;
|
|
2248
|
+
message: string;
|
|
2249
|
+
agentId?: string;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
1940
2252
|
/**
|
|
1941
2253
|
* Options for sending a message
|
|
1942
2254
|
*/
|
|
1943
2255
|
declare interface SendMessageOptions {
|
|
2256
|
+
/** Replaces config.metadata for this message; null omits metadata for this message. */
|
|
2257
|
+
metadata?: Record<string, unknown> | null;
|
|
1944
2258
|
/** Existing conversation ID */
|
|
1945
2259
|
conversationId?: string;
|
|
1946
2260
|
/** Override default agent */
|
|
@@ -2071,6 +2385,12 @@ declare interface SignalsSnapshot {
|
|
|
2071
2385
|
idleMs: number;
|
|
2072
2386
|
/** Rage-click bursts detected on the current route. */
|
|
2073
2387
|
rageClicks: number;
|
|
2388
|
+
/**
|
|
2389
|
+
* JavaScript errors captured on the current route (count only; the messages
|
|
2390
|
+
* travel in `client_context` under `errors:recent`). Always `0` unless the
|
|
2391
|
+
* client has `errorWatcher` enabled.
|
|
2392
|
+
*/
|
|
2393
|
+
jsErrors: number;
|
|
2074
2394
|
/**
|
|
2075
2395
|
* A→B→A→B route oscillations detected in the recent route sequence. Rolling
|
|
2076
2396
|
* session counter (cross-route by nature); trigger cooldowns and dismissal
|
|
@@ -2129,6 +2449,13 @@ declare interface SSEChunkData {
|
|
|
2129
2449
|
follow_up_replies?: string[];
|
|
2130
2450
|
satisfaction_feedback?: unknown;
|
|
2131
2451
|
ask_to_talk_to_human?: boolean;
|
|
2452
|
+
allowed_to_create_ticket?: boolean;
|
|
2453
|
+
ticket?: ToolCallTicketPrefill;
|
|
2454
|
+
mode?: "form" | "embed";
|
|
2455
|
+
ticket_form_id?: string;
|
|
2456
|
+
embed_html?: string;
|
|
2457
|
+
embed_description?: string;
|
|
2458
|
+
display_mode?: "collapsible" | "display" | "both";
|
|
2132
2459
|
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
2133
2460
|
waiting_tool_call_ids?: string[];
|
|
2134
2461
|
}
|
|
@@ -2182,12 +2509,82 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
2182
2509
|
declare interface SubmitToolCallResult {
|
|
2183
2510
|
status: string;
|
|
2184
2511
|
result?: unknown;
|
|
2512
|
+
/** Set when `status` is `"error"`. */
|
|
2513
|
+
error?: string;
|
|
2514
|
+
/** The ticket a ticketing `form` tool call resolved to, when it did. */
|
|
2515
|
+
ticket?: {
|
|
2516
|
+
ticket_id: string;
|
|
2517
|
+
ticket_url?: string;
|
|
2518
|
+
[key: string]: unknown;
|
|
2519
|
+
};
|
|
2185
2520
|
resume?: {
|
|
2186
2521
|
message_id: string;
|
|
2187
2522
|
ready: boolean;
|
|
2188
2523
|
};
|
|
2189
2524
|
}
|
|
2190
2525
|
|
|
2526
|
+
/** A custom field of a ticket form. */
|
|
2527
|
+
declare interface TicketField {
|
|
2528
|
+
id: string;
|
|
2529
|
+
/** The key the ticketing backend expects; used as the submit key when set. */
|
|
2530
|
+
externalId?: string;
|
|
2531
|
+
title?: string;
|
|
2532
|
+
/** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
|
|
2533
|
+
type?: string;
|
|
2534
|
+
required: boolean;
|
|
2535
|
+
/** Carried in the submission but never shown. */
|
|
2536
|
+
hidden: boolean;
|
|
2537
|
+
active?: boolean;
|
|
2538
|
+
/** Bypass progressive disclosure, while still respecting conditions. */
|
|
2539
|
+
alwaysVisible?: boolean;
|
|
2540
|
+
regexpForValidation?: string;
|
|
2541
|
+
position: number;
|
|
2542
|
+
/** Non-empty turns the field into a select. */
|
|
2543
|
+
options: TicketFieldOption[];
|
|
2544
|
+
/** Show this field only when the parent field holds `conditionalFieldValue`. */
|
|
2545
|
+
conditionalFieldId?: string;
|
|
2546
|
+
/** Legacy comma-separated condition values. */
|
|
2547
|
+
conditionalFieldValue?: string;
|
|
2548
|
+
/** Takes precedence over conditionalFieldValue when non-empty. */
|
|
2549
|
+
conditionalFieldValues?: string[];
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
/** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
|
|
2553
|
+
declare interface TicketFieldOption {
|
|
2554
|
+
id: string;
|
|
2555
|
+
/** Label shown to the user. */
|
|
2556
|
+
name?: string;
|
|
2557
|
+
/** Value submitted. Falls back to `name` when absent. */
|
|
2558
|
+
value?: string;
|
|
2559
|
+
/** Preselected when the form opens. */
|
|
2560
|
+
default: boolean;
|
|
2561
|
+
/** A note shown under the field once this option is picked. */
|
|
2562
|
+
message?: string;
|
|
2563
|
+
messageType: "info" | "warning" | "danger";
|
|
2564
|
+
position?: number;
|
|
2565
|
+
group?: string;
|
|
2566
|
+
noDisplay?: boolean;
|
|
2567
|
+
conditionalFieldId?: string;
|
|
2568
|
+
/** Available when the parent matches any of these values. */
|
|
2569
|
+
conditionalFieldValues?: string[];
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
/** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
|
|
2573
|
+
declare interface TicketForm {
|
|
2574
|
+
id: string;
|
|
2575
|
+
name?: string;
|
|
2576
|
+
/** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
|
|
2577
|
+
mode: "form" | "embed";
|
|
2578
|
+
showSubject: boolean;
|
|
2579
|
+
showBody: boolean;
|
|
2580
|
+
showPriority: boolean;
|
|
2581
|
+
showTypology: boolean;
|
|
2582
|
+
priorityTypologies?: string[];
|
|
2583
|
+
successMessageText?: string;
|
|
2584
|
+
successMessageUrlLabel?: string;
|
|
2585
|
+
fields: TicketField[];
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2191
2588
|
/**
|
|
2192
2589
|
* Tool call data from SSE stream
|
|
2193
2590
|
*/
|
|
@@ -2202,6 +2599,93 @@ declare interface ToolCallData {
|
|
|
2202
2599
|
data?: Record<string, unknown>;
|
|
2203
2600
|
functionName?: string;
|
|
2204
2601
|
arguments?: Record<string, unknown>;
|
|
2602
|
+
/**
|
|
2603
|
+
* Where the hosted widget shows the call: in the collapsible "reasoning"
|
|
2604
|
+
* section, in the message body, or both. Absent means collapsible only.
|
|
2605
|
+
*/
|
|
2606
|
+
displayMode?: "collapsible" | "display" | "both";
|
|
2607
|
+
/** The user asked to talk to a human. */
|
|
2608
|
+
askToTalkToHuman?: boolean;
|
|
2609
|
+
/** `false` when the tenant blocks ticket creation for this visitor. */
|
|
2610
|
+
allowedToCreateTicket?: boolean;
|
|
2611
|
+
/** Fields the agent pre-filled from the conversation. */
|
|
2612
|
+
ticket?: ToolCallTicketPrefill;
|
|
2613
|
+
/** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
|
|
2614
|
+
mode?: "form" | "embed";
|
|
2615
|
+
ticketFormId?: string;
|
|
2616
|
+
embedHtml?: string;
|
|
2617
|
+
embedDescription?: string;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
/**
|
|
2621
|
+
* Every string the ticket form and its surrounding chrome show, with the
|
|
2622
|
+
* hosted widget's English defaults, so a non-English site can translate them
|
|
2623
|
+
* through `toolCallForm.labels`.
|
|
2624
|
+
*/
|
|
2625
|
+
export declare interface ToolCallFormLabels {
|
|
2626
|
+
useFormToCreateTicket: string;
|
|
2627
|
+
yourEmail: string;
|
|
2628
|
+
emailPlaceholder: string;
|
|
2629
|
+
emailRequired: string;
|
|
2630
|
+
emailInvalid: string;
|
|
2631
|
+
subject: string;
|
|
2632
|
+
subjectRequired: string;
|
|
2633
|
+
typology: string;
|
|
2634
|
+
selectTypology: string;
|
|
2635
|
+
typologyRequired: string;
|
|
2636
|
+
question: string;
|
|
2637
|
+
task: string;
|
|
2638
|
+
incident: string;
|
|
2639
|
+
priority: string;
|
|
2640
|
+
selectPriority: string;
|
|
2641
|
+
priorityRequired: string;
|
|
2642
|
+
low: string;
|
|
2643
|
+
normal: string;
|
|
2644
|
+
high: string;
|
|
2645
|
+
urgent: string;
|
|
2646
|
+
detailedContext: string;
|
|
2647
|
+
detailedContextRequired: string;
|
|
2648
|
+
/** `{fieldTitle}` is substituted. */
|
|
2649
|
+
fieldRequired: string;
|
|
2650
|
+
fieldFormatInvalid: string;
|
|
2651
|
+
attachments: string;
|
|
2652
|
+
selectFile: string;
|
|
2653
|
+
submit: string;
|
|
2654
|
+
loading: string;
|
|
2655
|
+
maxCharacters: string;
|
|
2656
|
+
ticketSubmitted: string;
|
|
2657
|
+
findTicketHere: string;
|
|
2658
|
+
noTicketForm: string;
|
|
2659
|
+
notAllowed: string;
|
|
2660
|
+
submissionFailed: string;
|
|
2661
|
+
submissionFailedDescription: string;
|
|
2662
|
+
fileTooLarge: string;
|
|
2663
|
+
permissionDenied: string;
|
|
2664
|
+
validationFailed: string;
|
|
2665
|
+
pleaseCheckFields: string;
|
|
2666
|
+
embeddedFormSubmitted: string;
|
|
2667
|
+
noEmbedConfigured: string;
|
|
2668
|
+
embedSubmitTimeout: string;
|
|
2669
|
+
tryAgain: string;
|
|
2670
|
+
contactFormCreated: string;
|
|
2671
|
+
contactFormRejected: string;
|
|
2672
|
+
genericFormComingSoon: string;
|
|
2673
|
+
unknownToolCall: string;
|
|
2674
|
+
formPending: string;
|
|
2675
|
+
ticketCreatedBlocked: string;
|
|
2676
|
+
newConversation: string;
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
/** The ticket the agent pre-filled on a ticketing `form` tool call. */
|
|
2680
|
+
declare interface ToolCallTicketPrefill {
|
|
2681
|
+
subject?: string;
|
|
2682
|
+
body?: string;
|
|
2683
|
+
typology?: string;
|
|
2684
|
+
priority?: string;
|
|
2685
|
+
tag?: string;
|
|
2686
|
+
products?: string[];
|
|
2687
|
+
/** Keyed by the field's external id, or a lowercased, underscored title. */
|
|
2688
|
+
custom_fields?: Record<string, string>;
|
|
2205
2689
|
}
|
|
2206
2690
|
|
|
2207
2691
|
declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
|
|
@@ -2262,6 +2746,57 @@ export declare interface WidgetFeedbackOptions {
|
|
|
2262
2746
|
onError?: (error: Error) => void;
|
|
2263
2747
|
}
|
|
2264
2748
|
|
|
2749
|
+
/**
|
|
2750
|
+
* Every string the bubble widget's chrome shows (header, footer, home,
|
|
2751
|
+
* history, errors), so a non-English site can translate them. Message-level
|
|
2752
|
+
* strings live in {@link WidgetFeedbackOptions.labels}.
|
|
2753
|
+
*/
|
|
2754
|
+
export declare interface WidgetLabels {
|
|
2755
|
+
/** Footer tab. */
|
|
2756
|
+
home: string;
|
|
2757
|
+
/** Footer tab. */
|
|
2758
|
+
chats: string;
|
|
2759
|
+
/** Header title on the history screen. */
|
|
2760
|
+
history: string;
|
|
2761
|
+
/** The floating pill on the history screen, and a thread without a title. */
|
|
2762
|
+
newConversation: string;
|
|
2763
|
+
/** Empty history screen. */
|
|
2764
|
+
noHistory: string;
|
|
2765
|
+
/** Composer placeholder on the home screen. */
|
|
2766
|
+
askQuestion: string;
|
|
2767
|
+
/** Accessible name of the header back button. */
|
|
2768
|
+
back: string;
|
|
2769
|
+
/** Accessible name of the header close button. */
|
|
2770
|
+
close: string;
|
|
2771
|
+
/** Accessible name of the header new-chat button. */
|
|
2772
|
+
newChat: string;
|
|
2773
|
+
/** Title of the alert shown on a failed answer. */
|
|
2774
|
+
errorTitle: string;
|
|
2775
|
+
/** Body of the alert shown on a failed answer. */
|
|
2776
|
+
errorDescription: string;
|
|
2777
|
+
/** Accessible name of the scroll-to-bottom button. */
|
|
2778
|
+
scrollToBottom: string;
|
|
2779
|
+
/** Label of the button that hides a file error. */
|
|
2780
|
+
dismiss: string;
|
|
2781
|
+
/** Accessible name of the attach button. */
|
|
2782
|
+
attachFiles: string;
|
|
2783
|
+
/** Composer file errors; `{max}` / `{name}` are substituted. */
|
|
2784
|
+
tooManyFiles: string;
|
|
2785
|
+
invalidFileType: string;
|
|
2786
|
+
fileTooLarge: string;
|
|
2787
|
+
/** Relative time templates on the history screen; `{n}` is the count. */
|
|
2788
|
+
timeAgo: {
|
|
2789
|
+
minutes: string;
|
|
2790
|
+
hours: string;
|
|
2791
|
+
days: string;
|
|
2792
|
+
weeks: string;
|
|
2793
|
+
months: string;
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
/** The three screens of the bubble widget (`placement: "bubble"`). */
|
|
2798
|
+
export declare type WidgetScreen = "home" | "chat" | "history";
|
|
2799
|
+
|
|
2265
2800
|
/**
|
|
2266
2801
|
* Theme overrides for `mountChatWidget`. The keys map to `--ago-*` custom
|
|
2267
2802
|
* properties (see `THEME_VARS` in `./styles`).
|
|
@@ -2296,6 +2831,54 @@ export declare interface WidgetTheme {
|
|
|
2296
2831
|
accent?: string;
|
|
2297
2832
|
/** Background of assistant message bubbles when `agentBubble` is on. Defaults to a light gray. (`--ago-agent-bubble-background`) */
|
|
2298
2833
|
agentBubbleBg?: string;
|
|
2834
|
+
/** Text color inside assistant messages. Defaults to `text`. (`--ago-agent-bubble-text-color`) */
|
|
2835
|
+
agentBubbleText?: string;
|
|
2836
|
+
/** User message card background. `placement: "bubble"` only; defaults to white there. (`--ago-user-bubble-background`) */
|
|
2837
|
+
userBubbleBg?: string;
|
|
2838
|
+
/** User message text color. `placement: "bubble"` only. (`--ago-user-bubble-text-color`) */
|
|
2839
|
+
userBubbleText?: string;
|
|
2840
|
+
/** Floating launcher circle. `placement: "bubble"` only; defaults to `#007bff`. (`--ago-launcher-background`) */
|
|
2841
|
+
launcherBg?: string;
|
|
2842
|
+
/** Glyph color on the launcher. (`--ago-launcher-text-color`) */
|
|
2843
|
+
launcherText?: string;
|
|
2844
|
+
/** Composer send/stop button. `placement: "bubble"` only; defaults to `brand`. (`--ago-send-button-background`) */
|
|
2845
|
+
sendBg?: string;
|
|
2846
|
+
/** Panel width for `placement: "bubble"`, e.g. `"700px"`. Defaults to `550px`. (`--ago-panel-width`) */
|
|
2847
|
+
panelWidth?: string;
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
/**
|
|
2851
|
+
* Fine-tuning for the ticket form the agent's `ago_ticketing` tool opens in
|
|
2852
|
+
* the conversation (the `form` tool call). The form is always on: a tool call
|
|
2853
|
+
* the widget ignored would leave the visitor stuck.
|
|
2854
|
+
*/
|
|
2855
|
+
export declare interface WidgetToolCallFormOptions {
|
|
2856
|
+
/** Translate any of the form's strings. */
|
|
2857
|
+
labels?: Partial<ToolCallFormLabels>;
|
|
2858
|
+
/** Replace the success text once the ticket exists. */
|
|
2859
|
+
successMessage?: string;
|
|
2860
|
+
/** Replace the "You can find it here:" label before the ticket link. */
|
|
2861
|
+
successUrlLabel?: string;
|
|
2862
|
+
/**
|
|
2863
|
+
* Email of the visitor when the SDK has no identity for them (no `userEmail`
|
|
2864
|
+
* or `userJwt` in the client config). When absent, the form asks for it.
|
|
2865
|
+
*/
|
|
2866
|
+
userEmail?: string;
|
|
2867
|
+
/** Called once the ticket exists and the tool call is completed. */
|
|
2868
|
+
onSubmitted?: (data: {
|
|
2869
|
+
toolCallId: string;
|
|
2870
|
+
toolName: string;
|
|
2871
|
+
mode: "form" | "embed";
|
|
2872
|
+
ticket?: {
|
|
2873
|
+
id: string;
|
|
2874
|
+
url?: string;
|
|
2875
|
+
};
|
|
2876
|
+
values: Record<string, unknown>;
|
|
2877
|
+
}) => void;
|
|
2878
|
+
/** Called when creating the ticket or completing the tool call failed. */
|
|
2879
|
+
onError?: (error: Error) => void;
|
|
2880
|
+
/** Called when the visitor starts a new conversation from the blocked composer. */
|
|
2881
|
+
onNewConversation?: () => void;
|
|
2299
2882
|
}
|
|
2300
2883
|
|
|
2301
2884
|
export { }
|