@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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,110 @@ All notable changes to `@useago/sdk` are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.12.0] - 2026-09-07
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **User metadata on messages.** Set `metadata` on the client config (or in
|
|
13
|
+
`window.AGO.metadata`) and the JSON-serializable object rides along with every
|
|
14
|
+
new message, both JSON and multipart uploads. `sendMessage(text, { metadata })`
|
|
15
|
+
replaces the defaults for that message, `null` omits the field, and
|
|
16
|
+
`updateConfig({ metadata })` changes it at runtime. In React, `useAgo`
|
|
17
|
+
re-applies the `metadata` prop without recreating the client. The API stores
|
|
18
|
+
it as widget metadata on the user, where field mappings can pull selected
|
|
19
|
+
values into tickets. It is untrusted browser-supplied context, not a
|
|
20
|
+
credential.
|
|
21
|
+
- **JavaScript errors as agent context.** Set `errorWatcher: true` (or options)
|
|
22
|
+
on the client config and the page's recent JS errors ride along with every
|
|
23
|
+
message as the `errors:recent` context entry: uncaught exceptions with file,
|
|
24
|
+
line and stack, unhandled promise rejections, `console.error` calls (the
|
|
25
|
+
method is wrapped, calls through, and is restored on `destroy()`), and
|
|
26
|
+
errors the app hands over with `client.reportError(error, context?)`.
|
|
27
|
+
Deduplicated with a `count`, capped at 10, pruned after 10 minutes, messages
|
|
28
|
+
and stacks truncated. Options `maxErrors`, `maxAgeMs`, `maxStackChars`,
|
|
29
|
+
`filter`. New client methods `enableErrorWatcher`, `disableErrorWatcher`,
|
|
30
|
+
`reportError`, `getRecentErrors`, `clearErrors`; new event `error:captured`;
|
|
31
|
+
new exports `ErrorWatcher`, `CapturedError`, `ErrorWatcherOptions`. Off by
|
|
32
|
+
default: error messages can carry PII.
|
|
33
|
+
- **`jsErrors` proactive matcher.** Captured errors count as friction on the
|
|
34
|
+
current route (`SignalsSnapshot.jsErrors`, reset on navigation), so a
|
|
35
|
+
trigger can nudge right after a crash with `when: { jsErrors: 1 }`. Needs
|
|
36
|
+
`errorWatcher` on; counts only, the messages stay in `client_context`.
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- Ticket attachments become available when the dashboard form configuration
|
|
41
|
+
finishes loading.
|
|
42
|
+
- Ticket forms now support multiple condition values, nested questions and
|
|
43
|
+
conditional choices across ticketing providers. Changing a branch clears
|
|
44
|
+
answers that no longer apply. Required questions are checked before sending,
|
|
45
|
+
including those not yet revealed.
|
|
46
|
+
- Ticket forms respect option groups and order, fields marked always visible,
|
|
47
|
+
format validation, priority by request type and dashboard success messages
|
|
48
|
+
when the API supplies these settings.
|
|
49
|
+
|
|
50
|
+
## [1.11.0] - 2026-09-04
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
|
|
54
|
+
- **`loadHomeConfig` on the bubble widget: the home screen from the AGO
|
|
55
|
+
dashboard.** `mountChatWidget(el, { placement: "bubble", loadHomeConfig: true })`
|
|
56
|
+
takes the home title, the markdown subtitle and the starter cards from
|
|
57
|
+
`GET /config` instead of the options, the way the hosted widget does. One
|
|
58
|
+
request on mount, off the critical path: the panel renders with whatever the
|
|
59
|
+
options set and re-renders when the config lands, and a failed request leaves
|
|
60
|
+
the options in place. Each part is replaced only when the dashboard has a
|
|
61
|
+
value for it, and the header keeps the `title` option. The dashboard's
|
|
62
|
+
*widget starter* (an opening message the agent sends by itself) fires when the
|
|
63
|
+
panel is first opened, on a fresh visit only, never over a resumed thread.
|
|
64
|
+
- **`agentId` on `ConversationStarter`.** A starter card can name the agent
|
|
65
|
+
that answers it. Dashboard starters carry their own.
|
|
66
|
+
- **`SdkPermissionConfig.homePage`.** `AgoClient.getConfig()` now maps the
|
|
67
|
+
`home_page` block (`title`, `subtitle`, `home_starters`, `widget_starter`)
|
|
68
|
+
when the backend sends one. A starter card shows its `description` and sends
|
|
69
|
+
its `initial_message`; one with neither is dropped. New types
|
|
70
|
+
`SdkHomePageConfig`, `SdkHomeStarter`, `SdkWidgetStarter`.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## [1.10.0] - 2026-09-03
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
|
|
77
|
+
- **`placement: "bubble"` on `mountChatWidget`.** The hosted embed widget
|
|
78
|
+
without the iframe: a 54px launcher bottom right, a teaser bubble one second
|
|
79
|
+
after mount, and a 550px panel with a home screen (title, markdown
|
|
80
|
+
`subtitle`, `conversationStarters` cards), a conversation screen, and a chat
|
|
81
|
+
history screen with relative times and a "New conversation" pill. Reopens
|
|
82
|
+
the visitor's most recent thread when its last message is under two hours
|
|
83
|
+
old (`autoResume`), goes full screen under 450px, closes on Escape, and
|
|
84
|
+
takes the embed snippet's `colors` (`button`, `header` with gradients,
|
|
85
|
+
`agentMessage`, `background`, `font`, `userMessage`) with the header text
|
|
86
|
+
derived for contrast. New options `prompt`, `icon`, `colors`, `hideFooter`,
|
|
87
|
+
`subtitle`, `conversationStarters`, `autoResume`, `labels`; new handle
|
|
88
|
+
members `screen`, `showScreen`, `openConversation`, `newConversation`. New
|
|
89
|
+
theme tokens `--ago-launcher-background`, `--ago-launcher-text-color`,
|
|
90
|
+
`--ago-send-button-background`, `--ago-user-bubble-background`,
|
|
91
|
+
`--ago-user-bubble-text-color`, `--ago-agent-bubble-text-color`,
|
|
92
|
+
`--ago-panel-width`.
|
|
93
|
+
- **The ticket form renders in the vanilla widget.** The `form` tool call the
|
|
94
|
+
agent's `ago_ticketing` tool opens now shows the tenant's contact form in the
|
|
95
|
+
conversation, on every placement: inline fields from `GET /config`, the
|
|
96
|
+
embedded (HubSpot) variant, the "not allowed" notice, a green success block,
|
|
97
|
+
and the composer replaced by a "complete the form" card, then "ticket
|
|
98
|
+
created" with a New conversation button. New `toolCallForm` option (labels,
|
|
99
|
+
success text, `userEmail`, callbacks).
|
|
100
|
+
- **`AgoClient.getConfig()`, `AgoClient.createTicket()`, and
|
|
101
|
+
`AgoClient.getUserIdentity()`.** `ToolCallData` carries the ticketing fields
|
|
102
|
+
(`displayMode`, `askToTalkToHuman`, `allowedToCreateTicket`, `ticket`,
|
|
103
|
+
`mode`, `ticketFormId`, `embedHtml`, `embedDescription`), streamed and
|
|
104
|
+
persisted alike. New exported types `TicketForm`, `TicketField`,
|
|
105
|
+
`SdkConfig`, `CreateTicketInput`, `CreateTicketResult`.
|
|
106
|
+
|
|
107
|
+
### Changed
|
|
108
|
+
|
|
109
|
+
- Nothing for the existing `inline`, `left`, and `right` placements. The
|
|
110
|
+
`newConversation()` handle method is new on all of them.
|
|
111
|
+
|
|
8
112
|
## [1.9.0] - 2026-08-28
|
|
9
113
|
|
|
10
114
|
### Changed
|
package/README.md
CHANGED
|
@@ -304,6 +304,59 @@ React and Vue have a `useFeedback()` hook/composable; React also exports the
|
|
|
304
304
|
`<MessageFeedback messageId={...} />` row for a custom message list. Details in
|
|
305
305
|
[Feedback](docs/general/widget.md#feedback).
|
|
306
306
|
|
|
307
|
+
## Let the agent see what broke
|
|
308
|
+
|
|
309
|
+
"The button does nothing" is easier to answer with the exception in hand. Turn
|
|
310
|
+
on the error watcher and the page's recent JavaScript errors (uncaught
|
|
311
|
+
exceptions with file, line and stack, unhandled rejections, `console.error`
|
|
312
|
+
calls) ride along with every message, deduplicated and capped.
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
const ago = new AgoClient({
|
|
316
|
+
baseUrl: "https://playground.api.useago.com",
|
|
317
|
+
agent: "generic-guide",
|
|
318
|
+
errorWatcher: true, // off by default: error messages can carry PII
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// Errors you already catch (error boundaries, framework handlers):
|
|
322
|
+
ago.reportError(error, { component: "OrderTable" });
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Same option on `<AgoProvider>`, the Vue plugin, `provideAgo` and
|
|
326
|
+
`mountChatWidget({ config })`. Redact with a `filter`, tune the caps, or use
|
|
327
|
+
`when: { jsErrors: 1 }` in a proactive trigger to nudge right after a crash.
|
|
328
|
+
Details in [JavaScript errors](docs/general/functions-and-context.md#javascript-errors).
|
|
329
|
+
|
|
330
|
+
## Drop the chat bubble on any page
|
|
331
|
+
|
|
332
|
+
The hosted embed widget, without the iframe: a launcher in the corner, a teaser
|
|
333
|
+
bubble, and a panel with a home screen, the conversation, and the chat history.
|
|
334
|
+
It reopens the visitor's last thread for two hours and goes full screen on a
|
|
335
|
+
phone.
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
import { mountChatWidget } from "@useago/sdk/widget";
|
|
339
|
+
|
|
340
|
+
mountChatWidget(document.body, {
|
|
341
|
+
config: { baseUrl: "https://playground.api.useago.com", agent: "generic-guide" },
|
|
342
|
+
placement: "bubble",
|
|
343
|
+
title: "Ask AGO",
|
|
344
|
+
conversationStarters: [{ label: "What can the SDK do?" }],
|
|
345
|
+
colors: { button: "#007bff", header: "#03182f" },
|
|
346
|
+
});
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Add `loadHomeConfig: true` and the home title, subtitle and starter cards come
|
|
350
|
+
from your AGO dashboard instead of the options above.
|
|
351
|
+
|
|
352
|
+
When the visitor asks for a human, the agent's ticket form renders inside the
|
|
353
|
+
conversation on every placement, with the fields from your AGO dashboard.
|
|
354
|
+
Conditional questions and choices work across ticketing providers; changing an
|
|
355
|
+
answer clears responses that no longer apply. The API must include the form
|
|
356
|
+
metadata described in the ticket form guide.
|
|
357
|
+
Details in [Floating bubble](docs/general/widget.md#floating-bubble-placement-bubble)
|
|
358
|
+
and [Ticket form](docs/general/widget.md#ticket-form-the-form-tool-call).
|
|
359
|
+
|
|
307
360
|
## Show the source docs the agent retrieved
|
|
308
361
|
|
|
309
362
|
Each assistant message carries the knowledge sources it used in `m.sources`
|
package/dist/angular.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./types-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./types-mcW8vB1U.cjs"),c=require("./autoContinue-CP9pJR-V.cjs");var n=class{constructor(t){this.client=new r.AgoClient(t),this.messages$=this.fromEvent("message:complete"),this.chunks$=this.fromEvent("message:chunk"),this.errors$=this.fromEvent("message:error"),this.messageStart$=this.fromEvent("message:start")}fromEvent(t){const e=this.client;return{subscribe(i){const s=o=>{i.next?.(o)};return e.on(t,s),{unsubscribe:()=>e.off(t,s)}}}}sendMessage(t,e){return this.client.sendMessage(t,e)}stop(){return this.client.stop()}stopMessage(t){return this.client.stopMessage(t)}isGenerating(){return this.client.isGenerating()}getConversations(){return this.client.getConversations().then(t=>t.data)}getConversation(t){return this.client.getConversation(t)}getMessages(t){return this.client.getMessages(t)}submitToolCallForm(t,e){return this.client.submitToolCallForm(t,e)}confirmToolCall(t){return this.client.confirmToolCall(t)}rejectToolCall(t){return this.client.rejectToolCall(t)}submitFeedback(t,e,i){return this.client.submitFeedback(t,e,i)}submitConversationFeedback(t,e,i){return this.client.submitConversationFeedback(t,e,i)}registerFunction(t,e,i){typeof t=="object"?this.client.registerFunction(t):this.client.registerFunction(t,e,i)}unregisterFunction(t){return this.client.unregisterFunction(t)}registerNavigationFunction(t,e){this.client.registerNavigationFunction(t,e)}unregisterNavigationFunction(){this.client.unregisterNavigationFunction()}enableAutoContinueAfterNavigation(t){return c.attachAutoContinueAfterNavigation(this.client,t)}registerPageStateFunction(t,e){this.client.registerPageStateFunction(t,e)}unregisterPageStateFunction(t){this.client.unregisterPageStateFunction(t)}on(t,e){this.client.on(t,e)}off(t,e){this.client.off(t,e)}updateConfig(t){this.client.updateConfig(t)}getClient(){return this.client}destroy(){this.client.destroy()}};function u(t){return{provide:n,useValue:new n(t)}}exports.AgoService=n;exports.FEEDBACK_REASONS=r.FEEDBACK_REASONS;exports.provideAgo=u;
|
package/dist/angular.d.cts
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";
|