@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/react.d.ts
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* One normalized entry in the agent's activity feed. Merges a tool call
|
|
5
|
+
* (`toolCall:received`) or a client-function invocation (`function:invoke` /
|
|
6
|
+
* `function:awaiting-approval` / `function:result`) into a single shape.
|
|
7
|
+
*/
|
|
8
|
+
export declare interface AgoActivityItem {
|
|
9
|
+
/** Stable id — the tool-call id or the function invocationId. */
|
|
10
|
+
id: string;
|
|
11
|
+
kind: AgoActivityKind;
|
|
12
|
+
/** Human label, e.g. "Navigating to Products". Override via `labelFor`. */
|
|
13
|
+
label: string;
|
|
14
|
+
status: AgoActivityStatus;
|
|
15
|
+
/** The assistant message this activity belongs to (when known). */
|
|
16
|
+
messageId?: string;
|
|
17
|
+
toolName?: string;
|
|
18
|
+
toolDisplayName?: string;
|
|
19
|
+
functionName?: string;
|
|
20
|
+
arguments?: Record<string, unknown>;
|
|
21
|
+
message?: string;
|
|
22
|
+
data?: Record<string, unknown>;
|
|
23
|
+
formSchema?: FormSchema;
|
|
24
|
+
/** True when this item waits on the user before it runs. */
|
|
25
|
+
requiresApproval: boolean;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The kind of thing the agent is doing, normalized across the two wire sources
|
|
31
|
+
* (tool calls and client-function invocations) into one vocabulary the UI can
|
|
32
|
+
* switch on.
|
|
33
|
+
*/
|
|
34
|
+
export declare type AgoActivityKind = "navigation" | "action" | "status" | "progress" | "reasoning" | "confirmation" | "form";
|
|
35
|
+
|
|
36
|
+
/** Where the item is in its lifecycle. */
|
|
37
|
+
export declare type AgoActivityStatus = "running" | "done" | "error" | "awaiting-approval" | "rejected";
|
|
38
|
+
|
|
3
39
|
/**
|
|
4
40
|
* Agent information
|
|
5
41
|
*/
|
|
@@ -60,8 +96,20 @@ declare class AgoClient {
|
|
|
60
96
|
private warnedEmptyConversations;
|
|
61
97
|
/** Paused turns awaiting auto-resume, keyed by assistant message id. */
|
|
62
98
|
private pendingResumes;
|
|
99
|
+
/**
|
|
100
|
+
* Client function invocations held pending user approval, keyed by
|
|
101
|
+
* invocationId (the tool-call id). Populated when {@link requiresApproval}
|
|
102
|
+
* matches; drained by {@link approveFunction} / {@link rejectFunction}.
|
|
103
|
+
*/
|
|
104
|
+
private pendingApprovals;
|
|
63
105
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
64
106
|
private resumeGate;
|
|
107
|
+
/**
|
|
108
|
+
* Proactive-mode controller, set when the client was created with
|
|
109
|
+
* `proactive` options or when `createAgoProactive(client, opts)` was called.
|
|
110
|
+
* `null` otherwise.
|
|
111
|
+
*/
|
|
112
|
+
proactive: ProactiveController | null;
|
|
65
113
|
constructor(config: AgoConfig);
|
|
66
114
|
/**
|
|
67
115
|
* Send a message and receive a streaming response
|
|
@@ -110,6 +158,24 @@ declare class AgoClient {
|
|
|
110
158
|
*/
|
|
111
159
|
private maybeFlagEmptyReply;
|
|
112
160
|
private handleClientFunctionInvocation;
|
|
161
|
+
/**
|
|
162
|
+
* Whether a client function invocation must wait for explicit user approval.
|
|
163
|
+
* True when the {@link AgoConfig.approvalPolicy} returns true OR the function
|
|
164
|
+
* was registered with `requiresApproval: true` — the two OR together.
|
|
165
|
+
*/
|
|
166
|
+
private requiresApproval;
|
|
167
|
+
/**
|
|
168
|
+
* Approve a client function call held by the approval gate: run it, submit its
|
|
169
|
+
* result, and let the paused turn resume. No-op if the invocation is unknown
|
|
170
|
+
* (already handled, or never gated).
|
|
171
|
+
*/
|
|
172
|
+
approveFunction(invocationId: string): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Reject a client function call held by the approval gate: submit a rejection
|
|
175
|
+
* result so the agent sees the user declined, and let the paused turn resume
|
|
176
|
+
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
177
|
+
*/
|
|
178
|
+
rejectFunction(invocationId: string): Promise<void>;
|
|
113
179
|
/**
|
|
114
180
|
* Get list of conversations
|
|
115
181
|
*/
|
|
@@ -139,8 +205,10 @@ declare class AgoClient {
|
|
|
139
205
|
*
|
|
140
206
|
* Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
|
|
141
207
|
* navigation function would navigate again), so the app decides. Returns the
|
|
142
|
-
* resumed turn's final message, or `null` when there was nothing to resume
|
|
143
|
-
* some waiting function is not registered on this page
|
|
208
|
+
* resumed turn's final message, or `null` when there was nothing to resume,
|
|
209
|
+
* some waiting function is not registered on this page, or a waiting call is
|
|
210
|
+
* gated by the approval policy (it is held for `approveFunction` /
|
|
211
|
+
* `rejectFunction` and the turn stays paused, exactly as on the live stream).
|
|
144
212
|
*/
|
|
145
213
|
resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
|
|
146
214
|
/**
|
|
@@ -212,6 +280,14 @@ declare class AgoClient {
|
|
|
212
280
|
* Get all registered function schemas
|
|
213
281
|
*/
|
|
214
282
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
283
|
+
/**
|
|
284
|
+
* Execute a registered client function locally, through the same
|
|
285
|
+
* FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
|
|
286
|
+
* calls. Used by proactive nudge actions, where the user's explicit click on
|
|
287
|
+
* the action button constitutes the approval — nothing is submitted to the
|
|
288
|
+
* backend (there is no tool call to answer).
|
|
289
|
+
*/
|
|
290
|
+
executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
215
291
|
/**
|
|
216
292
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
217
293
|
*
|
|
@@ -313,6 +389,9 @@ declare class AgoClient {
|
|
|
313
389
|
*/
|
|
314
390
|
notifyContextChanged(): void;
|
|
315
391
|
/* Excluded from this release type: emitFormEvent */
|
|
392
|
+
/* Excluded from this release type: emitProactiveEvent */
|
|
393
|
+
/* Excluded from this release type: getHttp */
|
|
394
|
+
/* Excluded from this release type: getConfiguredAgent */
|
|
316
395
|
/**
|
|
317
396
|
* Enable automatic capture of the current browser page (URL + title).
|
|
318
397
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -357,6 +436,7 @@ declare class AgoClient {
|
|
|
357
436
|
* Clean up resources
|
|
358
437
|
*/
|
|
359
438
|
destroy(): void;
|
|
439
|
+
/* Excluded from this release type: reviveAfterDestroy */
|
|
360
440
|
}
|
|
361
441
|
|
|
362
442
|
/**
|
|
@@ -435,6 +515,15 @@ declare interface AgoClientEvents {
|
|
|
435
515
|
"toolCall:received": ToolCallData;
|
|
436
516
|
"toolCall:form": ToolCallData;
|
|
437
517
|
"function:invoke": ClientFunctionInvocation;
|
|
518
|
+
/**
|
|
519
|
+
* A client function call is held pending the user's approval (pause mode +
|
|
520
|
+
* an {@link AgoConfig.approvalPolicy}/`requiresApproval` match). The turn stays
|
|
521
|
+
* at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and
|
|
522
|
+
* resume, or `rejectFunction(invocationId)` to decline. Fires after
|
|
523
|
+
* `function:invoke` (which still fires for every call) and instead of the
|
|
524
|
+
* call running immediately.
|
|
525
|
+
*/
|
|
526
|
+
"function:awaiting-approval": ClientFunctionInvocation;
|
|
438
527
|
"function:result": {
|
|
439
528
|
invocationId: string;
|
|
440
529
|
result: unknown;
|
|
@@ -464,6 +553,25 @@ declare interface AgoClientEvents {
|
|
|
464
553
|
"connection:status": {
|
|
465
554
|
connected: boolean;
|
|
466
555
|
};
|
|
556
|
+
/**
|
|
557
|
+
* A proactive nudge passed every governor gate and is ready to display.
|
|
558
|
+
* `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
|
|
559
|
+
* `client.proactive.shown(nudge)` when they render it (impression tracking
|
|
560
|
+
* + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
|
|
561
|
+
*/
|
|
562
|
+
"nudge:ready": ProactiveNudgeInstance;
|
|
563
|
+
/** A nudge was displayed to the user (fires once per nudge). */
|
|
564
|
+
"nudge:shown": {
|
|
565
|
+
nudge: ProactiveNudgeInstance;
|
|
566
|
+
};
|
|
567
|
+
/** The user dismissed the nudge (its trigger is suppressed, see governor). */
|
|
568
|
+
"nudge:dismissed": {
|
|
569
|
+
nudge: ProactiveNudgeInstance;
|
|
570
|
+
};
|
|
571
|
+
/** The user accepted the nudge (its action ran / the chat is being seeded). */
|
|
572
|
+
"nudge:accepted": {
|
|
573
|
+
nudge: ProactiveNudgeInstance;
|
|
574
|
+
};
|
|
467
575
|
}
|
|
468
576
|
|
|
469
577
|
/**
|
|
@@ -503,6 +611,20 @@ export declare interface AgoConfig {
|
|
|
503
611
|
* Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
|
|
504
612
|
*/
|
|
505
613
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
614
|
+
/**
|
|
615
|
+
* Gate client function calls behind explicit user approval. Return `true` for
|
|
616
|
+
* an invocation the user must approve/reject before it runs; return `false`
|
|
617
|
+
* (or omit the policy) to let it run immediately as before.
|
|
618
|
+
*
|
|
619
|
+
* Only effective in pause mode (`clientFunctionsMode: "pause"`) — a gated call
|
|
620
|
+
* holds at `WAITING_CLIENT`, the SDK emits `function:awaiting-approval`, and it
|
|
621
|
+
* runs (and the turn resumes) only after `approveFunction(invocationId)`; a
|
|
622
|
+
* `rejectFunction(invocationId)` submits a rejection so the agent sees the
|
|
623
|
+
* decline. In placeholder mode there is no pause to hold, so the policy is a
|
|
624
|
+
* no-op and the call runs normally. A per-function `requiresApproval: true`
|
|
625
|
+
* also gates a call; the policy and the flag OR together.
|
|
626
|
+
*/
|
|
627
|
+
approvalPolicy?: (invocation: ClientFunctionInvocation) => boolean;
|
|
506
628
|
/**
|
|
507
629
|
* Max serialized size (bytes) of a client function result before the SDK
|
|
508
630
|
* replaces it with a flagged, truncated preview. Everything a handler
|
|
@@ -511,6 +633,16 @@ export declare interface AgoConfig {
|
|
|
511
633
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
512
634
|
*/
|
|
513
635
|
maxFunctionResultBytes?: number;
|
|
636
|
+
/**
|
|
637
|
+
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
638
|
+
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
639
|
+
* that can surface a nudge before the user opens the chat. Equivalent to
|
|
640
|
+
* calling `createAgoProactive(client, proactive)` — the resulting controller
|
|
641
|
+
* is available as `client.proactive`. Requires the tenant-level kill-switch
|
|
642
|
+
* (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
|
|
643
|
+
* default otherwise.
|
|
644
|
+
*/
|
|
645
|
+
proactive?: ProactiveOptions;
|
|
514
646
|
}
|
|
515
647
|
|
|
516
648
|
/**
|
|
@@ -554,12 +686,44 @@ export declare interface AgoMessage {
|
|
|
554
686
|
createdAt: Date;
|
|
555
687
|
}
|
|
556
688
|
|
|
689
|
+
/**
|
|
690
|
+
* Prebuilt proactive-nudge toast: a small, always-dismissable bubble anchored
|
|
691
|
+
* near the chat launcher. Never modal — it never blocks the page. Renders the
|
|
692
|
+
* nudge message, its optional action button, and an "open chat" affordance
|
|
693
|
+
* for nudges that expand into a conversation.
|
|
694
|
+
*/
|
|
695
|
+
export declare const AgoNudge: default_2.FC<AgoNudgeProps>;
|
|
696
|
+
|
|
697
|
+
export declare interface AgoNudgeProps {
|
|
698
|
+
/** The AGO client instance. If omitted, reads from AgoProvider context. */
|
|
699
|
+
client?: AgoClient;
|
|
700
|
+
/**
|
|
701
|
+
* Called after accepting a nudge that expands into the chat (agent-sourced
|
|
702
|
+
* or with a `goal`) — open your chat UI here. The conversation is already
|
|
703
|
+
* pre-seeded with a hidden kickoff message.
|
|
704
|
+
*/
|
|
705
|
+
onExpand?: UseProactiveNudgeOptions["onExpand"];
|
|
706
|
+
/** Auto-dismiss after this many ms. Off by default (nudges stay until acted on). */
|
|
707
|
+
autoHideMs?: number;
|
|
708
|
+
/** Corner to anchor to (near the chat launcher). Default `"bottom-right"`. */
|
|
709
|
+
position?: "bottom-right" | "bottom-left";
|
|
710
|
+
/** Label of the open-chat affordance. Default `"Open chat"`. */
|
|
711
|
+
openChatLabel?: string;
|
|
712
|
+
/** Additional CSS class (consumer hook only; the SDK ships no CSS for it). */
|
|
713
|
+
className?: string;
|
|
714
|
+
}
|
|
715
|
+
|
|
557
716
|
/**
|
|
558
717
|
* Options for {@link AgoClient.registerPageStateFunction}.
|
|
559
718
|
*/
|
|
560
719
|
export declare interface AgoPageStateOptions {
|
|
561
720
|
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
562
721
|
functionName?: string;
|
|
722
|
+
/**
|
|
723
|
+
* Require explicit user approval before this state change runs. See
|
|
724
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. Defaults to `false`.
|
|
725
|
+
*/
|
|
726
|
+
requiresApproval?: boolean;
|
|
563
727
|
}
|
|
564
728
|
|
|
565
729
|
/**
|
|
@@ -728,6 +892,11 @@ declare interface ClientFunctionDefinition {
|
|
|
728
892
|
* `Infinity` disables the guard for this function.
|
|
729
893
|
*/
|
|
730
894
|
maxResultBytes?: number;
|
|
895
|
+
/**
|
|
896
|
+
* Require explicit user approval before this function runs. See
|
|
897
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
898
|
+
*/
|
|
899
|
+
requiresApproval?: boolean;
|
|
731
900
|
}
|
|
732
901
|
|
|
733
902
|
/**
|
|
@@ -754,6 +923,11 @@ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name">
|
|
|
754
923
|
* disables the guard for this function.
|
|
755
924
|
*/
|
|
756
925
|
maxResultBytes?: number;
|
|
926
|
+
/**
|
|
927
|
+
* Require explicit user approval before this function runs. See
|
|
928
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
929
|
+
*/
|
|
930
|
+
requiresApproval?: boolean;
|
|
757
931
|
};
|
|
758
932
|
|
|
759
933
|
/**
|
|
@@ -794,6 +968,19 @@ declare interface ContextEntry {
|
|
|
794
968
|
description?: string;
|
|
795
969
|
/** Arbitrary structured data the AI should know about */
|
|
796
970
|
data?: Record<string, unknown>;
|
|
971
|
+
/**
|
|
972
|
+
* Marks the entry as constant for the whole conversation. The backend then
|
|
973
|
+
* pins it right after the system prompt, where LLM providers cache it across
|
|
974
|
+
* turns, instead of re-processing it next to every new user message.
|
|
975
|
+
*
|
|
976
|
+
* Only set this when the entry's content is byte-identical on every message
|
|
977
|
+
* of a conversation (a schema, a capability list, static instructions). A
|
|
978
|
+
* stable entry that changes between messages invalidates the provider's
|
|
979
|
+
* cache for the entire conversation history, which costs more than leaving
|
|
980
|
+
* the flag off. Default: `false` (re-sent near the newest user message).
|
|
981
|
+
* Backends that don't know the flag ignore it.
|
|
982
|
+
*/
|
|
983
|
+
stable?: boolean;
|
|
797
984
|
}
|
|
798
985
|
|
|
799
986
|
/**
|
|
@@ -898,10 +1085,22 @@ export declare interface FormCollector<V = Record<string, unknown>> {
|
|
|
898
1085
|
store: Store<FormCollectorState<V>>;
|
|
899
1086
|
/** Client functions to register: `[update]` or `[update, submit]`. */
|
|
900
1087
|
functions: ClientFunctionDefinition[];
|
|
901
|
-
/** Dynamic-context key under which the form state is exposed. */
|
|
1088
|
+
/** Dynamic-context key under which the live form state is exposed. */
|
|
902
1089
|
contextKey: string;
|
|
903
|
-
/**
|
|
1090
|
+
/**
|
|
1091
|
+
* Dynamic-context provider for the live form state (phase, values, missing)
|
|
1092
|
+
* — re-read on every message. The schema itself rides in the companion
|
|
1093
|
+
* {@link definitionContextProvider} entry.
|
|
1094
|
+
*/
|
|
904
1095
|
contextProvider: () => ContextEntry;
|
|
1096
|
+
/** Context key of the stable form definition (`<contextKey>:definition`). */
|
|
1097
|
+
definitionContextKey: string;
|
|
1098
|
+
/**
|
|
1099
|
+
* Provider for the form's definition (description + schema): identical on
|
|
1100
|
+
* every message and marked `stable: true`, so the backend can pin it in the
|
|
1101
|
+
* cacheable part of the prompt. Registered/removed by `install` alongside `contextProvider`.
|
|
1102
|
+
*/
|
|
1103
|
+
definitionContextProvider: () => ContextEntry;
|
|
905
1104
|
/** Register the functions + dynamic context on a client. Returns an uninstall fn. */
|
|
906
1105
|
install: (client: AgoClient) => () => void;
|
|
907
1106
|
/**
|
|
@@ -1048,6 +1247,43 @@ export declare interface FormSubmitResult {
|
|
|
1048
1247
|
error?: string;
|
|
1049
1248
|
}
|
|
1050
1249
|
|
|
1250
|
+
/**
|
|
1251
|
+
* HTTP client with authentication headers
|
|
1252
|
+
*/
|
|
1253
|
+
declare class HttpClient {
|
|
1254
|
+
private baseUrl;
|
|
1255
|
+
private headers;
|
|
1256
|
+
constructor(config: AgoConfig);
|
|
1257
|
+
/**
|
|
1258
|
+
* Update configuration (e.g., JWT token)
|
|
1259
|
+
*/
|
|
1260
|
+
updateConfig(config: Partial<AgoConfig>): void;
|
|
1261
|
+
/**
|
|
1262
|
+
* Make a GET request
|
|
1263
|
+
*/
|
|
1264
|
+
get<T>(path: string): Promise<T>;
|
|
1265
|
+
/**
|
|
1266
|
+
* Make a POST request with JSON body.
|
|
1267
|
+
*
|
|
1268
|
+
* `keepalive: true` lets the request survive a page unload (used by the
|
|
1269
|
+
* proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
|
|
1270
|
+
* headers, so it's a keepalive fetch instead).
|
|
1271
|
+
*/
|
|
1272
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
1273
|
+
keepalive?: boolean;
|
|
1274
|
+
}): Promise<T>;
|
|
1275
|
+
/**
|
|
1276
|
+
* Make a POST request and return the raw Response (for streaming)
|
|
1277
|
+
*/
|
|
1278
|
+
postStream(path: string, body?: unknown): Promise<Response>;
|
|
1279
|
+
/**
|
|
1280
|
+
* Make a POST request with FormData (for file uploads)
|
|
1281
|
+
*/
|
|
1282
|
+
postFormData(path: string, formData: FormData): Promise<Response>;
|
|
1283
|
+
private request;
|
|
1284
|
+
private handleErrorResponse;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1051
1287
|
/**
|
|
1052
1288
|
* Async sibling of {@link createFormCollector} that pulls the form's definition
|
|
1053
1289
|
* (description + schema + submit target) from the backend by name — the single
|
|
@@ -1142,6 +1378,182 @@ declare interface MockAgoClientOptions {
|
|
|
1142
1378
|
|
|
1143
1379
|
declare type MockFn = (...args: any[]) => any;
|
|
1144
1380
|
|
|
1381
|
+
/**
|
|
1382
|
+
* Optional action attached to a nudge. Accepting a `functionName` action
|
|
1383
|
+
* executes the registered client function (same `FunctionRegistry` path as
|
|
1384
|
+
* agent-invoked calls); `setPageState` applies values through the registered
|
|
1385
|
+
* page-state controls.
|
|
1386
|
+
*/
|
|
1387
|
+
export declare type NudgeAction = {
|
|
1388
|
+
label: string;
|
|
1389
|
+
functionName: string;
|
|
1390
|
+
arguments?: Record<string, unknown>;
|
|
1391
|
+
} | {
|
|
1392
|
+
label: string;
|
|
1393
|
+
setPageState: Record<string, unknown>;
|
|
1394
|
+
};
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* Controller returned by {@link createAgoProactive} (also available as
|
|
1398
|
+
* `client.proactive`).
|
|
1399
|
+
*/
|
|
1400
|
+
export declare interface ProactiveController {
|
|
1401
|
+
/** Persistently opt this browser out of proactive nudges. */
|
|
1402
|
+
optOut(): void;
|
|
1403
|
+
/** Undo {@link optOut}. */
|
|
1404
|
+
optIn(): void;
|
|
1405
|
+
isOptedOut(): boolean;
|
|
1406
|
+
/**
|
|
1407
|
+
* Tell the governor the user is already engaged (e.g. the chat widget is
|
|
1408
|
+
* open) — nudges are suppressed while `true`. Call from the UI layer.
|
|
1409
|
+
*/
|
|
1410
|
+
setEngaged(engaged: boolean): void;
|
|
1411
|
+
/** App-pushed field error counter (field NAME only — never values). */
|
|
1412
|
+
signalFieldError(fieldName: string): void;
|
|
1413
|
+
/** Current aggregated friction snapshot. */
|
|
1414
|
+
getSignalsSnapshot(): SignalsSnapshot;
|
|
1415
|
+
/** The nudge currently occupying the single-nudge slot, if any. */
|
|
1416
|
+
getActiveNudge(): ProactiveNudgeInstance | null;
|
|
1417
|
+
/**
|
|
1418
|
+
* Mark the nudge as displayed. Idempotent per nudge; counts it against the
|
|
1419
|
+
* frequency caps, tracks the impression, and emits `nudge:shown`.
|
|
1420
|
+
*/
|
|
1421
|
+
shown(nudge: ProactiveNudgeInstance): void;
|
|
1422
|
+
/**
|
|
1423
|
+
* Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
|
|
1424
|
+
* and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
|
|
1425
|
+
* hidden kickoff message so the agent starts the turn with full context.
|
|
1426
|
+
*/
|
|
1427
|
+
accept(nudge: ProactiveNudgeInstance): Promise<void>;
|
|
1428
|
+
/** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
|
|
1429
|
+
dismiss(nudge: ProactiveNudgeInstance): void;
|
|
1430
|
+
/** Report a downstream conversion attributable to the nudge (analytics only). */
|
|
1431
|
+
markConverted(nudge: ProactiveNudgeInstance): void;
|
|
1432
|
+
/** Detach everything: listeners, timers, context provider, event flush. */
|
|
1433
|
+
destroy(): void;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
|
|
1437
|
+
export declare interface ProactiveNudgeInstance {
|
|
1438
|
+
/** Client-generated uuid for this nudge instance (`client_nudge_id`). */
|
|
1439
|
+
id: string;
|
|
1440
|
+
triggerId: string;
|
|
1441
|
+
/** `static` = configured message; `agent` = backend LLM evaluation. */
|
|
1442
|
+
source: "static" | "agent";
|
|
1443
|
+
message: string;
|
|
1444
|
+
action?: NudgeAction;
|
|
1445
|
+
goal?: string;
|
|
1446
|
+
/** See {@link ProactiveTrigger.kickoff}. */
|
|
1447
|
+
kickoff?: string;
|
|
1448
|
+
createdAt: Date;
|
|
1449
|
+
/** Server-side nudge id (agent nudges only). */
|
|
1450
|
+
serverNudgeId?: string;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
|
|
1454
|
+
export declare interface ProactiveOptions {
|
|
1455
|
+
triggers: ProactiveTrigger[];
|
|
1456
|
+
/**
|
|
1457
|
+
* Global caps on nudges actually shown. `perSession` is in-memory (page
|
|
1458
|
+
* lifetime); `perDay` is persisted in localStorage with a date rollover —
|
|
1459
|
+
* best-effort by design (private browsing resets it); the costly LLM path is
|
|
1460
|
+
* additionally capped server-side.
|
|
1461
|
+
*/
|
|
1462
|
+
frequencyCap?: {
|
|
1463
|
+
perSession?: number;
|
|
1464
|
+
perDay?: number;
|
|
1465
|
+
};
|
|
1466
|
+
/** Evaluation tick, ms. Default 1000. Zero network per tick. */
|
|
1467
|
+
tickMs?: number;
|
|
1468
|
+
/** Storage backend for persisted governance state. Default `localStorage`. */
|
|
1469
|
+
storage?: StorageLike;
|
|
1470
|
+
/** Storage key for persisted governance state. Default `"ago_proactive"`. */
|
|
1471
|
+
storageKey?: string;
|
|
1472
|
+
/** Tuning of the signal detectors (rage-click window, throttles…). */
|
|
1473
|
+
signals?: SignalCollectorTuning;
|
|
1474
|
+
/**
|
|
1475
|
+
* Local demos and tests ONLY: bypass the remote kill-switch. When set, the
|
|
1476
|
+
* `GET /config` fetch is skipped and the kill-switch takes this value.
|
|
1477
|
+
* Leave unset in production — the tenant admin controls the feature, and
|
|
1478
|
+
* the evaluate endpoint stays gated server-side regardless.
|
|
1479
|
+
*/
|
|
1480
|
+
enabledOverride?: boolean;
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
/** A declarative proactive trigger. */
|
|
1484
|
+
export declare interface ProactiveTrigger {
|
|
1485
|
+
/** Stable id, used for cooldowns, dismissal memory, and analytics. */
|
|
1486
|
+
id: string;
|
|
1487
|
+
/** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
|
|
1488
|
+
when: ProactiveTriggerWhen;
|
|
1489
|
+
/**
|
|
1490
|
+
* Min time between two firings of this trigger (persisted across reloads).
|
|
1491
|
+
* A firing is the moment the trigger passes the gates — including an agent
|
|
1492
|
+
* evaluation that decides NOT to intervene, so a persistent condition can't
|
|
1493
|
+
* hammer the evaluate endpoint. Default 60 000.
|
|
1494
|
+
*/
|
|
1495
|
+
cooldownMs?: number;
|
|
1496
|
+
/**
|
|
1497
|
+
* `'agent'` asks the backend's fast-LLM second filter whether (and how) to
|
|
1498
|
+
* intervene; a `static` object shows the given message with no network call.
|
|
1499
|
+
*/
|
|
1500
|
+
intervene: "agent" | {
|
|
1501
|
+
type: "static";
|
|
1502
|
+
message: string;
|
|
1503
|
+
action?: NudgeAction;
|
|
1504
|
+
};
|
|
1505
|
+
/**
|
|
1506
|
+
* What the agent should help with. Sent to the evaluate endpoint, and used to
|
|
1507
|
+
* pre-seed the chat turn when the user accepts the nudge.
|
|
1508
|
+
*/
|
|
1509
|
+
goal?: string;
|
|
1510
|
+
/**
|
|
1511
|
+
* User-voice line used to OPEN the conversation when the user accepts this
|
|
1512
|
+
* nudge and no conversation exists yet — a hidden kickoff cannot start one
|
|
1513
|
+
* (the backend rejects it). Sent as a visible user message, so write it in
|
|
1514
|
+
* the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
|
|
1515
|
+
* already open, the SDK sends a hidden meta kickoff instead and this field
|
|
1516
|
+
* is unused. Without it, accepting with no open conversation skips the chat
|
|
1517
|
+
* pre-seed (the nudge action still runs).
|
|
1518
|
+
*/
|
|
1519
|
+
kickoff?: string;
|
|
1520
|
+
/**
|
|
1521
|
+
* How long a dismissal of this trigger's nudge suppresses it (persisted).
|
|
1522
|
+
* Default 24h.
|
|
1523
|
+
*/
|
|
1524
|
+
resurfaceAfterMs?: number;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
|
|
1529
|
+
* must pass against the current {@link SignalsSnapshot}. Numeric fields are
|
|
1530
|
+
* `>=` thresholds.
|
|
1531
|
+
*/
|
|
1532
|
+
declare interface ProactiveTriggerWhen {
|
|
1533
|
+
/**
|
|
1534
|
+
* Route pattern the current pathname must match. Supports the SDK's route
|
|
1535
|
+
* styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
|
|
1536
|
+
* wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
|
|
1537
|
+
* remaining segments (`/dossier/*`).
|
|
1538
|
+
*/
|
|
1539
|
+
route?: string;
|
|
1540
|
+
/** Min time since the last user activity, ms. */
|
|
1541
|
+
idleMs?: number;
|
|
1542
|
+
/** Min time spent on the current route, ms. */
|
|
1543
|
+
dwellMs?: number;
|
|
1544
|
+
/**
|
|
1545
|
+
* Partial deep match against the registered page state (funnel step,
|
|
1546
|
+
* filters…). Every key present here must deep-match the live value.
|
|
1547
|
+
*/
|
|
1548
|
+
pageState?: Partial<Record<string, unknown>>;
|
|
1549
|
+
/** Min rage-click bursts on the current route. */
|
|
1550
|
+
rageClicks?: number;
|
|
1551
|
+
/** Min A→B→A→B route oscillations this session. */
|
|
1552
|
+
routeBounces?: number;
|
|
1553
|
+
/** Per-field minimum error counts (field NAME → min count). */
|
|
1554
|
+
fieldErrors?: Record<string, number>;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1145
1557
|
/**
|
|
1146
1558
|
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
1147
1559
|
* continuation fires (e.g. wait for the destination page to mount after a
|
|
@@ -1174,6 +1586,54 @@ declare interface SendMessageOptions {
|
|
|
1174
1586
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
1175
1587
|
}
|
|
1176
1588
|
|
|
1589
|
+
/** Tuning knobs for the collector's detectors. All optional. */
|
|
1590
|
+
declare interface SignalCollectorTuning {
|
|
1591
|
+
/** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
|
|
1592
|
+
activityThrottleMs?: number;
|
|
1593
|
+
/** Rage click: clicks needed to count a burst. Default 3. */
|
|
1594
|
+
rageClickCount?: number;
|
|
1595
|
+
/** Rage click: max time between first and last click of a burst, ms. Default 1000. */
|
|
1596
|
+
rageClickWindowMs?: number;
|
|
1597
|
+
/** Rage click: max radius between clicks of a burst, px. Default 24. */
|
|
1598
|
+
rageClickRadiusPx?: number;
|
|
1599
|
+
/** Max routes kept in the recent-route sequence. Default 10. */
|
|
1600
|
+
maxRecentRoutes?: number;
|
|
1601
|
+
/** Max typed signals kept in the ring buffer. Default 50. */
|
|
1602
|
+
maxSignals?: number;
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Aggregated view of the current friction state. Registered as a dynamic
|
|
1607
|
+
* context provider (key `friction_signals`) so it rides along as
|
|
1608
|
+
* `client_context` on every message, and sent as `signals` to the proactive
|
|
1609
|
+
* evaluate endpoint.
|
|
1610
|
+
*/
|
|
1611
|
+
declare interface SignalsSnapshot {
|
|
1612
|
+
/** Current pathname. */
|
|
1613
|
+
route: string;
|
|
1614
|
+
/** Time spent on the current route, ms. */
|
|
1615
|
+
dwellMs: number;
|
|
1616
|
+
/** Time since the last user activity (pointer/key/scroll/touch), ms. */
|
|
1617
|
+
idleMs: number;
|
|
1618
|
+
/** Rage-click bursts detected on the current route. */
|
|
1619
|
+
rageClicks: number;
|
|
1620
|
+
/**
|
|
1621
|
+
* A→B→A→B route oscillations detected in the recent route sequence. Rolling
|
|
1622
|
+
* session counter (cross-route by nature); trigger cooldowns and dismissal
|
|
1623
|
+
* memory keep it from re-firing forever.
|
|
1624
|
+
*/
|
|
1625
|
+
routeBounces: number;
|
|
1626
|
+
/** App-pushed field error counters (field NAME → count), current route only. */
|
|
1627
|
+
fieldErrors: Record<string, number>;
|
|
1628
|
+
/** Most recent pathnames, oldest first (bounded). */
|
|
1629
|
+
recentRoutes: string[];
|
|
1630
|
+
/**
|
|
1631
|
+
* Merged `AgoStateControl.get()` snapshot of the registered page-state
|
|
1632
|
+
* controls (funnel step, filters…), or `null` when none are registered.
|
|
1633
|
+
*/
|
|
1634
|
+
pageState: Record<string, unknown> | null;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1177
1637
|
/**
|
|
1178
1638
|
* SSE stream chunk data
|
|
1179
1639
|
*/
|
|
@@ -1217,6 +1677,9 @@ declare interface SSEChunkData {
|
|
|
1217
1677
|
waiting_tool_call_ids?: string[];
|
|
1218
1678
|
}
|
|
1219
1679
|
|
|
1680
|
+
/** The slice of the Web Storage API that {@link createStore} relies on. */
|
|
1681
|
+
declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
|
|
1682
|
+
|
|
1220
1683
|
/**
|
|
1221
1684
|
* A minimal observable store: one value, synchronous subscriptions, and
|
|
1222
1685
|
* optional persistence via {@link PersistOptions} (localStorage by default).
|
|
@@ -1307,6 +1770,58 @@ export declare function useAgo(config: UseAgoOptions | null): {
|
|
|
1307
1770
|
isReady: boolean;
|
|
1308
1771
|
};
|
|
1309
1772
|
|
|
1773
|
+
/**
|
|
1774
|
+
* A live, normalized feed of what the agent is doing — navigations, state
|
|
1775
|
+
* changes, forms, confirmations, status, progress — plus the controls to
|
|
1776
|
+
* approve/reject/submit the items that wait on the user.
|
|
1777
|
+
*
|
|
1778
|
+
* Client functions surface via `function:invoke` (they're filtered out of
|
|
1779
|
+
* `toolCall:received`); everything else via `toolCall:received`. Reasoning is
|
|
1780
|
+
* suppressed unless `includeReasoning` is set. Approvals require the client's
|
|
1781
|
+
* approval gate (`AgoConfig.approvalPolicy` / `requiresApproval`, pause mode).
|
|
1782
|
+
*
|
|
1783
|
+
* ```tsx
|
|
1784
|
+
* const { items, latest, approve, reject } = useAgoActivity({
|
|
1785
|
+
* labelFor: (i) =>
|
|
1786
|
+
* i.kind === "navigation" ? routeLabels[i.arguments?.page as string] : undefined,
|
|
1787
|
+
* });
|
|
1788
|
+
* ```
|
|
1789
|
+
*/
|
|
1790
|
+
export declare function useAgoActivity(options?: UseAgoActivityOptions): UseAgoActivityResult;
|
|
1791
|
+
|
|
1792
|
+
export declare interface UseAgoActivityOptions {
|
|
1793
|
+
/** The AGO client. If omitted, reads from AgoProvider context. */
|
|
1794
|
+
client?: AgoClient;
|
|
1795
|
+
/**
|
|
1796
|
+
* Include the model's `reasoning` items in the feed. Off by default — the
|
|
1797
|
+
* chain-of-thought is noisy for an activity display.
|
|
1798
|
+
*/
|
|
1799
|
+
includeReasoning?: boolean;
|
|
1800
|
+
/**
|
|
1801
|
+
* Override the default label for an item. Return a string to replace it, or
|
|
1802
|
+
* `undefined` to keep the default. Use this to map route names / function
|
|
1803
|
+
* names to friendly copy, e.g. `navigateToPage` → "Navigating to Products".
|
|
1804
|
+
*/
|
|
1805
|
+
labelFor?: (item: AgoActivityItem) => string | undefined;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
export declare interface UseAgoActivityResult {
|
|
1809
|
+
/** Time-ordered activity for the current/most-recent turn. */
|
|
1810
|
+
items: AgoActivityItem[];
|
|
1811
|
+
/** The most recent item — handy for a collapsed "latest action" line. */
|
|
1812
|
+
latest?: AgoActivityItem;
|
|
1813
|
+
/** True while any item is waiting on the user (approval or form). */
|
|
1814
|
+
isAwaitingApproval: boolean;
|
|
1815
|
+
/** Approve an awaiting item (client function or confirmation). */
|
|
1816
|
+
approve: (id: string) => Promise<void>;
|
|
1817
|
+
/** Reject an awaiting item (client function or confirmation). */
|
|
1818
|
+
reject: (id: string) => Promise<void>;
|
|
1819
|
+
/** Submit form data for a `form` item. */
|
|
1820
|
+
submitForm: (id: string, values: Record<string, unknown>) => Promise<void>;
|
|
1821
|
+
/** Drop all items (e.g. when starting a new conversation). */
|
|
1822
|
+
clear: () => void;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1310
1825
|
/**
|
|
1311
1826
|
* Auto-continue the agent after it navigates, so a "go to page B and change X"
|
|
1312
1827
|
* request completes in one user gesture. Mount this once inside `AgoProvider`.
|
|
@@ -1421,6 +1936,11 @@ export declare interface UseAgoFunctionOptions {
|
|
|
1421
1936
|
* `Infinity` disables the guard for this function.
|
|
1422
1937
|
*/
|
|
1423
1938
|
maxResultBytes?: number;
|
|
1939
|
+
/**
|
|
1940
|
+
* Require explicit user approval before this function runs (pause mode only).
|
|
1941
|
+
* See `AgoConfig.approvalPolicy`.
|
|
1942
|
+
*/
|
|
1943
|
+
requiresApproval?: boolean;
|
|
1424
1944
|
}
|
|
1425
1945
|
|
|
1426
1946
|
/**
|
|
@@ -1634,4 +2154,41 @@ export declare interface UseMessagesResult {
|
|
|
1634
2154
|
*/
|
|
1635
2155
|
export declare function useOptionalAgoClient(): AgoClient | null;
|
|
1636
2156
|
|
|
2157
|
+
/**
|
|
2158
|
+
* Consume proactive nudges (see `createAgoProactive` / `AgoConfig.proactive`).
|
|
2159
|
+
* Receiving a nudge marks it as shown (impression tracking + frequency caps),
|
|
2160
|
+
* so only render ONE consumer of this hook per nudge surface — or use the
|
|
2161
|
+
* prebuilt `<AgoNudge />`.
|
|
2162
|
+
*
|
|
2163
|
+
* ```tsx
|
|
2164
|
+
* const { nudge, accept, dismiss } = useProactiveNudge({
|
|
2165
|
+
* onExpand: () => setChatOpen(true),
|
|
2166
|
+
* });
|
|
2167
|
+
* if (!nudge) return null;
|
|
2168
|
+
* return <MyToast text={nudge.message} onAccept={accept} onClose={dismiss} />;
|
|
2169
|
+
* ```
|
|
2170
|
+
*/
|
|
2171
|
+
export declare function useProactiveNudge(options?: UseProactiveNudgeOptions): UseProactiveNudgeResult;
|
|
2172
|
+
|
|
2173
|
+
export declare interface UseProactiveNudgeOptions {
|
|
2174
|
+
/** The AGO client instance. If omitted, reads from AgoProvider context. */
|
|
2175
|
+
client?: AgoClient;
|
|
2176
|
+
/**
|
|
2177
|
+
* Called after `accept()` when the nudge should expand into the chat (it
|
|
2178
|
+
* came from `intervene: 'agent'` or carries a `goal`). The SDK has already
|
|
2179
|
+
* pre-seeded the conversation with a hidden kickoff message at this point;
|
|
2180
|
+
* use this to open your chat UI (widget, panel…).
|
|
2181
|
+
*/
|
|
2182
|
+
onExpand?: (nudge: ProactiveNudgeInstance) => void;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
export declare interface UseProactiveNudgeResult {
|
|
2186
|
+
/** The active nudge, or `null` when none is ready. */
|
|
2187
|
+
nudge: ProactiveNudgeInstance | null;
|
|
2188
|
+
/** Accept the nudge: run its action, seed the chat when relevant, clear it. */
|
|
2189
|
+
accept: () => Promise<void>;
|
|
2190
|
+
/** Dismiss the nudge (suppresses its trigger, see the governor). */
|
|
2191
|
+
dismiss: () => void;
|
|
2192
|
+
}
|
|
2193
|
+
|
|
1637
2194
|
export { }
|