@useago/sdk 1.5.0 → 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.
Files changed (46) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/AgoClient-BGkFSNZF.cjs +8 -0
  3. package/dist/AgoClient-CW-BLT1_.js +1542 -0
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +390 -2
  6. package/dist/angular.d.ts +390 -2
  7. package/dist/angular.js +1 -1
  8. package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
  9. package/dist/{createConversationSession-DCSWShaW.js → createConversationSession-C7cnnWKW.js} +3 -3
  10. package/dist/createFormCollector-iCDwAwYJ.js +279 -0
  11. package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
  12. package/dist/createMockClient-Br0TWgLO.js +97 -0
  13. package/dist/createMockClient-BwNLPjeT.cjs +1 -0
  14. package/dist/devtools.d.cts +390 -2
  15. package/dist/devtools.d.ts +390 -2
  16. package/dist/helpers.d.cts +5 -0
  17. package/dist/helpers.d.ts +5 -0
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +605 -4
  20. package/dist/index.d.ts +605 -4
  21. package/dist/index.js +95 -90
  22. package/dist/react.cjs +3 -3
  23. package/dist/react.d.cts +561 -4
  24. package/dist/react.d.ts +561 -4
  25. package/dist/react.js +849 -517
  26. package/dist/testing.cjs +1 -1
  27. package/dist/testing.d.cts +390 -2
  28. package/dist/testing.d.ts +390 -2
  29. package/dist/testing.js +1 -1
  30. package/dist/vue.cjs +1 -1
  31. package/dist/vue.d.cts +411 -2
  32. package/dist/vue.d.ts +411 -2
  33. package/dist/vue.js +133 -110
  34. package/dist/widget.cjs +4 -4
  35. package/dist/widget.d.cts +387 -2
  36. package/dist/widget.d.ts +387 -2
  37. package/dist/widget.js +437 -423
  38. package/llms-full.txt +74 -2
  39. package/package.json +1 -1
  40. package/dist/AgoClient-q39FIjSC.js +0 -912
  41. package/dist/AgoClient-wcPRaIMs.cjs +0 -8
  42. package/dist/createConversationSession-BBYfQLLS.cjs +0 -1
  43. package/dist/createFormCollector-eimwwWEi.cjs +0 -1
  44. package/dist/createFormCollector-sB6rMccD.js +0 -299
  45. package/dist/createMockClient-BUc9PSbo.js +0 -79
  46. package/dist/createMockClient-CjdCqixj.cjs +0 -1
