@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.
Files changed (50) hide show
  1. package/dist/AgoClient-BGkFSNZF.cjs +8 -0
  2. package/dist/AgoClient-CW-BLT1_.js +1542 -0
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +311 -0
  5. package/dist/angular.d.ts +311 -0
  6. package/dist/angular.js +2 -2
  7. package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
  8. package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-C7cnnWKW.js} +3 -3
  9. package/dist/createFormCollector-iCDwAwYJ.js +279 -0
  10. package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
  11. package/dist/createMockClient-Br0TWgLO.js +97 -0
  12. package/dist/createMockClient-BwNLPjeT.cjs +1 -0
  13. package/dist/devtools.d.cts +311 -0
  14. package/dist/devtools.d.ts +311 -0
  15. package/dist/functions-IGSjjvF4.cjs +1 -0
  16. package/dist/helpers.cjs +1 -1
  17. package/dist/helpers.js +1 -1
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +510 -0
  20. package/dist/index.d.ts +510 -0
  21. package/dist/index.js +95 -90
  22. package/dist/react.cjs +3 -3
  23. package/dist/react.d.cts +375 -0
  24. package/dist/react.d.ts +375 -0
  25. package/dist/react.js +559 -422
  26. package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +311 -0
  29. package/dist/testing.d.ts +311 -0
  30. package/dist/testing.js +1 -1
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.d.cts +332 -0
  33. package/dist/vue.d.ts +332 -0
  34. package/dist/vue.js +133 -110
  35. package/dist/widget.cjs +1 -1
  36. package/dist/widget.d.cts +308 -0
  37. package/dist/widget.d.ts +308 -0
  38. package/dist/widget.js +7 -7
  39. package/package.json +1 -1
  40. package/dist/AgoClient-5VGybmvz.cjs +0 -8
  41. package/dist/AgoClient-DXrH2AMi.js +0 -964
  42. package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
  43. package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
  44. package/dist/createFormCollector-DYh90kiG.js +0 -305
  45. package/dist/createMockClient-C-wrjb2C.cjs +0 -1
  46. package/dist/createMockClient-we-XoPom.js +0 -79
  47. package/dist/functions-CPs7omgM.cjs +0 -1
  48. /package/dist/{autoContinue-CP9pJR-V.cjs → autoContinue-CcCTva-D.cjs} +0 -0
  49. /package/dist/{autoContinue-CC8K9mBU.js → autoContinue-D3Mmaaca.js} +0 -0
  50. /package/dist/{functions-tzyOZNp6.js → functions-CApuQZ2b.js} +0 -0
package/dist/vue.d.cts CHANGED
@@ -57,6 +57,12 @@ declare class AgoClient {
57
57
  private pendingApprovals;
58
58
  /** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
59
59
  private resumeGate;
60
+ /**
61
+ * Proactive-mode controller, set when the client was created with
62
+ * `proactive` options or when `createAgoProactive(client, opts)` was called.
63
+ * `null` otherwise.
64
+ */
65
+ proactive: ProactiveController | null;
60
66
  constructor(config: AgoConfig);
61
67
  /**
62
68
  * Send a message and receive a streaming response
@@ -227,6 +233,14 @@ declare class AgoClient {
227
233
  * Get all registered function schemas
228
234
  */
229
235
  getRegisteredFunctions(): ClientFunctionSchema[];
236
+ /**
237
+ * Execute a registered client function locally, through the same
238
+ * FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
239
+ * calls. Used by proactive nudge actions, where the user's explicit click on
240
+ * the action button constitutes the approval — nothing is submitted to the
241
+ * backend (there is no tool call to answer).
242
+ */
243
+ executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
230
244
  /**
231
245
  * Register a navigation function that lets AGO navigate users to different pages.
232
246
  *
@@ -328,6 +342,9 @@ declare class AgoClient {
328
342
  */
329
343
  notifyContextChanged(): void;
330
344
  /* Excluded from this release type: emitFormEvent */
345
+ /* Excluded from this release type: emitProactiveEvent */
346
+ /* Excluded from this release type: getHttp */
347
+ /* Excluded from this release type: getConfiguredAgent */
331
348
  /**
332
349
  * Enable automatic capture of the current browser page (URL + title).
333
350
  * Injected as a dynamic context entry named `browser-page`.
@@ -372,6 +389,7 @@ declare class AgoClient {
372
389
  * Clean up resources
373
390
  */
374
391
  destroy(): void;
392
+ /* Excluded from this release type: reviveAfterDestroy */
375
393
  }
