@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/angular.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ declare class AgoClient {
|
|
|
70
70
|
private contextRegistry;
|
|
71
71
|
private eventEmitter;
|
|
72
72
|
private activityLedger;
|
|
73
|
+
private errorWatcher;
|
|
73
74
|
private lastSentPageState;
|
|
74
75
|
private config;
|
|
75
76
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
@@ -239,6 +240,26 @@ declare class AgoClient {
|
|
|
239
240
|
* `SSEHandler.parseToolCall` so persisted and streamed tool calls match.
|
|
240
241
|
*/
|
|
241
242
|
private static mapPersistedToolCalls;
|
|
243
|
+
/**
|
|
244
|
+
* The tenant's SDK configuration (`GET /api/sdk/v1/config`): per-permission
|
|
245
|
+
* agents, the ticket form the agent's `ago_ticketing` tool opens, and the
|
|
246
|
+
* file-attachment flag. The vanilla widget fetches it once, when a ticket
|
|
247
|
+
* form first appears in a conversation.
|
|
248
|
+
*/
|
|
249
|
+
getConfig(): Promise<SdkConfig>;
|
|
250
|
+
/**
|
|
251
|
+
* The dashboard's home screen content. A starter card shows its
|
|
252
|
+
* `description` and sends its `initial_message`; one with neither is
|
|
253
|
+
* unusable and is dropped rather than rendered as an empty card.
|
|
254
|
+
*/
|
|
255
|
+
private static mapHomePage;
|
|
256
|
+
private static mapTicketForm;
|
|
257
|
+
/**
|
|
258
|
+
* Create a support ticket (`POST /api/sdk/v1/tickets`, multipart). This is
|
|
259
|
+
* what the ticket form in the conversation does before it completes the
|
|
260
|
+
* `form` tool call with {@link submitToolCallForm}.
|
|
261
|
+
*/
|
|
262
|
+
createTicket(input: CreateTicketInput): Promise<CreateTicketResult>;
|
|
242
263
|
/**
|
|
243
264
|
* Get messages for a conversation
|
|
244
265
|
*/
|
|
@@ -497,6 +518,15 @@ declare class AgoClient {
|
|
|
497
518
|
/* Excluded from this release type: emitProactiveEvent */
|
|
498
519
|
/* Excluded from this release type: getHttp */
|
|
499
520
|
/* Excluded from this release type: getConfiguredAgent */
|
|
521
|
+
/**
|
|
522
|
+
* How the SDK identifies the visitor: the configured `userEmail`, and
|
|
523
|
+
* whether a `userJwt` is set. The ticket form asks for an email when it has
|
|
524
|
+
* neither.
|
|
525
|
+
*/
|
|
526
|
+
getUserIdentity(): {
|
|
527
|
+
email?: string;
|
|
528
|
+
hasJwt: boolean;
|
|
529
|
+
};
|
|
500
530
|
/**
|
|
501
531
|
* Enable automatic capture of the current browser page (URL + title).
|
|
502
532
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -519,6 +549,26 @@ declare class AgoClient {
|
|
|
519
549
|
private addActivity;
|
|
520
550
|
private recordAgentAction;
|
|
521
551
|
private registerActivityContext;
|
|
552
|
+
/**
|
|
553
|
+
* Start capturing the page's JavaScript errors (uncaught exceptions,
|
|
554
|
+
* unhandled rejections, `console.error` calls, {@link reportError}) and send
|
|
555
|
+
* the recent ones as the `errors:recent` context entry on every message.
|
|
556
|
+
* Same as setting `errorWatcher` in the config. Calling it again replaces
|
|
557
|
+
* the watcher (and its options); the captured errors are not kept.
|
|
558
|
+
*/
|
|
559
|
+
enableErrorWatcher(options?: ErrorWatcherOptions): void;
|
|
560
|
+
/** Stop capturing errors and drop the `errors:recent` context entry. */
|
|
561
|
+
disableErrorWatcher(): void;
|
|
562
|
+
/**
|
|
563
|
+
* Record an error the app caught itself (React error boundary, Vue
|
|
564
|
+
* `errorHandler`, Angular `ErrorHandler`, a try/catch) so the agent sees it
|
|
565
|
+
* like an uncaught one. No-op unless the error watcher is enabled. `context`
|
|
566
|
+
* is size-clamped before it is stored; keep it small and free of secrets.
|
|
567
|
+
*/
|
|
568
|
+
reportError(error: unknown, context?: Record<string, unknown>): void;
|
|
569
|
+
/** Errors the watcher currently holds, oldest first (a copy). Empty when disabled. */
|
|
570
|
+
getRecentErrors(): CapturedError[];
|
|
571
|
+
clearErrors(): void;
|
|
522
572
|
/**
|
|
523
573
|
* Subscribe to an event
|
|
524
574
|
*/
|
|
@@ -713,6 +763,12 @@ export declare interface AgoClientEvents {
|
|
|
713
763
|
};
|
|
714
764
|
/** A user- or agent-action was recorded into the activity ledger. */
|
|
715
765
|
"activity:recorded": ActivityEntry;
|
|
766
|
+
/**
|
|
767
|
+
* The error watcher captured a JavaScript error (uncaught exception,
|
|
768
|
+
* unhandled rejection, `console.error` call, or `reportError`). Fires on
|
|
769
|
+
* repeats too, with the updated `count`. Requires `errorWatcher` in the config.
|
|
770
|
+
*/
|
|
771
|
+
"error:captured": CapturedError;
|
|
716
772
|
}
|
|
717
773
|
|
|
718
774
|
/**
|
|
@@ -733,6 +789,8 @@ export declare interface AgoConfig {
|
|
|
733
789
|
userEmail?: string;
|
|
734
790
|
/** JWT token for authenticated users */
|
|
735
791
|
userJwt?: string;
|
|
792
|
+
/** User metadata sent with messages. Use null to stop sending defaults. Not an authentication credential. */
|
|
793
|
+
metadata?: Record<string, unknown> | null;
|
|
736
794
|
/** Enable debug logging */
|
|
737
795
|
debug?: boolean;
|
|
738
796
|
/**
|
|
@@ -792,6 +850,18 @@ export declare interface AgoConfig {
|
|
|
792
850
|
* default otherwise.
|
|
793
851
|
*/
|
|
794
852
|
proactive?: ProactiveOptions;
|
|
853
|
+
/**
|
|
854
|
+
* Capture the page's JavaScript errors as agent context. When set, the SDK
|
|
855
|
+
* listens for uncaught exceptions and unhandled promise rejections, wraps
|
|
856
|
+
* `console.error` (calling through; restored on `destroy`), and sends the
|
|
857
|
+
* recent errors (deduplicated, capped, pruned after 10 min) as the
|
|
858
|
+
* `errors:recent` context entry on every message. `true` uses the defaults;
|
|
859
|
+
* pass {@link ErrorWatcherOptions} to tune the caps or add a `filter` that
|
|
860
|
+
* redacts messages. Off by default: error messages can carry PII or internal
|
|
861
|
+
* URLs, so enabling it is the host's call. Errors also feed the proactive
|
|
862
|
+
* mode's `jsErrors` signal. See `client.reportError()` for caught errors.
|
|
863
|
+
*/
|
|
864
|
+
errorWatcher?: boolean | ErrorWatcherOptions;
|
|
795
865
|
}
|
|
796
866
|
|
|
797
867
|
declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
|
|
@@ -1110,6 +1180,32 @@ declare type AgoStateSetResult = {
|
|
|
1110
1180
|
result: "unchanged";
|
|
1111
1181
|
};
|
|
1112
1182
|
|
|
1183
|
+
/** One JavaScript error captured on the page (deduplicated, see `count`). */
|
|
1184
|
+
declare interface CapturedError {
|
|
1185
|
+
type: CapturedErrorType;
|
|
1186
|
+
/** Error message, truncated to 500 chars. */
|
|
1187
|
+
message: string;
|
|
1188
|
+
/** Script URL the error came from, without its query string. */
|
|
1189
|
+
source?: string;
|
|
1190
|
+
line?: number;
|
|
1191
|
+
col?: number;
|
|
1192
|
+
/** Leading stack frames, truncated (see `maxStackChars`). */
|
|
1193
|
+
stack?: string;
|
|
1194
|
+
/** Pathname at capture time. */
|
|
1195
|
+
route: string;
|
|
1196
|
+
/** Epoch ms of the first occurrence. */
|
|
1197
|
+
firstAt: number;
|
|
1198
|
+
/** Epoch ms of the most recent occurrence. */
|
|
1199
|
+
lastAt: number;
|
|
1200
|
+
/** How many times this same error (type + message + source + line) fired. */
|
|
1201
|
+
count: number;
|
|
1202
|
+
/** App-provided context, manual reports only (size-clamped). */
|
|
1203
|
+
context?: Record<string, unknown>;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
/** How an error reached the watcher. */
|
|
1207
|
+
declare type CapturedErrorType = "error" | "unhandledrejection" | "console" | "manual";
|
|
1208
|
+
|
|
1113
1209
|
/**
|
|
1114
1210
|
* Single-object function definition — combines name, schema, and handler.
|
|
1115
1211
|
*
|
|
@@ -1243,6 +1339,30 @@ export declare interface Conversation {
|
|
|
1243
1339
|
messages?: AgoMessage[];
|
|
1244
1340
|
}
|
|
1245
1341
|
|
|
1342
|
+
/** Input of `AgoClient.createTicket` (`POST /api/sdk/v1/tickets`). */
|
|
1343
|
+
declare interface CreateTicketInput {
|
|
1344
|
+
subject: string;
|
|
1345
|
+
body: string;
|
|
1346
|
+
priority?: string;
|
|
1347
|
+
typology?: string;
|
|
1348
|
+
/** Conversation the ticket is filed from. */
|
|
1349
|
+
conversationId?: string;
|
|
1350
|
+
/** Reporter email, for a visitor the SDK does not otherwise identify. */
|
|
1351
|
+
email?: string;
|
|
1352
|
+
customFields?: Array<{
|
|
1353
|
+
id: string;
|
|
1354
|
+
value: string;
|
|
1355
|
+
}>;
|
|
1356
|
+
files?: File[];
|
|
1357
|
+
ticketFormId?: string;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
/** Response of `AgoClient.createTicket`. */
|
|
1361
|
+
declare interface CreateTicketResult {
|
|
1362
|
+
id: string;
|
|
1363
|
+
url?: string;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1246
1366
|
/**
|
|
1247
1367
|
* A function that returns a fresh context entry on demand.
|
|
1248
1368
|
* Evaluated every time a message is sent — use it to pull data from stores,
|
|
@@ -1250,6 +1370,23 @@ export declare interface Conversation {
|
|
|
1250
1370
|
*/
|
|
1251
1371
|
declare type DynamicContextProvider = () => ContextEntry | null | undefined;
|
|
1252
1372
|
|
|
1373
|
+
declare interface ErrorWatcherOptions {
|
|
1374
|
+
/** Max distinct errors kept. Oldest dropped first. Default 10. */
|
|
1375
|
+
maxErrors?: number;
|
|
1376
|
+
/**
|
|
1377
|
+
* Errors older than this are pruned when the buffer is read, so a crash from
|
|
1378
|
+
* an hour ago does not confuse the agent. Default 600 000 (10 min).
|
|
1379
|
+
*/
|
|
1380
|
+
maxAgeMs?: number;
|
|
1381
|
+
/** Max chars of stack kept per error. Default 2000. */
|
|
1382
|
+
maxStackChars?: number;
|
|
1383
|
+
/**
|
|
1384
|
+
* Redact or drop an error before it is stored. Return the (possibly edited)
|
|
1385
|
+
* error to keep it, `null` to drop it. Runs on every capture, so keep it cheap.
|
|
1386
|
+
*/
|
|
1387
|
+
filter?: (error: CapturedError) => CapturedError | null;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1253
1390
|
/** The four values of {@link FeedbackReason}, in dashboard order. */
|
|
1254
1391
|
export declare const FEEDBACK_REASONS: readonly FeedbackReason[];
|
|
1255
1392
|
|
|
@@ -1622,6 +1759,12 @@ declare interface ProactiveTriggerWhen {
|
|
|
1622
1759
|
pageState?: Partial<Record<string, unknown>>;
|
|
1623
1760
|
/** Min rage-click bursts on the current route. */
|
|
1624
1761
|
rageClicks?: number;
|
|
1762
|
+
/**
|
|
1763
|
+
* Min JavaScript errors captured on the current route. Needs the client's
|
|
1764
|
+
* `errorWatcher` enabled; without it the count stays at 0 and the matcher
|
|
1765
|
+
* never passes.
|
|
1766
|
+
*/
|
|
1767
|
+
jsErrors?: number;
|
|
1625
1768
|
/** Min A→B→A→B route oscillations this session. */
|
|
1626
1769
|
routeBounces?: number;
|
|
1627
1770
|
/** Per-field minimum error counts (field NAME → min count). */
|
|
@@ -1663,10 +1806,69 @@ declare type ResumeGate = (info: {
|
|
|
1663
1806
|
messageId: string;
|
|
1664
1807
|
}) => Promise<void> | void;
|
|
1665
1808
|
|
|
1809
|
+
/** Response of `GET /api/sdk/v1/config` (see `AgoClient.getConfig`). */
|
|
1810
|
+
declare interface SdkConfig {
|
|
1811
|
+
permissions: SdkPermissionConfig[];
|
|
1812
|
+
proactive: {
|
|
1813
|
+
enabled: boolean;
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
/** The dashboard's home screen content (title, subtitle, starter cards). */
|
|
1818
|
+
declare interface SdkHomePageConfig {
|
|
1819
|
+
title?: string;
|
|
1820
|
+
/** Markdown. */
|
|
1821
|
+
subtitle?: string;
|
|
1822
|
+
starters: SdkHomeStarter[];
|
|
1823
|
+
widgetStarter?: SdkWidgetStarter;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* A conversation starter card configured in the AGO dashboard. `label` is what
|
|
1828
|
+
* the card shows; clicking it sends `message`.
|
|
1829
|
+
*/
|
|
1830
|
+
declare interface SdkHomeStarter {
|
|
1831
|
+
id: string;
|
|
1832
|
+
/** The card's text (the starter's `description` in the dashboard). */
|
|
1833
|
+
label: string;
|
|
1834
|
+
/** What is sent when the card is clicked. */
|
|
1835
|
+
message: string;
|
|
1836
|
+
/** Answer with this agent instead of the configured default. */
|
|
1837
|
+
agentId?: string;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
/** One permission's configuration in {@link SdkConfig}. */
|
|
1841
|
+
declare interface SdkPermissionConfig {
|
|
1842
|
+
id?: string;
|
|
1843
|
+
name?: string;
|
|
1844
|
+
displayName?: string;
|
|
1845
|
+
agents: Array<{
|
|
1846
|
+
id: string;
|
|
1847
|
+
name?: string;
|
|
1848
|
+
}>;
|
|
1849
|
+
ticketForm?: TicketForm;
|
|
1850
|
+
/** Home screen content, when the tenant configured one. */
|
|
1851
|
+
homePage?: SdkHomePageConfig;
|
|
1852
|
+
fileAttachmentsEnabled: boolean;
|
|
1853
|
+
voiceEnabled: boolean;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
/**
|
|
1857
|
+
* The starter the dashboard sends by itself on a fresh visit, before the
|
|
1858
|
+
* visitor types anything.
|
|
1859
|
+
*/
|
|
1860
|
+
declare interface SdkWidgetStarter {
|
|
1861
|
+
id: string;
|
|
1862
|
+
message: string;
|
|
1863
|
+
agentId?: string;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1666
1866
|
/**
|
|
1667
1867
|
* Options for sending a message
|
|
1668
1868
|
*/
|
|
1669
1869
|
declare interface SendMessageOptions {
|
|
1870
|
+
/** Replaces config.metadata for this message; null omits metadata for this message. */
|
|
1871
|
+
metadata?: Record<string, unknown> | null;
|
|
1670
1872
|
/** Existing conversation ID */
|
|
1671
1873
|
conversationId?: string;
|
|
1672
1874
|
/** Override default agent */
|
|
@@ -1715,6 +1917,12 @@ declare interface SignalsSnapshot {
|
|
|
1715
1917
|
idleMs: number;
|
|
1716
1918
|
/** Rage-click bursts detected on the current route. */
|
|
1717
1919
|
rageClicks: number;
|
|
1920
|
+
/**
|
|
1921
|
+
* JavaScript errors captured on the current route (count only; the messages
|
|
1922
|
+
* travel in `client_context` under `errors:recent`). Always `0` unless the
|
|
1923
|
+
* client has `errorWatcher` enabled.
|
|
1924
|
+
*/
|
|
1925
|
+
jsErrors: number;
|
|
1718
1926
|
/**
|
|
1719
1927
|
* A→B→A→B route oscillations detected in the recent route sequence. Rolling
|
|
1720
1928
|
* session counter (cross-route by nature); trigger cooldowns and dismissal
|
|
@@ -1773,6 +1981,13 @@ declare interface SSEChunkData {
|
|
|
1773
1981
|
follow_up_replies?: string[];
|
|
1774
1982
|
satisfaction_feedback?: unknown;
|
|
1775
1983
|
ask_to_talk_to_human?: boolean;
|
|
1984
|
+
allowed_to_create_ticket?: boolean;
|
|
1985
|
+
ticket?: ToolCallTicketPrefill;
|
|
1986
|
+
mode?: "form" | "embed";
|
|
1987
|
+
ticket_form_id?: string;
|
|
1988
|
+
embed_html?: string;
|
|
1989
|
+
embed_description?: string;
|
|
1990
|
+
display_mode?: "collapsible" | "display" | "both";
|
|
1776
1991
|
/** Tool call ids still awaiting a client result, sent with the final `WAITING_CLIENT` event. */
|
|
1777
1992
|
waiting_tool_call_ids?: string[];
|
|
1778
1993
|
}
|
|
@@ -1826,12 +2041,82 @@ declare type SubmitConfig<V = Record<string, unknown>> = string | {
|
|
|
1826
2041
|
declare interface SubmitToolCallResult {
|
|
1827
2042
|
status: string;
|
|
1828
2043
|
result?: unknown;
|
|
2044
|
+
/** Set when `status` is `"error"`. */
|
|
2045
|
+
error?: string;
|
|
2046
|
+
/** The ticket a ticketing `form` tool call resolved to, when it did. */
|
|
2047
|
+
ticket?: {
|
|
2048
|
+
ticket_id: string;
|
|
2049
|
+
ticket_url?: string;
|
|
2050
|
+
[key: string]: unknown;
|
|
2051
|
+
};
|
|
1829
2052
|
resume?: {
|
|
1830
2053
|
message_id: string;
|
|
1831
2054
|
ready: boolean;
|
|
1832
2055
|
};
|
|
1833
2056
|
}
|
|
1834
2057
|
|
|
2058
|
+
/** A custom field of a ticket form. */
|
|
2059
|
+
declare interface TicketField {
|
|
2060
|
+
id: string;
|
|
2061
|
+
/** The key the ticketing backend expects; used as the submit key when set. */
|
|
2062
|
+
externalId?: string;
|
|
2063
|
+
title?: string;
|
|
2064
|
+
/** Field kind, e.g. `"text"`, `"checkbox"`, `"tagger"`. */
|
|
2065
|
+
type?: string;
|
|
2066
|
+
required: boolean;
|
|
2067
|
+
/** Carried in the submission but never shown. */
|
|
2068
|
+
hidden: boolean;
|
|
2069
|
+
active?: boolean;
|
|
2070
|
+
/** Bypass progressive disclosure, while still respecting conditions. */
|
|
2071
|
+
alwaysVisible?: boolean;
|
|
2072
|
+
regexpForValidation?: string;
|
|
2073
|
+
position: number;
|
|
2074
|
+
/** Non-empty turns the field into a select. */
|
|
2075
|
+
options: TicketFieldOption[];
|
|
2076
|
+
/** Show this field only when the parent field holds `conditionalFieldValue`. */
|
|
2077
|
+
conditionalFieldId?: string;
|
|
2078
|
+
/** Legacy comma-separated condition values. */
|
|
2079
|
+
conditionalFieldValue?: string;
|
|
2080
|
+
/** Takes precedence over conditionalFieldValue when non-empty. */
|
|
2081
|
+
conditionalFieldValues?: string[];
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
/** An option of a ticket form field (`GET /config` → `ticket_form.fields[].options[]`). */
|
|
2085
|
+
declare interface TicketFieldOption {
|
|
2086
|
+
id: string;
|
|
2087
|
+
/** Label shown to the user. */
|
|
2088
|
+
name?: string;
|
|
2089
|
+
/** Value submitted. Falls back to `name` when absent. */
|
|
2090
|
+
value?: string;
|
|
2091
|
+
/** Preselected when the form opens. */
|
|
2092
|
+
default: boolean;
|
|
2093
|
+
/** A note shown under the field once this option is picked. */
|
|
2094
|
+
message?: string;
|
|
2095
|
+
messageType: "info" | "warning" | "danger";
|
|
2096
|
+
position?: number;
|
|
2097
|
+
group?: string;
|
|
2098
|
+
noDisplay?: boolean;
|
|
2099
|
+
conditionalFieldId?: string;
|
|
2100
|
+
/** Available when the parent matches any of these values. */
|
|
2101
|
+
conditionalFieldValues?: string[];
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
/** The ticket form an agent's `ago_ticketing` tool opens in the conversation. */
|
|
2105
|
+
declare interface TicketForm {
|
|
2106
|
+
id: string;
|
|
2107
|
+
name?: string;
|
|
2108
|
+
/** `"form"` renders the SDK's own fields; `"embed"` hosts third-party HTML. */
|
|
2109
|
+
mode: "form" | "embed";
|
|
2110
|
+
showSubject: boolean;
|
|
2111
|
+
showBody: boolean;
|
|
2112
|
+
showPriority: boolean;
|
|
2113
|
+
showTypology: boolean;
|
|
2114
|
+
priorityTypologies?: string[];
|
|
2115
|
+
successMessageText?: string;
|
|
2116
|
+
successMessageUrlLabel?: string;
|
|
2117
|
+
fields: TicketField[];
|
|
2118
|
+
}
|
|
2119
|
+
|
|
1835
2120
|
/**
|
|
1836
2121
|
* Tool call data from SSE stream
|
|
1837
2122
|
*/
|
|
@@ -1846,6 +2131,34 @@ export declare interface ToolCallData {
|
|
|
1846
2131
|
data?: Record<string, unknown>;
|
|
1847
2132
|
functionName?: string;
|
|
1848
2133
|
arguments?: Record<string, unknown>;
|
|
2134
|
+
/**
|
|
2135
|
+
* Where the hosted widget shows the call: in the collapsible "reasoning"
|
|
2136
|
+
* section, in the message body, or both. Absent means collapsible only.
|
|
2137
|
+
*/
|
|
2138
|
+
displayMode?: "collapsible" | "display" | "both";
|
|
2139
|
+
/** The user asked to talk to a human. */
|
|
2140
|
+
askToTalkToHuman?: boolean;
|
|
2141
|
+
/** `false` when the tenant blocks ticket creation for this visitor. */
|
|
2142
|
+
allowedToCreateTicket?: boolean;
|
|
2143
|
+
/** Fields the agent pre-filled from the conversation. */
|
|
2144
|
+
ticket?: ToolCallTicketPrefill;
|
|
2145
|
+
/** `"embed"` hosts third-party HTML (`embedHtml`); otherwise the SDK's form. */
|
|
2146
|
+
mode?: "form" | "embed";
|
|
2147
|
+
ticketFormId?: string;
|
|
2148
|
+
embedHtml?: string;
|
|
2149
|
+
embedDescription?: string;
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
/** The ticket the agent pre-filled on a ticketing `form` tool call. */
|
|
2153
|
+
declare interface ToolCallTicketPrefill {
|
|
2154
|
+
subject?: string;
|
|
2155
|
+
body?: string;
|
|
2156
|
+
typology?: string;
|
|
2157
|
+
priority?: string;
|
|
2158
|
+
tag?: string;
|
|
2159
|
+
products?: string[];
|
|
2160
|
+
/** Keyed by the field's external id, or a lowercased, underscored title. */
|
|
2161
|
+
custom_fields?: Record<string, string>;
|
|
1849
2162
|
}
|
|
1850
2163
|
|
|
1851
2164
|
declare type ToolCallType = "form" | "confirmation_input" | "status_message" | "progress_indicator" | "client_function" | "reasoning" | "mcp_ui_resource";
|
package/dist/angular.js
CHANGED
package/dist/{createConversationSession-BaaXBQ5b.js → createConversationSession-B1Qn-y0I.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as d } from "./types-
|
|
1
|
+
import { g as d } from "./types-Ct1hlKwg.js";
|
|
2
2
|
var f = "ago_widget_id", g = "ago_last_thread", y = 7200 * 1e3;
|
|
3
3
|
function v() {
|
|
4
4
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
package/dist/{createConversationSession-CU0b-t1W.cjs → createConversationSession-B3v_xOU7.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
const d=require("./types-
|
|
1
|
+
const d=require("./types-mcW8vB1U.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),s=o.get();s.value!==null&&c(s.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function c(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||c(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const C=require("./types-
|
|
1
|
+
const C=require("./types-mcW8vB1U.cjs");var W=/^[a-zA-Z0-9_-]{1,40}$/,V=n=>n==null||n==="";function S(n,e){if("anyOf"in n)return n.anyOf.some(c=>S(c,e));if("allOf"in n)return n.allOf.every(c=>S(c,e));const l=e[n.property];if(V(l))return!1;if(Array.isArray(n.value))return n.value.some(c=>String(l)===String(c));if(!n.op)return String(l)===String(n.value);const i=Number(l),a=Number(n.value);if(Number.isNaN(i)||Number.isNaN(a))return!1;switch(n.op){case">=":return i>=a;case"<=":return i<=a;case">":return i>a;case"<":return i<a;default:return C.logger.warn(`Unknown requiredWhen op "${n.op}"; treating as not required.`),!1}}function h(n,e){const l=n.properties??{},i=new Set;for(const c of n.required??[]){const d=l[c]?.requiredWhen;(!d||S(d,e))&&i.add(c)}for(const[c,d]of Object.entries(l))d.requiredWhen&&S(d.requiredWhen,e)&&i.add(c);const a=[...i].filter(c=>V(e[c]));return{missing:a,complete:a.length===0}}function B(n){const e={};for(const[l,i]of Object.entries(n.properties??{}))e[l]={type:i.type,...i.description!=null&&{description:i.description},...i.enum&&{enum:i.enum},...i.default!==void 0&&{default:i.default}};return{type:"object",properties:e,required:[]}}function A(n){const{name:e,description:l,schema:i}=n;if(!W.test(e))throw new Error(`Invalid form collector name "${e}": must match ${W} (it becomes the update_/submit_ function names).`);const a=typeof n.submit=="string"?n.submit?{via:"client",url:n.submit}:!1:n.submit??!1;n.autoSubmit===!0&&!a&&C.logger.warn(`FormCollector "${e}": autoSubmit is ignored because no submit target is configured.`);const c=(n.autoSubmit??!0)&&!!a,d=i.properties??{},$=t=>{const r={};for(const[o,s]of Object.entries(t)){const u=d[o];if(u)if(s==null)r[o]=s;else if(u.type==="number"||u.type==="integer"){const f=typeof s=="number"?s:Number(s);r[o]=Number.isNaN(f)?s:f}else u.type==="boolean"?r[o]=typeof s=="boolean"?s:s==="true"?!0:s==="false"?!1:!!s:r[o]=s}return r},N=n.initialValues??{},m=C.createStore({values:N,submitted:!1}),w=t=>{const r=m.get(),o={...r,values:{...r.values,...t}};return m.set(o),o};let b=null;const k=(t,r)=>{b?.emitFormEvent("form:error",{name:e,values:t,error:r})};let p=null;const I=async()=>{const{values:t}=m.get(),{complete:r,missing:o}=h(i,t);if(!r)return{ok:!1,missing:o};if(!a)return{ok:!1,error:"No submit target configured for this form collector."};const s=t;try{let u;if(a.via==="client")if("handler"in a)u=await a.handler(s);else{const f=await fetch(a.url,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(s)});if(!f.ok){const j=`Submit failed: HTTP ${f.status}`;return k(s,j),{ok:!1,error:j}}u=await f.json().catch(()=>{})}else{if(!b)return{ok:!1,error:"Backend submit requires install(client) (or useFormCollector) first."};u=await b.submitFormCollector(e,s)}return m.set({...m.get(),submitted:!0,submitResult:u}),b?.emitFormEvent("form:submitted",{name:e,values:s,result:u}),{ok:!0,result:u}}catch(u){const f=u instanceof Error?u.message:"Submit failed";return C.logger.error(`FormCollector "${e}" submit failed:`,u),k(s,f),{ok:!1,error:f}}},F=()=>p||(p=(async()=>{try{return await I()}finally{p=null}})(),p),q=async()=>{if(!c||!a)return null;const{values:t,submitted:r}=m.get();return r||!h(i,t).complete?null:F()},O={name:`update_${e}`,description:`Fill or update fields of the "${e}" form. ${l} Pass any subset of fields; call it repeatedly to fill the form as the user provides information. Returns the current values and which required fields are still missing.`,parameters:B(i),handler:async t=>{const r=w($(t)),{missing:o}=h(i,r.values),s=await q();return s?s.ok?{ok:!0,values:r.values,missing:o,submitted:!0}:{ok:!0,values:r.values,missing:o,submitted:!1,submitError:s.error}:{ok:!0,values:r.values,missing:o}}},y=[O];a&&!c&&y.push({name:`submit_${e}`,description:`Submit the completed "${e}" form. Only call this once every required field is collected and the user has confirmed. If fields are missing it returns them instead of submitting.`,parameters:{type:"object",properties:{}},handler:()=>F()});const D="client__",_=a?`submit_${e}`:null,R=t=>{const r=t.functionName??t.toolName;if(r)return r.startsWith(D)?r.slice(8):r},x=t=>{let r={...N},o=!1;for(const s of t){const u=R(s);u===O.name?s.arguments&&(r={...r,...$(s.arguments)}):_&&u===_&&s.status?.toLowerCase()==="done"&&(o=!0)}m.set({values:r,submitted:o})},g=`form:${e}`,v=`${g}:definition`,P=()=>({name:`Form definition: ${e}`,description:`${l} Some fields are conditionally required; the requiredWhen field in the schema tells you when each becomes required. The form schema is the following: ${JSON.stringify(i)}.`,stable:!0}),T=()=>{const{values:t,submitted:r}=m.get(),{missing:o,complete:s}=h(i,t),u=a?c?" The form is submitted automatically as soon as every required field is filled, so there is no submit function to call.":` When nothing is missing and the user confirms, call submit_${e}.`:"",f=r?`The "${e}" form has been submitted.`:`You are currently collecting information from the user to fill the "${e}" form.`;return{name:`Form: ${e}`,description:`${f} The form's schema and field requirements are in the "${v}" client context. Call update_${e} with any fields the user provides; ask only for what is still missing.${u}`,data:{values:t,missing:o,complete:s,submitted:r}}},E=t=>{x((t.messages??[]).flatMap(r=>r.toolCalls??[]))};return{name:e,store:m,functions:y,contextKey:g,contextProvider:T,definitionContextKey:v,definitionContextProvider:P,install:t=>{b=t;for(const o of y)t.register(o);t.addDynamicContext(v,P),t.addDynamicContext(g,T);const r=m.subscribe(()=>t.notifyContextChanged());return t.on("conversation:loaded",E),()=>{r();for(const o of y)t.unregisterFunction(o.name);t.removeDynamicContext(g),t.removeDynamicContext(v),t.off("conversation:loaded",E),b===t&&(b=null)}},hydrate:x,submit:F,getValues:()=>m.get().values,setValues:t=>{w($(t)),q()},reset:()=>{m.set({values:N,submitted:!1})},getStatus:()=>h(i,m.get().values)}}async function L(n,e){const l=await n.getFormCollector(e.name);return A({name:l.name,description:e.description??l.description,schema:e.schema??l.schema,submit:e.submit??l.submit,initialValues:e.initialValues,autoSubmit:e.autoSubmit??l.autoSubmit})}Object.defineProperty(exports,"createFormCollector",{enumerable:!0,get:function(){return A}});Object.defineProperty(exports,"deriveFormStatus",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"loadFormCollector",{enumerable:!0,get:function(){return L}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function y(u={}){const{overrides:g={}}=u,a={id:"mock-msg-1",conversationId:"mock-conv-1",content:"Mock response",role:"assistant",status:"DONE",createdAt:new Date},l={id:"mock-conv-1",title:"Mock Conversation",lastMessageDate:new Date},n=new Map,c=[],m={sendMessage:async()=>a,continueMessage:async()=>a,stop:async()=>null,stopMessage:async()=>({status:"not_running"}),isGenerating:()=>!1,resumePendingClientFunctions:async()=>null,registerResumeGate:()=>()=>{},getConversations:async()=>[l],getConversation:async()=>l,getMessages:async()=>[a],submitToolCallForm:async()=>({status:"completed"}),confirmToolCall:async()=>{},rejectToolCall:async()=>{},getConfig:async()=>({permissions:[],proactive:{enabled:!1}}),createTicket:async()=>({id:"mock-ticket-1",url:"https://example.test/tickets/mock-ticket-1"}),submitFeedback:async()=>{},submitConversationFeedback:async()=>a.id,registerFunction:()=>{},unregisterFunction:()=>!0,getRegisteredFunctions:()=>[],executeClientFunction:async()=>{},getContextSnapshot:()=>null,notifyContextChanged:()=>{},setContext:()=>{},removeContext:()=>!0,addDynamicContext:()=>{},removeDynamicContext:()=>!0,registerNavigationFunction:()=>{},unregisterNavigationFunction:()=>{},getConfiguredAgent:()=>{},getUserIdentity:()=>({email:void 0,hasJwt:!1}),getHttp:()=>({get:async()=>({}),post:async()=>({})}),emitProactiveEvent:(e,t)=>{const o=n.get(e);o&&[...o].forEach(s=>s(t))},on:(e,t)=>{n.has(e)||n.set(e,new Set),n.get(e).add(t)},off:(e,t)=>{n.get(e)?.delete(t)},once:(e,t)=>{const o=(...s)=>{n.get(e)?.delete(o),t(...s)};n.has(e)||n.set(e,new Set),n.get(e).add(o)},waitFor:(e,t)=>new Promise((o,s)=>{let r;const d=f=>{r&&clearTimeout(r),n.get(e)?.delete(d),o(f)};n.has(e)||n.set(e,new Set),n.get(e).add(d),t?.timeout&&(r=setTimeout(()=>{n.get(e)?.delete(d),s(new Error(`waitFor("${e}") timed out after ${t.timeout}ms`))},t.timeout))}),updateConfig:()=>{},destroy:()=>{n.clear()},...g},i={};for(const[e,t]of Object.entries(m))i[e]=(...o)=>(c.push({method:e,args:o}),t(...o));return i.proactive=null,i.__calls=c,i.__callsFor=e=>c.filter(t=>t.method===e),i.__emitEvent=(e,t)=>{const o=n.get(e);o&&[...o].forEach(s=>s(t))},i}Object.defineProperty(exports,"createMockClient",{enumerable:!0,get:function(){return y}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function y(
|
|
2
|
-
const { overrides:
|
|
1
|
+
function y(g = {}) {
|
|
2
|
+
const { overrides: u = {} } = g, a = {
|
|
3
3
|
id: "mock-msg-1",
|
|
4
4
|
conversationId: "mock-conv-1",
|
|
5
5
|
content: "Mock response",
|
|
@@ -27,6 +27,14 @@ function y(u = {}) {
|
|
|
27
27
|
},
|
|
28
28
|
rejectToolCall: async () => {
|
|
29
29
|
},
|
|
30
|
+
getConfig: async () => ({
|
|
31
|
+
permissions: [],
|
|
32
|
+
proactive: { enabled: !1 }
|
|
33
|
+
}),
|
|
34
|
+
createTicket: async () => ({
|
|
35
|
+
id: "mock-ticket-1",
|
|
36
|
+
url: "https://example.test/tickets/mock-ticket-1"
|
|
37
|
+
}),
|
|
30
38
|
submitFeedback: async () => {
|
|
31
39
|
},
|
|
32
40
|
submitConversationFeedback: async () => a.id,
|
|
@@ -51,6 +59,10 @@ function y(u = {}) {
|
|
|
51
59
|
},
|
|
52
60
|
getConfiguredAgent: () => {
|
|
53
61
|
},
|
|
62
|
+
getUserIdentity: () => ({
|
|
63
|
+
email: void 0,
|
|
64
|
+
hasJwt: !1
|
|
65
|
+
}),
|
|
54
66
|
getHttp: () => ({
|
|
55
67
|
get: async () => ({}),
|
|
56
68
|
post: async () => ({})
|
|
@@ -85,7 +97,7 @@ function y(u = {}) {
|
|
|
85
97
|
destroy: () => {
|
|
86
98
|
n.clear();
|
|
87
99
|
},
|
|
88
|
-
...
|
|
100
|
+
...u
|
|
89
101
|
}, i = {};
|
|
90
102
|
for (const [e, t] of Object.entries(m)) i[e] = (...o) => (c.push({
|
|
91
103
|
method: e,
|