@useago/sdk 1.12.0 → 1.13.1
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 +111 -4
- package/README.md +73 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +140 -38
- package/dist/angular.d.ts +140 -38
- package/dist/angular.js +7 -4
- package/dist/autoContinue-C3UsCvT5.cjs +1 -0
- package/dist/{autoContinue-CC8K9mBU.js → autoContinue-Cb4_iEbO.js} +1 -1
- package/dist/{createConversationSession-B1Qn-y0I.js → createConversationSession-D0vks-8C.js} +1 -1
- package/dist/{createConversationSession-B3v_xOU7.cjs → createConversationSession-Ri3EKIJU.cjs} +1 -1
- package/dist/{createFormCollector-m79zk_NA.js → createFormCollector-BMN-blXs.js} +1 -1
- package/dist/{createFormCollector-FvwDOqnV.cjs → createFormCollector-BNCMIUw2.cjs} +1 -1
- package/dist/createMockClient-BPt1gSve.cjs +1 -0
- package/dist/{createMockClient-Beao82tu.js → createMockClient-YoYr3pQr.js} +1 -0
- package/dist/devtools.cjs +4 -4
- package/dist/devtools.d.cts +129 -33
- package/dist/devtools.d.ts +129 -33
- package/dist/devtools.js +87 -84
- package/dist/helpers.d.cts +42 -12
- package/dist/helpers.d.ts +42 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +135 -40
- package/dist/index.d.ts +135 -40
- package/dist/index.js +44 -43
- package/dist/react.cjs +4 -4
- package/dist/react.d.cts +187 -34
- package/dist/react.d.ts +187 -34
- package/dist/react.js +822 -729
- package/dist/speechToText-BV7qxqPF.js +704 -0
- package/dist/speechToText-ZciRyyJE.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +129 -33
- package/dist/testing.d.ts +129 -33
- package/dist/testing.js +1 -1
- package/dist/types-Ck3iZG0K.cjs +10 -0
- package/dist/{types-Ct1hlKwg.js → types-fX-VoHfa.js} +1042 -759
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +143 -35
- package/dist/vue.d.ts +143 -35
- package/dist/vue.js +133 -131
- package/dist/widget.cjs +6 -6
- package/dist/widget.d.cts +161 -33
- package/dist/widget.d.ts +161 -33
- package/dist/widget.js +1702 -1757
- package/llms-full.txt +166 -1
- package/package.json +1 -1
- package/dist/autoContinue-CP9pJR-V.cjs +0 -1
- package/dist/createMockClient-BEOXI8yW.cjs +0 -1
- package/dist/sheetController-BThJRtOu.cjs +0 -1
- package/dist/sheetController-aEKXIvjk.js +0 -343
- package/dist/types-mcW8vB1U.cjs +0 -10
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
var
|
|
3
|
-
function
|
|
1
|
+
import { a as X, i as F, n as S, r as V, t as C } from "./errors-BLfjXnLB.js";
|
|
2
|
+
var ts = 10, Y = 1e3;
|
|
3
|
+
function Ae(e) {
|
|
4
4
|
if (typeof e != "object" || e === null) return !1;
|
|
5
5
|
const t = Object.getPrototypeOf(e);
|
|
6
6
|
return t === Object.prototype || t === null;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function P(e, t) {
|
|
9
9
|
if (typeof e == "string") {
|
|
10
10
|
if (e.length <= 1e3) return e;
|
|
11
|
-
const s = e.length -
|
|
12
|
-
return e.slice(0,
|
|
11
|
+
const s = e.length - Y;
|
|
12
|
+
return e.slice(0, Y) + `…[truncated ${s} chars]`;
|
|
13
13
|
}
|
|
14
14
|
if (Array.isArray(e)) {
|
|
15
15
|
if (t.has(e)) return "…[circular]";
|
|
16
16
|
t.add(e);
|
|
17
|
-
const s = e.slice(0, 50).map((i) =>
|
|
17
|
+
const s = e.slice(0, 50).map((i) => P(i, t));
|
|
18
18
|
return e.length > 50 && s.push(`…[+${e.length - 50} more]`), t.delete(e), s;
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
20
|
+
if (Ae(e)) {
|
|
21
21
|
if (t.has(e)) return "…[circular]";
|
|
22
22
|
t.add(e);
|
|
23
23
|
const s = {};
|
|
24
|
-
for (const [i,
|
|
24
|
+
for (const [i, n] of Object.entries(e)) s[i] = P(n, t);
|
|
25
25
|
return t.delete(e), s;
|
|
26
26
|
}
|
|
27
27
|
return e;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
29
|
+
function me(e) {
|
|
30
|
+
return P(e, /* @__PURE__ */ new WeakSet());
|
|
31
31
|
}
|
|
32
|
-
var
|
|
32
|
+
var ke = class {
|
|
33
33
|
constructor(e = 10) {
|
|
34
34
|
this.entries = [];
|
|
35
35
|
const t = Math.floor(e);
|
|
@@ -41,7 +41,7 @@ var ye = class {
|
|
|
41
41
|
actor: e.actor ?? "user",
|
|
42
42
|
name: e.name,
|
|
43
43
|
summary: e.summary,
|
|
44
|
-
...e.data !== void 0 ? { data:
|
|
44
|
+
...e.data !== void 0 ? { data: me(e.data) } : {}
|
|
45
45
|
};
|
|
46
46
|
this.entries.push(t);
|
|
47
47
|
const s = this.entries.length - this.maxEntries;
|
|
@@ -56,7 +56,20 @@ var ye = class {
|
|
|
56
56
|
clear() {
|
|
57
57
|
this.entries = [];
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
|
+
function N(e) {
|
|
61
|
+
if (e == null) return null;
|
|
62
|
+
if (typeof e == "string") {
|
|
63
|
+
const t = e.trim().replace(/_/g, "-");
|
|
64
|
+
try {
|
|
65
|
+
const [s] = /^[a-z]{2,3}(?:-[a-z0-9]{1,8})*$/i.test(t) ? Intl.getCanonicalLocales(t) : [];
|
|
66
|
+
if (s) return s;
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
throw new S('Use a language tag such as "fr", "de-DE", or "pt-BR", or null to clear it. See docs/general/configuration.md#language (config_invalid_language).', "config_invalid_language");
|
|
71
|
+
}
|
|
72
|
+
var Re = class {
|
|
60
73
|
constructor(e = !1) {
|
|
61
74
|
this.enabled = e;
|
|
62
75
|
}
|
|
@@ -78,35 +91,129 @@ var ye = class {
|
|
|
78
91
|
debug(...e) {
|
|
79
92
|
this.enabled && console.debug("[AGO SDK]", ...e);
|
|
80
93
|
}
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
}, c = new Re(), Q = "ago_widget_id";
|
|
95
|
+
function O(e) {
|
|
96
|
+
return typeof DOMException < "u" && e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
97
|
+
}
|
|
98
|
+
function Te() {
|
|
99
|
+
if (typeof localStorage < "u") {
|
|
100
|
+
const t = localStorage.getItem(Q);
|
|
101
|
+
if (t) return t;
|
|
102
|
+
}
|
|
103
|
+
const e = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `ago-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
104
|
+
if (typeof localStorage < "u") try {
|
|
105
|
+
localStorage.setItem(Q, e);
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
return e;
|
|
109
|
+
}
|
|
110
|
+
var Ie = class {
|
|
111
|
+
constructor(e) {
|
|
112
|
+
this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.headers = { "X-User-Anon-Id": e.widgetId || Te() }, e.userEmail && (this.headers["X-User-Email"] = e.userEmail), e.userJwt && (this.headers.Authorization = `Bearer ${e.userJwt}`), e.permission && (this.headers["X-Widget-Permission"] = e.permission);
|
|
113
|
+
const t = N(e.language);
|
|
114
|
+
t && (this.headers["Accept-Language"] = t);
|
|
115
|
+
}
|
|
116
|
+
updateConfig(e) {
|
|
117
|
+
const t = N(e.language);
|
|
118
|
+
e.baseUrl && (this.baseUrl = e.baseUrl.replace(/\/$/, "")), e.widgetId && (this.headers["X-User-Anon-Id"] = e.widgetId), e.userEmail && (this.headers["X-User-Email"] = e.userEmail), e.userJwt && (this.headers.Authorization = `Bearer ${e.userJwt}`), e.permission !== void 0 && (e.permission ? this.headers["X-Widget-Permission"] = e.permission : delete this.headers["X-Widget-Permission"]), e.language !== void 0 && (t ? this.headers["Accept-Language"] = t : delete this.headers["Accept-Language"]);
|
|
119
|
+
}
|
|
120
|
+
async get(e) {
|
|
121
|
+
return this.request("GET", e);
|
|
122
|
+
}
|
|
123
|
+
async post(e, t, s) {
|
|
124
|
+
return this.request("POST", e, t, s);
|
|
125
|
+
}
|
|
126
|
+
async postStream(e, t, s) {
|
|
127
|
+
const i = `${this.baseUrl}${e}`;
|
|
128
|
+
c.debug("POST (stream)", i, t);
|
|
129
|
+
try {
|
|
130
|
+
const n = await fetch(i, {
|
|
131
|
+
method: "POST",
|
|
132
|
+
headers: {
|
|
133
|
+
...this.headers,
|
|
134
|
+
"Content-Type": "application/json"
|
|
135
|
+
},
|
|
136
|
+
body: t ? JSON.stringify(t) : void 0,
|
|
137
|
+
signal: s?.signal
|
|
138
|
+
});
|
|
139
|
+
return n.ok || await this.handleErrorResponse(n), n;
|
|
140
|
+
} catch (n) {
|
|
141
|
+
throw n instanceof C || O(n) ? n : new F(`Network error: ${n instanceof Error ? n.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, n instanceof Error ? n : void 0);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async postFormData(e, t, s) {
|
|
145
|
+
const i = `${this.baseUrl}${e}`;
|
|
146
|
+
c.debug("POST (formData)", i);
|
|
147
|
+
const n = { ...this.headers };
|
|
148
|
+
try {
|
|
149
|
+
const r = await fetch(i, {
|
|
150
|
+
method: "POST",
|
|
151
|
+
headers: n,
|
|
152
|
+
body: t,
|
|
153
|
+
signal: s?.signal
|
|
154
|
+
});
|
|
155
|
+
return r.ok || await this.handleErrorResponse(r), r;
|
|
156
|
+
} catch (r) {
|
|
157
|
+
throw r instanceof C || O(r) ? r : new F(`Network error: ${r instanceof Error ? r.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, r instanceof Error ? r : void 0);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async request(e, t, s, i) {
|
|
161
|
+
const n = `${this.baseUrl}${t}`;
|
|
162
|
+
c.debug(e, n, s);
|
|
163
|
+
try {
|
|
164
|
+
const r = await fetch(n, {
|
|
165
|
+
method: e,
|
|
166
|
+
headers: {
|
|
167
|
+
...this.headers,
|
|
168
|
+
"Content-Type": "application/json"
|
|
169
|
+
},
|
|
170
|
+
body: s ? JSON.stringify(s) : void 0,
|
|
171
|
+
...i?.keepalive ? { keepalive: !0 } : {}
|
|
172
|
+
});
|
|
173
|
+
return r.ok || await this.handleErrorResponse(r), r.status === 204 ? void 0 : r.json();
|
|
174
|
+
} catch (r) {
|
|
175
|
+
throw r instanceof C ? r : new F(`Network error: ${r instanceof Error ? r.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, r instanceof Error ? r : void 0);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async handleErrorResponse(e) {
|
|
179
|
+
let t;
|
|
180
|
+
try {
|
|
181
|
+
t = await e.json();
|
|
182
|
+
} catch {
|
|
183
|
+
}
|
|
184
|
+
if (t?.error) throw C.fromResponse(t, e.status);
|
|
185
|
+
let s = "";
|
|
186
|
+
throw e.status === 401 || e.status === 403 ? s = " Check `userJwt` (and that it has not expired)." : e.status === 404 && (s = " Check that `baseUrl` points at your AGO API root."), new C(`HTTP ${e.status}: ${e.statusText}.${s}`, "http_error", e.status, "api_error");
|
|
187
|
+
}
|
|
188
|
+
}, ss = 10, is = 6e5;
|
|
189
|
+
var xe = "[AGO SDK]", Fe = 300;
|
|
190
|
+
function L(e, t) {
|
|
84
191
|
return e.length <= t ? e : e.slice(0, t) + `…[truncated ${e.length - t} chars]`;
|
|
85
192
|
}
|
|
86
|
-
function
|
|
193
|
+
function De(e) {
|
|
87
194
|
const t = e.search(/[?#]/);
|
|
88
195
|
return t === -1 ? e : e.slice(0, t);
|
|
89
196
|
}
|
|
90
|
-
function
|
|
197
|
+
function K(e) {
|
|
91
198
|
return typeof e == "object" && e !== null && typeof e.message == "string";
|
|
92
199
|
}
|
|
93
|
-
function
|
|
200
|
+
function pe(e) {
|
|
94
201
|
if (typeof e == "string") return e;
|
|
95
|
-
if (
|
|
202
|
+
if (K(e)) return (typeof e.name == "string" && e.name ? `${e.name}: ` : "") + e.message;
|
|
96
203
|
if (typeof e == "object" && e !== null) try {
|
|
97
|
-
return
|
|
204
|
+
return L(JSON.stringify(e), Fe);
|
|
98
205
|
} catch {
|
|
99
206
|
return String(e);
|
|
100
207
|
}
|
|
101
208
|
return String(e);
|
|
102
209
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
210
|
+
function D(e) {
|
|
211
|
+
return K(e) ? {
|
|
105
212
|
message: (typeof e.name == "string" && e.name && e.name !== "Error" ? `${e.name}: ` : "") + e.message,
|
|
106
213
|
stack: typeof e.stack == "string" ? e.stack : void 0
|
|
107
|
-
} : { message:
|
|
214
|
+
} : { message: pe(e) };
|
|
108
215
|
}
|
|
109
|
-
var
|
|
216
|
+
var $e = class {
|
|
110
217
|
constructor(e = {}) {
|
|
111
218
|
this.started = !1, this.teardowns = [], this.errors = [], this.listeners = /* @__PURE__ */ new Set(), this.capturing = !1;
|
|
112
219
|
const t = Math.floor(e.maxErrors ?? 10);
|
|
@@ -118,19 +225,19 @@ var Se = class {
|
|
|
118
225
|
const e = (s) => this.onErrorEvent(s);
|
|
119
226
|
window.addEventListener("error", e), this.teardowns.push(() => window.removeEventListener("error", e));
|
|
120
227
|
const t = (s) => this.onRejectionEvent(s);
|
|
121
|
-
window.addEventListener("unhandledrejection", t), this.teardowns.push(() => window.removeEventListener("unhandledrejection", t)), this.wrapConsoleError(),
|
|
228
|
+
window.addEventListener("unhandledrejection", t), this.teardowns.push(() => window.removeEventListener("unhandledrejection", t)), this.wrapConsoleError(), c.log("ErrorWatcher started");
|
|
122
229
|
}
|
|
123
230
|
destroy() {
|
|
124
231
|
for (const e of this.teardowns) e();
|
|
125
|
-
this.teardowns = [], this.listeners.clear(), this.started = !1,
|
|
232
|
+
this.teardowns = [], this.listeners.clear(), this.started = !1, c.log("ErrorWatcher destroyed");
|
|
126
233
|
}
|
|
127
234
|
report(e, t) {
|
|
128
|
-
const s =
|
|
235
|
+
const s = D(e);
|
|
129
236
|
this.capture({
|
|
130
237
|
type: "manual",
|
|
131
238
|
message: s.message,
|
|
132
239
|
stack: s.stack,
|
|
133
|
-
...t ? { context:
|
|
240
|
+
...t ? { context: me(t) } : {}
|
|
134
241
|
});
|
|
135
242
|
}
|
|
136
243
|
subscribe(e) {
|
|
@@ -146,18 +253,18 @@ var Se = class {
|
|
|
146
253
|
}
|
|
147
254
|
onErrorEvent(e) {
|
|
148
255
|
if (typeof e.message != "string" && !e.error) return;
|
|
149
|
-
const t = e.error !== void 0 && e.error !== null ?
|
|
256
|
+
const t = e.error !== void 0 && e.error !== null ? D(e.error) : { message: e.message ?? "" };
|
|
150
257
|
this.capture({
|
|
151
258
|
type: "error",
|
|
152
259
|
message: t.message || e.message || "Unknown error",
|
|
153
260
|
stack: t.stack,
|
|
154
|
-
source: e.filename ?
|
|
261
|
+
source: e.filename ? De(e.filename) : void 0,
|
|
155
262
|
line: e.lineno || void 0,
|
|
156
263
|
col: e.colno || void 0
|
|
157
264
|
});
|
|
158
265
|
}
|
|
159
266
|
onRejectionEvent(e) {
|
|
160
|
-
const t = e.reason, s =
|
|
267
|
+
const t = e.reason, s = D(t);
|
|
161
268
|
this.capture({
|
|
162
269
|
type: "unhandledrejection",
|
|
163
270
|
message: s.message || "Unhandled promise rejection",
|
|
@@ -180,8 +287,8 @@ var Se = class {
|
|
|
180
287
|
onConsoleError(e) {
|
|
181
288
|
if (e.length === 0) return;
|
|
182
289
|
const t = e[0];
|
|
183
|
-
if (typeof t == "string" && t.startsWith(
|
|
184
|
-
const s = e.find(
|
|
290
|
+
if (typeof t == "string" && t.startsWith(xe)) return;
|
|
291
|
+
const s = e.find(K), i = e.map(pe).join(" ");
|
|
185
292
|
this.capture({
|
|
186
293
|
type: "console",
|
|
187
294
|
message: i,
|
|
@@ -195,7 +302,7 @@ var Se = class {
|
|
|
195
302
|
const t = Date.now(), s = e.stack !== void 0 ? this.trimStack(e.stack, e.message) : void 0;
|
|
196
303
|
let i = {
|
|
197
304
|
type: e.type,
|
|
198
|
-
message:
|
|
305
|
+
message: L(e.message, 500),
|
|
199
306
|
...e.source !== void 0 ? { source: e.source } : {},
|
|
200
307
|
...e.line !== void 0 ? { line: e.line } : {},
|
|
201
308
|
...e.col !== void 0 ? { col: e.col } : {},
|
|
@@ -207,19 +314,19 @@ var Se = class {
|
|
|
207
314
|
...e.context !== void 0 ? { context: e.context } : {}
|
|
208
315
|
};
|
|
209
316
|
if (this.filter) {
|
|
210
|
-
const
|
|
211
|
-
if (!
|
|
212
|
-
i =
|
|
317
|
+
const a = this.filter(i);
|
|
318
|
+
if (!a) return;
|
|
319
|
+
i = a;
|
|
213
320
|
}
|
|
214
321
|
this.prune(t);
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
|
|
322
|
+
const n = Z(i), r = this.errors.find((a) => Z(a) === n);
|
|
323
|
+
if (r) {
|
|
324
|
+
r.count += 1, r.lastAt = t, i.context !== void 0 && (r.context = i.context), this.notify(r);
|
|
218
325
|
return;
|
|
219
326
|
}
|
|
220
327
|
this.errors.push(i);
|
|
221
|
-
const
|
|
222
|
-
|
|
328
|
+
const o = this.errors.length - this.maxErrors;
|
|
329
|
+
o > 0 && this.errors.splice(0, o), this.notify(i);
|
|
223
330
|
} finally {
|
|
224
331
|
this.capturing = !1;
|
|
225
332
|
}
|
|
@@ -230,7 +337,7 @@ var Se = class {
|
|
|
230
337
|
for (const s of this.listeners) try {
|
|
231
338
|
s(t);
|
|
232
339
|
} catch (i) {
|
|
233
|
-
|
|
340
|
+
c.error("ErrorWatcher listener threw:", i);
|
|
234
341
|
}
|
|
235
342
|
}
|
|
236
343
|
prune(e = Date.now()) {
|
|
@@ -241,109 +348,47 @@ var Se = class {
|
|
|
241
348
|
const i = s.indexOf(`
|
|
242
349
|
`);
|
|
243
350
|
if (i !== -1 && s.slice(0, i).includes(t.slice(0, 80)) && (s = s.slice(i + 1)), s = s.trim(), !!s)
|
|
244
|
-
return
|
|
351
|
+
return L(s, this.maxStackChars);
|
|
245
352
|
}
|
|
246
353
|
currentPathname() {
|
|
247
354
|
return typeof window < "u" && window.location ? window.location.pathname : "";
|
|
248
355
|
}
|
|
249
356
|
};
|
|
250
|
-
function
|
|
357
|
+
function Z(e) {
|
|
251
358
|
return `${e.type}|${e.message}|${e.source ?? ""}|${e.line ?? ""}`;
|
|
252
359
|
}
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
|
|
360
|
+
var k = {
|
|
361
|
+
name: 30,
|
|
362
|
+
description: 500,
|
|
363
|
+
parameterName: 30,
|
|
364
|
+
parameterDescription: 150,
|
|
365
|
+
resultBytes: 1500
|
|
366
|
+
};
|
|
367
|
+
function Me(e) {
|
|
368
|
+
const t = [], s = (i, n, r) => {
|
|
369
|
+
const o = n?.length ?? 0;
|
|
370
|
+
o > r && t.push(`${i} (${o}/${r})`);
|
|
371
|
+
};
|
|
372
|
+
s("name", e.name, k.name), s("description", e.description, k.description);
|
|
373
|
+
for (const [i, n] of Object.entries(e.parameters?.properties ?? {}))
|
|
374
|
+
s(`"${i}" name`, i, k.parameterName), s(`"${i}" description`, n.description ?? "", k.parameterDescription);
|
|
375
|
+
return t;
|
|
268
376
|
}
|
|
269
|
-
var
|
|
377
|
+
var Pe = 5e4, Ne = 2e4, Oe = 2e3, Le = class {
|
|
270
378
|
constructor(e) {
|
|
271
|
-
this.
|
|
272
|
-
}
|
|
273
|
-
updateConfig(e) {
|
|
274
|
-
e.baseUrl && (this.baseUrl = e.baseUrl.replace(/\/$/, "")), e.widgetId && (this.headers["X-User-Anon-Id"] = e.widgetId), e.userEmail && (this.headers["X-User-Email"] = e.userEmail), e.userJwt && (this.headers.Authorization = `Bearer ${e.userJwt}`), e.permission !== void 0 && (e.permission ? this.headers["X-Widget-Permission"] = e.permission : delete this.headers["X-Widget-Permission"]);
|
|
275
|
-
}
|
|
276
|
-
async get(e) {
|
|
277
|
-
return this.request("GET", e);
|
|
278
|
-
}
|
|
279
|
-
async post(e, t, s) {
|
|
280
|
-
return this.request("POST", e, t, s);
|
|
281
|
-
}
|
|
282
|
-
async postStream(e, t, s) {
|
|
283
|
-
const i = `${this.baseUrl}${e}`;
|
|
284
|
-
l.debug("POST (stream)", i, t);
|
|
285
|
-
try {
|
|
286
|
-
const r = await fetch(i, {
|
|
287
|
-
method: "POST",
|
|
288
|
-
headers: {
|
|
289
|
-
...this.headers,
|
|
290
|
-
"Content-Type": "application/json"
|
|
291
|
-
},
|
|
292
|
-
body: t ? JSON.stringify(t) : void 0,
|
|
293
|
-
signal: s?.signal
|
|
294
|
-
});
|
|
295
|
-
return r.ok || await this.handleErrorResponse(r), r;
|
|
296
|
-
} catch (r) {
|
|
297
|
-
throw r instanceof _ || M(r) ? r : new R(`Network error: ${r instanceof Error ? r.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, r instanceof Error ? r : void 0);
|
|
298
|
-
}
|
|
379
|
+
this.functions = /* @__PURE__ */ new Map(), this.changeListeners = /* @__PURE__ */ new Set(), this.defaultMaxResultBytes = e?.maxResultBytes ?? Pe;
|
|
299
380
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
try {
|
|
305
|
-
const n = await fetch(i, {
|
|
306
|
-
method: "POST",
|
|
307
|
-
headers: r,
|
|
308
|
-
body: t,
|
|
309
|
-
signal: s?.signal
|
|
310
|
-
});
|
|
311
|
-
return n.ok || await this.handleErrorResponse(n), n;
|
|
312
|
-
} catch (n) {
|
|
313
|
-
throw n instanceof _ || M(n) ? n : new R(`Network error: ${n instanceof Error ? n.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, n instanceof Error ? n : void 0);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
async request(e, t, s, i) {
|
|
317
|
-
const r = `${this.baseUrl}${t}`;
|
|
318
|
-
l.debug(e, r, s);
|
|
319
|
-
try {
|
|
320
|
-
const n = await fetch(r, {
|
|
321
|
-
method: e,
|
|
322
|
-
headers: {
|
|
323
|
-
...this.headers,
|
|
324
|
-
"Content-Type": "application/json"
|
|
325
|
-
},
|
|
326
|
-
body: s ? JSON.stringify(s) : void 0,
|
|
327
|
-
...i?.keepalive ? { keepalive: !0 } : {}
|
|
328
|
-
});
|
|
329
|
-
return n.ok || await this.handleErrorResponse(n), n.status === 204 ? void 0 : n.json();
|
|
330
|
-
} catch (n) {
|
|
331
|
-
throw n instanceof _ ? n : new R(`Network error: ${n instanceof Error ? n.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, n instanceof Error ? n : void 0);
|
|
332
|
-
}
|
|
381
|
+
onChange(e) {
|
|
382
|
+
return this.changeListeners.add(e), () => {
|
|
383
|
+
this.changeListeners.delete(e);
|
|
384
|
+
};
|
|
333
385
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
386
|
+
emitChange() {
|
|
387
|
+
for (const e of this.changeListeners) try {
|
|
388
|
+
e();
|
|
389
|
+
} catch (t) {
|
|
390
|
+
c.error("Function registry change listener failed:", t);
|
|
339
391
|
}
|
|
340
|
-
if (t?.error) throw _.fromResponse(t, e.status);
|
|
341
|
-
let s = "";
|
|
342
|
-
throw e.status === 401 || e.status === 403 ? s = " Check `userJwt` (and that it has not expired)." : e.status === 404 && (s = " Check that `baseUrl` points at your AGO API root."), new _(`HTTP ${e.status}: ${e.statusText}.${s}`, "http_error", e.status, "api_error");
|
|
343
|
-
}
|
|
344
|
-
}, Ae = 5e4, ke = 2e4, Re = 2e3, Ie = class {
|
|
345
|
-
constructor(e) {
|
|
346
|
-
this.functions = /* @__PURE__ */ new Map(), this.defaultMaxResultBytes = e?.maxResultBytes ?? Ae;
|
|
347
392
|
}
|
|
348
393
|
setDefaultMaxResultBytes(e) {
|
|
349
394
|
this.defaultMaxResultBytes = e;
|
|
@@ -353,31 +398,35 @@ var be = class {
|
|
|
353
398
|
}
|
|
354
399
|
register(e, t, s) {
|
|
355
400
|
if (typeof e == "object") {
|
|
356
|
-
const { name:
|
|
357
|
-
return this.register(
|
|
358
|
-
description:
|
|
359
|
-
parameters:
|
|
360
|
-
maxResultBytes:
|
|
361
|
-
requiresApproval:
|
|
401
|
+
const { name: d, handler: f, description: m, parameters: v, maxResultBytes: p, requiresApproval: h, webmcp: g } = e;
|
|
402
|
+
return this.register(d, f, {
|
|
403
|
+
description: m,
|
|
404
|
+
parameters: v,
|
|
405
|
+
maxResultBytes: p,
|
|
406
|
+
requiresApproval: h,
|
|
407
|
+
webmcp: g
|
|
362
408
|
});
|
|
363
409
|
}
|
|
364
410
|
const i = e;
|
|
365
411
|
if (!t || !s) throw new S(`registerFunction("${i}"): both a handler and a schema are required. Pass them as arguments or use the single-object form: registerFunction({ name, parameters, handler }).`, "function_invalid_registration");
|
|
366
|
-
this.functions.has(i) &&
|
|
367
|
-
const { maxResultBytes:
|
|
412
|
+
this.functions.has(i) && c.warn(`Function "${i}" is being overwritten`);
|
|
413
|
+
const { maxResultBytes: n, requiresApproval: r, webmcp: o, ...a } = s, l = {
|
|
414
|
+
...a,
|
|
415
|
+
name: i
|
|
416
|
+
};
|
|
368
417
|
this.functions.set(i, {
|
|
369
|
-
schema:
|
|
370
|
-
...a,
|
|
371
|
-
name: i
|
|
372
|
-
},
|
|
418
|
+
schema: l,
|
|
373
419
|
handler: t,
|
|
374
|
-
maxResultBytes:
|
|
375
|
-
requiresApproval:
|
|
376
|
-
|
|
420
|
+
maxResultBytes: n,
|
|
421
|
+
requiresApproval: r,
|
|
422
|
+
webmcp: o
|
|
423
|
+
});
|
|
424
|
+
const u = Me(l);
|
|
425
|
+
u.length > 0 && c.warn(`Function "${i}" is over the per-tool budget on ${u.join(", ")}.`), c.log(`Registered function: ${i}`), this.emitChange();
|
|
377
426
|
}
|
|
378
427
|
unregister(e) {
|
|
379
428
|
const t = this.functions.delete(e);
|
|
380
|
-
return t &&
|
|
429
|
+
return t && (c.log(`Unregistered function: ${e}`), this.emitChange()), t;
|
|
381
430
|
}
|
|
382
431
|
get(e) {
|
|
383
432
|
return this.functions.get(e);
|
|
@@ -388,15 +437,21 @@ var be = class {
|
|
|
388
437
|
getSchemas() {
|
|
389
438
|
return Array.from(this.functions.values()).map((e) => e.schema);
|
|
390
439
|
}
|
|
440
|
+
getAll() {
|
|
441
|
+
return Array.from(this.functions.entries()).map(([e, t]) => ({
|
|
442
|
+
...t,
|
|
443
|
+
name: e
|
|
444
|
+
}));
|
|
445
|
+
}
|
|
391
446
|
async execute(e, t) {
|
|
392
447
|
const s = this.functions.get(e);
|
|
393
|
-
if (!s) throw new
|
|
394
|
-
|
|
448
|
+
if (!s) throw new V(`Function "${e}" is not registered`, e);
|
|
449
|
+
c.log(`Executing function: ${e}`, t);
|
|
395
450
|
try {
|
|
396
451
|
const i = await s.handler(t);
|
|
397
|
-
return
|
|
452
|
+
return c.log(`Function ${e} completed:`, i), this.guardResultSize(e, i, s.maxResultBytes);
|
|
398
453
|
} catch (i) {
|
|
399
|
-
throw
|
|
454
|
+
throw c.error(`Function ${e} failed:`, i), new V(`Function "${e}" execution failed: ${i instanceof Error ? i.message : "Unknown error"}`, e, i instanceof Error ? i : void 0);
|
|
400
455
|
}
|
|
401
456
|
}
|
|
402
457
|
guardResultSize(e, t, s) {
|
|
@@ -407,314 +462,443 @@ var be = class {
|
|
|
407
462
|
return t;
|
|
408
463
|
}
|
|
409
464
|
if (i === void 0) return t;
|
|
410
|
-
const
|
|
411
|
-
return
|
|
465
|
+
const n = new TextEncoder().encode(i).length, r = s ?? this.defaultMaxResultBytes;
|
|
466
|
+
return n > r ? (c.warn(`Function "${e}" result is ${n} bytes, over the ${r}-byte limit; a truncated preview was sent to the agent instead. Return fewer fields, paginate, or raise maxResultBytes for this function.`), {
|
|
412
467
|
truncated: !0,
|
|
413
|
-
originalBytes:
|
|
414
|
-
maxBytes:
|
|
415
|
-
preview: i.slice(0,
|
|
416
|
-
hint: `The result of "${e}" exceeded the ${
|
|
417
|
-
}) : (
|
|
468
|
+
originalBytes: n,
|
|
469
|
+
maxBytes: r,
|
|
470
|
+
preview: i.slice(0, Oe),
|
|
471
|
+
hint: `The result of "${e}" exceeded the ${r}-byte limit and was truncated. Request less data (use limit or filter parameters if available), or tell the user the result is too large to process.`
|
|
472
|
+
}) : (n > Ne && c.warn(`Function "${e}" returned a large result (${Math.round(n / 1024)} KB). Large results consume LLM context: return fewer fields, paginate, or push the data to the UI and return a summary.`), t);
|
|
418
473
|
}
|
|
419
474
|
clear() {
|
|
420
|
-
this.functions.
|
|
475
|
+
const e = this.functions.size > 0;
|
|
476
|
+
this.functions.clear(), c.log("Cleared all registered functions"), e && this.emitChange();
|
|
421
477
|
}
|
|
422
478
|
get size() {
|
|
423
479
|
return this.functions.size;
|
|
424
480
|
}
|
|
425
|
-
},
|
|
426
|
-
function
|
|
427
|
-
return
|
|
481
|
+
}, je = new TextEncoder();
|
|
482
|
+
function E(e) {
|
|
483
|
+
return je.encode(e).length;
|
|
428
484
|
}
|
|
429
|
-
function
|
|
430
|
-
return
|
|
485
|
+
function j(e) {
|
|
486
|
+
return E(JSON.stringify(e)) - 2;
|
|
431
487
|
}
|
|
432
|
-
function
|
|
488
|
+
function ye(e, t) {
|
|
433
489
|
if (t <= 0) return "";
|
|
434
490
|
let s = "", i = 0;
|
|
435
|
-
for (const
|
|
436
|
-
const
|
|
437
|
-
if (i +
|
|
438
|
-
s +=
|
|
491
|
+
for (const n of e) {
|
|
492
|
+
const r = j(n);
|
|
493
|
+
if (i + r > t) break;
|
|
494
|
+
s += n, i += r;
|
|
439
495
|
}
|
|
440
496
|
return s;
|
|
441
497
|
}
|
|
442
|
-
var
|
|
443
|
-
var
|
|
444
|
-
function
|
|
498
|
+
var Ue = 50, We = 2;
|
|
499
|
+
var Be = 2e3;
|
|
500
|
+
function A(e) {
|
|
445
501
|
try {
|
|
446
502
|
return JSON.stringify(e);
|
|
447
503
|
} catch {
|
|
448
504
|
return;
|
|
449
505
|
}
|
|
450
506
|
}
|
|
451
|
-
var
|
|
452
|
-
function
|
|
453
|
-
return t <= 0 ? Promise.resolve(
|
|
454
|
-
const
|
|
455
|
-
e.then((
|
|
456
|
-
clearTimeout(
|
|
457
|
-
}, (
|
|
458
|
-
clearTimeout(
|
|
507
|
+
var U = /* @__PURE__ */ Symbol("ago.pageData.timeout");
|
|
508
|
+
function Ge(e, t) {
|
|
509
|
+
return t <= 0 ? Promise.resolve(U) : new Promise((s, i) => {
|
|
510
|
+
const n = setTimeout(() => s(U), t);
|
|
511
|
+
e.then((r) => {
|
|
512
|
+
clearTimeout(n), s(r);
|
|
513
|
+
}, (r) => {
|
|
514
|
+
clearTimeout(n), i(r);
|
|
459
515
|
});
|
|
460
516
|
});
|
|
461
517
|
}
|
|
462
|
-
async function
|
|
518
|
+
async function qe(e, t) {
|
|
463
519
|
const s = Date.now() + t;
|
|
464
520
|
let i = 0;
|
|
465
|
-
for (; Date.now() < s && i <
|
|
466
|
-
i = e().isLoading?.() ? 0 : i + 1, await new Promise((
|
|
467
|
-
const
|
|
468
|
-
if (!
|
|
469
|
-
const
|
|
470
|
-
if (
|
|
471
|
-
|
|
472
|
-
const
|
|
473
|
-
if (!
|
|
474
|
-
Promise.resolve(
|
|
521
|
+
for (; Date.now() < s && i < We; )
|
|
522
|
+
i = e().isLoading?.() ? 0 : i + 1, await new Promise((a) => setTimeout(a, Ue));
|
|
523
|
+
const n = e().get();
|
|
524
|
+
if (!ee(n)) return n;
|
|
525
|
+
const r = await Ge(Promise.resolve(n), s - Date.now());
|
|
526
|
+
if (r !== U) return r;
|
|
527
|
+
c.warn("Page data did not resolve within the settle timeout; returning what the page has now. Raise settleTimeoutMs if the work legitimately takes longer.");
|
|
528
|
+
const o = e().get();
|
|
529
|
+
if (!ee(o)) return o;
|
|
530
|
+
Promise.resolve(o).catch(() => {
|
|
475
531
|
});
|
|
476
532
|
}
|
|
477
|
-
function
|
|
533
|
+
function ee(e) {
|
|
478
534
|
return typeof e == "object" && e !== null && typeof e.then == "function";
|
|
479
535
|
}
|
|
480
|
-
function
|
|
536
|
+
function Ke(e) {
|
|
481
537
|
if (typeof e != "object" || e === null || Array.isArray(e)) return;
|
|
482
538
|
const t = e;
|
|
483
539
|
let s;
|
|
484
540
|
for (const i of Object.keys(t)) {
|
|
485
|
-
const
|
|
486
|
-
Array.isArray(
|
|
541
|
+
const n = t[i];
|
|
542
|
+
Array.isArray(n) && (s === void 0 || n.length > t[s].length) && (s = i);
|
|
487
543
|
}
|
|
488
544
|
return s;
|
|
489
545
|
}
|
|
490
|
-
function
|
|
546
|
+
function Je(e, t) {
|
|
491
547
|
let s = 2, i = 0;
|
|
492
|
-
for (const
|
|
493
|
-
const
|
|
494
|
-
if (s +
|
|
495
|
-
s +=
|
|
548
|
+
for (const n of e) {
|
|
549
|
+
const r = E(A(n) ?? "null") + (i > 0 ? 1 : 0);
|
|
550
|
+
if (s + r > t) break;
|
|
551
|
+
s += r, i++;
|
|
496
552
|
}
|
|
497
553
|
return i;
|
|
498
554
|
}
|
|
499
|
-
function
|
|
555
|
+
function W(e) {
|
|
500
556
|
return `The page data returned by "${e}" was too large to send in full. Only the first items are included: ask for fewer rows or narrow the filters to see the rest.`;
|
|
501
557
|
}
|
|
502
|
-
function
|
|
503
|
-
const
|
|
558
|
+
function He(e, t, s, i) {
|
|
559
|
+
const n = {
|
|
504
560
|
truncated: !0,
|
|
505
561
|
originalBytes: s,
|
|
506
562
|
maxBytes: i,
|
|
507
563
|
preview: "",
|
|
508
|
-
hint:
|
|
509
|
-
},
|
|
564
|
+
hint: W(e)
|
|
565
|
+
}, r = E(A(n) ?? "{}");
|
|
510
566
|
return {
|
|
511
|
-
...
|
|
512
|
-
preview:
|
|
567
|
+
...n,
|
|
568
|
+
preview: ye(t, Math.min(Be, i - r))
|
|
513
569
|
};
|
|
514
570
|
}
|
|
515
|
-
function
|
|
516
|
-
const
|
|
517
|
-
...
|
|
518
|
-
[
|
|
571
|
+
function ze(e, t, s, i, n) {
|
|
572
|
+
const r = s === void 0 ? {} : { ...t }, o = s ?? "items", a = E(A({
|
|
573
|
+
...r,
|
|
574
|
+
[o]: [],
|
|
519
575
|
truncation: {
|
|
520
576
|
truncated: !0,
|
|
521
577
|
returnedItems: i.length,
|
|
522
578
|
totalItems: i.length,
|
|
523
|
-
hint:
|
|
579
|
+
hint: W(e)
|
|
524
580
|
}
|
|
525
581
|
}) ?? "{}") - 2;
|
|
526
|
-
if (
|
|
527
|
-
const
|
|
582
|
+
if (a >= n) return;
|
|
583
|
+
const l = i.slice(0, Je(i, n - a));
|
|
528
584
|
return {
|
|
529
|
-
...
|
|
530
|
-
[
|
|
585
|
+
...r,
|
|
586
|
+
[o]: l,
|
|
531
587
|
truncation: {
|
|
532
588
|
truncated: !0,
|
|
533
|
-
returnedItems:
|
|
589
|
+
returnedItems: l.length,
|
|
534
590
|
totalItems: i.length,
|
|
535
|
-
hint:
|
|
591
|
+
hint: W(e)
|
|
536
592
|
}
|
|
537
593
|
};
|
|
538
594
|
}
|
|
539
|
-
function
|
|
540
|
-
const i =
|
|
595
|
+
function te(e, t, s) {
|
|
596
|
+
const i = A(t);
|
|
541
597
|
if (i === void 0) return t;
|
|
542
|
-
const
|
|
543
|
-
if (
|
|
544
|
-
|
|
545
|
-
const
|
|
546
|
-
if (
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
598
|
+
const n = E(i);
|
|
599
|
+
if (n <= s) return t;
|
|
600
|
+
c.warn(`Page data for "${e}" is ${n} bytes, over the ${s}-byte limit; it was truncated to the first items that fit. Return fewer fields per item, paginate, or raise maxResultBytes on the data source.`);
|
|
601
|
+
const r = Ke(t), o = Array.isArray(t) ? t : r !== void 0 ? t[r] : void 0;
|
|
602
|
+
if (o) {
|
|
603
|
+
const a = ze(e, t, r, o, s), l = E(A(a) ?? "");
|
|
604
|
+
if (a !== void 0 && l <= s) return a;
|
|
605
|
+
}
|
|
606
|
+
return He(e, i, n, s);
|
|
607
|
+
}
|
|
608
|
+
var J = "navigateToPage", T = "listPages";
|
|
609
|
+
function Xe(e) {
|
|
610
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
611
|
+
}
|
|
612
|
+
function B(e) {
|
|
613
|
+
return e.split("/").filter((t) => t.startsWith(":")).map((t) => t.slice(1));
|
|
614
|
+
}
|
|
615
|
+
function Ve(e, t) {
|
|
616
|
+
const s = [];
|
|
617
|
+
return {
|
|
618
|
+
path: e.split("/").map((i) => {
|
|
619
|
+
if (!i.startsWith(":")) return i;
|
|
620
|
+
const n = i.slice(1), r = t[n];
|
|
621
|
+
return r == null || r === "" ? (s.push(n), i) : encodeURIComponent(String(r));
|
|
622
|
+
}).join("/"),
|
|
623
|
+
missing: s
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function Ye(e, t) {
|
|
627
|
+
const s = t.find((n) => n.path === e);
|
|
628
|
+
if (s) return s;
|
|
629
|
+
const i = t.find((n) => {
|
|
630
|
+
if (!n.path.includes(":")) return !1;
|
|
631
|
+
const r = "^" + n.path.split("/").map((o) => o.startsWith(":") ? "[^/]+" : Xe(o)).join("/") + "/?$";
|
|
632
|
+
return new RegExp(r).test(e);
|
|
633
|
+
});
|
|
634
|
+
return i || t.filter((n) => n.path !== "/" && e.startsWith(n.path)).sort((n, r) => r.path.length - n.path.length)[0];
|
|
635
|
+
}
|
|
636
|
+
function ve(e) {
|
|
637
|
+
return [...new Set(e.map((t) => t.section).filter((t) => !!t))];
|
|
638
|
+
}
|
|
639
|
+
function Qe(e) {
|
|
640
|
+
const t = B(e.path), s = t.length > 0 ? ` (requires ${t.map((i) => `"${i}"`).join(", ")})` : "";
|
|
641
|
+
return `- "${e.name}"${s}: ${e.description}`;
|
|
642
|
+
}
|
|
643
|
+
function Ze(e, t, s) {
|
|
644
|
+
const i = s?.catalogue === "onDemand", n = ve(t);
|
|
645
|
+
!i && n.length > 0 && c.log('registerNavigationFunction: routes declare "section" but catalogue is "inline", so it is unused. Set catalogue: "onDemand" to use it.');
|
|
646
|
+
const r = i ? `Navigate the user to a page. Call ${T} for what a page name means.` : `Navigate the user to a page in the application. Available pages:
|
|
647
|
+
${t.map(Qe).join(`
|
|
648
|
+
`)}`, o = /* @__PURE__ */ new Map();
|
|
649
|
+
for (const u of t) for (const d of B(u.path)) o.set(d, [...o.get(d) ?? [], u.name]);
|
|
650
|
+
const a = t.map((u) => u.name), l = { page: {
|
|
651
|
+
type: "string",
|
|
652
|
+
description: "The page to navigate to",
|
|
653
|
+
enum: a
|
|
654
|
+
} };
|
|
655
|
+
for (const [u, d] of o) {
|
|
656
|
+
if (u === "page") {
|
|
657
|
+
c.error('registerNavigationFunction: a ":page" placeholder collides with the "page" argument and is ignored. Rename the placeholder.');
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
l[u] = {
|
|
661
|
+
type: "string",
|
|
662
|
+
description: `Value for ":${u}" in the page path. Required when page is ${d.map((f) => `"${f}"`).join(" or ")}.`
|
|
663
|
+
};
|
|
549
664
|
}
|
|
550
|
-
return
|
|
665
|
+
return {
|
|
666
|
+
name: J,
|
|
667
|
+
description: r,
|
|
668
|
+
parameters: {
|
|
669
|
+
type: "object",
|
|
670
|
+
properties: l,
|
|
671
|
+
required: ["page"]
|
|
672
|
+
},
|
|
673
|
+
webmcp: { navigates: !0 },
|
|
674
|
+
handler: async (u) => {
|
|
675
|
+
const d = u.page, f = t.find((g) => g.name === d);
|
|
676
|
+
if (!f) return i ? {
|
|
677
|
+
success: !1,
|
|
678
|
+
error: `Unknown page: ${d}`,
|
|
679
|
+
pages: a
|
|
680
|
+
} : {
|
|
681
|
+
success: !1,
|
|
682
|
+
error: `Unknown page: ${d}`
|
|
683
|
+
};
|
|
684
|
+
let m = {};
|
|
685
|
+
if (typeof u.params == "string") try {
|
|
686
|
+
m = JSON.parse(u.params);
|
|
687
|
+
} catch {
|
|
688
|
+
}
|
|
689
|
+
else u.params && typeof u.params == "object" && (m = u.params);
|
|
690
|
+
const v = {};
|
|
691
|
+
for (const g of B(f.path)) v[g] = u[g] ?? m[g];
|
|
692
|
+
const { path: p, missing: h } = Ve(f.path, v);
|
|
693
|
+
if (h.length > 0) {
|
|
694
|
+
const g = h.map((y) => `"${y}": "..."`).join(", ");
|
|
695
|
+
return {
|
|
696
|
+
success: !1,
|
|
697
|
+
error: `Page "${d}" needs ${h.map((y) => `"${y}"`).join(", ")}. Retry with { "page": "${d}", ${g} }.`
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
return e(p), {
|
|
701
|
+
success: !0,
|
|
702
|
+
navigatedTo: p
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
function et(e) {
|
|
708
|
+
const t = ve(e), s = (i) => ({
|
|
709
|
+
name: i.name,
|
|
710
|
+
description: i.description
|
|
711
|
+
});
|
|
712
|
+
return {
|
|
713
|
+
name: T,
|
|
714
|
+
description: `List what each page name of ${J} means.`,
|
|
715
|
+
parameters: {
|
|
716
|
+
type: "object",
|
|
717
|
+
properties: t.length > 0 ? { section: {
|
|
718
|
+
type: "string",
|
|
719
|
+
description: "Which group of pages to list.",
|
|
720
|
+
enum: t
|
|
721
|
+
} } : {},
|
|
722
|
+
required: t.length > 0 ? ["section"] : []
|
|
723
|
+
},
|
|
724
|
+
webmcp: { annotations: { readOnlyHint: !0 } },
|
|
725
|
+
handler: (i) => {
|
|
726
|
+
if (t.length === 0) return { pages: e.map(s) };
|
|
727
|
+
const n = typeof i.section == "string" ? i.section : void 0, r = t.find((o) => o.toLowerCase() === n?.toLowerCase());
|
|
728
|
+
return r ? { pages: e.filter((o) => o.section === r).map(s) } : {
|
|
729
|
+
pages: [],
|
|
730
|
+
sections: t,
|
|
731
|
+
error: n ? `Unknown section: ${n}` : '"section" is required. Pick one and call again.'
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
};
|
|
551
735
|
}
|
|
552
|
-
function
|
|
736
|
+
function I(e, t) {
|
|
553
737
|
if (e === t) return !0;
|
|
554
738
|
if (e === null || t === null || typeof e != "object" || typeof t != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
555
739
|
if (Array.isArray(e))
|
|
556
|
-
return e.length !== t.length ? !1 : e.every((
|
|
740
|
+
return e.length !== t.length ? !1 : e.every((n, r) => I(n, t[r]));
|
|
557
741
|
const s = Object.keys(e), i = Object.keys(t);
|
|
558
|
-
return s.length !== i.length ? !1 : s.every((
|
|
742
|
+
return s.length !== i.length ? !1 : s.every((n) => n in t && I(e[n], t[n]));
|
|
559
743
|
}
|
|
560
|
-
var
|
|
561
|
-
function
|
|
562
|
-
return
|
|
744
|
+
var se = 100, $ = " … [truncated]", we = { truncated: !0 }, tt = E(',"data":' + JSON.stringify(we));
|
|
745
|
+
function G(e) {
|
|
746
|
+
return E(JSON.stringify(e));
|
|
563
747
|
}
|
|
564
|
-
function
|
|
565
|
-
if (
|
|
566
|
-
const s = Object.entries(e.rejected), i = Object.fromEntries(s.map(([
|
|
748
|
+
function ie(e, t) {
|
|
749
|
+
if (G(e) <= t || !e.rejected) return e;
|
|
750
|
+
const s = Object.entries(e.rejected), i = Object.fromEntries(s.map(([a]) => [a, $])), n = {
|
|
567
751
|
...e,
|
|
568
752
|
rejected: i
|
|
569
753
|
};
|
|
570
|
-
let
|
|
571
|
-
if (
|
|
572
|
-
const
|
|
573
|
-
for (const [
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
576
|
-
i[
|
|
754
|
+
let r = G(n);
|
|
755
|
+
if (r > t) return n;
|
|
756
|
+
const o = j($);
|
|
757
|
+
for (const [a, l] of s) {
|
|
758
|
+
const u = j(l), d = t - r + o;
|
|
759
|
+
if (u <= d) {
|
|
760
|
+
i[a] = l, r += u - o;
|
|
577
761
|
continue;
|
|
578
762
|
}
|
|
579
|
-
i[
|
|
763
|
+
i[a] = ye(l, d - o) + $;
|
|
580
764
|
break;
|
|
581
765
|
}
|
|
582
|
-
return
|
|
766
|
+
return n;
|
|
583
767
|
}
|
|
584
|
-
function
|
|
768
|
+
function _(e) {
|
|
585
769
|
return Array.isArray(e) ? "array" : typeof e;
|
|
586
770
|
}
|
|
587
|
-
function
|
|
588
|
-
return typeof e != "number" ? `Expected type "number", got "${
|
|
771
|
+
function ne(e) {
|
|
772
|
+
return typeof e != "number" ? `Expected type "number", got "${_(e)}".` : Number.isFinite(e) ? null : "Expected a finite number.";
|
|
589
773
|
}
|
|
590
|
-
function
|
|
591
|
-
const t = e.slice(0,
|
|
774
|
+
function Ee(e) {
|
|
775
|
+
const t = e.slice(0, se).map((i) => JSON.stringify(i)), s = e.length - se;
|
|
592
776
|
return s > 0 ? `${t.join(", ")} (${s} more not shown)` : t.join(", ");
|
|
593
777
|
}
|
|
594
|
-
function
|
|
595
|
-
return t.includes(e) ? null : `${JSON.stringify(e)} is not an allowed value. Allowed values: ${
|
|
778
|
+
function re(e, t) {
|
|
779
|
+
return t.includes(e) ? null : `${JSON.stringify(e)} is not an allowed value. Allowed values: ${Ee(t)}.`;
|
|
596
780
|
}
|
|
597
|
-
function
|
|
781
|
+
function st(e, t) {
|
|
598
782
|
const { schema: s } = t;
|
|
599
783
|
if (s.type === "array") {
|
|
600
|
-
if (!Array.isArray(e)) return `Expected type "array", got "${
|
|
601
|
-
for (let
|
|
602
|
-
const
|
|
784
|
+
if (!Array.isArray(e)) return `Expected type "array", got "${_(e)}".`;
|
|
785
|
+
for (let n = 0; n < e.length; n++) {
|
|
786
|
+
const r = e[n];
|
|
603
787
|
if (s.items?.type) {
|
|
604
|
-
const
|
|
605
|
-
if (
|
|
788
|
+
const o = s.items.type === "number" ? ne(r) : _(r) !== s.items.type ? `Expected type "${s.items.type}", got "${_(r)}".` : null;
|
|
789
|
+
if (o) return `Array item at index ${n}: ${o[0].toLowerCase()}${o.slice(1)}`;
|
|
606
790
|
}
|
|
607
791
|
if (s.items?.enum) {
|
|
608
|
-
const
|
|
609
|
-
if (
|
|
792
|
+
const o = re(r, s.items.enum);
|
|
793
|
+
if (o) return `Array item ${o}`;
|
|
610
794
|
}
|
|
611
795
|
}
|
|
612
796
|
return null;
|
|
613
797
|
}
|
|
614
798
|
if (s.type === "number") {
|
|
615
|
-
const
|
|
616
|
-
if (
|
|
617
|
-
} else if (
|
|
618
|
-
const i =
|
|
619
|
-
return i ?
|
|
799
|
+
const n = ne(e);
|
|
800
|
+
if (n) return n;
|
|
801
|
+
} else if (_(e) !== s.type) return `Expected type "${s.type}", got "${_(e)}".`;
|
|
802
|
+
const i = be(t);
|
|
803
|
+
return i ? re(e, i) : null;
|
|
620
804
|
}
|
|
621
|
-
function
|
|
805
|
+
function H(e) {
|
|
622
806
|
return e.clearable === !0 && e.schema.type === "string";
|
|
623
807
|
}
|
|
624
|
-
function
|
|
808
|
+
function be(e) {
|
|
625
809
|
const t = e.schema.enum;
|
|
626
810
|
if (t)
|
|
627
|
-
return
|
|
811
|
+
return H(e) && !t.includes("") ? [...t, ""] : t;
|
|
628
812
|
}
|
|
629
|
-
function
|
|
813
|
+
function it(e) {
|
|
630
814
|
const t = {
|
|
631
815
|
...e.schema,
|
|
632
816
|
description: e.description
|
|
633
817
|
};
|
|
634
|
-
|
|
635
|
-
const s =
|
|
818
|
+
H(e) && (t.description = `${e.description} Pass "" to clear it.`);
|
|
819
|
+
const s = be(e);
|
|
636
820
|
return s && (t.enum = s), t;
|
|
637
821
|
}
|
|
638
|
-
function
|
|
639
|
-
const s = new Map(e.map((
|
|
822
|
+
function nt(e, t) {
|
|
823
|
+
const s = new Map(e.map((r) => [r.name, r])), i = e.map((r) => r.name), n = e.map((r) => `- "${r.name}": ${r.description}`).join(`
|
|
640
824
|
`);
|
|
641
825
|
return {
|
|
642
826
|
name: t.name,
|
|
643
|
-
handler: async (
|
|
644
|
-
const
|
|
645
|
-
for (const [
|
|
646
|
-
const
|
|
647
|
-
if (!
|
|
648
|
-
|
|
827
|
+
handler: async (r) => {
|
|
828
|
+
const o = [], a = [], l = {};
|
|
829
|
+
for (const [h, g] of Object.entries(r)) {
|
|
830
|
+
const y = s.get(h);
|
|
831
|
+
if (!y) {
|
|
832
|
+
l[h] = `"${h}" is not a registered control. Available controls: ${Ee(i)}.`;
|
|
649
833
|
continue;
|
|
650
834
|
}
|
|
651
|
-
if (
|
|
652
|
-
const
|
|
653
|
-
if (
|
|
654
|
-
|
|
835
|
+
if (g == null || g === "" && !H(y)) continue;
|
|
836
|
+
const b = st(g, y);
|
|
837
|
+
if (b) {
|
|
838
|
+
l[h] = b;
|
|
655
839
|
continue;
|
|
656
840
|
}
|
|
657
|
-
if (
|
|
658
|
-
|
|
841
|
+
if (y.get && I(g, y.get())) {
|
|
842
|
+
a.push(h);
|
|
659
843
|
continue;
|
|
660
844
|
}
|
|
661
|
-
const
|
|
662
|
-
|
|
845
|
+
const w = await y.set(g);
|
|
846
|
+
w ? w.result === "rejected" ? l[h] = w.reason || "The page rejected this field's update." : w.result === "unchanged" ? a.push(h) : o.push(h) : o.push(h);
|
|
663
847
|
}
|
|
664
|
-
const
|
|
665
|
-
success: !
|
|
666
|
-
applied:
|
|
667
|
-
unchanged:
|
|
668
|
-
...
|
|
669
|
-
},
|
|
670
|
-
if (!t.data) return
|
|
671
|
-
const
|
|
672
|
-
...
|
|
673
|
-
data:
|
|
848
|
+
const u = Object.keys(l).length > 0, d = {
|
|
849
|
+
success: !u,
|
|
850
|
+
applied: o,
|
|
851
|
+
unchanged: a,
|
|
852
|
+
...u ? { rejected: l } : {}
|
|
853
|
+
}, f = t.getResultBudget();
|
|
854
|
+
if (!t.data) return ie(d, f);
|
|
855
|
+
const m = ie(d, f - tt), v = await t.data.read(m), p = {
|
|
856
|
+
...m,
|
|
857
|
+
data: v
|
|
674
858
|
};
|
|
675
|
-
return
|
|
676
|
-
...
|
|
677
|
-
data:
|
|
859
|
+
return G(p) <= f ? p : {
|
|
860
|
+
...m,
|
|
861
|
+
data: we
|
|
678
862
|
};
|
|
679
863
|
},
|
|
680
864
|
description: (e.length > 0 ? `Change the state of the current page. Set ONLY the controls the user explicitly asked for; leave the others unset. Available controls:
|
|
681
|
-
${
|
|
865
|
+
${n}` : "The current page has no editable state — nothing to change here.") + (t.data ? `
|
|
682
866
|
Returns the resulting page data once it has loaded: ${t.data.description}` : ""),
|
|
683
867
|
parameters: {
|
|
684
868
|
type: "object",
|
|
685
|
-
properties: Object.fromEntries(e.map((
|
|
869
|
+
properties: Object.fromEntries(e.map((r) => [r.name, it(r)])),
|
|
686
870
|
required: []
|
|
687
871
|
},
|
|
688
872
|
requiresApproval: t.requiresApproval,
|
|
689
873
|
maxResultBytes: t.data?.maxResultBytes
|
|
690
874
|
};
|
|
691
875
|
}
|
|
692
|
-
var
|
|
876
|
+
var rt = 250, ot = 3, at = 1e3, ct = 24, lt = 10, ut = 50, dt = [
|
|
693
877
|
"mousemove",
|
|
694
878
|
"mousedown",
|
|
695
879
|
"keydown",
|
|
696
880
|
"scroll",
|
|
697
881
|
"touchstart"
|
|
698
|
-
],
|
|
882
|
+
], ht = class {
|
|
699
883
|
constructor(e = {}) {
|
|
700
|
-
this.started = !1, this.teardowns = [], this.route = "", this.routeEnteredAt = 0, this.lastActivityAt = 0, this.lastHeavyActivityAt = 0, this.recentRoutes = [], this.routeBounces = 0, this.rageClicks = 0, this.jsErrors = 0, this.fieldErrors = {}, this.recentClicks = [], this.signals = [], this.listeners = /* @__PURE__ */ new Set(), this.getPageState = e.getPageState, this.activityThrottleMs = e.activityThrottleMs ??
|
|
884
|
+
this.started = !1, this.teardowns = [], this.route = "", this.routeEnteredAt = 0, this.lastActivityAt = 0, this.lastHeavyActivityAt = 0, this.recentRoutes = [], this.routeBounces = 0, this.rageClicks = 0, this.jsErrors = 0, this.fieldErrors = {}, this.recentClicks = [], this.signals = [], this.listeners = /* @__PURE__ */ new Set(), this.getPageState = e.getPageState, this.activityThrottleMs = e.activityThrottleMs ?? rt, this.rageClickCount = e.rageClickCount ?? ot, this.rageClickWindowMs = e.rageClickWindowMs ?? at, this.rageClickRadiusPx = e.rageClickRadiusPx ?? ct, this.maxRecentRoutes = e.maxRecentRoutes ?? lt, this.maxSignals = e.maxSignals ?? ut;
|
|
701
885
|
}
|
|
702
886
|
start() {
|
|
703
887
|
if (this.started || typeof window > "u" || typeof document > "u") return;
|
|
704
888
|
this.started = !0;
|
|
705
889
|
const e = Date.now();
|
|
706
890
|
this.route = this.currentPathname(), this.routeEnteredAt = e, this.lastActivityAt = e, this.recentRoutes = [this.route];
|
|
707
|
-
const t = (i,
|
|
708
|
-
i.addEventListener(
|
|
891
|
+
const t = (i, n, r) => {
|
|
892
|
+
i.addEventListener(n, r, { passive: !0 }), this.teardowns.push(() => i.removeEventListener(n, r));
|
|
709
893
|
}, s = () => this.recordActivity();
|
|
710
|
-
for (const i of
|
|
894
|
+
for (const i of dt) t(window, i, s);
|
|
711
895
|
t(document, "visibilitychange", () => {
|
|
712
896
|
document.visibilityState === "visible" && this.recordActivity();
|
|
713
|
-
}), t(window, "popstate", () => this.checkRoute()), t(window, "hashchange", () => this.checkRoute()), t(window, "click", (i) => this.onClick(i)),
|
|
897
|
+
}), t(window, "popstate", () => this.checkRoute()), t(window, "hashchange", () => this.checkRoute()), t(window, "click", (i) => this.onClick(i)), c.log("SignalCollector started");
|
|
714
898
|
}
|
|
715
899
|
destroy() {
|
|
716
900
|
for (const e of this.teardowns) e();
|
|
717
|
-
this.teardowns = [], this.listeners.clear(), this.recentClicks = [], this.started = !1,
|
|
901
|
+
this.teardowns = [], this.listeners.clear(), this.recentClicks = [], this.started = !1, c.log("SignalCollector destroyed");
|
|
718
902
|
}
|
|
719
903
|
signalFieldError(e) {
|
|
720
904
|
this.checkRoute();
|
|
@@ -767,7 +951,7 @@ var qe = 250, Ge = 3, Ke = 1e3, Je = 24, He = 10, Xe = 50, Ve = [
|
|
|
767
951
|
try {
|
|
768
952
|
return this.getPageState() ?? null;
|
|
769
953
|
} catch (e) {
|
|
770
|
-
return
|
|
954
|
+
return c.warn("SignalCollector getPageState threw:", e), null;
|
|
771
955
|
}
|
|
772
956
|
}
|
|
773
957
|
recordActivity() {
|
|
@@ -785,13 +969,13 @@ var qe = 250, Ge = 3, Ke = 1e3, Je = 24, He = 10, Xe = 50, Ve = [
|
|
|
785
969
|
at: t,
|
|
786
970
|
meta: { from: s }
|
|
787
971
|
});
|
|
788
|
-
const i = this.recentRoutes,
|
|
789
|
-
|
|
972
|
+
const i = this.recentRoutes, n = i.length;
|
|
973
|
+
n >= 4 && i[n - 1] === i[n - 3] && i[n - 2] === i[n - 4] && i[n - 1] !== i[n - 2] && (this.routeBounces += 1, this.pushSignal({
|
|
790
974
|
type: "route_bounce",
|
|
791
975
|
route: e,
|
|
792
976
|
at: t,
|
|
793
977
|
count: this.routeBounces,
|
|
794
|
-
meta: { between: `${i[
|
|
978
|
+
meta: { between: `${i[n - 2]}↔${i[n - 1]}` }
|
|
795
979
|
}));
|
|
796
980
|
}
|
|
797
981
|
onClick(e) {
|
|
@@ -802,9 +986,9 @@ var qe = 250, Ge = 3, Ke = 1e3, Je = 24, He = 10, Xe = 50, Ve = [
|
|
|
802
986
|
y: e.clientY,
|
|
803
987
|
stateKey: s
|
|
804
988
|
};
|
|
805
|
-
this.recentClicks = this.recentClicks.filter((
|
|
806
|
-
const
|
|
807
|
-
if (!
|
|
989
|
+
this.recentClicks = this.recentClicks.filter((a) => t - a.at <= this.rageClickWindowMs);
|
|
990
|
+
const n = this.recentClicks[0], r = !n || Math.abs(i.x - n.x) <= this.rageClickRadiusPx && Math.abs(i.y - n.y) <= this.rageClickRadiusPx, o = !n || n.stateKey === s;
|
|
991
|
+
if (!r || !o) {
|
|
808
992
|
this.recentClicks = [i];
|
|
809
993
|
return;
|
|
810
994
|
}
|
|
@@ -829,20 +1013,20 @@ var qe = 250, Ge = 3, Ke = 1e3, Je = 24, He = 10, Xe = 50, Ve = [
|
|
|
829
1013
|
for (const t of this.listeners) try {
|
|
830
1014
|
t(e);
|
|
831
1015
|
} catch (s) {
|
|
832
|
-
|
|
1016
|
+
c.error("Signal listener threw:", s);
|
|
833
1017
|
}
|
|
834
1018
|
}
|
|
835
1019
|
};
|
|
836
|
-
function
|
|
1020
|
+
function gt(e, t) {
|
|
837
1021
|
const s = t ? t.storage ?? (typeof localStorage < "u" ? localStorage : void 0) : void 0;
|
|
838
1022
|
let i = e;
|
|
839
1023
|
if (t && s) try {
|
|
840
|
-
const
|
|
841
|
-
|
|
1024
|
+
const a = s.getItem(t.key);
|
|
1025
|
+
a != null && (i = JSON.parse(a));
|
|
842
1026
|
} catch {
|
|
843
1027
|
}
|
|
844
|
-
const
|
|
845
|
-
function
|
|
1028
|
+
const n = /* @__PURE__ */ new Set(), r = () => n.forEach((a) => a(i));
|
|
1029
|
+
function o() {
|
|
846
1030
|
if (t && s) try {
|
|
847
1031
|
s.setItem(t.key, JSON.stringify(i));
|
|
848
1032
|
} catch {
|
|
@@ -850,31 +1034,31 @@ function Ye(e, t) {
|
|
|
850
1034
|
}
|
|
851
1035
|
return {
|
|
852
1036
|
get: () => i,
|
|
853
|
-
set: (
|
|
854
|
-
i =
|
|
1037
|
+
set: (a) => {
|
|
1038
|
+
i = a, o(), r();
|
|
855
1039
|
},
|
|
856
|
-
subscribe: (
|
|
857
|
-
|
|
1040
|
+
subscribe: (a) => (n.add(a), () => {
|
|
1041
|
+
n.delete(a);
|
|
858
1042
|
})
|
|
859
1043
|
};
|
|
860
1044
|
}
|
|
861
|
-
var
|
|
862
|
-
function
|
|
1045
|
+
var ft = 6e4, mt = 1440 * 60 * 1e3, pt = "ago_proactive";
|
|
1046
|
+
function M(e) {
|
|
863
1047
|
const t = new Date(e), s = String(t.getMonth() + 1).padStart(2, "0"), i = String(t.getDate()).padStart(2, "0");
|
|
864
1048
|
return `${t.getFullYear()}-${s}-${i}`;
|
|
865
1049
|
}
|
|
866
|
-
var
|
|
1050
|
+
var yt = class {
|
|
867
1051
|
constructor(e = {}) {
|
|
868
|
-
this.killSwitchEnabled = !1, this.engaged = !1, this.turnInFlight = !1, this.slotOccupied = !1, this.sessionCount = 0, this.perSessionCap = e.frequencyCap?.perSession, this.perDayCap = e.frequencyCap?.perDay, this.store =
|
|
1052
|
+
this.killSwitchEnabled = !1, this.engaged = !1, this.turnInFlight = !1, this.slotOccupied = !1, this.sessionCount = 0, this.perSessionCap = e.frequencyCap?.perSession, this.perDayCap = e.frequencyCap?.perDay, this.store = gt({
|
|
869
1053
|
optOut: !1,
|
|
870
1054
|
lastFiredAt: {},
|
|
871
1055
|
dismissedAt: {},
|
|
872
1056
|
day: {
|
|
873
|
-
date:
|
|
1057
|
+
date: M(Date.now()),
|
|
874
1058
|
count: 0
|
|
875
1059
|
}
|
|
876
1060
|
}, {
|
|
877
|
-
key: e.storageKey ??
|
|
1061
|
+
key: e.storageKey ?? pt,
|
|
878
1062
|
storage: e.storage
|
|
879
1063
|
});
|
|
880
1064
|
}
|
|
@@ -918,10 +1102,10 @@ var tt = class {
|
|
|
918
1102
|
if (this.engaged) return this.deny(e, "user engaged (widget open)");
|
|
919
1103
|
if (this.turnInFlight) return this.deny(e, "message turn in flight");
|
|
920
1104
|
if (this.slotOccupied) return this.deny(e, "nudge slot occupied");
|
|
921
|
-
const i = s.lastFiredAt[e.id],
|
|
922
|
-
if (i !== void 0 && t - i <
|
|
923
|
-
const
|
|
924
|
-
return
|
|
1105
|
+
const i = s.lastFiredAt[e.id], n = e.cooldownMs ?? ft;
|
|
1106
|
+
if (i !== void 0 && t - i < n) return this.deny(e, "cooldown");
|
|
1107
|
+
const r = s.dismissedAt[e.id], o = e.resurfaceAfterMs ?? mt;
|
|
1108
|
+
return r !== void 0 && t - r < o ? this.deny(e, "dismissed recently") : this.perSessionCap !== void 0 && this.sessionCount >= this.perSessionCap ? this.deny(e, "perSession cap") : this.perDayCap !== void 0 && this.dayCount(t) >= this.perDayCap ? this.deny(e, "perDay cap") : !0;
|
|
925
1109
|
}
|
|
926
1110
|
recordFired(e, t = Date.now()) {
|
|
927
1111
|
const s = this.store.get();
|
|
@@ -935,7 +1119,7 @@ var tt = class {
|
|
|
935
1119
|
}
|
|
936
1120
|
recordNudgeShown(e = Date.now()) {
|
|
937
1121
|
this.sessionCount += 1;
|
|
938
|
-
const t = this.store.get(), s =
|
|
1122
|
+
const t = this.store.get(), s = M(e), i = t.day.date === s ? {
|
|
939
1123
|
date: s,
|
|
940
1124
|
count: t.day.count + 1
|
|
941
1125
|
} : {
|
|
@@ -959,50 +1143,50 @@ var tt = class {
|
|
|
959
1143
|
}
|
|
960
1144
|
dayCount(e) {
|
|
961
1145
|
const t = this.store.get();
|
|
962
|
-
return t.day.date ===
|
|
1146
|
+
return t.day.date === M(e) ? t.day.count : 0;
|
|
963
1147
|
}
|
|
964
1148
|
deny(e, t) {
|
|
965
|
-
return
|
|
1149
|
+
return c.debug(`NudgeGovernor: trigger "${e.id}" blocked — ${t}`), !1;
|
|
966
1150
|
}
|
|
967
1151
|
};
|
|
968
|
-
function
|
|
1152
|
+
function x() {
|
|
969
1153
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
970
1154
|
const t = Math.floor(Math.random() * 16);
|
|
971
1155
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
972
1156
|
});
|
|
973
1157
|
}
|
|
974
|
-
function
|
|
1158
|
+
function vt(e) {
|
|
975
1159
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
976
1160
|
}
|
|
977
|
-
function
|
|
1161
|
+
function wt(e, t) {
|
|
978
1162
|
if (e === "*" || e === t) return !0;
|
|
979
|
-
const s = e.split("/"), i = s.map((
|
|
980
|
-
const
|
|
981
|
-
return
|
|
1163
|
+
const s = e.split("/"), i = s.map((n, r) => {
|
|
1164
|
+
const o = r === s.length - 1;
|
|
1165
|
+
return n === "*" ? o ? "[^/]+(?:/[^/]+)*" : "[^/]+" : n.startsWith(":") ? "[^/]+" : vt(n);
|
|
982
1166
|
});
|
|
983
1167
|
return new RegExp("^" + i.join("/") + "/?$").test(t);
|
|
984
1168
|
}
|
|
985
|
-
function
|
|
986
|
-
return e === t ? !0 : e === null || t === null ? !1 : Array.isArray(e) ? !Array.isArray(t) || t.length !== e.length ? !1 : e.every((s, i) =>
|
|
1169
|
+
function Se(e, t) {
|
|
1170
|
+
return e === t ? !0 : e === null || t === null ? !1 : Array.isArray(e) ? !Array.isArray(t) || t.length !== e.length ? !1 : e.every((s, i) => I(s, t[i])) : typeof e == "object" ? typeof t != "object" || Array.isArray(t) ? !1 : Object.entries(e).every(([s, i]) => Se(i, t[s])) : !1;
|
|
987
1171
|
}
|
|
988
|
-
function
|
|
989
|
-
if (e.route !== void 0 && !
|
|
1172
|
+
function Et(e, t) {
|
|
1173
|
+
if (e.route !== void 0 && !wt(e.route, t.route) || e.idleMs !== void 0 && t.idleMs < e.idleMs || e.dwellMs !== void 0 && t.dwellMs < e.dwellMs || e.rageClicks !== void 0 && t.rageClicks < e.rageClicks || e.jsErrors !== void 0 && (t.jsErrors ?? 0) < e.jsErrors || e.routeBounces !== void 0 && t.routeBounces < e.routeBounces) return !1;
|
|
990
1174
|
if (e.fieldErrors !== void 0) {
|
|
991
1175
|
for (const [s, i] of Object.entries(e.fieldErrors)) if ((t.fieldErrors[s] ?? 0) < i) return !1;
|
|
992
1176
|
}
|
|
993
|
-
return !(e.pageState !== void 0 && !
|
|
1177
|
+
return !(e.pageState !== void 0 && !Se(e.pageState, t.pageState ?? {}));
|
|
994
1178
|
}
|
|
995
|
-
var
|
|
1179
|
+
var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate", Ct = class {
|
|
996
1180
|
constructor(e) {
|
|
997
|
-
this.tickTimer = null, this.teardowns = [], this.started = !1, this.activeNudge = null, this.lastConversationId = null, this.shownIds = /* @__PURE__ */ new Set(), this.resolvedIds = /* @__PURE__ */ new Set(), this.lastEvaluationAt = 0, this.client = e.client, this.collector = e.collector, this.governor = e.governor, this.tracker = e.tracker, this.options = e.options, this.tickMs = e.options.tickMs ??
|
|
1181
|
+
this.tickTimer = null, this.teardowns = [], this.started = !1, this.activeNudge = null, this.lastConversationId = null, this.shownIds = /* @__PURE__ */ new Set(), this.resolvedIds = /* @__PURE__ */ new Set(), this.lastEvaluationAt = 0, this.client = e.client, this.collector = e.collector, this.governor = e.governor, this.tracker = e.tracker, this.options = e.options, this.tickMs = e.options.tickMs ?? bt;
|
|
998
1182
|
}
|
|
999
1183
|
start() {
|
|
1000
1184
|
if (this.started) return;
|
|
1001
1185
|
this.started = !0, this.options.enabledOverride !== void 0 ? this.governor.setKillSwitch(this.options.enabledOverride) : this.loadKillSwitch();
|
|
1002
|
-
const e = (
|
|
1003
|
-
|
|
1004
|
-
}, t = () => this.governor.setTurnInFlight(!1), s = () => this.governor.setTurnInFlight(!1), i = (
|
|
1005
|
-
|
|
1186
|
+
const e = (n) => {
|
|
1187
|
+
n.conversationId && (this.lastConversationId = n.conversationId), this.governor.setTurnInFlight(!0);
|
|
1188
|
+
}, t = () => this.governor.setTurnInFlight(!1), s = () => this.governor.setTurnInFlight(!1), i = (n) => {
|
|
1189
|
+
n?.id && (this.lastConversationId = n.id);
|
|
1006
1190
|
};
|
|
1007
1191
|
this.client.on("message:start", e), this.client.on("message:complete", t), this.client.on("message:error", s), this.client.on("conversation:loaded", i), this.teardowns.push(() => {
|
|
1008
1192
|
this.client.off("message:start", e), this.client.off("message:complete", t), this.client.off("message:error", s), this.client.off("conversation:loaded", i);
|
|
@@ -1020,17 +1204,17 @@ var nt = 1e3, ot = "/api/sdk/v1/config", at = "/api/sdk/v1/proactive/evaluate",
|
|
|
1020
1204
|
}
|
|
1021
1205
|
async loadKillSwitch() {
|
|
1022
1206
|
try {
|
|
1023
|
-
const e = await this.client.getHttp().get(
|
|
1207
|
+
const e = await this.client.getHttp().get(St);
|
|
1024
1208
|
this.governor.setKillSwitch(e?.proactive?.enabled === !0);
|
|
1025
1209
|
} catch (e) {
|
|
1026
|
-
|
|
1210
|
+
c.debug("Proactive config fetch failed; staying disabled:", e), this.governor.setKillSwitch(!1);
|
|
1027
1211
|
}
|
|
1028
1212
|
}
|
|
1029
1213
|
evaluate() {
|
|
1030
1214
|
if (this.lastEvaluationAt = Date.now(), typeof document < "u" && document.visibilityState === "hidden" || this.governor.isSlotOccupied()) return;
|
|
1031
1215
|
const e = this.collector.getSnapshot();
|
|
1032
1216
|
for (const t of this.options.triggers)
|
|
1033
|
-
if (
|
|
1217
|
+
if (Et(t.when, e) && this.governor.canFire(t)) {
|
|
1034
1218
|
this.fire(t);
|
|
1035
1219
|
return;
|
|
1036
1220
|
}
|
|
@@ -1041,7 +1225,7 @@ var nt = 1e3, ot = "/api/sdk/v1/config", at = "/api/sdk/v1/proactive/evaluate",
|
|
|
1041
1225
|
return;
|
|
1042
1226
|
}
|
|
1043
1227
|
this.setReady({
|
|
1044
|
-
id:
|
|
1228
|
+
id: x(),
|
|
1045
1229
|
triggerId: e.id,
|
|
1046
1230
|
source: "static",
|
|
1047
1231
|
message: e.intervene.message,
|
|
@@ -1052,7 +1236,7 @@ var nt = 1e3, ot = "/api/sdk/v1/config", at = "/api/sdk/v1/proactive/evaluate",
|
|
|
1052
1236
|
});
|
|
1053
1237
|
}
|
|
1054
1238
|
async evaluateWithAgent(e) {
|
|
1055
|
-
const t =
|
|
1239
|
+
const t = x(), s = {
|
|
1056
1240
|
client_nudge_id: t,
|
|
1057
1241
|
trigger_id: e.id,
|
|
1058
1242
|
goal: e.goal ?? "",
|
|
@@ -1063,9 +1247,9 @@ var nt = 1e3, ot = "/api/sdk/v1/config", at = "/api/sdk/v1/proactive/evaluate",
|
|
|
1063
1247
|
};
|
|
1064
1248
|
let i;
|
|
1065
1249
|
try {
|
|
1066
|
-
i = await this.client.getHttp().post(
|
|
1067
|
-
} catch (
|
|
1068
|
-
|
|
1250
|
+
i = await this.client.getHttp().post(_t, s);
|
|
1251
|
+
} catch (n) {
|
|
1252
|
+
c.debug("Proactive evaluate failed (treated as no-intervene):", n), this.governor.releaseSlot();
|
|
1069
1253
|
return;
|
|
1070
1254
|
}
|
|
1071
1255
|
if (!i?.intervene || !i.message) {
|
|
@@ -1077,7 +1261,7 @@ var nt = 1e3, ot = "/api/sdk/v1/config", at = "/api/sdk/v1/proactive/evaluate",
|
|
|
1077
1261
|
triggerId: e.id,
|
|
1078
1262
|
source: "agent",
|
|
1079
1263
|
message: i.message,
|
|
1080
|
-
action:
|
|
1264
|
+
action: At(i.action),
|
|
1081
1265
|
goal: e.goal,
|
|
1082
1266
|
kickoff: e.kickoff,
|
|
1083
1267
|
createdAt: /* @__PURE__ */ new Date(),
|
|
@@ -1113,10 +1297,10 @@ var nt = 1e3, ot = "/api/sdk/v1/config", at = "/api/sdk/v1/proactive/evaluate",
|
|
|
1113
1297
|
source: e.source,
|
|
1114
1298
|
type: "accepted",
|
|
1115
1299
|
occurredAt: Date.now()
|
|
1116
|
-
}), this.clearActive(e), this.client.emitProactiveEvent("nudge:accepted", { nudge: e }), (e.source === "agent" || e.goal) && (this.lastConversationId ? this.client.sendMessage(
|
|
1300
|
+
}), this.clearActive(e), this.client.emitProactiveEvent("nudge:accepted", { nudge: e }), (e.source === "agent" || e.goal) && (this.lastConversationId ? this.client.sendMessage(kt(e), {
|
|
1117
1301
|
hidden: !0,
|
|
1118
1302
|
conversationId: this.lastConversationId
|
|
1119
|
-
}).catch((t) =>
|
|
1303
|
+
}).catch((t) => c.debug("Nudge kickoff message failed:", t)) : e.kickoff ? this.client.sendMessage(e.kickoff).catch((t) => c.debug("Nudge kickoff message failed:", t)) : c.debug("Nudge accepted with no open conversation and no trigger.kickoff; skipping the chat pre-seed (a hidden message cannot open a conversation).")), e.action && await this.runAction(e.action));
|
|
1120
1304
|
}
|
|
1121
1305
|
markConverted(e) {
|
|
1122
1306
|
this.tracker.track({
|
|
@@ -1134,11 +1318,11 @@ var nt = 1e3, ot = "/api/sdk/v1/config", at = "/api/sdk/v1/proactive/evaluate",
|
|
|
1134
1318
|
try {
|
|
1135
1319
|
"functionName" in e ? await this.client.executeClientFunction(e.functionName, e.arguments ?? {}) : await this.client.executeClientFunction("setPageState", e.setPageState);
|
|
1136
1320
|
} catch (t) {
|
|
1137
|
-
|
|
1321
|
+
c.warn("Nudge action failed:", t);
|
|
1138
1322
|
}
|
|
1139
1323
|
}
|
|
1140
1324
|
};
|
|
1141
|
-
function
|
|
1325
|
+
function At(e) {
|
|
1142
1326
|
if (e)
|
|
1143
1327
|
return {
|
|
1144
1328
|
label: e.label,
|
|
@@ -1146,13 +1330,13 @@ function lt(e) {
|
|
|
1146
1330
|
arguments: e.arguments
|
|
1147
1331
|
};
|
|
1148
1332
|
}
|
|
1149
|
-
function
|
|
1333
|
+
function kt(e) {
|
|
1150
1334
|
const t = e.goal ? ` Goal: ${e.goal}.` : "";
|
|
1151
1335
|
return `The user accepted a proactive nudge that said: "${e.message}".${t} Recent friction signals are in the client context (friction_signals). Start helping with this now: briefly explain what you can do and take the first concrete step.`;
|
|
1152
1336
|
}
|
|
1153
|
-
var
|
|
1337
|
+
var Rt = 5e3, Tt = "/api/sdk/v1/proactive/events", It = class {
|
|
1154
1338
|
constructor(e) {
|
|
1155
|
-
if (this.queue = [], this.flushTimer = null, this.teardowns = [], this.destroyed = !1, this.post = e.post, this.agent = e.agent, this.flushIntervalMs = e.flushIntervalMs ??
|
|
1339
|
+
if (this.queue = [], this.flushTimer = null, this.teardowns = [], this.destroyed = !1, this.post = e.post, this.agent = e.agent, this.flushIntervalMs = e.flushIntervalMs ?? Rt, typeof document < "u") {
|
|
1156
1340
|
const t = () => {
|
|
1157
1341
|
document.visibilityState === "hidden" && this.flush({ keepalive: !0 });
|
|
1158
1342
|
};
|
|
@@ -1179,8 +1363,8 @@ var ut = 5e3, ht = "/api/sdk/v1/proactive/events", ft = class {
|
|
|
1179
1363
|
...this.agent ? { agent: this.agent } : {},
|
|
1180
1364
|
occurred_at: new Date(i.occurredAt).toISOString()
|
|
1181
1365
|
})) };
|
|
1182
|
-
this.post(
|
|
1183
|
-
|
|
1366
|
+
this.post(Tt, s, e).catch((i) => {
|
|
1367
|
+
c.debug("Proactive event batch failed:", i);
|
|
1184
1368
|
});
|
|
1185
1369
|
}
|
|
1186
1370
|
destroy() {
|
|
@@ -1190,81 +1374,81 @@ var ut = 5e3, ht = "/api/sdk/v1/proactive/events", ft = class {
|
|
|
1190
1374
|
this.teardowns = [];
|
|
1191
1375
|
}
|
|
1192
1376
|
}
|
|
1193
|
-
},
|
|
1194
|
-
function
|
|
1195
|
-
e.proactive && (
|
|
1196
|
-
const s = new
|
|
1377
|
+
}, oe = "friction_signals";
|
|
1378
|
+
function ae(e, t) {
|
|
1379
|
+
e.proactive && (c.warn("createAgoProactive: a proactive controller is already attached; replacing it."), e.proactive.destroy());
|
|
1380
|
+
const s = new ht({
|
|
1197
1381
|
...t.signals,
|
|
1198
1382
|
getPageState: () => {
|
|
1199
|
-
const
|
|
1200
|
-
if (!
|
|
1201
|
-
const
|
|
1202
|
-
for (const [
|
|
1203
|
-
return Object.keys(
|
|
1383
|
+
const l = e.getContextSnapshot();
|
|
1384
|
+
if (!l) return null;
|
|
1385
|
+
const u = {};
|
|
1386
|
+
for (const [d, f] of Object.entries(l.entries)) d.startsWith("page-state:") && f.data && Object.assign(u, f.data);
|
|
1387
|
+
return Object.keys(u).length > 0 ? u : null;
|
|
1204
1388
|
}
|
|
1205
1389
|
});
|
|
1206
1390
|
s.start();
|
|
1207
|
-
const i = (
|
|
1208
|
-
s.signalJsError(
|
|
1391
|
+
const i = (l) => {
|
|
1392
|
+
s.signalJsError(l.type);
|
|
1209
1393
|
};
|
|
1210
|
-
e.on("error:captured", i), e.addDynamicContext(
|
|
1211
|
-
const { pageState:
|
|
1394
|
+
e.on("error:captured", i), e.addDynamicContext(oe, () => {
|
|
1395
|
+
const { pageState: l, ...u } = s.getSnapshot({ pageState: !1 });
|
|
1212
1396
|
return {
|
|
1213
1397
|
name: "Friction signals",
|
|
1214
1398
|
description: "Behavioral friction observed on the current page: dwell/idle times, rage clicks, route bounces, repeated field errors, JavaScript error count (names and counters only).",
|
|
1215
|
-
data:
|
|
1399
|
+
data: u
|
|
1216
1400
|
};
|
|
1217
1401
|
});
|
|
1218
|
-
const
|
|
1402
|
+
const n = new yt({
|
|
1219
1403
|
frequencyCap: t.frequencyCap,
|
|
1220
1404
|
storage: t.storage,
|
|
1221
1405
|
storageKey: t.storageKey
|
|
1222
|
-
}),
|
|
1223
|
-
post: (
|
|
1406
|
+
}), r = new It({
|
|
1407
|
+
post: (l, u, d) => e.getHttp().post(l, u, d),
|
|
1224
1408
|
agent: e.getConfiguredAgent()
|
|
1225
|
-
}),
|
|
1409
|
+
}), o = new Ct({
|
|
1226
1410
|
client: e,
|
|
1227
1411
|
collector: s,
|
|
1228
|
-
governor:
|
|
1229
|
-
tracker:
|
|
1412
|
+
governor: n,
|
|
1413
|
+
tracker: r,
|
|
1230
1414
|
options: t
|
|
1231
1415
|
});
|
|
1232
|
-
|
|
1233
|
-
const
|
|
1234
|
-
optOut: () =>
|
|
1235
|
-
optIn: () =>
|
|
1236
|
-
isOptedOut: () =>
|
|
1237
|
-
setEngaged: (
|
|
1238
|
-
signalFieldError: (
|
|
1416
|
+
o.start();
|
|
1417
|
+
const a = {
|
|
1418
|
+
optOut: () => n.optOut(),
|
|
1419
|
+
optIn: () => n.optIn(),
|
|
1420
|
+
isOptedOut: () => n.isOptedOut(),
|
|
1421
|
+
setEngaged: (l) => n.setEngaged(l),
|
|
1422
|
+
signalFieldError: (l) => s.signalFieldError(l),
|
|
1239
1423
|
getSignalsSnapshot: () => s.getSnapshot(),
|
|
1240
|
-
getActiveNudge: () =>
|
|
1241
|
-
shown: (
|
|
1242
|
-
accept: (
|
|
1243
|
-
dismiss: (
|
|
1244
|
-
markConverted: (
|
|
1424
|
+
getActiveNudge: () => o.getActiveNudge(),
|
|
1425
|
+
shown: (l) => o.shown(l),
|
|
1426
|
+
accept: (l) => o.accept(l),
|
|
1427
|
+
dismiss: (l) => o.dismiss(l),
|
|
1428
|
+
markConverted: (l) => o.markConverted(l),
|
|
1245
1429
|
destroy: () => {
|
|
1246
|
-
|
|
1430
|
+
o.stop(), r.destroy(), e.off("error:captured", i), s.destroy(), e.removeDynamicContext(oe), e.proactive === a && (e.proactive = null);
|
|
1247
1431
|
}
|
|
1248
1432
|
};
|
|
1249
|
-
return e.proactive =
|
|
1433
|
+
return e.proactive = a, a;
|
|
1250
1434
|
}
|
|
1251
|
-
var
|
|
1435
|
+
var xt = class {
|
|
1252
1436
|
constructor() {
|
|
1253
1437
|
this.entries = /* @__PURE__ */ new Map(), this.dynamicProviders = /* @__PURE__ */ new Map();
|
|
1254
1438
|
}
|
|
1255
1439
|
set(e, t) {
|
|
1256
|
-
this.entries.set(e, t),
|
|
1440
|
+
this.entries.set(e, t), c.log(`ClientContext set: ${e}`);
|
|
1257
1441
|
}
|
|
1258
1442
|
remove(e) {
|
|
1259
1443
|
const t = this.entries.delete(e);
|
|
1260
|
-
return t &&
|
|
1444
|
+
return t && c.log(`ClientContext removed: ${e}`), t;
|
|
1261
1445
|
}
|
|
1262
1446
|
addDynamicProvider(e, t) {
|
|
1263
|
-
this.dynamicProviders.set(e, t),
|
|
1447
|
+
this.dynamicProviders.set(e, t), c.log(`DynamicContext provider added: ${e}`);
|
|
1264
1448
|
}
|
|
1265
1449
|
removeDynamicProvider(e) {
|
|
1266
1450
|
const t = this.dynamicProviders.delete(e);
|
|
1267
|
-
return t &&
|
|
1451
|
+
return t && c.log(`DynamicContext provider removed: ${e}`), t;
|
|
1268
1452
|
}
|
|
1269
1453
|
getSnapshot() {
|
|
1270
1454
|
if (this.entries.size === 0 && this.dynamicProviders.size === 0) return null;
|
|
@@ -1274,69 +1458,69 @@ var gt = class {
|
|
|
1274
1458
|
const i = s();
|
|
1275
1459
|
i && (e[t] = i);
|
|
1276
1460
|
} catch (i) {
|
|
1277
|
-
|
|
1461
|
+
c.error(`DynamicContext provider "${t}" threw:`, i);
|
|
1278
1462
|
}
|
|
1279
1463
|
return Object.keys(e).length === 0 ? null : { entries: e };
|
|
1280
1464
|
}
|
|
1281
1465
|
clear() {
|
|
1282
|
-
this.entries.clear(), this.dynamicProviders.clear(),
|
|
1466
|
+
this.entries.clear(), this.dynamicProviders.clear(), c.log("ClientContext cleared");
|
|
1283
1467
|
}
|
|
1284
|
-
},
|
|
1285
|
-
function
|
|
1468
|
+
}, Ft = "page-state:";
|
|
1469
|
+
function Dt(e) {
|
|
1286
1470
|
const t = {};
|
|
1287
|
-
for (const [s, i] of Object.entries(e)) s.startsWith(
|
|
1471
|
+
for (const [s, i] of Object.entries(e)) s.startsWith(Ft) && i.data && Object.assign(t, i.data);
|
|
1288
1472
|
return t;
|
|
1289
1473
|
}
|
|
1290
|
-
function
|
|
1474
|
+
function $t(e) {
|
|
1291
1475
|
const t = e["current-page"]?.data;
|
|
1292
1476
|
return t?.page ? t.page : t?.url ? t.url : e["browser-page"]?.data?.url;
|
|
1293
1477
|
}
|
|
1294
|
-
function
|
|
1478
|
+
function Mt(e, t) {
|
|
1295
1479
|
return e === t ? !0 : JSON.stringify(e) === JSON.stringify(t);
|
|
1296
1480
|
}
|
|
1297
|
-
function
|
|
1481
|
+
function Pt(e, t) {
|
|
1298
1482
|
const s = [];
|
|
1299
1483
|
for (const i of Object.keys(t))
|
|
1300
|
-
i in e && (
|
|
1484
|
+
i in e && (Mt(e[i], t[i]) || s.push({
|
|
1301
1485
|
field: i,
|
|
1302
1486
|
from: e[i],
|
|
1303
1487
|
to: t[i]
|
|
1304
1488
|
}));
|
|
1305
1489
|
return s;
|
|
1306
1490
|
}
|
|
1307
|
-
function
|
|
1308
|
-
const s =
|
|
1491
|
+
function Nt(e, t) {
|
|
1492
|
+
const s = Dt(t), i = $t(t);
|
|
1309
1493
|
return {
|
|
1310
|
-
changes: e && e.page === i ?
|
|
1494
|
+
changes: e && e.page === i ? Pt(e.state, s) : [],
|
|
1311
1495
|
baseline: {
|
|
1312
1496
|
page: i,
|
|
1313
1497
|
state: s
|
|
1314
1498
|
}
|
|
1315
1499
|
};
|
|
1316
1500
|
}
|
|
1317
|
-
function
|
|
1318
|
-
return e === null || typeof e != "object" ? JSON.stringify(e) ?? "null" : Array.isArray(e) ? `[${e.map(
|
|
1501
|
+
function q(e) {
|
|
1502
|
+
return e === null || typeof e != "object" ? JSON.stringify(e) ?? "null" : Array.isArray(e) ? `[${e.map(q).join(",")}]` : `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${q(e[t])}`).join(",")}}`;
|
|
1319
1503
|
}
|
|
1320
|
-
var
|
|
1504
|
+
var ce = "", Ot = class {
|
|
1321
1505
|
constructor(e, t = {}) {
|
|
1322
1506
|
this.callbacks = e, this.options = t, this.buffer = "", this.message = {}, this.toolCalls = [], this.sources = [], this.followUpReplies = [], this.isFirstChunk = !0, this.answerCompleteEmitted = !1, this.waitingClientEmitted = !1, this.firedClientFunctions = /* @__PURE__ */ new Map();
|
|
1323
1507
|
}
|
|
1324
1508
|
async processStream(e) {
|
|
1325
|
-
if (!e.body) throw new
|
|
1509
|
+
if (!e.body) throw new X("Response has no body. The endpoint did not return a stream: check that `baseUrl` points at an AGO API and nothing (proxy, mock) strips the SSE body.", "stream_no_body");
|
|
1326
1510
|
const t = e.body.getReader(), s = new TextDecoder();
|
|
1327
1511
|
try {
|
|
1328
1512
|
for (; ; ) {
|
|
1329
|
-
const { done: i, value:
|
|
1513
|
+
const { done: i, value: n } = await t.read();
|
|
1330
1514
|
if (i) break;
|
|
1331
|
-
const
|
|
1332
|
-
this.buffer +=
|
|
1515
|
+
const r = s.decode(n, { stream: !0 });
|
|
1516
|
+
this.buffer += r, this.processBuffer();
|
|
1333
1517
|
}
|
|
1334
1518
|
return this.buffer.trim() && this.processBuffer(), this.buildFinalMessage();
|
|
1335
1519
|
} catch (i) {
|
|
1336
1520
|
if (this.options.signal?.aborted)
|
|
1337
1521
|
return this.message.status = "CANCELED", this.buildFinalMessage();
|
|
1338
|
-
const
|
|
1339
|
-
throw this.callbacks.onError?.(
|
|
1522
|
+
const n = i instanceof Error ? i : new X("Stream processing failed mid-flight. The connection may have dropped; retry the message.");
|
|
1523
|
+
throw this.callbacks.onError?.(n), n;
|
|
1340
1524
|
} finally {
|
|
1341
1525
|
t.releaseLock();
|
|
1342
1526
|
}
|
|
@@ -1352,12 +1536,12 @@ var ie = "", _t = class {
|
|
|
1352
1536
|
`);
|
|
1353
1537
|
for (const i of s)
|
|
1354
1538
|
if (!i.startsWith(": ") && i.startsWith("data: ")) {
|
|
1355
|
-
const
|
|
1539
|
+
const n = i.slice(6);
|
|
1356
1540
|
try {
|
|
1357
|
-
const
|
|
1358
|
-
this.handleChunk(
|
|
1359
|
-
} catch (
|
|
1360
|
-
|
|
1541
|
+
const r = JSON.parse(n);
|
|
1542
|
+
this.handleChunk(r);
|
|
1543
|
+
} catch (r) {
|
|
1544
|
+
c.warn("Failed to parse SSE data:", n, r);
|
|
1361
1545
|
}
|
|
1362
1546
|
}
|
|
1363
1547
|
}
|
|
@@ -1385,9 +1569,9 @@ var ie = "", _t = class {
|
|
|
1385
1569
|
url: s.use_external_link ? s.external_link_url : s.internal_link_url
|
|
1386
1570
|
};
|
|
1387
1571
|
})), e.type === "client_function" && e.function_name) {
|
|
1388
|
-
const t = `${e.function_name}::${
|
|
1389
|
-
let
|
|
1390
|
-
i ? s && !i.has(s) && (i.has(
|
|
1572
|
+
const t = `${e.function_name}::${q(e.arguments ?? {})}`, s = e.id || "", i = this.firedClientFunctions.get(t);
|
|
1573
|
+
let n = !1;
|
|
1574
|
+
i ? s && !i.has(s) && (i.has(ce) ? (i.delete(ce), i.add(s)) : (i.add(s), n = !0)) : (this.firedClientFunctions.set(t, /* @__PURE__ */ new Set([s])), n = !0), n && this.callbacks.onClientFunction?.({
|
|
1391
1575
|
invocationId: s,
|
|
1392
1576
|
functionName: e.function_name,
|
|
1393
1577
|
arguments: e.arguments || {},
|
|
@@ -1447,11 +1631,11 @@ var ie = "", _t = class {
|
|
|
1447
1631
|
return e.status !== "WAITING_CLIENT" && this.callbacks.onComplete?.(e), e;
|
|
1448
1632
|
}
|
|
1449
1633
|
};
|
|
1450
|
-
function
|
|
1634
|
+
function ns(e) {
|
|
1451
1635
|
const t = e.message.toLowerCase();
|
|
1452
1636
|
return t.includes("load failed") || t.includes("failed to fetch") || t.includes("network") || t.includes("abort");
|
|
1453
1637
|
}
|
|
1454
|
-
var
|
|
1638
|
+
var Lt = /* @__PURE__ */ new Set([
|
|
1455
1639
|
"image/jpeg",
|
|
1456
1640
|
"image/png",
|
|
1457
1641
|
"image/gif",
|
|
@@ -1459,7 +1643,7 @@ var St = /* @__PURE__ */ new Set([
|
|
|
1459
1643
|
"image/bmp",
|
|
1460
1644
|
"image/tiff"
|
|
1461
1645
|
]);
|
|
1462
|
-
function
|
|
1646
|
+
function jt(e) {
|
|
1463
1647
|
if (!e) return;
|
|
1464
1648
|
const t = typeof window < "u" && window.location ? window.location.href : "https://ago.local/";
|
|
1465
1649
|
try {
|
|
@@ -1468,16 +1652,16 @@ function Ct(e) {
|
|
|
1468
1652
|
} catch {
|
|
1469
1653
|
}
|
|
1470
1654
|
}
|
|
1471
|
-
function
|
|
1472
|
-
return e.isSafeImage === !0 && typeof e.contentType == "string" && e.contentType.startsWith("image/") &&
|
|
1655
|
+
function rs(e) {
|
|
1656
|
+
return e.isSafeImage === !0 && typeof e.contentType == "string" && e.contentType.startsWith("image/") && jt(e.url) !== void 0;
|
|
1473
1657
|
}
|
|
1474
|
-
function
|
|
1658
|
+
function os(e) {
|
|
1475
1659
|
if (e == null || e < 0) return "";
|
|
1476
1660
|
if (e < 1024) return `${e} B`;
|
|
1477
1661
|
const t = e / 1024;
|
|
1478
1662
|
return t < 1024 ? `${t.toFixed(1)} KB` : `${(t / 1024).toFixed(1)} MB`;
|
|
1479
1663
|
}
|
|
1480
|
-
function
|
|
1664
|
+
function Ut(e) {
|
|
1481
1665
|
return {
|
|
1482
1666
|
id: String(e.id ?? ""),
|
|
1483
1667
|
name: typeof e.name == "string" && e.name ? e.name : "file",
|
|
@@ -1487,17 +1671,17 @@ function bt(e) {
|
|
|
1487
1671
|
isSafeImage: e.is_safe_image === !0
|
|
1488
1672
|
};
|
|
1489
1673
|
}
|
|
1490
|
-
function
|
|
1674
|
+
function as(e) {
|
|
1491
1675
|
return e.map((t, s) => ({
|
|
1492
1676
|
id: `local-${s}-${t.name}`,
|
|
1493
1677
|
name: t.name,
|
|
1494
1678
|
contentType: t.type || void 0,
|
|
1495
1679
|
fileSize: t.size,
|
|
1496
1680
|
url: typeof URL < "u" && URL.createObjectURL ? URL.createObjectURL(t) : void 0,
|
|
1497
|
-
isSafeImage:
|
|
1681
|
+
isSafeImage: Lt.has(t.type)
|
|
1498
1682
|
}));
|
|
1499
1683
|
}
|
|
1500
|
-
var
|
|
1684
|
+
var Wt = class {
|
|
1501
1685
|
constructor() {
|
|
1502
1686
|
this.handlers = /* @__PURE__ */ new Map();
|
|
1503
1687
|
}
|
|
@@ -1513,8 +1697,8 @@ var At = class {
|
|
|
1513
1697
|
s && s.forEach((i) => {
|
|
1514
1698
|
try {
|
|
1515
1699
|
i(t);
|
|
1516
|
-
} catch (
|
|
1517
|
-
console.error(`Error in event handler for ${String(e)}:`,
|
|
1700
|
+
} catch (n) {
|
|
1701
|
+
console.error(`Error in event handler for ${String(e)}:`, n);
|
|
1518
1702
|
}
|
|
1519
1703
|
});
|
|
1520
1704
|
}
|
|
@@ -1526,135 +1710,236 @@ var At = class {
|
|
|
1526
1710
|
}
|
|
1527
1711
|
waitFor(e, t) {
|
|
1528
1712
|
return new Promise((s, i) => {
|
|
1529
|
-
let
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1713
|
+
let n;
|
|
1714
|
+
const r = ((o) => {
|
|
1715
|
+
n && clearTimeout(n), s(o);
|
|
1532
1716
|
});
|
|
1533
|
-
this.once(e,
|
|
1534
|
-
this.off(e,
|
|
1717
|
+
this.once(e, r), t?.timeout && (n = setTimeout(() => {
|
|
1718
|
+
this.off(e, r), i(/* @__PURE__ */ new Error(`waitFor("${String(e)}") timed out after ${t.timeout}ms`));
|
|
1535
1719
|
}, t.timeout));
|
|
1536
1720
|
});
|
|
1537
1721
|
}
|
|
1538
1722
|
removeAllListeners(e) {
|
|
1539
1723
|
e ? this.handlers.delete(e) : this.handlers.clear();
|
|
1540
1724
|
}
|
|
1541
|
-
},
|
|
1542
|
-
function
|
|
1543
|
-
if (typeof
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1725
|
+
}, Bt = 4e3, Gt = 150, qt = 600;
|
|
1726
|
+
function Kt() {
|
|
1727
|
+
if (!(typeof document > "u"))
|
|
1728
|
+
return document.modelContext;
|
|
1729
|
+
}
|
|
1730
|
+
function Jt(e, t) {
|
|
1731
|
+
return new Promise((s) => {
|
|
1732
|
+
let i, n = !1;
|
|
1733
|
+
const r = () => {
|
|
1734
|
+
if (!n) {
|
|
1735
|
+
n = !0, clearTimeout(i), clearTimeout(l), clearTimeout(a);
|
|
1736
|
+
for (const d of t) d?.removeEventListener("abort", r);
|
|
1737
|
+
u(), s();
|
|
1738
|
+
}
|
|
1739
|
+
}, o = () => {
|
|
1740
|
+
clearTimeout(l), clearTimeout(i), i = setTimeout(r, Gt);
|
|
1741
|
+
}, a = setTimeout(r, Bt), l = setTimeout(r, qt), u = e(o);
|
|
1742
|
+
for (const d of t) {
|
|
1743
|
+
if (d?.aborted) return r();
|
|
1744
|
+
d?.addEventListener("abort", r);
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1547
1747
|
}
|
|
1548
|
-
function
|
|
1549
|
-
|
|
1748
|
+
function Ht(e) {
|
|
1749
|
+
const t = Kt();
|
|
1750
|
+
if (!t)
|
|
1751
|
+
return c.log("WebMCP is not available in this browser; bridge not attached"), () => {
|
|
1752
|
+
};
|
|
1753
|
+
const s = t, i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = new AbortController();
|
|
1754
|
+
let o = !1, a = !1;
|
|
1755
|
+
function l(p) {
|
|
1756
|
+
return JSON.stringify([
|
|
1757
|
+
p.description,
|
|
1758
|
+
p.inputSchema,
|
|
1759
|
+
p.annotations
|
|
1760
|
+
]);
|
|
1761
|
+
}
|
|
1762
|
+
function u(p, h) {
|
|
1763
|
+
const g = e.getFunctionRegistrations().find((y) => y.name === p)?.webmcp;
|
|
1764
|
+
return !g || !g.navigates ? !1 : h?.success !== !1;
|
|
1765
|
+
}
|
|
1766
|
+
function d() {
|
|
1767
|
+
const p = /* @__PURE__ */ new Map();
|
|
1768
|
+
for (const h of e.getFunctionRegistrations()) {
|
|
1769
|
+
if (h.webmcp === !1) continue;
|
|
1770
|
+
const g = h.webmcp || void 0, y = h.name, b = {
|
|
1771
|
+
name: y,
|
|
1772
|
+
description: h.schema.description,
|
|
1773
|
+
inputSchema: h.schema.parameters,
|
|
1774
|
+
annotations: g?.annotations,
|
|
1775
|
+
execute: async (w, _e) => {
|
|
1776
|
+
const z = await e.runExternalFunction(y, w ?? {});
|
|
1777
|
+
return !o && u(y, z) && await Jt((Ce) => e.onFunctionsChanged(Ce), [_e?.signal, r.signal]), z;
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
p.set(y, {
|
|
1781
|
+
tool: b,
|
|
1782
|
+
signature: l(b)
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
return p;
|
|
1786
|
+
}
|
|
1787
|
+
function f() {
|
|
1788
|
+
o || a || (a = !0, queueMicrotask(() => {
|
|
1789
|
+
a = !1, m();
|
|
1790
|
+
}));
|
|
1791
|
+
}
|
|
1792
|
+
function m() {
|
|
1793
|
+
if (o) return;
|
|
1794
|
+
const p = d();
|
|
1795
|
+
for (const [h, g] of i)
|
|
1796
|
+
p.get(h)?.signature !== g.signature && (g.controller.abort(), i.delete(h));
|
|
1797
|
+
for (const [h, g] of p) {
|
|
1798
|
+
if (i.has(h)) continue;
|
|
1799
|
+
const y = new AbortController();
|
|
1800
|
+
i.set(h, {
|
|
1801
|
+
signature: g.signature,
|
|
1802
|
+
controller: y
|
|
1803
|
+
}), Promise.resolve(s.registerTool(g.tool, { signal: y.signal })).catch((b) => {
|
|
1804
|
+
if (c.error(`WebMCP rejected the tool "${h}":`, b), i.get(h)?.controller !== y) return;
|
|
1805
|
+
i.delete(h);
|
|
1806
|
+
const w = JSON.stringify([h, g.signature]);
|
|
1807
|
+
n.has(w) || (n.add(w), f());
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
const v = e.onFunctionsChanged(f);
|
|
1812
|
+
return m(), c.log("WebMCP bridge attached"), () => {
|
|
1813
|
+
if (!o) {
|
|
1814
|
+
o = !0, r.abort(), v();
|
|
1815
|
+
for (const p of i.values()) p.controller.abort();
|
|
1816
|
+
i.clear(), c.log("WebMCP bridge detached");
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1550
1819
|
}
|
|
1551
|
-
function
|
|
1552
|
-
|
|
1820
|
+
var zt = "/api/sdk/v1/client-function-calls", le = "ago_webmcp_tab";
|
|
1821
|
+
function Xt() {
|
|
1822
|
+
try {
|
|
1823
|
+
const e = sessionStorage.getItem(le);
|
|
1824
|
+
if (e) return e;
|
|
1825
|
+
const t = x();
|
|
1826
|
+
return sessionStorage.setItem(le, t), t;
|
|
1827
|
+
} catch {
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1553
1830
|
}
|
|
1554
|
-
function
|
|
1555
|
-
const s =
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1831
|
+
function Vt(e, t) {
|
|
1832
|
+
const { name: s } = t.schema, i = Xt(), n = {
|
|
1833
|
+
function_name: s,
|
|
1834
|
+
arguments: t.args,
|
|
1835
|
+
result: t.error === void 0 ? t.result ?? null : null,
|
|
1836
|
+
error: t.error ?? null,
|
|
1837
|
+
duration_ms: t.durationMs,
|
|
1838
|
+
...i ? { tab_id: i } : {},
|
|
1839
|
+
...e.declared.has(s) ? {} : { client_functions: [t.schema] }
|
|
1563
1840
|
};
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
const i = t.find((r) => {
|
|
1569
|
-
if (!r.path.includes(":")) return !1;
|
|
1570
|
-
const n = "^" + r.path.split("/").map((a) => a.startsWith(":") ? "[^/]+" : Rt(a)).join("/") + "/?$";
|
|
1571
|
-
return new RegExp(n).test(e);
|
|
1841
|
+
e.post(zt, n, t.navigates ? { keepalive: !0 } : void 0).then(() => {
|
|
1842
|
+
e.declared.add(s);
|
|
1843
|
+
}).catch((r) => {
|
|
1844
|
+
c.debug("External call report failed:", r);
|
|
1572
1845
|
});
|
|
1573
|
-
return i || t.filter((r) => r.path !== "/" && e.startsWith(r.path)).sort((r, n) => n.path.length - r.path.length)[0];
|
|
1574
1846
|
}
|
|
1575
|
-
var
|
|
1576
|
-
function
|
|
1847
|
+
var ue = '`baseUrl` is required, e.g. new AgoClient({ baseUrl: "https://YOUR-DOMAIN.api.useago.com" }). Try the public demo account https://playground.api.useago.com (agent generic-guide). See docs/general/configuration.md#error-codes (config_missing_base_url).', Yt = /^[a-z][a-z0-9+.-]*:\/\//i, de = !1;
|
|
1848
|
+
function he(e, t = "AgoClient") {
|
|
1849
|
+
if (typeof e != "object" || e === null) throw new S(`${t}: ${ue}`, "config_missing_base_url");
|
|
1850
|
+
const s = e.baseUrl;
|
|
1851
|
+
if (typeof s != "string" || s.trim() === "") throw new S(`${t}: ${ue}`, "config_missing_base_url");
|
|
1852
|
+
N(e.language), !s.startsWith("/") && !Yt.test(s) && (de || (de = !0, console.warn(`[AGO] ${t}: \`baseUrl\` has no protocol and is not a relative path (config_suspect_base_url). Requests will fail: Node throws a URL parse error, browsers fetch it as a relative path. Use "https://..." (or a "/path" for a same-origin proxy).`)));
|
|
1853
|
+
}
|
|
1854
|
+
var Qt = "activity:recent", Zt = "state:delta", ge = "errors:recent";
|
|
1855
|
+
function fe(e) {
|
|
1577
1856
|
return e === "setPageState" ? "readPageData" : `read${e.charAt(0).toUpperCase()}${e.slice(1)}Data`;
|
|
1578
1857
|
}
|
|
1579
|
-
var
|
|
1858
|
+
var cs = class R {
|
|
1580
1859
|
constructor(t) {
|
|
1581
|
-
this.errorWatcher = null, this.lastSentPageState = null, this.warnedEmptyConversations = /* @__PURE__ */ new Set(), this.warnedPageDataPlaceholder = !1, this.pageDataCompanions = /* @__PURE__ */ new Set(), this.pendingResumes = /* @__PURE__ */ new Map(), this.pendingApprovals = /* @__PURE__ */ new Map(), this.resumeGate = null, this.activeTurn = null, this.pausedTurn = null, this.stoppedTurnIds = /* @__PURE__ */ new Set(), this.proactive = null,
|
|
1860
|
+
this.errorWatcher = null, this.lastSentPageState = null, this.warnedEmptyConversations = /* @__PURE__ */ new Set(), this.declaredExternally = /* @__PURE__ */ new Set(), this.warnedPageDataPlaceholder = !1, this.pageDataCompanions = /* @__PURE__ */ new Set(), this.pendingResumes = /* @__PURE__ */ new Map(), this.pendingApprovals = /* @__PURE__ */ new Map(), this.resumeGate = null, this.activeTurn = null, this.pausedTurn = null, this.stoppedTurnIds = /* @__PURE__ */ new Set(), this.proactive = null, this.detachWebMCP = null, this.listPagesRegistered = !1, he(t, "AgoClient"), this.config = t, this.activityLedger = new ke(t.maxActivityEntries), this.httpClient = new Ie(t), this.functionRegistry = new Le({ maxResultBytes: t.maxFunctionResultBytes }), this.contextRegistry = new xt(), this.eventEmitter = new Wt(), this.registerActivityContext(), this.functionRegistry.onChange(() => {
|
|
1861
|
+
this.eventEmitter.emit("functions:changed", this.functionRegistry.getSchemas());
|
|
1862
|
+
}), t.debug && c.enable(), t.errorWatcher && this.enableErrorWatcher(t.errorWatcher === !0 ? void 0 : t.errorWatcher), t.proactive && ae(this, t.proactive), this.attachWebMCPBridge(), c.log("AgoClient initialized");
|
|
1863
|
+
}
|
|
1864
|
+
attachWebMCPBridge() {
|
|
1865
|
+
!this.config.webmcp || this.detachWebMCP || (this.detachWebMCP = Ht(this));
|
|
1582
1866
|
}
|
|
1583
1867
|
async sendMessage(t, s) {
|
|
1584
|
-
|
|
1868
|
+
if (typeof t != "string" || !t.trim()) throw new S("Add message text before sending, including when attaching files. See docs/general/core.md#file-attachments.", "message_empty_content");
|
|
1869
|
+
const i = this.functionRegistry.getSchemas(), n = this.buildSendContext(), r = this.config.agent || this.config.defaultAgentId, o = this.resolveClientFunctionsMode(s), a = s?.metadata !== void 0 ? s.metadata : this.config.metadata, l = a != null ? JSON.stringify(a) : void 0, u = {
|
|
1585
1870
|
content: t,
|
|
1586
1871
|
conversation_id: s?.conversationId,
|
|
1587
|
-
agent_id: s?.agentId ||
|
|
1872
|
+
agent_id: s?.agentId || r
|
|
1588
1873
|
};
|
|
1589
|
-
|
|
1590
|
-
const
|
|
1591
|
-
let
|
|
1874
|
+
a != null && (u.metadata = a), i.length > 0 && (u.client_functions = i, o === "pause" && (u.client_functions_mode = o)), n && (u.client_context = n), s?.hidden && (u.hidden = !0);
|
|
1875
|
+
const d = this.beginTurn();
|
|
1876
|
+
let f;
|
|
1592
1877
|
if (s?.files && s.files.length > 0) {
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1595
|
-
for (const
|
|
1596
|
-
|
|
1597
|
-
} else
|
|
1598
|
-
return
|
|
1878
|
+
const m = new FormData();
|
|
1879
|
+
m.append("content", t), l !== void 0 && m.append("metadata", l), s.conversationId && m.append("conversation_id", s.conversationId), (s.agentId || r) && m.append("agent_id", s.agentId || r || ""), i.length > 0 && (m.append("client_functions", JSON.stringify(i)), o === "pause" && m.append("client_functions_mode", o)), n && m.append("client_context", JSON.stringify(n)), s.hidden && m.append("hidden", "true");
|
|
1880
|
+
for (const v of s.files) m.append("files", v);
|
|
1881
|
+
f = await this.sendRequest(d, () => this.httpClient.postFormData("/api/sdk/v1/messages", m, { signal: d.controller.signal }));
|
|
1882
|
+
} else f = await this.sendRequest(d, () => this.httpClient.postStream("/api/sdk/v1/messages", u, { signal: d.controller.signal }));
|
|
1883
|
+
return f ? this.processSSEResponse(f, d) : this.buildStoppedMessage(d);
|
|
1599
1884
|
}
|
|
1600
1885
|
async sendRequest(t, s) {
|
|
1601
1886
|
try {
|
|
1602
1887
|
return await s();
|
|
1603
1888
|
} catch (i) {
|
|
1604
|
-
if (this.endTurn(t),
|
|
1889
|
+
if (this.endTurn(t), O(i)) return null;
|
|
1605
1890
|
throw i;
|
|
1606
1891
|
}
|
|
1607
1892
|
}
|
|
1608
1893
|
async processSSEResponse(t, s) {
|
|
1609
1894
|
let i = !1;
|
|
1610
|
-
const
|
|
1611
|
-
onRawChunk: (
|
|
1612
|
-
s && (
|
|
1895
|
+
const n = new Ot({
|
|
1896
|
+
onRawChunk: (r) => {
|
|
1897
|
+
s && (r.message_id && !s.messageId && (s.messageId = r.message_id), r.thread?.id && (s.conversationId = r.thread.id)), this.eventEmitter.emit("stream:message", r);
|
|
1613
1898
|
},
|
|
1614
|
-
onStart: (
|
|
1615
|
-
this.eventEmitter.emit("message:start",
|
|
1899
|
+
onStart: (r) => {
|
|
1900
|
+
this.eventEmitter.emit("message:start", r);
|
|
1616
1901
|
},
|
|
1617
|
-
onChunk: (
|
|
1618
|
-
this.eventEmitter.emit("message:chunk",
|
|
1902
|
+
onChunk: (r) => {
|
|
1903
|
+
this.eventEmitter.emit("message:chunk", r);
|
|
1619
1904
|
},
|
|
1620
|
-
onToolCall: (
|
|
1621
|
-
this.eventEmitter.emit("toolCall:received",
|
|
1905
|
+
onToolCall: (r) => {
|
|
1906
|
+
this.eventEmitter.emit("toolCall:received", r), r.type === "form" && this.eventEmitter.emit("toolCall:form", r);
|
|
1622
1907
|
},
|
|
1623
|
-
onClientFunction: async (
|
|
1624
|
-
if (i = !0, this.eventEmitter.emit("function:invoke",
|
|
1625
|
-
this.pendingApprovals.set(
|
|
1908
|
+
onClientFunction: async (r) => {
|
|
1909
|
+
if (i = !0, this.eventEmitter.emit("function:invoke", r), this.recordAgentAction(r), r.invocationId && this.requiresApproval(r)) {
|
|
1910
|
+
this.pendingApprovals.set(r.invocationId, r), this.eventEmitter.emit("function:awaiting-approval", r);
|
|
1626
1911
|
return;
|
|
1627
1912
|
}
|
|
1628
|
-
await this.handleClientFunctionInvocation(
|
|
1913
|
+
await this.handleClientFunctionInvocation(r);
|
|
1629
1914
|
},
|
|
1630
|
-
onTitle: (
|
|
1631
|
-
this.eventEmitter.emit("conversation:title",
|
|
1915
|
+
onTitle: (r) => {
|
|
1916
|
+
this.eventEmitter.emit("conversation:title", r);
|
|
1632
1917
|
},
|
|
1633
|
-
onAnswerComplete: (
|
|
1634
|
-
this.eventEmitter.emit("message:answer-complete",
|
|
1918
|
+
onAnswerComplete: (r) => {
|
|
1919
|
+
this.eventEmitter.emit("message:answer-complete", r);
|
|
1635
1920
|
},
|
|
1636
|
-
onWaitingClient: (
|
|
1921
|
+
onWaitingClient: (r) => {
|
|
1637
1922
|
this.pausedTurn = {
|
|
1638
|
-
messageId:
|
|
1639
|
-
conversationId:
|
|
1640
|
-
}, this.eventEmitter.emit("message:waiting-client",
|
|
1923
|
+
messageId: r.messageId,
|
|
1924
|
+
conversationId: r.conversationId
|
|
1925
|
+
}, this.eventEmitter.emit("message:waiting-client", r), this.markResumeSignal(r.messageId, r.conversationId, "waitingConfirmed");
|
|
1641
1926
|
},
|
|
1642
|
-
onComplete: (
|
|
1643
|
-
s?.stopRequested && !
|
|
1927
|
+
onComplete: (r) => {
|
|
1928
|
+
s?.stopRequested && !r.id || this.eventEmitter.emit("message:complete", r);
|
|
1644
1929
|
},
|
|
1645
|
-
onError: (
|
|
1930
|
+
onError: (r) => {
|
|
1646
1931
|
this.eventEmitter.emit("message:error", {
|
|
1647
|
-
error:
|
|
1648
|
-
code:
|
|
1932
|
+
error: r.message,
|
|
1933
|
+
code: r instanceof S ? r.code : void 0
|
|
1649
1934
|
});
|
|
1650
1935
|
}
|
|
1651
1936
|
}, { signal: s?.controller.signal });
|
|
1652
1937
|
try {
|
|
1653
|
-
const
|
|
1654
|
-
return s?.stopRequested && (this.postStopForTurn(s, s.messageId ??
|
|
1655
|
-
conversationId: s.conversationId ??
|
|
1656
|
-
messageId: s.messageId ??
|
|
1657
|
-
})),
|
|
1938
|
+
const r = await n.processStream(t);
|
|
1939
|
+
return s?.stopRequested && (this.postStopForTurn(s, s.messageId ?? r.id), this.eventEmitter.emit("message:stopped", {
|
|
1940
|
+
conversationId: s.conversationId ?? r.conversationId ?? "",
|
|
1941
|
+
messageId: s.messageId ?? r.id ?? ""
|
|
1942
|
+
})), r.status !== "WAITING_CLIENT" && this.maybeFlagEmptyReply(r, i), r;
|
|
1658
1943
|
} finally {
|
|
1659
1944
|
s && this.endTurn(s);
|
|
1660
1945
|
}
|
|
@@ -1663,8 +1948,8 @@ var Lt = class A {
|
|
|
1663
1948
|
const t = this.activeTurn;
|
|
1664
1949
|
if (t) {
|
|
1665
1950
|
t.stopRequested = !0;
|
|
1666
|
-
const
|
|
1667
|
-
return t.controller.abort(),
|
|
1951
|
+
const n = t.messageId;
|
|
1952
|
+
return t.controller.abort(), n ? this.postStopForTurn(t, n) : null;
|
|
1668
1953
|
}
|
|
1669
1954
|
const s = this.pausedTurn;
|
|
1670
1955
|
if (!s) return null;
|
|
@@ -1672,8 +1957,8 @@ var Lt = class A {
|
|
|
1672
1957
|
let i = null;
|
|
1673
1958
|
try {
|
|
1674
1959
|
i = await this.stopMessage(s.messageId);
|
|
1675
|
-
} catch (
|
|
1676
|
-
|
|
1960
|
+
} catch (n) {
|
|
1961
|
+
c.warn("Failed to stop the paused turn:", n);
|
|
1677
1962
|
}
|
|
1678
1963
|
return this.eventEmitter.emit("message:stopped", {
|
|
1679
1964
|
conversationId: s.conversationId,
|
|
@@ -1710,7 +1995,7 @@ var Lt = class A {
|
|
|
1710
1995
|
try {
|
|
1711
1996
|
return await this.stopMessage(s);
|
|
1712
1997
|
} catch (i) {
|
|
1713
|
-
return
|
|
1998
|
+
return c.warn("Failed to stop the turn server-side:", i), null;
|
|
1714
1999
|
}
|
|
1715
2000
|
}
|
|
1716
2001
|
buildStoppedMessage(t) {
|
|
@@ -1736,22 +2021,22 @@ var Lt = class A {
|
|
|
1736
2021
|
};
|
|
1737
2022
|
}
|
|
1738
2023
|
async continueMessage(t) {
|
|
1739
|
-
const s = this.functionRegistry.getSchemas(), i = this.buildSendContext(),
|
|
1740
|
-
s.length > 0 && (
|
|
1741
|
-
const
|
|
1742
|
-
|
|
1743
|
-
const
|
|
1744
|
-
return
|
|
2024
|
+
const s = this.functionRegistry.getSchemas(), i = this.buildSendContext(), n = {};
|
|
2025
|
+
s.length > 0 && (n.client_functions = s), i && (n.client_context = i);
|
|
2026
|
+
const r = this.beginTurn();
|
|
2027
|
+
r.messageId = t;
|
|
2028
|
+
const o = await this.sendRequest(r, () => this.httpClient.postStream(`/api/sdk/v1/messages/${t}/continue`, n, { signal: r.controller.signal }));
|
|
2029
|
+
return o ? this.processSSEResponse(o, r) : this.buildStoppedMessage(r);
|
|
1745
2030
|
}
|
|
1746
2031
|
markResumeSignal(t, s, i) {
|
|
1747
2032
|
if (!t) return;
|
|
1748
|
-
const
|
|
2033
|
+
const n = this.pendingResumes.get(t) ?? {
|
|
1749
2034
|
conversationId: s,
|
|
1750
2035
|
waitingConfirmed: !1,
|
|
1751
2036
|
resultsReady: !1,
|
|
1752
2037
|
started: !1
|
|
1753
2038
|
};
|
|
1754
|
-
|
|
2039
|
+
n[i] = !0, s && (n.conversationId = s), this.pendingResumes.set(t, n), !(!n.waitingConfirmed || !n.resultsReady || n.started) && (n.started = !0, this.runAutoResume(t, n.conversationId));
|
|
1755
2040
|
}
|
|
1756
2041
|
async runAutoResume(t, s) {
|
|
1757
2042
|
try {
|
|
@@ -1760,13 +2045,13 @@ var Lt = class A {
|
|
|
1760
2045
|
messageId: t
|
|
1761
2046
|
});
|
|
1762
2047
|
} catch (i) {
|
|
1763
|
-
|
|
2048
|
+
c.warn("Resume gate threw; resuming anyway:", i);
|
|
1764
2049
|
}
|
|
1765
2050
|
if (this.pendingResumes.delete(t), !this.stoppedTurnIds.delete(t))
|
|
1766
2051
|
try {
|
|
1767
2052
|
await this.continueMessage(t);
|
|
1768
2053
|
} catch (i) {
|
|
1769
|
-
|
|
2054
|
+
c.warn("Auto-resume of paused turn failed:", i);
|
|
1770
2055
|
}
|
|
1771
2056
|
}
|
|
1772
2057
|
maybeFlagEmptyReply(t, s) {
|
|
@@ -1778,26 +2063,26 @@ var Lt = class A {
|
|
|
1778
2063
|
const i = t.conversationId || "(no conversation)";
|
|
1779
2064
|
if (this.warnedEmptyConversations.has(i)) return;
|
|
1780
2065
|
this.warnedEmptyConversations.add(i);
|
|
1781
|
-
const
|
|
1782
|
-
t.id ? console.warn("[AGO] Reply completed with empty content. Possible causes: " + (
|
|
2066
|
+
const n = this.config.agent || this.config.defaultAgentId;
|
|
2067
|
+
t.id ? console.warn("[AGO] Reply completed with empty content. Possible causes: " + (n ? `the agent "${n}" may not exist for this tenant, ` : "an unknown `agent` slug, ") + "or the agent replied with no text. Listen for the `message:empty` event to handle this in your app; silence this warning with `warnOnEmptyReply: false`.") : console.warn("[AGO] The stream completed without any message data. Possible causes: " + (n ? `the agent "${n}" may not exist for this tenant, or ` : "") + "`baseUrl` does not point at an AGO endpoint that returns server-sent events. Listen for the `message:empty` event to handle this in your app; silence this warning with `warnOnEmptyReply: false`.");
|
|
1783
2068
|
}, 0);
|
|
1784
2069
|
}
|
|
1785
2070
|
async handleClientFunctionInvocation(t) {
|
|
1786
2071
|
let s, i;
|
|
1787
2072
|
try {
|
|
1788
2073
|
s = await this.functionRegistry.execute(t.functionName, t.arguments);
|
|
1789
|
-
} catch (
|
|
1790
|
-
i =
|
|
2074
|
+
} catch (n) {
|
|
2075
|
+
i = n instanceof Error ? n.message : "Unknown error", c.error("Client function execution failed:", n);
|
|
1791
2076
|
}
|
|
1792
2077
|
if (t.invocationId) try {
|
|
1793
|
-
const
|
|
2078
|
+
const n = await this.submitToolCallForm(t.invocationId, {
|
|
1794
2079
|
result: s,
|
|
1795
2080
|
error: i,
|
|
1796
2081
|
_type: "client_function_result"
|
|
1797
2082
|
});
|
|
1798
|
-
|
|
1799
|
-
} catch (
|
|
1800
|
-
|
|
2083
|
+
n?.resume?.ready && this.markResumeSignal(n.resume.message_id, t.conversationId, "resultsReady");
|
|
2084
|
+
} catch (n) {
|
|
2085
|
+
c.error("Failed to submit function result:", n);
|
|
1801
2086
|
}
|
|
1802
2087
|
this.eventEmitter.emit("function:result", {
|
|
1803
2088
|
invocationId: t.invocationId,
|
|
@@ -1810,7 +2095,7 @@ var Lt = class A {
|
|
|
1810
2095
|
if (s) try {
|
|
1811
2096
|
if (s(t)) return !0;
|
|
1812
2097
|
} catch (i) {
|
|
1813
|
-
|
|
2098
|
+
c.warn("approvalPolicy threw; not gating this call:", i);
|
|
1814
2099
|
}
|
|
1815
2100
|
return this.functionRegistry.get(t.functionName)?.requiresApproval === !0;
|
|
1816
2101
|
}
|
|
@@ -1827,31 +2112,68 @@ var Lt = class A {
|
|
|
1827
2112
|
reason: "user_rejected"
|
|
1828
2113
|
};
|
|
1829
2114
|
try {
|
|
1830
|
-
const
|
|
2115
|
+
const n = await this.submitToolCallForm(t, {
|
|
1831
2116
|
result: i,
|
|
1832
2117
|
_type: "client_function_result"
|
|
1833
2118
|
});
|
|
1834
|
-
|
|
1835
|
-
} catch (
|
|
1836
|
-
|
|
2119
|
+
n?.resume?.ready && this.markResumeSignal(n.resume.message_id, s.conversationId, "resultsReady");
|
|
2120
|
+
} catch (n) {
|
|
2121
|
+
c.error("Failed to submit function rejection:", n);
|
|
1837
2122
|
}
|
|
1838
2123
|
this.eventEmitter.emit("function:result", {
|
|
1839
2124
|
invocationId: t,
|
|
1840
2125
|
result: i
|
|
1841
2126
|
});
|
|
1842
2127
|
}
|
|
2128
|
+
async runExternalFunction(t, s) {
|
|
2129
|
+
const i = {
|
|
2130
|
+
invocationId: `webmcp-${x()}`,
|
|
2131
|
+
functionName: t,
|
|
2132
|
+
arguments: s,
|
|
2133
|
+
conversationId: ""
|
|
2134
|
+
}, { invocationId: n } = i;
|
|
2135
|
+
this.eventEmitter.emit("function:invoke", i);
|
|
2136
|
+
const r = Date.now();
|
|
2137
|
+
try {
|
|
2138
|
+
const o = await this.functionRegistry.execute(t, s);
|
|
2139
|
+
return this.eventEmitter.emit("function:result", {
|
|
2140
|
+
invocationId: n,
|
|
2141
|
+
result: o
|
|
2142
|
+
}), this.reportExternalCall(t, s, r, { result: o }), o;
|
|
2143
|
+
} catch (o) {
|
|
2144
|
+
const a = o instanceof Error ? o.message : String(o);
|
|
2145
|
+
throw this.eventEmitter.emit("function:result", {
|
|
2146
|
+
invocationId: n,
|
|
2147
|
+
result: null,
|
|
2148
|
+
error: a
|
|
2149
|
+
}), this.reportExternalCall(t, s, r, { error: a }), o;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
reportExternalCall(t, s, i, n) {
|
|
2153
|
+
const r = this.functionRegistry.get(t);
|
|
2154
|
+
r && Vt({
|
|
2155
|
+
post: (o, a, l) => this.httpClient.post(o, a, l),
|
|
2156
|
+
declared: this.declaredExternally
|
|
2157
|
+
}, {
|
|
2158
|
+
schema: r.schema,
|
|
2159
|
+
args: s,
|
|
2160
|
+
durationMs: Date.now() - i,
|
|
2161
|
+
navigates: r.webmcp ? r.webmcp.navigates : void 0,
|
|
2162
|
+
...n
|
|
2163
|
+
});
|
|
2164
|
+
}
|
|
1843
2165
|
async getConversations(t) {
|
|
1844
2166
|
const s = new URLSearchParams();
|
|
1845
2167
|
t?.page !== void 0 && s.set("page", String(t.page)), t?.pageSize !== void 0 && s.set("page_size", String(t.pageSize));
|
|
1846
|
-
const i = s.toString(),
|
|
1847
|
-
id: String(
|
|
1848
|
-
title:
|
|
1849
|
-
lastMessageDate: new Date(
|
|
2168
|
+
const i = s.toString(), n = await this.httpClient.get(`/api/sdk/v1/conversations${i ? `?${i}` : ""}`), r = (Array.isArray(n.data) ? n.data : []).map((o) => ({
|
|
2169
|
+
id: String(o.id),
|
|
2170
|
+
title: o.title ?? "",
|
|
2171
|
+
lastMessageDate: new Date(o.last_message_at ?? o.created_at ?? 0)
|
|
1850
2172
|
}));
|
|
1851
2173
|
return {
|
|
1852
|
-
data:
|
|
1853
|
-
hasMore:
|
|
1854
|
-
total:
|
|
2174
|
+
data: r,
|
|
2175
|
+
hasMore: n.has_more ?? !1,
|
|
2176
|
+
total: n.total ?? r.length
|
|
1855
2177
|
};
|
|
1856
2178
|
}
|
|
1857
2179
|
async getConversation(t) {
|
|
@@ -1859,17 +2181,22 @@ var Lt = class A {
|
|
|
1859
2181
|
id: s.id,
|
|
1860
2182
|
title: s.title,
|
|
1861
2183
|
lastMessageDate: new Date(s.last_message_at ?? s.created_at ?? 0),
|
|
1862
|
-
messages: s.messages.map((
|
|
1863
|
-
id:
|
|
2184
|
+
messages: s.messages.map((n) => ({
|
|
2185
|
+
id: n.id,
|
|
1864
2186
|
conversationId: s.id,
|
|
1865
|
-
content:
|
|
1866
|
-
role:
|
|
1867
|
-
status:
|
|
1868
|
-
createdAt: new Date(
|
|
1869
|
-
hidden:
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
2187
|
+
content: n.content,
|
|
2188
|
+
role: n.role,
|
|
2189
|
+
status: n.status,
|
|
2190
|
+
createdAt: new Date(n.created_at),
|
|
2191
|
+
hidden: n.hidden,
|
|
2192
|
+
sources: n.sources && n.sources.length > 0 ? n.sources.map(({ id: r, title: o, url: a }) => ({
|
|
2193
|
+
id: r,
|
|
2194
|
+
title: o,
|
|
2195
|
+
url: a ?? void 0
|
|
2196
|
+
})) : void 0,
|
|
2197
|
+
toolCalls: R.mapPersistedToolCalls(n.tool_call_data),
|
|
2198
|
+
attachments: n.attachments && n.attachments.length > 0 ? n.attachments.map(Ut) : void 0,
|
|
2199
|
+
followUpReplies: n.follow_up_replies && n.follow_up_replies.length > 0 ? n.follow_up_replies : void 0
|
|
1873
2200
|
}))
|
|
1874
2201
|
};
|
|
1875
2202
|
return this.eventEmitter.emit("conversation:loaded", i), i;
|
|
@@ -1897,6 +2224,10 @@ var Lt = class A {
|
|
|
1897
2224
|
embedDescription: s.embed_description
|
|
1898
2225
|
}));
|
|
1899
2226
|
}
|
|
2227
|
+
async transcribeAudio(t, s) {
|
|
2228
|
+
const i = new FormData();
|
|
2229
|
+
return i.append("file", t, t.name), (await this.httpClient.postFormData("/api/sdk/v1/audio/transcriptions", i, s)).json();
|
|
2230
|
+
}
|
|
1900
2231
|
async getConfig() {
|
|
1901
2232
|
const t = await this.httpClient.get("/api/sdk/v1/config");
|
|
1902
2233
|
return {
|
|
@@ -1908,10 +2239,11 @@ var Lt = class A {
|
|
|
1908
2239
|
id: i.id,
|
|
1909
2240
|
name: i.name ?? void 0
|
|
1910
2241
|
})),
|
|
1911
|
-
ticketForm: s.ticket_form ?
|
|
1912
|
-
homePage: s.home_page ?
|
|
2242
|
+
ticketForm: s.ticket_form ? R.mapTicketForm(s.ticket_form) : void 0,
|
|
2243
|
+
homePage: s.home_page ? R.mapHomePage(s.home_page) : void 0,
|
|
1913
2244
|
fileAttachmentsEnabled: !!s.file_attachments_enabled,
|
|
1914
|
-
voiceEnabled: !!s.voice_enabled
|
|
2245
|
+
voiceEnabled: !!s.voice_enabled,
|
|
2246
|
+
speechToTextEnabled: !!s.speech_to_text_enabled
|
|
1915
2247
|
})),
|
|
1916
2248
|
proactive: { enabled: !!t.proactive?.enabled }
|
|
1917
2249
|
};
|
|
@@ -1922,11 +2254,11 @@ var Lt = class A {
|
|
|
1922
2254
|
title: t.title ?? void 0,
|
|
1923
2255
|
subtitle: t.subtitle ?? void 0,
|
|
1924
2256
|
starters: (t.home_starters ?? []).flatMap((i) => {
|
|
1925
|
-
const
|
|
1926
|
-
return !
|
|
2257
|
+
const n = i.description || i.title || "", r = i.initial_message || n;
|
|
2258
|
+
return !n || !r ? [] : [{
|
|
1927
2259
|
id: i.id,
|
|
1928
|
-
label:
|
|
1929
|
-
message:
|
|
2260
|
+
label: n,
|
|
2261
|
+
message: r,
|
|
1930
2262
|
agentId: i.agent_id ?? void 0
|
|
1931
2263
|
}];
|
|
1932
2264
|
}),
|
|
@@ -1982,7 +2314,7 @@ var Lt = class A {
|
|
|
1982
2314
|
async createTicket(t) {
|
|
1983
2315
|
const s = new FormData();
|
|
1984
2316
|
s.append("subject", t.subject), s.append("body", t.body), t.priority && s.append("priority", t.priority), t.typology && s.append("typology", t.typology), t.conversationId && s.append("conversation_id", t.conversationId), t.email && s.append("email", t.email), t.customFields && t.customFields.length > 0 && s.append("custom_fields", JSON.stringify(t.customFields));
|
|
1985
|
-
for (const
|
|
2317
|
+
for (const n of t.files ?? []) s.append("files", n, n.name);
|
|
1986
2318
|
t.ticketFormId && s.append("ticket_form_id", t.ticketFormId);
|
|
1987
2319
|
const i = await (await this.httpClient.postFormData("/api/sdk/v1/tickets", s)).json();
|
|
1988
2320
|
return {
|
|
@@ -1994,41 +2326,41 @@ var Lt = class A {
|
|
|
1994
2326
|
return (await this.getConversation(t)).messages || [];
|
|
1995
2327
|
}
|
|
1996
2328
|
async resumePendingClientFunctions(t) {
|
|
1997
|
-
const s = [...t.messages ?? []].reverse().find((
|
|
2329
|
+
const s = [...t.messages ?? []].reverse().find((a) => a.role === "assistant" && a.status === "WAITING_CLIENT");
|
|
1998
2330
|
if (!s) return null;
|
|
1999
|
-
const i = (s.toolCalls ?? []).filter((
|
|
2000
|
-
if (
|
|
2001
|
-
return
|
|
2002
|
-
let
|
|
2003
|
-
for (const
|
|
2004
|
-
const
|
|
2005
|
-
invocationId:
|
|
2006
|
-
functionName:
|
|
2007
|
-
arguments:
|
|
2331
|
+
const i = (s.toolCalls ?? []).filter((a) => a.type === "client_function" && a.status === "waiting_input" && a.functionName), n = new Set(this.functionRegistry.getSchemas().map((a) => a.name)), r = i.filter((a) => !n.has(a.functionName));
|
|
2332
|
+
if (r.length > 0)
|
|
2333
|
+
return c.warn("Cannot resume paused turn: function(s) not registered on this page:", r.map((a) => a.functionName)), null;
|
|
2334
|
+
let o = i.length === 0;
|
|
2335
|
+
for (const a of i) {
|
|
2336
|
+
const l = {
|
|
2337
|
+
invocationId: a.id,
|
|
2338
|
+
functionName: a.functionName,
|
|
2339
|
+
arguments: a.arguments ?? {},
|
|
2008
2340
|
conversationId: t.id
|
|
2009
2341
|
};
|
|
2010
|
-
if (this.requiresApproval(
|
|
2011
|
-
this.pendingApprovals.set(
|
|
2342
|
+
if (this.requiresApproval(l)) {
|
|
2343
|
+
this.pendingApprovals.set(a.id, l), this.markResumeSignal(s.id, t.id, "waitingConfirmed"), this.eventEmitter.emit("function:awaiting-approval", l), o = !1;
|
|
2012
2344
|
continue;
|
|
2013
2345
|
}
|
|
2014
|
-
this.eventEmitter.emit("function:invoke",
|
|
2015
|
-
let
|
|
2346
|
+
this.eventEmitter.emit("function:invoke", l);
|
|
2347
|
+
let u, d;
|
|
2016
2348
|
try {
|
|
2017
|
-
|
|
2018
|
-
} catch (
|
|
2019
|
-
|
|
2349
|
+
u = await this.functionRegistry.execute(a.functionName, a.arguments ?? {});
|
|
2350
|
+
} catch (f) {
|
|
2351
|
+
d = f instanceof Error ? f.message : "Unknown error", c.error("Client function execution failed:", f);
|
|
2020
2352
|
}
|
|
2021
2353
|
this.eventEmitter.emit("function:result", {
|
|
2022
|
-
invocationId:
|
|
2023
|
-
result:
|
|
2024
|
-
error:
|
|
2025
|
-
}),
|
|
2026
|
-
result:
|
|
2027
|
-
error:
|
|
2354
|
+
invocationId: a.id,
|
|
2355
|
+
result: u,
|
|
2356
|
+
error: d
|
|
2357
|
+
}), o = (await this.submitToolCallForm(a.id, {
|
|
2358
|
+
result: u,
|
|
2359
|
+
error: d,
|
|
2028
2360
|
_type: "client_function_result"
|
|
2029
|
-
}))?.resume?.ready ??
|
|
2361
|
+
}))?.resume?.ready ?? o;
|
|
2030
2362
|
}
|
|
2031
|
-
return
|
|
2363
|
+
return o ? this.continueMessage(s.id) : null;
|
|
2032
2364
|
}
|
|
2033
2365
|
async submitToolCallForm(t, s) {
|
|
2034
2366
|
return this.httpClient.post(`/api/sdk/v1/tool-calls/${t}/submit`, { formData: s });
|
|
@@ -2055,21 +2387,21 @@ var Lt = class A {
|
|
|
2055
2387
|
});
|
|
2056
2388
|
}
|
|
2057
2389
|
async submitFeedback(t, s, i) {
|
|
2058
|
-
const
|
|
2390
|
+
const n = i?.comment?.trim(), r = i?.reasons?.length ? [...new Set(i.reasons)] : [];
|
|
2059
2391
|
await this.httpClient.post(`/api/sdk/v1/messages/${t}/feedback`, {
|
|
2060
2392
|
rating: s,
|
|
2061
|
-
...
|
|
2062
|
-
...
|
|
2393
|
+
...r.length ? { reasons: r } : {},
|
|
2394
|
+
...n ? { comment: n } : {}
|
|
2063
2395
|
});
|
|
2064
2396
|
}
|
|
2065
2397
|
async submitConversationFeedback(t, s, i) {
|
|
2066
|
-
let
|
|
2067
|
-
if (!
|
|
2068
|
-
const
|
|
2069
|
-
if (!
|
|
2070
|
-
|
|
2398
|
+
let n = i?.lastMessageId;
|
|
2399
|
+
if (!n) {
|
|
2400
|
+
const r = [...(await this.getConversation(t)).messages ?? []].reverse().find((o) => o.role === "assistant" && !o.hidden && !!o.content && o.status !== "IN_PROGRESS" && o.status !== "WAITING_CLIENT");
|
|
2401
|
+
if (!r) throw new S(`Conversation ${t} has no finished answer to report feedback on. Wait for the turn to complete, or pass \`lastMessageId\`.`, "feedback_no_message");
|
|
2402
|
+
n = r.id;
|
|
2071
2403
|
}
|
|
2072
|
-
return await this.submitFeedback(
|
|
2404
|
+
return await this.submitFeedback(n, s, i), n;
|
|
2073
2405
|
}
|
|
2074
2406
|
registerFunction(t, s, i) {
|
|
2075
2407
|
typeof t == "object" ? this.functionRegistry.register(t) : this.functionRegistry.register(t, s, i);
|
|
@@ -2084,133 +2416,84 @@ var Lt = class A {
|
|
|
2084
2416
|
getRegisteredFunctions() {
|
|
2085
2417
|
return this.functionRegistry.getSchemas();
|
|
2086
2418
|
}
|
|
2419
|
+
onFunctionsChanged(t) {
|
|
2420
|
+
return this.functionRegistry.onChange(t);
|
|
2421
|
+
}
|
|
2422
|
+
getFunctionRegistrations() {
|
|
2423
|
+
return this.functionRegistry.getAll();
|
|
2424
|
+
}
|
|
2087
2425
|
async executeClientFunction(t, s) {
|
|
2088
2426
|
return this.functionRegistry.execute(t, s);
|
|
2089
2427
|
}
|
|
2090
|
-
registerNavigationFunction(t, s) {
|
|
2091
|
-
|
|
2092
|
-
const c = F(o.path), d = c.length > 0 ? ` (requires ${c.map((u) => `"${u}"`).join(", ")})` : "";
|
|
2093
|
-
return `- "${o.name}"${d}: ${o.description}`;
|
|
2094
|
-
}).join(`
|
|
2095
|
-
`), n = /* @__PURE__ */ new Map();
|
|
2096
|
-
for (const o of s) for (const c of F(o.path)) n.set(c, [...n.get(c) ?? [], o.name]);
|
|
2097
|
-
const a = { page: {
|
|
2098
|
-
type: "string",
|
|
2099
|
-
description: "The page to navigate to",
|
|
2100
|
-
enum: i
|
|
2101
|
-
} };
|
|
2102
|
-
for (const [o, c] of n) {
|
|
2103
|
-
if (o === "page") {
|
|
2104
|
-
l.error('registerNavigationFunction: a ":page" placeholder collides with the "page" argument and is ignored. Rename the placeholder.');
|
|
2105
|
-
continue;
|
|
2106
|
-
}
|
|
2107
|
-
a[o] = {
|
|
2108
|
-
type: "string",
|
|
2109
|
-
description: `Value for ":${o}" in the page path. Required when page is ${c.map((d) => `"${d}"`).join(" or ")}.`
|
|
2110
|
-
};
|
|
2111
|
-
}
|
|
2112
|
-
this.registerFunction("navigateToPage", async (o) => {
|
|
2113
|
-
const c = o.page, d = s.find((m) => m.name === c);
|
|
2114
|
-
if (!d) return {
|
|
2115
|
-
success: !1,
|
|
2116
|
-
error: `Unknown page: ${c}`
|
|
2117
|
-
};
|
|
2118
|
-
let u = {};
|
|
2119
|
-
if (typeof o.params == "string") try {
|
|
2120
|
-
u = JSON.parse(o.params);
|
|
2121
|
-
} catch {
|
|
2122
|
-
}
|
|
2123
|
-
else o.params && typeof o.params == "object" && (u = o.params);
|
|
2124
|
-
const h = {};
|
|
2125
|
-
for (const m of F(d.path)) h[m] = o[m] ?? u[m];
|
|
2126
|
-
const { path: f, missing: y } = It(d.path, h);
|
|
2127
|
-
if (y.length > 0) {
|
|
2128
|
-
const m = y.map((g) => `"${g}": "..."`).join(", ");
|
|
2129
|
-
return {
|
|
2130
|
-
success: !1,
|
|
2131
|
-
error: `Page "${c}" needs ${y.map((g) => `"${g}"`).join(", ")}. Retry with { "page": "${c}", ${m} }.`
|
|
2132
|
-
};
|
|
2133
|
-
}
|
|
2134
|
-
return t(f), {
|
|
2135
|
-
success: !0,
|
|
2136
|
-
navigatedTo: f
|
|
2137
|
-
};
|
|
2138
|
-
}, {
|
|
2139
|
-
description: `Navigate the user to a page in the application. Available pages:
|
|
2140
|
-
${r}`,
|
|
2141
|
-
parameters: {
|
|
2142
|
-
type: "object",
|
|
2143
|
-
properties: a,
|
|
2144
|
-
required: ["page"]
|
|
2145
|
-
}
|
|
2146
|
-
}), this.addDynamicContext("current-page", () => {
|
|
2428
|
+
registerNavigationFunction(t, s, i) {
|
|
2429
|
+
this.registerFunction(Ze(t, s, i)), i?.catalogue === "onDemand" ? (this.registerFunction(et(s)), this.listPagesRegistered = !0) : this.listPagesRegistered && (this.unregisterFunction(T), this.listPagesRegistered = !1), this.addDynamicContext("current-page", () => {
|
|
2147
2430
|
if (typeof window > "u" || !window.location) return null;
|
|
2148
|
-
const
|
|
2149
|
-
return
|
|
2431
|
+
const n = window.location.href, r = typeof document < "u" ? document.title : void 0, o = Ye(window.location.pathname, s), a = { url: n };
|
|
2432
|
+
return o && (a.page = o.name), r && (a.title = r), {
|
|
2150
2433
|
name: "Current page",
|
|
2151
2434
|
description: "The page the user is currently viewing.",
|
|
2152
|
-
data:
|
|
2435
|
+
data: a
|
|
2153
2436
|
};
|
|
2154
2437
|
});
|
|
2155
2438
|
}
|
|
2156
2439
|
unregisterNavigationFunction() {
|
|
2157
|
-
this.unregisterFunction(
|
|
2440
|
+
this.unregisterFunction(J), this.listPagesRegistered && (this.unregisterFunction(T), this.listPagesRegistered = !1), this.removeDynamicContext("current-page");
|
|
2158
2441
|
}
|
|
2159
2442
|
registerPageStateFunction(t, s) {
|
|
2160
|
-
const i = s?.functionName ?? "setPageState",
|
|
2161
|
-
this.registerFunction(
|
|
2443
|
+
const i = s?.functionName ?? "setPageState", n = s?.data;
|
|
2444
|
+
this.registerFunction(nt(t, {
|
|
2162
2445
|
name: i,
|
|
2163
2446
|
requiresApproval: s?.requiresApproval,
|
|
2164
|
-
getResultBudget: () =>
|
|
2165
|
-
data:
|
|
2166
|
-
description:
|
|
2167
|
-
maxResultBytes:
|
|
2168
|
-
read: async (
|
|
2447
|
+
getResultBudget: () => n ? this.pageDataBudget(n) : this.functionRegistry.getDefaultMaxResultBytes(),
|
|
2448
|
+
data: n ? {
|
|
2449
|
+
description: n.description,
|
|
2450
|
+
maxResultBytes: n.maxResultBytes,
|
|
2451
|
+
read: async (o) => te(i, await this.readPageData(i, n, s), this.pageDataBudget(n) - this.envelopeBytes(o))
|
|
2169
2452
|
} : void 0
|
|
2170
2453
|
}));
|
|
2171
|
-
const
|
|
2172
|
-
|
|
2173
|
-
description: `Read what the current page is displaying, without changing anything: ${
|
|
2454
|
+
const r = fe(i);
|
|
2455
|
+
n ? (this.warnIfPlaceholderMode(i), this.registerFunction(r, async () => ({ data: te(i, await this.readPageData(i, n, s), this.pageDataBudget(n) - this.envelopeBytes({})) }), {
|
|
2456
|
+
description: `Read what the current page is displaying, without changing anything: ${n.description}`,
|
|
2174
2457
|
parameters: {
|
|
2175
2458
|
type: "object",
|
|
2176
2459
|
properties: {}
|
|
2177
2460
|
},
|
|
2178
|
-
maxResultBytes:
|
|
2179
|
-
}), this.pageDataCompanions.add(
|
|
2180
|
-
const
|
|
2181
|
-
if (
|
|
2182
|
-
const
|
|
2183
|
-
for (const
|
|
2461
|
+
maxResultBytes: n.maxResultBytes
|
|
2462
|
+
}), this.pageDataCompanions.add(r)) : this.pageDataCompanions.delete(r) && this.unregisterFunction(r), this.addDynamicContext(`page-state:${i}`, () => {
|
|
2463
|
+
const o = t.filter((l) => typeof l.get == "function");
|
|
2464
|
+
if (o.length === 0) return null;
|
|
2465
|
+
const a = {};
|
|
2466
|
+
for (const l of o) a[l.name] = l.get();
|
|
2184
2467
|
return {
|
|
2185
2468
|
name: "Page state",
|
|
2186
2469
|
description: "Current, editable state of the page the user is viewing.",
|
|
2187
|
-
data:
|
|
2470
|
+
data: a
|
|
2188
2471
|
};
|
|
2189
2472
|
});
|
|
2190
2473
|
}
|
|
2191
2474
|
unregisterPageStateFunction(t) {
|
|
2192
2475
|
const s = t ?? "setPageState";
|
|
2193
2476
|
this.unregisterFunction(s);
|
|
2194
|
-
const i =
|
|
2477
|
+
const i = fe(s);
|
|
2195
2478
|
this.pageDataCompanions.delete(i) && this.unregisterFunction(i), this.removeDynamicContext(`page-state:${s}`);
|
|
2196
2479
|
}
|
|
2197
2480
|
pageDataBudget(t) {
|
|
2198
2481
|
return t.maxResultBytes ?? this.functionRegistry.getDefaultMaxResultBytes();
|
|
2199
2482
|
}
|
|
2200
2483
|
envelopeBytes(t) {
|
|
2201
|
-
return
|
|
2484
|
+
return E(JSON.stringify({
|
|
2202
2485
|
...t,
|
|
2203
2486
|
data: null
|
|
2204
2487
|
})) - 4;
|
|
2205
2488
|
}
|
|
2206
2489
|
readPageData(t, s, i) {
|
|
2207
|
-
return
|
|
2490
|
+
return qe(() => s, i?.settleTimeoutMs ?? 1e4).catch((n) => (c.warn(`Reading page data for "${t}" failed:`, n), {
|
|
2208
2491
|
error: "page_data_unavailable",
|
|
2209
|
-
message:
|
|
2492
|
+
message: n instanceof Error ? n.message : String(n)
|
|
2210
2493
|
}));
|
|
2211
2494
|
}
|
|
2212
2495
|
warnIfPlaceholderMode(t) {
|
|
2213
|
-
this.warnedPageDataPlaceholder || this.config.clientFunctionsMode === "placeholder" && (this.warnedPageDataPlaceholder = !0,
|
|
2496
|
+
this.warnedPageDataPlaceholder || this.config.clientFunctionsMode === "placeholder" && (this.warnedPageDataPlaceholder = !0, c.warn(`"${t}" declares a data source, but clientFunctionsMode is "placeholder": the agent will not see that data during the turn it calls the function. Switch to "pause" (the default) for the data to come back as the result of its own call.`));
|
|
2214
2497
|
}
|
|
2215
2498
|
setContext(t, s) {
|
|
2216
2499
|
this.contextRegistry.set(t, s), this.notifyContextChanged();
|
|
@@ -2264,10 +2547,10 @@ ${r}`,
|
|
|
2264
2547
|
return this.contextRegistry.getSnapshot();
|
|
2265
2548
|
}
|
|
2266
2549
|
buildSendContext() {
|
|
2267
|
-
const t = this.contextRegistry.getSnapshot(), s = t?.entries ?? {}, { changes: i, baseline:
|
|
2268
|
-
return this.lastSentPageState =
|
|
2550
|
+
const t = this.contextRegistry.getSnapshot(), s = t?.entries ?? {}, { changes: i, baseline: n } = Nt(this.lastSentPageState, s);
|
|
2551
|
+
return this.lastSentPageState = n, i.length === 0 ? t : { entries: {
|
|
2269
2552
|
...s,
|
|
2270
|
-
[
|
|
2553
|
+
[Zt]: {
|
|
2271
2554
|
name: "State changes",
|
|
2272
2555
|
description: "Fields in the page state that changed since your last message, as field: <old> -> <new>.",
|
|
2273
2556
|
data: { changes: i }
|
|
@@ -2289,20 +2572,20 @@ ${r}`,
|
|
|
2289
2572
|
}
|
|
2290
2573
|
recordAgentAction(t) {
|
|
2291
2574
|
const s = t.functionName, i = t.arguments;
|
|
2292
|
-
let
|
|
2575
|
+
let n, r;
|
|
2293
2576
|
if (s === "navigateToPage") {
|
|
2294
|
-
const
|
|
2295
|
-
|
|
2296
|
-
} else s === "setPageState" ? (
|
|
2577
|
+
const o = i?.page;
|
|
2578
|
+
n = "agent.navigate", r = o ? `Agent navigated to "${String(o)}"` : "Agent navigated";
|
|
2579
|
+
} else s === "setPageState" ? (n = "agent.page_state", r = "Agent changed the page state") : (n = `agent.${s}`, r = `Agent ran "${s}"`);
|
|
2297
2580
|
this.addActivity({
|
|
2298
2581
|
actor: "agent",
|
|
2299
|
-
name:
|
|
2300
|
-
summary:
|
|
2582
|
+
name: n,
|
|
2583
|
+
summary: r,
|
|
2301
2584
|
...i && Object.keys(i).length > 0 ? { data: { arguments: i } } : {}
|
|
2302
2585
|
});
|
|
2303
2586
|
}
|
|
2304
2587
|
registerActivityContext() {
|
|
2305
|
-
this.contextRegistry.addDynamicProvider(
|
|
2588
|
+
this.contextRegistry.addDynamicProvider(Qt, () => {
|
|
2306
2589
|
const t = this.activityLedger.getRecent();
|
|
2307
2590
|
return t.length === 0 ? null : {
|
|
2308
2591
|
name: "Recent activity",
|
|
@@ -2313,30 +2596,30 @@ ${r}`,
|
|
|
2313
2596
|
}
|
|
2314
2597
|
enableErrorWatcher(t) {
|
|
2315
2598
|
this.disableErrorWatcher();
|
|
2316
|
-
const s = new
|
|
2599
|
+
const s = new $e(t);
|
|
2317
2600
|
this.errorWatcher = s, s.start(), s.subscribe((i) => {
|
|
2318
2601
|
this.eventEmitter.emit("error:captured", i), this.notifyContextChanged();
|
|
2319
|
-
}), this.contextRegistry.addDynamicProvider(
|
|
2602
|
+
}), this.contextRegistry.addDynamicProvider(ge, () => {
|
|
2320
2603
|
const i = s.getErrors();
|
|
2321
2604
|
if (i.length === 0) return null;
|
|
2322
|
-
const
|
|
2605
|
+
const n = Date.now();
|
|
2323
2606
|
return {
|
|
2324
2607
|
name: "Recent JavaScript errors",
|
|
2325
2608
|
description: "JavaScript errors captured on the page in the last minutes, oldest first, with how long ago each last fired (ageMs) and how many times (count). Use them to diagnose when the user reports something broken or unresponsive; do not bring them up otherwise.",
|
|
2326
|
-
data: { errors: i.map(({ firstAt:
|
|
2327
|
-
...
|
|
2328
|
-
ageMs: Math.max(0,
|
|
2329
|
-
...
|
|
2609
|
+
data: { errors: i.map(({ firstAt: r, lastAt: o, ...a }) => ({
|
|
2610
|
+
...a,
|
|
2611
|
+
ageMs: Math.max(0, n - o),
|
|
2612
|
+
...r !== o ? { firstSeenAgoMs: Math.max(0, n - r) } : {}
|
|
2330
2613
|
})) }
|
|
2331
2614
|
};
|
|
2332
2615
|
});
|
|
2333
2616
|
}
|
|
2334
2617
|
disableErrorWatcher() {
|
|
2335
|
-
this.errorWatcher && (this.errorWatcher.destroy(), this.errorWatcher = null, this.contextRegistry.removeDynamicProvider(
|
|
2618
|
+
this.errorWatcher && (this.errorWatcher.destroy(), this.errorWatcher = null, this.contextRegistry.removeDynamicProvider(ge));
|
|
2336
2619
|
}
|
|
2337
2620
|
reportError(t, s) {
|
|
2338
2621
|
if (!this.errorWatcher) {
|
|
2339
|
-
|
|
2622
|
+
c.warn("reportError() ignored: enable the error watcher first (errorWatcher: true).");
|
|
2340
2623
|
return;
|
|
2341
2624
|
}
|
|
2342
2625
|
this.errorWatcher.report(t, s);
|
|
@@ -2361,48 +2644,48 @@ ${r}`,
|
|
|
2361
2644
|
}
|
|
2362
2645
|
updateConfig(t) {
|
|
2363
2646
|
const s = {};
|
|
2364
|
-
for (const [
|
|
2647
|
+
for (const [n, r] of Object.entries(t)) r !== void 0 && (s[n] = r);
|
|
2365
2648
|
const i = {
|
|
2366
2649
|
...this.config,
|
|
2367
2650
|
...s
|
|
2368
2651
|
};
|
|
2369
|
-
|
|
2652
|
+
he(i, "AgoClient.updateConfig"), this.config = i, this.httpClient.updateConfig(s), s.debug !== void 0 && (s.debug ? c.enable() : c.disable()), s.maxFunctionResultBytes !== void 0 && this.functionRegistry.setDefaultMaxResultBytes(s.maxFunctionResultBytes), s.errorWatcher !== void 0 && (s.errorWatcher ? this.enableErrorWatcher(s.errorWatcher === !0 ? void 0 : s.errorWatcher) : this.disableErrorWatcher());
|
|
2370
2653
|
}
|
|
2371
2654
|
destroy() {
|
|
2372
|
-
this.proactive?.destroy(), this.proactive = null, this.errorWatcher?.destroy(), this.errorWatcher = null, this.activeTurn?.controller.abort(), this.activeTurn = null, this.pausedTurn = null, this.stoppedTurnIds.clear(), this.eventEmitter.removeAllListeners(), this.functionRegistry.clear(), this.contextRegistry.clear(), this.pendingResumes.clear(), this.pendingApprovals.clear(), this.resumeGate = null,
|
|
2655
|
+
this.proactive?.destroy(), this.proactive = null, this.errorWatcher?.destroy(), this.errorWatcher = null, this.detachWebMCP?.(), this.detachWebMCP = null, this.activeTurn?.controller.abort(), this.activeTurn = null, this.pausedTurn = null, this.stoppedTurnIds.clear(), this.eventEmitter.removeAllListeners(), this.functionRegistry.clear(), this.listPagesRegistered = !1, this.contextRegistry.clear(), this.pendingResumes.clear(), this.pendingApprovals.clear(), this.resumeGate = null, c.log("AgoClient destroyed");
|
|
2373
2656
|
}
|
|
2374
2657
|
reviveAfterDestroy() {
|
|
2375
|
-
this.registerActivityContext(), this.config.errorWatcher && !this.errorWatcher && this.enableErrorWatcher(this.config.errorWatcher === !0 ? void 0 : this.config.errorWatcher), this.config.proactive && !this.proactive &&
|
|
2658
|
+
this.registerActivityContext(), this.config.errorWatcher && !this.errorWatcher && this.enableErrorWatcher(this.config.errorWatcher === !0 ? void 0 : this.config.errorWatcher), this.config.proactive && !this.proactive && ae(this, this.config.proactive), this.attachWebMCPBridge();
|
|
2376
2659
|
}
|
|
2377
|
-
},
|
|
2660
|
+
}, ls = [
|
|
2378
2661
|
"inaccurate",
|
|
2379
2662
|
"incomplete",
|
|
2380
2663
|
"information_not_found",
|
|
2381
2664
|
"technical_issue"
|
|
2382
2665
|
];
|
|
2383
2666
|
export {
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2667
|
+
ke as C,
|
|
2668
|
+
c as S,
|
|
2669
|
+
ht as _,
|
|
2670
|
+
as as a,
|
|
2671
|
+
is as b,
|
|
2672
|
+
jt as c,
|
|
2673
|
+
xt as d,
|
|
2674
|
+
ae as f,
|
|
2675
|
+
gt as g,
|
|
2676
|
+
Se as h,
|
|
2677
|
+
Wt as i,
|
|
2678
|
+
Ot as l,
|
|
2679
|
+
Et as m,
|
|
2680
|
+
cs as n,
|
|
2681
|
+
rs as o,
|
|
2682
|
+
wt as p,
|
|
2683
|
+
he as r,
|
|
2684
|
+
os as s,
|
|
2685
|
+
ls as t,
|
|
2686
|
+
ns as u,
|
|
2687
|
+
Le as v,
|
|
2688
|
+
ts as w,
|
|
2689
|
+
$e as x,
|
|
2690
|
+
ss as y
|
|
2408
2691
|
};
|