376
394
 
377
395
  /**
@@ -488,6 +506,25 @@ declare interface AgoClientEvents {
488
506
  "connection:status": {
489
507
  connected: boolean;
490
508
  };
509
+ /**
510
+ * A proactive nudge passed every governor gate and is ready to display.
511
+ * `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
512
+ * `client.proactive.shown(nudge)` when they render it (impression tracking
513
+ * + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
514
+ */
515
+ "nudge:ready": ProactiveNudgeInstance;
516
+ /** A nudge was displayed to the user (fires once per nudge). */
517
+ "nudge:shown": {
518
+ nudge: ProactiveNudgeInstance;
519
+ };
520
+ /** The user dismissed the nudge (its trigger is suppressed, see governor). */
521
+ "nudge:dismissed": {
522
+ nudge: ProactiveNudgeInstance;
523
+ };
524
+ /** The user accepted the nudge (its action ran / the chat is being seeded). */
525
+ "nudge:accepted": {
526
+ nudge: ProactiveNudgeInstance;
527
+ };
491
528
  }
492
529
 
493
530
  /**
@@ -549,6 +586,16 @@ export declare interface AgoConfig {
549
586
  * with `maxResultBytes` on its definition; `Infinity` disables the guard.
550
587
  */
551
588
  maxFunctionResultBytes?: number;
589
+ /**
590
+ * Enable the proactive mode: declarative triggers evaluated client-side
591
+ * against friction signals (dwell/idle time, rage clicks, route bounces…)
592
+ * that can surface a nudge before the user opens the chat. Equivalent to
593
+ * calling `createAgoProactive(client, proactive)` — the resulting controller
594
+ * is available as `client.proactive`. Requires the tenant-level kill-switch
595
+ * (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
596
+ * default otherwise.
597
+ */
598
+ proactive?: ProactiveOptions;
552
599
  }
553
600
 
554
601
  declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
@@ -892,6 +939,43 @@ declare interface FormSchema {
892
939
  required?: string[];
893
940
  }
894
941
 
942
+ /**
943
+ * HTTP client with authentication headers
944
+ */
945
+ declare class HttpClient {
946
+ private baseUrl;
947
+ private headers;
948
+ constructor(config: AgoConfig);
949
+ /**
950
+ * Update configuration (e.g., JWT token)
951
+ */
952
+ updateConfig(config: Partial<AgoConfig>): void;
953
+ /**
954
+ * Make a GET request
955
+ */
956
+ get<T>(path: string): Promise<T>;
957
+ /**
958
+ * Make a POST request with JSON body.
959
+ *
960
+ * `keepalive: true` lets the request survive a page unload (used by the
961
+ * proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
962
+ * headers, so it's a keepalive fetch instead).
963
+ */
964
+ post<T>(path: string, body?: unknown, options?: {
965
+ keepalive?: boolean;
966
+ }): Promise<T>;
967
+ /**
968
+ * Make a POST request and return the raw Response (for streaming)
969
+ */
970
+ postStream(path: string, body?: unknown): Promise<Response>;
971
+ /**
972
+ * Make a POST request with FormData (for file uploads)
973
+ */
974
+ postFormData(path: string, formData: FormData): Promise<Response>;
975
+ private request;
976
+ private handleErrorResponse;
977
+ }
978
+
895
979
  declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
896
980
  /**
897
981
  * The turn paused on client function call(s) (pause mode): the agent waits for
@@ -908,6 +992,182 @@ declare type MessageStatus_2 = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANC
908
992
  */
909
993
  | "WAITING_CLIENT";
910
994
 
