@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/angular.d.ts
CHANGED
|
@@ -58,8 +58,20 @@ declare class AgoClient {
|
|
|
58
58
|
private warnedEmptyConversations;
|
|
59
59
|
/** Paused turns awaiting auto-resume, keyed by assistant message id. */
|
|
60
60
|
private pendingResumes;
|
|
61
|
+
/**
|
|
62
|
+
* Client function invocations held pending user approval, keyed by
|
|
63
|
+
* invocationId (the tool-call id). Populated when {@link requiresApproval}
|
|
64
|
+
* matches; drained by {@link approveFunction} / {@link rejectFunction}.
|
|
65
|
+
*/
|
|
66
|
+
private pendingApprovals;
|
|
61
67
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
62
68
|
private resumeGate;
|
|
69
|
+
/**
|
|
70
|
+
* Proactive-mode controller, set when the client was created with
|
|
71
|
+
* `proactive` options or when `createAgoProactive(client, opts)` was called.
|
|
72
|
+
* `null` otherwise.
|
|
73
|
+
*/
|
|
74
|
+
proactive: ProactiveController | null;
|
|
63
75
|
constructor(config: AgoConfig);
|
|
64
76
|
/**
|
|
65
77
|
* Send a message and receive a streaming response
|
|
@@ -108,6 +120,24 @@ declare class AgoClient {
|
|
|
108
120
|
*/
|
|
109
121
|
private maybeFlagEmptyReply;
|
|
110
122
|
private handleClientFunctionInvocation;
|
|
123
|
+
/**
|
|
124
|
+
* Whether a client function invocation must wait for explicit user approval.
|
|
125
|
+
* True when the {@link AgoConfig.approvalPolicy} returns true OR the function
|
|
126
|
+
* was registered with `requiresApproval: true` — the two OR together.
|
|
127
|
+
*/
|
|
128
|
+
private requiresApproval;
|
|
129
|
+
/**
|
|
130
|
+
* Approve a client function call held by the approval gate: run it, submit its
|
|
131
|
+
* result, and let the paused turn resume. No-op if the invocation is unknown
|
|
132
|
+
* (already handled, or never gated).
|
|
133
|
+
*/
|
|
134
|
+
approveFunction(invocationId: string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Reject a client function call held by the approval gate: submit a rejection
|
|
137
|
+
* result so the agent sees the user declined, and let the paused turn resume
|
|
138
|
+
* (the agent decides what to do next). No-op if the invocation is unknown.
|
|
139
|
+
*/
|
|
140
|
+
rejectFunction(invocationId: string): Promise<void>;
|
|
111
141
|
/**
|
|
112
142
|
* Get list of conversations
|
|
113
143
|
*/
|
|
@@ -137,8 +167,10 @@ declare class AgoClient {
|
|
|
137
167
|
*
|
|
138
168
|
* Opt-in on purpose — re-running functions on reload can be surprising (e.g. a
|
|
139
169
|
* navigation function would navigate again), so the app decides. Returns the
|
|
140
|
-
* resumed turn's final message, or `null` when there was nothing to resume
|
|
141
|
-
* some waiting function is not registered on this page
|
|
170
|
+
* resumed turn's final message, or `null` when there was nothing to resume,
|
|
171
|
+
* some waiting function is not registered on this page, or a waiting call is
|
|
172
|
+
* gated by the approval policy (it is held for `approveFunction` /
|
|
173
|
+
* `rejectFunction` and the turn stays paused, exactly as on the live stream).
|
|
142
174
|
*/
|
|
143
175
|
resumePendingClientFunctions(conversation: Conversation): Promise<AgoMessage | null>;
|
|
144
176
|
/**
|
|
@@ -210,6 +242,14 @@ declare class AgoClient {
|
|
|
210
242
|
* Get all registered function schemas
|
|
211
243
|
*/
|
|
212
244
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
245
|
+
/**
|
|
246
|
+
* Execute a registered client function locally, through the same
|
|
247
|
+
* FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
|
|
248
|
+
* calls. Used by proactive nudge actions, where the user's explicit click on
|
|
249
|
+
* the action button constitutes the approval — nothing is submitted to the
|
|
250
|
+
* backend (there is no tool call to answer).
|
|
251
|
+
*/
|
|
252
|
+
executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
213
253
|
/**
|
|
214
254
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
215
255
|
*
|
|
@@ -311,6 +351,9 @@ declare class AgoClient {
|
|
|
311
351
|
*/
|
|
312
352
|
notifyContextChanged(): void;
|
|
313
353
|
/* Excluded from this release type: emitFormEvent */
|
|
354
|
+
/* Excluded from this release type: emitProactiveEvent */
|
|
355
|
+
/* Excluded from this release type: getHttp */
|
|
356
|
+
/* Excluded from this release type: getConfiguredAgent */
|
|
314
357
|
/**
|
|
315
358
|
* Enable automatic capture of the current browser page (URL + title).
|
|
316
359
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -355,6 +398,7 @@ declare class AgoClient {
|
|
|
355
398
|
* Clean up resources
|
|
356
399
|
*/
|
|
357
400
|
destroy(): void;
|
|
401
|
+
/* Excluded from this release type: reviveAfterDestroy */
|
|
358
402
|
}
|
|
359
403
|
|
|
360
404
|
/**
|
|
@@ -433,6 +477,15 @@ export declare interface AgoClientEvents {
|
|
|
433
477
|
"toolCall:received": ToolCallData;
|
|
434
478
|
"toolCall:form": ToolCallData;
|
|
435
479
|
"function:invoke": ClientFunctionInvocation;
|
|
480
|
+
/**
|
|
481
|
+
* A client function call is held pending the user's approval (pause mode +
|
|
482
|
+
* an {@link AgoConfig.approvalPolicy}/`requiresApproval` match). The turn stays
|
|
483
|
+
* at `WAITING_CLIENT`; call `approveFunction(invocationId)` to run it and
|
|
484
|
+
* resume, or `rejectFunction(invocationId)` to decline. Fires after
|
|
485
|
+
* `function:invoke` (which still fires for every call) and instead of the
|
|
486
|
+
* call running immediately.
|
|
487
|
+
*/
|
|
488
|
+
"function:awaiting-approval": ClientFunctionInvocation;
|
|
436
489
|
"function:result": {
|
|
437
490
|
invocationId: string;
|
|
438
491
|
result: unknown;
|
|
@@ -462,6 +515,25 @@ export declare interface AgoClientEvents {
|
|
|
462
515
|
"connection:status": {
|
|
463
516
|
connected: boolean;
|
|
464
517
|
};
|
|
518
|
+
/**
|
|
519
|
+
* A proactive nudge passed every governor gate and is ready to display.
|
|
520
|
+
* `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
|
|
521
|
+
* `client.proactive.shown(nudge)` when they render it (impression tracking
|
|
522
|
+
* + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
|
|
523
|
+
*/
|
|
524
|
+
"nudge:ready": ProactiveNudgeInstance;
|
|
525
|
+
/** A nudge was displayed to the user (fires once per nudge). */
|
|
526
|
+
"nudge:shown": {
|
|
527
|
+
nudge: ProactiveNudgeInstance;
|
|
528
|
+
};
|
|
529
|
+
/** The user dismissed the nudge (its trigger is suppressed, see governor). */
|
|
530
|
+
"nudge:dismissed": {
|
|
531
|
+
nudge: ProactiveNudgeInstance;
|
|
532
|
+
};
|
|
533
|
+
/** The user accepted the nudge (its action ran / the chat is being seeded). */
|
|
534
|
+
"nudge:accepted": {
|
|
535
|
+
nudge: ProactiveNudgeInstance;
|
|
536
|
+
};
|
|
465
537
|
}
|
|
466
538
|
|
|
467
539
|
/**
|
|
@@ -501,6 +573,20 @@ export declare interface AgoConfig {
|
|
|
501
573
|
* Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
|
|
502
574
|
*/
|
|
503
575
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
576
|
+
/**
|
|
577
|
+
* Gate client function calls behind explicit user approval. Return `true` for
|
|
578
|
+
* an invocation the user must approve/reject before it runs; return `false`
|
|
579
|
+
* (or omit the policy) to let it run immediately as before.
|
|
580
|
+
*
|
|
581
|
+
* Only effective in pause mode (`clientFunctionsMode: "pause"`) — a gated call
|
|
582
|
+
* holds at `WAITING_CLIENT`, the SDK emits `function:awaiting-approval`, and it
|
|
583
|
+
* runs (and the turn resumes) only after `approveFunction(invocationId)`; a
|
|
584
|
+
* `rejectFunction(invocationId)` submits a rejection so the agent sees the
|
|
585
|
+
* decline. In placeholder mode there is no pause to hold, so the policy is a
|
|
586
|
+
* no-op and the call runs normally. A per-function `requiresApproval: true`
|
|
587
|
+
* also gates a call; the policy and the flag OR together.
|
|
588
|
+
*/
|
|
589
|
+
approvalPolicy?: (invocation: ClientFunctionInvocation) => boolean;
|
|
504
590
|
/**
|
|
505
591
|
* Max serialized size (bytes) of a client function result before the SDK
|
|
506
592
|
* replaces it with a flagged, truncated preview. Everything a handler
|
|
@@ -509,6 +595,16 @@ export declare interface AgoConfig {
|
|
|
509
595
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
510
596
|
*/
|
|
511
597
|
maxFunctionResultBytes?: number;
|
|
598
|
+
/**
|
|
599
|
+
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
600
|
+
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
601
|
+
* that can surface a nudge before the user opens the chat. Equivalent to
|
|
602
|
+
* calling `createAgoProactive(client, proactive)` — the resulting controller
|
|
603
|
+
* is available as `client.proactive`. Requires the tenant-level kill-switch
|
|
604
|
+
* (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
|
|
605
|
+
* default otherwise.
|
|
606
|
+
*/
|
|
607
|
+
proactive?: ProactiveOptions;
|
|
512
608
|
}
|
|
513
609
|
|
|
514
610
|
declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
|
|
@@ -545,6 +641,11 @@ export declare interface AgoMessage {
|
|
|
545
641
|
export declare interface AgoPageStateOptions {
|
|
546
642
|
/** Name of the synthesized client function. Defaults to "setPageState". */
|
|
547
643
|
functionName?: string;
|
|
644
|
+
/**
|
|
645
|
+
* Require explicit user approval before this state change runs. See
|
|
646
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. Defaults to `false`.
|
|
647
|
+
*/
|
|
648
|
+
requiresApproval?: boolean;
|
|
548
649
|
}
|
|
549
650
|
|
|
550
651
|
export declare type AgoProvideOptions = AgoConfig;
|
|
@@ -726,6 +827,11 @@ declare interface ClientFunctionDefinition {
|
|
|
726
827
|
* `Infinity` disables the guard for this function.
|
|
727
828
|
*/
|
|
728
829
|
maxResultBytes?: number;
|
|
830
|
+
/**
|
|
831
|
+
* Require explicit user approval before this function runs. See
|
|
832
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
833
|
+
*/
|
|
834
|
+
requiresApproval?: boolean;
|
|
729
835
|
}
|
|
730
836
|
|
|
731
837
|
/**
|
|
@@ -752,6 +858,11 @@ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name">
|
|
|
752
858
|
* disables the guard for this function.
|
|
753
859
|
*/
|
|
754
860
|
maxResultBytes?: number;
|
|
861
|
+
/**
|
|
862
|
+
* Require explicit user approval before this function runs. See
|
|
863
|
+
* {@link AgoConfig.approvalPolicy} — pause mode only. ORs with the policy.
|
|
864
|
+
*/
|
|
865
|
+
requiresApproval?: boolean;
|
|
755
866
|
};
|
|
756
867
|
|
|
757
868
|
/**
|
|
@@ -792,6 +903,19 @@ declare interface ContextEntry {
|
|
|
792
903
|
description?: string;
|
|
793
904
|
/** Arbitrary structured data the AI should know about */
|
|
794
905
|
data?: Record<string, unknown>;
|
|
906
|
+
/**
|
|
907
|
+
* Marks the entry as constant for the whole conversation. The backend then
|
|
908
|
+
* pins it right after the system prompt, where LLM providers cache it across
|
|
909
|
+
* turns, instead of re-processing it next to every new user message.
|
|
910
|
+
*
|
|
911
|
+
* Only set this when the entry's content is byte-identical on every message
|
|
912
|
+
* of a conversation (a schema, a capability list, static instructions). A
|
|
913
|
+
* stable entry that changes between messages invalidates the provider's
|
|
914
|
+
* cache for the entire conversation history, which costs more than leaving
|
|
915
|
+
* the flag off. Default: `false` (re-sent near the newest user message).
|
|
916
|
+
* Backends that don't know the flag ignore it.
|
|
917
|
+
*/
|
|
918
|
+
stable?: boolean;
|
|
795
919
|
}
|
|
796
920
|
|
|
797
921
|
/**
|
|
@@ -915,6 +1039,43 @@ declare interface FormSchema {
|
|
|
915
1039
|
required?: string[];
|
|
916
1040
|
}
|
|
917
1041
|
|
|
1042
|
+
/**
|
|
1043
|
+
* HTTP client with authentication headers
|
|
1044
|
+
*/
|
|
1045
|
+
declare class HttpClient {
|
|
1046
|
+
private baseUrl;
|
|
1047
|
+
private headers;
|
|
1048
|
+
constructor(config: AgoConfig);
|
|
1049
|
+
/**
|
|
1050
|
+
* Update configuration (e.g., JWT token)
|
|
1051
|
+
*/
|
|
1052
|
+
updateConfig(config: Partial<AgoConfig>): void;
|
|
1053
|
+
/**
|
|
1054
|
+
* Make a GET request
|
|
1055
|
+
*/
|
|
1056
|
+
get<T>(path: string): Promise<T>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Make a POST request with JSON body.
|
|
1059
|
+
*
|
|
1060
|
+
* `keepalive: true` lets the request survive a page unload (used by the
|
|
1061
|
+
* proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
|
|
1062
|
+
* headers, so it's a keepalive fetch instead).
|
|
1063
|
+
*/
|
|
1064
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
1065
|
+
keepalive?: boolean;
|
|
1066
|
+
}): Promise<T>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Make a POST request and return the raw Response (for streaming)
|
|
1069
|
+
*/
|
|
1070
|
+
postStream(path: string, body?: unknown): Promise<Response>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Make a POST request with FormData (for file uploads)
|
|
1073
|
+
*/
|
|
1074
|
+
postFormData(path: string, formData: FormData): Promise<Response>;
|
|
1075
|
+
private request;
|
|
1076
|
+
private handleErrorResponse;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
918
1079
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
919
1080
|
/**
|
|
920
1081
|
* The turn paused on client function call(s) (pause mode): the agent waits for
|
|
@@ -923,6 +1084,21 @@ declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCEL
|
|
|
923
1084
|
*/
|
|
924
1085
|
| "WAITING_CLIENT";
|
|
925
1086
|
|
|
1087
|
+
/**
|
|
1088
|
+
* Optional action attached to a nudge. Accepting a `functionName` action
|
|
1089
|
+
* executes the registered client function (same `FunctionRegistry` path as
|
|
1090
|
+
* agent-invoked calls); `setPageState` applies values through the registered
|
|
1091
|
+
* page-state controls.
|
|
1092
|
+
*/
|
|
1093
|
+
declare type NudgeAction = {
|
|
1094
|
+
label: string;
|
|
1095
|
+
functionName: string;
|
|
1096
|
+
arguments?: Record<string, unknown>;
|
|
1097
|
+
} | {
|
|
1098
|
+
label: string;
|
|
1099
|
+
setPageState: Record<string, unknown>;
|
|
1100
|
+
};
|
|
1101
|
+
|
|
926
1102
|
declare interface Observable<T> {
|
|
927
1103
|
subscribe(observer: {
|
|
928
1104
|
next?: (value: T) => void;
|
|
@@ -932,6 +1108,167 @@ declare interface Observable<T> {
|
|
|
932
1108
|
};
|
|
933
1109
|
}
|
|
934
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
* Controller returned by {@link createAgoProactive} (also available as
|
|
1113
|
+
* `client.proactive`).
|
|
1114
|
+
*/
|
|
1115
|
+
declare interface ProactiveController {
|
|
1116
|
+
/** Persistently opt this browser out of proactive nudges. */
|
|
1117
|
+
optOut(): void;
|
|
1118
|
+
/** Undo {@link optOut}. */
|
|
1119
|
+
optIn(): void;
|
|
1120
|
+
isOptedOut(): boolean;
|
|
1121
|
+
/**
|
|
1122
|
+
* Tell the governor the user is already engaged (e.g. the chat widget is
|
|
1123
|
+
* open) — nudges are suppressed while `true`. Call from the UI layer.
|
|
1124
|
+
*/
|
|
1125
|
+
setEngaged(engaged: boolean): void;
|
|
1126
|
+
/** App-pushed field error counter (field NAME only — never values). */
|
|
1127
|
+
signalFieldError(fieldName: string): void;
|
|
1128
|
+
/** Current aggregated friction snapshot. */
|
|
1129
|
+
getSignalsSnapshot(): SignalsSnapshot;
|
|
1130
|
+
/** The nudge currently occupying the single-nudge slot, if any. */
|
|
1131
|
+
getActiveNudge(): ProactiveNudgeInstance | null;
|
|
1132
|
+
/**
|
|
1133
|
+
* Mark the nudge as displayed. Idempotent per nudge; counts it against the
|
|
1134
|
+
* frequency caps, tracks the impression, and emits `nudge:shown`.
|
|
1135
|
+
*/
|
|
1136
|
+
shown(nudge: ProactiveNudgeInstance): void;
|
|
1137
|
+
/**
|
|
1138
|
+
* Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
|
|
1139
|
+
* and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
|
|
1140
|
+
* hidden kickoff message so the agent starts the turn with full context.
|
|
1141
|
+
*/
|
|
1142
|
+
accept(nudge: ProactiveNudgeInstance): Promise<void>;
|
|
1143
|
+
/** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
|
|
1144
|
+
dismiss(nudge: ProactiveNudgeInstance): void;
|
|
1145
|
+
/** Report a downstream conversion attributable to the nudge (analytics only). */
|
|
1146
|
+
markConverted(nudge: ProactiveNudgeInstance): void;
|
|
1147
|
+
/** Detach everything: listeners, timers, context provider, event flush. */
|
|
1148
|
+
destroy(): void;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
|
|
1152
|
+
declare interface ProactiveNudgeInstance {
|
|
1153
|
+
/** Client-generated uuid for this nudge instance (`client_nudge_id`). */
|
|
1154
|
+
id: string;
|
|
1155
|
+
triggerId: string;
|
|
1156
|
+
/** `static` = configured message; `agent` = backend LLM evaluation. */
|
|
1157
|
+
source: "static" | "agent";
|
|
1158
|
+
message: string;
|
|
1159
|
+
action?: NudgeAction;
|
|
1160
|
+
goal?: string;
|
|
1161
|
+
/** See {@link ProactiveTrigger.kickoff}. */
|
|
1162
|
+
kickoff?: string;
|
|
1163
|
+
createdAt: Date;
|
|
1164
|
+
/** Server-side nudge id (agent nudges only). */
|
|
1165
|
+
serverNudgeId?: string;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
|
|
1169
|
+
declare interface ProactiveOptions {
|
|
1170
|
+
triggers: ProactiveTrigger[];
|
|
1171
|
+
/**
|
|
1172
|
+
* Global caps on nudges actually shown. `perSession` is in-memory (page
|
|
1173
|
+
* lifetime); `perDay` is persisted in localStorage with a date rollover —
|
|
1174
|
+
* best-effort by design (private browsing resets it); the costly LLM path is
|
|
1175
|
+
* additionally capped server-side.
|
|
1176
|
+
*/
|
|
1177
|
+
frequencyCap?: {
|
|
1178
|
+
perSession?: number;
|
|
1179
|
+
perDay?: number;
|
|
1180
|
+
};
|
|
1181
|
+
/** Evaluation tick, ms. Default 1000. Zero network per tick. */
|
|
1182
|
+
tickMs?: number;
|
|
1183
|
+
/** Storage backend for persisted governance state. Default `localStorage`. */
|
|
1184
|
+
storage?: StorageLike;
|
|
1185
|
+
/** Storage key for persisted governance state. Default `"ago_proactive"`. */
|
|
1186
|
+
storageKey?: string;
|
|
1187
|
+
/** Tuning of the signal detectors (rage-click window, throttles…). */
|
|
1188
|
+
signals?: SignalCollectorTuning;
|
|
1189
|
+
/**
|
|
1190
|
+
* Local demos and tests ONLY: bypass the remote kill-switch. When set, the
|
|
1191
|
+
* `GET /config` fetch is skipped and the kill-switch takes this value.
|
|
1192
|
+
* Leave unset in production — the tenant admin controls the feature, and
|
|
1193
|
+
* the evaluate endpoint stays gated server-side regardless.
|
|
1194
|
+
*/
|
|
1195
|
+
enabledOverride?: boolean;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/** A declarative proactive trigger. */
|
|
1199
|
+
declare interface ProactiveTrigger {
|
|
1200
|
+
/** Stable id, used for cooldowns, dismissal memory, and analytics. */
|
|
1201
|
+
id: string;
|
|
1202
|
+
/** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
|
|
1203
|
+
when: ProactiveTriggerWhen;
|
|
1204
|
+
/**
|
|
1205
|
+
* Min time between two firings of this trigger (persisted across reloads).
|
|
1206
|
+
* A firing is the moment the trigger passes the gates — including an agent
|
|
1207
|
+
* evaluation that decides NOT to intervene, so a persistent condition can't
|
|
1208
|
+
* hammer the evaluate endpoint. Default 60 000.
|
|
1209
|
+
*/
|
|
1210
|
+
cooldownMs?: number;
|
|
1211
|
+
/**
|
|
1212
|
+
* `'agent'` asks the backend's fast-LLM second filter whether (and how) to
|
|
1213
|
+
* intervene; a `static` object shows the given message with no network call.
|
|
1214
|
+
*/
|
|
1215
|
+
intervene: "agent" | {
|
|
1216
|
+
type: "static";
|
|
1217
|
+
message: string;
|
|
1218
|
+
action?: NudgeAction;
|
|
1219
|
+
};
|
|
1220
|
+
/**
|
|
1221
|
+
* What the agent should help with. Sent to the evaluate endpoint, and used to
|
|
1222
|
+
* pre-seed the chat turn when the user accepts the nudge.
|
|
1223
|
+
*/
|
|
1224
|
+
goal?: string;
|
|
1225
|
+
/**
|
|
1226
|
+
* User-voice line used to OPEN the conversation when the user accepts this
|
|
1227
|
+
* nudge and no conversation exists yet — a hidden kickoff cannot start one
|
|
1228
|
+
* (the backend rejects it). Sent as a visible user message, so write it in
|
|
1229
|
+
* the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
|
|
1230
|
+
* already open, the SDK sends a hidden meta kickoff instead and this field
|
|
1231
|
+
* is unused. Without it, accepting with no open conversation skips the chat
|
|
1232
|
+
* pre-seed (the nudge action still runs).
|
|
1233
|
+
*/
|
|
1234
|
+
kickoff?: string;
|
|
1235
|
+
/**
|
|
1236
|
+
* How long a dismissal of this trigger's nudge suppresses it (persisted).
|
|
1237
|
+
* Default 24h.
|
|
1238
|
+
*/
|
|
1239
|
+
resurfaceAfterMs?: number;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/**
|
|
1243
|
+
* Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
|
|
1244
|
+
* must pass against the current {@link SignalsSnapshot}. Numeric fields are
|
|
1245
|
+
* `>=` thresholds.
|
|
1246
|
+
*/
|
|
1247
|
+
declare interface ProactiveTriggerWhen {
|
|
1248
|
+
/**
|
|
1249
|
+
* Route pattern the current pathname must match. Supports the SDK's route
|
|
1250
|
+
* styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
|
|
1251
|
+
* wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
|
|
1252
|
+
* remaining segments (`/dossier/*`).
|
|
1253
|
+
*/
|
|
1254
|
+
route?: string;
|
|
1255
|
+
/** Min time since the last user activity, ms. */
|
|
1256
|
+
idleMs?: number;
|
|
1257
|
+
/** Min time spent on the current route, ms. */
|
|
1258
|
+
dwellMs?: number;
|
|
1259
|
+
/**
|
|
1260
|
+
* Partial deep match against the registered page state (funnel step,
|
|
1261
|
+
* filters…). Every key present here must deep-match the live value.
|
|
1262
|
+
*/
|
|
1263
|
+
pageState?: Partial<Record<string, unknown>>;
|
|
1264
|
+
/** Min rage-click bursts on the current route. */
|
|
1265
|
+
rageClicks?: number;
|
|
1266
|
+
/** Min A→B→A→B route oscillations this session. */
|
|
1267
|
+
routeBounces?: number;
|
|
1268
|
+
/** Per-field minimum error counts (field NAME → min count). */
|
|
1269
|
+
fieldErrors?: Record<string, number>;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
935
1272
|
/**
|
|
936
1273
|
* Factory function that returns an Angular-compatible provider.
|
|
937
1274
|
* Use in your app's `providers` array or `bootstrapApplication`:
|
|
@@ -988,6 +1325,54 @@ declare interface SendMessageOptions {
|
|
|
988
1325
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
989
1326
|
}
|
|
990
1327
|
|
|
1328
|
+
/** Tuning knobs for the collector's detectors. All optional. */
|
|
1329
|
+
declare interface SignalCollectorTuning {
|
|
1330
|
+
/** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
|
|
1331
|
+
activityThrottleMs?: number;
|
|
1332
|
+
/** Rage click: clicks needed to count a burst. Default 3. */
|
|
1333
|
+
rageClickCount?: number;
|
|
1334
|
+
/** Rage click: max time between first and last click of a burst, ms. Default 1000. */
|
|
1335
|
+
rageClickWindowMs?: number;
|
|
1336
|
+
/** Rage click: max radius between clicks of a burst, px. Default 24. */
|
|
1337
|
+
rageClickRadiusPx?: number;
|
|
1338
|
+
/** Max routes kept in the recent-route sequence. Default 10. */
|
|
1339
|
+
maxRecentRoutes?: number;
|
|
1340
|
+
/** Max typed signals kept in the ring buffer. Default 50. */
|
|
1341
|
+
maxSignals?: number;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
/**
|
|
1345
|
+
* Aggregated view of the current friction state. Registered as a dynamic
|
|
1346
|
+
* context provider (key `friction_signals`) so it rides along as
|
|
1347
|
+
* `client_context` on every message, and sent as `signals` to the proactive
|
|
1348
|
+
* evaluate endpoint.
|
|
1349
|
+
*/
|
|
1350
|
+
declare interface SignalsSnapshot {
|
|
1351
|
+
/** Current pathname. */
|
|
1352
|
+
route: string;
|
|
1353
|
+
/** Time spent on the current route, ms. */
|
|
1354
|
+
dwellMs: number;
|
|
1355
|
+
/** Time since the last user activity (pointer/key/scroll/touch), ms. */
|
|
1356
|
+
idleMs: number;
|
|
1357
|
+
/** Rage-click bursts detected on the current route. */
|
|
1358
|
+
rageClicks: number;
|
|
1359
|
+
/**
|
|
1360
|
+
* A→B→A→B route oscillations detected in the recent route sequence. Rolling
|
|
1361
|
+
* session counter (cross-route by nature); trigger cooldowns and dismissal
|
|
1362
|
+
* memory keep it from re-firing forever.
|
|
1363
|
+
*/
|
|
1364
|
+
routeBounces: number;
|
|
1365
|
+
/** App-pushed field error counters (field NAME → count), current route only. */
|
|
1366
|
+
fieldErrors: Record<string, number>;
|
|
1367
|
+
/** Most recent pathnames, oldest first (bounded). */
|
|
1368
|
+
recentRoutes: string[];
|
|
1369
|
+
/**
|
|
1370
|
+
* Merged `AgoStateControl.get()` snapshot of the registered page-state
|
|
1371
|
+
* controls (funnel step, filters…), or `null` when none are registered.
|
|
1372
|
+
*/
|
|
1373
|
+
pageState: Record<string, unknown> | null;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
991
1376
|
/**
|
|
992
1377
|
* SSE stream chunk data
|
|
993
1378
|
*/
|
|
@@ -1031,6 +1416,9 @@ declare interface SSEChunkData {
|
|
|
1031
1416
|
waiting_tool_call_ids?: string[];
|
|
1032
1417
|
}
|
|
1033
1418
|
|
|
1419
|
+
/** The slice of the Web Storage API that {@link createStore} relies on. */
|
|
1420
|
+
declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
|
|
1421
|
+
|
|
1034
1422
|
/**
|
|
1035
1423
|
* Where a completed form is sent.
|
|
1036
1424
|
* - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser
|
package/dist/angular.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const d=require("./AgoClient-BGkFSNZF.cjs");var f="ago_widget_id",g="ago_last_thread",y=7200*1e3;function v(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const r=Math.floor(Math.random()*16);return(e==="x"?r:r&3|8).toString(16)})}function _(e={}){const r=e.key??f,i=e.threadKey??g,u=e.ttlMs??y,l=e.storage??(typeof localStorage<"u"?localStorage:void 0);let n=e.widgetId??"";if(!n&&l)try{n=l.getItem(r)??""}catch{}if(n||(n=v()),l)try{l.setItem(r,n)}catch{}const o=d.createStore({value:null,lastMessageAt:null},{key:i,storage:l}),s=o.get();s.value!==null&&c(s.lastMessageAt)&&o.set({value:null,lastMessageAt:null});function c(t){return t===null?!0:Number.isFinite(u)?Date.now()-t>u:!1}return{widgetId:n,key:r,getLastActiveThread(){const{value:t,lastMessageAt:a}=o.get();return t===null||c(a)?null:t},setActiveThread(t,a){const x=a==null?null:a instanceof Date?a.getTime():a;o.set({value:t,lastMessageAt:x})},clear(){o.set({value:null,lastMessageAt:null})}}}Object.defineProperty(exports,"createConversationSession",{enumerable:!0,get:function(){return _}});
|
package/dist/{createConversationSession-DCSWShaW.js → createConversationSession-C7cnnWKW.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as d } from "./AgoClient-CW-BLT1_.js";
|
|
2
2
|
var f = "ago_widget_id", g = "ago_last_thread", y = 7200 * 1e3;
|
|
3
3
|
function v() {
|
|
4
4
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
@@ -6,7 +6,7 @@ function v() {
|
|
|
6
6
|
return (e === "x" ? r : r & 3 | 8).toString(16);
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function h(e = {}) {
|
|
10
10
|
const r = e.key ?? f, c = e.threadKey ?? g, u = e.ttlMs ?? y, l = e.storage ?? (typeof localStorage < "u" ? localStorage : void 0);
|
|
11
11
|
let n = e.widgetId ?? "";
|
|
12
12
|
if (!n && l) try {
|
|
@@ -54,5 +54,5 @@ function D(e = {}) {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
export {
|
|
57
|
-
|
|
57
|
+
h as t
|
|
58
58
|
};
|