@useago/sdk 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +311 -0
- package/dist/angular.d.ts +311 -0
- package/dist/angular.js +2 -2
- package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
- package/dist/{createConversationSession-DPrrr70o.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 +311 -0
- package/dist/devtools.d.ts +311 -0
- package/dist/functions-IGSjjvF4.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +510 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +95 -90
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +375 -0
- package/dist/react.d.ts +375 -0
- package/dist/react.js +559 -422
- package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +311 -0
- package/dist/testing.d.ts +311 -0
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +332 -0
- package/dist/vue.d.ts +332 -0
- package/dist/vue.js +133 -110
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +308 -0
- package/dist/widget.d.ts +308 -0
- package/dist/widget.js +7 -7
- package/package.json +1 -1
- package/dist/AgoClient-5VGybmvz.cjs +0 -8
- package/dist/AgoClient-DXrH2AMi.js +0 -964
- package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
- package/dist/createFormCollector-DYh90kiG.js +0 -305
- package/dist/createMockClient-C-wrjb2C.cjs +0 -1
- package/dist/createMockClient-we-XoPom.js +0 -79
- package/dist/functions-CPs7omgM.cjs +0 -1
- /package/dist/{autoContinue-CP9pJR-V.cjs → autoContinue-CcCTva-D.cjs} +0 -0
- /package/dist/{autoContinue-CC8K9mBU.js → autoContinue-D3Mmaaca.js} +0 -0
- /package/dist/{functions-tzyOZNp6.js → functions-CApuQZ2b.js} +0 -0
package/dist/devtools.d.ts
CHANGED
|
@@ -49,6 +49,12 @@ declare class AgoClient {
|
|
|
49
49
|
private pendingApprovals;
|
|
50
50
|
/** App-provided gate deciding WHEN a paused turn resumes (see {@link registerResumeGate}). */
|
|
51
51
|
private resumeGate;
|
|
52
|
+
/**
|
|
53
|
+
* Proactive-mode controller, set when the client was created with
|
|
54
|
+
* `proactive` options or when `createAgoProactive(client, opts)` was called.
|
|
55
|
+
* `null` otherwise.
|
|
56
|
+
*/
|
|
57
|
+
proactive: ProactiveController | null;
|
|
52
58
|
constructor(config: AgoConfig);
|
|
53
59
|
/**
|
|
54
60
|
* Send a message and receive a streaming response
|
|
@@ -219,6 +225,14 @@ declare class AgoClient {
|
|
|
219
225
|
* Get all registered function schemas
|
|
220
226
|
*/
|
|
221
227
|
getRegisteredFunctions(): ClientFunctionSchema[];
|
|
228
|
+
/**
|
|
229
|
+
* Execute a registered client function locally, through the same
|
|
230
|
+
* FunctionRegistry path (result-size guard, error wrapping) as agent-invoked
|
|
231
|
+
* calls. Used by proactive nudge actions, where the user's explicit click on
|
|
232
|
+
* the action button constitutes the approval — nothing is submitted to the
|
|
233
|
+
* backend (there is no tool call to answer).
|
|
234
|
+
*/
|
|
235
|
+
executeClientFunction(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
222
236
|
/**
|
|
223
237
|
* Register a navigation function that lets AGO navigate users to different pages.
|
|
224
238
|
*
|
|
@@ -320,6 +334,9 @@ declare class AgoClient {
|
|
|
320
334
|
*/
|
|
321
335
|
notifyContextChanged(): void;
|
|
322
336
|
/* Excluded from this release type: emitFormEvent */
|
|
337
|
+
/* Excluded from this release type: emitProactiveEvent */
|
|
338
|
+
/* Excluded from this release type: getHttp */
|
|
339
|
+
/* Excluded from this release type: getConfiguredAgent */
|
|
323
340
|
/**
|
|
324
341
|
* Enable automatic capture of the current browser page (URL + title).
|
|
325
342
|
* Injected as a dynamic context entry named `browser-page`.
|
|
@@ -364,6 +381,7 @@ declare class AgoClient {
|
|
|
364
381
|
* Clean up resources
|
|
365
382
|
*/
|
|
366
383
|
destroy(): void;
|
|
384
|
+
/* Excluded from this release type: reviveAfterDestroy */
|
|
367
385
|
}
|
|
368
386
|
|
|
369
387
|
/**
|
|
@@ -480,6 +498,25 @@ declare interface AgoClientEvents {
|
|
|
480
498
|
"connection:status": {
|
|
481
499
|
connected: boolean;
|
|
482
500
|
};
|
|
501
|
+
/**
|
|
502
|
+
* A proactive nudge passed every governor gate and is ready to display.
|
|
503
|
+
* `useProactiveNudge` / `<AgoNudge>` consume this; custom UIs should call
|
|
504
|
+
* `client.proactive.shown(nudge)` when they render it (impression tracking
|
|
505
|
+
* + frequency caps), then `accept(nudge)` / `dismiss(nudge)`.
|
|
506
|
+
*/
|
|
507
|
+
"nudge:ready": ProactiveNudgeInstance;
|
|
508
|
+
/** A nudge was displayed to the user (fires once per nudge). */
|
|
509
|
+
"nudge:shown": {
|
|
510
|
+
nudge: ProactiveNudgeInstance;
|
|
511
|
+
};
|
|
512
|
+
/** The user dismissed the nudge (its trigger is suppressed, see governor). */
|
|
513
|
+
"nudge:dismissed": {
|
|
514
|
+
nudge: ProactiveNudgeInstance;
|
|
515
|
+
};
|
|
516
|
+
/** The user accepted the nudge (its action ran / the chat is being seeded). */
|
|
517
|
+
"nudge:accepted": {
|
|
518
|
+
nudge: ProactiveNudgeInstance;
|
|
519
|
+
};
|
|
483
520
|
}
|
|
484
521
|
|
|
485
522
|
/**
|
|
@@ -541,6 +578,16 @@ declare interface AgoConfig {
|
|
|
541
578
|
* with `maxResultBytes` on its definition; `Infinity` disables the guard.
|
|
542
579
|
*/
|
|
543
580
|
maxFunctionResultBytes?: number;
|
|
581
|
+
/**
|
|
582
|
+
* Enable the proactive mode: declarative triggers evaluated client-side
|
|
583
|
+
* against friction signals (dwell/idle time, rage clicks, route bounces…)
|
|
584
|
+
* that can surface a nudge before the user opens the chat. Equivalent to
|
|
585
|
+
* calling `createAgoProactive(client, proactive)` — the resulting controller
|
|
586
|
+
* is available as `client.proactive`. Requires the tenant-level kill-switch
|
|
587
|
+
* (`GET /api/sdk/v1/config` → `proactive.enabled`) to be on; disabled by
|
|
588
|
+
* default otherwise.
|
|
589
|
+
*/
|
|
590
|
+
proactive?: ProactiveOptions;
|
|
544
591
|
}
|
|
545
592
|
|
|
546
593
|
declare type AgoEventHandler<K extends AgoEventName> = (data: AgoClientEvents[K]) => void;
|
|
@@ -878,6 +925,43 @@ declare interface FormSchema {
|
|
|
878
925
|
required?: string[];
|
|
879
926
|
}
|
|
880
927
|
|
|
928
|
+
/**
|
|
929
|
+
* HTTP client with authentication headers
|
|
930
|
+
*/
|
|
931
|
+
declare class HttpClient {
|
|
932
|
+
private baseUrl;
|
|
933
|
+
private headers;
|
|
934
|
+
constructor(config: AgoConfig);
|
|
935
|
+
/**
|
|
936
|
+
* Update configuration (e.g., JWT token)
|
|
937
|
+
*/
|
|
938
|
+
updateConfig(config: Partial<AgoConfig>): void;
|
|
939
|
+
/**
|
|
940
|
+
* Make a GET request
|
|
941
|
+
*/
|
|
942
|
+
get<T>(path: string): Promise<T>;
|
|
943
|
+
/**
|
|
944
|
+
* Make a POST request with JSON body.
|
|
945
|
+
*
|
|
946
|
+
* `keepalive: true` lets the request survive a page unload (used by the
|
|
947
|
+
* proactive event tracker's flush-on-hide — sendBeacon can't carry the auth
|
|
948
|
+
* headers, so it's a keepalive fetch instead).
|
|
949
|
+
*/
|
|
950
|
+
post<T>(path: string, body?: unknown, options?: {
|
|
951
|
+
keepalive?: boolean;
|
|
952
|
+
}): Promise<T>;
|
|
953
|
+
/**
|
|
954
|
+
* Make a POST request and return the raw Response (for streaming)
|
|
955
|
+
*/
|
|
956
|
+
postStream(path: string, body?: unknown): Promise<Response>;
|
|
957
|
+
/**
|
|
958
|
+
* Make a POST request with FormData (for file uploads)
|
|
959
|
+
*/
|
|
960
|
+
postFormData(path: string, formData: FormData): Promise<Response>;
|
|
961
|
+
private request;
|
|
962
|
+
private handleErrorResponse;
|
|
963
|
+
}
|
|
964
|
+
|
|
881
965
|
export declare function initDevPanel(options: DevPanelOptions): void;
|
|
882
966
|
|
|
883
967
|
declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCELED"
|
|
@@ -888,6 +972,182 @@ declare type MessageStatus = "IN_PROGRESS" | "DONE" | "ERROR" | "TODO" | "CANCEL
|
|
|
888
972
|
*/
|
|
889
973
|
| "WAITING_CLIENT";
|
|
890
974
|
|
|
975
|
+
/**
|
|
976
|
+
* Optional action attached to a nudge. Accepting a `functionName` action
|
|
977
|
+
* executes the registered client function (same `FunctionRegistry` path as
|
|
978
|
+
* agent-invoked calls); `setPageState` applies values through the registered
|
|
979
|
+
* page-state controls.
|
|
980
|
+
*/
|
|
981
|
+
declare type NudgeAction = {
|
|
982
|
+
label: string;
|
|
983
|
+
functionName: string;
|
|
984
|
+
arguments?: Record<string, unknown>;
|
|
985
|
+
} | {
|
|
986
|
+
label: string;
|
|
987
|
+
setPageState: Record<string, unknown>;
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Controller returned by {@link createAgoProactive} (also available as
|
|
992
|
+
* `client.proactive`).
|
|
993
|
+
*/
|
|
994
|
+
declare interface ProactiveController {
|
|
995
|
+
/** Persistently opt this browser out of proactive nudges. */
|
|
996
|
+
optOut(): void;
|
|
997
|
+
/** Undo {@link optOut}. */
|
|
998
|
+
optIn(): void;
|
|
999
|
+
isOptedOut(): boolean;
|
|
1000
|
+
/**
|
|
1001
|
+
* Tell the governor the user is already engaged (e.g. the chat widget is
|
|
1002
|
+
* open) — nudges are suppressed while `true`. Call from the UI layer.
|
|
1003
|
+
*/
|
|
1004
|
+
setEngaged(engaged: boolean): void;
|
|
1005
|
+
/** App-pushed field error counter (field NAME only — never values). */
|
|
1006
|
+
signalFieldError(fieldName: string): void;
|
|
1007
|
+
/** Current aggregated friction snapshot. */
|
|
1008
|
+
getSignalsSnapshot(): SignalsSnapshot;
|
|
1009
|
+
/** The nudge currently occupying the single-nudge slot, if any. */
|
|
1010
|
+
getActiveNudge(): ProactiveNudgeInstance | null;
|
|
1011
|
+
/**
|
|
1012
|
+
* Mark the nudge as displayed. Idempotent per nudge; counts it against the
|
|
1013
|
+
* frequency caps, tracks the impression, and emits `nudge:shown`.
|
|
1014
|
+
*/
|
|
1015
|
+
shown(nudge: ProactiveNudgeInstance): void;
|
|
1016
|
+
/**
|
|
1017
|
+
* Accept the nudge: run its action (if any), emit `nudge:accepted`, track,
|
|
1018
|
+
* and — for agent nudges or nudges with a `goal` — pre-seed the chat with a
|
|
1019
|
+
* hidden kickoff message so the agent starts the turn with full context.
|
|
1020
|
+
*/
|
|
1021
|
+
accept(nudge: ProactiveNudgeInstance): Promise<void>;
|
|
1022
|
+
/** Dismiss the nudge: suppress the trigger, track, emit `nudge:dismissed`. */
|
|
1023
|
+
dismiss(nudge: ProactiveNudgeInstance): void;
|
|
1024
|
+
/** Report a downstream conversion attributable to the nudge (analytics only). */
|
|
1025
|
+
markConverted(nudge: ProactiveNudgeInstance): void;
|
|
1026
|
+
/** Detach everything: listeners, timers, context provider, event flush. */
|
|
1027
|
+
destroy(): void;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/** A concrete nudge produced by the engine, carried by every `nudge:*` event. */
|
|
1031
|
+
declare interface ProactiveNudgeInstance {
|
|
1032
|
+
/** Client-generated uuid for this nudge instance (`client_nudge_id`). */
|
|
1033
|
+
id: string;
|
|
1034
|
+
triggerId: string;
|
|
1035
|
+
/** `static` = configured message; `agent` = backend LLM evaluation. */
|
|
1036
|
+
source: "static" | "agent";
|
|
1037
|
+
message: string;
|
|
1038
|
+
action?: NudgeAction;
|
|
1039
|
+
goal?: string;
|
|
1040
|
+
/** See {@link ProactiveTrigger.kickoff}. */
|
|
1041
|
+
kickoff?: string;
|
|
1042
|
+
createdAt: Date;
|
|
1043
|
+
/** Server-side nudge id (agent nudges only). */
|
|
1044
|
+
serverNudgeId?: string;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/** Options for {@link createAgoProactive} / `AgoConfig.proactive`. */
|
|
1048
|
+
declare interface ProactiveOptions {
|
|
1049
|
+
triggers: ProactiveTrigger[];
|
|
1050
|
+
/**
|
|
1051
|
+
* Global caps on nudges actually shown. `perSession` is in-memory (page
|
|
1052
|
+
* lifetime); `perDay` is persisted in localStorage with a date rollover —
|
|
1053
|
+
* best-effort by design (private browsing resets it); the costly LLM path is
|
|
1054
|
+
* additionally capped server-side.
|
|
1055
|
+
*/
|
|
1056
|
+
frequencyCap?: {
|
|
1057
|
+
perSession?: number;
|
|
1058
|
+
perDay?: number;
|
|
1059
|
+
};
|
|
1060
|
+
/** Evaluation tick, ms. Default 1000. Zero network per tick. */
|
|
1061
|
+
tickMs?: number;
|
|
1062
|
+
/** Storage backend for persisted governance state. Default `localStorage`. */
|
|
1063
|
+
storage?: StorageLike;
|
|
1064
|
+
/** Storage key for persisted governance state. Default `"ago_proactive"`. */
|
|
1065
|
+
storageKey?: string;
|
|
1066
|
+
/** Tuning of the signal detectors (rage-click window, throttles…). */
|
|
1067
|
+
signals?: SignalCollectorTuning;
|
|
1068
|
+
/**
|
|
1069
|
+
* Local demos and tests ONLY: bypass the remote kill-switch. When set, the
|
|
1070
|
+
* `GET /config` fetch is skipped and the kill-switch takes this value.
|
|
1071
|
+
* Leave unset in production — the tenant admin controls the feature, and
|
|
1072
|
+
* the evaluate endpoint stays gated server-side regardless.
|
|
1073
|
+
*/
|
|
1074
|
+
enabledOverride?: boolean;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/** A declarative proactive trigger. */
|
|
1078
|
+
declare interface ProactiveTrigger {
|
|
1079
|
+
/** Stable id, used for cooldowns, dismissal memory, and analytics. */
|
|
1080
|
+
id: string;
|
|
1081
|
+
/** Conjunction of matchers (see {@link ProactiveTriggerWhen}). */
|
|
1082
|
+
when: ProactiveTriggerWhen;
|
|
1083
|
+
/**
|
|
1084
|
+
* Min time between two firings of this trigger (persisted across reloads).
|
|
1085
|
+
* A firing is the moment the trigger passes the gates — including an agent
|
|
1086
|
+
* evaluation that decides NOT to intervene, so a persistent condition can't
|
|
1087
|
+
* hammer the evaluate endpoint. Default 60 000.
|
|
1088
|
+
*/
|
|
1089
|
+
cooldownMs?: number;
|
|
1090
|
+
/**
|
|
1091
|
+
* `'agent'` asks the backend's fast-LLM second filter whether (and how) to
|
|
1092
|
+
* intervene; a `static` object shows the given message with no network call.
|
|
1093
|
+
*/
|
|
1094
|
+
intervene: "agent" | {
|
|
1095
|
+
type: "static";
|
|
1096
|
+
message: string;
|
|
1097
|
+
action?: NudgeAction;
|
|
1098
|
+
};
|
|
1099
|
+
/**
|
|
1100
|
+
* What the agent should help with. Sent to the evaluate endpoint, and used to
|
|
1101
|
+
* pre-seed the chat turn when the user accepts the nudge.
|
|
1102
|
+
*/
|
|
1103
|
+
goal?: string;
|
|
1104
|
+
/**
|
|
1105
|
+
* User-voice line used to OPEN the conversation when the user accepts this
|
|
1106
|
+
* nudge and no conversation exists yet — a hidden kickoff cannot start one
|
|
1107
|
+
* (the backend rejects it). Sent as a visible user message, so write it in
|
|
1108
|
+
* the app's language ("Oui, aidez-moi à choisir !"). When a conversation is
|
|
1109
|
+
* already open, the SDK sends a hidden meta kickoff instead and this field
|
|
1110
|
+
* is unused. Without it, accepting with no open conversation skips the chat
|
|
1111
|
+
* pre-seed (the nudge action still runs).
|
|
1112
|
+
*/
|
|
1113
|
+
kickoff?: string;
|
|
1114
|
+
/**
|
|
1115
|
+
* How long a dismissal of this trigger's nudge suppresses it (persisted).
|
|
1116
|
+
* Default 24h.
|
|
1117
|
+
*/
|
|
1118
|
+
resurfaceAfterMs?: number;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Conditions of a proactive trigger. Pure conjunction: EVERY specified matcher
|
|
1123
|
+
* must pass against the current {@link SignalsSnapshot}. Numeric fields are
|
|
1124
|
+
* `>=` thresholds.
|
|
1125
|
+
*/
|
|
1126
|
+
declare interface ProactiveTriggerWhen {
|
|
1127
|
+
/**
|
|
1128
|
+
* Route pattern the current pathname must match. Supports the SDK's route
|
|
1129
|
+
* styles: exact (`/billing`), `:param` segments (`/users/:id`), single-segment
|
|
1130
|
+
* wildcards (`/a/*` / `/b`), and a trailing `/*` that matches one or more
|
|
1131
|
+
* remaining segments (`/dossier/*`).
|
|
1132
|
+
*/
|
|
1133
|
+
route?: string;
|
|
1134
|
+
/** Min time since the last user activity, ms. */
|
|
1135
|
+
idleMs?: number;
|
|
1136
|
+
/** Min time spent on the current route, ms. */
|
|
1137
|
+
dwellMs?: number;
|
|
1138
|
+
/**
|
|
1139
|
+
* Partial deep match against the registered page state (funnel step,
|
|
1140
|
+
* filters…). Every key present here must deep-match the live value.
|
|
1141
|
+
*/
|
|
1142
|
+
pageState?: Partial<Record<string, unknown>>;
|
|
1143
|
+
/** Min rage-click bursts on the current route. */
|
|
1144
|
+
rageClicks?: number;
|
|
1145
|
+
/** Min A→B→A→B route oscillations this session. */
|
|
1146
|
+
routeBounces?: number;
|
|
1147
|
+
/** Per-field minimum error counts (field NAME → min count). */
|
|
1148
|
+
fieldErrors?: Record<string, number>;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
891
1151
|
/**
|
|
892
1152
|
* Hook run before a paused turn is resumed, so the app controls WHEN the
|
|
893
1153
|
* continuation fires (e.g. wait for the destination page to mount after a
|
|
@@ -920,6 +1180,54 @@ declare interface SendMessageOptions {
|
|
|
920
1180
|
clientFunctionsMode?: ClientFunctionsMode;
|
|
921
1181
|
}
|
|
922
1182
|
|
|
1183
|
+
/** Tuning knobs for the collector's detectors. All optional. */
|
|
1184
|
+
declare interface SignalCollectorTuning {
|
|
1185
|
+
/** Min gap between heavy activity work (route checks, notifications), ms. Default 250. */
|
|
1186
|
+
activityThrottleMs?: number;
|
|
1187
|
+
/** Rage click: clicks needed to count a burst. Default 3. */
|
|
1188
|
+
rageClickCount?: number;
|
|
1189
|
+
/** Rage click: max time between first and last click of a burst, ms. Default 1000. */
|
|
1190
|
+
rageClickWindowMs?: number;
|
|
1191
|
+
/** Rage click: max radius between clicks of a burst, px. Default 24. */
|
|
1192
|
+
rageClickRadiusPx?: number;
|
|
1193
|
+
/** Max routes kept in the recent-route sequence. Default 10. */
|
|
1194
|
+
maxRecentRoutes?: number;
|
|
1195
|
+
/** Max typed signals kept in the ring buffer. Default 50. */
|
|
1196
|
+
maxSignals?: number;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Aggregated view of the current friction state. Registered as a dynamic
|
|
1201
|
+
* context provider (key `friction_signals`) so it rides along as
|
|
1202
|
+
* `client_context` on every message, and sent as `signals` to the proactive
|
|
1203
|
+
* evaluate endpoint.
|
|
1204
|
+
*/
|
|
1205
|
+
declare interface SignalsSnapshot {
|
|
1206
|
+
/** Current pathname. */
|
|
1207
|
+
route: string;
|
|
1208
|
+
/** Time spent on the current route, ms. */
|
|
1209
|
+
dwellMs: number;
|
|
1210
|
+
/** Time since the last user activity (pointer/key/scroll/touch), ms. */
|
|
1211
|
+
idleMs: number;
|
|
1212
|
+
/** Rage-click bursts detected on the current route. */
|
|
1213
|
+
rageClicks: number;
|
|
1214
|
+
/**
|
|
1215
|
+
* A→B→A→B route oscillations detected in the recent route sequence. Rolling
|
|
1216
|
+
* session counter (cross-route by nature); trigger cooldowns and dismissal
|
|
1217
|
+
* memory keep it from re-firing forever.
|
|
1218
|
+
*/
|
|
1219
|
+
routeBounces: number;
|
|
1220
|
+
/** App-pushed field error counters (field NAME → count), current route only. */
|
|
1221
|
+
fieldErrors: Record<string, number>;
|
|
1222
|
+
/** Most recent pathnames, oldest first (bounded). */
|
|
1223
|
+
recentRoutes: string[];
|
|
1224
|
+
/**
|
|
1225
|
+
* Merged `AgoStateControl.get()` snapshot of the registered page-state
|
|
1226
|
+
* controls (funnel step, filters…), or `null` when none are registered.
|
|
1227
|
+
*/
|
|
1228
|
+
pageState: Record<string, unknown> | null;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
923
1231
|
/**
|
|
924
1232
|
* SSE stream chunk data
|
|
925
1233
|
*/
|
|
@@ -963,6 +1271,9 @@ declare interface SSEChunkData {
|
|
|
963
1271
|
waiting_tool_call_ids?: string[];
|
|
964
1272
|
}
|
|
965
1273
|
|
|
1274
|
+
/** The slice of the Web Storage API that {@link createStore} relies on. */
|
|
1275
|
+
declare type StorageLike = Pick<Storage, "getItem" | "setItem">;
|
|
1276
|
+
|
|
966
1277
|
/**
|
|
967
1278
|
* Where a completed form is sent.
|
|
968
1279
|
* - `"https://..."` (a bare string) — shorthand for `{ via: "client", url }`: the browser
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const v=require("./rolldown-runtime-16Nf8qvH.cjs");var w=v.__exportAll({copyToClipboard:()=>c,getLocalStorage:()=>f,getUserLocation:()=>p,highlightElement:()=>h,openUrl:()=>a,scrollToElement:()=>d,setLocalStorage:()=>m,setTheme:()=>l,showConfirmDialog:()=>u,showNotification:()=>s,showToast:()=>i,submitForm:()=>y,trackEvent:()=>g}),i={name:"showToast",description:"Show a toast notification to the user. Use this to confirm actions or display brief messages.",parameters:{type:"object",properties:{message:{type:"string",description:"The message to display"},type:{type:"string",description:"Toast type",enum:["success","error","warning","info"]},duration:{type:"number",description:"Duration in milliseconds (default 3000)"}},required:["message"]},handler:async()=>({shown:!1,error:"No toast handler configured"})},s={name:"showNotification",description:"Show a browser notification to the user. Useful for important alerts even when the tab is not focused.",parameters:{type:"object",properties:{title:{type:"string",description:"Notification title"},body:{type:"string",description:"Notification body text"}},required:["title"]},handler:async e=>typeof Notification>"u"?{shown:!1,error:"Notifications not supported"}:Notification.permission==="denied"?{shown:!1,error:"Notification permission denied"}:(Notification.permission!=="granted"&&await Notification.requestPermission(),Notification.permission==="granted"?(new Notification(e.title,{body:e.body}),{shown:!0}):{shown:!1,error:"Permission not granted"})},a={name:"openUrl",description:"Open a URL in a new browser tab.",parameters:{type:"object",properties:{url:{type:"string",description:"The URL to open"}},required:["url"]},handler:async e=>(window.open(e.url,"_blank","noopener,noreferrer"),{opened:!0})},c={name:"copyToClipboard",description:"Copy text to the user's clipboard.",parameters:{type:"object",properties:{text:{type:"string",description:"The text to copy"}},required:["text"]},handler:async e=>(await navigator.clipboard.writeText(e.text),{copied:!0})},l={name:"setTheme",description:"Change the application's color theme. Sets a data-theme attribute on the document element.",parameters:{type:"object",properties:{theme:{type:"string",description:"Theme to apply",enum:["light","dark","system"]}},required:["theme"]},handler:async e=>{const t=e.theme;return document.documentElement.setAttribute("data-theme",t),t==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"),{theme:t,applied:!0}}},u={name:"showConfirmDialog",description:"Show a confirmation dialog to the user and return their choice (true/false).",parameters:{type:"object",properties:{message:{type:"string",description:"The confirmation message to display"}},required:["message"]},handler:async e=>({confirmed:window.confirm(e.message)})},p={name:"getUserLocation",description:"Get the user's current geographic location (requires permission).",parameters:{type:"object",properties:{}},handler:async()=>navigator.geolocation?new Promise(e=>{navigator.geolocation.getCurrentPosition(t=>e({latitude:t.coords.latitude,longitude:t.coords.longitude,accuracy:t.coords.accuracy}),t=>e({error:t.message}))}):{error:"Geolocation not supported"}},d={name:"scrollToElement",description:"Scroll the page to a specific element identified by CSS selector.",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the element to scroll to (e.g. '#section-pricing')"},behavior:{type:"string",description:"Scroll behavior",enum:["smooth","instant"]}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);return t?(t.scrollIntoView({behavior:e.behavior||"smooth"}),{scrolled:!0}):{scrolled:!1,error:`Element not found: ${e.selector}`}}},m={name:"setLocalStorage",description:"Store a value in the browser's localStorage.",parameters:{type:"object",properties:{key:{type:"string",description:"Storage key"},value:{type:"string",description:"Value to store"}},required:["key","value"]},handler:async e=>(localStorage.setItem(e.key,e.value),{stored:!0})},f={name:"getLocalStorage",description:"Retrieve a value from the browser's localStorage.",parameters:{type:"object",properties:{key:{type:"string",description:"Storage key"}},required:["key"]},handler:async e=>{const t=localStorage.getItem(e.key);return{key:e.key,value:t,found:t!==null}}},h={name:"highlightElement",description:"Highlight a DOM element to draw the user's attention (e.g. for onboarding).",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the element to highlight"},color:{type:"string",description:"Highlight border color (default: #3b82f6)"}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);if(!t)return{highlighted:!1,error:`Element not found: ${e.selector}`};const r=t.style.outline,o=e.color||"#3b82f6";return t.style.outline=`3px solid ${o}`,t.style.outlineOffset="2px",t.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{t.style.outline=r,t.style.outlineOffset=""},3e3),{highlighted:!0}}},y={name:"submitForm",description:"Fill and submit an HTML form on the page. Pass field values as key-value pairs.",parameters:{type:"object",properties:{selector:{type:"string",description:"CSS selector of the form element"},values:{type:"string",description:"JSON string of field name → value pairs"}},required:["selector"]},handler:async e=>{const t=document.querySelector(e.selector);if(!t)return{submitted:!1,error:`Form not found: ${e.selector}`};if(e.values){const r=JSON.parse(e.values);for(const[o,b]of Object.entries(r)){const n=t.elements.namedItem(o);n&&(n.value=b)}}return t.requestSubmit(),{submitted:!0}}},g={name:"trackEvent",description:"Track a custom analytics event. Override the handler to wire up your analytics provider.",parameters:{type:"object",properties:{event:{type:"string",description:"Event name"},properties:{type:"string",description:"JSON string of event properties"}},required:["event"]},handler:async e=>{const t=e.properties?JSON.parse(e.properties):{};return console.log(`[AGO Analytics] ${e.event}`,t),{tracked:!0,event:e.event}}};Object.defineProperty(exports,"copyToClipboard",{enumerable:!0,get:function(){return c}});Object.defineProperty(exports,"functions_exports",{enumerable:!0,get:function(){return w}});Object.defineProperty(exports,"getLocalStorage",{enumerable:!0,get:function(){return f}});Object.defineProperty(exports,"getUserLocation",{enumerable:!0,get:function(){return p}});Object.defineProperty(exports,"highlightElement",{enumerable:!0,get:function(){return h}});Object.defineProperty(exports,"openUrl",{enumerable:!0,get:function(){return a}});Object.defineProperty(exports,"scrollToElement",{enumerable:!0,get:function(){return d}});Object.defineProperty(exports,"setLocalStorage",{enumerable:!0,get:function(){return m}});Object.defineProperty(exports,"setTheme",{enumerable:!0,get:function(){return l}});Object.defineProperty(exports,"showConfirmDialog",{enumerable:!0,get:function(){return u}});Object.defineProperty(exports,"showNotification",{enumerable:!0,get:function(){return s}});Object.defineProperty(exports,"showToast",{enumerable:!0,get:function(){return i}});Object.defineProperty(exports,"submitForm",{enumerable:!0,get:function(){return y}});Object.defineProperty(exports,"trackEvent",{enumerable:!0,get:function(){return g}});
|
package/dist/helpers.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./functions-IGSjjvF4.cjs");exports.copyToClipboard=o.copyToClipboard;exports.getLocalStorage=o.getLocalStorage;exports.getUserLocation=o.getUserLocation;exports.highlightElement=o.highlightElement;exports.openUrl=o.openUrl;exports.scrollToElement=o.scrollToElement;exports.setLocalStorage=o.setLocalStorage;exports.setTheme=o.setTheme;exports.showConfirmDialog=o.showConfirmDialog;exports.showNotification=o.showNotification;exports.showToast=o.showToast;exports.submitForm=o.submitForm;exports.trackEvent=o.trackEvent;
|
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a, c as s, d as t, f as e, i as r, l as i, m as l, o as m, p as c, r as g, s as h, t as n, u as p } from "./functions-
|
|
1
|
+
import { a, c as s, d as t, f as e, i as r, l as i, m as l, o as m, p as c, r as g, s as h, t as n, u as p } from "./functions-CApuQZ2b.js";
|
|
2
2
|
export {
|
|
3
3
|
n as copyToClipboard,
|
|
4
4
|
g as getLocalStorage,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./AgoClient-BGkFSNZF.cjs"),C=require("./autoContinue-CcCTva-D.cjs"),p=require("./createConversationSession-BCb0D6bt.cjs"),f=require("./createFormCollector-t_fGyuTD.cjs"),S=require("./createMockClient-BwNLPjeT.cjs");require("./testing.cjs");const g=require("./functions-IGSjjvF4.cjs");function w(e){return e}function E(e,o){return e.on("message:complete",o),()=>e.off("message:complete",o)}function y(e,o){return e.on("message:chunk",o),()=>e.off("message:chunk",o)}function v(e,o){return e.on("message:start",o),()=>e.off("message:start",o)}function F(e,o){return e.on("message:error",o),()=>e.off("message:error",o)}function b(e,o){return e.on("toolCall:received",o),()=>e.off("toolCall:received",o)}function M(e,o){return e.on("form:submitted",o),()=>e.off("form:submitted",o)}function q(e,o){return e.on("form:error",o),()=>e.off("form:error",o)}function k(e,o){return e.on("function:invoke",o),()=>e.off("function:invoke",o)}async function*T(e,o,l){const a=[];let n=null,i=!1;const c=s=>{a.push(s),n?.()},m=s=>c({type:"start",data:s}),r=s=>c({type:"chunk",data:s}),u=s=>{c({type:"complete",data:s}),i=!0,n?.()},d=s=>{c({type:"error",data:s}),i=!0,n?.()},h=s=>c({type:"toolCall",data:s});e.on("message:start",m),e.on("message:chunk",r),e.on("message:complete",u),e.on("message:error",d),e.on("toolCall:received",h),e.sendMessage(o,l).catch(()=>{i=!0,n?.()});try{for(;!i||a.length>0;)a.length>0?yield a.shift():(await new Promise(s=>{n=s}),n=null)}finally{e.off("message:start",m),e.off("message:chunk",r),e.off("message:complete",u),e.off("message:error",d),e.off("toolCall:received",h)}}function A(e){let o,l,a,n,i,c;if(typeof window<"u"&&window.AGO){const r=window.AGO;o=r.basepath,l=r.widgetId,a=r.agent||r.defaultAgent,n=r.permission,i=r.email,c=r.jwt}if(typeof document<"u"){const r=u=>document.querySelector(`meta[name="${u}"]`)?.getAttribute("content")||void 0;o=o||r("ago-base-url"),l=l||r("ago-widget-id"),a=a||r("ago-agent")||r("ago-agent-id"),n=n||r("ago-permission"),i=i||r("ago-user-email")}if(typeof document<"u"){const r=[document.body,...Array.from(document.querySelectorAll("script[data-ago-base-url]"))].filter(Boolean);for(const u of r)u&&(o=o||u.getAttribute("data-ago-base-url")||void 0,l=l||u.getAttribute("data-ago-widget-id")||void 0,a=a||u.getAttribute("data-ago-agent")||u.getAttribute("data-ago-agent-id")||void 0,n=n||u.getAttribute("data-ago-permission")||void 0,i=i||u.getAttribute("data-ago-user-email")||void 0)}o=e?.baseUrl||o,l=e?.widgetId||l,a=e?.agent||e?.defaultAgentId||a,n=e?.permission||n,i=e?.userEmail||i,c=e?.userJwt||c;const m=e?.debug;return o?{baseUrl:o,widgetId:l,agent:a,permission:n,userEmail:i,userJwt:c,debug:m}:null}function I(e){const o=A(e);if(!o)throw new t.AgoError('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.',"config_missing_base_url");return new t.AgoClient(o)}function U(e,o){return{...e,handler:o}}exports.AgoApiError=t.AgoApiError;exports.AgoClient=t.AgoClient;exports.AgoError=t.AgoError;exports.AgoFunctionError=t.AgoFunctionError;exports.AgoNetworkError=t.AgoNetworkError;exports.AgoStreamError=t.AgoStreamError;exports.ClientContextRegistry=t.ClientContextRegistry;exports.EventEmitter=t.EventEmitter;exports.FunctionRegistry=t.FunctionRegistry;exports.SSEHandler=t.SSEHandler;exports.SignalCollector=t.SignalCollector;exports.attachAutoContinueAfterNavigation=C.attachAutoContinueAfterNavigation;exports.autoDetectConfig=A;exports.canInlineImage=t.canInlineImage;exports.copyToClipboard=g.copyToClipboard;exports.createAgo=I;exports.createAgoProactive=t.createAgoProactive;exports.createConversationSession=p.createConversationSession;exports.createFormCollector=f.createFormCollector;exports.createMessageStream=T;exports.createMockClient=S.createMockClient;exports.createStore=t.createStore;exports.defineFunction=w;exports.deriveFormStatus=f.deriveFormStatus;exports.formatFileSize=t.formatFileSize;exports.getLocalStorage=g.getLocalStorage;exports.getUserLocation=g.getUserLocation;exports.highlightElement=g.highlightElement;exports.isStreamNetworkError=t.isStreamNetworkError;exports.loadFormCollector=f.loadFormCollector;exports.logger=t.logger;exports.matchesRoutePattern=t.matchesRoutePattern;exports.matchesWhen=t.matchesWhen;exports.onFormError=q;exports.onFormSubmitted=M;exports.onFunctionInvoke=k;exports.onMessage=E;exports.onMessageChunk=y;exports.onMessageError=F;exports.onMessageStart=v;exports.onToolCall=b;exports.openUrl=g.openUrl;exports.partialDeepMatch=t.partialDeepMatch;exports.safeAttachmentUrl=t.safeAttachmentUrl;exports.scrollToElement=g.scrollToElement;exports.setLocalStorage=g.setLocalStorage;exports.setTheme=g.setTheme;exports.showConfirmDialog=g.showConfirmDialog;exports.showNotification=g.showNotification;exports.showToast=g.showToast;exports.submitForm=g.submitForm;exports.trackEvent=g.trackEvent;exports.validateConfig=t.validateConfig;exports.withHandler=U;
|