995
+ /**
996
+ * Optional action attached to a nudge. Accepting a `functionName` action
997
+ * executes the registered client function (same `FunctionRegistry` path as
998
+ * agent-invoked calls); `setPageState` applies values through the registered
999
+ * page-state controls.
1000
+ */
1001
+ export declare type NudgeAction = {
1002
+ label: string;
1003
+ functionName: string;
1004
+ arguments?: Record<string, unknown>;
1005
+ } | {
1006
+ label: string;
1007
+ setPageState: Record<string, unknown>;
1008
+ };
1009
+
1010
+ /**
1011
+ * Controller returned by {@link createAgoProactive} (also available as
1012
+ * `client.proactive`).
1013
+ */
1014
+ export declare interface ProactiveController {
1015
+ /** Persistently opt this browser out of proactive nudges. */
1016
+ optOut(): void;
1017
+ /** Undo {@link optOut}. */
1018
+ optIn(): void;
1019
+ isOptedOut(): boolean;
1020
+ /**
1021
+ * Tell the governor the user is already engaged (e.g. the chat widget is
1022
+ * open) — nudges are suppressed while `true`. Call from the UI layer.
1023
+ */
1024
+ setEngaged(engaged: boolean): void;
1025
+ /** App-pushed field error counter (field NAME only — never values). */
1026
+ signalFieldError(fieldName: string): void;
1027
+ /** Current aggregated friction snapshot. */
1028
+ getSignalsSnapshot(): SignalsSnapshot;
1029
+ /** The nudge currently occupying the single-nudge slot, if any. */
1030
+ getActiveNudge(): ProactiveNudgeInstance | null;
1031
+ /**
1032
+ * Mark the nudge as displayed. Idempotent per nudge; counts it against the
1033
+ * frequency caps, tracks the impression, and emits `nudge:shown`.
1034
+ */
1035
+ shown(nudge: ProactiveNudgeInstance): void;
1036
+ /**
1037
+ * Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
1038
+ * and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
1039
+ * hidden kickoff message so the agent starts the turn with full context.
1040
+ */
1041
+ accept(nudge: ProactiveNudgeInstance): Promise<void>;
1042
+ /** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
1043
+ dismiss(nudge: ProactiveNudgeInstance): void;
1044
+ /** Report a downstream conversion attributable to the nudge (analytics only). */
1045
+ markConverted(nudge: ProactiveNudgeInstance): void;
1046
+ /** Detach everything: listeners, timers, context provider, event flush. */
1047
+ destroy(): void;
1048
+ }
1049
+
1050
+ /** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
1051
+ export declare interface ProactiveNudgeInstance {
1052
+ /** Client-generated uuid for this nudge instance (`client_nudge_id`). */
1053
+ id: string;
1054
+ triggerId: string;
1055
+ /** `static` = configured message; `agent` = backend LLM evaluation. */
1056
+ source: "static" | "agent";
1057
+ message: string;
1058
+ action?: NudgeAction;
1059
+ goal?: string;
1060
+ /** See {@link ProactiveTrigger.kickoff}. */
1061
+ kickoff?: string;
1062
+ createdAt: Date;
1063
+ /** Server-side nudge id (agent nudges only). */
1064
+ serverNudgeId?: string;
1065
+ }
1066
+
1067
+ /** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
1068
+ export declare interface ProactiveOptions {
1069
+ triggers: ProactiveTrigger[];
1070
+ /**
1071
+ * Global caps on nudges actually shown. `perSession` is in-memory (page
1072
+ * lifetime); `perDay` is persisted in localStorage with a date rollover —
1073
+ * best-effort by design (private browsing resets it); the costly LLM path is
1074
+ * additionally capped server-side.
1075
+ */
1076
+ frequencyCap?: {
1077
+ perSession?: number;
1078
+ perDay?: number;
1079
+ };
1080
+ /** Evaluation tick, ms. Default 1000. Zero network per tick. */
1081
+ tickMs?: number;
1082
+ /** Storage backend for persisted governance state. Default `localStorage`. */
1083
+ storage?: StorageLike;
1084
+ /** Storage key for persisted governance state. Default `"ago_proactive"`. */
1085
+ storageKey?: string;
1086
+ /** Tuning of the signal detectors (rage-click window, throttles…). */
1087
+ signals?: SignalCollectorTuning;
1088
+ /**
1089
+ * Local demos and tests ONLY: bypass the remote kill-switch. When set, the
1090
+ * `GET /config` fetch is skipped and the kill-switch takes this value.
1091
+ * Leave unset in production — the tenant admin controls the feature, and
1092
+ * the evaluate endpoint stays gated server-side regardless.
1093
+ */
1094
+ enabledOverride?: boolean;
1095
+ }
1096
+
1097
+ /** A declarative proactive trigger. */
1098
+ export declare interface ProactiveTrigger {
1099
+ /** Stable id, used for cooldowns, dismissal memory, and analytics. */
1100
+ id: string;
1101
+ /** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
1102
+ when: ProactiveTriggerWhen;
1103
+ /**
1104
+ * Min time between two firings of this trigger (persisted across reloads).
1105
+ * A firing is the moment the trigger passes the gates — including an agent
1106
+ * evaluation that decides NOT to intervene, so a persistent condition can't
1107
+ * hammer the evaluate endpoint. Default 60 000.
1108
+ */
1109
+ cooldownMs?: number;
1110
+ /**
1111
+ * `'agent'` asks the backend's fast-LLM second filter whether (and how) to
1112
+ * intervene; a `static` object shows the given message with no network call.
1113
+ */
1114
+ intervene: "agent" | {
1115
+ type: "static";
1116
+ message: string;
1117
+ action?: NudgeAction;
1118
+ };
1119
+ /**
1120
+ * What the agent should help with. Sent to the evaluate endpoint, and used to
1121
+ * pre-seed the chat turn when the user accepts the nudge.
1122
+ */
1123
+ goal?: string;
1124
+ /**
1125
+ * User-voice line used to OPEN the conversation when the user accepts this
1126
+ * nudge and no conversation exists yet — a hidden kickoff cannot start one
1127
+ * (the backend rejects it). Sent as a visible user message, so write it in
1128
+ * the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
1129
+ * already open, the SDK sends a hidden meta kickoff instead and this field
1130
+ * is unused. Without it, accepting with no open conversation skips the chat
1131
+ * pre-seed (the nudge action still runs).
1132
+ */
1133
+ kickoff?: string;
1134
+ /**
1135
+ * How long a dismissal of this trigger's nudge suppresses it (persisted).
1136
+ * Default 24h.
1137
+ */
1138
+ resurfaceAfterMs?: number;
1139
+ }
1140
+
1141
+ /**
1142
+ * Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
1143
+ * must pass against the current {@link SignalsSnapshot}. Numeric fields are
1144
+ * `>=` thresholds.
1145
+ */
1146
+ declare interface ProactiveTriggerWhen {
1147
+ /**
1148
+ * Route pattern the current pathname must match. Supports the SDK's route
1149
+ * styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
1150
+ * wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
1151
+ * remaining segments (`/dossier/*`).
1152
+ */
1153
+ route?: string;
1154
+ /** Min time since the last user activity, ms. */
1155
+ idleMs?: number;
1156
+ /** Min time spent on the current route, ms. */
1157
+ dwellMs?: number;
1158
+ /**
1159
+ * Partial deep match against the registered page state (funnel step,
1160
+ * filters…). Every key present here must deep-match the live value.
1161
+ */
1162
+ pageState?: Partial<Record<string, unknown>>;
1163
+ /** Min rage-click bursts on the current route. */
1164
+ rageClicks?: number;
1165
+ /** Min A→B→A→B route oscillations this session. */
1166
+ routeBounces?: number;
1167
+ /** Per-field minimum error counts (field NAME → min count). */
1168
+ fieldErrors?: Record<string, number>;
1169
+ }
1170
+
911
1171
  /**
912
1172
  * Hook run before a paused turn is resumed, so the app controls WHEN the
913
1173
  * continuation fires (e.g. wait for the destination page to mount after a
@@ -940,6 +1200,54 @@ declare interface SendMessageOptions {
940
1200
  clientFunctionsMode?: ClientFunctionsMode;
941
1201
  }
942
1202
 
1203
+ /** Tuning knobs for the collector's detectors. All optional. */
1204
+ declare interface SignalCollectorTuning {
1205
+ /** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
1206
+ activityThrottleMs?: number;
1207
+ /** Rage click: clicks needed to count a burst. Default 3. */
1208
+ rageClickCount?: number;
1209
+ /** Rage click: max time between first and last click of a burst, ms. Default 1000. */
1210
+ rageClickWindowMs?: number;
1211
+ /** Rage click: max radius between clicks of a burst, px. Default 24. */
1212
+ rageClickRadiusPx?: number;
1213
+ /** Max routes kept in the recent-route sequence. Default 10. */
1214
+ maxRecentRoutes?: number;
1215
+ /** Max typed signals kept in the ring buffer. Default 50. */
1216
+ maxSignals?: number;
1217
+ }
1218
+
1219
+ /**
1220
+ * Aggregated view of the current friction state. Registered as a dynamic
1221
+ * context provider (key `friction_signals`) so it rides along as
1222
+ * `client_context` on every message, and sent as `signals` to the proactive
1223
+ * evaluate endpoint.
1224
+ */
1225
+ declare interface SignalsSnapshot {
1226
+ /** Current pathname. */
1227
+ route: string;
1228
+ /** Time spent on the current route, ms. */
1229
+ dwellMs: number;
1230
+ /** Time since the last user activity (pointer/key/scroll/touch), ms. */
1231
+ idleMs: number;
1232
+ /** Rage-click bursts detected on the current route. */
1233
+ rageClicks: number;
1234
+ /**
1235
+ * A→B→A→B route oscillations detected in the recent route sequence. Rolling
1236
+ * session counter (cross-route by nature); trigger cooldowns and dismissal
1237
+ * memory keep it from re-firing forever.
1238
+ */
1239
+ routeBounces: number;
1240
+ /** App-pushed field error counters (field NAME → count), current route only. */
1241
+ fieldErrors: Record<string, number>;
1242
+ /** Most recent pathnames, oldest first (bounded). */
1243
+ recentRoutes: string[];
1244
+ /**
1245
+ * Merged `AgoStateControl.get()` snapshot of the registered page-state
1246
+ * controls (funnel step, filters…), or `null` when none are registered.
1247
+ */
1248
+ pageState: Record<string, unknown> | null;
1249
+ }
1250
+
943
1251
  /**
944
1252
  * SSE stream chunk data
945
1253
  */
