@useago/sdk 1.5.2 → 1.5.3
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/dist/AgoClient-BGkFSNZF.cjs +8 -0
- package/dist/AgoClient-CW-BLT1_.js +1542 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +311 -0
- package/dist/angular.d.ts +311 -0
- package/dist/angular.js +2 -2
- package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
- package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-C7cnnWKW.js} +3 -3
- package/dist/createFormCollector-iCDwAwYJ.js +279 -0
- package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
- package/dist/createMockClient-Br0TWgLO.js +97 -0
- package/dist/createMockClient-BwNLPjeT.cjs +1 -0
- package/dist/devtools.d.cts +311 -0
- package/dist/devtools.d.ts +311 -0
- package/dist/functions-IGSjjvF4.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +510 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +95 -90
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +375 -0
- package/dist/react.d.ts +375 -0
- package/dist/react.js +559 -422
- package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +311 -0
- package/dist/testing.d.ts +311 -0
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +332 -0
- package/dist/vue.d.ts +332 -0
- package/dist/vue.js +133 -110
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +308 -0
- package/dist/widget.d.ts +308 -0
- package/dist/widget.js +7 -7
- 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/functions-CPs7omgM.cjs +0 -1
- /package/dist/{autoContinue-CP9pJR-V.cjs → autoContinue-CcCTva-D.cjs} +0 -0
- /package/dist/{autoContinue-CC8K9mBU.js → autoContinue-D3Mmaaca.js} +0 -0
- /package/dist/{functions-tzyOZNp6.js → functions-CApuQZ2b.js} +0 -0
package/dist/react.d.ts
CHANGED
|
@@ -104,6 +104,12 @@ declare class AgoClient {
|
|
|
104
104
|
private pendingApprovals;
|
|
105
105
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
106
106
|
private resumeGate;
|
|
107
|
+
/**
|
|
108
|
+
* Proactive-mode controller, set when the client was created with
|
|
109
|
+
* `proactive` options or when `createAgoProactive(client, opts)` was called.
|
|
110
|
+
* `null` otherwise.
|
|
111
|
+
*/
|
|
112
|
+
proactive: ProactiveController | null;
|
|
107
113
|
constructor(config: AgoConfig);
|
|
108
114
|
/**
|
|
109
115
|
* Send a message and receive a streaming response
|
|
@@ -274,6 +280,14 @@ declare class AgoClient {
|
|
|
274
280
|
* Get all registered function schemas
|
|
275
281
|
*/
|
|
276
282
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
283
|
+
/**
|
|
284
|
+
* Execute a registered client function locally, through the same
|
|
285
|
+
* FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
|
|
286
|
+
* calls. Used by proactive nudge actions, where the user's explicit click on
|
|
287
|
+
* the action button constitutes the approval — nothing is submitted to the
|
|
288
|
+
* backend (there is no tool call to answer).
|
|
289
|
+
*/
|
|
290
|
+
executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
277
291
|
/**
|
|
278
292
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
279
293
|
*
|
|
@@ -375,6 +389,9 @@ declare class AgoClient {
|
|
|
375
389
|
*/
|
|
376
390
|
notifyContextChanged(): void;
|
|
377
391
|
/* Excluded from this release type: emitFormEvent */
|
|
392
|
+
/* Excluded from this release type: emitProactiveEvent */
|
|
393
|
+
/* Excluded from this release type: getHttp */
|
|
394
|
+
/* Excluded from this release type: getConfiguredAgent */
|
|
378
395
|
/**
|
|
379
396
|
* Enable automatic capture of the current browser page (URL + title).
|
|
380
397
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -419,6 +436,7 @@ declare class AgoClient {
|
|
|
419
436
|
* Clean up resources
|
|
420
437
|
*/
|
|
421
438
|
destroy(): void;
|
|
439
|
+
/* Excluded from this release type: reviveAfterDestroy */
|
|
422
440
|
}
|
|
423
441
|
|
|
424
442
|
/**
|
|
@@ -535,6 +553,25 @@ declare interface AgoClientEvents {
|
|
|
535
553
|
"connection:status": {
|
|
536
554
|
connected: boolean;
|
|
537
555
|
};
|
|
556
|
+
/**
|
|
557
|
+
* A proactive nudge passed every governor gate and is ready to display.
|
|
558
|
+
* `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
|
|
559
|
+
* `client.proactive.shown(nudge)` when they render it (impression tracking
|
|
560
|
+
* + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
|
|
561
|
+
*/
|
|
562
|
+
"nudge:ready": ProactiveNudgeInstance;
|
|
563
|
+
/** A nudge was displayed to the user (fires once per nudge). */
|
|
564
|
+
"nudge:shown": {
|
|
565
|
+
nudge: ProactiveNudgeInstance;
|
|
566
|
+
};
|
|
567
|
+
/** The user dismissed the nudge (its trigger is suppressed, see governor). */
|
|
568
|
+
"nudge:dismissed": {
|
|
569
|
+
nudge: ProactiveNudgeInstance;
|
|
570
|
+
};
|
|
571
|
+
/** The user accepted the nudge (its action ran / the chat is being seeded). */
|
|
572
|
+
"nudge:accepted": {
|
|
573
|
+
nudge: ProactiveNudgeInstance;
|
|
574
|
+
};
|
|
538
575
|
}
|
|
539
576
|
|
|
540
577
|
/**
|
|
@@ -596,6 +633,16 @@ export declare interface AgoConfig {
|
|
|
596
633
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
597
634
|
*/
|
|
598
635
|
maxFunctionResultBytes?: number;
|
|
636
|
+
/**
|
|
637
|
+
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
638
|
+
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
639
|
+
* that can surface a nudge before the user opens the chat. Equivalent to
|
|
640
|
+
* calling `createAgoProactive(client, proactive)` — the resulting controller
|
|
641
|
+
* is available as `client.proactive`. Requires the tenant-level kill-switch
|
|
642
|
+
* (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
|
|
643
|
+
* default otherwise.
|
|
644
|
+
*/
|
|
645
|
+
proactive?: ProactiveOptions;
|
|
599
646
|
}
|
|
600
647
|
|
|
601
648
|
/**
|
|
@@ -639,6 +686,33 @@ export declare interface AgoMessage {
|
|
|
639
686
|
createdAt: Date;
|
|
640
687
|
}
|
|
641
688
|
|
|
689
|
+
/**
|
|
690
|
+
* Prebuilt proactive-nudge toast: a small, always-dismissable bubble anchored
|
|
691
|
+
* near the chat launcher. Never modal — it never blocks the page. Renders the
|
|
692
|
+
* nudge message, its optional action button, and an "open chat" affordance
|
|
693
|
+
* for nudges that expand into a conversation.
|
|
694
|
+
*/
|
|
695
|
+
export declare const AgoNudge: default_2.FC<AgoNudgeProps>;
|
|
696
|
+
|
|
697
|
+
export declare interface AgoNudgeProps {
|
|
698
|
+
/** The AGO client instance. If omitted, reads from AgoProvider context. */
|
|
699
|
+
client?: AgoClient;
|
|
700
|
+
/**
|
|
701
|
+
* Called after accepting a nudge that expands into the chat (agent-sourced
|
|
702
|
+
* or with a `goal`) — open your chat UI here. The conversation is already
|
|
703
|
+
* pre-seeded with a hidden kickoff message.
|
|
704
|
+
*/
|
|
705
|
+
onExpand?: UseProactiveNudgeOptions["onExpand"];
|
|
706
|
+
/** Auto-dismiss after this many ms. Off by default (nudges stay until acted on). */
|
|
707
|
+
autoHideMs?: number;
|
|
708
|
+
/** Corner to anchor to (near the chat launcher). Default `"bottom-right"`. */
|
|
709
|
+
position?: "bottom-right" | "bottom-left";
|
|
710
|
+
/** Label of the open-chat affordance. Default `"Open chat"`. */
|
|
711
|
+
openChatLabel?: string;
|
|
712
|
+
/** Additional CSS class (consumer hook only; the SDK ships no CSS for it). */
|
|
713
|
+
className?: string;
|
|
714
|
+
}
|
|
715
|
+
|
|
642
716
|
/**
|
|
643
717
|
* Options for {@link AgoClient.registerPageStateFunction}.
|
|
644
718
|
*/
|
|
@@ -1173,6 +1247,43 @@ export declare interface FormSubmitResult {
|
|
|
1173
1247
|
error?: string;
|
|
1174
1248
|
}
|
|
1175
1249
|
|
|
1250
|
+
/**
|
|
1251
|
+
* HTTP client with authentication headers
|
|
1252
|
+
*/
|
|
1253
|
+
declare class HttpClient {
|
|
1254
|
+
private baseUrl;
|
|
1255
|
+
private headers;
|
|
1256
|
+
constructor(config: AgoConfig);
|
|
1257
|
+
/**
|
|
1258
|
+
* Update configuration (e.g., JWT token)
|
|
1259
|
+
*/
|
|
1260
|
+
updateConfig(config: Partial<AgoConfig>): void;
|
|
1261
|
+
/**
|
|
1262
|
+
* Make a GET request
|
|
1263
|
+
*/
|
|
1264
|
+
get<T>(path: string): Promise<T>;
|
|
1265
|
+
/**
|
|
1266
|
+
* Make a POST request with JSON body.
|
|
1267
|
+
*
|
|
1268
|
+
* `keepalive: true` lets the request survive a page unload (used by the
|
|
1269
|
+
* proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
|
|
1270
|
+
* headers, so it's a keepalive fetch instead).
|
|
1271
|
+
*/
|
|
1272
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
1273
|
+
keepalive?: boolean;
|
|
1274
|
+
}): Promise<T>;
|
|
1275
|
+
/**
|
|
1276
|
+
* Make a POST request and return the raw Response (for streaming)
|
|
1277
|
+
*/
|
|
1278
|
+
postStream(path: string, body?: unknown): Promise<Response>;
|
|
1279
|
+
/**
|
|
1280
|
+
* Make a POST request with FormData (for file uploads)
|
|
1281
|
+
*/
|
|
1282
|
+
postFormData(path: string, formData: FormData): Promise<Response>;
|
|
1283
|
+
private request;
|
|
1284
|
+
private handleErrorResponse;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1176
1287
|
/**
|
|
1177
1288
|
* Async sibling of {@link createFormCollector} that pulls the form's definition
|
|
1178
1289
|
* (description + schema + submit target) from the backend by name — the single
|
|
@@ -1267,6 +1378,182 @@ declare interface MockAgoClientOptions {
|
|
|
1267
1378
|
|
|
1268
1379
|
declare type MockFn = (...args: any[]) => any;
|
|
1269
1380
|
|
|
1381
|
+
/**
|
|
1382
|
+
* Optional action attached to a nudge. Accepting a `functionName` action
|
|
1383
|
+
* executes the registered client function (same `FunctionRegistry` path as
|
|
1384
|
+
* agent-invoked calls); `setPageState` applies values through the registered
|
|
1385
|
+
* page-state controls.
|
|
1386
|
+
*/
|
|
1387
|
+
export declare type NudgeAction = {
|
|
1388
|
+
label: string;
|
|
1389
|
+
functionName: string;
|
|
1390
|
+
arguments?: Record<string, unknown>;
|
|
1391
|
+
} | {
|
|
1392
|
+
label: string;
|
|
1393
|
+
setPageState: Record<string, unknown>;
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* Controller returned by {@link createAgoProactive} (also available as
|
|
1398
|
+
* `client.proactive`).
|
|
1399
|
+
*/
|
|
1400
|
+
export declare interface ProactiveController {
|
|
1401
|
+
/** Persistently opt this browser out of proactive nudges. */
|
|
1402
|
+
optOut(): void;
|
|
1403
|
+
/** Undo {@link optOut}. */
|
|
1404
|
+
optIn(): void;
|
|
1405
|
+
isOptedOut(): boolean;
|
|
1406
|
+
/**
|
|
1407
|
+
* Tell the governor the user is already engaged (e.g. the chat widget is
|
|
1408
|
+
* open) — nudges are suppressed while `true`. Call from the UI layer.
|
|
1409
|
+
*/
|
|
1410
|
+
setEngaged(engaged: boolean): void;
|
|
1411
|
+
/** App-pushed field error counter (field NAME only — never values). */
|
|
1412
|
+
signalFieldError(fieldName: string): void;
|
|
1413
|
+
/** Current aggregated friction snapshot. */
|
|
1414
|
+
getSignalsSnapshot(): SignalsSnapshot;
|
|
1415
|
+
/** The nudge currently occupying the single-nudge slot, if any. */
|
|
1416
|
+
getActiveNudge(): ProactiveNudgeInstance | null;
|
|
1417
|
+
/**
|
|
1418
|
+
* Mark the nudge as displayed. Idempotent per nudge; counts it against the
|
|
1419
|
+
* frequency caps, tracks the impression, and emits `nudge:shown`.
|
|
1420
|
+
*/
|
|
1421
|
+
shown(nudge: ProactiveNudgeInstance): void;
|
|
1422
|
+
/**
|
|
1423
|
+
* Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
|
|
1424
|
+
* and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
|
|
1425
|
+
* hidden kickoff message so the agent starts the turn with full context.
|
|
1426
|
+
*/
|
|
1427
|
+
accept(nudge: ProactiveNudgeInstance): Promise<void>;
|
|
1428
|
+
/** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
|
|
1429
|
+
dismiss(nudge: ProactiveNudgeInstance): void;
|
|
1430
|
+
/** Report a downstream conversion attributable to the nudge (analytics only). */
|
|
1431
|
+
markConverted(nudge: ProactiveNudgeInstance): void;
|
|
1432
|
+
/** Detach everything: listeners, timers, context provider, event flush. */
|
|
1433
|
+
destroy(): void;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
|
|
1437
|
+
export declare interface ProactiveNudgeInstance {
|
|
1438
|
+
/** Client-generated uuid for this nudge instance (`client_nudge_id`). */
|
|
1439
|
+
id: string;
|
|
1440
|
+
triggerId: string;
|
|
1441
|
+
/** `static` = configured message; `agent` = backend LLM evaluation. */
|
|
1442
|
+
source: "static" | "agent";
|
|
1443
|
+
message: string;
|
|
1444
|
+
action?: NudgeAction;
|
|
1445
|
+
goal?: string;
|
|
1446
|
+
/** See {@link ProactiveTrigger.kickoff}. */
|
|
1447
|
+
kickoff?: string;
|
|
1448
|
+
createdAt: Date;
|
|
1449
|
+
/** Server-side nudge id (agent nudges only). */
|
|
1450
|
+
serverNudgeId?: string;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
|
|
1454
|
+
export declare interface ProactiveOptions {
|
|
1455
|
+
triggers: ProactiveTrigger[];
|
|
1456
|
+
/**
|
|
1457
|
+
* Global caps on nudges actually shown. `perSession` is in-memory (page
|
|
1458
|
+
* lifetime); `perDay` is persisted in localStorage with a date rollover —
|
|
1459
|
+
* best-effort by design (private browsing resets it); the costly LLM path is
|
|
1460
|
+
* additionally capped server-side.
|
|
1461
|
+
*/
|
|
1462
|
+
frequencyCap?: {
|
|
1463
|
+
perSession?: number;
|
|
1464
|
+
perDay?: number;
|
|
1465
|
+
};
|
|
1466
|
+
/** Evaluation tick, ms. Default 1000. Zero network per tick. */
|
|
1467
|
+
tickMs?: number;
|
|
1468
|
+
/** Storage backend for persisted governance state. Default `localStorage`. */
|
|
1469
|
+
storage?: StorageLike;
|
|
1470
|
+
/** Storage key for persisted governance state. Default `"ago_proactive"`. */
|
|
1471
|
+
storageKey?: string;
|
|
1472
|
+
/** Tuning of the signal detectors (rage-click window, throttles…). */
|
|
1473
|
+
signals?: SignalCollectorTuning;
|
|
1474
|
+
/**
|
|
1475
|
+
* Local demos and tests ONLY: bypass the remote kill-switch. When set, the
|
|
1476
|
+
* `GET /config` fetch is skipped and the kill-switch takes this value.
|
|
1477
|
+
* Leave unset in production — the tenant admin controls the feature, and
|
|
1478
|
+
* the evaluate endpoint stays gated server-side regardless.
|
|
1479
|
+
*/
|
|
1480
|
+
enabledOverride?: boolean;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
/** A declarative proactive trigger. */
|
|
1484
|
+
export declare interface ProactiveTrigger {
|
|
1485
|
+
/** Stable id, used for cooldowns, dismissal memory, and analytics. */
|
|
1486
|
+
id: string;
|
|
1487
|
+
/** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
|
|
1488
|
+
when: ProactiveTriggerWhen;
|
|
1489
|
+
/**
|
|
1490
|
+
* Min time between two firings of this trigger (persisted across reloads).
|
|
1491
|
+
* A firing is the moment the trigger passes the gates — including an agent
|
|
1492
|
+
* evaluation that decides NOT to intervene, so a persistent condition can't
|
|
1493
|
+
* hammer the evaluate endpoint. Default 60 000.
|
|
1494
|
+
*/
|
|
1495
|
+
cooldownMs?: number;
|
|
1496
|
+
/**
|
|
1497
|
+
* `'agent'` asks the backend's fast-LLM second filter whether (and how) to
|
|
1498
|
+
* intervene; a `static` object shows the given message with no network call.
|
|
1499
|
+
*/
|
|
1500
|
+
intervene: "agent" | {
|
|
1501
|
+
type: "static";
|
|
1502
|
+
message: string;
|
|
1503
|
+
action?: NudgeAction;
|
|
1504
|
+
};
|
|
1505
|
+
/**
|
|
1506
|
+
* What the agent should help with. Sent to the evaluate endpoint, and used to
|
|
1507
|
+
* pre-seed the chat turn when the user accepts the nudge.
|
|
1508
|
+
*/
|
|
1509
|
+
goal?: string;
|
|
1510
|
+
/**
|
|
1511
|
+
* User-voice line used to OPEN the conversation when the user accepts this
|
|
1512
|
+
* nudge and no conversation exists yet — a hidden kickoff cannot start one
|
|
1513
|
+
* (the backend rejects it). Sent as a visible user message, so write it in
|
|
1514
|
+
* the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
|
|
1515
|
+
* already open, the SDK sends a hidden meta kickoff instead and this field
|
|
1516
|
+
* is unused. Without it, accepting with no open conversation skips the chat
|
|
1517
|
+
* pre-seed (the nudge action still runs).
|
|
1518
|
+
*/
|
|
1519
|
+
kickoff?: string;
|
|
1520
|
+
/**
|
|
1521
|
+
* How long a dismissal of this trigger's nudge suppresses it (persisted).
|
|
1522
|
+
* Default 24h.
|
|
1523
|
+
*/
|
|
1524
|
+
resurfaceAfterMs?: number;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
|
|
1529
|
+
* must pass against the current {@link SignalsSnapshot}. Numeric fields are
|
|
1530
|
+
* `>=` thresholds.
|
|
1531
|
+
*/
|
|
1532
|
+
declare interface ProactiveTriggerWhen {
|
|
1533
|
+
/**
|
|
1534
|
+
* Route pattern the current pathname must match. Supports the SDK's route
|
|
1535
|
+
* styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
|
|
1536
|
+
* wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
|
|
1537
|
+
* remaining segments (`/dossier/*`).
|
|
1538
|
+
*/
|
|
1539
|
+
route?: string;
|
|
1540
|
+
/** Min time since the last user activity, ms. */
|
|
1541
|
+
idleMs?: number;
|
|
1542
|
+
/** Min time spent on the current route, ms. */
|
|
1543
|
+
dwellMs?: number;
|
|
1544
|
+
/**
|
|
1545
|
+
* Partial deep match against the registered page state (funnel step,
|
|
1546
|
+
* filters…). Every key present here must deep-match the live value.
|
|
1547
|
+
*/
|
|
1548
|
+
pageState?: Partial<Record<string, unknown>>;
|
|
1549
|
+
/** Min rage-click bursts on the current route. */
|
|
1550
|
+
rageClicks?: number;
|
|
1551
|
+
/** Min A→B→A→B route oscillations this session. */
|
|
1552
|
+
routeBounces?: number;
|
|
1553
|
+
/** Per-field minimum error counts (field NAME → min count). */
|
|
1554
|
+
fieldErrors?: Record<string, number>;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1270
1557
|
/**
|
|
1271
1558
|
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
1272
1559
|
* continuation fires (e.g. wait for the destination page to mount after a
|
|
@@ -1299,6 +1586,54 @@ declare interface SendMessageOptions {
|
|
|
1299
1586
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
1300
1587
|
}
|
|
1301
1588
|
|
|
1589
|
+
/** Tuning knobs for the collector's detectors. All optional. */
|
|
1590
|
+
declare interface SignalCollectorTuning {
|
|
1591
|
+
/** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
|
|
1592
|
+
activityThrottleMs?: number;
|
|
1593
|
+
/** Rage click: clicks needed to count a burst. Default 3. */
|
|
1594
|
+
rageClickCount?: number;
|
|
1595
|
+
/** Rage click: max time between first and last click of a burst, ms. Default 1000. */
|
|
1596
|
+
rageClickWindowMs?: number;
|
|
1597
|
+
/** Rage click: max radius between clicks of a burst, px. Default 24. */
|
|
1598
|
+
rageClickRadiusPx?: number;
|
|
1599
|
+
/** Max routes kept in the recent-route sequence. Default 10. */
|
|
1600
|
+
maxRecentRoutes?: number;
|
|
1601
|
+
/** Max typed signals kept in the ring buffer. Default 50. */
|
|
1602
|
+
maxSignals?: number;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Aggregated view of the current friction state. Registered as a dynamic
|
|
1607
|
+
* context provider (key `friction_signals`) so it rides along as
|
|
1608
|
+
* `client_context` on every message, and sent as `signals` to the proactive
|
|
1609
|
+
* evaluate endpoint.
|
|
1610
|
+
*/
|
|
1611
|
+
declare interface SignalsSnapshot {
|
|
1612
|
+
/** Current pathname. */
|
|
1613
|
+
route: string;
|
|
1614
|
+
/** Time spent on the current route, ms. */
|
|
1615
|
+
dwellMs: number;
|
|
1616
|
+
/** Time since the last user activity (pointer/key/scroll/touch), ms. */
|
|
1617
|
+
idleMs: number;
|
|
1618
|
+
/** Rage-click bursts detected on the current route. */
|
|
1619
|
+
rageClicks: number;
|
|
1620
|
+
/**
|
|
1621
|
+
* A→B→A→B route oscillations detected in the recent route sequence. Rolling
|
|
1622
|
+
* session counter (cross-route by nature); trigger cooldowns and dismissal
|
|
1623
|
+
* memory keep it from re-firing forever.
|
|
1624
|
+
*/
|
|
1625
|
+
routeBounces: number;
|
|
1626
|
+
/** App-pushed field error counters (field NAME → count), current route only. */
|
|
1627
|
+
fieldErrors: Record<string, number>;
|
|
1628
|
+
/** Most recent pathnames, oldest first (bounded). */
|
|
1629
|
+
recentRoutes: string[];
|
|
1630
|
+
/**
|
|
1631
|
+
* Merged `AgoStateControl.get()` snapshot of the registered page-state
|
|
1632
|
+
* controls (funnel step, filters…), or `null` when none are registered.
|
|
1633
|
+
*/
|
|
1634
|
+
pageState: Record<string, unknown> | null;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1302
1637
|
/**
|
|
1303
1638
|
* SSE stream chunk data
|
|
1304
1639
|
*/
|
|
@@ -1342,6 +1677,9 @@ declare interface SSEChunkData {
|
|
|
1342
1677
|
waiting_tool_call_ids?: string[];
|
|
1343
1678
|
}
|
|
1344
1679
|
|
|
1680
|
+
/** The slice of the Web Storage API that {@link createStore} relies on. */
|
|
1681
|
+
declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
|
|
1682
|
+
|
|
1345
1683
|
/**
|
|
1346
1684
|
* A minimal observable store: one value, synchronous subscriptions, and
|
|
1347
1685
|
* optional persistence via {@link PersistOptions} (localStorage by default).
|
|
@@ -1816,4 +2154,41 @@ export declare interface UseMessagesResult {
|
|
|
1816
2154
|
*/
|
|
1817
2155
|
export declare function useOptionalAgoClient(): AgoClient | null;
|
|
1818
2156
|
|
|
2157
|
+
/**
|
|
2158
|
+
* Consume proactive nudges (see `createAgoProactive` / `AgoConfig.proactive`).
|
|
2159
|
+
* Receiving a nudge marks it as shown (impression tracking + frequency caps),
|
|
2160
|
+
* so only render ONE consumer of this hook per nudge surface — or use the
|
|
2161
|
+
* prebuilt `<AgoNudge />`.
|
|
2162
|
+
*
|
|
2163
|
+
* ```tsx
|
|
2164
|
+
* const { nudge, accept, dismiss } = useProactiveNudge({
|
|
2165
|
+
* onExpand: () => setChatOpen(true),
|
|
2166
|
+
* });
|
|
2167
|
+
* if (!nudge) return null;
|
|
2168
|
+
* return <MyToast text={nudge.message} onAccept={accept} onClose={dismiss} />;
|
|
2169
|
+
* ```
|
|
2170
|
+
*/
|
|
2171
|
+
export declare function useProactiveNudge(options?: UseProactiveNudgeOptions): UseProactiveNudgeResult;
|
|
2172
|
+
|
|
2173
|
+
export declare interface UseProactiveNudgeOptions {
|
|
2174
|
+
/** The AGO client instance. If omitted, reads from AgoProvider context. */
|
|
2175
|
+
client?: AgoClient;
|
|
2176
|
+
/**
|
|
2177
|
+
* Called after `accept()` when the nudge should expand into the chat (it
|
|
2178
|
+
* came from `intervene: 'agent'` or carries a `goal`). The SDK has already
|
|
2179
|
+
* pre-seeded the conversation with a hidden kickoff message at this point;
|
|
2180
|
+
* use this to open your chat UI (widget, panel…).
|
|
2181
|
+
*/
|
|
2182
|
+
onExpand?: (nudge: ProactiveNudgeInstance) => void;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
export declare interface UseProactiveNudgeResult {
|
|
2186
|
+
/** The active nudge, or `null` when none is ready. */
|
|
2187
|
+
nudge: ProactiveNudgeInstance | null;
|
|
2188
|
+
/** Accept the nudge: run its action, seed the chat when relevant, clear it. */
|
|
2189
|
+
accept: () => Promise<void>;
|
|
2190
|
+
/** Dismiss the nudge (suppresses its trigger, see the governor). */
|
|
2191
|
+
dismiss: () => void;
|
|
2192
|
+
}
|
|
2193
|
+
|
|
1819
2194
|
export { }
|