@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.
- package/CHANGELOG.md +48 -0
- 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 +390 -2
- package/dist/angular.d.ts +390 -2
- package/dist/angular.js +1 -1
- package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
- package/dist/{createConversationSession-DCSWShaW.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 +390 -2
- package/dist/devtools.d.ts +390 -2
- package/dist/helpers.d.cts +5 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +605 -4
- package/dist/index.d.ts +605 -4
- package/dist/index.js +95 -90
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +561 -4
- package/dist/react.d.ts +561 -4
- package/dist/react.js +849 -517
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +390 -2
- package/dist/testing.d.ts +390 -2
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +411 -2
- package/dist/vue.d.ts +411 -2
- package/dist/vue.js +133 -110
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +387 -2
- package/dist/widget.d.ts +387 -2
- package/dist/widget.js +437 -423
- package/llms-full.txt +74 -2
- package/package.json +1 -1
- package/dist/AgoClient-q39FIjSC.js +0 -912
- package/dist/AgoClient-wcPRaIMs.cjs +0 -8
- package/dist/createConversationSession-BBYfQLLS.cjs +0 -1
- package/dist/createFormCollector-eimwwWEi.cjs +0 -1
- package/dist/createFormCollector-sB6rMccD.js +0 -299
- package/dist/createMockClient-BUc9PSbo.js +0 -79
- package/dist/createMockClient-CjdCqixj.cjs +0 -1
package/dist/vue.d.ts
CHANGED
|
@@ -49,8 +49,20 @@ declare class AgoClient {
|
|
|
49
49
|
private warnedEmptyConversations;
|
|
50
50
|
/** Paused turns awaiting auto-resume, keyed by assistant message id. */
|
|
51
51
|
private pendingResumes;
|
|
52
|
+
/**
|
|
53
|
+
* Client function invocations held pending user approval, keyed by
|
|
54
|
+
* invocationId (the tool-call id). Populated when {@link requiresApproval}
|
|
55
|
+
* matches; drained by {@link approveFunction} / {@link rejectFunction}.
|
|
56
|
+
*/
|
|
57
|
+
private pendingApprovals;
|
|
52
58
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
53
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;
|
|
54
66
|
constructor(config: AgoConfig);
|
|
55
67
|
/**
|
|
56
68
|
* Send a message and receive a streaming response
|
|
@@ -99,6 +111,24 @@ declare class AgoClient {
|
|
|
99
111
|
*/
|
|
100
112
|
private maybeFlagEmptyReply;
|
|
101
113
|
private handleClientFunctionInvocation;
|
|
114
|
+
/**
|
|
115
|
+
* Whether a client function invocation must wait for explicit user approval.
|
|
116
|
+
* True when the {@link AgoConfig.approvalPolicy} returns true OR the function
|
|
117
|
+
* was registered with `requiresApproval: true` — the two OR together.
|
|
118
|
+
*/
|
|
119
|
+
private requiresApproval;
|
|
120
|
+
/**
|
|
121
|
+
* Approve a client function call held by the approval gate: run it, submit its
|
|
122
|
+
* result, and let the paused turn resume. No-op if the invocation is unknown
|
|
123
|
+
* (already handled, or never gated).
|
|
124
|
+
*/
|
|
125
|
+
approveFunction(invocationId: string): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Reject a client function call held by the approval gate: submit a rejection
|
|
128
|
+
* result so the agent sees the user declined, and let the paused turn resume
|
|
129
|
+
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
130
|
+
*/
|
|
131
|
+
rejectFunction(invocationId: string): Promise<void>;
|
|
102
132
|
/**
|
|
103
133
|
* Get list of conversations
|
|
104
134
|
*/
|
|
@@ -128,8 +158,10 @@ declare class AgoClient {
|
|
|
128
158
|
*
|
|
129
159
|
* Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
|
|
130
160
|
* navigation function would navigate again), so the app decides. Returns the
|
|
131
|
-
* resumed turn's final message, or `null` when there was nothing to resume
|
|
132
|
-
* some waiting function is not registered on this page
|
|
161
|
+
* resumed turn's final message, or `null` when there was nothing to resume,
|
|
162
|
+
* some waiting function is not registered on this page, or a waiting call is
|
|
163
|
+
* gated by the approval policy (it is held for `approveFunction` /
|
|
164
|
+
* `rejectFunction` and the turn stays paused, exactly as on the live stream).
|
|
133
165
|
*/
|
|
134
166
|
resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
|
|
135
167
|
/**
|
|
@@ -201,6 +233,14 @@ declare class AgoClient {
|
|
|
201
233
|
* Get all registered function schemas
|
|
202
234
|
*/
|
|
203
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>;
|
|
204
244
|
/**
|
|
205
245
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
206
246
|
*
|
|
@@ -302,6 +342,9 @@ declare class AgoClient {
|
|
|
302
342
|
*/
|
|
303
343
|
notifyContextChanged(): void;
|
|
304
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 */
|
|
305
348
|
/**
|
|
306
349
|
* Enable automatic capture of the current browser page (URL + title).
|
|
307
350
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -346,6 +389,7 @@ declare class AgoClient {
|
|
|
346
389
|
* Clean up resources
|
|
347
390
|
*/
|
|
348
391
|
destroy(): void;
|
|
392
|
+
/* Excluded from this release type: reviveAfterDestroy */
|
|
349
393
|
}
|
|
350
394
|
|
|
351
395
|
/**
|
|
@@ -424,6 +468,15 @@ declare interface AgoClientEvents {
|
|
|
424
468
|
"toolCall:received": ToolCallData;
|
|
425
469
|
"toolCall:form": ToolCallData;
|
|
426
470
|
"function:invoke": ClientFunctionInvocation;
|
|
471
|
+
/**
|
|
472
|
+
* A client function call is held pending the user's approval (pause mode +
|
|
473
|
+
* an {@link AgoConfig.approvalPolicy}/`requiresApproval` match). The turn stays
|
|
474
|
+
* at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and
|
|
475
|
+
* resume, or `rejectFunction(invocationId)` to decline. Fires after
|
|
476
|
+
* `function:invoke` (which still fires for every call) and instead of the
|
|
477
|
+
* call running immediately.
|
|
478
|
+
*/
|
|
479
|
+
"function:awaiting-approval": ClientFunctionInvocation;
|
|
427
480
|
"function:result": {
|
|
428
481
|
invocationId: string;
|
|
429
482
|
result: unknown;
|
|
@@ -453,6 +506,25 @@ declare interface AgoClientEvents {
|
|
|
453
506
|
"connection:status": {
|
|
454
507
|
connected: boolean;
|
|
455
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
|
+
};
|
|
456
528
|
}
|
|
457
529
|
|
|
458
530
|
/**
|
|
@@ -492,6 +564,20 @@ export declare interface AgoConfig {
|
|
|
492
564
|
* Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
|
|
493
565
|
*/
|
|
494
566
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
567
|
+
/**
|
|
568
|
+
* Gate client function calls behind explicit user approval. Return `true` for
|
|
569
|
+
* an invocation the user must approve/reject before it runs; return `false`
|
|
570
|
+
* (or omit the policy) to let it run immediately as before.
|
|
571
|
+
*
|
|
572
|
+
* Only effective in pause mode (`clientFunctionsMode: "pause"`) — a gated call
|
|
573
|
+
* holds at `WAITING_CLIENT`, the SDK emits `function:awaiting-approval`, and it
|
|
574
|
+
* runs (and the turn resumes) only after `approveFunction(invocationId)`; a
|
|
575
|
+
* `rejectFunction(invocationId)` submits a rejection so the agent sees the
|
|
576
|
+
* decline. In placeholder mode there is no pause to hold, so the policy is a
|
|
577
|
+
* no-op and the call runs normally. A per-function `requiresApproval: true`
|
|
578
|
+
* also gates a call; the policy and the flag OR together.
|
|
579
|
+
*/
|
|
580
|
+
approvalPolicy?: (invocation: ClientFunctionInvocation) => boolean;
|
|
495
581
|
/**
|
|
496
582
|
* Max serialized size (bytes) of a client function result before the SDK
|
|
497
583
|
* replaces it with a flagged, truncated preview. Everything a handler
|
|
@@ -500,6 +586,16 @@ export declare interface AgoConfig {
|
|
|
500
586
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
501
587
|
*/
|
|
502
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;
|
|
503
599
|
}
|
|
504
600
|
|
|
505
601
|
declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
|
|
@@ -536,6 +632,11 @@ export declare interface AgoMessage {
|
|
|
536
632
|
export declare interface AgoPageStateOptions {
|
|
537
633
|
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
538
634
|
functionName?: string;
|
|
635
|
+
/**
|
|
636
|
+
* Require explicit user approval before this state change runs. See
|
|
637
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. Defaults to `false`.
|
|
638
|
+
*/
|
|
639
|
+
requiresApproval?: boolean;
|
|
539
640
|
}
|
|
540
641
|
|
|
541
642
|
/**
|
|
@@ -618,6 +719,11 @@ declare interface ClientFunctionDefinition {
|
|
|
618
719
|
* `Infinity` disables the guard for this function.
|
|
619
720
|
*/
|
|
620
721
|
maxResultBytes?: number;
|
|
722
|
+
/**
|
|
723
|
+
* Require explicit user approval before this function runs. See
|
|
724
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
725
|
+
*/
|
|
726
|
+
requiresApproval?: boolean;
|
|
621
727
|
}
|
|
622
728
|
|
|
623
729
|
/**
|
|
@@ -644,6 +750,11 @@ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name">
|
|
|
644
750
|
* disables the guard for this function.
|
|
645
751
|
*/
|
|
646
752
|
maxResultBytes?: number;
|
|
753
|
+
/**
|
|
754
|
+
* Require explicit user approval before this function runs. See
|
|
755
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
756
|
+
*/
|
|
757
|
+
requiresApproval?: boolean;
|
|
647
758
|
};
|
|
648
759
|
|
|
649
760
|
/**
|
|
@@ -684,6 +795,19 @@ declare interface ContextEntry {
|
|
|
684
795
|
description?: string;
|
|
685
796
|
/** Arbitrary structured data the AI should know about */
|
|
686
797
|
data?: Record<string, unknown>;
|
|
798
|
+
/**
|
|
799
|
+
* Marks the entry as constant for the whole conversation. The backend then
|
|
800
|
+
* pins it right after the system prompt, where LLM providers cache it across
|
|
801
|
+
* turns, instead of re-processing it next to every new user message.
|
|
802
|
+
*
|
|
803
|
+
* Only set this when the entry's content is byte-identical on every message
|
|
804
|
+
* of a conversation (a schema, a capability list, static instructions). A
|
|
805
|
+
* stable entry that changes between messages invalidates the provider's
|
|
806
|
+
* cache for the entire conversation history, which costs more than leaving
|
|
807
|
+
* the flag off. Default: `false` (re-sent near the newest user message).
|
|
808
|
+
* Backends that don't know the flag ignore it.
|
|
809
|
+
*/
|
|
810
|
+
stable?: boolean;
|
|
687
811
|
}
|
|
688
812
|
|
|
689
813
|
/**
|
|
@@ -815,6 +939,43 @@ declare interface FormSchema {
|
|
|
815
939
|
required?: string[];
|
|
816
940
|
}
|
|
817
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
|
+
|
|
818
979
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
819
980
|
/**
|
|
820
981
|
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
@@ -831,6 +992,182 @@ declare type MessageStatus_2 = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANC
|
|
|
831
992
|
*/
|
|
832
993
|
| "WAITING_CLIENT";
|
|
833
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
|
+
|
|
834
1171
|
/**
|
|
835
1172
|
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
836
1173
|
* continuation fires (e.g. wait for the destination page to mount after a
|
|
@@ -863,6 +1200,54 @@ declare interface SendMessageOptions {
|
|
|
863
1200
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
864
1201
|
}
|
|
865
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
|
+
|
|
866
1251
|
/**
|
|
867
1252
|
* SSE stream chunk data
|
|
868
1253
|
*/
|
|
@@ -906,6 +1291,9 @@ declare interface SSEChunkData {
|
|
|
906
1291
|
waiting_tool_call_ids?: string[];
|
|
907
1292
|
}
|
|
908
1293
|
|
|
1294
|
+
/** The slice of the Web Storage API that {@link createStore} relies on. */
|
|
1295
|
+
declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
|
|
1296
|
+
|
|
909
1297
|
/**
|
|
910
1298
|
* A minimal observable store: one value, synchronous subscriptions, and
|
|
911
1299
|
* optional persistence via {@link PersistOptions} (localStorage by default).
|
|
@@ -1711,4 +2099,25 @@ declare interface UseMessagesOptions {
|
|
|
1711
2099
|
conversationId?: string;
|
|
1712
2100
|
}
|
|
1713
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
|
+
|
|
1714
2123
|
export { }
|