@@ -41,8 +41,20 @@ declare class AgoClient {
41
41
  private warnedEmptyConversations;
42
42
  /** Paused turns awaiting auto-resume, keyed by assistant message id. */
43
43
  private pendingResumes;
44
+ /**
45
+ * Client function invocations held pending user approval, keyed by
46
+ * invocationId (the tool-call id). Populated when {@link requiresApproval}
47
+ * matches; drained by {@link approveFunction} / {@link rejectFunction}.
48
+ */
49
+ private pendingApprovals;
44
50
  /** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
45
51
  private resumeGate;
52
+ /**
53
+ * Proactive-mode controller, set when the client was created with
54
+ * `proactive` options or when `createAgoProactive(client, opts)` was called.
55
+ * `null` otherwise.
56
+ */
57
+ proactive: ProactiveController | null;
46
58
  constructor(config: AgoConfig);
47
59
  /**
48
60
  * Send a message and receive a streaming response
@@ -91,6 +103,24 @@ declare class AgoClient {
91
103
  */
92
104
  private maybeFlagEmptyReply;
93
105
  private handleClientFunctionInvocation;
106
+ /**
107
+ * Whether a client function invocation must wait for explicit user approval.
108
+ * True when the {@link AgoConfig.approvalPolicy} returns true OR the function
109
+ * was registered with `requiresApproval: true` — the two OR together.
110
+ */
111
+ private requiresApproval;
112
+ /**
113
+ * Approve a client function call held by the approval gate: run it, submit its
114
+ * result, and let the paused turn resume. No-op if the invocation is unknown
115
+ * (already handled, or never gated).
116
+ */
117
+ approveFunction(invocationId: string): Promise<void>;
118
+ /**
119
+ * Reject a client function call held by the approval gate: submit a rejection
120
+ * result so the agent sees the user declined, and let the paused turn resume
121
+ * (the agent decides what to do next). No-op if the invocation is unknown.
122
+ */
123
+ rejectFunction(invocationId: string): Promise<void>;
94
124
  /**
95
125
  * Get list of conversations
96
126
  */
@@ -120,8 +150,10 @@ declare class AgoClient {
120
150
  *
121
151
  * Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
122
152
  * navigation function would navigate again), so the app decides. Returns the
123
- * resumed turn's final message, or `null` when there was nothing to resume or
124
- * some waiting function is not registered on this page.
153
+ * resumed turn's final message, or `null` when there was nothing to resume,
154
+ * some waiting function is not registered on this page, or a waiting call is
155
+ * gated by the approval policy (it is held for `approveFunction` /
156
+ * `rejectFunction` and the turn stays paused, exactly as on the live stream).
125
157
  */
126
158
  resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
127
159
  /**
@@ -193,6 +225,14 @@ declare class AgoClient {
193
225
  * Get all registered function schemas
194
226
  */
195
227
  getRegisteredFunctions(): ClientFunctionSchema[];
228
+ /**
229
+ * Execute a registered client function locally, through the same
230
+ * FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
231
+ * calls. Used by proactive nudge actions, where the user's explicit click on
232
+ * the action button constitutes the approval — nothing is submitted to the
233
+ * backend (there is no tool call to answer).
234
+ */
235
+ executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
196
236
  /**
197
237
  * Register a navigation function that lets AGO navigate users to different pages.
198
238
  *
@@ -294,6 +334,9 @@ declare class AgoClient {
294
334
  */
295
335
  notifyContextChanged(): void;
296
336
  /* Excluded from this release type: emitFormEvent */
337
+ /* Excluded from this release type: emitProactiveEvent */
338
+ /* Excluded from this release type: getHttp */
339
+ /* Excluded from this release type: getConfiguredAgent */
297
340
  /**
298
341
  * Enable automatic capture of the current browser page (URL + title).
299
342
  * Injected as a dynamic context entry named `browser-page`.
@@ -338,6 +381,7 @@ declare class AgoClient {
338
381
  * Clean up resources
339
382
  */
340
383
  destroy(): void;
384
+ /* Excluded from this release type: reviveAfterDestroy */
341
385
  }
342
386
 