@@ -983,6 +1291,9 @@ declare interface SSEChunkData {
983
1291
  waiting_tool_call_ids?: string[];
984
1292
  }
985
1293
 
1294
+ /** The slice of the Web Storage API that {@link createStore} relies on. */
1295
+ declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
1296
+
986
1297
  /**
987
1298
  * A minimal observable store: one value, synchronous subscriptions, and
988
1299
  * optional persistence via {@link PersistOptions} (localStorage by default).
@@ -1788,4 +2099,25 @@ declare interface UseMessagesOptions {
1788
2099
  conversationId?: string;
1789
2100
  }
1790
2101
 
2102
+ /**
2103
+ * Consume proactive nudges (see `createAgoProactive` / `AgoConfig.proactive`)
2104
+ * with auto-cleanup on unmount. Vue mirror of the React `useProactiveNudge`.
2105
+ * Receiving a nudge marks it as shown (impression tracking + frequency caps),
2106
+ * so render only ONE consumer per nudge surface.
2107
+ *
2108
+ * ```ts
2109
+ * const { nudge, accept, dismiss } = useProactiveNudge();
2110
+ * ```
2111
+ */
2112
+ export declare function useProactiveNudge(): UseProactiveNudgeResult;
2113
+
2114
+ export declare interface UseProactiveNudgeResult {
2115
+ /** The active nudge, or `null` when none is ready. */
2116
+ nudge: ShallowRef<ProactiveNudgeInstance | null>;
2117
+ /** Accept the nudge: run its action, seed the chat when relevant, clear it. */
2118
+ accept: () => Promise<void>;
2119
+ /** Dismiss the nudge (suppresses its trigger, see the governor). */
2120
+ dismiss: () => void;
2121
+ }
2122
+
1791
2123
  export { }