@useago/sdk 1.5.2 → 1.5.4
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 +18 -0
- package/README.md +10 -0
- package/dist/AgoClient-BW0YZsis.js +1681 -0
- package/dist/AgoClient-Ba3ICq4K.cjs +8 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +352 -0
- package/dist/angular.d.ts +352 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-BjsgjL-v.js} +3 -3
- package/dist/createConversationSession-okoz3teC.cjs +1 -0
- package/dist/createFormCollector-BWIh1pMl.cjs +1 -0
- package/dist/createFormCollector-Bay2UpRv.js +279 -0
- package/dist/createMockClient-DcuNlufr.js +97 -0
- package/dist/createMockClient-Dw-cyISN.cjs +1 -0
- package/dist/devtools.d.cts +352 -0
- package/dist/devtools.d.ts +352 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +564 -0
- package/dist/index.d.ts +564 -0
- package/dist/index.js +97 -90
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +430 -0
- package/dist/react.d.ts +430 -0
- package/dist/react.js +600 -443
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +352 -0
- package/dist/testing.d.ts +352 -0
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +373 -0
- package/dist/vue.d.ts +373 -0
- package/dist/vue.js +133 -110
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +349 -0
- package/dist/widget.d.ts +349 -0
- package/dist/widget.js +7 -7
- package/llms-full.txt +29 -0
- package/package.json +1 -1
- package/dist/AgoClient-5VGybmvz.cjs +0 -8
- package/dist/AgoClient-DXrH2AMi.js +0 -964
- package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
- package/dist/createFormCollector-DYh90kiG.js +0 -305
- package/dist/createMockClient-C-wrjb2C.cjs +0 -1
- package/dist/createMockClient-we-XoPom.js +0 -79
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
2
|
|
|
3
|
+
export declare interface ActivityEntry {
|
|
4
|
+
ts: number;
|
|
5
|
+
actor: "user" | "agent";
|
|
6
|
+
name: string;
|
|
7
|
+
summary: string;
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export declare interface ActivityInput {
|
|
12
|
+
actor?: "user" | "agent";
|
|
13
|
+
name: string;
|
|
14
|
+
summary: string;
|
|
15
|
+
data?: Record<string, unknown>;
|
|
16
|
+
ts?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
3
19
|
/**
|
|
4
20
|
* One normalized entry in the agent's activity feed. Merges a tool call
|
|
5
21
|
* (`toolCall:received`) or a client-function invocation (`function:invoke` /
|
|
@@ -91,6 +107,8 @@ declare class AgoClient {
|
|
|
91
107
|
private functionRegistry;
|
|
92
108
|
private contextRegistry;
|
|
93
109
|
private eventEmitter;
|
|
110
|
+
private activityLedger;
|
|
111
|
+
private lastSentPageState;
|
|
94
112
|
private config;
|
|
95
113
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
96
114
|
private warnedEmptyConversations;
|
|
@@ -104,6 +122,12 @@ declare class AgoClient {
|
|
|
104
122
|
private pendingApprovals;
|
|
105
123
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
106
124
|
private resumeGate;
|
|
125
|
+
/**
|
|
126
|
+
* Proactive-mode controller, set when the client was created with
|
|
127
|
+
* `proactive` options or when `createAgoProactive(client, opts)` was called.
|
|
128
|
+
* `null` otherwise.
|
|
129
|
+
*/
|
|
130
|
+
proactive: ProactiveController | null;
|
|
107
131
|
constructor(config: AgoConfig);
|
|
108
132
|
/**
|
|
109
133
|
* Send a message and receive a streaming response
|
|
@@ -274,6 +298,14 @@ declare class AgoClient {
|
|
|
274
298
|
* Get all registered function schemas
|
|
275
299
|
*/
|
|
276
300
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
301
|
+
/**
|
|
302
|
+
* Execute a registered client function locally, through the same
|
|
303
|
+
* FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
|
|
304
|
+
* calls. Used by proactive nudge actions, where the user's explicit click on
|
|
305
|
+
* the action button constitutes the approval — nothing is submitted to the
|
|
306
|
+
* backend (there is no tool call to answer).
|
|
307
|
+
*/
|
|
308
|
+
executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
277
309
|
/**
|
|
278
310
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
279
311
|
*
|
|
@@ -375,6 +407,9 @@ declare class AgoClient {
|
|
|
375
407
|
*/
|
|
376
408
|
notifyContextChanged(): void;
|
|
377
409
|
/* Excluded from this release type: emitFormEvent */
|
|
410
|
+
/* Excluded from this release type: emitProactiveEvent */
|
|
411
|
+
/* Excluded from this release type: getHttp */
|
|
412
|
+
/* Excluded from this release type: getConfiguredAgent */
|
|
378
413
|
/**
|
|
379
414
|
* Enable automatic capture of the current browser page (URL + title).
|
|
380
415
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -384,6 +419,19 @@ declare class AgoClient {
|
|
|
384
419
|
* Get the current context snapshot.
|
|
385
420
|
*/
|
|
386
421
|
getContextSnapshot(): ContextSnapshot | null;
|
|
422
|
+
private buildSendContext;
|
|
423
|
+
/**
|
|
424
|
+
* Record something the user just did so the agent is aware of it on the next
|
|
425
|
+
* message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
|
|
426
|
+
* (no raw payloads, secrets, or PII).
|
|
427
|
+
*/
|
|
428
|
+
recordActivity(entry: ActivityInput): void;
|
|
429
|
+
/** Recent user + agent actions, oldest first (a copy). */
|
|
430
|
+
getRecentActivity(): ActivityEntry[];
|
|
431
|
+
clearActivity(): void;
|
|
432
|
+
private addActivity;
|
|
433
|
+
private recordAgentAction;
|
|
434
|
+
private registerActivityContext;
|
|
387
435
|
/**
|
|
388
436
|
* Subscribe to an event
|
|
389
437
|
*/
|
|
@@ -419,6 +467,7 @@ declare class AgoClient {
|
|
|
419
467
|
* Clean up resources
|
|
420
468
|
*/
|
|
421
469
|
destroy(): void;
|
|
470
|
+
/* Excluded from this release type: reviveAfterDestroy */
|
|
422
471
|
}
|
|
423
472
|
|
|
424
473
|
/**
|
|
@@ -535,6 +584,27 @@ declare interface AgoClientEvents {
|
|
|
535
584
|
"connection:status": {
|
|
536
585
|
connected: boolean;
|
|
537
586
|
};
|
|
587
|
+
/**
|
|
588
|
+
* A proactive nudge passed every governor gate and is ready to display.
|
|
589
|
+
* `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
|
|
590
|
+
* `client.proactive.shown(nudge)` when they render it (impression tracking
|
|
591
|
+
* + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
|
|
592
|
+
*/
|
|
593
|
+
"nudge:ready": ProactiveNudgeInstance;
|
|
594
|
+
/** A nudge was displayed to the user (fires once per nudge). */
|
|
595
|
+
"nudge:shown": {
|
|
596
|
+
nudge: ProactiveNudgeInstance;
|
|
597
|
+
};
|
|
598
|
+
/** The user dismissed the nudge (its trigger is suppressed, see governor). */
|
|
599
|
+
"nudge:dismissed": {
|
|
600
|
+
nudge: ProactiveNudgeInstance;
|
|
601
|
+
};
|
|
602
|
+
/** The user accepted the nudge (its action ran / the chat is being seeded). */
|
|
603
|
+
"nudge:accepted": {
|
|
604
|
+
nudge: ProactiveNudgeInstance;
|
|
605
|
+
};
|
|
606
|
+
/** A user- or agent-action was recorded into the activity ledger. */
|
|
607
|
+
"activity:recorded": ActivityEntry;
|
|
538
608
|
}
|
|
539
609
|
|
|
540
610
|
/**
|
|
@@ -596,6 +666,24 @@ export declare interface AgoConfig {
|
|
|
596
666
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
597
667
|
*/
|
|
598
668
|
maxFunctionResultBytes?: number;
|
|
669
|
+
/**
|
|
670
|
+
* Max number of recent actions kept in the in-memory activity ledger that
|
|
671
|
+
* rides along as the `activity:recent` context entry. Older entries drop
|
|
672
|
+
* first. Default `10`. Larger values give the agent more history at the cost
|
|
673
|
+
* of tokens on every message. Each entry's `data` is also size-clamped (long
|
|
674
|
+
* strings truncated, large arrays capped) so one event can't bloat the context.
|
|
675
|
+
*/
|
|
676
|
+
maxActivityEntries?: number;
|
|
677
|
+
/**
|
|
678
|
+
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
679
|
+
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
680
|
+
* that can surface a nudge before the user opens the chat. Equivalent to
|
|
681
|
+
* calling `createAgoProactive(client, proactive)` — the resulting controller
|
|
682
|
+
* is available as `client.proactive`. Requires the tenant-level kill-switch
|
|
683
|
+
* (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
|
|
684
|
+
* default otherwise.
|
|
685
|
+
*/
|
|
686
|
+
proactive?: ProactiveOptions;
|
|
599
687
|
}
|
|
600
688
|
|
|
601
689
|
/**
|
|
@@ -639,6 +727,33 @@ export declare interface AgoMessage {
|
|
|
639
727
|
createdAt: Date;
|
|
640
728
|
}
|
|
641
729
|
|
|
730
|
+
/**
|
|
731
|
+
* Prebuilt proactive-nudge toast: a small, always-dismissable bubble anchored
|
|
732
|
+
* near the chat launcher. Never modal — it never blocks the page. Renders the
|
|
733
|
+
* nudge message, its optional action button, and an "open chat" affordance
|
|
734
|
+
* for nudges that expand into a conversation.
|
|
735
|
+
*/
|
|
736
|
+
export declare const AgoNudge: default_2.FC<AgoNudgeProps>;
|
|
737
|
+
|
|
738
|
+
export declare interface AgoNudgeProps {
|
|
739
|
+
/** The AGO client instance. If omitted, reads from AgoProvider context. */
|
|
740
|
+
client?: AgoClient;
|
|
741
|
+
/**
|
|
742
|
+
* Called after accepting a nudge that expands into the chat (agent-sourced
|
|
743
|
+
* or with a `goal`) — open your chat UI here. The conversation is already
|
|
744
|
+
* pre-seeded with a hidden kickoff message.
|
|
745
|
+
*/
|
|
746
|
+
onExpand?: UseProactiveNudgeOptions["onExpand"];
|
|
747
|
+
/** Auto-dismiss after this many ms. Off by default (nudges stay until acted on). */
|
|
748
|
+
autoHideMs?: number;
|
|
749
|
+
/** Corner to anchor to (near the chat launcher). Default `"bottom-right"`. */
|
|
750
|
+
position?: "bottom-right" | "bottom-left";
|
|
751
|
+
/** Label of the open-chat affordance. Default `"Open chat"`. */
|
|
752
|
+
openChatLabel?: string;
|
|
753
|
+
/** Additional CSS class (consumer hook only; the SDK ships no CSS for it). */
|
|
754
|
+
className?: string;
|
|
755
|
+
}
|
|
756
|
+
|
|
642
757
|
/**
|
|
643
758
|
* Options for {@link AgoClient.registerPageStateFunction}.
|
|
644
759
|
*/
|
|
@@ -1173,6 +1288,43 @@ export declare interface FormSubmitResult {
|
|
|
1173
1288
|
error?: string;
|
|
1174
1289
|
}
|
|
1175
1290
|
|
|
1291
|
+
/**
|
|
1292
|
+
* HTTP client with authentication headers
|
|
1293
|
+
*/
|
|
1294
|
+
declare class HttpClient {
|
|
1295
|
+
private baseUrl;
|
|
1296
|
+
private headers;
|
|
1297
|
+
constructor(config: AgoConfig);
|
|
1298
|
+
/**
|
|
1299
|
+
* Update configuration (e.g., JWT token)
|
|
1300
|
+
*/
|
|
1301
|
+
updateConfig(config: Partial<AgoConfig>): void;
|
|
1302
|
+
/**
|
|
1303
|
+
* Make a GET request
|
|
1304
|
+
*/
|
|
1305
|
+
get<T>(path: string): Promise<T>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Make a POST request with JSON body.
|
|
1308
|
+
*
|
|
1309
|
+
* `keepalive: true` lets the request survive a page unload (used by the
|
|
1310
|
+
* proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
|
|
1311
|
+
* headers, so it's a keepalive fetch instead).
|
|
1312
|
+
*/
|
|
1313
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
1314
|
+
keepalive?: boolean;
|
|
1315
|
+
}): Promise<T>;
|
|
1316
|
+
/**
|
|
1317
|
+
* Make a POST request and return the raw Response (for streaming)
|
|
1318
|
+
*/
|
|
1319
|
+
postStream(path: string, body?: unknown): Promise<Response>;
|
|
1320
|
+
/**
|
|
1321
|
+
* Make a POST request with FormData (for file uploads)
|
|
1322
|
+
*/
|
|
1323
|
+
postFormData(path: string, formData: FormData): Promise<Response>;
|
|
1324
|
+
private request;
|
|
1325
|
+
private handleErrorResponse;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1176
1328
|
/**
|
|
1177
1329
|
* Async sibling of {@link createFormCollector} that pulls the form's definition
|
|
1178
1330
|
* (description + schema + submit target) from the backend by name — the single
|
|
@@ -1267,6 +1419,182 @@ declare interface MockAgoClientOptions {
|
|
|
1267
1419
|
|
|
1268
1420
|
declare type MockFn = (...args: any[]) => any;
|
|
1269
1421
|
|
|
1422
|
+
/**
|
|
1423
|
+
* Optional action attached to a nudge. Accepting a `functionName` action
|
|
1424
|
+
* executes the registered client function (same `FunctionRegistry` path as
|
|
1425
|
+
* agent-invoked calls); `setPageState` applies values through the registered
|
|
1426
|
+
* page-state controls.
|
|
1427
|
+
*/
|
|
1428
|
+
export declare type NudgeAction = {
|
|
1429
|
+
label: string;
|
|
1430
|
+
functionName: string;
|
|
1431
|
+
arguments?: Record<string, unknown>;
|
|
1432
|
+
} | {
|
|
1433
|
+
label: string;
|
|
1434
|
+
setPageState: Record<string, unknown>;
|
|
1435
|
+
};
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* Controller returned by {@link createAgoProactive} (also available as
|
|
1439
|
+
* `client.proactive`).
|
|
1440
|
+
*/
|
|
1441
|
+
export declare interface ProactiveController {
|
|
1442
|
+
/** Persistently opt this browser out of proactive nudges. */
|
|
1443
|
+
optOut(): void;
|
|
1444
|
+
/** Undo {@link optOut}. */
|
|
1445
|
+
optIn(): void;
|
|
1446
|
+
isOptedOut(): boolean;
|
|
1447
|
+
/**
|
|
1448
|
+
* Tell the governor the user is already engaged (e.g. the chat widget is
|
|
1449
|
+
* open) — nudges are suppressed while `true`. Call from the UI layer.
|
|
1450
|
+
*/
|
|
1451
|
+
setEngaged(engaged: boolean): void;
|
|
1452
|
+
/** App-pushed field error counter (field NAME only — never values). */
|
|
1453
|
+
signalFieldError(fieldName: string): void;
|
|
1454
|
+
/** Current aggregated friction snapshot. */
|
|
1455
|
+
getSignalsSnapshot(): SignalsSnapshot;
|
|
1456
|
+
/** The nudge currently occupying the single-nudge slot, if any. */
|
|
1457
|
+
getActiveNudge(): ProactiveNudgeInstance | null;
|
|
1458
|
+
/**
|
|
1459
|
+
* Mark the nudge as displayed. Idempotent per nudge; counts it against the
|
|
1460
|
+
* frequency caps, tracks the impression, and emits `nudge:shown`.
|
|
1461
|
+
*/
|
|
1462
|
+
shown(nudge: ProactiveNudgeInstance): void;
|
|
1463
|
+
/**
|
|
1464
|
+
* Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
|
|
1465
|
+
* and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
|
|
1466
|
+
* hidden kickoff message so the agent starts the turn with full context.
|
|
1467
|
+
*/
|
|
1468
|
+
accept(nudge: ProactiveNudgeInstance): Promise<void>;
|
|
1469
|
+
/** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
|
|
1470
|
+
dismiss(nudge: ProactiveNudgeInstance): void;
|
|
1471
|
+
/** Report a downstream conversion attributable to the nudge (analytics only). */
|
|
1472
|
+
markConverted(nudge: ProactiveNudgeInstance): void;
|
|
1473
|
+
/** Detach everything: listeners, timers, context provider, event flush. */
|
|
1474
|
+
destroy(): void;
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
/** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
|
|
1478
|
+
export declare interface ProactiveNudgeInstance {
|
|
1479
|
+
/** Client-generated uuid for this nudge instance (`client_nudge_id`). */
|
|
1480
|
+
id: string;
|
|
1481
|
+
triggerId: string;
|
|
1482
|
+
/** `static` = configured message; `agent` = backend LLM evaluation. */
|
|
1483
|
+
source: "static" | "agent";
|
|
1484
|
+
message: string;
|
|
1485
|
+
action?: NudgeAction;
|
|
1486
|
+
goal?: string;
|
|
1487
|
+
/** See {@link ProactiveTrigger.kickoff}. */
|
|
1488
|
+
kickoff?: string;
|
|
1489
|
+
createdAt: Date;
|
|
1490
|
+
/** Server-side nudge id (agent nudges only). */
|
|
1491
|
+
serverNudgeId?: string;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
|
|
1495
|
+
export declare interface ProactiveOptions {
|
|
1496
|
+
triggers: ProactiveTrigger[];
|
|
1497
|
+
/**
|
|
1498
|
+
* Global caps on nudges actually shown. `perSession` is in-memory (page
|
|
1499
|
+
* lifetime); `perDay` is persisted in localStorage with a date rollover —
|
|
1500
|
+
* best-effort by design (private browsing resets it); the costly LLM path is
|
|
1501
|
+
* additionally capped server-side.
|
|
1502
|
+
*/
|
|
1503
|
+
frequencyCap?: {
|
|
1504
|
+
perSession?: number;
|
|
1505
|
+
perDay?: number;
|
|
1506
|
+
};
|
|
1507
|
+
/** Evaluation tick, ms. Default 1000. Zero network per tick. */
|
|
1508
|
+
tickMs?: number;
|
|
1509
|
+
/** Storage backend for persisted governance state. Default `localStorage`. */
|
|
1510
|
+
storage?: StorageLike;
|
|
1511
|
+
/** Storage key for persisted governance state. Default `"ago_proactive"`. */
|
|
1512
|
+
storageKey?: string;
|
|
1513
|
+
/** Tuning of the signal detectors (rage-click window, throttles…). */
|
|
1514
|
+
signals?: SignalCollectorTuning;
|
|
1515
|
+
/**
|
|
1516
|
+
* Local demos and tests ONLY: bypass the remote kill-switch. When set, the
|
|
1517
|
+
* `GET /config` fetch is skipped and the kill-switch takes this value.
|
|
1518
|
+
* Leave unset in production — the tenant admin controls the feature, and
|
|
1519
|
+
* the evaluate endpoint stays gated server-side regardless.
|
|
1520
|
+
*/
|
|
1521
|
+
enabledOverride?: boolean;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/** A declarative proactive trigger. */
|
|
1525
|
+
export declare interface ProactiveTrigger {
|
|
1526
|
+
/** Stable id, used for cooldowns, dismissal memory, and analytics. */
|
|
1527
|
+
id: string;
|
|
1528
|
+
/** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
|
|
1529
|
+
when: ProactiveTriggerWhen;
|
|
1530
|
+
/**
|
|
1531
|
+
* Min time between two firings of this trigger (persisted across reloads).
|
|
1532
|
+
* A firing is the moment the trigger passes the gates — including an agent
|
|
1533
|
+
* evaluation that decides NOT to intervene, so a persistent condition can't
|
|
1534
|
+
* hammer the evaluate endpoint. Default 60 000.
|
|
1535
|
+
*/
|
|
1536
|
+
cooldownMs?: number;
|
|
1537
|
+
/**
|
|
1538
|
+
* `'agent'` asks the backend's fast-LLM second filter whether (and how) to
|
|
1539
|
+
* intervene; a `static` object shows the given message with no network call.
|
|
1540
|
+
*/
|
|
1541
|
+
intervene: "agent" | {
|
|
1542
|
+
type: "static";
|
|
1543
|
+
message: string;
|
|
1544
|
+
action?: NudgeAction;
|
|
1545
|
+
};
|
|
1546
|
+
/**
|
|
1547
|
+
* What the agent should help with. Sent to the evaluate endpoint, and used to
|
|
1548
|
+
* pre-seed the chat turn when the user accepts the nudge.
|
|
1549
|
+
*/
|
|
1550
|
+
goal?: string;
|
|
1551
|
+
/**
|
|
1552
|
+
* User-voice line used to OPEN the conversation when the user accepts this
|
|
1553
|
+
* nudge and no conversation exists yet — a hidden kickoff cannot start one
|
|
1554
|
+
* (the backend rejects it). Sent as a visible user message, so write it in
|
|
1555
|
+
* the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
|
|
1556
|
+
* already open, the SDK sends a hidden meta kickoff instead and this field
|
|
1557
|
+
* is unused. Without it, accepting with no open conversation skips the chat
|
|
1558
|
+
* pre-seed (the nudge action still runs).
|
|
1559
|
+
*/
|
|
1560
|
+
kickoff?: string;
|
|
1561
|
+
/**
|
|
1562
|
+
* How long a dismissal of this trigger's nudge suppresses it (persisted).
|
|
1563
|
+
* Default 24h.
|
|
1564
|
+
*/
|
|
1565
|
+
resurfaceAfterMs?: number;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
|
|
1570
|
+
* must pass against the current {@link SignalsSnapshot}. Numeric fields are
|
|
1571
|
+
* `>=` thresholds.
|
|
1572
|
+
*/
|
|
1573
|
+
declare interface ProactiveTriggerWhen {
|
|
1574
|
+
/**
|
|
1575
|
+
* Route pattern the current pathname must match. Supports the SDK's route
|
|
1576
|
+
* styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
|
|
1577
|
+
* wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
|
|
1578
|
+
* remaining segments (`/dossier/*`).
|
|
1579
|
+
*/
|
|
1580
|
+
route?: string;
|
|
1581
|
+
/** Min time since the last user activity, ms. */
|
|
1582
|
+
idleMs?: number;
|
|
1583
|
+
/** Min time spent on the current route, ms. */
|
|
1584
|
+
dwellMs?: number;
|
|
1585
|
+
/**
|
|
1586
|
+
* Partial deep match against the registered page state (funnel step,
|
|
1587
|
+
* filters…). Every key present here must deep-match the live value.
|
|
1588
|
+
*/
|
|
1589
|
+
pageState?: Partial<Record<string, unknown>>;
|
|
1590
|
+
/** Min rage-click bursts on the current route. */
|
|
1591
|
+
rageClicks?: number;
|
|
1592
|
+
/** Min A→B→A→B route oscillations this session. */
|
|
1593
|
+
routeBounces?: number;
|
|
1594
|
+
/** Per-field minimum error counts (field NAME → min count). */
|
|
1595
|
+
fieldErrors?: Record<string, number>;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1270
1598
|
/**
|
|
1271
1599
|
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
1272
1600
|
* continuation fires (e.g. wait for the destination page to mount after a
|
|
@@ -1299,6 +1627,54 @@ declare interface SendMessageOptions {
|
|
|
1299
1627
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
1300
1628
|
}
|
|
1301
1629
|
|
|
1630
|
+
/** Tuning knobs for the collector's detectors. All optional. */
|
|
1631
|
+
declare interface SignalCollectorTuning {
|
|
1632
|
+
/** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
|
|
1633
|
+
activityThrottleMs?: number;
|
|
1634
|
+
/** Rage click: clicks needed to count a burst. Default 3. */
|
|
1635
|
+
rageClickCount?: number;
|
|
1636
|
+
/** Rage click: max time between first and last click of a burst, ms. Default 1000. */
|
|
1637
|
+
rageClickWindowMs?: number;
|
|
1638
|
+
/** Rage click: max radius between clicks of a burst, px. Default 24. */
|
|
1639
|
+
rageClickRadiusPx?: number;
|
|
1640
|
+
/** Max routes kept in the recent-route sequence. Default 10. */
|
|
1641
|
+
maxRecentRoutes?: number;
|
|
1642
|
+
/** Max typed signals kept in the ring buffer. Default 50. */
|
|
1643
|
+
maxSignals?: number;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* Aggregated view of the current friction state. Registered as a dynamic
|
|
1648
|
+
* context provider (key `friction_signals`) so it rides along as
|
|
1649
|
+
* `client_context` on every message, and sent as `signals` to the proactive
|
|
1650
|
+
* evaluate endpoint.
|
|
1651
|
+
*/
|
|
1652
|
+
declare interface SignalsSnapshot {
|
|
1653
|
+
/** Current pathname. */
|
|
1654
|
+
route: string;
|
|
1655
|
+
/** Time spent on the current route, ms. */
|
|
1656
|
+
dwellMs: number;
|
|
1657
|
+
/** Time since the last user activity (pointer/key/scroll/touch), ms. */
|
|
1658
|
+
idleMs: number;
|
|
1659
|
+
/** Rage-click bursts detected on the current route. */
|
|
1660
|
+
rageClicks: number;
|
|
1661
|
+
/**
|
|
1662
|
+
* A→B→A→B route oscillations detected in the recent route sequence. Rolling
|
|
1663
|
+
* session counter (cross-route by nature); trigger cooldowns and dismissal
|
|
1664
|
+
* memory keep it from re-firing forever.
|
|
1665
|
+
*/
|
|
1666
|
+
routeBounces: number;
|
|
1667
|
+
/** App-pushed field error counters (field NAME → count), current route only. */
|
|
1668
|
+
fieldErrors: Record<string, number>;
|
|
1669
|
+
/** Most recent pathnames, oldest first (bounded). */
|
|
1670
|
+
recentRoutes: string[];
|
|
1671
|
+
/**
|
|
1672
|
+
* Merged `AgoStateControl.get()` snapshot of the registered page-state
|
|
1673
|
+
* controls (funnel step, filters…), or `null` when none are registered.
|
|
1674
|
+
*/
|
|
1675
|
+
pageState: Record<string, unknown> | null;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1302
1678
|
/**
|
|
1303
1679
|
* SSE stream chunk data
|
|
1304
1680
|
*/
|
|
@@ -1342,6 +1718,9 @@ declare interface SSEChunkData {
|
|
|
1342
1718
|
waiting_tool_call_ids?: string[];
|
|
1343
1719
|
}
|
|
1344
1720
|
|
|
1721
|
+
/** The slice of the Web Storage API that {@link createStore} relies on. */
|
|
1722
|
+
declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
|
|
1723
|
+
|
|
1345
1724
|
/**
|
|
1346
1725
|
* A minimal observable store: one value, synchronous subscriptions, and
|
|
1347
1726
|
* optional persistence via {@link PersistOptions} (localStorage by default).
|
|
@@ -1451,6 +1830,20 @@ export declare function useAgo(config: UseAgoOptions | null): {
|
|
|
1451
1830
|
*/
|
|
1452
1831
|
export declare function useAgoActivity(options?: UseAgoActivityOptions): UseAgoActivityResult;
|
|
1453
1832
|
|
|
1833
|
+
/** Recent user + agent activity, kept in sync with the client's ledger. */
|
|
1834
|
+
export declare function useAgoActivityLog(options?: UseAgoActivityLogOptions): UseAgoActivityLogResult;
|
|
1835
|
+
|
|
1836
|
+
export declare interface UseAgoActivityLogOptions {
|
|
1837
|
+
client?: AgoClient;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
export declare interface UseAgoActivityLogResult {
|
|
1841
|
+
entries: ActivityEntry[];
|
|
1842
|
+
latest?: ActivityEntry;
|
|
1843
|
+
record: (entry: ActivityInput) => void;
|
|
1844
|
+
clear: () => void;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1454
1847
|
export declare interface UseAgoActivityOptions {
|
|
1455
1848
|
/** The AGO client. If omitted, reads from AgoProvider context. */
|
|
1456
1849
|
client?: AgoClient;
|
|
@@ -1816,4 +2209,41 @@ export declare interface UseMessagesResult {
|
|
|
1816
2209
|
*/
|
|
1817
2210
|
export declare function useOptionalAgoClient(): AgoClient | null;
|
|
1818
2211
|
|
|
2212
|
+
/**
|
|
2213
|
+
* Consume proactive nudges (see `createAgoProactive` / `AgoConfig.proactive`).
|
|
2214
|
+
* Receiving a nudge marks it as shown (impression tracking + frequency caps),
|
|
2215
|
+
* so only render ONE consumer of this hook per nudge surface — or use the
|
|
2216
|
+
* prebuilt `<AgoNudge />`.
|
|
2217
|
+
*
|
|
2218
|
+
* ```tsx
|
|
2219
|
+
* const { nudge, accept, dismiss } = useProactiveNudge({
|
|
2220
|
+
* onExpand: () => setChatOpen(true),
|
|
2221
|
+
* });
|
|
2222
|
+
* if (!nudge) return null;
|
|
2223
|
+
* return <MyToast text={nudge.message} onAccept={accept} onClose={dismiss} />;
|
|
2224
|
+
* ```
|
|
2225
|
+
*/
|
|
2226
|
+
export declare function useProactiveNudge(options?: UseProactiveNudgeOptions): UseProactiveNudgeResult;
|
|
2227
|
+
|
|
2228
|
+
export declare interface UseProactiveNudgeOptions {
|
|
2229
|
+
/** The AGO client instance. If omitted, reads from AgoProvider context. */
|
|
2230
|
+
client?: AgoClient;
|
|
2231
|
+
/**
|
|
2232
|
+
* Called after `accept()` when the nudge should expand into the chat (it
|
|
2233
|
+
* came from `intervene: 'agent'` or carries a `goal`). The SDK has already
|
|
2234
|
+
* pre-seeded the conversation with a hidden kickoff message at this point;
|
|
2235
|
+
* use this to open your chat UI (widget, panel…).
|
|
2236
|
+
*/
|
|
2237
|
+
onExpand?: (nudge: ProactiveNudgeInstance) => void;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
export declare interface UseProactiveNudgeResult {
|
|
2241
|
+
/** The active nudge, or `null` when none is ready. */
|
|
2242
|
+
nudge: ProactiveNudgeInstance | null;
|
|
2243
|
+
/** Accept the nudge: run its action, seed the chat when relevant, clear it. */
|
|
2244
|
+
accept: () => Promise<void>;
|
|
2245
|
+
/** Dismiss the nudge (suppresses its trigger, see the governor). */
|
|
2246
|
+
dismiss: () => void;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
1819
2249
|
export { }
|