343
387
  /**
@@ -416,6 +460,15 @@ declare interface AgoClientEvents {
416
460
  "toolCall:received": ToolCallData;
417
461
  "toolCall:form": ToolCallData;
418
462
  "function:invoke": ClientFunctionInvocation;
463
+ /**
464
+ * A client function call is held pending the user's approval (pause mode +
465
+ * an {@link AgoConfig.approvalPolicy}/`requiresApproval` match). The turn stays
466
+ * at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and
467
+ * resume, or `rejectFunction(invocationId)` to decline. Fires after
468
+ * `function:invoke` (which still fires for every call) and instead of the
469
+ * call running immediately.
470
+ */
471
+ "function:awaiting-approval": ClientFunctionInvocation;
419
472
  "function:result": {
420
473
  invocationId: string;
421
474
  result: unknown;
@@ -445,6 +498,25 @@ declare interface AgoClientEvents {
445
498
  "connection:status": {
446
499
  connected: boolean;
447
500
  };
501
+ /**
502
+ * A proactive nudge passed every governor gate and is ready to display.
503
+ * `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
504
+ * `client.proactive.shown(nudge)` when they render it (impression tracking
505
+ * + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
506
+ */
507
+ "nudge:ready": ProactiveNudgeInstance;
508
+ /** A nudge was displayed to the user (fires once per nudge). */
509
+ "nudge:shown": {
510
+ nudge: ProactiveNudgeInstance;
511
+ };
512
+ /** The user dismissed the nudge (its trigger is suppressed, see governor). */
513
+ "nudge:dismissed": {
514
+ nudge: ProactiveNudgeInstance;
515
+ };
516
+ /** The user accepted the nudge (its action ran / the chat is being seeded). */
517
+ "nudge:accepted": {
518
+ nudge: ProactiveNudgeInstance;
519
+ };
448
520
  }
449
521
 
450
522
  /**
@@ -484,6 +556,20 @@ declare interface AgoConfig {
484
556
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
485
557
  */
486
558
  clientFunctionsMode?: ClientFunctionsMode;
559
+ /**
560
+ * Gate client function calls behind explicit user approval. Return `true` for
561
+ * an invocation the user must approve/reject before it runs; return `false`
562
+ * (or omit the policy) to let it run immediately as before.
563
+ *
564
+ * Only effective in pause mode (`clientFunctionsMode: "pause"`) — a gated call
565
+ * holds at `WAITING_CLIENT`, the SDK emits `function:awaiting-approval`, and it
566
+ * runs (and the turn resumes) only after `approveFunction(invocationId)`; a
567
+ * `rejectFunction(invocationId)` submits a rejection so the agent sees the
568
+ * decline. In placeholder mode there is no pause to hold, so the policy is a
569
+ * no-op and the call runs normally. A per-function `requiresApproval: true`
570
+ * also gates a call; the policy and the flag OR together.
571
+ */
572
+ approvalPolicy?: (invocation: ClientFunctionInvocation) => boolean;
487
573
  /**
488
574
  * Max serialized size (bytes) of a client function result before the SDK
489
575
  * replaces it with a flagged, truncated preview. Everything a handler
@@ -492,6 +578,16 @@ declare interface AgoConfig {
492
578
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
493
579
  */
494
580
  maxFunctionResultBytes?: number;
581
+ /**
582
+ * Enable the proactive mode: declarative triggers evaluated client-side
583
+ * against friction signals (dwell/idle time, rage clicks, route bounces…)
584
+ * that can surface a nudge before the user opens the chat. Equivalent to
585
+ * calling `createAgoProactive(client, proactive)` — the resulting controller
586
+ * is available as `client.proactive`. Requires the tenant-level kill-switch
587
+ * (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
588
+ * default otherwise.
589
+ */
590
+ proactive?: ProactiveOptions;
495
591
  }
496
592
 
497
593
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -528,6 +624,11 @@ declare interface AgoMessage {
528
624
  declare interface AgoPageStateOptions {
529
625
  /** Name of the synthesized client function. Defaults to "setPageState". */
530
626
  functionName?: string;
627
+ /**
628
+ * Require explicit user approval before this state change runs. See
629
+ * {@link AgoConfig.approvalPolicy} — pause mode only. Defaults to `false`.
630
+ */
631
+ requiresApproval?: boolean;
531
632
  }
532
633
 
533
634
  /**
@@ -589,6 +690,11 @@ declare interface ClientFunctionDefinition {
589
690
  * `Infinity` disables the guard for this function.
590
691
  */
591
692
  maxResultBytes?: number;
693
+ /**
694
+ * Require explicit user approval before this function runs. See
695
+ * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
696
+ */
697
+ requiresApproval?: boolean;
592
698
  }
593
699
 
594
700
  /**
@@ -615,6 +721,11 @@ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name">
615
721
  * disables the guard for this function.
616
722
  */
617
723
  maxResultBytes?: number;
724
+ /**
725
+ * Require explicit user approval before this function runs. See
726
+ * {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
727
+ */
728
+ requiresApproval?: boolean;
618
729
  };
619
730
 
620
731
  /**
@@ -655,6 +766,19 @@ declare interface ContextEntry {
655
766
  description?: string;
656
767
  /** Arbitrary structured data the AI should know about */
657
768
  data?: Record<string, unknown>;
769
+ /**
770
+ * Marks the entry as constant for the whole conversation. The backend then
771
+ * pins it right after the system prompt, where LLM providers cache it across
772
+ * turns, instead of re-processing it next to every new user message.
773
+ *
774
+ * Only set this when the entry's content is byte-identical on every message
775
+ * of a conversation (a schema, a capability list, static instructions). A
776
+ * stable entry that changes between messages invalidates the provider's
777
+ * cache for the entire conversation history, which costs more than leaving
778
+ * the flag off. Default: `false` (re-sent near the newest user message).
779
+ * Backends that don't know the flag ignore it.
780
+ */
781
+ stable?: boolean;
658
782
  }
659
783
 
