@pluno/product-agent-web 0.1.179 → 0.1.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -9
- package/dist/modelSelection.d.ts +35 -0
- package/dist/product-agent-sdk.js +999 -986
- package/dist/product-agent-widget.js +3130 -2980
- package/dist/transportIdentity.d.ts +2 -1
- package/dist/widget.d.ts +5 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const e = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
1
|
+
const Is = "pluno-product-agent-attachments";
|
|
2
|
+
const ze = "files";
|
|
3
|
+
async function Ts(t) {
|
|
4
|
+
const e = await Ze();
|
|
5
|
+
await Ms(e, "readwrite", (s) => s.put(t));
|
|
6
|
+
}
|
|
7
|
+
async function Ss(t, e) {
|
|
8
|
+
const s = await Ze();
|
|
9
|
+
await et(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await tt(
|
|
11
11
|
n.get(t)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,38 +16,38 @@ async function Is(t, e) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const e = await
|
|
21
|
-
await
|
|
19
|
+
async function ws(t = 864e5) {
|
|
20
|
+
const e = await Ze(), s = Date.now() - t;
|
|
21
|
+
await et(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await tt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Ze() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
|
|
28
|
-
const s = indexedDB.open(
|
|
28
|
+
const s = indexedDB.open(Is, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(ze, { keyPath: "attachmentId" });
|
|
31
31
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
32
32
|
}, s.onsuccess = () => t(s.result), s.onerror = () => e(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
return await
|
|
35
|
+
async function Ms(t, e, s) {
|
|
36
|
+
return await et(t, e, async (n) => await tt(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function et(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(ze, e), o = i.objectStore(ze);
|
|
41
41
|
let a, l = !1;
|
|
42
|
-
s(o).then((
|
|
43
|
-
a =
|
|
44
|
-
}).catch((
|
|
42
|
+
s(o).then((c) => {
|
|
43
|
+
a = c;
|
|
44
|
+
}).catch((c) => {
|
|
45
45
|
l = !0;
|
|
46
46
|
try {
|
|
47
47
|
i.abort();
|
|
48
48
|
} catch {
|
|
49
49
|
}
|
|
50
|
-
r(
|
|
50
|
+
r(c);
|
|
51
51
|
}), i.oncomplete = () => {
|
|
52
52
|
l || n(a);
|
|
53
53
|
}, i.onerror = () => {
|
|
@@ -57,16 +57,16 @@ function Qe(t, e, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function tt(t) {
|
|
61
61
|
return new Promise((e, s) => {
|
|
62
62
|
t.onsuccess = () => e(t.result), t.onerror = () => s(t.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function As(t) {
|
|
66
66
|
return t !== null && (typeof t == "object" || typeof t == "function");
|
|
67
67
|
}
|
|
68
68
|
function Bt(t, e, s) {
|
|
69
|
-
const n = Reflect.get(t, "pluno"), r =
|
|
69
|
+
const n = Reflect.get(t, "pluno"), r = As(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(t, "pluno", r))
|
|
71
71
|
return null;
|
|
72
72
|
const i = Object.getOwnPropertyDescriptor(r, e);
|
|
@@ -80,65 +80,65 @@ function Bt(t, e, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const Rs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function Es(t, e) {
|
|
85
85
|
return e ? t.replace(
|
|
86
|
-
|
|
86
|
+
Rs,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
|
|
88
88
|
) : t;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
91
|
-
function
|
|
92
|
-
return (t.type === "function_call" || t.type === "tool_call") && t.name ===
|
|
90
|
+
const ks = "save_runtime_captured_skill";
|
|
91
|
+
function Cs(t) {
|
|
92
|
+
return (t.type === "function_call" || t.type === "tool_call") && t.name === ks;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
const n = e.map((
|
|
94
|
+
function bs(t, e, s) {
|
|
95
|
+
const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
96
96
|
n.flatMap(
|
|
97
|
-
({ identity:
|
|
97
|
+
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
98
98
|
)
|
|
99
99
|
), i = n.filter(
|
|
100
|
-
({ identity:
|
|
101
|
-
), o = new Map(i.map(({ item:
|
|
100
|
+
({ identity: u }) => !(u.isTransient && u.activityKeys?.some((p) => r.has(p)))
|
|
101
|
+
), o = new Map(i.map(({ item: u, identity: p }) => [p.id, u])), a = new Map(
|
|
102
102
|
i.flatMap(
|
|
103
|
-
({ item:
|
|
103
|
+
({ item: u, identity: p }) => p.optimisticKey ? [[p.optimisticKey, u]] : []
|
|
104
104
|
)
|
|
105
105
|
), l = new Map(
|
|
106
106
|
i.flatMap(
|
|
107
|
-
({ item:
|
|
107
|
+
({ item: u, identity: p }) => p.assistantDraftKey ? [[p.assistantDraftKey, u]] : []
|
|
108
108
|
)
|
|
109
|
-
),
|
|
110
|
-
for (const { item:
|
|
111
|
-
for (const g of
|
|
112
|
-
const
|
|
113
|
-
(!
|
|
109
|
+
), c = /* @__PURE__ */ new Map();
|
|
110
|
+
for (const { item: u, identity: p } of i)
|
|
111
|
+
for (const g of p.activityKeys ?? []) {
|
|
112
|
+
const m = c.get(g);
|
|
113
|
+
(!m || s(m).isTransient) && c.set(g, u);
|
|
114
114
|
}
|
|
115
|
-
const d = new Set(i.map(({ identity:
|
|
116
|
-
i.flatMap(({ identity:
|
|
117
|
-
),
|
|
118
|
-
for (const
|
|
119
|
-
const
|
|
120
|
-
let g = o.get(
|
|
121
|
-
if (
|
|
122
|
-
f.push(g),
|
|
115
|
+
const d = new Set(i.map(({ identity: u }) => u.id)), h = new Set(
|
|
116
|
+
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
117
|
+
), y = /* @__PURE__ */ new Set(), f = [];
|
|
118
|
+
for (const u of t) {
|
|
119
|
+
const p = s(u);
|
|
120
|
+
let g = o.get(p.id);
|
|
121
|
+
if (p.isOptimistic && p.optimisticKey ? g = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? g = l.get(p.assistantDraftKey) : p.isActivity && (g = p.activityKeys?.map((k) => c.get(k)).find((k) => k !== void 0) ?? g), g && !y.has(g)) {
|
|
122
|
+
f.push(g), y.add(g);
|
|
123
123
|
continue;
|
|
124
124
|
}
|
|
125
|
-
const
|
|
126
|
-
(
|
|
125
|
+
const m = p.respondsToUserMessageId !== void 0 && d.has(p.respondsToUserMessageId) || p.runId !== void 0 && h.has(p.runId);
|
|
126
|
+
(p.isOptimistic || (p.isAssistantDraft || p.isActivity) && m) && f.push(u);
|
|
127
127
|
}
|
|
128
|
-
for (const { item:
|
|
129
|
-
|
|
128
|
+
for (const { item: u } of i)
|
|
129
|
+
y.has(u) || f.push(u);
|
|
130
130
|
return f;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function _s(t, e, s, n) {
|
|
133
133
|
return t.filter((r) => {
|
|
134
134
|
const i = n(r);
|
|
135
135
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
const Oe = "pluno.productAgent.transportId",
|
|
138
|
+
const Oe = "pluno.productAgent.transportId", Ps = "pluno.productAgent.transportIdentity", Ne = "pluno.productAgent.transportIdentity.event", Us = 50, vs = globalThis.setTimeout.bind(globalThis);
|
|
139
139
|
let ne = null;
|
|
140
|
-
const
|
|
141
|
-
async function
|
|
140
|
+
const Ie = /* @__PURE__ */ new Set(), xe = /* @__PURE__ */ new Map();
|
|
141
|
+
async function Ds(t = Wt()) {
|
|
142
142
|
const e = t.randomUUID(), s = t.storage.getItem(Oe);
|
|
143
143
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
144
144
|
const o = t.channel.subscribe((l) => {
|
|
@@ -158,6 +158,8 @@ async function Us(t = Wt()) {
|
|
|
158
158
|
});
|
|
159
159
|
if (!s)
|
|
160
160
|
t.storage.setItem(Oe, n), r = !0;
|
|
161
|
+
else if (t.skipStoredIdentityCollisionCheck)
|
|
162
|
+
r = !0;
|
|
161
163
|
else
|
|
162
164
|
for (; ; ) {
|
|
163
165
|
if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
|
|
@@ -174,49 +176,52 @@ async function Us(t = Wt()) {
|
|
|
174
176
|
}
|
|
175
177
|
};
|
|
176
178
|
}
|
|
177
|
-
async function
|
|
178
|
-
ne || (ne =
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
async function qs(t = !1) {
|
|
180
|
+
ne || (ne = Ds({
|
|
181
|
+
...Wt(),
|
|
182
|
+
skipStoredIdentityCollisionCheck: t
|
|
183
|
+
}), ne.then((r) => {
|
|
184
|
+
const i = (o) => {
|
|
185
|
+
o.persisted || (r.release(), ne = null, Ie.clear(), window.removeEventListener("pagehide", i));
|
|
181
186
|
};
|
|
182
|
-
window.addEventListener("pagehide",
|
|
187
|
+
window.addEventListener("pagehide", i);
|
|
183
188
|
}));
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
let
|
|
189
|
+
const e = await ne, s = Ls();
|
|
190
|
+
Ie.add(s);
|
|
191
|
+
let n = !1;
|
|
187
192
|
return {
|
|
188
193
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
189
|
-
transportId:
|
|
194
|
+
transportId: s === 0 ? e.transportId : `${e.transportId}.${s}`,
|
|
190
195
|
release: () => {
|
|
191
|
-
|
|
196
|
+
n || (n = !0, Ie.delete(s));
|
|
192
197
|
}
|
|
193
198
|
};
|
|
194
199
|
}
|
|
195
|
-
function
|
|
200
|
+
function Ls() {
|
|
196
201
|
let t = 0;
|
|
197
|
-
for (;
|
|
202
|
+
for (; Ie.has(t); )
|
|
198
203
|
t += 1;
|
|
199
204
|
return t;
|
|
200
205
|
}
|
|
201
206
|
function Wt() {
|
|
202
207
|
return {
|
|
203
208
|
storage: Os(),
|
|
204
|
-
channel:
|
|
209
|
+
channel: Ns(),
|
|
205
210
|
randomUUID: () => crypto.randomUUID(),
|
|
206
|
-
settle: () => new Promise((t) =>
|
|
211
|
+
settle: () => new Promise((t) => vs(t, Us))
|
|
207
212
|
};
|
|
208
213
|
}
|
|
209
214
|
function Os() {
|
|
210
215
|
return {
|
|
211
216
|
getItem: (t) => {
|
|
212
217
|
try {
|
|
213
|
-
return window.sessionStorage?.getItem(t) ??
|
|
218
|
+
return window.sessionStorage?.getItem(t) ?? xe.get(t) ?? null;
|
|
214
219
|
} catch {
|
|
215
|
-
return
|
|
220
|
+
return xe.get(t) ?? null;
|
|
216
221
|
}
|
|
217
222
|
},
|
|
218
223
|
setItem: (t, e) => {
|
|
219
|
-
|
|
224
|
+
xe.set(t, e);
|
|
220
225
|
try {
|
|
221
226
|
window.sessionStorage?.setItem(t, e);
|
|
222
227
|
} catch {
|
|
@@ -224,9 +229,9 @@ function Os() {
|
|
|
224
229
|
}
|
|
225
230
|
};
|
|
226
231
|
}
|
|
227
|
-
function
|
|
232
|
+
function Ns() {
|
|
228
233
|
if (typeof BroadcastChannel < "u") {
|
|
229
|
-
const t = new BroadcastChannel(
|
|
234
|
+
const t = new BroadcastChannel(Ps);
|
|
230
235
|
return {
|
|
231
236
|
postMessage: (e) => t.postMessage(e),
|
|
232
237
|
subscribe: (e) => {
|
|
@@ -236,11 +241,11 @@ function qs() {
|
|
|
236
241
|
close: () => t.close()
|
|
237
242
|
};
|
|
238
243
|
}
|
|
239
|
-
return
|
|
244
|
+
return xs();
|
|
240
245
|
}
|
|
241
|
-
function
|
|
246
|
+
function xs() {
|
|
242
247
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
243
|
-
if (s.key !==
|
|
248
|
+
if (s.key !== Ne || !s.newValue)
|
|
244
249
|
return;
|
|
245
250
|
const n = JSON.parse(s.newValue);
|
|
246
251
|
for (const r of t)
|
|
@@ -249,9 +254,9 @@ function Ls() {
|
|
|
249
254
|
return window.addEventListener("storage", e), {
|
|
250
255
|
postMessage: (s) => {
|
|
251
256
|
window.localStorage.setItem(
|
|
252
|
-
|
|
257
|
+
Ne,
|
|
253
258
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
254
|
-
), window.localStorage.removeItem(
|
|
259
|
+
), window.localStorage.removeItem(Ne);
|
|
255
260
|
},
|
|
256
261
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
257
262
|
close: () => {
|
|
@@ -260,7 +265,7 @@ function Ls() {
|
|
|
260
265
|
};
|
|
261
266
|
}
|
|
262
267
|
const Ht = "schedule_follow_up";
|
|
263
|
-
function
|
|
268
|
+
function Bs(t) {
|
|
264
269
|
let e = t;
|
|
265
270
|
if (typeof e == "string")
|
|
266
271
|
try {
|
|
@@ -273,8 +278,18 @@ function Ns(t) {
|
|
|
273
278
|
const s = e;
|
|
274
279
|
return s.ok !== !0 || s.toolName !== Ht || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
275
280
|
}
|
|
276
|
-
const
|
|
277
|
-
|
|
281
|
+
const Ws = [
|
|
282
|
+
{ value: "gpt-5.6-terra", label: "gpt-5.6-terra" },
|
|
283
|
+
{ value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5" },
|
|
284
|
+
{ value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash" }
|
|
285
|
+
], Hs = [
|
|
286
|
+
{ value: "anthropic/claude-opus-5", label: "Claude Opus 5" },
|
|
287
|
+
{ value: "gpt-5.6-sol", label: "gpt-5.6-sol" }
|
|
288
|
+
], $s = [
|
|
289
|
+
...Ws,
|
|
290
|
+
...Hs
|
|
291
|
+
], js = (t) => $s.some((e) => e.value === t), Fs = globalThis.fetch.bind(globalThis), Ke = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', zs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ks = ".pluno-pa-widget__panel", Gs = ".pluno-pa-widget__timeline", ht = `${Ke}[data-pluno-sdk-preview-channel]`;
|
|
292
|
+
let Vs = 0;
|
|
278
293
|
function gt(t) {
|
|
279
294
|
const e = {};
|
|
280
295
|
for (const o of [
|
|
@@ -306,14 +321,14 @@ function gt(t) {
|
|
|
306
321
|
if (a && typeof a == "object") {
|
|
307
322
|
const l = a.composerPreload;
|
|
308
323
|
if (l && typeof l == "object") {
|
|
309
|
-
const
|
|
310
|
-
e.composerPreloaded = !0, typeof
|
|
324
|
+
const c = l.runId;
|
|
325
|
+
e.composerPreloaded = !0, typeof c == "string" && (e.preloadRunId = c);
|
|
311
326
|
}
|
|
312
327
|
}
|
|
313
328
|
}
|
|
314
329
|
return e;
|
|
315
330
|
}
|
|
316
|
-
function
|
|
331
|
+
function Be(t, e, s) {
|
|
317
332
|
if (typeof window > "u")
|
|
318
333
|
return;
|
|
319
334
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -325,36 +340,36 @@ function Ne(t, e, s) {
|
|
|
325
340
|
source: "web_sdk",
|
|
326
341
|
category: t,
|
|
327
342
|
name: e,
|
|
328
|
-
sequence:
|
|
343
|
+
sequence: ++Vs,
|
|
329
344
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
330
345
|
monotonicMs: performance.now(),
|
|
331
346
|
data: s
|
|
332
347
|
};
|
|
333
348
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
334
349
|
}
|
|
335
|
-
class
|
|
350
|
+
class pe extends Error {
|
|
336
351
|
}
|
|
337
|
-
function
|
|
352
|
+
function Xs(t) {
|
|
338
353
|
return t === 408 || t === 425 || t === 429 || t >= 500;
|
|
339
354
|
}
|
|
340
|
-
const
|
|
355
|
+
const Js = "https://app.pluno.ai", Ys = 2e4, Qs = 1e4, Zs = 1e4, en = 1e4, tn = 1e4, sn = 3e3, nn = 3e4, rn = 1e3, ft = 3e4, mt = 0.2, yt = 6e4, It = 15e3, re = 8, Tt = "Browser connection was interrupted.", St = 15e3, on = "Pluno could not send this message. Try it again.", wt = 2e3, an = 1e3, ln = 100, Mt = 8e3, At = 3, cn = [300, 1e3], $t = 50 * 1024 * 1024, un = /* @__PURE__ */ new Set([
|
|
341
356
|
".jpeg:image/jpeg",
|
|
342
357
|
".jpg:image/jpeg",
|
|
343
358
|
".pdf:application/pdf",
|
|
344
359
|
".png:image/png",
|
|
345
360
|
".webp:image/webp"
|
|
346
|
-
]),
|
|
361
|
+
]), Ai = ".pdf,.png,.jpg,.jpeg,.webp", st = 64e3, We = 4e3, nt = 30, dn = 2e3, pn = 1e3, jt = "Image is too large for model vision input.", hn = 100, Ft = "pluno.productAgent.state.", Ge = "pluno.productAgent.pendingEvents.", Ce = "pluno.productAgent.activeToolCalls.", gn = 100;
|
|
347
362
|
function ie(t, e = 0) {
|
|
348
363
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
349
364
|
return Math.max(e, s);
|
|
350
365
|
}
|
|
351
|
-
const
|
|
352
|
-
let
|
|
353
|
-
function
|
|
354
|
-
const s = Math.min(ft,
|
|
366
|
+
const Te = /* @__PURE__ */ new Set();
|
|
367
|
+
let he = null;
|
|
368
|
+
function fn(t, e = Math.random) {
|
|
369
|
+
const s = Math.min(ft, rn * 2 ** t), n = 1 - mt + e() * mt * 2;
|
|
355
370
|
return Math.min(ft, Math.round(s * n));
|
|
356
371
|
}
|
|
357
|
-
function
|
|
372
|
+
function mn(t, e, s) {
|
|
358
373
|
return new Promise((n, r) => {
|
|
359
374
|
const i = setTimeout(() => r(new Error(s)), e);
|
|
360
375
|
t.then(
|
|
@@ -371,15 +386,16 @@ class zt {
|
|
|
371
386
|
constructor(e, s) {
|
|
372
387
|
this.options = e, this.transportIdentity = s, this.state = {
|
|
373
388
|
...this.state,
|
|
374
|
-
starterPrompts:
|
|
389
|
+
starterPrompts: Xn(e.initialStarterPrompts)
|
|
375
390
|
};
|
|
376
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
391
|
+
const n = e.restorePersistedState === !1 ? null : $r(e.clientId, e.expectedPersistedSessionId);
|
|
377
392
|
n && (this.state = {
|
|
378
393
|
...this.state,
|
|
379
394
|
...n,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
),
|
|
395
|
+
// Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
|
|
396
|
+
// activity is deliberately not restored here because it hydrates after the transcript is visible.
|
|
397
|
+
messages: n.messages.filter(rs),
|
|
398
|
+
isLoadingSession: n.sessionId !== null,
|
|
383
399
|
status: "idle",
|
|
384
400
|
user: null,
|
|
385
401
|
assistantDraft: "",
|
|
@@ -393,14 +409,14 @@ class zt {
|
|
|
393
409
|
taskStatus: null,
|
|
394
410
|
isRetrying: !1,
|
|
395
411
|
lastError: null
|
|
396
|
-
}), this.queuedClientEvents =
|
|
397
|
-
|
|
398
|
-
|
|
412
|
+
}), this.queuedClientEvents = Vr(
|
|
413
|
+
Fr(e.clientId),
|
|
414
|
+
zr(e.clientId)
|
|
399
415
|
);
|
|
400
416
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
401
417
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
402
418
|
);
|
|
403
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"),
|
|
419
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), K(e.clientId, this.queuedClientEvents);
|
|
404
420
|
}
|
|
405
421
|
options;
|
|
406
422
|
listeners = {};
|
|
@@ -433,10 +449,7 @@ class zt {
|
|
|
433
449
|
sessionLoadRequestTimer = null;
|
|
434
450
|
pendingSessionSubscription = null;
|
|
435
451
|
sessionHistoryHydration = null;
|
|
436
|
-
|
|
437
|
-
sessionItemsCursor = null;
|
|
438
|
-
hasLoadedOlderSessionItems = !1;
|
|
439
|
-
loadedOlderSessionItemIds = /* @__PURE__ */ new Set();
|
|
452
|
+
sessionActivityRequestId = null;
|
|
440
453
|
transportIdentity;
|
|
441
454
|
retryAttemptsByClientMessageId = {};
|
|
442
455
|
retryTimersByClientMessageId = {};
|
|
@@ -488,8 +501,6 @@ class zt {
|
|
|
488
501
|
appearance: null,
|
|
489
502
|
messages: [],
|
|
490
503
|
isLoadingSession: !1,
|
|
491
|
-
isLoadingOlderMessages: !1,
|
|
492
|
-
hasOlderMessages: !1,
|
|
493
504
|
assistantDraft: "",
|
|
494
505
|
assistantDraftItemId: null,
|
|
495
506
|
assistantDraftPhase: null,
|
|
@@ -505,24 +516,25 @@ class zt {
|
|
|
505
516
|
lastErrorSecuritySettingsUrl: null
|
|
506
517
|
};
|
|
507
518
|
static async init(e) {
|
|
508
|
-
const s =
|
|
519
|
+
const s = e, n = await qs(
|
|
520
|
+
s.skipStoredTransportIdentityCollisionCheck === !0
|
|
521
|
+
), r = new zt({
|
|
509
522
|
...e,
|
|
510
|
-
backendUrl:
|
|
511
|
-
clientId: e.clientId ??
|
|
512
|
-
model: e.model ?? zs,
|
|
523
|
+
backendUrl: qn(e.backendUrl ?? Js),
|
|
524
|
+
clientId: e.clientId ?? er(),
|
|
513
525
|
productVariant: e.productVariant ?? "customer_embedded",
|
|
514
|
-
entrySurface:
|
|
515
|
-
},
|
|
526
|
+
entrySurface: Ln(e.entrySurface)
|
|
527
|
+
}, n);
|
|
516
528
|
try {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
message:
|
|
529
|
+
ws().catch((i) => {
|
|
530
|
+
w("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
531
|
+
message: i instanceof Error ? i.message : String(i)
|
|
520
532
|
});
|
|
521
|
-
}),
|
|
522
|
-
} catch (
|
|
523
|
-
throw
|
|
533
|
+
}), s.disableNetworkCapture || r.enableNetworkCapture(), r.startPageLifecycleRecovery(), r.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await r.connect();
|
|
534
|
+
} catch (i) {
|
|
535
|
+
throw r.destroy(), i;
|
|
524
536
|
}
|
|
525
|
-
return
|
|
537
|
+
return r;
|
|
526
538
|
}
|
|
527
539
|
on(e, s) {
|
|
528
540
|
const n = this.listeners[e] ?? /* @__PURE__ */ new Set();
|
|
@@ -545,15 +557,15 @@ class zt {
|
|
|
545
557
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
546
558
|
);
|
|
547
559
|
try {
|
|
548
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
560
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await mn(this.options.tokenProvider(), Zs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
549
561
|
return;
|
|
550
562
|
if (!this.token && !this.options.webSocketFactory)
|
|
551
563
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
552
|
-
const s =
|
|
564
|
+
const s = xn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
553
565
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
554
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (
|
|
555
|
-
},
|
|
556
|
-
this.socket !== n || (this.clearSocketConnectTimer(),
|
|
566
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (w("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
567
|
+
}, en), n.addEventListener("open", () => {
|
|
568
|
+
this.socket !== n || (this.clearSocketConnectTimer(), w("web-sdk.agent", "Pluno socket opened", {
|
|
557
569
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
558
570
|
isThinking: this.state.isThinking
|
|
559
571
|
}), !(this.token ? this.sendNow({
|
|
@@ -563,19 +575,19 @@ class zt {
|
|
|
563
575
|
transportId: this.transportIdentity.transportId,
|
|
564
576
|
pageUrl: location.href
|
|
565
577
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
566
|
-
this.socket === n && (
|
|
567
|
-
},
|
|
578
|
+
this.socket === n && (w("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
579
|
+
}, tn));
|
|
568
580
|
}), n.addEventListener("message", (r) => {
|
|
569
|
-
this.socket === n && this.handleServerEvent(
|
|
581
|
+
this.socket === n && this.handleServerEvent(Gn(r.data));
|
|
570
582
|
}), n.addEventListener("sendfailure", (r) => {
|
|
571
583
|
if (this.socket !== n)
|
|
572
584
|
return;
|
|
573
|
-
const i =
|
|
585
|
+
const i = Vn(r?.detail?.data);
|
|
574
586
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
575
587
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
576
|
-
) && (this.queuedClientEvents.push(i),
|
|
588
|
+
) && (this.queuedClientEvents.push(i), K(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
|
|
577
589
|
}), n.addEventListener("close", (r) => {
|
|
578
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (
|
|
590
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (w("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
579
591
|
code: typeof r?.code == "number" ? r.code : null,
|
|
580
592
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
581
593
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -583,7 +595,7 @@ class zt {
|
|
|
583
595
|
isThinking: this.state.isThinking
|
|
584
596
|
}), this.setReconnectingState(), this.scheduleReconnect()));
|
|
585
597
|
}), n.addEventListener("error", () => {
|
|
586
|
-
this.socket !== n || this.state.status === "closed" || (
|
|
598
|
+
this.socket !== n || this.state.status === "closed" || (w("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
587
599
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
588
600
|
isThinking: this.state.isThinking
|
|
589
601
|
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
@@ -606,7 +618,7 @@ class zt {
|
|
|
606
618
|
this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
607
619
|
}
|
|
608
620
|
destroy() {
|
|
609
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
621
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Xr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
610
622
|
for (const e of Object.values(this.listeners))
|
|
611
623
|
e?.clear();
|
|
612
624
|
}
|
|
@@ -614,10 +626,11 @@ class zt {
|
|
|
614
626
|
const s = b(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
|
|
615
627
|
type: "runtime.warmup",
|
|
616
628
|
reason: e,
|
|
617
|
-
...e === "composer_input" ? { warmupId: r?.event.warmupId ??
|
|
629
|
+
...e === "composer_input" ? { warmupId: r?.event.warmupId ?? B() } : {},
|
|
618
630
|
entrySurface: this.options.entrySurface,
|
|
619
631
|
sessionId: this.state.sessionId ?? void 0,
|
|
620
|
-
page: s
|
|
632
|
+
page: s,
|
|
633
|
+
model: this.options.model
|
|
621
634
|
};
|
|
622
635
|
if (e === "composer_input") {
|
|
623
636
|
if (this.options.productVariant === "customer_embedded") {
|
|
@@ -644,23 +657,23 @@ class zt {
|
|
|
644
657
|
}
|
|
645
658
|
async sendMessage(e, s = {}) {
|
|
646
659
|
const n = e.trim(), r = s.attachments ?? [];
|
|
647
|
-
if (this.options.productVariant === "customer_embedded" && (r.forEach(
|
|
648
|
-
(
|
|
660
|
+
if (this.options.productVariant === "customer_embedded" && (r.forEach(ls), r.reduce(
|
|
661
|
+
(S, _) => S + _.sizeBytes,
|
|
649
662
|
0
|
|
650
663
|
) > $t))
|
|
651
664
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
652
|
-
let i = r.map(
|
|
665
|
+
let i = r.map(Re);
|
|
653
666
|
if (!n && i.length === 0)
|
|
654
667
|
return null;
|
|
655
668
|
if (this.pendingClientMessageId)
|
|
656
669
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
657
|
-
const o = b(), a = s.clientMessageId ??
|
|
670
|
+
const o = b(), a = s.clientMessageId ?? B(), l = {
|
|
658
671
|
id: `local-${a}`,
|
|
659
672
|
role: "user",
|
|
660
673
|
content: n,
|
|
661
674
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
662
675
|
...r.length > 0 ? { attachments: r } : {}
|
|
663
|
-
},
|
|
676
|
+
}, c = this.state.messages.some((T) => T.id === l.id || T.clientMessageId === a), d = this.state.isThinking, h = this.state.taskStatus, y = this.state.pendingMessageStatus, f = this.state.turnPhase, u = this.state.messages, p = c ? this.state.messages : [...this.state.messages, l], g = {
|
|
664
677
|
assistantDraft: this.state.assistantDraft,
|
|
665
678
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
666
679
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -669,7 +682,7 @@ class zt {
|
|
|
669
682
|
lastError: this.state.lastError
|
|
670
683
|
};
|
|
671
684
|
this.setState({
|
|
672
|
-
messages:
|
|
685
|
+
messages: p,
|
|
673
686
|
...d ? {} : {
|
|
674
687
|
assistantDraft: "",
|
|
675
688
|
assistantDraftItemId: null,
|
|
@@ -683,46 +696,52 @@ class zt {
|
|
|
683
696
|
taskStatus: "working",
|
|
684
697
|
isRetrying: !1,
|
|
685
698
|
lastError: null
|
|
686
|
-
}),
|
|
699
|
+
}), c || this.emit("message", l);
|
|
687
700
|
try {
|
|
688
|
-
const
|
|
689
|
-
for (const
|
|
690
|
-
const
|
|
691
|
-
if (
|
|
692
|
-
|
|
701
|
+
const T = [];
|
|
702
|
+
for (const S of i) {
|
|
703
|
+
const _ = S.id ? this.attachmentFiles.get(S.id) : void 0;
|
|
704
|
+
if (S.sandboxPath || S.storageKey) {
|
|
705
|
+
T.push(S);
|
|
693
706
|
continue;
|
|
694
707
|
}
|
|
695
|
-
if (!
|
|
696
|
-
throw new Error(`Attachment bytes are unavailable for ${
|
|
697
|
-
|
|
708
|
+
if (!_)
|
|
709
|
+
throw new Error(`Attachment bytes are unavailable for ${S.name}`);
|
|
710
|
+
T.push(await this.uploadAttachmentForMessage({ file: _, attachment: S }));
|
|
698
711
|
}
|
|
699
|
-
i =
|
|
700
|
-
} catch (
|
|
712
|
+
i = T;
|
|
713
|
+
} catch (T) {
|
|
701
714
|
throw this.setState({
|
|
702
|
-
...
|
|
715
|
+
...c ? {} : { messages: u },
|
|
703
716
|
...d ? {} : { ...g, isThinking: !1 },
|
|
704
|
-
pendingMessageStatus:
|
|
717
|
+
pendingMessageStatus: y,
|
|
705
718
|
turnPhase: f,
|
|
706
|
-
taskStatus:
|
|
707
|
-
}),
|
|
719
|
+
taskStatus: h
|
|
720
|
+
}), T;
|
|
708
721
|
}
|
|
709
722
|
this.retryableClientMessageId = null;
|
|
710
|
-
const
|
|
723
|
+
const m = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, k = {
|
|
711
724
|
type: "chat.user_message",
|
|
712
725
|
sessionId: this.state.sessionId ?? void 0,
|
|
713
726
|
clientMessageId: a,
|
|
714
727
|
initiatedBy: s.initiatedBy,
|
|
715
|
-
invocation:
|
|
728
|
+
invocation: On(s.invocation ?? s.initiatedBy),
|
|
716
729
|
entrySurface: this.options.entrySurface,
|
|
717
730
|
content: n,
|
|
718
|
-
pageContent:
|
|
719
|
-
attachments: i.length > 0 ? i.map(
|
|
731
|
+
pageContent: m && rt() || void 0,
|
|
732
|
+
attachments: i.length > 0 ? i.map(Re) : void 0,
|
|
720
733
|
page: o,
|
|
721
734
|
model: this.options.model,
|
|
722
735
|
metadata: Rt(this.options.metadata)
|
|
723
736
|
};
|
|
724
737
|
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = k, this.send(k), this.schedulePendingDeliveryAck(a), a;
|
|
725
738
|
}
|
|
739
|
+
getModel() {
|
|
740
|
+
return this.options.model;
|
|
741
|
+
}
|
|
742
|
+
setModel(e) {
|
|
743
|
+
this.options.model = e;
|
|
744
|
+
}
|
|
726
745
|
retryLastMessage() {
|
|
727
746
|
const e = this.state.sessionId, s = this.retryableClientMessageId;
|
|
728
747
|
if (!s)
|
|
@@ -739,16 +758,16 @@ class zt {
|
|
|
739
758
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
|
|
740
759
|
}
|
|
741
760
|
createLocalAttachment(e) {
|
|
742
|
-
this.options.productVariant === "customer_embedded" &&
|
|
743
|
-
const s =
|
|
761
|
+
this.options.productVariant === "customer_embedded" && Jr(e);
|
|
762
|
+
const s = B(), n = {
|
|
744
763
|
id: s,
|
|
745
764
|
name: e.name || "attachment",
|
|
746
|
-
mimeType:
|
|
765
|
+
mimeType: Qe(e),
|
|
747
766
|
sizeBytes: e.size
|
|
748
767
|
};
|
|
749
768
|
this.attachmentFiles.set(s, e);
|
|
750
769
|
const r = Date.now();
|
|
751
|
-
return
|
|
770
|
+
return Ts({
|
|
752
771
|
attachmentId: s,
|
|
753
772
|
name: n.name,
|
|
754
773
|
mimeType: n.mimeType,
|
|
@@ -759,7 +778,7 @@ class zt {
|
|
|
759
778
|
createdAt: r,
|
|
760
779
|
lastUsedAt: r
|
|
761
780
|
}).catch((i) => {
|
|
762
|
-
|
|
781
|
+
w("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
763
782
|
attachmentId: s,
|
|
764
783
|
name: n.name,
|
|
765
784
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -777,7 +796,7 @@ class zt {
|
|
|
777
796
|
file: e,
|
|
778
797
|
attachment: s
|
|
779
798
|
}) {
|
|
780
|
-
const n = this.state.sessionId, r =
|
|
799
|
+
const n = this.state.sessionId, r = Qe(e), i = {
|
|
781
800
|
sessionId: n ?? void 0,
|
|
782
801
|
attachmentId: s.id,
|
|
783
802
|
clientId: this.options.clientId,
|
|
@@ -792,36 +811,36 @@ class zt {
|
|
|
792
811
|
};
|
|
793
812
|
let o;
|
|
794
813
|
if (this.options.persistAttachmentUpload)
|
|
795
|
-
o = await
|
|
814
|
+
o = await ye(
|
|
796
815
|
() => this.options.persistAttachmentUpload(i, e),
|
|
797
816
|
"Failed to upload attachment"
|
|
798
817
|
);
|
|
799
818
|
else {
|
|
800
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
819
|
+
const l = this.options.prepareAttachmentUpload ? await ye(
|
|
801
820
|
() => this.options.prepareAttachmentUpload(i),
|
|
802
821
|
"Failed to prepare attachment upload"
|
|
803
822
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
804
|
-
await
|
|
805
|
-
const
|
|
823
|
+
await ye(async () => {
|
|
824
|
+
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
806
825
|
method: l.uploadMethod,
|
|
807
826
|
headers: l.uploadHeaders,
|
|
808
827
|
body: e
|
|
809
828
|
});
|
|
810
|
-
if (!
|
|
811
|
-
throw new
|
|
812
|
-
return
|
|
829
|
+
if (!c.ok)
|
|
830
|
+
throw new we("Failed to upload attachment", c.status);
|
|
831
|
+
return c;
|
|
813
832
|
}, "Failed to upload attachment"), o = l;
|
|
814
833
|
}
|
|
815
834
|
this.setState({ sessionId: o.sessionId });
|
|
816
|
-
const a =
|
|
817
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
835
|
+
const a = as(o.attachment, this.options.backendUrl);
|
|
836
|
+
return this.updateAttachmentInState(s.id, a), s.id && Ss(s.id, {
|
|
818
837
|
sessionId: o.sessionId,
|
|
819
838
|
fileUrl: a.fileUrl,
|
|
820
839
|
sandboxPath: a.sandboxPath,
|
|
821
840
|
storageKey: a.storageKey,
|
|
822
841
|
lastUsedAt: Date.now()
|
|
823
842
|
}).catch((l) => {
|
|
824
|
-
|
|
843
|
+
w("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
825
844
|
attachmentId: s.id,
|
|
826
845
|
name: a.name,
|
|
827
846
|
message: l instanceof Error ? l.message : String(l)
|
|
@@ -841,18 +860,18 @@ class zt {
|
|
|
841
860
|
}
|
|
842
861
|
async prepareEmbedAttachmentUpload(e) {
|
|
843
862
|
let s = !1;
|
|
844
|
-
return await
|
|
863
|
+
return await ye(async () => {
|
|
845
864
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
846
865
|
if (n.ok)
|
|
847
866
|
return await n.json();
|
|
848
|
-
if (
|
|
867
|
+
if (hi(n.status) && this.options.tokenProvider && !s) {
|
|
849
868
|
s = !0;
|
|
850
869
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
851
870
|
if (r.ok)
|
|
852
871
|
return await r.json();
|
|
853
|
-
throw new
|
|
872
|
+
throw new we("Failed to prepare attachment upload", r.status);
|
|
854
873
|
}
|
|
855
|
-
throw new
|
|
874
|
+
throw new we("Failed to prepare attachment upload", n.status);
|
|
856
875
|
}, "Failed to prepare attachment upload");
|
|
857
876
|
}
|
|
858
877
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -870,7 +889,7 @@ class zt {
|
|
|
870
889
|
if (!this.state.sessionId)
|
|
871
890
|
return;
|
|
872
891
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
873
|
-
const e =
|
|
892
|
+
const e = vr(
|
|
874
893
|
this.state.messages,
|
|
875
894
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
876
895
|
this.state.assistantDraftRunId,
|
|
@@ -883,7 +902,7 @@ class zt {
|
|
|
883
902
|
stoppedCausalSequence: null,
|
|
884
903
|
toolCallIds: new Set(
|
|
885
904
|
this.state.messages.filter(
|
|
886
|
-
(s) =>
|
|
905
|
+
(s) => je(
|
|
887
906
|
s,
|
|
888
907
|
e.respondsToUserMessageId,
|
|
889
908
|
e.runId
|
|
@@ -893,8 +912,8 @@ class zt {
|
|
|
893
912
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
894
913
|
for (const [s, n] of this.activeBrowserToolCalls)
|
|
895
914
|
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
|
|
896
|
-
|
|
897
|
-
messages:
|
|
915
|
+
Lt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
916
|
+
messages: Dt(
|
|
898
917
|
this.state.messages,
|
|
899
918
|
e.clientMessageId,
|
|
900
919
|
e.runId
|
|
@@ -910,7 +929,7 @@ class zt {
|
|
|
910
929
|
}
|
|
911
930
|
startNewSession(e = {}) {
|
|
912
931
|
const s = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
|
|
913
|
-
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.
|
|
932
|
+
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.options.model = void 0), s && this.send({
|
|
914
933
|
type: "session.reset",
|
|
915
934
|
sessionId: this.state.sessionId ?? void 0,
|
|
916
935
|
warmupId: n ?? void 0,
|
|
@@ -920,8 +939,6 @@ class zt {
|
|
|
920
939
|
starterPrompts: [...this.state.starterPrompts],
|
|
921
940
|
messages: [],
|
|
922
941
|
isLoadingSession: !1,
|
|
923
|
-
isLoadingOlderMessages: !1,
|
|
924
|
-
hasOlderMessages: !1,
|
|
925
942
|
assistantDraft: "",
|
|
926
943
|
assistantDraftItemId: null,
|
|
927
944
|
assistantDraftPhase: null,
|
|
@@ -935,7 +952,7 @@ class zt {
|
|
|
935
952
|
});
|
|
936
953
|
}
|
|
937
954
|
listSessions(e = {}) {
|
|
938
|
-
const s =
|
|
955
|
+
const s = B(), n = new Promise((i, o) => {
|
|
939
956
|
const a = window.setTimeout(() => {
|
|
940
957
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
941
958
|
}, Mt);
|
|
@@ -957,29 +974,27 @@ class zt {
|
|
|
957
974
|
setSessionPinned(e, s) {
|
|
958
975
|
return this.sendSessionMutation(
|
|
959
976
|
this.pendingSessionPinRequests,
|
|
960
|
-
{ type: "session.pin", requestId:
|
|
977
|
+
{ type: "session.pin", requestId: B(), sessionId: e, pinned: s },
|
|
961
978
|
"Session pin did not respond in time"
|
|
962
979
|
);
|
|
963
980
|
}
|
|
964
981
|
renameSession(e, s) {
|
|
965
982
|
return this.sendSessionMutation(
|
|
966
983
|
this.pendingSessionRenameRequests,
|
|
967
|
-
{ type: "session.rename", requestId:
|
|
984
|
+
{ type: "session.rename", requestId: B(), sessionId: e, title: s },
|
|
968
985
|
"Session rename did not respond in time"
|
|
969
986
|
);
|
|
970
987
|
}
|
|
971
988
|
loadSession(e) {
|
|
972
|
-
const s =
|
|
989
|
+
const s = B(), n = this.activeComposerWarmupId;
|
|
973
990
|
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), n && this.send({
|
|
974
991
|
type: "session.reset",
|
|
975
992
|
warmupId: n,
|
|
976
993
|
page: b()
|
|
977
|
-
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.
|
|
994
|
+
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionActivityRequestId = null, this.setState({
|
|
978
995
|
sessionId: e,
|
|
979
996
|
messages: [],
|
|
980
997
|
isLoadingSession: !0,
|
|
981
|
-
isLoadingOlderMessages: !1,
|
|
982
|
-
hasOlderMessages: !1,
|
|
983
998
|
assistantDraft: "",
|
|
984
999
|
assistantDraftItemId: null,
|
|
985
1000
|
assistantDraftPhase: null,
|
|
@@ -998,19 +1013,6 @@ class zt {
|
|
|
998
1013
|
page: b()
|
|
999
1014
|
});
|
|
1000
1015
|
}
|
|
1001
|
-
loadOlderMessages() {
|
|
1002
|
-
if (!this.state.sessionId || !this.sessionItemsCursor || this.state.isLoadingSession || this.state.isLoadingOlderMessages)
|
|
1003
|
-
return;
|
|
1004
|
-
const e = N();
|
|
1005
|
-
this.sessionItemsRequestId = e, this.setState({ isLoadingOlderMessages: !0, lastError: null, lastErrorCode: null }), this.send({
|
|
1006
|
-
type: "session.items.list",
|
|
1007
|
-
requestId: e,
|
|
1008
|
-
sessionId: this.state.sessionId,
|
|
1009
|
-
cursor: this.sessionItemsCursor,
|
|
1010
|
-
limit: 50,
|
|
1011
|
-
page: b()
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
1016
|
canLoadSessionHistoryOverHttp() {
|
|
1015
1017
|
return !this.options.token && !this.options.tokenProvider ? !1 : this.options.productVariant === "customer_embedded" || !!this.options.runtimeCommunityId;
|
|
1016
1018
|
}
|
|
@@ -1019,7 +1021,7 @@ class zt {
|
|
|
1019
1021
|
return;
|
|
1020
1022
|
let r;
|
|
1021
1023
|
try {
|
|
1022
|
-
r = await this.fetchSessionHistoryPageUntilCurrent(e, null, () => this.sessionLoadRequestId === s && this.state.sessionId === e);
|
|
1024
|
+
r = await this.fetchSessionHistoryPageUntilCurrent(e, "transcript", null, () => this.sessionLoadRequestId === s && this.state.sessionId === e);
|
|
1023
1025
|
} catch (o) {
|
|
1024
1026
|
this.failSessionHistoryRequest(s, e, o, !1);
|
|
1025
1027
|
return;
|
|
@@ -1031,16 +1033,17 @@ class zt {
|
|
|
1031
1033
|
type: "conversation.state",
|
|
1032
1034
|
requestId: s,
|
|
1033
1035
|
session: r.session,
|
|
1034
|
-
items: r.items
|
|
1035
|
-
itemsNextCursor: r.nextCursor
|
|
1036
|
+
items: r.items
|
|
1036
1037
|
});
|
|
1037
1038
|
for (const o of i)
|
|
1038
1039
|
this.handleServerEvent(o);
|
|
1039
|
-
|
|
1040
|
+
window.setTimeout(() => {
|
|
1041
|
+
this.autoLoadSessionActivity(e);
|
|
1042
|
+
}, 0);
|
|
1040
1043
|
}
|
|
1041
1044
|
subscribeToSessionBeforeHistory(e) {
|
|
1042
1045
|
this.pendingSessionSubscription?.resolve(!1);
|
|
1043
|
-
const s =
|
|
1046
|
+
const s = B(), n = new Promise((r) => {
|
|
1044
1047
|
this.pendingSessionSubscription = { requestId: s, sessionId: e, resolve: r };
|
|
1045
1048
|
});
|
|
1046
1049
|
return this.send({
|
|
@@ -1051,67 +1054,68 @@ class zt {
|
|
|
1051
1054
|
subscribeOnly: !0
|
|
1052
1055
|
}), n;
|
|
1053
1056
|
}
|
|
1054
|
-
async
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1057
|
+
async autoLoadSessionActivity(e) {
|
|
1058
|
+
let s = null;
|
|
1059
|
+
do {
|
|
1060
|
+
const n = B();
|
|
1061
|
+
this.sessionActivityRequestId = n;
|
|
1058
1062
|
let r;
|
|
1059
1063
|
try {
|
|
1060
|
-
r = await this.fetchSessionHistoryPageUntilCurrent(e, s, () => this.state.sessionId === e && this.
|
|
1064
|
+
r = await this.fetchSessionHistoryPageUntilCurrent(e, "activity", s, () => this.state.sessionId === e && this.sessionActivityRequestId === n);
|
|
1061
1065
|
} catch (i) {
|
|
1062
1066
|
this.failSessionHistoryRequest(n, e, i, !0);
|
|
1063
1067
|
return;
|
|
1064
1068
|
}
|
|
1065
|
-
if (!r || this.state.sessionId !== e || this.
|
|
1069
|
+
if (!r || this.state.sessionId !== e || this.sessionActivityRequestId !== n)
|
|
1066
1070
|
return;
|
|
1067
1071
|
this.handleServerEvent({
|
|
1068
|
-
type: "session.
|
|
1072
|
+
type: "session.activity.page",
|
|
1069
1073
|
requestId: n,
|
|
1070
1074
|
sessionId: e,
|
|
1071
1075
|
items: r.items,
|
|
1072
1076
|
nextCursor: r.nextCursor
|
|
1073
|
-
});
|
|
1074
|
-
}
|
|
1077
|
+
}), s = r.nextCursor;
|
|
1078
|
+
} while (this.state.sessionId === e && s !== null);
|
|
1075
1079
|
}
|
|
1076
|
-
async fetchSessionHistoryPageUntilCurrent(e, s, n) {
|
|
1077
|
-
let
|
|
1078
|
-
for (;
|
|
1080
|
+
async fetchSessionHistoryPageUntilCurrent(e, s, n, r) {
|
|
1081
|
+
let i = 500;
|
|
1082
|
+
for (; r(); )
|
|
1079
1083
|
try {
|
|
1080
|
-
const
|
|
1081
|
-
if (!
|
|
1082
|
-
throw new
|
|
1083
|
-
this.token =
|
|
1084
|
-
const
|
|
1085
|
-
s &&
|
|
1086
|
-
let
|
|
1087
|
-
this.options.productVariant === "customer_embedded" ? (
|
|
1088
|
-
const
|
|
1084
|
+
const o = this.options.token ?? await this.options.tokenProvider?.() ?? this.token;
|
|
1085
|
+
if (!o)
|
|
1086
|
+
throw new pe("Product Agent history requires authentication");
|
|
1087
|
+
this.token = o;
|
|
1088
|
+
const a = new URLSearchParams();
|
|
1089
|
+
s === "activity" && a.set("limit", "200"), n && a.set("cursor", n);
|
|
1090
|
+
let l, c;
|
|
1091
|
+
this.options.productVariant === "customer_embedded" ? (a.set("client_id", this.options.clientId), a.set("transport_id", this.transportIdentity.transportId), l = `/api/product-agent/embed/sessions/${encodeURIComponent(e)}/history${s === "activity" ? "/activity" : ""}`, c = `Bearer ${o}`) : (a.set("community_id", this.options.runtimeCommunityId ?? ""), this.options.automationRunId && a.set("automation_run_id", this.options.automationRunId), l = `/api/product-agent/runtime/sessions/${encodeURIComponent(e)}/history${s === "activity" ? "/activity" : ""}`, c = o);
|
|
1092
|
+
const d = await fetch(new URL(`${l}?${a.toString()}`, this.options.backendUrl), {
|
|
1089
1093
|
method: "GET",
|
|
1090
1094
|
cache: "no-store",
|
|
1091
|
-
headers: { authorization:
|
|
1095
|
+
headers: { authorization: c },
|
|
1092
1096
|
signal: AbortSignal.timeout(15e3)
|
|
1093
1097
|
});
|
|
1094
|
-
if (!
|
|
1095
|
-
const
|
|
1096
|
-
throw
|
|
1098
|
+
if (!d.ok) {
|
|
1099
|
+
const y = await d.text() || `History request failed (${d.status})`;
|
|
1100
|
+
throw Xs(d.status) ? new Error(y) : new pe(y);
|
|
1097
1101
|
}
|
|
1098
|
-
const
|
|
1099
|
-
if (!
|
|
1100
|
-
throw new
|
|
1102
|
+
const h = await d.json();
|
|
1103
|
+
if (!h?.session || !Array.isArray(h.items))
|
|
1104
|
+
throw new pe("Invalid Product Agent session history response");
|
|
1101
1105
|
return {
|
|
1102
|
-
session:
|
|
1103
|
-
items:
|
|
1104
|
-
nextCursor: typeof
|
|
1106
|
+
session: h.session,
|
|
1107
|
+
items: h.items,
|
|
1108
|
+
nextCursor: typeof h.nextCursor == "string" ? h.nextCursor : null
|
|
1105
1109
|
};
|
|
1106
|
-
} catch (
|
|
1107
|
-
if (
|
|
1108
|
-
throw
|
|
1109
|
-
|
|
1110
|
+
} catch (o) {
|
|
1111
|
+
if (o instanceof pe)
|
|
1112
|
+
throw o;
|
|
1113
|
+
w("web-sdk.history", "HTTP session history page failed; retrying", {
|
|
1110
1114
|
sessionId: e,
|
|
1111
|
-
hasCursor: !!
|
|
1112
|
-
retryDelayMs:
|
|
1113
|
-
message:
|
|
1114
|
-
}), await new Promise((
|
|
1115
|
+
hasCursor: !!n,
|
|
1116
|
+
retryDelayMs: i,
|
|
1117
|
+
message: o instanceof Error ? o.message : String(o)
|
|
1118
|
+
}), await new Promise((a) => window.setTimeout(a, i)), i = Math.min(i * 2, 5e3);
|
|
1115
1119
|
}
|
|
1116
1120
|
return null;
|
|
1117
1121
|
}
|
|
@@ -1119,22 +1123,28 @@ class zt {
|
|
|
1119
1123
|
if (this.state.sessionId !== s)
|
|
1120
1124
|
return;
|
|
1121
1125
|
const i = n instanceof Error ? n.message : String(n);
|
|
1126
|
+
if (r) {
|
|
1127
|
+
this.sessionActivityRequestId = null, w("web-sdk.history", "Background session activity hydration stopped", {
|
|
1128
|
+
sessionId: s,
|
|
1129
|
+
message: i
|
|
1130
|
+
});
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1122
1133
|
this.handleServerEvent({
|
|
1123
1134
|
type: "error",
|
|
1124
1135
|
code: "history_load_failed",
|
|
1125
1136
|
message: i,
|
|
1126
1137
|
requestId: e,
|
|
1127
1138
|
sessionId: s
|
|
1128
|
-
}),
|
|
1139
|
+
}), w("web-sdk.history", "HTTP session history page failed permanently", {
|
|
1129
1140
|
sessionId: s,
|
|
1130
|
-
olderMessages: r,
|
|
1131
1141
|
message: i
|
|
1132
1142
|
});
|
|
1133
1143
|
}
|
|
1134
1144
|
send(e) {
|
|
1135
|
-
this.sendNow(
|
|
1145
|
+
this.sendNow(L(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
1136
1146
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
1137
|
-
) || this.queuedClientEvents.push(e),
|
|
1147
|
+
) || this.queuedClientEvents.push(e), K(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
1138
1148
|
status: "reconnecting",
|
|
1139
1149
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
1140
1150
|
}), this.scheduleReconnect());
|
|
@@ -1150,9 +1160,9 @@ class zt {
|
|
|
1150
1160
|
return !1;
|
|
1151
1161
|
const s = this.socket;
|
|
1152
1162
|
try {
|
|
1153
|
-
return s.send(JSON.stringify(e)),
|
|
1163
|
+
return s.send(JSON.stringify(e)), Be("client_event", e.type, gt(e)), !0;
|
|
1154
1164
|
} catch (n) {
|
|
1155
|
-
return
|
|
1165
|
+
return w("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1156
1166
|
message: n instanceof Error ? n.message : String(n),
|
|
1157
1167
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1158
1168
|
isThinking: this.state.isThinking
|
|
@@ -1184,7 +1194,7 @@ class zt {
|
|
|
1184
1194
|
}
|
|
1185
1195
|
}));
|
|
1186
1196
|
} catch (r) {
|
|
1187
|
-
|
|
1197
|
+
w("web-sdk.agent", "Pluno health signal send failed", {
|
|
1188
1198
|
name: e,
|
|
1189
1199
|
message: r instanceof Error ? r.message : String(r)
|
|
1190
1200
|
});
|
|
@@ -1194,9 +1204,9 @@ class zt {
|
|
|
1194
1204
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
1195
1205
|
return;
|
|
1196
1206
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
1197
|
-
const e =
|
|
1207
|
+
const e = Bn();
|
|
1198
1208
|
this.sendNow(
|
|
1199
|
-
|
|
1209
|
+
L({
|
|
1200
1210
|
type: "starter_prompts.page_context",
|
|
1201
1211
|
pageUrl: e.pageUrl,
|
|
1202
1212
|
pageTitle: e.pageTitle,
|
|
@@ -1205,13 +1215,13 @@ class zt {
|
|
|
1205
1215
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
1206
1216
|
}
|
|
1207
1217
|
startStarterPromptUrlWatcher() {
|
|
1208
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
1218
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = Wn(() => this.handleStarterPromptUrlChange()));
|
|
1209
1219
|
}
|
|
1210
1220
|
handleStarterPromptUrlChange() {
|
|
1211
1221
|
const e = location.href;
|
|
1212
1222
|
e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
1213
1223
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
1214
|
-
},
|
|
1224
|
+
}, gn));
|
|
1215
1225
|
}
|
|
1216
1226
|
refreshStarterPromptsForCurrentUrl() {
|
|
1217
1227
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -1226,18 +1236,18 @@ class zt {
|
|
|
1226
1236
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
1227
1237
|
return;
|
|
1228
1238
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
1229
|
-
|
|
1239
|
+
K(this.options.clientId, this.queuedClientEvents);
|
|
1230
1240
|
for (let s = 0; s < e.length; s += 1) {
|
|
1231
1241
|
const n = e[s];
|
|
1232
|
-
if (!this.sendNow(
|
|
1233
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1242
|
+
if (!this.sendNow(L(n))) {
|
|
1243
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), K(this.options.clientId, this.queuedClientEvents);
|
|
1234
1244
|
return;
|
|
1235
1245
|
}
|
|
1236
|
-
|
|
1246
|
+
K(this.options.clientId, this.queuedClientEvents);
|
|
1237
1247
|
}
|
|
1238
1248
|
}
|
|
1239
1249
|
resetForAuthenticationScopeChange() {
|
|
1240
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
1250
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], K(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear();
|
|
1241
1251
|
}
|
|
1242
1252
|
flushPendingWidgetLifecycleEvents() {
|
|
1243
1253
|
if (this.authenticatedSocket !== this.socket || this.socket?.readyState !== WebSocket.OPEN || this.pendingWidgetLifecycleEvents.length === 0)
|
|
@@ -1258,8 +1268,8 @@ class zt {
|
|
|
1258
1268
|
return;
|
|
1259
1269
|
this.clearPendingWarmupAckTimer();
|
|
1260
1270
|
const s = Math.min(
|
|
1261
|
-
|
|
1262
|
-
|
|
1271
|
+
sn * 2 ** e.retryAttempt,
|
|
1272
|
+
nn
|
|
1263
1273
|
);
|
|
1264
1274
|
e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
|
|
1265
1275
|
this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
|
|
@@ -1272,26 +1282,26 @@ class zt {
|
|
|
1272
1282
|
return [...this.stoppedTurns].reverse().find((o) => o.sessionId !== e ? !1 : r && o.respondsToUserMessageId ? r === o.respondsToUserMessageId : n && o.clientMessageId ? n === o.clientMessageId : !!(i && o.runId && i === o.runId)) ?? null;
|
|
1273
1283
|
}
|
|
1274
1284
|
findStoppedTurnForEvent(e) {
|
|
1275
|
-
const s = e.type === "session.item" ?
|
|
1285
|
+
const s = e.type === "session.item" ? U(e.item) : null;
|
|
1276
1286
|
return this.findStoppedTurn(
|
|
1277
1287
|
oe(e) ?? this.state.sessionId,
|
|
1278
1288
|
s ?? e
|
|
1279
1289
|
);
|
|
1280
1290
|
}
|
|
1281
1291
|
rememberDurablyStoppedTurn(e, s, n) {
|
|
1282
|
-
if (!e || !s || !
|
|
1292
|
+
if (!e || !s || !Se(s) || this.findStoppedTurn(e, s))
|
|
1283
1293
|
return;
|
|
1284
|
-
const r =
|
|
1294
|
+
const r = N(s), i = C(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1285
1295
|
this.stoppedTurns.push({
|
|
1286
1296
|
sessionId: e,
|
|
1287
1297
|
clientMessageId: o,
|
|
1288
1298
|
respondsToUserMessageId: r,
|
|
1289
1299
|
runId: i,
|
|
1290
1300
|
stoppedAt: n,
|
|
1291
|
-
stoppedCausalSequence:
|
|
1301
|
+
stoppedCausalSequence: D(s),
|
|
1292
1302
|
toolCallIds: new Set(
|
|
1293
1303
|
this.state.messages.filter(
|
|
1294
|
-
(a) =>
|
|
1304
|
+
(a) => je(a, r, i)
|
|
1295
1305
|
).map((a) => a.callId).filter((a) => typeof a == "string")
|
|
1296
1306
|
)
|
|
1297
1307
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
@@ -1301,26 +1311,26 @@ class zt {
|
|
|
1301
1311
|
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1302
1312
|
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1303
1313
|
}
|
|
1304
|
-
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !
|
|
1314
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !Se(U(e.item)) : e.type !== "conversation.state" : !1;
|
|
1305
1315
|
}
|
|
1306
1316
|
filterStoppedSnapshotItems(e, s) {
|
|
1307
1317
|
return e.filter((n) => {
|
|
1308
|
-
const r =
|
|
1309
|
-
if (!i || r?.type === "message" && r.role === "user" ||
|
|
1318
|
+
const r = U(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1319
|
+
if (!i || r?.type === "message" && r.role === "user" || Se(r))
|
|
1310
1320
|
return !0;
|
|
1311
1321
|
if (i.stoppedCausalSequence !== null) {
|
|
1312
|
-
const o = r ?
|
|
1322
|
+
const o = r ? D(r) : null;
|
|
1313
1323
|
return o === null || o <= i.stoppedCausalSequence;
|
|
1314
1324
|
}
|
|
1315
1325
|
if (i.stoppedAt) {
|
|
1316
|
-
const o =
|
|
1326
|
+
const o = M(n, "createdAt");
|
|
1317
1327
|
return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
|
|
1318
1328
|
}
|
|
1319
1329
|
return !1;
|
|
1320
1330
|
});
|
|
1321
1331
|
}
|
|
1322
1332
|
handleServerEvent(e) {
|
|
1323
|
-
if (
|
|
1333
|
+
if (Be("server_event", e.type, gt(e)), e.type === "session.subscribed") {
|
|
1324
1334
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1325
1335
|
if (s && n && s === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
|
|
1326
1336
|
const r = this.pendingSessionSubscription;
|
|
@@ -1338,9 +1348,9 @@ class zt {
|
|
|
1338
1348
|
return;
|
|
1339
1349
|
}
|
|
1340
1350
|
if (e.type === "session.item" && this.rememberDurablyStoppedTurn(
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1351
|
+
M(e.item, "sessionId") ?? this.state.sessionId,
|
|
1352
|
+
U(e.item),
|
|
1353
|
+
M(e.item, "createdAt")
|
|
1344
1354
|
), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1345
1355
|
if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
|
|
1346
1356
|
this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
|
|
@@ -1376,22 +1386,22 @@ class zt {
|
|
|
1376
1386
|
this.activeResponseRunId = s, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
|
|
1377
1387
|
return;
|
|
1378
1388
|
}
|
|
1379
|
-
if (
|
|
1389
|
+
if (Tn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
1380
1390
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
1381
|
-
const s =
|
|
1391
|
+
const s = tr(e.user);
|
|
1382
1392
|
this.authenticatedSocket !== this.socket && this.authenticatedUserId && s && s.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = s?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
1383
|
-
const n =
|
|
1384
|
-
|
|
1393
|
+
const n = Jn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1394
|
+
w("web-sdk.agent", "Received auth.ok appearance", {
|
|
1385
1395
|
hasAppearance: r,
|
|
1386
1396
|
rawAppearance: e.appearance,
|
|
1387
1397
|
normalizedAppearance: n
|
|
1388
|
-
}), this.runtimeHelperJavascript =
|
|
1398
|
+
}), this.runtimeHelperJavascript = Yn(e.runtimeHelpers)?.javascript ?? null;
|
|
1389
1399
|
const i = bt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1390
1400
|
user: s,
|
|
1391
1401
|
status: "connected",
|
|
1392
1402
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1393
1403
|
};
|
|
1394
|
-
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !
|
|
1404
|
+
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !ge() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1395
1405
|
type: "page.upsert",
|
|
1396
1406
|
sessionId: this.state.sessionId,
|
|
1397
1407
|
page: b(),
|
|
@@ -1407,138 +1417,131 @@ class zt {
|
|
|
1407
1417
|
return;
|
|
1408
1418
|
}
|
|
1409
1419
|
if (e.type === "conversation.state") {
|
|
1410
|
-
const s = Array.isArray(e.items) ? e.items : [], n =
|
|
1411
|
-
if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && n !== this.state.sessionId)
|
|
1420
|
+
const s = Array.isArray(e.items) ? e.items : [], n = M(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null, i = this.state.isLoadingSession && this.sessionLoadRequestId === null && r === null && n === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
|
|
1421
|
+
if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && this.sessionLoadRequestId !== null && r === null || this.state.isLoadingSession && n !== this.state.sessionId)
|
|
1412
1422
|
return;
|
|
1413
|
-
n === this.state.sessionId &&
|
|
1423
|
+
this.updatePersonalModelFromSession(e.session), n === this.state.sessionId && this.clearSessionLoadRequest();
|
|
1414
1424
|
for (const E of s)
|
|
1415
1425
|
this.rememberDurablyStoppedTurn(
|
|
1416
1426
|
n,
|
|
1417
|
-
|
|
1418
|
-
|
|
1427
|
+
U(E),
|
|
1428
|
+
M(E, "createdAt")
|
|
1419
1429
|
);
|
|
1420
|
-
const
|
|
1421
|
-
clientMessageId:
|
|
1422
|
-
respondsToUserMessageId:
|
|
1423
|
-
runId:
|
|
1424
|
-
}),
|
|
1425
|
-
|
|
1426
|
-
let
|
|
1430
|
+
const o = Z(s), a = o === null ? null : s[o], l = U(a), c = this.findStoppedTurn(n, {
|
|
1431
|
+
clientMessageId: l?.clientMessageId,
|
|
1432
|
+
respondsToUserMessageId: M(a, "id"),
|
|
1433
|
+
runId: l?.runId
|
|
1434
|
+
}), d = this.filterStoppedSnapshotItems(s, n), h = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, y = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, f = e.isRetrying === !0, u = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1435
|
+
h && y && (this.pendingClientMessageId = y);
|
|
1436
|
+
let p = cr(
|
|
1427
1437
|
e.assistantDraft
|
|
1428
1438
|
);
|
|
1429
|
-
|
|
1430
|
-
respondsToUserMessageId:
|
|
1431
|
-
runId:
|
|
1432
|
-
}) && (
|
|
1433
|
-
const
|
|
1434
|
-
this.rememberUserMessageClientMessageIds(
|
|
1435
|
-
const
|
|
1436
|
-
if (
|
|
1437
|
-
const E =
|
|
1438
|
-
this.retryAttemptsByClientMessageId[
|
|
1439
|
-
this.retryAttemptsByClientMessageId[
|
|
1439
|
+
p && this.findStoppedTurn(n, {
|
|
1440
|
+
respondsToUserMessageId: p.respondsToUserMessageId,
|
|
1441
|
+
runId: p.runId
|
|
1442
|
+
}) && (p = void 0);
|
|
1443
|
+
const g = p !== void 0;
|
|
1444
|
+
this.rememberUserMessageClientMessageIds(d);
|
|
1445
|
+
const m = kr(d);
|
|
1446
|
+
if (m) {
|
|
1447
|
+
const E = Cr(d, m);
|
|
1448
|
+
this.retryAttemptsByClientMessageId[m] = Math.max(
|
|
1449
|
+
this.retryAttemptsByClientMessageId[m] ?? 0,
|
|
1440
1450
|
E
|
|
1441
1451
|
);
|
|
1442
1452
|
}
|
|
1443
|
-
const
|
|
1444
|
-
const
|
|
1445
|
-
return Ut(
|
|
1446
|
-
}),
|
|
1453
|
+
const k = d.filter((E) => {
|
|
1454
|
+
const q = U(E);
|
|
1455
|
+
return Ut(q) ? !1 : !q || !m || !Ae(q) ? !0 : Je(d, q) !== m;
|
|
1456
|
+
}), S = Yt(
|
|
1447
1457
|
this.state.messages,
|
|
1448
|
-
_t(
|
|
1449
|
-
),
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
) : k, w = Pt(m), U = h ? c?.content ?? "" : this.state.assistantDraft, D = h ? c?.itemId ?? null : this.state.assistantDraftItemId, R = h ? c?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, ee = h ? c?.runId ?? null : this.state.assistantDraftRunId, C = u.some(
|
|
1454
|
-
(E, O) => Dt(
|
|
1455
|
-
P(E),
|
|
1456
|
-
U,
|
|
1457
|
-
D,
|
|
1458
|
+
_t(k, this.options.backendUrl)
|
|
1459
|
+
), _ = Pt(S), v = g ? p?.content ?? "" : this.state.assistantDraft, R = g ? p?.itemId ?? null : this.state.assistantDraftItemId, ee = g ? p?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, P = g ? p?.runId ?? null : this.state.assistantDraftRunId, F = d.some(
|
|
1460
|
+
(E, q) => vt(
|
|
1461
|
+
U(E),
|
|
1462
|
+
v,
|
|
1458
1463
|
R,
|
|
1459
1464
|
ee,
|
|
1460
|
-
|
|
1465
|
+
P,
|
|
1466
|
+
br(d, q)
|
|
1461
1467
|
)
|
|
1462
|
-
),
|
|
1463
|
-
if (!
|
|
1468
|
+
), X = g ? p?.content ?? "" : this.state.assistantDraft, te = !!p?.content && !F, O = _ && (!X || F), ce = Ar(S), z = O && ce ? "completed" : c ? "stopped" : O ? "failed" : null;
|
|
1469
|
+
if (!_ && Er(this.state.messages, d))
|
|
1464
1470
|
return;
|
|
1465
|
-
this.lastUserMessagePageUrl =
|
|
1466
|
-
const
|
|
1467
|
-
if (this.latestRecoverableClientMessageId =
|
|
1468
|
-
sessionId:
|
|
1469
|
-
messages:
|
|
1471
|
+
this.lastUserMessagePageUrl = Rr(d);
|
|
1472
|
+
const x = O || c ? null : Xe(d);
|
|
1473
|
+
if (this.latestRecoverableClientMessageId = x, ce && this.clearRetryTimers(), this.setState({
|
|
1474
|
+
sessionId: M(e.session, "id") ?? this.state.sessionId,
|
|
1475
|
+
messages: S,
|
|
1470
1476
|
isLoadingSession: !1,
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
...
|
|
1475
|
-
|
|
1476
|
-
...V && this.state.taskStatus === "working" ? { taskStatus: V } : {},
|
|
1477
|
-
...C ? {
|
|
1477
|
+
...h ? { pendingMessageStatus: h } : {},
|
|
1478
|
+
...u ? { turnPhase: u } : {},
|
|
1479
|
+
isRetrying: f,
|
|
1480
|
+
...z && this.state.taskStatus === "working" ? { taskStatus: z } : {},
|
|
1481
|
+
...F ? {
|
|
1478
1482
|
assistantDraft: "",
|
|
1479
1483
|
assistantDraftItemId: null,
|
|
1480
1484
|
assistantDraftPhase: null,
|
|
1481
1485
|
assistantDraftRespondsToUserMessageId: null,
|
|
1482
1486
|
assistantDraftRunId: null
|
|
1483
|
-
} :
|
|
1484
|
-
assistantDraft:
|
|
1485
|
-
assistantDraftItemId:
|
|
1486
|
-
assistantDraftPhase:
|
|
1487
|
-
assistantDraftRespondsToUserMessageId:
|
|
1488
|
-
assistantDraftRunId:
|
|
1487
|
+
} : g ? {
|
|
1488
|
+
assistantDraft: p?.content ?? "",
|
|
1489
|
+
assistantDraftItemId: p?.itemId ?? null,
|
|
1490
|
+
assistantDraftPhase: p?.phase ?? null,
|
|
1491
|
+
assistantDraftRespondsToUserMessageId: p?.respondsToUserMessageId ?? null,
|
|
1492
|
+
assistantDraftRunId: p?.runId ?? null
|
|
1489
1493
|
} : {},
|
|
1490
|
-
...
|
|
1494
|
+
...te ? {
|
|
1491
1495
|
isThinking: !0,
|
|
1492
1496
|
turnPhase: "thinking",
|
|
1493
1497
|
lastError: null
|
|
1494
|
-
} :
|
|
1498
|
+
} : O ? {
|
|
1495
1499
|
isThinking: !1,
|
|
1496
1500
|
status: "connected",
|
|
1497
1501
|
lastError: null,
|
|
1498
1502
|
lastErrorCode: null,
|
|
1499
1503
|
lastErrorSecuritySettingsUrl: null
|
|
1500
|
-
} :
|
|
1504
|
+
} : x ? {
|
|
1501
1505
|
isThinking: !0,
|
|
1502
|
-
turnPhase:
|
|
1506
|
+
turnPhase: u ?? this.state.turnPhase ?? "starting",
|
|
1503
1507
|
lastError: null
|
|
1504
1508
|
} : {}
|
|
1505
|
-
}),
|
|
1509
|
+
}), O)
|
|
1506
1510
|
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1507
|
-
else if (!
|
|
1508
|
-
if (
|
|
1509
|
-
this.activeClientMessageId =
|
|
1510
|
-
const E = Z(
|
|
1511
|
-
this.activeResponseUserMessageId =
|
|
1511
|
+
else if (!c && (te || x)) {
|
|
1512
|
+
if (x) {
|
|
1513
|
+
this.activeClientMessageId = x;
|
|
1514
|
+
const E = Z(d), q = E === null ? null : d[E];
|
|
1515
|
+
this.activeResponseUserMessageId = M(q, "id");
|
|
1512
1516
|
}
|
|
1513
1517
|
this.markThinkingProgress();
|
|
1514
1518
|
}
|
|
1515
|
-
if (
|
|
1516
|
-
const E =
|
|
1517
|
-
E && this.retryAfterInterruptedRun(E,
|
|
1519
|
+
if (m) {
|
|
1520
|
+
const E = M(e.session, "id") ?? this.state.sessionId;
|
|
1521
|
+
E && this.retryAfterInterruptedRun(E, m);
|
|
1518
1522
|
}
|
|
1523
|
+
i && n && window.setTimeout(() => {
|
|
1524
|
+
this.autoLoadSessionActivity(n);
|
|
1525
|
+
}, 0);
|
|
1519
1526
|
return;
|
|
1520
1527
|
}
|
|
1521
|
-
if (e.type === "session.
|
|
1528
|
+
if (e.type === "session.activity.page") {
|
|
1522
1529
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1523
|
-
if (!s ||
|
|
1530
|
+
if (!s || n !== this.state.sessionId)
|
|
1524
1531
|
return;
|
|
1525
1532
|
const r = _t(
|
|
1526
1533
|
Array.isArray(e.items) ? e.items : [],
|
|
1527
1534
|
this.options.backendUrl
|
|
1528
|
-
)
|
|
1529
|
-
|
|
1530
|
-
this.
|
|
1531
|
-
this.sessionItemsRequestId = null, this.sessionItemsCursor = typeof e.nextCursor == "string" ? e.nextCursor : null, this.hasLoadedOlderSessionItems = !0, this.setState({
|
|
1532
|
-
messages: [...r, ...this.state.messages.filter((o) => !i.has(o.id))],
|
|
1533
|
-
isLoadingOlderMessages: !1,
|
|
1534
|
-
hasOlderMessages: this.sessionItemsCursor !== null
|
|
1535
|
+
);
|
|
1536
|
+
s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
1537
|
+
messages: yr(this.state.messages, r)
|
|
1535
1538
|
});
|
|
1536
1539
|
return;
|
|
1537
1540
|
}
|
|
1538
1541
|
if (e.type === "sessions.page") {
|
|
1539
1542
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1540
1543
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1541
|
-
sessions:
|
|
1544
|
+
sessions: sr(e.sessions),
|
|
1542
1545
|
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1543
1546
|
}));
|
|
1544
1547
|
return;
|
|
@@ -1553,21 +1556,21 @@ class zt {
|
|
|
1553
1556
|
}
|
|
1554
1557
|
if (e.type === "session.updated") {
|
|
1555
1558
|
this.clearRunAckResyncRetryTimer();
|
|
1556
|
-
const s =
|
|
1559
|
+
const s = M(e.session, "id");
|
|
1557
1560
|
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1558
1561
|
...this.pendingComposerWarmup.event,
|
|
1559
1562
|
sessionId: s
|
|
1560
|
-
}, this.pendingComposerWarmup.scope = `${s}:${this.pendingComposerWarmup.event.page.url}`), this.setState({ sessionId: s ?? this.state.sessionId });
|
|
1563
|
+
}, this.pendingComposerWarmup.scope = `${s}:${this.pendingComposerWarmup.event.page.url}`), this.setState({ sessionId: s ?? this.state.sessionId }), this.updatePersonalModelFromSession(e.session);
|
|
1561
1564
|
const n = e.session && typeof e.session == "object" ? e.session.metadata : null;
|
|
1562
1565
|
typeof e.warmupId == "string" && e.warmupId === this.activeComposerWarmupId && n && typeof n == "object" && n.composerPreload && this.clearPendingComposerWarmup();
|
|
1563
1566
|
return;
|
|
1564
1567
|
}
|
|
1565
1568
|
if (e.type === "session.item") {
|
|
1566
1569
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1567
|
-
const s =
|
|
1568
|
-
if (
|
|
1570
|
+
const s = U(e.item);
|
|
1571
|
+
if (Ae(s)) {
|
|
1569
1572
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1570
|
-
const r =
|
|
1573
|
+
const r = M(e.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1571
1574
|
if (r && a) {
|
|
1572
1575
|
this.retryAfterInterruptedRun(r, a);
|
|
1573
1576
|
return;
|
|
@@ -1581,19 +1584,19 @@ class zt {
|
|
|
1581
1584
|
return;
|
|
1582
1585
|
const n = Jt(e.item, this.options.backendUrl);
|
|
1583
1586
|
if (n) {
|
|
1584
|
-
const r =
|
|
1585
|
-
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
1586
|
-
const o =
|
|
1587
|
+
const r = Dr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1588
|
+
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), H(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Pr(s) && this.clearRunAckResyncRetryTimer();
|
|
1589
|
+
const o = Ve(this.state.messages, n), a = Pt(o), l = vt(
|
|
1587
1590
|
s,
|
|
1588
1591
|
this.state.assistantDraft,
|
|
1589
1592
|
this.state.assistantDraftItemId,
|
|
1590
1593
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1591
1594
|
this.state.assistantDraftRunId,
|
|
1592
|
-
|
|
1595
|
+
ss(
|
|
1593
1596
|
o,
|
|
1594
|
-
o.findIndex((
|
|
1597
|
+
o.findIndex((h) => h.id === n.id)
|
|
1595
1598
|
)
|
|
1596
|
-
),
|
|
1599
|
+
), c = a && (!this.state.assistantDraft || l), d = Me(n) && (c || H(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
1597
1600
|
this.setState({
|
|
1598
1601
|
messages: o,
|
|
1599
1602
|
...l ? {
|
|
@@ -1603,7 +1606,7 @@ class zt {
|
|
|
1603
1606
|
assistantDraftRespondsToUserMessageId: null,
|
|
1604
1607
|
assistantDraftRunId: null
|
|
1605
1608
|
} : {},
|
|
1606
|
-
...
|
|
1609
|
+
...c ? {
|
|
1607
1610
|
isThinking: !1,
|
|
1608
1611
|
...r && this.state.taskStatus === "working" ? { taskStatus: r } : {},
|
|
1609
1612
|
isRetrying: !1
|
|
@@ -1614,15 +1617,15 @@ class zt {
|
|
|
1614
1617
|
lastErrorCode: null,
|
|
1615
1618
|
lastErrorSecuritySettingsUrl: null
|
|
1616
1619
|
} : {}
|
|
1617
|
-
}),
|
|
1620
|
+
}), c && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
1618
1621
|
}
|
|
1619
1622
|
return;
|
|
1620
1623
|
}
|
|
1621
1624
|
if (e.type === "chat.assistant_delta") {
|
|
1622
1625
|
this.clearRunAckResyncRetryTimer();
|
|
1623
|
-
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((
|
|
1624
|
-
this.activeClientMessageId && (this.activeResponseUserMessageId =
|
|
1625
|
-
messages:
|
|
1626
|
+
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((h) => h.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, d = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1627
|
+
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = d), this.setState({
|
|
1628
|
+
messages: Ve(this.state.messages, {
|
|
1626
1629
|
id: o,
|
|
1627
1630
|
role: "assistant",
|
|
1628
1631
|
content: i,
|
|
@@ -1630,13 +1633,13 @@ class zt {
|
|
|
1630
1633
|
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1631
1634
|
dataType: "assistant_draft",
|
|
1632
1635
|
...l ? { phase: l } : {},
|
|
1633
|
-
...
|
|
1636
|
+
...c ? { respondsToUserMessageId: c } : {},
|
|
1634
1637
|
...d ? { runId: d } : {}
|
|
1635
1638
|
}),
|
|
1636
1639
|
assistantDraft: i,
|
|
1637
1640
|
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1638
1641
|
assistantDraftPhase: l,
|
|
1639
|
-
assistantDraftRespondsToUserMessageId:
|
|
1642
|
+
assistantDraftRespondsToUserMessageId: c,
|
|
1640
1643
|
assistantDraftRunId: d,
|
|
1641
1644
|
isThinking: !0,
|
|
1642
1645
|
taskStatus: "working",
|
|
@@ -1651,21 +1654,21 @@ class zt {
|
|
|
1651
1654
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null;
|
|
1652
1655
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1653
1656
|
return;
|
|
1654
|
-
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l =
|
|
1657
|
+
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = _s(
|
|
1655
1658
|
this.state.messages.filter(
|
|
1656
|
-
(
|
|
1657
|
-
|
|
1659
|
+
(c) => c.dataType !== "assistant_draft" || !je(
|
|
1660
|
+
c,
|
|
1658
1661
|
n,
|
|
1659
1662
|
r
|
|
1660
1663
|
)
|
|
1661
1664
|
),
|
|
1662
1665
|
n,
|
|
1663
1666
|
r,
|
|
1664
|
-
|
|
1667
|
+
Qt
|
|
1665
1668
|
);
|
|
1666
1669
|
this.setState({
|
|
1667
1670
|
sessionId: s,
|
|
1668
|
-
messages:
|
|
1671
|
+
messages: pr(
|
|
1669
1672
|
l,
|
|
1670
1673
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
1671
1674
|
n,
|
|
@@ -1688,9 +1691,9 @@ class zt {
|
|
|
1688
1691
|
if (s)
|
|
1689
1692
|
this.nonTranscriptToolCallIds.add(s);
|
|
1690
1693
|
else {
|
|
1691
|
-
const n =
|
|
1694
|
+
const n = fr(e);
|
|
1692
1695
|
if (n) {
|
|
1693
|
-
const r =
|
|
1696
|
+
const r = hr(
|
|
1694
1697
|
this.state.messages,
|
|
1695
1698
|
n
|
|
1696
1699
|
);
|
|
@@ -1729,13 +1732,6 @@ class zt {
|
|
|
1729
1732
|
});
|
|
1730
1733
|
return;
|
|
1731
1734
|
}
|
|
1732
|
-
if (s && s === this.sessionItemsRequestId) {
|
|
1733
|
-
this.sessionItemsRequestId = null, this.setState({
|
|
1734
|
-
isLoadingOlderMessages: !1,
|
|
1735
|
-
lastError: typeof e.message == "string" ? e.message : "Could not load older messages."
|
|
1736
|
-
});
|
|
1737
|
-
return;
|
|
1738
|
-
}
|
|
1739
1735
|
const n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1740
1736
|
if (s && n) {
|
|
1741
1737
|
window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof e.message == "string" ? e.message : "Pluno error"));
|
|
@@ -1758,20 +1754,20 @@ class zt {
|
|
|
1758
1754
|
return;
|
|
1759
1755
|
}
|
|
1760
1756
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1761
|
-
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l =
|
|
1757
|
+
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Nn(a.message);
|
|
1762
1758
|
l && console.error(l);
|
|
1763
|
-
const
|
|
1759
|
+
const c = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null, h = Dt(
|
|
1764
1760
|
this.state.messages,
|
|
1765
|
-
|
|
1761
|
+
c,
|
|
1766
1762
|
d
|
|
1767
|
-
),
|
|
1768
|
-
|
|
1769
|
-
|
|
1763
|
+
), y = Mr(
|
|
1764
|
+
h,
|
|
1765
|
+
c,
|
|
1770
1766
|
d
|
|
1771
1767
|
);
|
|
1772
1768
|
this.setState({
|
|
1773
|
-
status:
|
|
1774
|
-
messages:
|
|
1769
|
+
status: y ? "connected" : "error",
|
|
1770
|
+
messages: h,
|
|
1775
1771
|
assistantDraft: "",
|
|
1776
1772
|
assistantDraftItemId: null,
|
|
1777
1773
|
assistantDraftPhase: null,
|
|
@@ -1780,14 +1776,20 @@ class zt {
|
|
|
1780
1776
|
isThinking: !1,
|
|
1781
1777
|
...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
|
|
1782
1778
|
isRetrying: !1,
|
|
1783
|
-
lastError:
|
|
1784
|
-
lastErrorCode:
|
|
1785
|
-
lastErrorSecuritySettingsUrl:
|
|
1779
|
+
lastError: y ? null : a.message,
|
|
1780
|
+
lastErrorCode: y ? null : typeof e.code == "string" ? e.code : null,
|
|
1781
|
+
lastErrorSecuritySettingsUrl: y ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
|
|
1786
1782
|
}), this.clearThinkingWatchdog(), this.emit("error", a);
|
|
1787
1783
|
}
|
|
1788
1784
|
}
|
|
1789
1785
|
}
|
|
1790
1786
|
}
|
|
1787
|
+
updatePersonalModelFromSession(e) {
|
|
1788
|
+
if (this.options.productVariant !== "personal" || !e || typeof e != "object")
|
|
1789
|
+
return;
|
|
1790
|
+
const s = e.metadata, n = s && typeof s == "object" ? s.model : void 0;
|
|
1791
|
+
this.options.model = js(n) ? n : "gpt-5.6-terra";
|
|
1792
|
+
}
|
|
1791
1793
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1792
1794
|
if (!this.options.keepRunsActiveOnSessionNavigation || !Et(e))
|
|
1793
1795
|
return !1;
|
|
@@ -1801,7 +1803,7 @@ class zt {
|
|
|
1801
1803
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1802
1804
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1803
1805
|
return !1;
|
|
1804
|
-
if (
|
|
1806
|
+
if (ge())
|
|
1805
1807
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1806
1808
|
if (e.code === "run_still_active") {
|
|
1807
1809
|
if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
|
|
@@ -1832,7 +1834,7 @@ class zt {
|
|
|
1832
1834
|
}, o), !0;
|
|
1833
1835
|
}
|
|
1834
1836
|
retryAfterInterruptedRun(e, s) {
|
|
1835
|
-
if (
|
|
1837
|
+
if (ge()) {
|
|
1836
1838
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1837
1839
|
return;
|
|
1838
1840
|
}
|
|
@@ -1857,10 +1859,10 @@ class zt {
|
|
|
1857
1859
|
}
|
|
1858
1860
|
rememberUserMessageClientMessageIds(e) {
|
|
1859
1861
|
for (const s of e) {
|
|
1860
|
-
const n =
|
|
1862
|
+
const n = M(s, "id"), r = U(s);
|
|
1861
1863
|
n && r?.type === "message" && r.role === "user" && r.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof r.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId), r.clientMessageId === this.pendingClientMessageId && this.promotePendingDelivery(
|
|
1862
1864
|
r.clientMessageId,
|
|
1863
|
-
|
|
1865
|
+
M(s, "sessionId") ?? this.state.sessionId,
|
|
1864
1866
|
n,
|
|
1865
1867
|
null
|
|
1866
1868
|
), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
|
|
@@ -1946,7 +1948,7 @@ class zt {
|
|
|
1946
1948
|
}), this.markThinkingProgress();
|
|
1947
1949
|
}
|
|
1948
1950
|
schedulePendingDeliveryAck(e) {
|
|
1949
|
-
this.clearPendingDeliveryTimers(), !
|
|
1951
|
+
this.clearPendingDeliveryTimers(), !ge() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
1950
1952
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
1951
1953
|
}, St));
|
|
1952
1954
|
}
|
|
@@ -1972,7 +1974,7 @@ class zt {
|
|
|
1972
1974
|
...this.state.isThinking ? {} : { turnPhase: null },
|
|
1973
1975
|
isRetrying: !1,
|
|
1974
1976
|
...this.state.isThinking ? {} : { taskStatus: "failed" },
|
|
1975
|
-
lastError:
|
|
1977
|
+
lastError: on,
|
|
1976
1978
|
lastErrorCode: "message_delivery_failed"
|
|
1977
1979
|
});
|
|
1978
1980
|
}
|
|
@@ -1987,7 +1989,7 @@ class zt {
|
|
|
1987
1989
|
s,
|
|
1988
1990
|
typeof e.runId == "string" ? e.runId : null
|
|
1989
1991
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
1990
|
-
messages:
|
|
1992
|
+
messages: Lr(
|
|
1991
1993
|
this.state.messages,
|
|
1992
1994
|
s
|
|
1993
1995
|
)
|
|
@@ -1999,7 +2001,7 @@ class zt {
|
|
|
1999
2001
|
}, St);
|
|
2000
2002
|
}
|
|
2001
2003
|
recoverMissedRunAck(e) {
|
|
2002
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (
|
|
2004
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (w("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
2003
2005
|
sessionId: this.state.sessionId,
|
|
2004
2006
|
clientMessageId: e
|
|
2005
2007
|
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(e));
|
|
@@ -2012,7 +2014,7 @@ class zt {
|
|
|
2012
2014
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
2013
2015
|
isThinking: !0,
|
|
2014
2016
|
lastError: null
|
|
2015
|
-
}),
|
|
2017
|
+
}), w("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
2016
2018
|
sessionId: this.state.sessionId,
|
|
2017
2019
|
clientMessageId: e
|
|
2018
2020
|
}), this.state.sessionId ? this.send({
|
|
@@ -2034,13 +2036,13 @@ class zt {
|
|
|
2034
2036
|
return;
|
|
2035
2037
|
const e = this.activeClientMessageId;
|
|
2036
2038
|
if (!e) {
|
|
2037
|
-
|
|
2039
|
+
w("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
2038
2040
|
sessionId: this.state.sessionId
|
|
2039
2041
|
}), this.reportHealthSignal("run_recovery_exhausted", {
|
|
2040
2042
|
reason: "missing_client_message_id"
|
|
2041
2043
|
}), this.setState({
|
|
2042
2044
|
messages: this.state.messages.filter(
|
|
2043
|
-
(r) => !
|
|
2045
|
+
(r) => !V(r)
|
|
2044
2046
|
),
|
|
2045
2047
|
isThinking: !1,
|
|
2046
2048
|
taskStatus: "failed",
|
|
@@ -2051,7 +2053,7 @@ class zt {
|
|
|
2051
2053
|
}
|
|
2052
2054
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
2053
2055
|
if (n >= re) {
|
|
2054
|
-
|
|
2056
|
+
w("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
2055
2057
|
sessionId: this.state.sessionId,
|
|
2056
2058
|
clientMessageId: e
|
|
2057
2059
|
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
@@ -2063,7 +2065,7 @@ class zt {
|
|
|
2063
2065
|
return;
|
|
2064
2066
|
}
|
|
2065
2067
|
if (s < 1) {
|
|
2066
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1,
|
|
2068
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1, w("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
2067
2069
|
sessionId: this.state.sessionId,
|
|
2068
2070
|
clientMessageId: e,
|
|
2069
2071
|
resyncAttempts: s + 1
|
|
@@ -2074,7 +2076,7 @@ class zt {
|
|
|
2074
2076
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
2075
2077
|
isThinking: !0,
|
|
2076
2078
|
lastError: null
|
|
2077
|
-
}),
|
|
2079
|
+
}), w("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
2078
2080
|
sessionId: this.state.sessionId,
|
|
2079
2081
|
clientMessageId: e,
|
|
2080
2082
|
retryAttempts: n + 1
|
|
@@ -2102,15 +2104,15 @@ class zt {
|
|
|
2102
2104
|
if (!s || !n || !r)
|
|
2103
2105
|
return;
|
|
2104
2106
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
2105
|
-
if (!a && !l || !
|
|
2107
|
+
if (!a && !l || !ti(o)) {
|
|
2106
2108
|
this.setToolMessageLoading(n, !1), this.send({
|
|
2107
2109
|
type: "tool.result",
|
|
2108
2110
|
sessionId: s,
|
|
2109
2111
|
callId: n,
|
|
2110
2112
|
toolName: r,
|
|
2111
2113
|
summary: i,
|
|
2112
|
-
rawInput:
|
|
2113
|
-
rawOutput:
|
|
2114
|
+
rawInput: L(o),
|
|
2115
|
+
rawOutput: L({
|
|
2114
2116
|
ok: !1,
|
|
2115
2117
|
toolName: r,
|
|
2116
2118
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -2125,7 +2127,7 @@ class zt {
|
|
|
2125
2127
|
callId: n,
|
|
2126
2128
|
toolName: r,
|
|
2127
2129
|
summary: i,
|
|
2128
|
-
rawInput:
|
|
2130
|
+
rawInput: L(o),
|
|
2129
2131
|
rawOutput: {
|
|
2130
2132
|
ok: !1,
|
|
2131
2133
|
toolName: r,
|
|
@@ -2141,21 +2143,21 @@ class zt {
|
|
|
2141
2143
|
callId: n,
|
|
2142
2144
|
toolName: r,
|
|
2143
2145
|
summary: i,
|
|
2144
|
-
rawInput:
|
|
2146
|
+
rawInput: L(o),
|
|
2145
2147
|
rawOutput: null
|
|
2146
2148
|
},
|
|
2147
2149
|
startedAtMs: Date.now(),
|
|
2148
2150
|
startedAtUrl: location.href,
|
|
2149
2151
|
startedAtOrigin: location.origin
|
|
2150
2152
|
}), this.installSessionBrowserApis();
|
|
2151
|
-
let
|
|
2152
|
-
|
|
2153
|
+
let c = null, d;
|
|
2154
|
+
c = await this.executeRuntimeHelper(), d = await kt(
|
|
2153
2155
|
o,
|
|
2154
|
-
|
|
2155
|
-
).catch((
|
|
2156
|
+
vn(e.runtimeContext, this.options.backendUrl)
|
|
2157
|
+
).catch((h) => ({
|
|
2156
2158
|
ok: !1,
|
|
2157
2159
|
exception: {
|
|
2158
|
-
message:
|
|
2160
|
+
message: h instanceof Error ? h.message : String(h)
|
|
2159
2161
|
}
|
|
2160
2162
|
})), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
2161
2163
|
type: "tool.result",
|
|
@@ -2163,12 +2165,12 @@ class zt {
|
|
|
2163
2165
|
callId: n,
|
|
2164
2166
|
toolName: r,
|
|
2165
2167
|
summary: o.summary,
|
|
2166
|
-
rawInput:
|
|
2167
|
-
rawOutput:
|
|
2168
|
-
}),
|
|
2168
|
+
rawInput: L(o),
|
|
2169
|
+
rawOutput: L(Qn(d, c))
|
|
2170
|
+
}), Lt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
2169
2171
|
}
|
|
2170
2172
|
setToolMessageLoading(e, s) {
|
|
2171
|
-
const n =
|
|
2173
|
+
const n = gr(
|
|
2172
2174
|
this.state.messages,
|
|
2173
2175
|
e,
|
|
2174
2176
|
s
|
|
@@ -2179,17 +2181,17 @@ class zt {
|
|
|
2179
2181
|
if (this.pageLifecycleCleanup)
|
|
2180
2182
|
return;
|
|
2181
2183
|
const e = () => {
|
|
2182
|
-
|
|
2184
|
+
is(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
2183
2185
|
};
|
|
2184
2186
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
2185
2187
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
2186
2188
|
};
|
|
2187
2189
|
}
|
|
2188
2190
|
installSessionBrowserApis() {
|
|
2189
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
2191
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Mn();
|
|
2190
2192
|
}
|
|
2191
2193
|
cleanupSessionBrowserApis() {
|
|
2192
|
-
this.sessionBrowserApisCleanup && (
|
|
2194
|
+
this.sessionBrowserApisCleanup && (Pn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
2193
2195
|
}
|
|
2194
2196
|
async executeRuntimeHelper() {
|
|
2195
2197
|
if (!this.runtimeHelperJavascript?.trim())
|
|
@@ -2197,15 +2199,15 @@ class zt {
|
|
|
2197
2199
|
const e = await kt({
|
|
2198
2200
|
javascript: this.runtimeHelperJavascript
|
|
2199
2201
|
});
|
|
2200
|
-
return e.ok === !1 ?
|
|
2202
|
+
return e.ok === !1 ? Zn(e) : null;
|
|
2201
2203
|
}
|
|
2202
2204
|
enableNetworkCapture() {
|
|
2203
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
2204
|
-
|
|
2205
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = yn((e) => {
|
|
2206
|
+
ai(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
2205
2207
|
}));
|
|
2206
2208
|
}
|
|
2207
2209
|
enqueueNetworkEvent(e) {
|
|
2208
|
-
this.queuedNetworkEvents.length >=
|
|
2210
|
+
this.queuedNetworkEvents.length >= ln || (this.queuedNetworkEvents.push(oi(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
2209
2211
|
this.networkBatchTimer = null;
|
|
2210
2212
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
2211
2213
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -2214,15 +2216,15 @@ class zt {
|
|
|
2214
2216
|
page: b(),
|
|
2215
2217
|
events: s
|
|
2216
2218
|
});
|
|
2217
|
-
},
|
|
2219
|
+
}, an)));
|
|
2218
2220
|
}
|
|
2219
2221
|
scheduleReconnect() {
|
|
2220
2222
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
2221
2223
|
return;
|
|
2222
|
-
const e =
|
|
2224
|
+
const e = fn(this.reconnectAttempts);
|
|
2223
2225
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
2224
2226
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
2225
|
-
|
|
2227
|
+
w("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
2226
2228
|
message: s instanceof Error ? s.message : String(s),
|
|
2227
2229
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
2228
2230
|
isThinking: this.state.isThinking
|
|
@@ -2234,9 +2236,9 @@ class zt {
|
|
|
2234
2236
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
2235
2237
|
const e = this.socket;
|
|
2236
2238
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
2237
|
-
this.socket === e && (
|
|
2238
|
-
},
|
|
2239
|
-
},
|
|
2239
|
+
this.socket === e && (w("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
2240
|
+
}, Qs));
|
|
2241
|
+
}, Ys);
|
|
2240
2242
|
}
|
|
2241
2243
|
stopHeartbeat() {
|
|
2242
2244
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -2274,7 +2276,7 @@ class zt {
|
|
|
2274
2276
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2275
2277
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2276
2278
|
};
|
|
2277
|
-
this.state = o,
|
|
2279
|
+
this.state = o, jr(this.options.clientId, this.state), this.emit("state", this.getState()), Be("state", this.state.status, {
|
|
2278
2280
|
status: this.state.status,
|
|
2279
2281
|
sessionId: this.state.sessionId,
|
|
2280
2282
|
messageCount: this.state.messages.length,
|
|
@@ -2296,56 +2298,56 @@ class zt {
|
|
|
2296
2298
|
this.listeners[e]?.forEach((r) => r(s));
|
|
2297
2299
|
}
|
|
2298
2300
|
}
|
|
2299
|
-
const
|
|
2300
|
-
function
|
|
2301
|
-
const e = window.__plunoProductAgentNetworkCapture ??
|
|
2301
|
+
const He = /* @__PURE__ */ new WeakMap();
|
|
2302
|
+
function yn(t) {
|
|
2303
|
+
const e = window.__plunoProductAgentNetworkCapture ?? In();
|
|
2302
2304
|
return e.subscribers.add(t), () => {
|
|
2303
2305
|
e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
2304
2306
|
};
|
|
2305
2307
|
}
|
|
2306
|
-
function
|
|
2307
|
-
const t = /* @__PURE__ */ new Set(), e = (
|
|
2308
|
+
function In() {
|
|
2309
|
+
const t = /* @__PURE__ */ new Set(), e = (y) => {
|
|
2308
2310
|
t.forEach((f) => {
|
|
2309
2311
|
try {
|
|
2310
|
-
f(
|
|
2312
|
+
f(y);
|
|
2311
2313
|
} catch {
|
|
2312
2314
|
}
|
|
2313
2315
|
});
|
|
2314
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f,
|
|
2315
|
-
const
|
|
2316
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, u) {
|
|
2317
|
+
const p = Date.now();
|
|
2316
2318
|
let g;
|
|
2317
2319
|
try {
|
|
2318
|
-
g = s.call(this, f,
|
|
2319
|
-
} catch (
|
|
2320
|
-
throw
|
|
2320
|
+
g = s.call(this, f, u);
|
|
2321
|
+
} catch (m) {
|
|
2322
|
+
throw m;
|
|
2321
2323
|
}
|
|
2322
2324
|
try {
|
|
2323
|
-
const
|
|
2324
|
-
if (!J(k,
|
|
2325
|
-
const
|
|
2326
|
-
requestId:
|
|
2327
|
-
url:
|
|
2328
|
-
method: (
|
|
2329
|
-
requestHeaders:
|
|
2330
|
-
requestBody: Nt(
|
|
2325
|
+
const m = f instanceof Request ? f : null, k = si(f, m), T = cs(u?.headers ?? m?.headers);
|
|
2326
|
+
if (!J(k, T, u?.body)) {
|
|
2327
|
+
const _ = {
|
|
2328
|
+
requestId: Fe("fetch"),
|
|
2329
|
+
url: W(k, We),
|
|
2330
|
+
method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
2331
|
+
requestHeaders: T,
|
|
2332
|
+
requestBody: Nt(u?.body),
|
|
2331
2333
|
resourceType: "fetch",
|
|
2332
|
-
startedAt: new Date(
|
|
2334
|
+
startedAt: new Date(p).toISOString()
|
|
2333
2335
|
};
|
|
2334
2336
|
g.then(
|
|
2335
|
-
(
|
|
2336
|
-
|
|
2337
|
+
(v) => {
|
|
2338
|
+
ni(v, _, p, e).catch(() => {
|
|
2337
2339
|
e({
|
|
2338
|
-
...
|
|
2339
|
-
responseStatus:
|
|
2340
|
-
durationMs: Date.now() -
|
|
2340
|
+
..._,
|
|
2341
|
+
responseStatus: v.status,
|
|
2342
|
+
durationMs: Date.now() - p
|
|
2341
2343
|
});
|
|
2342
2344
|
});
|
|
2343
2345
|
},
|
|
2344
|
-
(
|
|
2346
|
+
(v) => {
|
|
2345
2347
|
e({
|
|
2346
|
-
...
|
|
2347
|
-
errorText:
|
|
2348
|
-
durationMs: Date.now() -
|
|
2348
|
+
..._,
|
|
2349
|
+
errorText: W(v instanceof Error ? v.message : String(v)),
|
|
2350
|
+
durationMs: Date.now() - p
|
|
2349
2351
|
});
|
|
2350
2352
|
}
|
|
2351
2353
|
);
|
|
@@ -2353,42 +2355,42 @@ function pn() {
|
|
|
2353
2355
|
} catch {
|
|
2354
2356
|
}
|
|
2355
2357
|
return g;
|
|
2356
|
-
}, a = function(f,
|
|
2357
|
-
const k = n.call(this, f,
|
|
2358
|
-
return
|
|
2359
|
-
requestId:
|
|
2358
|
+
}, a = function(f, u, p, g, m) {
|
|
2359
|
+
const k = n.call(this, f, u, p ?? !0, g ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
2360
|
+
return He.set(this, {
|
|
2361
|
+
requestId: Fe("xhr"),
|
|
2360
2362
|
method: String(f ?? "GET").toUpperCase(),
|
|
2361
|
-
url:
|
|
2363
|
+
url: W(T, We),
|
|
2362
2364
|
requestHeaders: {},
|
|
2363
2365
|
startedAtMs: Date.now(),
|
|
2364
2366
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2365
|
-
excluded: J(
|
|
2367
|
+
excluded: J(T)
|
|
2366
2368
|
}), k;
|
|
2367
|
-
}, l = function(f,
|
|
2368
|
-
const
|
|
2369
|
-
return g && Object.keys(g.requestHeaders).length <
|
|
2370
|
-
},
|
|
2369
|
+
}, l = function(f, u) {
|
|
2370
|
+
const p = r.call(this, f, u), g = He.get(this);
|
|
2371
|
+
return g && Object.keys(g.requestHeaders).length < nt && (g.requestHeaders[f] = ot(f, u), g.excluded = g.excluded || J(g.url, g.requestHeaders)), p;
|
|
2372
|
+
}, c = function(f) {
|
|
2371
2373
|
try {
|
|
2372
|
-
const
|
|
2373
|
-
|
|
2374
|
+
const u = He.get(this);
|
|
2375
|
+
u && (u.excluded = u.excluded || J(u.url, u.requestHeaders, f), u.requestBody = Nt(f), u.excluded || this.addEventListener(
|
|
2374
2376
|
"loadend",
|
|
2375
2377
|
() => {
|
|
2376
2378
|
queueMicrotask(() => {
|
|
2377
2379
|
try {
|
|
2378
|
-
const
|
|
2380
|
+
const p = ci(this.getAllResponseHeaders());
|
|
2379
2381
|
e({
|
|
2380
|
-
requestId:
|
|
2381
|
-
url:
|
|
2382
|
-
method:
|
|
2383
|
-
requestHeaders:
|
|
2384
|
-
requestBody:
|
|
2382
|
+
requestId: u.requestId,
|
|
2383
|
+
url: u.url,
|
|
2384
|
+
method: u.method,
|
|
2385
|
+
requestHeaders: u.requestHeaders,
|
|
2386
|
+
requestBody: u.requestBody,
|
|
2385
2387
|
resourceType: "xhr",
|
|
2386
2388
|
responseStatus: this.status,
|
|
2387
|
-
responseHeaders:
|
|
2388
|
-
responseBody:
|
|
2389
|
+
responseHeaders: p,
|
|
2390
|
+
responseBody: ii(this, p),
|
|
2389
2391
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2390
|
-
startedAt:
|
|
2391
|
-
durationMs: Date.now() -
|
|
2392
|
+
startedAt: u.startedAt,
|
|
2393
|
+
durationMs: Date.now() - u.startedAtMs
|
|
2392
2394
|
});
|
|
2393
2395
|
} catch {
|
|
2394
2396
|
return;
|
|
@@ -2414,25 +2416,25 @@ function pn() {
|
|
|
2414
2416
|
} catch {
|
|
2415
2417
|
}
|
|
2416
2418
|
try {
|
|
2417
|
-
XMLHttpRequest.prototype.send =
|
|
2419
|
+
XMLHttpRequest.prototype.send = c;
|
|
2418
2420
|
} catch {
|
|
2419
2421
|
}
|
|
2420
2422
|
let d = null;
|
|
2421
2423
|
if (typeof PerformanceObserver < "u") {
|
|
2422
|
-
d = new PerformanceObserver((
|
|
2423
|
-
for (const f of
|
|
2424
|
-
const
|
|
2425
|
-
if (
|
|
2424
|
+
d = new PerformanceObserver((y) => {
|
|
2425
|
+
for (const f of y.getEntries()) {
|
|
2426
|
+
const u = f;
|
|
2427
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || J(u.name))
|
|
2426
2428
|
continue;
|
|
2427
|
-
const
|
|
2429
|
+
const p = performance.timeOrigin + u.startTime;
|
|
2428
2430
|
e({
|
|
2429
|
-
requestId:
|
|
2430
|
-
url:
|
|
2431
|
+
requestId: Fe("resource"),
|
|
2432
|
+
url: W(u.name, We),
|
|
2431
2433
|
method: "GET",
|
|
2432
2434
|
resourceType: "resource",
|
|
2433
|
-
responseStatus:
|
|
2434
|
-
startedAt: new Date(
|
|
2435
|
-
durationMs:
|
|
2435
|
+
responseStatus: u.responseStatus,
|
|
2436
|
+
startedAt: new Date(p).toISOString(),
|
|
2437
|
+
durationMs: u.duration
|
|
2436
2438
|
});
|
|
2437
2439
|
}
|
|
2438
2440
|
});
|
|
@@ -2442,7 +2444,7 @@ function pn() {
|
|
|
2442
2444
|
d.disconnect(), d = null;
|
|
2443
2445
|
}
|
|
2444
2446
|
}
|
|
2445
|
-
const
|
|
2447
|
+
const h = {
|
|
2446
2448
|
subscribers: t,
|
|
2447
2449
|
destroy: () => {
|
|
2448
2450
|
d?.disconnect();
|
|
@@ -2459,14 +2461,14 @@ function pn() {
|
|
|
2459
2461
|
} catch {
|
|
2460
2462
|
}
|
|
2461
2463
|
try {
|
|
2462
|
-
XMLHttpRequest.prototype.send ===
|
|
2464
|
+
XMLHttpRequest.prototype.send === c && (XMLHttpRequest.prototype.send = i);
|
|
2463
2465
|
} catch {
|
|
2464
2466
|
}
|
|
2465
2467
|
}
|
|
2466
2468
|
};
|
|
2467
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
2469
|
+
return window.__plunoProductAgentNetworkCapture = h, h;
|
|
2468
2470
|
}
|
|
2469
|
-
function
|
|
2471
|
+
function w(t, e, s) {
|
|
2470
2472
|
if (typeof window > "u")
|
|
2471
2473
|
return;
|
|
2472
2474
|
const n = window, r = {
|
|
@@ -2481,7 +2483,7 @@ function Rt(t) {
|
|
|
2481
2483
|
const e = typeof t == "function" ? t() : t;
|
|
2482
2484
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2483
2485
|
}
|
|
2484
|
-
function
|
|
2486
|
+
function Tn(t) {
|
|
2485
2487
|
return t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call";
|
|
2486
2488
|
}
|
|
2487
2489
|
function Et(t) {
|
|
@@ -2502,27 +2504,27 @@ function oe(t) {
|
|
|
2502
2504
|
}
|
|
2503
2505
|
return null;
|
|
2504
2506
|
}
|
|
2505
|
-
const
|
|
2506
|
-
function
|
|
2507
|
+
const Sn = 5e3, wn = 12e4;
|
|
2508
|
+
function Mn() {
|
|
2507
2509
|
const t = [
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
+
Rn(),
|
|
2511
|
+
An()
|
|
2510
2512
|
].filter((e) => typeof e == "function");
|
|
2511
2513
|
return () => {
|
|
2512
2514
|
for (const e of t.reverse())
|
|
2513
2515
|
e();
|
|
2514
2516
|
};
|
|
2515
2517
|
}
|
|
2516
|
-
function
|
|
2517
|
-
return Bt(globalThis, "getPageSnapshot", async () =>
|
|
2518
|
+
function An() {
|
|
2519
|
+
return Bt(globalThis, "getPageSnapshot", async () => rt());
|
|
2518
2520
|
}
|
|
2519
|
-
function
|
|
2521
|
+
function Rn() {
|
|
2520
2522
|
return Bt(globalThis, "pageImages", {
|
|
2521
|
-
inspectImage: async (e, s) => await
|
|
2523
|
+
inspectImage: async (e, s) => await En(e, s)
|
|
2522
2524
|
});
|
|
2523
2525
|
}
|
|
2524
|
-
async function
|
|
2525
|
-
const s =
|
|
2526
|
+
async function En(t, e = {}) {
|
|
2527
|
+
const s = _n(e.name), n = await kn(t);
|
|
2526
2528
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2527
2529
|
type: "pluno.pageImages.inspectImage",
|
|
2528
2530
|
imageAttached: !1,
|
|
@@ -2540,15 +2542,15 @@ async function Sn(t, e = {}) {
|
|
|
2540
2542
|
imageAttachmentError: n.error
|
|
2541
2543
|
};
|
|
2542
2544
|
}
|
|
2543
|
-
async function
|
|
2545
|
+
async function kn(t) {
|
|
2544
2546
|
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: jt } : {
|
|
2545
2547
|
ok: !0,
|
|
2546
2548
|
mimeType: t.type,
|
|
2547
2549
|
sizeBytes: t.size,
|
|
2548
|
-
dataUrl: await
|
|
2549
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
2550
|
+
dataUrl: await Un(t)
|
|
2551
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Cn(t);
|
|
2550
2552
|
}
|
|
2551
|
-
function
|
|
2553
|
+
function Cn(t) {
|
|
2552
2554
|
if (!t.startsWith("data:") || !t.includes(","))
|
|
2553
2555
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
2554
2556
|
const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -2559,7 +2561,7 @@ function Mn(t) {
|
|
|
2559
2561
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
2560
2562
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
2561
2563
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
2562
|
-
const o =
|
|
2564
|
+
const o = bn(i);
|
|
2563
2565
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
2564
2566
|
ok: !0,
|
|
2565
2567
|
mimeType: r,
|
|
@@ -2567,22 +2569,22 @@ function Mn(t) {
|
|
|
2567
2569
|
dataUrl: `data:${r};base64,${i}`
|
|
2568
2570
|
};
|
|
2569
2571
|
}
|
|
2570
|
-
function
|
|
2572
|
+
function bn(t) {
|
|
2571
2573
|
if (t.length === 0 || t.length % 4 !== 0)
|
|
2572
2574
|
return null;
|
|
2573
2575
|
const e = t.length - t.replace(/=+$/, "").length;
|
|
2574
2576
|
return e > 2 ? null : t.length / 4 * 3 - e;
|
|
2575
2577
|
}
|
|
2576
|
-
function
|
|
2578
|
+
function _n(t) {
|
|
2577
2579
|
return (typeof t == "string" ? t.trim() : "") || "Page image";
|
|
2578
2580
|
}
|
|
2579
|
-
function
|
|
2581
|
+
function Pn(t) {
|
|
2580
2582
|
try {
|
|
2581
2583
|
t();
|
|
2582
2584
|
} catch {
|
|
2583
2585
|
}
|
|
2584
2586
|
}
|
|
2585
|
-
function
|
|
2587
|
+
function Un(t) {
|
|
2586
2588
|
return new Promise((e, s) => {
|
|
2587
2589
|
const n = new FileReader();
|
|
2588
2590
|
n.onload = () => {
|
|
@@ -2596,25 +2598,25 @@ function kn(t) {
|
|
|
2596
2598
|
}
|
|
2597
2599
|
async function kt(t, e) {
|
|
2598
2600
|
const s = Object.getPrototypeOf(async function() {
|
|
2599
|
-
}).constructor, n = t.timeoutMs ??
|
|
2601
|
+
}).constructor, n = t.timeoutMs ?? Sn, r = Date.now(), i = [];
|
|
2600
2602
|
let o;
|
|
2601
2603
|
const a = {
|
|
2602
2604
|
log: console.log,
|
|
2603
2605
|
info: console.info,
|
|
2604
2606
|
warn: console.warn,
|
|
2605
2607
|
error: console.error
|
|
2606
|
-
}, l = (
|
|
2607
|
-
i.push({ level:
|
|
2608
|
+
}, l = (c) => (...d) => {
|
|
2609
|
+
i.push({ level: c, args: d }), a[c](...d);
|
|
2608
2610
|
};
|
|
2609
2611
|
console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error");
|
|
2610
2612
|
try {
|
|
2611
|
-
const
|
|
2613
|
+
const c = /* @__PURE__ */ Symbol("execute_code_timeout"), d = await Promise.race([
|
|
2612
2614
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
2613
|
-
new Promise((
|
|
2614
|
-
o = window.setTimeout(() =>
|
|
2615
|
+
new Promise((h) => {
|
|
2616
|
+
o = window.setTimeout(() => h(c), n);
|
|
2615
2617
|
})
|
|
2616
2618
|
]);
|
|
2617
|
-
return d ===
|
|
2619
|
+
return d === c ? Dn(n) : {
|
|
2618
2620
|
ok: !0,
|
|
2619
2621
|
result: d,
|
|
2620
2622
|
console: i,
|
|
@@ -2624,14 +2626,14 @@ async function kt(t, e) {
|
|
|
2624
2626
|
origin: location.origin
|
|
2625
2627
|
}
|
|
2626
2628
|
};
|
|
2627
|
-
} catch (
|
|
2629
|
+
} catch (c) {
|
|
2628
2630
|
return {
|
|
2629
2631
|
ok: !1,
|
|
2630
2632
|
console: i,
|
|
2631
2633
|
exception: {
|
|
2632
|
-
name:
|
|
2633
|
-
message:
|
|
2634
|
-
stack:
|
|
2634
|
+
name: c instanceof Error ? c.name : "Error",
|
|
2635
|
+
message: c instanceof Error ? c.message : String(c),
|
|
2636
|
+
stack: c instanceof Error ? c.stack : void 0
|
|
2635
2637
|
},
|
|
2636
2638
|
metadata: {
|
|
2637
2639
|
durationMs: Date.now() - r,
|
|
@@ -2643,7 +2645,7 @@ async function kt(t, e) {
|
|
|
2643
2645
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2644
2646
|
}
|
|
2645
2647
|
}
|
|
2646
|
-
function
|
|
2648
|
+
function vn(t, e) {
|
|
2647
2649
|
if (!t || typeof t != "object")
|
|
2648
2650
|
return;
|
|
2649
2651
|
const s = t.sandboxFilesToken;
|
|
@@ -2653,13 +2655,13 @@ function Cn(t, e) {
|
|
|
2653
2655
|
const r = () => {
|
|
2654
2656
|
if (!n)
|
|
2655
2657
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2656
|
-
}, i = async (a, l) => await
|
|
2658
|
+
}, i = async (a, l) => await Fs(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2657
2659
|
return {
|
|
2658
2660
|
value: Object.freeze({
|
|
2659
2661
|
upload: async (a) => {
|
|
2660
2662
|
if (r(), !(a instanceof Blob))
|
|
2661
2663
|
throw new TypeError("sandboxFiles.upload expects a File or Blob");
|
|
2662
|
-
const l = a instanceof File && a.name ? a.name : "file",
|
|
2664
|
+
const l = a instanceof File && a.name ? a.name : "file", c = `?name=${encodeURIComponent(l)}&size_bytes=${a.size}`, d = await i(`/api/product-agent/attachments/sandbox-files${c}`, {
|
|
2663
2665
|
method: "PUT",
|
|
2664
2666
|
headers: { Authorization: `Bearer ${s}` },
|
|
2665
2667
|
body: a
|
|
@@ -2676,9 +2678,9 @@ function Cn(t, e) {
|
|
|
2676
2678
|
);
|
|
2677
2679
|
if (!l.ok)
|
|
2678
2680
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
2679
|
-
const
|
|
2680
|
-
return new File([
|
|
2681
|
-
type:
|
|
2681
|
+
const c = await l.blob(), h = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
2682
|
+
return new File([c], h || a.split("/").pop() || "file", {
|
|
2683
|
+
type: c.type
|
|
2682
2684
|
});
|
|
2683
2685
|
}
|
|
2684
2686
|
}),
|
|
@@ -2687,7 +2689,7 @@ function Cn(t, e) {
|
|
|
2687
2689
|
}
|
|
2688
2690
|
};
|
|
2689
2691
|
}
|
|
2690
|
-
function
|
|
2692
|
+
function Dn(t) {
|
|
2691
2693
|
return {
|
|
2692
2694
|
ok: !1,
|
|
2693
2695
|
exception: {
|
|
@@ -2701,10 +2703,10 @@ function bn(t) {
|
|
|
2701
2703
|
}
|
|
2702
2704
|
};
|
|
2703
2705
|
}
|
|
2704
|
-
function
|
|
2706
|
+
function qn(t) {
|
|
2705
2707
|
return t.replace(/\/+$/, "");
|
|
2706
2708
|
}
|
|
2707
|
-
function
|
|
2709
|
+
function Ln(t) {
|
|
2708
2710
|
const e = {
|
|
2709
2711
|
sidepanel: "extension_sidepanel",
|
|
2710
2712
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2716,18 +2718,18 @@ function Pn(t) {
|
|
|
2716
2718
|
};
|
|
2717
2719
|
return t && t in e ? e[t] : t ?? "embedded_custom_ui";
|
|
2718
2720
|
}
|
|
2719
|
-
function
|
|
2721
|
+
function On(t) {
|
|
2720
2722
|
return t === "pluno" ? "scheduled_continuation" : t ?? "user";
|
|
2721
2723
|
}
|
|
2722
|
-
function
|
|
2724
|
+
function Nn(t, e = location.origin) {
|
|
2723
2725
|
return /origin (?:is not allowed|does not match browser origin)/i.test(t) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
|
|
2724
2726
|
}
|
|
2725
|
-
function
|
|
2727
|
+
function xn(t) {
|
|
2726
2728
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2727
2729
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2728
2730
|
}
|
|
2729
2731
|
function b() {
|
|
2730
|
-
const t =
|
|
2732
|
+
const t = Xt();
|
|
2731
2733
|
return {
|
|
2732
2734
|
url: location.href,
|
|
2733
2735
|
title: document.title,
|
|
@@ -2735,21 +2737,21 @@ function b() {
|
|
|
2735
2737
|
...t ? { plunoProductAgentUi: t } : {}
|
|
2736
2738
|
};
|
|
2737
2739
|
}
|
|
2738
|
-
function
|
|
2740
|
+
function Bn() {
|
|
2739
2741
|
return {
|
|
2740
2742
|
pageUrl: location.href,
|
|
2741
2743
|
pageTitle: document.title,
|
|
2742
|
-
htmlContent:
|
|
2744
|
+
htmlContent: rt()
|
|
2743
2745
|
};
|
|
2744
2746
|
}
|
|
2745
|
-
function
|
|
2746
|
-
return
|
|
2747
|
-
|
|
2747
|
+
function Wn(t) {
|
|
2748
|
+
return Te.add(t), he || (he = Hn()), () => {
|
|
2749
|
+
Te.delete(t), Te.size === 0 && (he?.(), he = null);
|
|
2748
2750
|
};
|
|
2749
2751
|
}
|
|
2750
|
-
function
|
|
2752
|
+
function Hn() {
|
|
2751
2753
|
const t = () => {
|
|
2752
|
-
for (const i of Array.from(
|
|
2754
|
+
for (const i of Array.from(Te))
|
|
2753
2755
|
i();
|
|
2754
2756
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2755
2757
|
const o = e(...i);
|
|
@@ -2762,33 +2764,33 @@ function Ln() {
|
|
|
2762
2764
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2763
2765
|
};
|
|
2764
2766
|
}
|
|
2765
|
-
function
|
|
2766
|
-
return
|
|
2767
|
+
function ge() {
|
|
2768
|
+
return Xt()?.surface === "browser_extension_sdk_preview";
|
|
2767
2769
|
}
|
|
2768
|
-
function
|
|
2770
|
+
function rt() {
|
|
2769
2771
|
if (!document.body)
|
|
2770
2772
|
return "";
|
|
2771
|
-
const t = [], e = [], s = (
|
|
2772
|
-
const
|
|
2773
|
-
!
|
|
2773
|
+
const t = [], e = [], s = (p, g) => {
|
|
2774
|
+
const m = Q(g);
|
|
2775
|
+
!m || e.includes(m) || (t.push([p, m]), e.push(m));
|
|
2774
2776
|
};
|
|
2775
2777
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2776
2778
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2777
|
-
(
|
|
2779
|
+
(p) => Kt(p) && !p.parentElement?.closest(n)
|
|
2778
2780
|
);
|
|
2779
|
-
for (const
|
|
2780
|
-
s("Active overlay",
|
|
2781
|
-
const i =
|
|
2782
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2783
|
-
const a = t.map(([
|
|
2781
|
+
for (const p of r.slice(0, 3))
|
|
2782
|
+
s("Active overlay", $e(ae(p), e));
|
|
2783
|
+
const i = $n(), o = i ? $e(ae(i), e) : "";
|
|
2784
|
+
s("Main page content", o), s("Additional visible page text", $e(ae(document.body), e));
|
|
2785
|
+
const a = t.map(([p, g]) => `${p}:
|
|
2784
2786
|
${g}`).join(`
|
|
2785
2787
|
|
|
2786
|
-
`).trim().slice(0, 12e3), l =
|
|
2788
|
+
`).trim().slice(0, 12e3), l = jn(r, i).trim(), c = `Simplified DOM outline:
|
|
2787
2789
|
`, d = `
|
|
2788
2790
|
|
|
2789
2791
|
Visible page text:
|
|
2790
|
-
`,
|
|
2791
|
-
return `${
|
|
2792
|
+
`, h = 12e3 - c.length - d.length, y = Math.min(a.length, 7900), f = l.slice(0, h - y), u = a.slice(0, h - f.length);
|
|
2793
|
+
return `${c}${f}${d}${u}`;
|
|
2792
2794
|
}
|
|
2793
2795
|
function ae(t) {
|
|
2794
2796
|
return t.innerText ?? t.textContent ?? "";
|
|
@@ -2801,7 +2803,7 @@ function Q(t) {
|
|
|
2801
2803
|
|
|
2802
2804
|
`).trim();
|
|
2803
2805
|
}
|
|
2804
|
-
function
|
|
2806
|
+
function $e(t, e) {
|
|
2805
2807
|
let s = Q(t);
|
|
2806
2808
|
for (const n of e)
|
|
2807
2809
|
s = s.replace(n, "");
|
|
@@ -2811,10 +2813,10 @@ function Kt(t) {
|
|
|
2811
2813
|
const e = window.getComputedStyle(t);
|
|
2812
2814
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2813
2815
|
}
|
|
2814
|
-
function
|
|
2816
|
+
function $n() {
|
|
2815
2817
|
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Kt).sort((t, e) => ae(e).length - ae(t).length)[0] ?? null;
|
|
2816
2818
|
}
|
|
2817
|
-
function
|
|
2819
|
+
function jn(t, e) {
|
|
2818
2820
|
const s = /* @__PURE__ */ new Set([
|
|
2819
2821
|
"main",
|
|
2820
2822
|
"nav",
|
|
@@ -2894,84 +2896,84 @@ function xn(t, e) {
|
|
|
2894
2896
|
"data-test",
|
|
2895
2897
|
"data-qa",
|
|
2896
2898
|
"data-cy"
|
|
2897
|
-
],
|
|
2898
|
-
e &&
|
|
2899
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: h } = Fn(), y = new Set(t);
|
|
2900
|
+
e && y.add(e);
|
|
2899
2901
|
let f = 0;
|
|
2900
|
-
const
|
|
2901
|
-
const
|
|
2902
|
-
return
|
|
2903
|
-
},
|
|
2904
|
-
const
|
|
2905
|
-
return `${
|
|
2906
|
-
}, g = (
|
|
2907
|
-
const
|
|
2908
|
-
const
|
|
2909
|
-
if (f >= 1e3 && !
|
|
2902
|
+
const u = (T) => {
|
|
2903
|
+
const S = T.getAttribute("role");
|
|
2904
|
+
return S && !o.has(S) ? S : "";
|
|
2905
|
+
}, p = (T) => {
|
|
2906
|
+
const S = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
|
|
2907
|
+
return `${T.tagName.toLowerCase()}|${u(T)}|${S}`;
|
|
2908
|
+
}, g = (T, S, _) => {
|
|
2909
|
+
const v = (R, ee) => {
|
|
2910
|
+
const P = R.tagName.toLowerCase(), F = window.getComputedStyle(R), X = d.has(R);
|
|
2911
|
+
if (f >= 1e3 && !X || _.has(R) || i.has(P) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || F.display === "none" || F.visibility === "hidden")
|
|
2910
2912
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2911
2913
|
f += 1;
|
|
2912
|
-
const
|
|
2913
|
-
for (const
|
|
2914
|
-
const A =
|
|
2915
|
-
|
|
2914
|
+
const te = u(R), O = Vt(R), ce = a.has(te) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(P) || P === "a" && R.hasAttribute("href"), ue = Array.from(R.children).filter((I) => I instanceof HTMLElement), z = /* @__PURE__ */ new Map();
|
|
2915
|
+
for (const I of ue) {
|
|
2916
|
+
const A = p(I);
|
|
2917
|
+
z.set(A, (z.get(A) ?? 0) + 1);
|
|
2916
2918
|
}
|
|
2917
|
-
const
|
|
2918
|
-
for (const
|
|
2919
|
-
const A =
|
|
2920
|
-
|
|
2919
|
+
const x = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
|
|
2920
|
+
for (const I of ue) {
|
|
2921
|
+
const A = p(I), j = E.get(A) ?? 0;
|
|
2922
|
+
E.set(A, j + 1), (z.get(A) ?? 0) > 8 && j >= 6 && !d.has(I) && x.set(A, (x.get(A) ?? 0) + 1);
|
|
2921
2923
|
}
|
|
2922
|
-
const
|
|
2923
|
-
for (const
|
|
2924
|
-
const A =
|
|
2925
|
-
if (
|
|
2926
|
-
at.has(A) || (
|
|
2924
|
+
const q = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Set(), Pe = [], lt = [];
|
|
2925
|
+
for (const I of ue) {
|
|
2926
|
+
const A = p(I), j = z.get(A) ?? 0, dt = q.get(A) ?? 0;
|
|
2927
|
+
if (q.set(A, dt + 1), j > 8 && dt >= 6 && !d.has(I)) {
|
|
2928
|
+
at.has(A) || (Pe.push([`… ${x.get(A) ?? 0} similar siblings omitted`]), at.add(A));
|
|
2927
2929
|
continue;
|
|
2928
2930
|
}
|
|
2929
|
-
const
|
|
2930
|
-
lt.push(
|
|
2931
|
+
const pt = v(I, ee);
|
|
2932
|
+
lt.push(pt), Pe.push(pt.lines);
|
|
2931
2933
|
}
|
|
2932
|
-
const
|
|
2934
|
+
const Ue = [];
|
|
2933
2935
|
if (R.shadowRoot)
|
|
2934
|
-
for (const
|
|
2935
|
-
|
|
2936
|
-
const
|
|
2937
|
-
[
|
|
2938
|
-
).slice(0, 180),
|
|
2939
|
-
if (
|
|
2940
|
-
const
|
|
2936
|
+
for (const I of Array.from(R.shadowRoot.children))
|
|
2937
|
+
I instanceof HTMLElement && Ue.push(v(I, ee + 1));
|
|
2938
|
+
const de = [...lt, ...Ue], ve = O.length > 0 || ce || de.some((I) => I.hasUsefulContent), ct = Q(
|
|
2939
|
+
[O, ...de.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
2940
|
+
).slice(0, 180), ys = R.hasAttribute("contenteditable") && (O.length > 0 || !R.querySelector("[contenteditable]")), ut = c.some((I) => R.hasAttribute(I)) || !!te || ys, De = (R.getClientRects().length > 0 || F.display === "contents") && (s.has(P) || ut || X) && (ve || X) && (!r.has(P) || ve || ut || X), qe = De ? 1 : 0, se = [];
|
|
2941
|
+
if (De) {
|
|
2942
|
+
const I = de.some((j) => j.containsTextElement), A = n.has(P) && !I ? ct : O;
|
|
2941
2943
|
se.push(Gt(R, l, o, A.slice(0, 180)));
|
|
2942
2944
|
}
|
|
2943
|
-
for (const
|
|
2944
|
-
se.push(...
|
|
2945
|
-
const
|
|
2946
|
-
if (
|
|
2947
|
-
const
|
|
2948
|
-
|
|
2949
|
-
const A =
|
|
2945
|
+
for (const I of Pe)
|
|
2946
|
+
se.push(...fe(I, qe));
|
|
2947
|
+
const Le = Ue.flatMap((I) => I.lines);
|
|
2948
|
+
if (Le.length > 0) {
|
|
2949
|
+
const I = Le.slice(0, 20);
|
|
2950
|
+
Le.length > I.length && I.push("… shadow DOM omitted");
|
|
2951
|
+
const A = P.includes("tooltip") || P.includes("popper") || P.includes("loader");
|
|
2950
2952
|
if (ee < 2 && !A) {
|
|
2951
|
-
const j =
|
|
2952
|
-
se.push(...
|
|
2953
|
+
const j = De ? "#shadow-root" : `${P} #shadow-root`;
|
|
2954
|
+
se.push(...fe([j, ...fe(I, 1)], qe));
|
|
2953
2955
|
} else
|
|
2954
|
-
se.push(...
|
|
2956
|
+
se.push(...fe(I, qe));
|
|
2955
2957
|
}
|
|
2956
2958
|
return {
|
|
2957
2959
|
lines: se,
|
|
2958
|
-
hasUsefulContent:
|
|
2959
|
-
textPreview:
|
|
2960
|
-
containsTextElement: n.has(
|
|
2960
|
+
hasUsefulContent: ve,
|
|
2961
|
+
textPreview: ct,
|
|
2962
|
+
containsTextElement: n.has(P) || de.some((I) => I.containsTextElement)
|
|
2961
2963
|
};
|
|
2962
2964
|
};
|
|
2963
|
-
return [`--- ${
|
|
2965
|
+
return [`--- ${S} ---`, ...v(T, 0).lines].join(`
|
|
2964
2966
|
`);
|
|
2965
|
-
},
|
|
2966
|
-
k &&
|
|
2967
|
-
${JSON.stringify(k)}`),
|
|
2968
|
-
for (const
|
|
2969
|
-
|
|
2970
|
-
if (e &&
|
|
2971
|
-
const
|
|
2972
|
-
|
|
2973
|
-
}
|
|
2974
|
-
return
|
|
2967
|
+
}, m = [], k = Q(window.getSelection()?.toString() ?? "");
|
|
2968
|
+
k && m.push(`--- selected text ---
|
|
2969
|
+
${JSON.stringify(k)}`), h.length > 0 && m.push(zn(h, s, l, o));
|
|
2970
|
+
for (const T of t.slice(0, 3))
|
|
2971
|
+
m.push(g(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2972
|
+
if (e && m.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
2973
|
+
const T = e || t.length ? "other visible DOM" : "visible DOM";
|
|
2974
|
+
m.push(g(document.body, T, y));
|
|
2975
|
+
}
|
|
2976
|
+
return m.join(`
|
|
2975
2977
|
|
|
2976
2978
|
`);
|
|
2977
2979
|
}
|
|
@@ -2979,7 +2981,7 @@ function Gt(t, e, s, n) {
|
|
|
2979
2981
|
const r = t.tagName.toLowerCase();
|
|
2980
2982
|
let i = r;
|
|
2981
2983
|
const o = t.getAttribute("id");
|
|
2982
|
-
o &&
|
|
2984
|
+
o && Kn(o) && (i += `#${o}`);
|
|
2983
2985
|
for (const a of e) {
|
|
2984
2986
|
const l = t.getAttribute(a);
|
|
2985
2987
|
l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
|
|
@@ -2992,20 +2994,20 @@ function Gt(t, e, s, n) {
|
|
|
2992
2994
|
t.hasAttribute(a) && (i += `[${a}]`);
|
|
2993
2995
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2994
2996
|
}
|
|
2995
|
-
function
|
|
2997
|
+
function Fn() {
|
|
2996
2998
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
|
|
2997
2999
|
if (!a)
|
|
2998
3000
|
return;
|
|
2999
|
-
const
|
|
3000
|
-
if (
|
|
3001
|
+
const c = window.getComputedStyle(a);
|
|
3002
|
+
if (c.display === "none" || c.visibility === "hidden")
|
|
3001
3003
|
return;
|
|
3002
3004
|
const d = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
3003
3005
|
d.add(l), e.set(a, d);
|
|
3004
|
-
let
|
|
3005
|
-
for (;
|
|
3006
|
-
t.add(
|
|
3007
|
-
const
|
|
3008
|
-
|
|
3006
|
+
let h = a;
|
|
3007
|
+
for (; h; ) {
|
|
3008
|
+
t.add(h);
|
|
3009
|
+
const y = h.getRootNode();
|
|
3010
|
+
h = h.parentElement ?? (y instanceof ShadowRoot && y.host instanceof HTMLElement ? y.host : null);
|
|
3009
3011
|
}
|
|
3010
3012
|
};
|
|
3011
3013
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -3024,18 +3026,18 @@ function Bn() {
|
|
|
3024
3026
|
], o = [document];
|
|
3025
3027
|
for (let a = 0; a < o.length; a += 1) {
|
|
3026
3028
|
const l = o[a];
|
|
3027
|
-
for (const [
|
|
3028
|
-
for (const
|
|
3029
|
-
s(
|
|
3030
|
-
for (const
|
|
3031
|
-
|
|
3029
|
+
for (const [c, d] of i)
|
|
3030
|
+
for (const h of Array.from(l.querySelectorAll(c)))
|
|
3031
|
+
s(h, d);
|
|
3032
|
+
for (const c of Array.from(l.querySelectorAll("*")))
|
|
3033
|
+
c.shadowRoot && o.push(c.shadowRoot);
|
|
3032
3034
|
}
|
|
3033
3035
|
return {
|
|
3034
3036
|
priorityElements: t,
|
|
3035
3037
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
3036
3038
|
};
|
|
3037
3039
|
}
|
|
3038
|
-
function
|
|
3040
|
+
function zn(t, e, s, n) {
|
|
3039
3041
|
const r = ["--- active/current elements ---"];
|
|
3040
3042
|
for (const i of t) {
|
|
3041
3043
|
const o = [];
|
|
@@ -3043,16 +3045,16 @@ function Wn(t, e, s, n) {
|
|
|
3043
3045
|
for (; a; ) {
|
|
3044
3046
|
const d = a.tagName.toLowerCase();
|
|
3045
3047
|
(a === i.element || e.has(d) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
3046
|
-
const
|
|
3047
|
-
a = a.parentElement ?? (
|
|
3048
|
+
const h = a.getRootNode();
|
|
3049
|
+
a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
|
|
3048
3050
|
}
|
|
3049
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o,
|
|
3051
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d, h) => Gt(
|
|
3050
3052
|
d,
|
|
3051
3053
|
s,
|
|
3052
3054
|
n,
|
|
3053
|
-
|
|
3055
|
+
h === l.length - 1 ? Vt(d).slice(0, 180) : ""
|
|
3054
3056
|
));
|
|
3055
|
-
o.length > l.length &&
|
|
3057
|
+
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
3056
3058
|
}
|
|
3057
3059
|
return r.join(`
|
|
3058
3060
|
`);
|
|
@@ -3060,23 +3062,23 @@ function Wn(t, e, s, n) {
|
|
|
3060
3062
|
function Ct(t) {
|
|
3061
3063
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
3062
3064
|
}
|
|
3063
|
-
function
|
|
3065
|
+
function fe(t, e) {
|
|
3064
3066
|
if (e === 0)
|
|
3065
3067
|
return t;
|
|
3066
3068
|
const s = " ".repeat(e);
|
|
3067
3069
|
return t.map((n) => `${s}${n}`);
|
|
3068
3070
|
}
|
|
3069
|
-
function
|
|
3071
|
+
function Vt(t) {
|
|
3070
3072
|
return Q(
|
|
3071
3073
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
3072
3074
|
);
|
|
3073
3075
|
}
|
|
3074
|
-
function
|
|
3076
|
+
function Kn(t) {
|
|
3075
3077
|
return t.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(t) && !/[a-f0-9]{12,}/i.test(t) && !/:r[0-9a-z]+:/i.test(t);
|
|
3076
3078
|
}
|
|
3077
|
-
function
|
|
3078
|
-
const t = document.querySelector(
|
|
3079
|
-
if (!(t ?? document.querySelector(
|
|
3079
|
+
function Xt() {
|
|
3080
|
+
const t = document.querySelector(ht);
|
|
3081
|
+
if (!(t ?? document.querySelector(Ke)))
|
|
3080
3082
|
return;
|
|
3081
3083
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
3082
3084
|
return {
|
|
@@ -3085,28 +3087,28 @@ function Vt() {
|
|
|
3085
3087
|
selectors: [
|
|
3086
3088
|
{
|
|
3087
3089
|
name: "widget_host",
|
|
3088
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
3090
|
+
selector: s === "browser_extension_sdk_preview" ? ht : Ke,
|
|
3089
3091
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
3090
3092
|
},
|
|
3091
3093
|
{
|
|
3092
3094
|
name: "widget_root",
|
|
3093
|
-
selector:
|
|
3095
|
+
selector: zs,
|
|
3094
3096
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
3095
3097
|
},
|
|
3096
3098
|
{
|
|
3097
3099
|
name: "widget_panel",
|
|
3098
|
-
selector:
|
|
3100
|
+
selector: Ks,
|
|
3099
3101
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
3100
3102
|
},
|
|
3101
3103
|
{
|
|
3102
3104
|
name: "widget_timeline",
|
|
3103
|
-
selector:
|
|
3105
|
+
selector: Gs,
|
|
3104
3106
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
3105
3107
|
}
|
|
3106
3108
|
]
|
|
3107
3109
|
};
|
|
3108
3110
|
}
|
|
3109
|
-
function
|
|
3111
|
+
function Gn(t) {
|
|
3110
3112
|
try {
|
|
3111
3113
|
const e = JSON.parse(t);
|
|
3112
3114
|
return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
|
|
@@ -3114,7 +3116,7 @@ function $n(t) {
|
|
|
3114
3116
|
return { type: "error", message: "Invalid server event" };
|
|
3115
3117
|
}
|
|
3116
3118
|
}
|
|
3117
|
-
function
|
|
3119
|
+
function Vn(t) {
|
|
3118
3120
|
if (typeof t != "string")
|
|
3119
3121
|
return null;
|
|
3120
3122
|
try {
|
|
@@ -3130,10 +3132,10 @@ function bt(t, e) {
|
|
|
3130
3132
|
const s = t[e];
|
|
3131
3133
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
3132
3134
|
}
|
|
3133
|
-
function
|
|
3135
|
+
function Xn(t) {
|
|
3134
3136
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
3135
3137
|
}
|
|
3136
|
-
function
|
|
3138
|
+
function Jn(t) {
|
|
3137
3139
|
if (!t || typeof t != "object")
|
|
3138
3140
|
return null;
|
|
3139
3141
|
const e = t, s = e.appearance, n = s && typeof s == "object" ? s : e, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -3144,13 +3146,13 @@ function zn(t) {
|
|
|
3144
3146
|
...a !== null ? { scribbleStyle: a } : {}
|
|
3145
3147
|
};
|
|
3146
3148
|
}
|
|
3147
|
-
function
|
|
3149
|
+
function Yn(t) {
|
|
3148
3150
|
if (!t || typeof t != "object")
|
|
3149
3151
|
return null;
|
|
3150
3152
|
const e = t.javascript;
|
|
3151
3153
|
return typeof e != "string" || !e.trim() ? null : { javascript: e };
|
|
3152
3154
|
}
|
|
3153
|
-
function
|
|
3155
|
+
function Qn(t, e) {
|
|
3154
3156
|
return e ? t && typeof t == "object" ? {
|
|
3155
3157
|
...t,
|
|
3156
3158
|
helperError: e
|
|
@@ -3160,23 +3162,23 @@ function Gn(t, e) {
|
|
|
3160
3162
|
helperError: e
|
|
3161
3163
|
} : t;
|
|
3162
3164
|
}
|
|
3163
|
-
function
|
|
3165
|
+
function Zn(t) {
|
|
3164
3166
|
if (!t || typeof t != "object")
|
|
3165
3167
|
return t;
|
|
3166
3168
|
const e = t;
|
|
3167
3169
|
return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : t;
|
|
3168
3170
|
}
|
|
3169
|
-
function
|
|
3171
|
+
function er() {
|
|
3170
3172
|
const t = "pluno.productAgent.clientId", e = window.localStorage.getItem(t);
|
|
3171
3173
|
if (e)
|
|
3172
3174
|
return e;
|
|
3173
3175
|
const s = crypto.randomUUID();
|
|
3174
3176
|
return window.localStorage.setItem(t, s), s;
|
|
3175
3177
|
}
|
|
3176
|
-
function
|
|
3178
|
+
function B() {
|
|
3177
3179
|
return crypto.randomUUID();
|
|
3178
3180
|
}
|
|
3179
|
-
function
|
|
3181
|
+
function tr(t) {
|
|
3180
3182
|
if (!t || typeof t != "object")
|
|
3181
3183
|
return null;
|
|
3182
3184
|
const e = t, s = typeof e.id == "string" ? e.id : null;
|
|
@@ -3188,21 +3190,21 @@ function Jn(t) {
|
|
|
3188
3190
|
} : null;
|
|
3189
3191
|
}
|
|
3190
3192
|
function _t(t, e) {
|
|
3191
|
-
return Array.isArray(t) ?
|
|
3193
|
+
return Array.isArray(t) ? Ye(
|
|
3192
3194
|
t.map((s) => Jt(s, e)).filter((s) => s !== null)
|
|
3193
3195
|
) : [];
|
|
3194
3196
|
}
|
|
3195
|
-
function
|
|
3197
|
+
function sr(t) {
|
|
3196
3198
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3197
3199
|
if (!e || typeof e != "object")
|
|
3198
3200
|
return [];
|
|
3199
|
-
const s = e, n =
|
|
3201
|
+
const s = e, n = M(s, "id"), r = M(s, "createdAt"), i = M(s, "updatedAt"), o = M(s, "lastActiveAt");
|
|
3200
3202
|
return !n || !r || !i || !o ? [] : [
|
|
3201
3203
|
{
|
|
3202
3204
|
id: n,
|
|
3203
|
-
title:
|
|
3204
|
-
customTitle:
|
|
3205
|
-
firstUserMessage:
|
|
3205
|
+
title: M(s, "title"),
|
|
3206
|
+
customTitle: M(s, "customTitle"),
|
|
3207
|
+
firstUserMessage: M(s, "firstUserMessage"),
|
|
3206
3208
|
currentPage: s.currentPage ?? null,
|
|
3207
3209
|
createdAt: r,
|
|
3208
3210
|
updatedAt: i,
|
|
@@ -3220,22 +3222,22 @@ function Jt(t, e) {
|
|
|
3220
3222
|
if (!n || typeof n != "object")
|
|
3221
3223
|
return null;
|
|
3222
3224
|
const r = n;
|
|
3223
|
-
if (r.hiddenFromTranscript === !0 ||
|
|
3225
|
+
if (r.hiddenFromTranscript === !0 || Cs(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
3224
3226
|
return null;
|
|
3225
3227
|
if (r.type === "message") {
|
|
3226
3228
|
const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
|
|
3227
3229
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3228
3230
|
role: i,
|
|
3229
3231
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
3230
|
-
content:
|
|
3231
|
-
|
|
3232
|
+
content: Es(
|
|
3233
|
+
ur(r.content),
|
|
3232
3234
|
e
|
|
3233
3235
|
),
|
|
3234
3236
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3235
|
-
...
|
|
3236
|
-
respondsToUserMessageId:
|
|
3237
|
-
...
|
|
3238
|
-
attachments:
|
|
3237
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3238
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3239
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3240
|
+
attachments: os(r.attachments, e)
|
|
3239
3241
|
};
|
|
3240
3242
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
3241
3243
|
value: r.id,
|
|
@@ -3246,67 +3248,67 @@ function Jt(t, e) {
|
|
|
3246
3248
|
}), o;
|
|
3247
3249
|
}
|
|
3248
3250
|
if (r.type === "function_call_output") {
|
|
3249
|
-
const i =
|
|
3251
|
+
const i = Bs(r.output);
|
|
3250
3252
|
if (i)
|
|
3251
3253
|
return {
|
|
3252
3254
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3253
3255
|
role: "tool",
|
|
3254
3256
|
content: "",
|
|
3255
3257
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3256
|
-
respondsToUserMessageId:
|
|
3257
|
-
...
|
|
3258
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3259
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3258
3260
|
dataType: "scheduled_check_in",
|
|
3259
3261
|
toolName: Ht,
|
|
3260
|
-
callId:
|
|
3262
|
+
callId: me(r) ?? void 0,
|
|
3261
3263
|
scheduledCheckInAt: i
|
|
3262
3264
|
};
|
|
3263
|
-
const o =
|
|
3265
|
+
const o = rr(r.output), a = ir(r.output);
|
|
3264
3266
|
return o ? {
|
|
3265
3267
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3266
3268
|
role: "tool",
|
|
3267
3269
|
content: `Connect ${o.appName} to continue`,
|
|
3268
3270
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3269
|
-
...
|
|
3270
|
-
respondsToUserMessageId:
|
|
3271
|
-
...
|
|
3271
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3272
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3273
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3272
3274
|
dataType: "function_call_output",
|
|
3273
3275
|
toolName: "authenticate_pipedream_app",
|
|
3274
|
-
callId:
|
|
3276
|
+
callId: me(r) ?? void 0,
|
|
3275
3277
|
integrationAuthRequest: o
|
|
3276
3278
|
} : a ? {
|
|
3277
3279
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3278
3280
|
role: "tool",
|
|
3279
3281
|
content: "Connect WhatsApp to continue",
|
|
3280
3282
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3281
|
-
...
|
|
3282
|
-
respondsToUserMessageId:
|
|
3283
|
-
...
|
|
3283
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3284
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3285
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3284
3286
|
dataType: "function_call_output",
|
|
3285
3287
|
toolName: "request_personal_channel_connection",
|
|
3286
|
-
callId:
|
|
3288
|
+
callId: me(r) ?? void 0,
|
|
3287
3289
|
personalChannelConnectionRequest: a
|
|
3288
3290
|
} : null;
|
|
3289
3291
|
}
|
|
3290
3292
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
3291
3293
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3292
3294
|
role: "tool",
|
|
3293
|
-
content: r.type === "mcp_call" ?
|
|
3295
|
+
content: r.type === "mcp_call" ? nr(r) : ar(r),
|
|
3294
3296
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3295
|
-
...
|
|
3296
|
-
respondsToUserMessageId:
|
|
3297
|
-
...
|
|
3297
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3298
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3299
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3298
3300
|
dataType: String(r.type),
|
|
3299
3301
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
3300
|
-
callId:
|
|
3302
|
+
callId: me(r) ?? void 0,
|
|
3301
3303
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
3302
3304
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
3303
3305
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3304
3306
|
role: "system",
|
|
3305
|
-
content:
|
|
3307
|
+
content: or(r),
|
|
3306
3308
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3307
|
-
...
|
|
3308
|
-
respondsToUserMessageId:
|
|
3309
|
-
...
|
|
3309
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3310
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3311
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3310
3312
|
dataType: String(r.type),
|
|
3311
3313
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
3312
3314
|
...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
|
|
@@ -3314,11 +3316,11 @@ function Jt(t, e) {
|
|
|
3314
3316
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
3315
3317
|
} : null;
|
|
3316
3318
|
}
|
|
3317
|
-
function
|
|
3319
|
+
function nr(t) {
|
|
3318
3320
|
const s = (typeof t.server_label == "string" ? t.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
3319
3321
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
3320
3322
|
}
|
|
3321
|
-
function
|
|
3323
|
+
function rr(t) {
|
|
3322
3324
|
if (typeof t != "string")
|
|
3323
3325
|
return null;
|
|
3324
3326
|
try {
|
|
@@ -3335,7 +3337,7 @@ function Zn(t) {
|
|
|
3335
3337
|
return null;
|
|
3336
3338
|
}
|
|
3337
3339
|
}
|
|
3338
|
-
function
|
|
3340
|
+
function ir(t) {
|
|
3339
3341
|
if (typeof t != "string")
|
|
3340
3342
|
return null;
|
|
3341
3343
|
try {
|
|
@@ -3350,10 +3352,10 @@ function er(t) {
|
|
|
3350
3352
|
return null;
|
|
3351
3353
|
}
|
|
3352
3354
|
}
|
|
3353
|
-
function
|
|
3355
|
+
function or(t) {
|
|
3354
3356
|
return t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message : "";
|
|
3355
3357
|
}
|
|
3356
|
-
function
|
|
3358
|
+
function ar(t) {
|
|
3357
3359
|
if (t.type === "web_search_call") {
|
|
3358
3360
|
const e = t.action;
|
|
3359
3361
|
if (e && typeof e == "object") {
|
|
@@ -3365,9 +3367,9 @@ function sr(t) {
|
|
|
3365
3367
|
}
|
|
3366
3368
|
return "🔎 Searching the web";
|
|
3367
3369
|
}
|
|
3368
|
-
return
|
|
3370
|
+
return lr(t);
|
|
3369
3371
|
}
|
|
3370
|
-
function
|
|
3372
|
+
function lr(t) {
|
|
3371
3373
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3372
3374
|
return Y(t.summary);
|
|
3373
3375
|
if (typeof t.arguments == "string")
|
|
@@ -3384,7 +3386,7 @@ function Y(t) {
|
|
|
3384
3386
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3385
3387
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3386
3388
|
}
|
|
3387
|
-
function
|
|
3389
|
+
function cr(t) {
|
|
3388
3390
|
if (t == null)
|
|
3389
3391
|
return t;
|
|
3390
3392
|
if (typeof t != "object")
|
|
@@ -3399,14 +3401,14 @@ function rr(t) {
|
|
|
3399
3401
|
runId: typeof e.runId == "string" ? e.runId : null
|
|
3400
3402
|
};
|
|
3401
3403
|
}
|
|
3402
|
-
function
|
|
3404
|
+
function me(t) {
|
|
3403
3405
|
const e = t.callId ?? t.call_id;
|
|
3404
3406
|
return typeof e == "string" && e ? e : null;
|
|
3405
3407
|
}
|
|
3406
|
-
function
|
|
3408
|
+
function D(t) {
|
|
3407
3409
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
3408
3410
|
}
|
|
3409
|
-
function
|
|
3411
|
+
function ur(t) {
|
|
3410
3412
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
3411
3413
|
if (!e || typeof e != "object")
|
|
3412
3414
|
return "";
|
|
@@ -3414,31 +3416,31 @@ function ir(t) {
|
|
|
3414
3416
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
3415
3417
|
}).filter(Boolean).join("") : "";
|
|
3416
3418
|
}
|
|
3417
|
-
function
|
|
3418
|
-
const s =
|
|
3419
|
-
|
|
3420
|
-
|
|
3419
|
+
function Ve(t, e) {
|
|
3420
|
+
const s = Zt(t, e), n = mr(
|
|
3421
|
+
dr(
|
|
3422
|
+
wr(t, e),
|
|
3421
3423
|
s
|
|
3422
3424
|
),
|
|
3423
3425
|
s
|
|
3424
3426
|
), r = n.findIndex((o) => o.id === s.id);
|
|
3425
3427
|
if (r === -1)
|
|
3426
|
-
return
|
|
3428
|
+
return Ye(
|
|
3427
3429
|
[...n, s]
|
|
3428
3430
|
);
|
|
3429
3431
|
const i = [...n];
|
|
3430
|
-
return i[r] = s,
|
|
3432
|
+
return i[r] = s, Ye(i);
|
|
3431
3433
|
}
|
|
3432
|
-
function
|
|
3434
|
+
function dr(t, e) {
|
|
3433
3435
|
const s = e.assistantDraftItemId;
|
|
3434
3436
|
return s ? t.map(
|
|
3435
3437
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
3436
3438
|
) : t;
|
|
3437
3439
|
}
|
|
3438
|
-
function
|
|
3440
|
+
function je(t, e, s) {
|
|
3439
3441
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3440
3442
|
}
|
|
3441
|
-
function
|
|
3443
|
+
function pr(t, e, s, n) {
|
|
3442
3444
|
if (s === null) return t;
|
|
3443
3445
|
let r = -1;
|
|
3444
3446
|
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
@@ -3455,12 +3457,12 @@ function ar(t, e, s, n) {
|
|
|
3455
3457
|
respondsToUserMessageId: s
|
|
3456
3458
|
}, i;
|
|
3457
3459
|
}
|
|
3458
|
-
function
|
|
3460
|
+
function hr(t, e) {
|
|
3459
3461
|
const s = t.findIndex(
|
|
3460
3462
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3461
3463
|
);
|
|
3462
3464
|
if (s === -1)
|
|
3463
|
-
return
|
|
3465
|
+
return Ve(t, e);
|
|
3464
3466
|
const n = [...t];
|
|
3465
3467
|
return n[s] = {
|
|
3466
3468
|
...n[s],
|
|
@@ -3472,12 +3474,12 @@ function lr(t, e) {
|
|
|
3472
3474
|
...n[s].runId ? {} : { runId: e.runId }
|
|
3473
3475
|
}, n;
|
|
3474
3476
|
}
|
|
3475
|
-
function
|
|
3477
|
+
function gr(t, e, s) {
|
|
3476
3478
|
let n = !1;
|
|
3477
3479
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
3478
3480
|
return n ? r : t;
|
|
3479
3481
|
}
|
|
3480
|
-
function
|
|
3482
|
+
function fr(t) {
|
|
3481
3483
|
if (t.hiddenFromTranscript === !0)
|
|
3482
3484
|
return null;
|
|
3483
3485
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
@@ -3497,7 +3499,7 @@ function cr(t) {
|
|
|
3497
3499
|
loading: !0
|
|
3498
3500
|
};
|
|
3499
3501
|
}
|
|
3500
|
-
function
|
|
3502
|
+
function mr(t, e) {
|
|
3501
3503
|
if (e.id.startsWith("transient-activity:"))
|
|
3502
3504
|
return t;
|
|
3503
3505
|
const s = e.toolName === "tab_lifecycle";
|
|
@@ -3506,24 +3508,32 @@ function dr(t, e) {
|
|
|
3506
3508
|
const n = (i) => i.id === `transient-activity:${e.callId}` && i.callId === e.callId || s && i.id.startsWith("transient-activity:") && i.toolName === "browser_tabs" && !!i.runId && i.runId === e.runId, r = t.findIndex(n);
|
|
3507
3509
|
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
3508
3510
|
}
|
|
3509
|
-
function
|
|
3510
|
-
return
|
|
3511
|
+
function Yt(t, e) {
|
|
3512
|
+
return bs(
|
|
3511
3513
|
t,
|
|
3512
3514
|
e.map(
|
|
3513
|
-
(s) =>
|
|
3515
|
+
(s) => Zt(t, s)
|
|
3514
3516
|
),
|
|
3515
|
-
|
|
3517
|
+
Qt
|
|
3516
3518
|
);
|
|
3517
3519
|
}
|
|
3518
|
-
function
|
|
3519
|
-
const
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3520
|
+
function yr(t, e) {
|
|
3521
|
+
const s = new Map(t.map((n) => [n.id, n]));
|
|
3522
|
+
for (const n of e)
|
|
3523
|
+
s.set(n.id, n);
|
|
3524
|
+
return Yt(
|
|
3525
|
+
t,
|
|
3526
|
+
[...s.values()]
|
|
3527
|
+
).sort(Ir);
|
|
3524
3528
|
}
|
|
3525
|
-
function
|
|
3526
|
-
|
|
3529
|
+
function Ir(t, e) {
|
|
3530
|
+
if ((t.respondsToUserMessageId !== void 0 && t.respondsToUserMessageId === e.respondsToUserMessageId || t.respondsToUserMessageId === void 0 && e.respondsToUserMessageId === void 0 && t.runId !== void 0 && t.runId === e.runId) && t.causalSequence !== void 0 && e.causalSequence !== void 0 && t.causalSequence !== e.causalSequence)
|
|
3531
|
+
return t.causalSequence - e.causalSequence;
|
|
3532
|
+
const n = Date.parse(t.createdAt) - Date.parse(e.createdAt);
|
|
3533
|
+
return Number.isNaN(n) ? 0 : n;
|
|
3534
|
+
}
|
|
3535
|
+
function Qt(t) {
|
|
3536
|
+
const e = G(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3527
3537
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3528
3538
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3529
3539
|
];
|
|
@@ -3534,55 +3544,55 @@ function Yt(t) {
|
|
|
3534
3544
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3535
3545
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3536
3546
|
...t.runId ? { runId: t.runId } : {},
|
|
3537
|
-
isOptimistic:
|
|
3547
|
+
isOptimistic: be(t),
|
|
3538
3548
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3539
3549
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3540
3550
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3541
3551
|
};
|
|
3542
3552
|
}
|
|
3543
|
-
function
|
|
3553
|
+
function Zt(t, e) {
|
|
3544
3554
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3545
3555
|
return e;
|
|
3546
3556
|
const s = t.find(
|
|
3547
|
-
(o) => o.role === "user" && (o.id === e.id ||
|
|
3557
|
+
(o) => o.role === "user" && (o.id === e.id || be(o) && es(o, e))
|
|
3548
3558
|
);
|
|
3549
3559
|
if (!s?.attachments?.length)
|
|
3550
3560
|
return e;
|
|
3551
3561
|
const n = e.attachments.map((o) => {
|
|
3552
|
-
const a =
|
|
3553
|
-
return a ?
|
|
3554
|
-
}), r = { ...e, attachments: n }, i =
|
|
3562
|
+
const a = Tr(s.attachments ?? [], o);
|
|
3563
|
+
return a ? Sr(o, a) : o;
|
|
3564
|
+
}), r = { ...e, attachments: n }, i = G(e);
|
|
3555
3565
|
return i && Object.defineProperty(r, "clientMessageId", {
|
|
3556
3566
|
value: i,
|
|
3557
3567
|
enumerable: !1
|
|
3558
3568
|
}), r;
|
|
3559
3569
|
}
|
|
3560
|
-
function
|
|
3570
|
+
function Tr(t, e) {
|
|
3561
3571
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
3562
3572
|
}
|
|
3563
|
-
function
|
|
3573
|
+
function Sr(t, e) {
|
|
3564
3574
|
const { previewUrl: s } = e;
|
|
3565
3575
|
return s ? { ...t, previewUrl: s } : t;
|
|
3566
3576
|
}
|
|
3567
|
-
function
|
|
3577
|
+
function wr(t, e) {
|
|
3568
3578
|
if (e.role !== "user")
|
|
3569
3579
|
return t;
|
|
3570
3580
|
const s = t.findIndex(
|
|
3571
|
-
(r) =>
|
|
3581
|
+
(r) => be(r) && es(r, e)
|
|
3572
3582
|
);
|
|
3573
3583
|
if (s === -1)
|
|
3574
3584
|
return t;
|
|
3575
3585
|
const n = [...t];
|
|
3576
3586
|
return n.splice(s, 1), n;
|
|
3577
3587
|
}
|
|
3578
|
-
function
|
|
3579
|
-
const s =
|
|
3588
|
+
function es(t, e) {
|
|
3589
|
+
const s = G(t), n = G(e);
|
|
3580
3590
|
return s && n ? s === n : t.content === e.content;
|
|
3581
3591
|
}
|
|
3582
|
-
function
|
|
3592
|
+
function be(t) {
|
|
3583
3593
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3584
3594
|
}
|
|
3585
|
-
function
|
|
3595
|
+
function G(t) {
|
|
3586
3596
|
const e = t.clientMessageId;
|
|
3587
3597
|
if (e)
|
|
3588
3598
|
return e;
|
|
@@ -3592,18 +3602,18 @@ function X(t) {
|
|
|
3592
3602
|
return n ? t.id.slice(n.length) : null;
|
|
3593
3603
|
}
|
|
3594
3604
|
function Pt(t) {
|
|
3595
|
-
const e =
|
|
3605
|
+
const e = ts(t);
|
|
3596
3606
|
if (e === null)
|
|
3597
3607
|
return !1;
|
|
3598
3608
|
const s = t[e].id;
|
|
3599
3609
|
if (t.some(
|
|
3600
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3610
|
+
(r) => r.respondsToUserMessageId === s && Me(r)
|
|
3601
3611
|
))
|
|
3602
3612
|
return !0;
|
|
3603
3613
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3604
3614
|
const i = t[r];
|
|
3605
3615
|
if (!i.respondsToUserMessageId) {
|
|
3606
|
-
if (
|
|
3616
|
+
if (H(i))
|
|
3607
3617
|
return !0;
|
|
3608
3618
|
if (i.role === "system") {
|
|
3609
3619
|
if (i.dataType === "run_error")
|
|
@@ -3615,10 +3625,10 @@ function Pt(t) {
|
|
|
3615
3625
|
}
|
|
3616
3626
|
return !1;
|
|
3617
3627
|
}
|
|
3618
|
-
function
|
|
3628
|
+
function Mr(t, e, s) {
|
|
3619
3629
|
const n = new Set(
|
|
3620
3630
|
t.filter(
|
|
3621
|
-
(r) => r.role === "user" && e !== null &&
|
|
3631
|
+
(r) => r.role === "user" && e !== null && G(r) === e
|
|
3622
3632
|
).map((r) => r.id)
|
|
3623
3633
|
);
|
|
3624
3634
|
return t.some((r, i) => {
|
|
@@ -3629,29 +3639,29 @@ function yr(t, e, s) {
|
|
|
3629
3639
|
if (s && r.runId === s) {
|
|
3630
3640
|
if (n.size === 0)
|
|
3631
3641
|
return !0;
|
|
3632
|
-
const o =
|
|
3642
|
+
const o = ss(t, i);
|
|
3633
3643
|
return !r.respondsToUserMessageId && o !== null && n.has(o);
|
|
3634
3644
|
}
|
|
3635
3645
|
return !1;
|
|
3636
3646
|
});
|
|
3637
3647
|
}
|
|
3638
|
-
function
|
|
3639
|
-
const e =
|
|
3648
|
+
function Ar(t) {
|
|
3649
|
+
const e = ts(t);
|
|
3640
3650
|
if (e === null)
|
|
3641
|
-
return t.some(
|
|
3651
|
+
return t.some(H);
|
|
3642
3652
|
const s = t[e].id;
|
|
3643
3653
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3644
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3645
|
-
) : t.slice(e + 1).some(
|
|
3654
|
+
(n) => n.respondsToUserMessageId === s && H(n)
|
|
3655
|
+
) : t.slice(e + 1).some(H);
|
|
3646
3656
|
}
|
|
3647
|
-
function
|
|
3657
|
+
function ts(t) {
|
|
3648
3658
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3649
|
-
if (t[e].role === "user" && !
|
|
3659
|
+
if (t[e].role === "user" && !be(t[e]))
|
|
3650
3660
|
return e;
|
|
3651
3661
|
return null;
|
|
3652
3662
|
}
|
|
3653
|
-
function
|
|
3654
|
-
return
|
|
3663
|
+
function Me(t) {
|
|
3664
|
+
return H(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3655
3665
|
}
|
|
3656
3666
|
function Z(t) {
|
|
3657
3667
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
@@ -3667,29 +3677,29 @@ function Z(t) {
|
|
|
3667
3677
|
}
|
|
3668
3678
|
return null;
|
|
3669
3679
|
}
|
|
3670
|
-
function
|
|
3680
|
+
function Rr(t) {
|
|
3671
3681
|
const e = Z(t);
|
|
3672
3682
|
if (e === null)
|
|
3673
3683
|
return null;
|
|
3674
|
-
const n =
|
|
3684
|
+
const n = U(t[e])?.page;
|
|
3675
3685
|
if (!n || typeof n != "object")
|
|
3676
3686
|
return null;
|
|
3677
3687
|
const r = n.url;
|
|
3678
3688
|
return typeof r == "string" ? r : null;
|
|
3679
3689
|
}
|
|
3680
|
-
function
|
|
3690
|
+
function U(t) {
|
|
3681
3691
|
if (!t || typeof t != "object")
|
|
3682
3692
|
return null;
|
|
3683
3693
|
const e = t.data;
|
|
3684
3694
|
return e && typeof e == "object" ? e : null;
|
|
3685
3695
|
}
|
|
3686
|
-
function
|
|
3696
|
+
function Ae(t) {
|
|
3687
3697
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3688
3698
|
}
|
|
3689
3699
|
function Ut(t) {
|
|
3690
3700
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3691
3701
|
}
|
|
3692
|
-
function
|
|
3702
|
+
function Er(t, e) {
|
|
3693
3703
|
const s = Z(e);
|
|
3694
3704
|
if (s === null)
|
|
3695
3705
|
return !1;
|
|
@@ -3698,10 +3708,10 @@ function Sr(t, e) {
|
|
|
3698
3708
|
return !1;
|
|
3699
3709
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3700
3710
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3701
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3702
|
-
) : t.slice(i + 1).some(
|
|
3711
|
+
(o) => o.respondsToUserMessageId === r && Me(o)
|
|
3712
|
+
) : t.slice(i + 1).some(Me);
|
|
3703
3713
|
}
|
|
3704
|
-
function
|
|
3714
|
+
function Xe(t) {
|
|
3705
3715
|
const e = Z(t);
|
|
3706
3716
|
if (e === null)
|
|
3707
3717
|
return null;
|
|
@@ -3714,7 +3724,7 @@ function Ge(t) {
|
|
|
3714
3724
|
const r = n.clientMessageId;
|
|
3715
3725
|
return typeof r == "string" ? r : null;
|
|
3716
3726
|
}
|
|
3717
|
-
function
|
|
3727
|
+
function kr(t) {
|
|
3718
3728
|
const e = Z(t);
|
|
3719
3729
|
if (e === null)
|
|
3720
3730
|
return null;
|
|
@@ -3729,22 +3739,22 @@ function wr(t) {
|
|
|
3729
3739
|
if (i.type === "message" && i.role === "assistant")
|
|
3730
3740
|
return null;
|
|
3731
3741
|
if (i.type === "run_error")
|
|
3732
|
-
return i.retryable !== !0 ? null :
|
|
3742
|
+
return i.retryable !== !0 ? null : Je(t, i) ?? Xe(t);
|
|
3733
3743
|
if (i.type === "run_status")
|
|
3734
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3744
|
+
return i.status === "interrupted" && i.retryable === !0 ? Je(t, i) ?? Xe(t) : null;
|
|
3735
3745
|
}
|
|
3736
3746
|
return null;
|
|
3737
3747
|
}
|
|
3738
|
-
function
|
|
3748
|
+
function Je(t, e) {
|
|
3739
3749
|
if (typeof e.clientMessageId == "string")
|
|
3740
3750
|
return e.clientMessageId;
|
|
3741
|
-
const s =
|
|
3751
|
+
const s = N(e);
|
|
3742
3752
|
if (!s)
|
|
3743
3753
|
return null;
|
|
3744
|
-
const n = t.find((i) =>
|
|
3754
|
+
const n = t.find((i) => M(i, "id") === s), r = U(n);
|
|
3745
3755
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3746
3756
|
}
|
|
3747
|
-
function
|
|
3757
|
+
function Cr(t, e) {
|
|
3748
3758
|
let s = 0;
|
|
3749
3759
|
for (const n of t) {
|
|
3750
3760
|
if (!n || typeof n != "object")
|
|
@@ -3757,91 +3767,91 @@ function Mr(t, e) {
|
|
|
3757
3767
|
}
|
|
3758
3768
|
return s;
|
|
3759
3769
|
}
|
|
3760
|
-
function
|
|
3761
|
-
if (!e || !
|
|
3770
|
+
function vt(t, e, s, n, r, i) {
|
|
3771
|
+
if (!e || !_r(t))
|
|
3762
3772
|
return !1;
|
|
3763
3773
|
const o = t;
|
|
3764
|
-
if (
|
|
3774
|
+
if (Ae(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3765
3775
|
return !1;
|
|
3766
|
-
const a =
|
|
3767
|
-
return n !== null ? a !== null ? a === n : r !== null &&
|
|
3776
|
+
const a = N(o);
|
|
3777
|
+
return n !== null ? a !== null ? a === n : r !== null && C(o) === r && i === n : r === null || C(o) === r;
|
|
3768
3778
|
}
|
|
3769
|
-
function
|
|
3779
|
+
function br(t, e) {
|
|
3770
3780
|
for (let s = e - 1; s >= 0; s -= 1) {
|
|
3771
|
-
const n =
|
|
3781
|
+
const n = U(t[s]);
|
|
3772
3782
|
if (n?.type === "message" && n.role === "user")
|
|
3773
|
-
return
|
|
3783
|
+
return M(t[s], "id");
|
|
3774
3784
|
}
|
|
3775
3785
|
return null;
|
|
3776
3786
|
}
|
|
3777
|
-
function
|
|
3787
|
+
function ss(t, e) {
|
|
3778
3788
|
for (let s = e - 1; s >= 0; s -= 1)
|
|
3779
3789
|
if (t[s].role === "user")
|
|
3780
3790
|
return t[s].id;
|
|
3781
3791
|
return null;
|
|
3782
3792
|
}
|
|
3783
|
-
function
|
|
3793
|
+
function _r(t) {
|
|
3784
3794
|
if (!t || typeof t != "object")
|
|
3785
3795
|
return !1;
|
|
3786
3796
|
const e = t;
|
|
3787
3797
|
return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
|
|
3788
3798
|
}
|
|
3789
|
-
function
|
|
3799
|
+
function H(t) {
|
|
3790
3800
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3791
3801
|
}
|
|
3792
|
-
function
|
|
3802
|
+
function Pr(t) {
|
|
3793
3803
|
if (!t || typeof t != "object")
|
|
3794
3804
|
return !1;
|
|
3795
3805
|
const e = t;
|
|
3796
3806
|
return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
|
|
3797
3807
|
}
|
|
3798
|
-
function
|
|
3799
|
-
return t.filter((e, s) =>
|
|
3808
|
+
function Ye(t) {
|
|
3809
|
+
return t.filter((e, s) => V(e) ? !Hr(t, s) && !ns(t, s) && !Br(t, s) && !Wr(t, s) : Ur(e) ? e.retryable === !0 && xr(t, s) ? !1 : !Nr(t, s) : !0);
|
|
3800
3810
|
}
|
|
3801
|
-
function
|
|
3811
|
+
function Ur(t) {
|
|
3802
3812
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3803
3813
|
}
|
|
3804
|
-
function
|
|
3814
|
+
function V(t) {
|
|
3805
3815
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3806
3816
|
}
|
|
3807
|
-
function
|
|
3817
|
+
function vr(t, e, s, n) {
|
|
3808
3818
|
const r = t.findIndex(
|
|
3809
|
-
(l,
|
|
3819
|
+
(l, c) => V(l) && !ns(t, c)
|
|
3810
3820
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3811
3821
|
(l) => l.role === "user" && l.id === o
|
|
3812
3822
|
) : null;
|
|
3813
3823
|
return {
|
|
3814
|
-
clientMessageId: a ?
|
|
3824
|
+
clientMessageId: a ? G(a) : o ? null : n,
|
|
3815
3825
|
respondsToUserMessageId: o,
|
|
3816
3826
|
runId: s ?? i?.runId ?? null
|
|
3817
3827
|
};
|
|
3818
3828
|
}
|
|
3819
|
-
function
|
|
3829
|
+
function Se(t) {
|
|
3820
3830
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3821
3831
|
}
|
|
3822
|
-
function
|
|
3823
|
-
return
|
|
3832
|
+
function Dr(t, e) {
|
|
3833
|
+
return H(e) ? "completed" : Se(t) ? "stopped" : !Ae(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
|
|
3824
3834
|
}
|
|
3825
|
-
function
|
|
3835
|
+
function Dt(t, e, s) {
|
|
3826
3836
|
const n = new Set(
|
|
3827
3837
|
t.filter(
|
|
3828
|
-
(r) => r.role === "user" && e !== null &&
|
|
3838
|
+
(r) => r.role === "user" && e !== null && G(r) === e
|
|
3829
3839
|
).map((r) => r.id)
|
|
3830
3840
|
);
|
|
3831
3841
|
return t.filter(
|
|
3832
|
-
(r) => !
|
|
3842
|
+
(r) => !V(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3833
3843
|
);
|
|
3834
3844
|
}
|
|
3835
|
-
function
|
|
3845
|
+
function ns(t, e) {
|
|
3836
3846
|
return t.some(
|
|
3837
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
3847
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && qr(
|
|
3838
3848
|
t,
|
|
3839
3849
|
e,
|
|
3840
3850
|
n
|
|
3841
3851
|
)
|
|
3842
3852
|
);
|
|
3843
3853
|
}
|
|
3844
|
-
function
|
|
3854
|
+
function qr(t, e, s) {
|
|
3845
3855
|
const n = t[e], r = t[s];
|
|
3846
3856
|
if (le(n, r))
|
|
3847
3857
|
return !0;
|
|
@@ -3852,26 +3862,26 @@ function _r(t, e, s) {
|
|
|
3852
3862
|
return t[i].id === n.respondsToUserMessageId;
|
|
3853
3863
|
return !1;
|
|
3854
3864
|
}
|
|
3855
|
-
function
|
|
3865
|
+
function Lr(t, e) {
|
|
3856
3866
|
const s = [...t].reverse().find(
|
|
3857
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
3867
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && qt(n) && !Or(
|
|
3858
3868
|
t,
|
|
3859
3869
|
n.respondsToUserMessageId
|
|
3860
3870
|
)
|
|
3861
3871
|
)?.respondsToUserMessageId;
|
|
3862
3872
|
return s ? t.map(
|
|
3863
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3873
|
+
(n) => n.respondsToUserMessageId === s && qt(n) ? { ...n, steered: !0 } : n
|
|
3864
3874
|
) : t;
|
|
3865
3875
|
}
|
|
3866
|
-
function
|
|
3867
|
-
return t.role === "tool" ||
|
|
3876
|
+
function qt(t) {
|
|
3877
|
+
return t.role === "tool" || V(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3868
3878
|
}
|
|
3869
|
-
function
|
|
3879
|
+
function Or(t, e) {
|
|
3870
3880
|
return t.some(
|
|
3871
|
-
(s) => s.respondsToUserMessageId === e && (
|
|
3881
|
+
(s) => s.respondsToUserMessageId === e && (H(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3872
3882
|
);
|
|
3873
3883
|
}
|
|
3874
|
-
function
|
|
3884
|
+
function Nr(t, e) {
|
|
3875
3885
|
const s = t[e];
|
|
3876
3886
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
3877
3887
|
const r = t[n];
|
|
@@ -3880,7 +3890,7 @@ function Dr(t, e) {
|
|
|
3880
3890
|
}
|
|
3881
3891
|
return !1;
|
|
3882
3892
|
}
|
|
3883
|
-
function
|
|
3893
|
+
function xr(t, e) {
|
|
3884
3894
|
const s = t[e];
|
|
3885
3895
|
if (!s.respondsToUserMessageId)
|
|
3886
3896
|
return !1;
|
|
@@ -3888,37 +3898,37 @@ function vr(t, e) {
|
|
|
3888
3898
|
const r = t[n];
|
|
3889
3899
|
if (r.role === "user")
|
|
3890
3900
|
return !1;
|
|
3891
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3901
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || V(r)))
|
|
3892
3902
|
return !0;
|
|
3893
3903
|
}
|
|
3894
3904
|
return !1;
|
|
3895
3905
|
}
|
|
3896
|
-
function
|
|
3906
|
+
function Br(t, e) {
|
|
3897
3907
|
const s = t[e];
|
|
3898
3908
|
return t.some(
|
|
3899
3909
|
(n, r) => r !== e && n.role === "assistant" && le(s, n)
|
|
3900
3910
|
);
|
|
3901
3911
|
}
|
|
3902
|
-
function
|
|
3912
|
+
function Wr(t, e) {
|
|
3903
3913
|
const s = t[e];
|
|
3904
3914
|
return t.some(
|
|
3905
3915
|
(n, r) => r !== e && n.role === "tool" && le(s, n)
|
|
3906
3916
|
);
|
|
3907
3917
|
}
|
|
3908
|
-
function
|
|
3918
|
+
function Hr(t, e) {
|
|
3909
3919
|
const s = t[e];
|
|
3910
3920
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3911
|
-
if (
|
|
3921
|
+
if (V(t[n]) && le(s, t[n]))
|
|
3912
3922
|
return !0;
|
|
3913
3923
|
return !1;
|
|
3914
3924
|
}
|
|
3915
3925
|
function le(t, e) {
|
|
3916
3926
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
3917
3927
|
}
|
|
3918
|
-
function
|
|
3928
|
+
function M(t, e) {
|
|
3919
3929
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
3920
3930
|
}
|
|
3921
|
-
function
|
|
3931
|
+
function $r(t, e) {
|
|
3922
3932
|
try {
|
|
3923
3933
|
const s = window.localStorage.getItem(`${Ft}${t}`);
|
|
3924
3934
|
if (!s)
|
|
@@ -3926,7 +3936,7 @@ function Nr(t, e) {
|
|
|
3926
3936
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3927
3937
|
if (e !== void 0 && r !== e)
|
|
3928
3938
|
return null;
|
|
3929
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3939
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Zr).filter((o) => !!o) : [];
|
|
3930
3940
|
return {
|
|
3931
3941
|
sessionId: r,
|
|
3932
3942
|
messages: i
|
|
@@ -3935,48 +3945,51 @@ function Nr(t, e) {
|
|
|
3935
3945
|
return null;
|
|
3936
3946
|
}
|
|
3937
3947
|
}
|
|
3938
|
-
function
|
|
3948
|
+
function rs(t) {
|
|
3949
|
+
return t.role === "user" || t.role === "assistant" || t.dataType === "run_status" || t.dataType === "run_error";
|
|
3950
|
+
}
|
|
3951
|
+
function jr(t, e) {
|
|
3939
3952
|
try {
|
|
3940
3953
|
window.localStorage.setItem(
|
|
3941
3954
|
`${Ft}${t}`,
|
|
3942
3955
|
JSON.stringify({
|
|
3943
3956
|
sessionId: e.sessionId,
|
|
3944
|
-
messages: e.messages.slice(-
|
|
3957
|
+
messages: e.messages.filter(rs).slice(-hn).map(ei)
|
|
3945
3958
|
})
|
|
3946
3959
|
);
|
|
3947
3960
|
} catch {
|
|
3948
3961
|
return;
|
|
3949
3962
|
}
|
|
3950
3963
|
}
|
|
3951
|
-
function
|
|
3964
|
+
function Fr(t) {
|
|
3952
3965
|
try {
|
|
3953
|
-
const e = window.localStorage.getItem(`${
|
|
3966
|
+
const e = window.localStorage.getItem(`${Ge}${t}`);
|
|
3954
3967
|
if (!e)
|
|
3955
3968
|
return [];
|
|
3956
3969
|
const s = JSON.parse(e);
|
|
3957
|
-
return Array.isArray(s) ? s.filter(
|
|
3970
|
+
return Array.isArray(s) ? s.filter(it) : [];
|
|
3958
3971
|
} catch {
|
|
3959
3972
|
return [];
|
|
3960
3973
|
}
|
|
3961
3974
|
}
|
|
3962
|
-
function
|
|
3975
|
+
function K(t, e) {
|
|
3963
3976
|
try {
|
|
3964
|
-
const s = e.filter(
|
|
3977
|
+
const s = e.filter(it);
|
|
3965
3978
|
if (s.length === 0) {
|
|
3966
|
-
window.localStorage.removeItem(`${
|
|
3979
|
+
window.localStorage.removeItem(`${Ge}${t}`);
|
|
3967
3980
|
return;
|
|
3968
3981
|
}
|
|
3969
3982
|
window.localStorage.setItem(
|
|
3970
|
-
`${
|
|
3983
|
+
`${Ge}${t}`,
|
|
3971
3984
|
JSON.stringify(s.slice(-25))
|
|
3972
3985
|
);
|
|
3973
3986
|
} catch {
|
|
3974
3987
|
return;
|
|
3975
3988
|
}
|
|
3976
3989
|
}
|
|
3977
|
-
function
|
|
3990
|
+
function is(t, e) {
|
|
3978
3991
|
try {
|
|
3979
|
-
const s = `${
|
|
3992
|
+
const s = `${Ce}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
3980
3993
|
...o,
|
|
3981
3994
|
storedAt: Date.now(),
|
|
3982
3995
|
unloadUrl: n,
|
|
@@ -3990,28 +4003,28 @@ function ns(t, e) {
|
|
|
3990
4003
|
} catch {
|
|
3991
4004
|
}
|
|
3992
4005
|
}
|
|
3993
|
-
function
|
|
4006
|
+
function Lt(t, e) {
|
|
3994
4007
|
try {
|
|
3995
|
-
if (window.sessionStorage.getItem(`${
|
|
4008
|
+
if (window.sessionStorage.getItem(`${Ce}${t}`) === null)
|
|
3996
4009
|
return;
|
|
3997
4010
|
} catch {
|
|
3998
4011
|
return;
|
|
3999
4012
|
}
|
|
4000
|
-
|
|
4013
|
+
is(t, e);
|
|
4001
4014
|
}
|
|
4002
|
-
function
|
|
4015
|
+
function zr(t) {
|
|
4003
4016
|
try {
|
|
4004
|
-
const e = `${
|
|
4017
|
+
const e = `${Ce}${t}`, s = window.sessionStorage.getItem(e);
|
|
4005
4018
|
if (window.sessionStorage.removeItem(e), !s)
|
|
4006
4019
|
return [];
|
|
4007
4020
|
const n = JSON.parse(s);
|
|
4008
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
4021
|
+
return Array.isArray(n) ? n.flatMap((r) => Gr(r) ? [{
|
|
4009
4022
|
...r.event,
|
|
4010
4023
|
page: b(),
|
|
4011
4024
|
rawOutput: {
|
|
4012
4025
|
pageContextRestarted: !0,
|
|
4013
4026
|
outcome: "unknown",
|
|
4014
|
-
message:
|
|
4027
|
+
message: Kr(location.href),
|
|
4015
4028
|
currentUrl: location.href,
|
|
4016
4029
|
console: [],
|
|
4017
4030
|
metadata: {
|
|
@@ -4028,17 +4041,17 @@ function Wr(t) {
|
|
|
4028
4041
|
return [];
|
|
4029
4042
|
}
|
|
4030
4043
|
}
|
|
4031
|
-
function
|
|
4044
|
+
function Kr(t) {
|
|
4032
4045
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
4033
4046
|
Current URL: ${t}`;
|
|
4034
4047
|
}
|
|
4035
|
-
function
|
|
4048
|
+
function Gr(t) {
|
|
4036
4049
|
if (!t || typeof t != "object")
|
|
4037
4050
|
return !1;
|
|
4038
4051
|
const e = t, s = e.event;
|
|
4039
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
4052
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && it(s) && s.type === "tool.result";
|
|
4040
4053
|
}
|
|
4041
|
-
function
|
|
4054
|
+
function Vr(t, e) {
|
|
4042
4055
|
const s = new Set(
|
|
4043
4056
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
4044
4057
|
);
|
|
@@ -4047,26 +4060,26 @@ function jr(t, e) {
|
|
|
4047
4060
|
...e.filter((n) => !s.has(n.callId))
|
|
4048
4061
|
];
|
|
4049
4062
|
}
|
|
4050
|
-
function
|
|
4063
|
+
function Xr(t) {
|
|
4051
4064
|
try {
|
|
4052
|
-
window.sessionStorage.removeItem(`${
|
|
4065
|
+
window.sessionStorage.removeItem(`${Ce}${t}`);
|
|
4053
4066
|
} catch {
|
|
4054
4067
|
return;
|
|
4055
4068
|
}
|
|
4056
4069
|
}
|
|
4057
|
-
function
|
|
4070
|
+
function it(t) {
|
|
4058
4071
|
if (!t || typeof t != "object")
|
|
4059
4072
|
return !1;
|
|
4060
4073
|
const e = t;
|
|
4061
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
4074
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && Ot(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Ot(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
|
|
4062
4075
|
}
|
|
4063
|
-
function
|
|
4076
|
+
function Ot(t) {
|
|
4064
4077
|
if (!t || typeof t != "object")
|
|
4065
4078
|
return !1;
|
|
4066
4079
|
const e = t;
|
|
4067
4080
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
4068
4081
|
}
|
|
4069
|
-
function
|
|
4082
|
+
function os(t, e) {
|
|
4070
4083
|
if (!Array.isArray(t))
|
|
4071
4084
|
return;
|
|
4072
4085
|
const s = t.filter((r) => {
|
|
@@ -4074,41 +4087,41 @@ function rs(t, e) {
|
|
|
4074
4087
|
return !1;
|
|
4075
4088
|
const i = r;
|
|
4076
4089
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
4077
|
-
}), n = e ? s.map((r) =>
|
|
4090
|
+
}), n = e ? s.map((r) => as(r, e)) : s;
|
|
4078
4091
|
return n.length > 0 ? n : void 0;
|
|
4079
4092
|
}
|
|
4080
|
-
function
|
|
4093
|
+
function as(t, e) {
|
|
4081
4094
|
return t.fileUrl?.startsWith("/") ? {
|
|
4082
4095
|
...t,
|
|
4083
4096
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
4084
4097
|
} : t;
|
|
4085
4098
|
}
|
|
4086
|
-
function
|
|
4087
|
-
return t.type ||
|
|
4099
|
+
function Qe(t) {
|
|
4100
|
+
return t.type || Qr(t.name) || "application/octet-stream";
|
|
4088
4101
|
}
|
|
4089
|
-
function
|
|
4090
|
-
|
|
4102
|
+
function Jr(t) {
|
|
4103
|
+
ls({
|
|
4091
4104
|
name: t.name,
|
|
4092
|
-
mimeType:
|
|
4105
|
+
mimeType: Qe(t),
|
|
4093
4106
|
sizeBytes: t.size
|
|
4094
4107
|
});
|
|
4095
4108
|
}
|
|
4096
|
-
function
|
|
4097
|
-
const e =
|
|
4098
|
-
if (!
|
|
4109
|
+
function ls(t) {
|
|
4110
|
+
const e = Yr(t.name), s = t.mimeType.trim().toLowerCase();
|
|
4111
|
+
if (!un.has(`${e}:${s}`))
|
|
4099
4112
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
4100
4113
|
if (t.sizeBytes <= 0 || t.sizeBytes >= $t)
|
|
4101
4114
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
4102
4115
|
}
|
|
4103
|
-
function
|
|
4116
|
+
function Yr(t) {
|
|
4104
4117
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
4105
4118
|
return s >= 0 ? e.slice(s) : "";
|
|
4106
4119
|
}
|
|
4107
|
-
function
|
|
4120
|
+
function Qr(t) {
|
|
4108
4121
|
const e = t.toLowerCase();
|
|
4109
4122
|
return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
|
|
4110
4123
|
}
|
|
4111
|
-
function
|
|
4124
|
+
function Zr(t) {
|
|
4112
4125
|
if (!t || typeof t != "object")
|
|
4113
4126
|
return null;
|
|
4114
4127
|
const e = t;
|
|
@@ -4125,17 +4138,17 @@ function Xr(t) {
|
|
|
4125
4138
|
dataType: typeof e.dataType == "string" ? e.dataType : void 0,
|
|
4126
4139
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
4127
4140
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
4128
|
-
attachments:
|
|
4141
|
+
attachments: os(e.attachments)?.map(Re),
|
|
4129
4142
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
4130
4143
|
};
|
|
4131
4144
|
}
|
|
4132
|
-
function
|
|
4145
|
+
function ei(t) {
|
|
4133
4146
|
return t.attachments?.length ? {
|
|
4134
4147
|
...t,
|
|
4135
|
-
attachments: t.attachments.map(
|
|
4148
|
+
attachments: t.attachments.map(Re)
|
|
4136
4149
|
} : t;
|
|
4137
4150
|
}
|
|
4138
|
-
function
|
|
4151
|
+
function Re(t) {
|
|
4139
4152
|
const {
|
|
4140
4153
|
dataUrl: e,
|
|
4141
4154
|
objectUrl: s,
|
|
@@ -4145,47 +4158,47 @@ function Me(t) {
|
|
|
4145
4158
|
} = t;
|
|
4146
4159
|
return i;
|
|
4147
4160
|
}
|
|
4148
|
-
function
|
|
4161
|
+
function N(t) {
|
|
4149
4162
|
const e = t.respondsToUserMessageId;
|
|
4150
4163
|
return typeof e == "string" && e ? e : null;
|
|
4151
4164
|
}
|
|
4152
|
-
function
|
|
4165
|
+
function C(t) {
|
|
4153
4166
|
const e = t.runId;
|
|
4154
4167
|
return typeof e == "string" && e ? e : null;
|
|
4155
4168
|
}
|
|
4156
|
-
function
|
|
4169
|
+
function ti(t) {
|
|
4157
4170
|
const e = t?.timeoutMs;
|
|
4158
|
-
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <=
|
|
4171
|
+
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= wn);
|
|
4159
4172
|
}
|
|
4160
|
-
function
|
|
4173
|
+
function cs(t) {
|
|
4161
4174
|
const e = {};
|
|
4162
4175
|
try {
|
|
4163
4176
|
new Headers(t).forEach((s, n) => {
|
|
4164
|
-
Object.keys(e).length <
|
|
4177
|
+
Object.keys(e).length < nt && (e[n] = ot(n, s));
|
|
4165
4178
|
});
|
|
4166
4179
|
} catch {
|
|
4167
4180
|
return {};
|
|
4168
4181
|
}
|
|
4169
4182
|
return e;
|
|
4170
4183
|
}
|
|
4171
|
-
function
|
|
4172
|
-
return
|
|
4184
|
+
function ot(t, e) {
|
|
4185
|
+
return fs(t) ? _e : W(ke(e), dn);
|
|
4173
4186
|
}
|
|
4174
|
-
function
|
|
4187
|
+
function si(t, e) {
|
|
4175
4188
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
4176
4189
|
}
|
|
4177
|
-
async function
|
|
4178
|
-
const r =
|
|
4190
|
+
async function ni(t, e, s, n) {
|
|
4191
|
+
const r = cs(t.headers);
|
|
4179
4192
|
n({
|
|
4180
4193
|
...e,
|
|
4181
4194
|
responseStatus: t.status,
|
|
4182
4195
|
responseHeaders: r,
|
|
4183
|
-
responseBody: await
|
|
4196
|
+
responseBody: await ri(t),
|
|
4184
4197
|
durationMs: Date.now() - s
|
|
4185
4198
|
});
|
|
4186
4199
|
}
|
|
4187
|
-
async function
|
|
4188
|
-
if (!
|
|
4200
|
+
async function ri(t) {
|
|
4201
|
+
if (!us(t.headers))
|
|
4189
4202
|
return;
|
|
4190
4203
|
let e = null, s = null;
|
|
4191
4204
|
try {
|
|
@@ -4194,20 +4207,20 @@ async function Zr(t) {
|
|
|
4194
4207
|
const n = new Promise((a) => {
|
|
4195
4208
|
s = window.setTimeout(() => {
|
|
4196
4209
|
e?.cancel(), a("timeout");
|
|
4197
|
-
},
|
|
4210
|
+
}, pn);
|
|
4198
4211
|
}), r = new TextDecoder();
|
|
4199
4212
|
let i = "", o = 0;
|
|
4200
4213
|
for (; ; ) {
|
|
4201
4214
|
const a = await Promise.race([e.read(), n]);
|
|
4202
4215
|
if (a === "timeout")
|
|
4203
4216
|
return;
|
|
4204
|
-
const { done: l, value:
|
|
4217
|
+
const { done: l, value: c } = a;
|
|
4205
4218
|
if (l)
|
|
4206
|
-
return
|
|
4207
|
-
const d =
|
|
4208
|
-
if (
|
|
4209
|
-
return i += r.decode(
|
|
4210
|
-
o +=
|
|
4219
|
+
return W(i + r.decode());
|
|
4220
|
+
const d = st - o;
|
|
4221
|
+
if (c.byteLength > d)
|
|
4222
|
+
return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${W(i)}... [truncated]`;
|
|
4223
|
+
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
4211
4224
|
}
|
|
4212
4225
|
} catch {
|
|
4213
4226
|
e?.cancel();
|
|
@@ -4216,20 +4229,20 @@ async function Zr(t) {
|
|
|
4216
4229
|
s !== null && window.clearTimeout(s);
|
|
4217
4230
|
}
|
|
4218
4231
|
}
|
|
4219
|
-
function
|
|
4220
|
-
if (
|
|
4232
|
+
function ii(t, e) {
|
|
4233
|
+
if (us(new Headers(e)))
|
|
4221
4234
|
try {
|
|
4222
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
4235
|
+
return t.responseType === "" || t.responseType === "text" ? W(t.responseText ?? "") : void 0;
|
|
4223
4236
|
} catch {
|
|
4224
4237
|
return;
|
|
4225
4238
|
}
|
|
4226
4239
|
}
|
|
4227
4240
|
function Nt(t) {
|
|
4228
4241
|
if (typeof t == "string")
|
|
4229
|
-
return
|
|
4242
|
+
return W(t);
|
|
4230
4243
|
}
|
|
4231
|
-
function
|
|
4232
|
-
return
|
|
4244
|
+
function oi(t) {
|
|
4245
|
+
return L({
|
|
4233
4246
|
...t,
|
|
4234
4247
|
requestBody: xt(t.requestBody),
|
|
4235
4248
|
responseBody: xt(t.responseBody)
|
|
@@ -4240,21 +4253,21 @@ function xt(t) {
|
|
|
4240
4253
|
return t;
|
|
4241
4254
|
const e = t.trim();
|
|
4242
4255
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4243
|
-
return
|
|
4256
|
+
return ke(t);
|
|
4244
4257
|
try {
|
|
4245
|
-
return JSON.stringify(
|
|
4258
|
+
return JSON.stringify(L(JSON.parse(t)));
|
|
4246
4259
|
} catch {
|
|
4247
|
-
return
|
|
4260
|
+
return ke(t);
|
|
4248
4261
|
}
|
|
4249
4262
|
}
|
|
4250
|
-
function
|
|
4263
|
+
function us(t) {
|
|
4251
4264
|
if (!t)
|
|
4252
4265
|
return !1;
|
|
4253
4266
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4254
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
4267
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= st && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4255
4268
|
}
|
|
4256
4269
|
function J(t, e = {}, s) {
|
|
4257
|
-
if (
|
|
4270
|
+
if (li(s))
|
|
4258
4271
|
return !0;
|
|
4259
4272
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
4260
4273
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -4269,7 +4282,7 @@ function J(t, e = {}, s) {
|
|
|
4269
4282
|
return !0;
|
|
4270
4283
|
}
|
|
4271
4284
|
}
|
|
4272
|
-
function
|
|
4285
|
+
function ai(t, e) {
|
|
4273
4286
|
if (J(t))
|
|
4274
4287
|
return !0;
|
|
4275
4288
|
try {
|
|
@@ -4279,117 +4292,117 @@ function si(t, e) {
|
|
|
4279
4292
|
return !0;
|
|
4280
4293
|
}
|
|
4281
4294
|
}
|
|
4282
|
-
function
|
|
4295
|
+
function li(t) {
|
|
4283
4296
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4284
4297
|
}
|
|
4285
|
-
function
|
|
4298
|
+
function ci(t) {
|
|
4286
4299
|
const e = {};
|
|
4287
4300
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4288
4301
|
const n = s.indexOf(":");
|
|
4289
4302
|
if (n <= 0)
|
|
4290
4303
|
continue;
|
|
4291
|
-
if (Object.keys(e).length >=
|
|
4304
|
+
if (Object.keys(e).length >= nt)
|
|
4292
4305
|
break;
|
|
4293
4306
|
const r = s.slice(0, n).trim();
|
|
4294
|
-
e[r] =
|
|
4307
|
+
e[r] = ot(r, s.slice(n + 1).trim());
|
|
4295
4308
|
}
|
|
4296
4309
|
return e;
|
|
4297
4310
|
}
|
|
4298
|
-
function
|
|
4311
|
+
function W(t, e = st) {
|
|
4299
4312
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4300
4313
|
}
|
|
4301
|
-
function
|
|
4314
|
+
function Fe(t) {
|
|
4302
4315
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4303
4316
|
}
|
|
4304
|
-
class
|
|
4317
|
+
class we extends Error {
|
|
4305
4318
|
constructor(e, s) {
|
|
4306
4319
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4307
4320
|
}
|
|
4308
4321
|
status;
|
|
4309
4322
|
}
|
|
4310
|
-
async function
|
|
4323
|
+
async function ye(t, e) {
|
|
4311
4324
|
let s = null;
|
|
4312
4325
|
for (let n = 0; n < At; n += 1)
|
|
4313
4326
|
try {
|
|
4314
4327
|
return await t();
|
|
4315
4328
|
} catch (r) {
|
|
4316
|
-
if (s = r, n >= At - 1 || !
|
|
4329
|
+
if (s = r, n >= At - 1 || !di(r))
|
|
4317
4330
|
throw r;
|
|
4318
|
-
await
|
|
4331
|
+
await ui(n);
|
|
4319
4332
|
}
|
|
4320
4333
|
throw s instanceof Error ? s : new Error(e);
|
|
4321
4334
|
}
|
|
4322
|
-
function
|
|
4335
|
+
function ui(t) {
|
|
4323
4336
|
return new Promise((e) => {
|
|
4324
|
-
window.setTimeout(e,
|
|
4337
|
+
window.setTimeout(e, cn[t] ?? 0);
|
|
4325
4338
|
});
|
|
4326
4339
|
}
|
|
4327
|
-
function
|
|
4328
|
-
return t instanceof
|
|
4340
|
+
function di(t) {
|
|
4341
|
+
return t instanceof we ? pi(t.status) : t instanceof TypeError;
|
|
4329
4342
|
}
|
|
4330
|
-
function
|
|
4343
|
+
function pi(t) {
|
|
4331
4344
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
4332
4345
|
}
|
|
4333
|
-
function
|
|
4346
|
+
function hi(t) {
|
|
4334
4347
|
return t === 401 || t === 403;
|
|
4335
4348
|
}
|
|
4336
|
-
const
|
|
4337
|
-
function
|
|
4338
|
-
return
|
|
4349
|
+
const _e = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", gi = "[REDACTED_SIGNED_URL]", fi = 20, mi = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, ds = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ps = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, hs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, gs = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, yi = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Ii = /\bhttps?:\/\/[^\s"'<>]+/gi, Ti = /[),.;\]]+$/;
|
|
4350
|
+
function L(t) {
|
|
4351
|
+
return Ee(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4339
4352
|
}
|
|
4340
|
-
function
|
|
4353
|
+
function Ee(t, e, s) {
|
|
4341
4354
|
if (typeof t == "string")
|
|
4342
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4355
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : ke(t);
|
|
4343
4356
|
if (t === null || typeof t != "object")
|
|
4344
4357
|
return t;
|
|
4345
|
-
if (e >=
|
|
4358
|
+
if (e >= fi)
|
|
4346
4359
|
return "[REDACTED_MAX_DEPTH]";
|
|
4347
4360
|
if (s.has(t))
|
|
4348
4361
|
return "[REDACTED_CIRCULAR]";
|
|
4349
4362
|
if (s.add(t), Array.isArray(t))
|
|
4350
|
-
return t.map((r) =>
|
|
4363
|
+
return t.map((r) => Ee(r, e + 1, s));
|
|
4351
4364
|
const n = {};
|
|
4352
4365
|
for (const [r, i] of Object.entries(t))
|
|
4353
|
-
r === "pageContent" ? n[r] = i :
|
|
4366
|
+
r === "pageContent" ? n[r] = i : fs(r) ? n[r] = _e : n[r] = r.toLowerCase() === "url" ? Si(i) : Ee(i, e + 1, s);
|
|
4354
4367
|
return n;
|
|
4355
4368
|
}
|
|
4356
|
-
function
|
|
4369
|
+
function fs(t) {
|
|
4357
4370
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
4358
4371
|
return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
|
|
4359
4372
|
}
|
|
4360
|
-
function
|
|
4361
|
-
return typeof t == "string" ?
|
|
4373
|
+
function Si(t) {
|
|
4374
|
+
return typeof t == "string" ? ms(t) : Ee(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4362
4375
|
}
|
|
4363
|
-
function
|
|
4376
|
+
function ms(t) {
|
|
4364
4377
|
try {
|
|
4365
4378
|
const e = new URL(t, location.href);
|
|
4366
4379
|
for (const s of Array.from(e.searchParams.keys()))
|
|
4367
|
-
|
|
4368
|
-
return e.username && (e.username =
|
|
4380
|
+
mi.test(s) && e.searchParams.set(s, $);
|
|
4381
|
+
return e.username && (e.username = $), e.password && (e.password = $), e.toString();
|
|
4369
4382
|
} catch {
|
|
4370
|
-
return
|
|
4383
|
+
return wi(t);
|
|
4371
4384
|
}
|
|
4372
4385
|
}
|
|
4373
|
-
function
|
|
4374
|
-
return t.replace(
|
|
4386
|
+
function ke(t) {
|
|
4387
|
+
return t.replace(yi, gi).replace(Ii, Mi).replace(ds, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(hs, $).replace(gs, (e, s) => `${s}: ${_e}`);
|
|
4375
4388
|
}
|
|
4376
|
-
function
|
|
4377
|
-
return t.replace(
|
|
4389
|
+
function wi(t) {
|
|
4390
|
+
return t.replace(ds, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(hs, $).replace(gs, (e, s) => `${s}: ${_e}`);
|
|
4378
4391
|
}
|
|
4379
|
-
function
|
|
4380
|
-
const e = t.match(
|
|
4381
|
-
return `${
|
|
4392
|
+
function Mi(t) {
|
|
4393
|
+
const e = t.match(Ti)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4394
|
+
return `${ms(s)}${e}`;
|
|
4382
4395
|
}
|
|
4383
4396
|
export {
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4397
|
+
ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4398
|
+
Ke as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4399
|
+
Ks as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4400
|
+
zs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4401
|
+
Gs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
4402
|
+
Ai as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
4390
4403
|
zt as PlunoProductAgent,
|
|
4391
|
-
|
|
4404
|
+
fn as calculateReconnectDelay,
|
|
4392
4405
|
zt as default,
|
|
4393
|
-
|
|
4394
|
-
|
|
4406
|
+
Nn as getProductAgentOriginAccessErrorMessage,
|
|
4407
|
+
Jr as validateProductAgentProviderInputFile
|
|
4395
4408
|
};
|