@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/testing.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-Dw-cyISN.cjs");exports.createMockClient=e.createMockClient;
|
package/dist/testing.d.cts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
declare interface ActivityEntry {
|
|
2
|
+
ts: number;
|
|
3
|
+
actor: "user" | "agent";
|
|
4
|
+
name: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare interface ActivityInput {
|
|
10
|
+
actor?: "user" | "agent";
|
|
11
|
+
name: string;
|
|
12
|
+
summary: string;
|
|
13
|
+
data?: Record<string, unknown>;
|
|
14
|
+
ts?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
/**
|
|
2
18
|
* Agent information
|
|
3
19
|
*/
|
|
@@ -36,6 +52,8 @@ declare class AgoClient {
|
|
|
36
52
|
private functionRegistry;
|
|
37
53
|
private contextRegistry;
|
|
38
54
|
private eventEmitter;
|
|
55
|
+
private activityLedger;
|
|
56
|
+
private lastSentPageState;
|
|
39
57
|
private config;
|
|
40
58
|
/** Conversations already warned about an empty reply (one warning each). */
|
|
41
59
|
private warnedEmptyConversations;
|
|
@@ -49,6 +67,12 @@ declare class AgoClient {
|
|
|
49
67
|
private pendingApprovals;
|
|
50
68
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
51
69
|
private resumeGate;
|
|
70
|
+
/**
|
|
71
|
+
* Proactive-mode controller, set when the client was created with
|
|
72
|
+
* `proactive` options or when `createAgoProactive(client, opts)` was called.
|
|
73
|
+
* `null` otherwise.
|
|
74
|
+
*/
|
|
75
|
+
proactive: ProactiveController | null;
|
|
52
76
|
constructor(config: AgoConfig);
|
|
53
77
|
/**
|
|
54
78
|
* Send a message and receive a streaming response
|
|
@@ -219,6 +243,14 @@ declare class AgoClient {
|
|
|
219
243
|
* Get all registered function schemas
|
|
220
244
|
*/
|
|
221
245
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
246
|
+
/**
|
|
247
|
+
* Execute a registered client function locally, through the same
|
|
248
|
+
* FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
|
|
249
|
+
* calls. Used by proactive nudge actions, where the user's explicit click on
|
|
250
|
+
* the action button constitutes the approval — nothing is submitted to the
|
|
251
|
+
* backend (there is no tool call to answer).
|
|
252
|
+
*/
|
|
253
|
+
executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
222
254
|
/**
|
|
223
255
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
224
256
|
*
|
|
@@ -320,6 +352,9 @@ declare class AgoClient {
|
|
|
320
352
|
*/
|
|
321
353
|
notifyContextChanged(): void;
|
|
322
354
|
/* Excluded from this release type: emitFormEvent */
|
|
355
|
+
/* Excluded from this release type: emitProactiveEvent */
|
|
356
|
+
/* Excluded from this release type: getHttp */
|
|
357
|
+
/* Excluded from this release type: getConfiguredAgent */
|
|
323
358
|
/**
|
|
324
359
|
* Enable automatic capture of the current browser page (URL + title).
|
|
325
360
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -329,6 +364,19 @@ declare class AgoClient {
|
|
|
329
364
|
* Get the current context snapshot.
|
|
330
365
|
*/
|
|
331
366
|
getContextSnapshot(): ContextSnapshot | null;
|
|
367
|
+
private buildSendContext;
|
|
368
|
+
/**
|
|
369
|
+
* Record something the user just did so the agent is aware of it on the next
|
|
370
|
+
* message. `actor` defaults to `"user"`. Keep `summary` short and high-signal
|
|
371
|
+
* (no raw payloads, secrets, or PII).
|
|
372
|
+
*/
|
|
373
|
+
recordActivity(entry: ActivityInput): void;
|
|
374
|
+
/** Recent user + agent actions, oldest first (a copy). */
|
|
375
|
+
getRecentActivity(): ActivityEntry[];
|
|
376
|
+
clearActivity(): void;
|
|
377
|
+
private addActivity;
|
|
378
|
+
private recordAgentAction;
|
|
379
|
+
private registerActivityContext;
|
|
332
380
|
/**
|
|
333
381
|
* Subscribe to an event
|
|
334
382
|
*/
|
|
@@ -364,6 +412,7 @@ declare class AgoClient {
|
|
|
364
412
|
* Clean up resources
|
|
365
413
|
*/
|
|
366
414
|
destroy(): void;
|
|
415
|
+
/* Excluded from this release type: reviveAfterDestroy */
|
|
367
416
|
}
|
|
368
417
|
|
|
369
418
|
/**
|
|
@@ -480,6 +529,27 @@ declare interface AgoClientEvents {
|
|
|
480
529
|
"connection:status": {
|
|
481
530
|
connected: boolean;
|
|
482
531
|
};
|
|
532
|
+
/**
|
|
533
|
+
* A proactive nudge passed every governor gate and is ready to display.
|
|
534
|
+
* `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
|
|
535
|
+
* `client.proactive.shown(nudge)` when they render it (impression tracking
|
|
536
|
+
* + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
|
|
537
|
+
*/
|
|
538
|
+
"nudge:ready": ProactiveNudgeInstance;
|
|
539
|
+
/** A nudge was displayed to the user (fires once per nudge). */
|
|
540
|
+
"nudge:shown": {
|
|
541
|
+
nudge: ProactiveNudgeInstance;
|
|
542
|
+
};
|
|
543
|
+
/** The user dismissed the nudge (its trigger is suppressed, see governor). */
|
|
544
|
+
"nudge:dismissed": {
|
|
545
|
+
nudge: ProactiveNudgeInstance;
|
|
546
|
+
};
|
|
547
|
+
/** The user accepted the nudge (its action ran / the chat is being seeded). */
|
|
548
|
+
"nudge:accepted": {
|
|
549
|
+
nudge: ProactiveNudgeInstance;
|
|
550
|
+
};
|
|
551
|
+
/** A user- or agent-action was recorded into the activity ledger. */
|
|
552
|
+
"activity:recorded": ActivityEntry;
|
|
483
553
|
}
|
|
484
554
|
|
|
485
555
|
/**
|
|
@@ -541,6 +611,24 @@ declare interface AgoConfig {
|
|
|
541
611
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
542
612
|
*/
|
|
543
613
|
maxFunctionResultBytes?: number;
|
|
614
|
+
/**
|
|
615
|
+
* Max number of recent actions kept in the in-memory activity ledger that
|
|
616
|
+
* rides along as the `activity:recent` context entry. Older entries drop
|
|
617
|
+
* first. Default `10`. Larger values give the agent more history at the cost
|
|
618
|
+
* of tokens on every message. Each entry's `data` is also size-clamped (long
|
|
619
|
+
* strings truncated, large arrays capped) so one event can't bloat the context.
|
|
620
|
+
*/
|
|
621
|
+
maxActivityEntries?: number;
|
|
622
|
+
/**
|
|
623
|
+
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
624
|
+
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
625
|
+
* that can surface a nudge before the user opens the chat. Equivalent to
|
|
626
|
+
* calling `createAgoProactive(client, proactive)` — the resulting controller
|
|
627
|
+
* is available as `client.proactive`. Requires the tenant-level kill-switch
|
|
628
|
+
* (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
|
|
629
|
+
* default otherwise.
|
|
630
|
+
*/
|
|
631
|
+
proactive?: ProactiveOptions;
|
|
544
632
|
}
|
|
545
633
|
|
|
546
634
|
declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
|
|
@@ -868,6 +956,43 @@ declare interface FormSchema {
|
|
|
868
956
|
required?: string[];
|
|
869
957
|
}
|
|
870
958
|
|
|
959
|
+
/**
|
|
960
|
+
* HTTP client with authentication headers
|
|
961
|
+
*/
|
|
962
|
+
declare class HttpClient {
|
|
963
|
+
private baseUrl;
|
|
964
|
+
private headers;
|
|
965
|
+
constructor(config: AgoConfig);
|
|
966
|
+
/**
|
|
967
|
+
* Update configuration (e.g., JWT token)
|
|
968
|
+
*/
|
|
969
|
+
updateConfig(config: Partial<AgoConfig>): void;
|
|
970
|
+
/**
|
|
971
|
+
* Make a GET request
|
|
972
|
+
*/
|
|
973
|
+
get<T>(path: string): Promise<T>;
|
|
974
|
+
/**
|
|
975
|
+
* Make a POST request with JSON body.
|
|
976
|
+
*
|
|
977
|
+
* `keepalive: true` lets the request survive a page unload (used by the
|
|
978
|
+
* proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
|
|
979
|
+
* headers, so it's a keepalive fetch instead).
|
|
980
|
+
*/
|
|
981
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
982
|
+
keepalive?: boolean;
|
|
983
|
+
}): Promise<T>;
|
|
984
|
+
/**
|
|
985
|
+
* Make a POST request and return the raw Response (for streaming)
|
|
986
|
+
*/
|
|
987
|
+
postStream(path: string, body?: unknown): Promise<Response>;
|
|
988
|
+
/**
|
|
989
|
+
* Make a POST request with FormData (for file uploads)
|
|
990
|
+
*/
|
|
991
|
+
postFormData(path: string, formData: FormData): Promise<Response>;
|
|
992
|
+
private request;
|
|
993
|
+
private handleErrorResponse;
|
|
994
|
+
}
|
|
995
|
+
|
|
871
996
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
872
997
|
/**
|
|
873
998
|
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
@@ -906,6 +1031,182 @@ export declare interface MockAgoClientOptions {
|
|
|
906
1031
|
|
|
907
1032
|
declare type MockFn = (...args: any[]) => any;
|
|
908
1033
|
|
|
1034
|
+
/**
|
|
1035
|
+
* Optional action attached to a nudge. Accepting a `functionName` action
|
|
1036
|
+
* executes the registered client function (same `FunctionRegistry` path as
|
|
1037
|
+
* agent-invoked calls); `setPageState` applies values through the registered
|
|
1038
|
+
* page-state controls.
|
|
1039
|
+
*/
|
|
1040
|
+
declare type NudgeAction = {
|
|
1041
|
+
label: string;
|
|
1042
|
+
functionName: string;
|
|
1043
|
+
arguments?: Record<string, unknown>;
|
|
1044
|
+
} | {
|
|
1045
|
+
label: string;
|
|
1046
|
+
setPageState: Record<string, unknown>;
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Controller returned by {@link createAgoProactive} (also available as
|
|
1051
|
+
* `client.proactive`).
|
|
1052
|
+
*/
|
|
1053
|
+
declare interface ProactiveController {
|
|
1054
|
+
/** Persistently opt this browser out of proactive nudges. */
|
|
1055
|
+
optOut(): void;
|
|
1056
|
+
/** Undo {@link optOut}. */
|
|
1057
|
+
optIn(): void;
|
|
1058
|
+
isOptedOut(): boolean;
|
|
1059
|
+
/**
|
|
1060
|
+
* Tell the governor the user is already engaged (e.g. the chat widget is
|
|
1061
|
+
* open) — nudges are suppressed while `true`. Call from the UI layer.
|
|
1062
|
+
*/
|
|
1063
|
+
setEngaged(engaged: boolean): void;
|
|
1064
|
+
/** App-pushed field error counter (field NAME only — never values). */
|
|
1065
|
+
signalFieldError(fieldName: string): void;
|
|
1066
|
+
/** Current aggregated friction snapshot. */
|
|
1067
|
+
getSignalsSnapshot(): SignalsSnapshot;
|
|
1068
|
+
/** The nudge currently occupying the single-nudge slot, if any. */
|
|
1069
|
+
getActiveNudge(): ProactiveNudgeInstance | null;
|
|
1070
|
+
/**
|
|
1071
|
+
* Mark the nudge as displayed. Idempotent per nudge; counts it against the
|
|
1072
|
+
* frequency caps, tracks the impression, and emits `nudge:shown`.
|
|
1073
|
+
*/
|
|
1074
|
+
shown(nudge: ProactiveNudgeInstance): void;
|
|
1075
|
+
/**
|
|
1076
|
+
* Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
|
|
1077
|
+
* and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
|
|
1078
|
+
* hidden kickoff message so the agent starts the turn with full context.
|
|
1079
|
+
*/
|
|
1080
|
+
accept(nudge: ProactiveNudgeInstance): Promise<void>;
|
|
1081
|
+
/** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
|
|
1082
|
+
dismiss(nudge: ProactiveNudgeInstance): void;
|
|
1083
|
+
/** Report a downstream conversion attributable to the nudge (analytics only). */
|
|
1084
|
+
markConverted(nudge: ProactiveNudgeInstance): void;
|
|
1085
|
+
/** Detach everything: listeners, timers, context provider, event flush. */
|
|
1086
|
+
destroy(): void;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
|
|
1090
|
+
declare interface ProactiveNudgeInstance {
|
|
1091
|
+
/** Client-generated uuid for this nudge instance (`client_nudge_id`). */
|
|
1092
|
+
id: string;
|
|
1093
|
+
triggerId: string;
|
|
1094
|
+
/** `static` = configured message; `agent` = backend LLM evaluation. */
|
|
1095
|
+
source: "static" | "agent";
|
|
1096
|
+
message: string;
|
|
1097
|
+
action?: NudgeAction;
|
|
1098
|
+
goal?: string;
|
|
1099
|
+
/** See {@link ProactiveTrigger.kickoff}. */
|
|
1100
|
+
kickoff?: string;
|
|
1101
|
+
createdAt: Date;
|
|
1102
|
+
/** Server-side nudge id (agent nudges only). */
|
|
1103
|
+
serverNudgeId?: string;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
/** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
|
|
1107
|
+
declare interface ProactiveOptions {
|
|
1108
|
+
triggers: ProactiveTrigger[];
|
|
1109
|
+
/**
|
|
1110
|
+
* Global caps on nudges actually shown. `perSession` is in-memory (page
|
|
1111
|
+
* lifetime); `perDay` is persisted in localStorage with a date rollover —
|
|
1112
|
+
* best-effort by design (private browsing resets it); the costly LLM path is
|
|
1113
|
+
* additionally capped server-side.
|
|
1114
|
+
*/
|
|
1115
|
+
frequencyCap?: {
|
|
1116
|
+
perSession?: number;
|
|
1117
|
+
perDay?: number;
|
|
1118
|
+
};
|
|
1119
|
+
/** Evaluation tick, ms. Default 1000. Zero network per tick. */
|
|
1120
|
+
tickMs?: number;
|
|
1121
|
+
/** Storage backend for persisted governance state. Default `localStorage`. */
|
|
1122
|
+
storage?: StorageLike;
|
|
1123
|
+
/** Storage key for persisted governance state. Default `"ago_proactive"`. */
|
|
1124
|
+
storageKey?: string;
|
|
1125
|
+
/** Tuning of the signal detectors (rage-click window, throttles…). */
|
|
1126
|
+
signals?: SignalCollectorTuning;
|
|
1127
|
+
/**
|
|
1128
|
+
* Local demos and tests ONLY: bypass the remote kill-switch. When set, the
|
|
1129
|
+
* `GET /config` fetch is skipped and the kill-switch takes this value.
|
|
1130
|
+
* Leave unset in production — the tenant admin controls the feature, and
|
|
1131
|
+
* the evaluate endpoint stays gated server-side regardless.
|
|
1132
|
+
*/
|
|
1133
|
+
enabledOverride?: boolean;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/** A declarative proactive trigger. */
|
|
1137
|
+
declare interface ProactiveTrigger {
|
|
1138
|
+
/** Stable id, used for cooldowns, dismissal memory, and analytics. */
|
|
1139
|
+
id: string;
|
|
1140
|
+
/** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
|
|
1141
|
+
when: ProactiveTriggerWhen;
|
|
1142
|
+
/**
|
|
1143
|
+
* Min time between two firings of this trigger (persisted across reloads).
|
|
1144
|
+
* A firing is the moment the trigger passes the gates — including an agent
|
|
1145
|
+
* evaluation that decides NOT to intervene, so a persistent condition can't
|
|
1146
|
+
* hammer the evaluate endpoint. Default 60 000.
|
|
1147
|
+
*/
|
|
1148
|
+
cooldownMs?: number;
|
|
1149
|
+
/**
|
|
1150
|
+
* `'agent'` asks the backend's fast-LLM second filter whether (and how) to
|
|
1151
|
+
* intervene; a `static` object shows the given message with no network call.
|
|
1152
|
+
*/
|
|
1153
|
+
intervene: "agent" | {
|
|
1154
|
+
type: "static";
|
|
1155
|
+
message: string;
|
|
1156
|
+
action?: NudgeAction;
|
|
1157
|
+
};
|
|
1158
|
+
/**
|
|
1159
|
+
* What the agent should help with. Sent to the evaluate endpoint, and used to
|
|
1160
|
+
* pre-seed the chat turn when the user accepts the nudge.
|
|
1161
|
+
*/
|
|
1162
|
+
goal?: string;
|
|
1163
|
+
/**
|
|
1164
|
+
* User-voice line used to OPEN the conversation when the user accepts this
|
|
1165
|
+
* nudge and no conversation exists yet — a hidden kickoff cannot start one
|
|
1166
|
+
* (the backend rejects it). Sent as a visible user message, so write it in
|
|
1167
|
+
* the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
|
|
1168
|
+
* already open, the SDK sends a hidden meta kickoff instead and this field
|
|
1169
|
+
* is unused. Without it, accepting with no open conversation skips the chat
|
|
1170
|
+
* pre-seed (the nudge action still runs).
|
|
1171
|
+
*/
|
|
1172
|
+
kickoff?: string;
|
|
1173
|
+
/**
|
|
1174
|
+
* How long a dismissal of this trigger's nudge suppresses it (persisted).
|
|
1175
|
+
* Default 24h.
|
|
1176
|
+
*/
|
|
1177
|
+
resurfaceAfterMs?: number;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
|
|
1182
|
+
* must pass against the current {@link SignalsSnapshot}. Numeric fields are
|
|
1183
|
+
* `>=` thresholds.
|
|
1184
|
+
*/
|
|
1185
|
+
declare interface ProactiveTriggerWhen {
|
|
1186
|
+
/**
|
|
1187
|
+
* Route pattern the current pathname must match. Supports the SDK's route
|
|
1188
|
+
* styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
|
|
1189
|
+
* wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
|
|
1190
|
+
* remaining segments (`/dossier/*`).
|
|
1191
|
+
*/
|
|
1192
|
+
route?: string;
|
|
1193
|
+
/** Min time since the last user activity, ms. */
|
|
1194
|
+
idleMs?: number;
|
|
1195
|
+
/** Min time spent on the current route, ms. */
|
|
1196
|
+
dwellMs?: number;
|
|
1197
|
+
/**
|
|
1198
|
+
* Partial deep match against the registered page state (funnel step,
|
|
1199
|
+
* filters…). Every key present here must deep-match the live value.
|
|
1200
|
+
*/
|
|
1201
|
+
pageState?: Partial<Record<string, unknown>>;
|
|
1202
|
+
/** Min rage-click bursts on the current route. */
|
|
1203
|
+
rageClicks?: number;
|
|
1204
|
+
/** Min A→B→A→B route oscillations this session. */
|
|
1205
|
+
routeBounces?: number;
|
|
1206
|
+
/** Per-field minimum error counts (field NAME → min count). */
|
|
1207
|
+
fieldErrors?: Record<string, number>;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
909
1210
|
/**
|
|
910
1211
|
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
911
1212
|
* continuation fires (e.g. wait for the destination page to mount after a
|
|
@@ -938,6 +1239,54 @@ declare interface SendMessageOptions {
|
|
|
938
1239
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
939
1240
|
}
|
|
940
1241
|
|
|
1242
|
+
/** Tuning knobs for the collector's detectors. All optional. */
|
|
1243
|
+
declare interface SignalCollectorTuning {
|
|
1244
|
+
/** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
|
|
1245
|
+
activityThrottleMs?: number;
|
|
1246
|
+
/** Rage click: clicks needed to count a burst. Default 3. */
|
|
1247
|
+
rageClickCount?: number;
|
|
1248
|
+
/** Rage click: max time between first and last click of a burst, ms. Default 1000. */
|
|
1249
|
+
rageClickWindowMs?: number;
|
|
1250
|
+
/** Rage click: max radius between clicks of a burst, px. Default 24. */
|
|
1251
|
+
rageClickRadiusPx?: number;
|
|
1252
|
+
/** Max routes kept in the recent-route sequence. Default 10. */
|
|
1253
|
+
maxRecentRoutes?: number;
|
|
1254
|
+
/** Max typed signals kept in the ring buffer. Default 50. */
|
|
1255
|
+
maxSignals?: number;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Aggregated view of the current friction state. Registered as a dynamic
|
|
1260
|
+
* context provider (key `friction_signals`) so it rides along as
|
|
1261
|
+
* `client_context` on every message, and sent as `signals` to the proactive
|
|
1262
|
+
* evaluate endpoint.
|
|
1263
|
+
*/
|
|
1264
|
+
declare interface SignalsSnapshot {
|
|
1265
|
+
/** Current pathname. */
|
|
1266
|
+
route: string;
|
|
1267
|
+
/** Time spent on the current route, ms. */
|
|
1268
|
+
dwellMs: number;
|
|
1269
|
+
/** Time since the last user activity (pointer/key/scroll/touch), ms. */
|
|
1270
|
+
idleMs: number;
|
|
1271
|
+
/** Rage-click bursts detected on the current route. */
|
|
1272
|
+
rageClicks: number;
|
|
1273
|
+
/**
|
|
1274
|
+
* A→B→A→B route oscillations detected in the recent route sequence. Rolling
|
|
1275
|
+
* session counter (cross-route by nature); trigger cooldowns and dismissal
|
|
1276
|
+
* memory keep it from re-firing forever.
|
|
1277
|
+
*/
|
|
1278
|
+
routeBounces: number;
|
|
1279
|
+
/** App-pushed field error counters (field NAME → count), current route only. */
|
|
1280
|
+
fieldErrors: Record<string, number>;
|
|
1281
|
+
/** Most recent pathnames, oldest first (bounded). */
|
|
1282
|
+
recentRoutes: string[];
|
|
1283
|
+
/**
|
|
1284
|
+
* Merged `AgoStateControl.get()` snapshot of the registered page-state
|
|
1285
|
+
* controls (funnel step, filters…), or `null` when none are registered.
|
|
1286
|
+
*/
|
|
1287
|
+
pageState: Record<string, unknown> | null;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
941
1290
|
/**
|
|
942
1291
|
* SSE stream chunk data
|
|
943
1292
|
*/
|
|
@@ -981,6 +1330,9 @@ declare interface SSEChunkData {
|
|
|
981
1330
|
waiting_tool_call_ids?: string[];
|
|
982
1331
|
}
|
|
983
1332
|
|
|
1333
|
+
/** The slice of the Web Storage API that {@link createStore} relies on. */
|
|
1334
|
+
declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
|
|
1335
|
+
|
|
984
1336
|
/**
|
|
985
1337
|
* Where a completed form is sent.
|
|
986
1338
|
* - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser
|