660
784
  /**
@@ -801,6 +925,43 @@ declare interface FormSchema {
801
925
  required?: string[];
802
926
  }
803
927
 
928
+ /**
929
+ * HTTP client with authentication headers
930
+ */
931
+ declare class HttpClient {
932
+ private baseUrl;
933
+ private headers;
934
+ constructor(config: AgoConfig);
935
+ /**
936
+ * Update configuration (e.g., JWT token)
937
+ */
938
+ updateConfig(config: Partial<AgoConfig>): void;
939
+ /**
940
+ * Make a GET request
941
+ */
942
+ get<T>(path: string): Promise<T>;
943
+ /**
944
+ * Make a POST request with JSON body.
945
+ *
946
+ * `keepalive: true` lets the request survive a page unload (used by the
947
+ * proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
948
+ * headers, so it's a keepalive fetch instead).
949
+ */
950
+ post<T>(path: string, body?: unknown, options?: {
951
+ keepalive?: boolean;
952
+ }): Promise<T>;
953
+ /**
954
+ * Make a POST request and return the raw Response (for streaming)
955
+ */
956
+ postStream(path: string, body?: unknown): Promise<Response>;
957
+ /**
958
+ * Make a POST request with FormData (for file uploads)
959
+ */
960
+ postFormData(path: string, formData: FormData): Promise<Response>;
961
+ private request;
962
+ private handleErrorResponse;
963
+ }
964
+
804
965
  export declare function initDevPanel(options: DevPanelOptions): void;
805
966
 
806
967
  declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
@@ -811,6 +972,182 @@ declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCEL
811
972
  */
812
973
  | "WAITING_CLIENT";
813
974
 
975
+ /**
976
+ * Optional action attached to a nudge. Accepting a `functionName` action
977
+ * executes the registered client function (same `FunctionRegistry` path as
978
+ * agent-invoked calls); `setPageState` applies values through the registered
979
+ * page-state controls.
980
+ */
981
+ declare type NudgeAction = {
982
+ label: string;
983
+ functionName: string;
984
+ arguments?: Record<string, unknown>;
985
+ } | {
986
+ label: string;
987
+ setPageState: Record<string, unknown>;
988
+ };
989
+
990
+ /**
991
+ * Controller returned by {@link createAgoProactive} (also available as
992
+ * `client.proactive`).
993
+ */
994
+ declare interface ProactiveController {
995
+ /** Persistently opt this browser out of proactive nudges. */
996
+ optOut(): void;
997
+ /** Undo {@link optOut}. */
998
+ optIn(): void;
999
+ isOptedOut(): boolean;
1000
+ /**
1001
+ * Tell the governor the user is already engaged (e.g. the chat widget is
1002
+ * open) — nudges are suppressed while `true`. Call from the UI layer.
1003
+ */
1004
+ setEngaged(engaged: boolean): void;
1005
+ /** App-pushed field error counter (field NAME only — never values). */
1006
+ signalFieldError(fieldName: string): void;
1007
+ /** Current aggregated friction snapshot. */
1008
+ getSignalsSnapshot(): SignalsSnapshot;
1009
+ /** The nudge currently occupying the single-nudge slot, if any. */
1010
+ getActiveNudge(): ProactiveNudgeInstance | null;
1011
+ /**
1012
+ * Mark the nudge as displayed. Idempotent per nudge; counts it against the
1013
+ * frequency caps, tracks the impression, and emits `nudge:shown`.
1014
+ */
1015
+ shown(nudge: ProactiveNudgeInstance): void;
1016
+ /**
1017
+ * Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
1018
+ * and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
1019
+ * hidden kickoff message so the agent starts the turn with full context.
1020
+ */
1021
+ accept(nudge: ProactiveNudgeInstance): Promise<void>;
1022
+ /** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
1023
+ dismiss(nudge: ProactiveNudgeInstance): void;
1024
+ /** Report a downstream conversion attributable to the nudge (analytics only). */
1025
+ markConverted(nudge: ProactiveNudgeInstance): void;
1026
+ /** Detach everything: listeners, timers, context provider, event flush. */
1027
+ destroy(): void;
1028
+ }
1029
+
1030
+ /** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
1031
+ declare interface ProactiveNudgeInstance {
1032
+ /** Client-generated uuid for this nudge instance (`client_nudge_id`). */
1033
+ id: string;
1034
+ triggerId: string;
1035
+ /** `static` = configured message; `agent` = backend LLM evaluation. */
1036
+ source: "static" | "agent";
1037
+ message: string;
1038
+ action?: NudgeAction;
1039
+ goal?: string;
1040
+ /** See {@link ProactiveTrigger.kickoff}. */
1041
+ kickoff?: string;
1042
+ createdAt: Date;
1043
+ /** Server-side nudge id (agent nudges only). */
1044
+ serverNudgeId?: string;
1045
+ }
1046
+
1047
+ /** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
1048
+ declare interface ProactiveOptions {
1049
+ triggers: ProactiveTrigger[];
1050
+ /**
1051
+ * Global caps on nudges actually shown. `perSession` is in-memory (page
1052
+ * lifetime); `perDay` is persisted in localStorage with a date rollover —
1053
+ * best-effort by design (private browsing resets it); the costly LLM path is
1054
+ * additionally capped server-side.
1055
+ */
1056
+ frequencyCap?: {
1057
+ perSession?: number;
1058
+ perDay?: number;
1059
+ };
1060
+ /** Evaluation tick, ms. Default 1000. Zero network per tick. */
1061
+ tickMs?: number;
1062
+ /** Storage backend for persisted governance state. Default `localStorage`. */
1063
+ storage?: StorageLike;
1064
+ /** Storage key for persisted governance state. Default `"ago_proactive"`. */
1065
+ storageKey?: string;
1066
+ /** Tuning of the signal detectors (rage-click window, throttles…). */
1067
+ signals?: SignalCollectorTuning;
1068
+ /**
1069
+ * Local demos and tests ONLY: bypass the remote kill-switch. When set, the
1070
+ * `GET /config` fetch is skipped and the kill-switch takes this value.
1071
+ * Leave unset in production — the tenant admin controls the feature, and
1072
+ * the evaluate endpoint stays gated server-side regardless.
1073
+ */
1074
+ enabledOverride?: boolean;
1075
+ }
1076
+
1077
+ /** A declarative proactive trigger. */
1078
+ declare interface ProactiveTrigger {
1079
+ /** Stable id, used for cooldowns, dismissal memory, and analytics. */
1080
+ id: string;
1081
+ /** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
1082
+ when: ProactiveTriggerWhen;
1083
+ /**
1084
+ * Min time between two firings of this trigger (persisted across reloads).
1085
+ * A firing is the moment the trigger passes the gates — including an agent
1086
+ * evaluation that decides NOT to intervene, so a persistent condition can't
1087
+ * hammer the evaluate endpoint. Default 60 000.
1088
+ */
1089
+ cooldownMs?: number;
1090
+ /**
1091
+ * `'agent'` asks the backend's fast-LLM second filter whether (and how) to
1092
+ * intervene; a `static` object shows the given message with no network call.
1093
+ */
1094
+ intervene: "agent" | {
1095
+ type: "static";
1096
+ message: string;
1097
+ action?: NudgeAction;
1098
+ };
1099
+ /**
1100
+ * What the agent should help with. Sent to the evaluate endpoint, and used to
1101
+ * pre-seed the chat turn when the user accepts the nudge.
1102
+ */
1103
+ goal?: string;
1104
+ /**
1105
+ * User-voice line used to OPEN the conversation when the user accepts this
1106
+ * nudge and no conversation exists yet — a hidden kickoff cannot start one
1107
+ * (the backend rejects it). Sent as a visible user message, so write it in
1108
+ * the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
1109
+ * already open, the SDK sends a hidden meta kickoff instead and this field
1110
+ * is unused. Without it, accepting with no open conversation skips the chat
1111
+ * pre-seed (the nudge action still runs).
1112
+ */
1113
+ kickoff?: string;
1114
+ /**
1115
+ * How long a dismissal of this trigger's nudge suppresses it (persisted).
1116
+ * Default 24h.
1117
+ */
1118
+ resurfaceAfterMs?: number;
1119
+ }
1120
+
1121
+ /**
1122
+ * Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
1123
+ * must pass against the current {@link SignalsSnapshot}. Numeric fields are
1124
+ * `>=` thresholds.
1125
+ */
1126
+ declare interface ProactiveTriggerWhen {
1127
+ /**
1128
+ * Route pattern the current pathname must match. Supports the SDK's route
1129
+ * styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
1130
+ * wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
1131
+ * remaining segments (`/dossier/*`).
1132
+ */
1133
+ route?: string;
1134
+ /** Min time since the last user activity, ms. */
1135
+ idleMs?: number;
1136
+ /** Min time spent on the current route, ms. */
1137
+ dwellMs?: number;
1138
+ /**
1139
+ * Partial deep match against the registered page state (funnel step,
1140
+ * filters…). Every key present here must deep-match the live value.
1141
+ */
1142
+ pageState?: Partial<Record<string, unknown>>;
1143
+ /** Min rage-click bursts on the current route. */
1144
+ rageClicks?: number;
1145
+ /** Min A→B→A→B route oscillations this session. */
1146
+ routeBounces?: number;
1147
+ /** Per-field minimum error counts (field NAME → min count). */
1148
+ fieldErrors?: Record<string, number>;
1149
+ }
1150
+
814
1151
  /**
815
1152
  * Hook run before a paused turn is resumed, so the app controls WHEN the
816
1153
  * continuation fires (e.g. wait for the destination page to mount after a
@@ -843,6 +1180,54 @@ declare interface SendMessageOptions {
843
1180
  clientFunctionsMode?: ClientFunctionsMode;
844
1181
  }
845
1182
 
1183
+ /** Tuning knobs for the collector's detectors. All optional. */
1184
+ declare interface SignalCollectorTuning {
1185
+ /** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
1186
+ activityThrottleMs?: number;
1187
+ /** Rage click: clicks needed to count a burst. Default 3. */
1188
+ rageClickCount?: number;
1189
+ /** Rage click: max time between first and last click of a burst, ms. Default 1000. */
1190
+ rageClickWindowMs?: number;
1191
+ /** Rage click: max radius between clicks of a burst, px. Default 24. */
1192
+ rageClickRadiusPx?: number;
1193
+ /** Max routes kept in the recent-route sequence. Default 10. */
1194
+ maxRecentRoutes?: number;
1195
+ /** Max typed signals kept in the ring buffer. Default 50. */
1196
+ maxSignals?: number;
1197
+ }
1198
+
1199
+ /**
1200
+ * Aggregated view of the current friction state. Registered as a dynamic
1201
+ * context provider (key `friction_signals`) so it rides along as
1202
+ * `client_context` on every message, and sent as `signals` to the proactive
1203
+ * evaluate endpoint.
1204
+ */
1205
+ declare interface SignalsSnapshot {
1206
+ /** Current pathname. */
1207
+ route: string;
1208
+ /** Time spent on the current route, ms. */
1209
+ dwellMs: number;
1210
+ /** Time since the last user activity (pointer/key/scroll/touch), ms. */
1211
+ idleMs: number;
1212
+ /** Rage-click bursts detected on the current route. */
1213
+ rageClicks: number;
1214
+ /**
1215
+ * A→B→A→B route oscillations detected in the recent route sequence. Rolling
1216
+ * session counter (cross-route by nature); trigger cooldowns and dismissal
1217
+ * memory keep it from re-firing forever.
1218
+ */
1219
+ routeBounces: number;
1220
+ /** App-pushed field error counters (field NAME → count), current route only. */
1221
+ fieldErrors: Record<string, number>;
1222
+ /** Most recent pathnames, oldest first (bounded). */
1223
+ recentRoutes: string[];
1224
+ /**
1225
+ * Merged `AgoStateControl.get()` snapshot of the registered page-state
1226
+ * controls (funnel step, filters…), or `null` when none are registered.
1227
+ */
1228
+ pageState: Record<string, unknown> | null;
1229
+ }
1230
+
846
1231
  /**
847
1232
  * SSE stream chunk data
848
1233
  */
@@ -886,6 +1271,9 @@ declare interface SSEChunkData {
886
1271
  waiting_tool_call_ids?: string[];
887
1272
  }
888
1273
 
1274
+ /** The slice of the Web Storage API that {@link createStore} relies on. */
1275
+ declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
1276
+
889
1277
  /**
890
1278
  * Where a completed form is sent.
891
1279
  * - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser