@pluno/product-agent-web 0.1.191 → 0.1.192
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 +1 -0
- package/dist/product-agent-sdk.js +855 -809
- package/dist/product-agent-widget.js +1737 -1691
- package/dist/runRecovery.d.ts +18 -0
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Rs = "pluno-product-agent-attachments";
|
|
2
2
|
const Ve = "files";
|
|
3
|
-
async function
|
|
3
|
+
async function Es(t) {
|
|
4
4
|
const e = await st();
|
|
5
|
-
await
|
|
5
|
+
await bs(e, "readwrite", (s) => s.put(t));
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
7
|
+
async function ks(t, e) {
|
|
8
8
|
const s = await st();
|
|
9
9
|
await nt(s, "readwrite", async (n) => {
|
|
10
10
|
const r = await rt(
|
|
@@ -16,7 +16,7 @@ async function Ms(t, e) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
19
|
+
async function Cs(t = 864e5) {
|
|
20
20
|
const e = await st(), s = Date.now() - t;
|
|
21
21
|
await nt(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
@@ -25,14 +25,14 @@ async function As(t = 864e5) {
|
|
|
25
25
|
}
|
|
26
26
|
function st() {
|
|
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(Rs, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
30
|
const r = s.result.createObjectStore(Ve, { 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
|
|
35
|
+
async function bs(t, e, s) {
|
|
36
36
|
return await nt(t, e, async (n) => await rt(s(n)));
|
|
37
37
|
}
|
|
38
38
|
function nt(t, e, s) {
|
|
@@ -62,11 +62,11 @@ function rt(t) {
|
|
|
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 _s(t) {
|
|
66
66
|
return t !== null && (typeof t == "object" || typeof t == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const n = Reflect.get(t, "pluno"), r =
|
|
68
|
+
function $t(t, e, s) {
|
|
69
|
+
const n = Reflect.get(t, "pluno"), r = _s(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,15 +80,15 @@ function Ht(t, e, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const Ps = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function Us(t, e) {
|
|
85
85
|
return e ? t.replace(
|
|
86
|
-
|
|
86
|
+
Ps,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
|
|
88
88
|
) : t;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
91
|
-
function
|
|
90
|
+
const vs = "suggest_share_on_socials";
|
|
91
|
+
function Ds(t) {
|
|
92
92
|
let e = t;
|
|
93
93
|
if (typeof t == "string")
|
|
94
94
|
try {
|
|
@@ -96,17 +96,17 @@ function _s(t) {
|
|
|
96
96
|
} catch {
|
|
97
97
|
return null;
|
|
98
98
|
}
|
|
99
|
-
const s =
|
|
99
|
+
const s = Os(e);
|
|
100
100
|
return s ? typeof s.showSharePrompt == "boolean" ? s.showSharePrompt : s.ok === !0 && typeof s.message == "string" && s.message.includes("social-sharing prompt") ? !0 : null : null;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Os(t) {
|
|
103
103
|
return t && typeof t == "object" && !Array.isArray(t) ? t : null;
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
function
|
|
107
|
-
return (t.type === "function_call" || t.type === "tool_call") && t.name ===
|
|
105
|
+
const qs = "save_runtime_captured_skill";
|
|
106
|
+
function Ls(t) {
|
|
107
|
+
return (t.type === "function_call" || t.type === "tool_call") && t.name === qs;
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function Ns(t, e, s) {
|
|
110
110
|
const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
111
111
|
n.flatMap(
|
|
112
112
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
@@ -123,37 +123,37 @@ function Ds(t, e, s) {
|
|
|
123
123
|
)
|
|
124
124
|
), c = /* @__PURE__ */ new Map();
|
|
125
125
|
for (const { item: u, identity: p } of i)
|
|
126
|
-
for (const
|
|
127
|
-
const
|
|
128
|
-
(!
|
|
126
|
+
for (const m of p.activityKeys ?? []) {
|
|
127
|
+
const f = c.get(m);
|
|
128
|
+
(!f || s(f).isTransient) && c.set(m, u);
|
|
129
129
|
}
|
|
130
130
|
const d = new Set(i.map(({ identity: u }) => u.id)), h = new Set(
|
|
131
131
|
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
132
|
-
),
|
|
132
|
+
), g = /* @__PURE__ */ new Set(), y = [];
|
|
133
133
|
for (const u of t) {
|
|
134
134
|
const p = s(u);
|
|
135
|
-
let
|
|
136
|
-
if (p.isOptimistic && p.optimisticKey ?
|
|
137
|
-
|
|
135
|
+
let m = o.get(p.id);
|
|
136
|
+
if (p.isOptimistic && p.optimisticKey ? m = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? m = l.get(p.assistantDraftKey) : p.isActivity && (m = p.activityKeys?.map((R) => c.get(R)).find((R) => R !== void 0) ?? m), m && !g.has(m)) {
|
|
137
|
+
y.push(m), g.add(m);
|
|
138
138
|
continue;
|
|
139
139
|
}
|
|
140
|
-
const
|
|
141
|
-
(p.isOptimistic || (p.isAssistantDraft || p.isActivity) &&
|
|
140
|
+
const f = p.respondsToUserMessageId !== void 0 && d.has(p.respondsToUserMessageId) || p.runId !== void 0 && h.has(p.runId);
|
|
141
|
+
(p.isOptimistic || (p.isAssistantDraft || p.isActivity) && f) && y.push(u);
|
|
142
142
|
}
|
|
143
143
|
for (const { item: u } of i)
|
|
144
|
-
|
|
145
|
-
return
|
|
144
|
+
g.has(u) || y.push(u);
|
|
145
|
+
return y;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function xs(t, e, s, n) {
|
|
148
148
|
return t.filter((r) => {
|
|
149
149
|
const i = n(r);
|
|
150
150
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
const xe = "pluno.productAgent.transportId",
|
|
153
|
+
const xe = "pluno.productAgent.transportId", Bs = "pluno.productAgent.transportIdentity", Be = "pluno.productAgent.transportIdentity.event", Ws = 50, Hs = globalThis.setTimeout.bind(globalThis);
|
|
154
154
|
let oe = null;
|
|
155
|
-
const
|
|
156
|
-
async function
|
|
155
|
+
const we = /* @__PURE__ */ new Set(), We = /* @__PURE__ */ new Map();
|
|
156
|
+
async function $s(t = Ft()) {
|
|
157
157
|
const e = t.randomUUID(), s = t.storage.getItem(xe);
|
|
158
158
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
159
159
|
const o = t.channel.subscribe((l) => {
|
|
@@ -191,42 +191,42 @@ async function xs(t = $t()) {
|
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
async function
|
|
195
|
-
oe || (oe =
|
|
196
|
-
|
|
194
|
+
async function Fs(t = !1) {
|
|
195
|
+
oe || (oe = $s({
|
|
196
|
+
...Ft(),
|
|
197
197
|
skipStoredIdentityCollisionCheck: t
|
|
198
198
|
}), oe.then((r) => {
|
|
199
199
|
const i = (o) => {
|
|
200
|
-
o.persisted || (r.release(), oe = null,
|
|
200
|
+
o.persisted || (r.release(), oe = null, we.clear(), window.removeEventListener("pagehide", i));
|
|
201
201
|
};
|
|
202
202
|
window.addEventListener("pagehide", i);
|
|
203
203
|
}));
|
|
204
|
-
const e = await oe, s =
|
|
205
|
-
|
|
204
|
+
const e = await oe, s = js();
|
|
205
|
+
we.add(s);
|
|
206
206
|
let n = !1;
|
|
207
207
|
return {
|
|
208
208
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
209
209
|
transportId: s === 0 ? e.transportId : `${e.transportId}.${s}`,
|
|
210
210
|
release: () => {
|
|
211
|
-
n || (n = !0,
|
|
211
|
+
n || (n = !0, we.delete(s));
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function js() {
|
|
216
216
|
let t = 0;
|
|
217
|
-
for (;
|
|
217
|
+
for (; we.has(t); )
|
|
218
218
|
t += 1;
|
|
219
219
|
return t;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function Ft() {
|
|
222
222
|
return {
|
|
223
|
-
storage:
|
|
224
|
-
channel:
|
|
223
|
+
storage: zs(),
|
|
224
|
+
channel: Ks(),
|
|
225
225
|
randomUUID: () => crypto.randomUUID(),
|
|
226
|
-
settle: () => new Promise((t) =>
|
|
226
|
+
settle: () => new Promise((t) => Hs(t, Ws))
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function zs() {
|
|
230
230
|
return {
|
|
231
231
|
getItem: (t) => {
|
|
232
232
|
try {
|
|
@@ -244,9 +244,9 @@ function Hs() {
|
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function Ks() {
|
|
248
248
|
if (typeof BroadcastChannel < "u") {
|
|
249
|
-
const t = new BroadcastChannel(
|
|
249
|
+
const t = new BroadcastChannel(Bs);
|
|
250
250
|
return {
|
|
251
251
|
postMessage: (e) => t.postMessage(e),
|
|
252
252
|
subscribe: (e) => {
|
|
@@ -256,9 +256,9 @@ function $s() {
|
|
|
256
256
|
close: () => t.close()
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
|
-
return
|
|
259
|
+
return Gs();
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function Gs() {
|
|
262
262
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
263
263
|
if (s.key !== Be || !s.newValue)
|
|
264
264
|
return;
|
|
@@ -279,8 +279,8 @@ function Fs() {
|
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
function
|
|
282
|
+
const jt = "schedule_follow_up";
|
|
283
|
+
function Vs(t) {
|
|
284
284
|
let e = t;
|
|
285
285
|
if (typeof e == "string")
|
|
286
286
|
try {
|
|
@@ -291,24 +291,50 @@ function js(t) {
|
|
|
291
291
|
if (!e || typeof e != "object")
|
|
292
292
|
return null;
|
|
293
293
|
const s = e;
|
|
294
|
-
return s.ok !== !0 || s.toolName !==
|
|
294
|
+
return s.ok !== !0 || s.toolName !== jt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : {
|
|
295
295
|
id: typeof s.taskId == "string" && s.taskId ? s.taskId : null,
|
|
296
296
|
dueAt: s.dueAt
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
|
-
const
|
|
299
|
+
const Xs = [
|
|
300
300
|
{ value: "gpt-5.6-sol", label: "gpt-5.6-sol", price: "$$" },
|
|
301
301
|
{ value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5", price: "$$" },
|
|
302
302
|
{ value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash", price: "$" }
|
|
303
|
-
],
|
|
303
|
+
], Js = [
|
|
304
304
|
{ value: "anthropic/claude-opus-5", label: "Claude Opus 5", price: "$$$" },
|
|
305
305
|
{ value: "gpt-5.6-terra", label: "gpt-5.6-terra", price: "$$" }
|
|
306
|
-
],
|
|
307
|
-
...
|
|
308
|
-
...
|
|
309
|
-
], He = (t) =>
|
|
310
|
-
|
|
311
|
-
|
|
306
|
+
], Qs = [
|
|
307
|
+
...Xs,
|
|
308
|
+
...Js
|
|
309
|
+
], He = (t) => Qs.some((e) => e.value === t);
|
|
310
|
+
function Ys(t, e) {
|
|
311
|
+
return t.filter((s, n) => {
|
|
312
|
+
const r = ft(s);
|
|
313
|
+
return zt(r) ? !t.slice(n + 1).some((i) => {
|
|
314
|
+
const o = ft(i);
|
|
315
|
+
return Kt(r, o) && Gt(r, o);
|
|
316
|
+
}) : !0;
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function zt(t) {
|
|
320
|
+
return t.type === "run_status" && t.status === "stopped" && t.reason === "task_tab_closed";
|
|
321
|
+
}
|
|
322
|
+
function Zs(t, e) {
|
|
323
|
+
return t.reason === "task_tab_closed" && Gt(t, e) && Kt(t, e);
|
|
324
|
+
}
|
|
325
|
+
function ft(t) {
|
|
326
|
+
return t.data && typeof t.data == "object" ? t.data : {};
|
|
327
|
+
}
|
|
328
|
+
function Kt(t, e) {
|
|
329
|
+
const s = typeof t.runId == "string" ? t.runId : null, n = typeof e.runId == "string" ? e.runId : null;
|
|
330
|
+
return s && n && s === n ? !1 : e.type === "message" ? e.role === "assistant" : e.type === "run_status" ? !zt(e) : e.type === "run_error";
|
|
331
|
+
}
|
|
332
|
+
function Gt(t, e) {
|
|
333
|
+
return typeof t.respondsToUserMessageId == "string" && typeof e.respondsToUserMessageId == "string" ? t.respondsToUserMessageId === e.respondsToUserMessageId : typeof t.clientMessageId == "string" && typeof e.clientMessageId == "string" ? t.clientMessageId === e.clientMessageId : typeof t.runId == "string" && typeof e.runId == "string" && t.runId === e.runId;
|
|
334
|
+
}
|
|
335
|
+
const en = globalThis.fetch.bind(globalThis), Xe = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', tn = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', sn = ".pluno-pa-widget__panel", nn = ".pluno-pa-widget__timeline", mt = `${Xe}[data-pluno-sdk-preview-channel]`;
|
|
336
|
+
let rn = 0;
|
|
337
|
+
function yt(t) {
|
|
312
338
|
const e = {};
|
|
313
339
|
for (const o of [
|
|
314
340
|
"type",
|
|
@@ -358,36 +384,36 @@ function $e(t, e, s) {
|
|
|
358
384
|
source: "web_sdk",
|
|
359
385
|
category: t,
|
|
360
386
|
name: e,
|
|
361
|
-
sequence: ++
|
|
387
|
+
sequence: ++rn,
|
|
362
388
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
363
389
|
monotonicMs: performance.now(),
|
|
364
390
|
data: s
|
|
365
391
|
};
|
|
366
392
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
367
393
|
}
|
|
368
|
-
class
|
|
394
|
+
class fe extends Error {
|
|
369
395
|
}
|
|
370
|
-
function
|
|
396
|
+
function on(t) {
|
|
371
397
|
return t === 408 || t === 425 || t === 429 || t >= 500;
|
|
372
398
|
}
|
|
373
|
-
const
|
|
399
|
+
const an = "https://app.pluno.ai", ln = 2e4, cn = 1e4, un = 1e4, dn = 1e4, pn = 1e4, hn = 3e3, gn = 3e4, fn = 1e3, It = 3e4, St = 0.2, Tt = 6e4, wt = 15e3, ae = 8, Mt = "Browser connection was interrupted.", At = 15e3, mn = "Pluno could not send this message. Try it again.", Rt = 2e3, yn = 1e3, In = 100, Et = 8e3, kt = 3, Sn = [300, 1e3], Vt = 50 * 1024 * 1024, Tn = /* @__PURE__ */ new Set([
|
|
374
400
|
".jpeg:image/jpeg",
|
|
375
401
|
".jpg:image/jpeg",
|
|
376
402
|
".pdf:application/pdf",
|
|
377
403
|
".png:image/png",
|
|
378
404
|
".webp:image/webp"
|
|
379
|
-
]),
|
|
405
|
+
]), Oi = ".pdf,.png,.jpg,.jpeg,.webp", it = 64e3, Fe = 4e3, ot = 30, wn = 2e3, Mn = 1e3, Xt = "Image is too large for model vision input.", An = 100, Jt = "pluno.productAgent.state.", Je = "pluno.productAgent.pendingEvents.", Pe = "pluno.productAgent.activeToolCalls.", Rn = 100;
|
|
380
406
|
function le(t, e = 0) {
|
|
381
407
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
382
408
|
return Math.max(e, s);
|
|
383
409
|
}
|
|
384
|
-
const
|
|
385
|
-
let
|
|
386
|
-
function
|
|
387
|
-
const s = Math.min(
|
|
388
|
-
return Math.min(
|
|
410
|
+
const Me = /* @__PURE__ */ new Set();
|
|
411
|
+
let me = null;
|
|
412
|
+
function En(t, e = Math.random) {
|
|
413
|
+
const s = Math.min(It, fn * 2 ** t), n = 1 - St + e() * St * 2;
|
|
414
|
+
return Math.min(It, Math.round(s * n));
|
|
389
415
|
}
|
|
390
|
-
function
|
|
416
|
+
function kn(t, e, s) {
|
|
391
417
|
return new Promise((n, r) => {
|
|
392
418
|
const i = setTimeout(() => r(new Error(s)), e);
|
|
393
419
|
t.then(
|
|
@@ -400,19 +426,19 @@ function Tn(t, e, s) {
|
|
|
400
426
|
);
|
|
401
427
|
});
|
|
402
428
|
}
|
|
403
|
-
class
|
|
429
|
+
class Qt {
|
|
404
430
|
constructor(e, s) {
|
|
405
431
|
this.options = e, this.transportIdentity = s, this.personalModelSelectionOverride = e.productVariant === "personal" && He(e.model) ? e.model : null, this.state = {
|
|
406
432
|
...this.state,
|
|
407
|
-
starterPrompts:
|
|
433
|
+
starterPrompts: ir(e.initialStarterPrompts)
|
|
408
434
|
};
|
|
409
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
435
|
+
const n = e.restorePersistedState === !1 ? null : Zr(e.clientId, e.expectedPersistedSessionId);
|
|
410
436
|
n && (this.state = {
|
|
411
437
|
...this.state,
|
|
412
438
|
...n,
|
|
413
439
|
// Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
|
|
414
440
|
// activity is deliberately not restored here because it hydrates after the transcript is visible.
|
|
415
|
-
messages: n.messages.filter(
|
|
441
|
+
messages: n.messages.filter(us),
|
|
416
442
|
isLoadingSession: n.sessionId !== null,
|
|
417
443
|
status: "idle",
|
|
418
444
|
user: null,
|
|
@@ -427,14 +453,14 @@ class Gt {
|
|
|
427
453
|
taskStatus: null,
|
|
428
454
|
isRetrying: !1,
|
|
429
455
|
lastError: null
|
|
430
|
-
}), this.queuedClientEvents =
|
|
431
|
-
|
|
432
|
-
|
|
456
|
+
}), this.queuedClientEvents = ii(
|
|
457
|
+
ti(e.clientId),
|
|
458
|
+
si(e.clientId)
|
|
433
459
|
);
|
|
434
460
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
435
461
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
436
462
|
);
|
|
437
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"),
|
|
463
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), G(e.clientId, this.queuedClientEvents);
|
|
438
464
|
}
|
|
439
465
|
options;
|
|
440
466
|
listeners = {};
|
|
@@ -540,17 +566,17 @@ class Gt {
|
|
|
540
566
|
lastErrorSecuritySettingsUrl: null
|
|
541
567
|
};
|
|
542
568
|
static async init(e) {
|
|
543
|
-
const s = e, n = await
|
|
569
|
+
const s = e, n = await Fs(
|
|
544
570
|
s.skipStoredTransportIdentityCollisionCheck === !0
|
|
545
|
-
), r = new
|
|
571
|
+
), r = new Qt({
|
|
546
572
|
...e,
|
|
547
|
-
backendUrl:
|
|
548
|
-
clientId: e.clientId ??
|
|
573
|
+
backendUrl: jn(e.backendUrl ?? an),
|
|
574
|
+
clientId: e.clientId ?? ur(),
|
|
549
575
|
productVariant: e.productVariant ?? "customer_embedded",
|
|
550
|
-
entrySurface:
|
|
576
|
+
entrySurface: zn(e.entrySurface)
|
|
551
577
|
}, n);
|
|
552
578
|
try {
|
|
553
|
-
|
|
579
|
+
Cs().catch((i) => {
|
|
554
580
|
A("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
555
581
|
message: i instanceof Error ? i.message : String(i)
|
|
556
582
|
});
|
|
@@ -576,7 +602,7 @@ class Gt {
|
|
|
576
602
|
const s = e.trim();
|
|
577
603
|
if (!s)
|
|
578
604
|
return;
|
|
579
|
-
const n = this.stagedProactiveSuggestionQuestionMessageId ?? `local-proactive-suggestion-edit-${
|
|
605
|
+
const n = this.stagedProactiveSuggestionQuestionMessageId ?? `local-proactive-suggestion-edit-${N()}`;
|
|
580
606
|
this.stagedProactiveSuggestionQuestionMessageId = n;
|
|
581
607
|
const r = {
|
|
582
608
|
id: n,
|
|
@@ -596,14 +622,14 @@ class Gt {
|
|
|
596
622
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
597
623
|
);
|
|
598
624
|
try {
|
|
599
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
625
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await kn(this.options.tokenProvider(), un, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
600
626
|
return;
|
|
601
627
|
if (!this.token && !this.options.webSocketFactory)
|
|
602
628
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
603
|
-
const s =
|
|
629
|
+
const s = Vn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
604
630
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
605
631
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (A("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
606
|
-
},
|
|
632
|
+
}, dn), n.addEventListener("open", () => {
|
|
607
633
|
this.socket !== n || (this.clearSocketConnectTimer(), A("web-sdk.agent", "Pluno socket opened", {
|
|
608
634
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
609
635
|
isThinking: this.state.isThinking
|
|
@@ -615,16 +641,16 @@ class Gt {
|
|
|
615
641
|
pageUrl: location.href
|
|
616
642
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
617
643
|
this.socket === n && (A("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
618
|
-
},
|
|
644
|
+
}, pn));
|
|
619
645
|
}), n.addEventListener("message", (r) => {
|
|
620
|
-
this.socket === n && this.handleServerEvent(
|
|
646
|
+
this.socket === n && this.handleServerEvent(nr(r.data));
|
|
621
647
|
}), n.addEventListener("sendfailure", (r) => {
|
|
622
648
|
if (this.socket !== n)
|
|
623
649
|
return;
|
|
624
|
-
const i =
|
|
650
|
+
const i = rr(r?.detail?.data);
|
|
625
651
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
626
652
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
627
|
-
) && (this.queuedClientEvents.push(i),
|
|
653
|
+
) && (this.queuedClientEvents.push(i), G(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();
|
|
628
654
|
}), n.addEventListener("close", (r) => {
|
|
629
655
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (A("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
630
656
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -657,7 +683,7 @@ class Gt {
|
|
|
657
683
|
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;
|
|
658
684
|
}
|
|
659
685
|
destroy() {
|
|
660
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
686
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), oi(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
|
|
661
687
|
for (const e of Object.values(this.listeners))
|
|
662
688
|
e?.clear();
|
|
663
689
|
}
|
|
@@ -665,7 +691,7 @@ class Gt {
|
|
|
665
691
|
const s = b(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
|
|
666
692
|
type: "runtime.warmup",
|
|
667
693
|
reason: e,
|
|
668
|
-
...e === "composer_input" ? { warmupId: r?.event.warmupId ??
|
|
694
|
+
...e === "composer_input" ? { warmupId: r?.event.warmupId ?? N() } : {},
|
|
669
695
|
entrySurface: this.options.entrySurface,
|
|
670
696
|
sessionId: this.state.sessionId ?? void 0,
|
|
671
697
|
page: s,
|
|
@@ -696,18 +722,18 @@ class Gt {
|
|
|
696
722
|
}
|
|
697
723
|
async sendMessage(e, s = {}) {
|
|
698
724
|
const n = e.trim(), r = s.attachments ?? [];
|
|
699
|
-
if (this.options.productVariant === "customer_embedded" && (r.forEach(
|
|
700
|
-
(
|
|
725
|
+
if (this.options.productVariant === "customer_embedded" && (r.forEach(gs), r.reduce(
|
|
726
|
+
(w, L) => w + L.sizeBytes,
|
|
701
727
|
0
|
|
702
|
-
) >
|
|
728
|
+
) > Vt))
|
|
703
729
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
704
|
-
let i = r.map(
|
|
730
|
+
let i = r.map(Ce);
|
|
705
731
|
if (!n && i.length === 0)
|
|
706
732
|
return null;
|
|
707
733
|
if (this.pendingClientMessageId)
|
|
708
734
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
709
|
-
const o = b(), a = s.clientMessageId ??
|
|
710
|
-
(
|
|
735
|
+
const o = b(), a = s.clientMessageId ?? N(), l = s.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
|
|
736
|
+
(T) => T.id === this.stagedProactiveSuggestionQuestionMessageId
|
|
711
737
|
) ?? null : null, d = l ? {
|
|
712
738
|
id: `local-proactive-suggestion-question-${a}`,
|
|
713
739
|
role: "assistant",
|
|
@@ -720,16 +746,16 @@ class Gt {
|
|
|
720
746
|
content: n,
|
|
721
747
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
722
748
|
...r.length > 0 ? { attachments: r } : {}
|
|
723
|
-
},
|
|
749
|
+
}, g = this.state.messages.some((T) => T.id === h.id || T.clientMessageId === a), y = this.state.isThinking, u = this.state.taskStatus, p = this.state.pendingMessageStatus, m = this.state.turnPhase, f = this.state.messages, R = g ? this.state.messages : [
|
|
724
750
|
...this.state.messages.map(
|
|
725
|
-
(
|
|
726
|
-
...
|
|
751
|
+
(T) => c && T.id === c.id ? {
|
|
752
|
+
...T,
|
|
727
753
|
id: `local-proactive-suggestion-question-${a}`
|
|
728
|
-
} :
|
|
754
|
+
} : T
|
|
729
755
|
),
|
|
730
756
|
...!c && d ? [d] : [],
|
|
731
757
|
h
|
|
732
|
-
],
|
|
758
|
+
], S = {
|
|
733
759
|
assistantDraft: this.state.assistantDraft,
|
|
734
760
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
735
761
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -738,8 +764,8 @@ class Gt {
|
|
|
738
764
|
lastError: this.state.lastError
|
|
739
765
|
};
|
|
740
766
|
this.setState({
|
|
741
|
-
messages:
|
|
742
|
-
...
|
|
767
|
+
messages: R,
|
|
768
|
+
...y ? {} : {
|
|
743
769
|
assistantDraft: "",
|
|
744
770
|
assistantDraftItemId: null,
|
|
745
771
|
assistantDraftPhase: null,
|
|
@@ -747,51 +773,51 @@ class Gt {
|
|
|
747
773
|
assistantDraftRunId: null
|
|
748
774
|
},
|
|
749
775
|
pendingMessageStatus: "sending",
|
|
750
|
-
turnPhase:
|
|
751
|
-
isThinking:
|
|
776
|
+
turnPhase: y ? m : "sending",
|
|
777
|
+
isThinking: y,
|
|
752
778
|
taskStatus: "working",
|
|
753
779
|
isRetrying: !1,
|
|
754
780
|
lastError: null
|
|
755
|
-
}),
|
|
781
|
+
}), g || (d && !c && this.emit("message", d), this.emit("message", h));
|
|
756
782
|
try {
|
|
757
|
-
const
|
|
758
|
-
for (const
|
|
759
|
-
const
|
|
760
|
-
if (
|
|
761
|
-
|
|
783
|
+
const T = [];
|
|
784
|
+
for (const w of i) {
|
|
785
|
+
const L = w.id ? this.attachmentFiles.get(w.id) : void 0;
|
|
786
|
+
if (w.sandboxPath || w.storageKey) {
|
|
787
|
+
T.push(w);
|
|
762
788
|
continue;
|
|
763
789
|
}
|
|
764
|
-
if (!
|
|
765
|
-
throw new Error(`Attachment bytes are unavailable for ${
|
|
766
|
-
|
|
790
|
+
if (!L)
|
|
791
|
+
throw new Error(`Attachment bytes are unavailable for ${w.name}`);
|
|
792
|
+
T.push(await this.uploadAttachmentForMessage({ file: L, attachment: w }));
|
|
767
793
|
}
|
|
768
|
-
i =
|
|
769
|
-
} catch (
|
|
794
|
+
i = T;
|
|
795
|
+
} catch (T) {
|
|
770
796
|
throw this.setState({
|
|
771
|
-
...
|
|
772
|
-
...
|
|
797
|
+
...g ? {} : { messages: f },
|
|
798
|
+
...y ? {} : { ...S, isThinking: !1 },
|
|
773
799
|
pendingMessageStatus: p,
|
|
774
|
-
turnPhase:
|
|
800
|
+
turnPhase: m,
|
|
775
801
|
taskStatus: u
|
|
776
|
-
}),
|
|
802
|
+
}), T;
|
|
777
803
|
}
|
|
778
804
|
this.retryableClientMessageId = null;
|
|
779
|
-
const
|
|
805
|
+
const U = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, x = {
|
|
780
806
|
type: "chat.user_message",
|
|
781
807
|
sessionId: this.state.sessionId ?? void 0,
|
|
782
808
|
clientMessageId: a,
|
|
783
809
|
initiatedBy: s.initiatedBy,
|
|
784
|
-
invocation:
|
|
810
|
+
invocation: Kn(s.invocation ?? s.initiatedBy),
|
|
785
811
|
entrySurface: this.options.entrySurface,
|
|
786
812
|
content: n,
|
|
787
813
|
proactiveSuggestionQuestion: s.proactiveSuggestionQuestion,
|
|
788
|
-
pageContent:
|
|
789
|
-
attachments: i.length > 0 ? i.map(
|
|
814
|
+
pageContent: U && at() || void 0,
|
|
815
|
+
attachments: i.length > 0 ? i.map(Ce) : void 0,
|
|
790
816
|
page: o,
|
|
791
817
|
model: this.options.model,
|
|
792
|
-
metadata:
|
|
818
|
+
metadata: Ct(this.options.metadata)
|
|
793
819
|
};
|
|
794
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent =
|
|
820
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = x, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(x), this.schedulePendingDeliveryAck(a), a;
|
|
795
821
|
}
|
|
796
822
|
getModel() {
|
|
797
823
|
return this.options.model;
|
|
@@ -815,8 +841,8 @@ class Gt {
|
|
|
815
841
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = 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;
|
|
816
842
|
}
|
|
817
843
|
createLocalAttachment(e) {
|
|
818
|
-
this.options.productVariant === "customer_embedded" &&
|
|
819
|
-
const s =
|
|
844
|
+
this.options.productVariant === "customer_embedded" && ai(e);
|
|
845
|
+
const s = N(), n = {
|
|
820
846
|
id: s,
|
|
821
847
|
name: e.name || "attachment",
|
|
822
848
|
mimeType: tt(e),
|
|
@@ -824,7 +850,7 @@ class Gt {
|
|
|
824
850
|
};
|
|
825
851
|
this.attachmentFiles.set(s, e);
|
|
826
852
|
const r = Date.now();
|
|
827
|
-
return
|
|
853
|
+
return Es({
|
|
828
854
|
attachmentId: s,
|
|
829
855
|
name: n.name,
|
|
830
856
|
mimeType: n.mimeType,
|
|
@@ -863,34 +889,34 @@ class Gt {
|
|
|
863
889
|
sizeBytes: e.size,
|
|
864
890
|
page: b(),
|
|
865
891
|
model: this.options.model,
|
|
866
|
-
metadata:
|
|
892
|
+
metadata: Ct(this.options.metadata),
|
|
867
893
|
entrySurface: this.options.entrySurface
|
|
868
894
|
};
|
|
869
895
|
let o;
|
|
870
896
|
if (this.options.persistAttachmentUpload)
|
|
871
|
-
o = await
|
|
897
|
+
o = await Te(
|
|
872
898
|
() => this.options.persistAttachmentUpload(i, e),
|
|
873
899
|
"Failed to upload attachment"
|
|
874
900
|
);
|
|
875
901
|
else {
|
|
876
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
902
|
+
const l = this.options.prepareAttachmentUpload ? await Te(
|
|
877
903
|
() => this.options.prepareAttachmentUpload(i),
|
|
878
904
|
"Failed to prepare attachment upload"
|
|
879
905
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
880
|
-
await
|
|
906
|
+
await Te(async () => {
|
|
881
907
|
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
882
908
|
method: l.uploadMethod,
|
|
883
909
|
headers: l.uploadHeaders,
|
|
884
910
|
body: e
|
|
885
911
|
});
|
|
886
912
|
if (!c.ok)
|
|
887
|
-
throw new
|
|
913
|
+
throw new Re("Failed to upload attachment", c.status);
|
|
888
914
|
return c;
|
|
889
915
|
}, "Failed to upload attachment"), o = l;
|
|
890
916
|
}
|
|
891
917
|
this.setState({ sessionId: o.sessionId });
|
|
892
|
-
const a =
|
|
893
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
918
|
+
const a = hs(o.attachment, this.options.backendUrl);
|
|
919
|
+
return this.updateAttachmentInState(s.id, a), s.id && ks(s.id, {
|
|
894
920
|
sessionId: o.sessionId,
|
|
895
921
|
fileUrl: a.fileUrl,
|
|
896
922
|
sandboxPath: a.sandboxPath,
|
|
@@ -917,18 +943,18 @@ class Gt {
|
|
|
917
943
|
}
|
|
918
944
|
async prepareEmbedAttachmentUpload(e) {
|
|
919
945
|
let s = !1;
|
|
920
|
-
return await
|
|
946
|
+
return await Te(async () => {
|
|
921
947
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
922
948
|
if (n.ok)
|
|
923
949
|
return await n.json();
|
|
924
|
-
if (
|
|
950
|
+
if (Ri(n.status) && this.options.tokenProvider && !s) {
|
|
925
951
|
s = !0;
|
|
926
952
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
927
953
|
if (r.ok)
|
|
928
954
|
return await r.json();
|
|
929
|
-
throw new
|
|
955
|
+
throw new Re("Failed to prepare attachment upload", r.status);
|
|
930
956
|
}
|
|
931
|
-
throw new
|
|
957
|
+
throw new Re("Failed to prepare attachment upload", n.status);
|
|
932
958
|
}, "Failed to prepare attachment upload");
|
|
933
959
|
}
|
|
934
960
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -946,7 +972,7 @@ class Gt {
|
|
|
946
972
|
if (!this.state.sessionId)
|
|
947
973
|
return;
|
|
948
974
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
949
|
-
const e =
|
|
975
|
+
const e = Fr(
|
|
950
976
|
this.state.messages,
|
|
951
977
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
952
978
|
this.state.assistantDraftRunId,
|
|
@@ -955,6 +981,8 @@ class Gt {
|
|
|
955
981
|
this.stoppedTurns.push({
|
|
956
982
|
sessionId: this.state.sessionId,
|
|
957
983
|
...e,
|
|
984
|
+
reason: "user_requested",
|
|
985
|
+
stoppedItemId: null,
|
|
958
986
|
stoppedAt: null,
|
|
959
987
|
stoppedCausalSequence: null,
|
|
960
988
|
toolCallIds: new Set(
|
|
@@ -969,8 +997,8 @@ class Gt {
|
|
|
969
997
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
970
998
|
for (const [s, n] of this.activeBrowserToolCalls)
|
|
971
999
|
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
|
|
972
|
-
|
|
973
|
-
messages:
|
|
1000
|
+
xt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
1001
|
+
messages: Lt(
|
|
974
1002
|
this.state.messages,
|
|
975
1003
|
e.clientMessageId,
|
|
976
1004
|
e.runId
|
|
@@ -1010,10 +1038,10 @@ class Gt {
|
|
|
1010
1038
|
});
|
|
1011
1039
|
}
|
|
1012
1040
|
listSessions(e = {}) {
|
|
1013
|
-
const s =
|
|
1041
|
+
const s = N(), n = new Promise((i, o) => {
|
|
1014
1042
|
const a = window.setTimeout(() => {
|
|
1015
1043
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
1016
|
-
},
|
|
1044
|
+
}, Et);
|
|
1017
1045
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
1018
1046
|
}), r = {
|
|
1019
1047
|
type: "sessions.list",
|
|
@@ -1032,19 +1060,19 @@ class Gt {
|
|
|
1032
1060
|
setSessionPinned(e, s) {
|
|
1033
1061
|
return this.sendSessionMutation(
|
|
1034
1062
|
this.pendingSessionPinRequests,
|
|
1035
|
-
{ type: "session.pin", requestId:
|
|
1063
|
+
{ type: "session.pin", requestId: N(), sessionId: e, pinned: s },
|
|
1036
1064
|
"Session pin did not respond in time"
|
|
1037
1065
|
);
|
|
1038
1066
|
}
|
|
1039
1067
|
renameSession(e, s) {
|
|
1040
1068
|
return this.sendSessionMutation(
|
|
1041
1069
|
this.pendingSessionRenameRequests,
|
|
1042
|
-
{ type: "session.rename", requestId:
|
|
1070
|
+
{ type: "session.rename", requestId: N(), sessionId: e, title: s },
|
|
1043
1071
|
"Session rename did not respond in time"
|
|
1044
1072
|
);
|
|
1045
1073
|
}
|
|
1046
1074
|
loadSession(e) {
|
|
1047
|
-
const s =
|
|
1075
|
+
const s = N(), n = this.activeComposerWarmupId;
|
|
1048
1076
|
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId !== e && this.rememberCurrentRunAsDetached(), this.detachedSessionIds.delete(e), this.deferredDetachedSessionEvents.delete(e), !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({
|
|
1049
1077
|
type: "session.reset",
|
|
1050
1078
|
warmupId: n,
|
|
@@ -1103,7 +1131,7 @@ class Gt {
|
|
|
1103
1131
|
}
|
|
1104
1132
|
subscribeToSessionBeforeHistory(e) {
|
|
1105
1133
|
this.pendingSessionSubscription?.resolve(!1);
|
|
1106
|
-
const s =
|
|
1134
|
+
const s = N(), n = new Promise((r) => {
|
|
1107
1135
|
this.pendingSessionSubscription = { requestId: s, sessionId: e, resolve: r };
|
|
1108
1136
|
});
|
|
1109
1137
|
return this.send({
|
|
@@ -1117,7 +1145,7 @@ class Gt {
|
|
|
1117
1145
|
async autoLoadSessionActivity(e) {
|
|
1118
1146
|
let s = null;
|
|
1119
1147
|
do {
|
|
1120
|
-
const n =
|
|
1148
|
+
const n = N();
|
|
1121
1149
|
this.sessionActivityRequestId = n;
|
|
1122
1150
|
let r;
|
|
1123
1151
|
try {
|
|
@@ -1143,7 +1171,7 @@ class Gt {
|
|
|
1143
1171
|
try {
|
|
1144
1172
|
const o = this.options.token ?? await this.options.tokenProvider?.() ?? this.token;
|
|
1145
1173
|
if (!o)
|
|
1146
|
-
throw new
|
|
1174
|
+
throw new fe("Product Agent history requires authentication");
|
|
1147
1175
|
this.token = o;
|
|
1148
1176
|
const a = new URLSearchParams();
|
|
1149
1177
|
s === "activity" && a.set("limit", "200"), n && a.set("cursor", n);
|
|
@@ -1156,12 +1184,12 @@ class Gt {
|
|
|
1156
1184
|
signal: AbortSignal.timeout(15e3)
|
|
1157
1185
|
});
|
|
1158
1186
|
if (!d.ok) {
|
|
1159
|
-
const
|
|
1160
|
-
throw
|
|
1187
|
+
const g = await d.text() || `History request failed (${d.status})`;
|
|
1188
|
+
throw on(d.status) ? new Error(g) : new fe(g);
|
|
1161
1189
|
}
|
|
1162
1190
|
const h = await d.json();
|
|
1163
1191
|
if (!h?.session || !Array.isArray(h.items))
|
|
1164
|
-
throw new
|
|
1192
|
+
throw new fe("Invalid Product Agent session history response");
|
|
1165
1193
|
return {
|
|
1166
1194
|
session: h.session,
|
|
1167
1195
|
items: h.items,
|
|
@@ -1169,7 +1197,7 @@ class Gt {
|
|
|
1169
1197
|
...Object.prototype.hasOwnProperty.call(h, "activeScheduledFollowUps") ? { activeScheduledFollowUps: h.activeScheduledFollowUps } : {}
|
|
1170
1198
|
};
|
|
1171
1199
|
} catch (o) {
|
|
1172
|
-
if (o instanceof
|
|
1200
|
+
if (o instanceof fe)
|
|
1173
1201
|
throw o;
|
|
1174
1202
|
A("web-sdk.history", "HTTP session history page failed; retrying", {
|
|
1175
1203
|
sessionId: e,
|
|
@@ -1203,9 +1231,9 @@ class Gt {
|
|
|
1203
1231
|
});
|
|
1204
1232
|
}
|
|
1205
1233
|
send(e) {
|
|
1206
|
-
this.sendNow(
|
|
1234
|
+
this.sendNow(O(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
1207
1235
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
1208
|
-
) || this.queuedClientEvents.push(e),
|
|
1236
|
+
) || this.queuedClientEvents.push(e), G(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
1209
1237
|
status: "reconnecting",
|
|
1210
1238
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
1211
1239
|
}), this.scheduleReconnect());
|
|
@@ -1221,7 +1249,7 @@ class Gt {
|
|
|
1221
1249
|
return !1;
|
|
1222
1250
|
const s = this.socket;
|
|
1223
1251
|
try {
|
|
1224
|
-
return s.send(JSON.stringify(e)), $e("client_event", e.type,
|
|
1252
|
+
return s.send(JSON.stringify(e)), $e("client_event", e.type, yt(e)), !0;
|
|
1225
1253
|
} catch (n) {
|
|
1226
1254
|
return A("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1227
1255
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -1265,9 +1293,9 @@ class Gt {
|
|
|
1265
1293
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
1266
1294
|
return;
|
|
1267
1295
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
1268
|
-
const e =
|
|
1296
|
+
const e = Xn();
|
|
1269
1297
|
this.sendNow(
|
|
1270
|
-
|
|
1298
|
+
O({
|
|
1271
1299
|
type: "starter_prompts.page_context",
|
|
1272
1300
|
pageUrl: e.pageUrl,
|
|
1273
1301
|
pageTitle: e.pageTitle,
|
|
@@ -1276,13 +1304,13 @@ class Gt {
|
|
|
1276
1304
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
1277
1305
|
}
|
|
1278
1306
|
startStarterPromptUrlWatcher() {
|
|
1279
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
1307
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = Jn(() => this.handleStarterPromptUrlChange()));
|
|
1280
1308
|
}
|
|
1281
1309
|
handleStarterPromptUrlChange() {
|
|
1282
1310
|
const e = location.href;
|
|
1283
1311
|
e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
1284
1312
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
1285
|
-
},
|
|
1313
|
+
}, Rn));
|
|
1286
1314
|
}
|
|
1287
1315
|
refreshStarterPromptsForCurrentUrl() {
|
|
1288
1316
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -1297,18 +1325,18 @@ class Gt {
|
|
|
1297
1325
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
1298
1326
|
return;
|
|
1299
1327
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
1300
|
-
|
|
1328
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1301
1329
|
for (let s = 0; s < e.length; s += 1) {
|
|
1302
1330
|
const n = e[s];
|
|
1303
|
-
if (!this.sendNow(
|
|
1304
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1331
|
+
if (!this.sendNow(O(n))) {
|
|
1332
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), G(this.options.clientId, this.queuedClientEvents);
|
|
1305
1333
|
return;
|
|
1306
1334
|
}
|
|
1307
|
-
|
|
1335
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1308
1336
|
}
|
|
1309
1337
|
}
|
|
1310
1338
|
resetForAuthenticationScopeChange() {
|
|
1311
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
1339
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], G(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
|
|
1312
1340
|
}
|
|
1313
1341
|
flushPendingWidgetLifecycleEvents() {
|
|
1314
1342
|
if (this.authenticatedSocket !== this.socket || this.socket?.readyState !== WebSocket.OPEN || this.pendingWidgetLifecycleEvents.length === 0)
|
|
@@ -1329,8 +1357,8 @@ class Gt {
|
|
|
1329
1357
|
return;
|
|
1330
1358
|
this.clearPendingWarmupAckTimer();
|
|
1331
1359
|
const s = Math.min(
|
|
1332
|
-
|
|
1333
|
-
|
|
1360
|
+
hn * 2 ** e.retryAttempt,
|
|
1361
|
+
gn
|
|
1334
1362
|
);
|
|
1335
1363
|
e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
|
|
1336
1364
|
this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
|
|
@@ -1343,23 +1371,26 @@ class Gt {
|
|
|
1343
1371
|
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;
|
|
1344
1372
|
}
|
|
1345
1373
|
findStoppedTurnForEvent(e) {
|
|
1346
|
-
const s = e.type === "session.item" ?
|
|
1374
|
+
const s = e.type === "session.item" ? _(e.item) : null;
|
|
1347
1375
|
return this.findStoppedTurn(
|
|
1348
|
-
|
|
1376
|
+
K(e) ?? this.state.sessionId,
|
|
1349
1377
|
s ?? e
|
|
1350
1378
|
);
|
|
1351
1379
|
}
|
|
1352
|
-
rememberDurablyStoppedTurn(e, s
|
|
1353
|
-
|
|
1380
|
+
rememberDurablyStoppedTurn(e, s) {
|
|
1381
|
+
const n = _(s);
|
|
1382
|
+
if (!e || !n || !Ae(n) || this.findStoppedTurn(e, n))
|
|
1354
1383
|
return;
|
|
1355
|
-
const r =
|
|
1384
|
+
const r = q(n), i = C(n), o = typeof n.clientMessageId == "string" ? n.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1356
1385
|
this.stoppedTurns.push({
|
|
1357
1386
|
sessionId: e,
|
|
1358
1387
|
clientMessageId: o,
|
|
1359
1388
|
respondsToUserMessageId: r,
|
|
1360
1389
|
runId: i,
|
|
1361
|
-
|
|
1362
|
-
|
|
1390
|
+
reason: M(n, "reason"),
|
|
1391
|
+
stoppedItemId: M(s, "id"),
|
|
1392
|
+
stoppedAt: M(s, "createdAt"),
|
|
1393
|
+
stoppedCausalSequence: D(n),
|
|
1363
1394
|
toolCallIds: new Set(
|
|
1364
1395
|
this.state.messages.filter(
|
|
1365
1396
|
(a) => Ke(a, r, i)
|
|
@@ -1367,31 +1398,39 @@ class Gt {
|
|
|
1367
1398
|
)
|
|
1368
1399
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
1369
1400
|
}
|
|
1401
|
+
forgetSupersededTaskTabClosedTurn(e, s) {
|
|
1402
|
+
if (!e || !s)
|
|
1403
|
+
return;
|
|
1404
|
+
const n = this.findStoppedTurn(e, s);
|
|
1405
|
+
!n || n.reason !== "task_tab_closed" || Zs(n, s) && (this.stoppedTurns.splice(this.stoppedTurns.indexOf(n), 1), n.stoppedItemId && this.setState({
|
|
1406
|
+
messages: this.state.messages.filter((r) => r.id !== n.stoppedItemId)
|
|
1407
|
+
}));
|
|
1408
|
+
}
|
|
1370
1409
|
shouldIgnoreStoppedTurnEvent(e) {
|
|
1371
1410
|
if (e.type === "tool.status") {
|
|
1372
1411
|
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1373
1412
|
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1374
1413
|
}
|
|
1375
|
-
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !
|
|
1414
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !Ae(_(e.item)) : e.type !== "conversation.state" : !1;
|
|
1376
1415
|
}
|
|
1377
1416
|
filterStoppedSnapshotItems(e, s) {
|
|
1378
1417
|
return e.filter((n) => {
|
|
1379
|
-
const r =
|
|
1380
|
-
if (!i || r?.type === "message" && r.role === "user" ||
|
|
1418
|
+
const r = _(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1419
|
+
if (!i || r?.type === "message" && r.role === "user" || Ae(r))
|
|
1381
1420
|
return !0;
|
|
1382
1421
|
if (i.stoppedCausalSequence !== null) {
|
|
1383
|
-
const o = r ?
|
|
1422
|
+
const o = r ? D(r) : null;
|
|
1384
1423
|
return o === null || o <= i.stoppedCausalSequence;
|
|
1385
1424
|
}
|
|
1386
1425
|
if (i.stoppedAt) {
|
|
1387
|
-
const o =
|
|
1426
|
+
const o = M(n, "createdAt");
|
|
1388
1427
|
return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
|
|
1389
1428
|
}
|
|
1390
1429
|
return !1;
|
|
1391
1430
|
});
|
|
1392
1431
|
}
|
|
1393
1432
|
handleServerEvent(e) {
|
|
1394
|
-
if ($e("server_event", e.type,
|
|
1433
|
+
if ($e("server_event", e.type, yt(e)), e.type === "session.subscribed") {
|
|
1395
1434
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1396
1435
|
if (s && n && s === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
|
|
1397
1436
|
const r = this.pendingSessionSubscription;
|
|
@@ -1404,15 +1443,18 @@ class Gt {
|
|
|
1404
1443
|
this.pendingSessionSubscription = null, s.resolve(!1), n && (this.sessionHistoryHydration = null, this.handleServerEvent({ ...e, requestId: n.requestId }));
|
|
1405
1444
|
return;
|
|
1406
1445
|
}
|
|
1407
|
-
if (this.sessionHistoryHydration &&
|
|
1446
|
+
if (this.sessionHistoryHydration && ye(e) && K(e) === this.sessionHistoryHydration.sessionId) {
|
|
1408
1447
|
this.sessionHistoryHydration.bufferedEvents.push(e);
|
|
1409
1448
|
return;
|
|
1410
1449
|
}
|
|
1411
|
-
if (e.type === "session.item"
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1450
|
+
if (e.type === "session.item") {
|
|
1451
|
+
const s = M(e.item, "sessionId") ?? this.state.sessionId;
|
|
1452
|
+
this.forgetSupersededTaskTabClosedTurn(s, _(e.item)), this.rememberDurablyStoppedTurn(
|
|
1453
|
+
s,
|
|
1454
|
+
e.item
|
|
1455
|
+
);
|
|
1456
|
+
}
|
|
1457
|
+
if (!(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1416
1458
|
if (e.type === "run.ack" && typeof e.sessionId == "string" && typeof e.clientMessageId == "string" && this.detachedClientMessageIds.delete(e.clientMessageId) && e.sessionId !== this.state.sessionId) {
|
|
1417
1459
|
this.detachedSessionIds.add(e.sessionId), this.deferredDetachedSessionEvents.delete(e.sessionId);
|
|
1418
1460
|
return;
|
|
@@ -1425,14 +1467,14 @@ class Gt {
|
|
|
1425
1467
|
if (e.type === "run.ack") {
|
|
1426
1468
|
if (this.shouldIgnoreStoppedTurnEvent(e))
|
|
1427
1469
|
return;
|
|
1428
|
-
const s =
|
|
1470
|
+
const s = K(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null, r = s ? this.deferredDetachedSessionEvents.get(s) ?? [] : [];
|
|
1429
1471
|
s && this.deferredDetachedSessionEvents.delete(s), s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && (n === this.activeClientMessageId || n === this.pendingClientMessageId) && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(e);
|
|
1430
1472
|
for (const i of r)
|
|
1431
1473
|
this.handleServerEvent(i);
|
|
1432
1474
|
return;
|
|
1433
1475
|
}
|
|
1434
1476
|
if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
1435
|
-
const s =
|
|
1477
|
+
const s = K(e);
|
|
1436
1478
|
if (s) {
|
|
1437
1479
|
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1438
1480
|
return;
|
|
@@ -1454,17 +1496,17 @@ class Gt {
|
|
|
1454
1496
|
this.activeResponseRunId = s, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
|
|
1455
1497
|
return;
|
|
1456
1498
|
}
|
|
1457
|
-
if (
|
|
1499
|
+
if (_n(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
1458
1500
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
1459
|
-
const s =
|
|
1501
|
+
const s = dr(e.user);
|
|
1460
1502
|
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();
|
|
1461
|
-
const n =
|
|
1503
|
+
const n = or(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1462
1504
|
A("web-sdk.agent", "Received auth.ok appearance", {
|
|
1463
1505
|
hasAppearance: r,
|
|
1464
1506
|
rawAppearance: e.appearance,
|
|
1465
1507
|
normalizedAppearance: n
|
|
1466
|
-
}), this.runtimeHelperJavascript =
|
|
1467
|
-
const i =
|
|
1508
|
+
}), this.runtimeHelperJavascript = ar(e.runtimeHelpers)?.javascript ?? null;
|
|
1509
|
+
const i = Pt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1468
1510
|
user: s,
|
|
1469
1511
|
status: "connected",
|
|
1470
1512
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
@@ -1473,7 +1515,7 @@ class Gt {
|
|
|
1473
1515
|
type: "runtime.auth_ack",
|
|
1474
1516
|
connectionAttempt: this.connectionAttemptId,
|
|
1475
1517
|
entrySurface: this.options.entrySurface
|
|
1476
|
-
}), o && i.length === 0 && !a && !
|
|
1518
|
+
}), o && i.length === 0 && !a && !Ie() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1477
1519
|
type: "page.upsert",
|
|
1478
1520
|
sessionId: this.state.sessionId,
|
|
1479
1521
|
page: b(),
|
|
@@ -1483,107 +1525,111 @@ class Gt {
|
|
|
1483
1525
|
}
|
|
1484
1526
|
if (e.type === "starterPrompts.updated") {
|
|
1485
1527
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1486
|
-
starterPrompts:
|
|
1528
|
+
starterPrompts: Pt(e, "starterPrompts"),
|
|
1487
1529
|
starterPromptsLoading: !1
|
|
1488
1530
|
});
|
|
1489
1531
|
return;
|
|
1490
1532
|
}
|
|
1491
1533
|
if (e.type === "scheduled_follow_ups.updated") {
|
|
1492
1534
|
typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
|
|
1493
|
-
activeScheduledFollowUps:
|
|
1535
|
+
activeScheduledFollowUps: Ut(
|
|
1494
1536
|
e.activeScheduledFollowUps
|
|
1495
1537
|
)
|
|
1496
1538
|
});
|
|
1497
1539
|
return;
|
|
1498
1540
|
}
|
|
1499
1541
|
if (e.type === "conversation.state") {
|
|
1500
|
-
const s = Array.isArray(e.items) ? e.items : [], n = Object.prototype.hasOwnProperty.call(
|
|
1542
|
+
const s = Array.isArray(e.items) ? e.items : [], n = Ys(s), r = Object.prototype.hasOwnProperty.call(
|
|
1501
1543
|
e,
|
|
1502
1544
|
"activeScheduledFollowUps"
|
|
1503
|
-
),
|
|
1504
|
-
if (
|
|
1545
|
+
), i = M(e.session, "id") ?? this.state.sessionId, o = typeof e.requestId == "string" ? e.requestId : null, a = this.state.isLoadingSession && this.sessionLoadRequestId === null && o === null && i === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
|
|
1546
|
+
if (o && o !== this.sessionLoadRequestId || this.state.isLoadingSession && this.sessionLoadRequestId !== null && o === null || this.state.isLoadingSession && i !== this.state.sessionId)
|
|
1505
1547
|
return;
|
|
1506
|
-
this.updatePersonalModelFromSession(e.session),
|
|
1507
|
-
for (const k of
|
|
1508
|
-
this.
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
m && f && (this.pendingClientMessageId = f);
|
|
1519
|
-
let g = pr(
|
|
1548
|
+
this.updatePersonalModelFromSession(e.session), i === this.state.sessionId && this.clearSessionLoadRequest();
|
|
1549
|
+
for (const k of n)
|
|
1550
|
+
this.forgetSupersededTaskTabClosedTurn(i, _(k));
|
|
1551
|
+
for (const k of n)
|
|
1552
|
+
this.rememberDurablyStoppedTurn(i, k);
|
|
1553
|
+
const l = se(n), c = l === null ? null : n[l], d = _(c), h = this.findStoppedTurn(i, {
|
|
1554
|
+
clientMessageId: d?.clientMessageId,
|
|
1555
|
+
respondsToUserMessageId: M(c, "id"),
|
|
1556
|
+
runId: d?.runId
|
|
1557
|
+
}), g = this.filterStoppedSnapshotItems(n, i), y = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, u = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, m = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1558
|
+
y && u && (this.pendingClientMessageId = u);
|
|
1559
|
+
let f = Sr(
|
|
1520
1560
|
e.assistantDraft
|
|
1521
1561
|
);
|
|
1522
|
-
|
|
1523
|
-
respondsToUserMessageId:
|
|
1524
|
-
runId:
|
|
1525
|
-
}) && (
|
|
1526
|
-
const
|
|
1527
|
-
this.rememberUserMessageClientMessageIds(
|
|
1528
|
-
const
|
|
1529
|
-
if (
|
|
1530
|
-
const k =
|
|
1531
|
-
this.retryAttemptsByClientMessageId[
|
|
1532
|
-
this.retryAttemptsByClientMessageId[
|
|
1562
|
+
f && this.findStoppedTurn(i, {
|
|
1563
|
+
respondsToUserMessageId: f.respondsToUserMessageId,
|
|
1564
|
+
runId: f.runId
|
|
1565
|
+
}) && (f = void 0);
|
|
1566
|
+
const R = f !== void 0;
|
|
1567
|
+
this.rememberUserMessageClientMessageIds(g);
|
|
1568
|
+
const S = Nr(g);
|
|
1569
|
+
if (S) {
|
|
1570
|
+
const k = xr(g, S);
|
|
1571
|
+
this.retryAttemptsByClientMessageId[S] = Math.max(
|
|
1572
|
+
this.retryAttemptsByClientMessageId[S] ?? 0,
|
|
1533
1573
|
k
|
|
1534
1574
|
);
|
|
1535
1575
|
}
|
|
1536
|
-
const
|
|
1537
|
-
const
|
|
1538
|
-
return
|
|
1539
|
-
}),
|
|
1576
|
+
const U = g.filter((k) => {
|
|
1577
|
+
const v = _(k);
|
|
1578
|
+
return Ot(v) ? !1 : !v || !S || !ke(v) ? !0 : Ze(g, v) !== S;
|
|
1579
|
+
}), T = ns(
|
|
1540
1580
|
this.state.messages,
|
|
1541
|
-
|
|
1542
|
-
),
|
|
1543
|
-
(k,
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
_,
|
|
1581
|
+
vt(U, this.options.backendUrl)
|
|
1582
|
+
), w = Dt(T), L = R ? f?.content ?? "" : this.state.assistantDraft, P = R ? f?.itemId ?? null : this.state.assistantDraftItemId, ne = R ? f?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, J = R ? f?.runId ?? null : this.state.assistantDraftRunId, Q = g.some(
|
|
1583
|
+
(k, v) => qt(
|
|
1584
|
+
_(k),
|
|
1585
|
+
L,
|
|
1586
|
+
P,
|
|
1548
1587
|
ne,
|
|
1549
|
-
|
|
1588
|
+
J,
|
|
1589
|
+
Br(g, v)
|
|
1550
1590
|
)
|
|
1551
|
-
),
|
|
1552
|
-
if (!
|
|
1591
|
+
), Y = R ? f?.content ?? "" : this.state.assistantDraft, pe = !!f?.content && !Q, B = w && (!Y || Q), z = Or(T), re = B && z ? "completed" : h ? "stopped" : B ? "failed" : null;
|
|
1592
|
+
if (!w && Lr(this.state.messages, g))
|
|
1553
1593
|
return;
|
|
1554
|
-
this.lastUserMessagePageUrl =
|
|
1555
|
-
const F =
|
|
1556
|
-
if (this.latestRecoverableClientMessageId = F,
|
|
1557
|
-
sessionId:
|
|
1558
|
-
messages:
|
|
1559
|
-
...
|
|
1560
|
-
activeScheduledFollowUps:
|
|
1594
|
+
this.lastUserMessagePageUrl = qr(g);
|
|
1595
|
+
const F = B || h ? null : Ye(g);
|
|
1596
|
+
if (this.latestRecoverableClientMessageId = F, z && this.clearRetryTimers(), this.setState({
|
|
1597
|
+
sessionId: M(e.session, "id") ?? this.state.sessionId,
|
|
1598
|
+
messages: T,
|
|
1599
|
+
...r ? {
|
|
1600
|
+
activeScheduledFollowUps: Ut(
|
|
1561
1601
|
e.activeScheduledFollowUps
|
|
1562
1602
|
)
|
|
1563
1603
|
} : {},
|
|
1564
1604
|
isLoadingSession: !1,
|
|
1565
|
-
...
|
|
1566
|
-
...
|
|
1567
|
-
isRetrying:
|
|
1568
|
-
...
|
|
1569
|
-
|
|
1605
|
+
...y ? { pendingMessageStatus: y } : {},
|
|
1606
|
+
...m ? { turnPhase: m } : {},
|
|
1607
|
+
isRetrying: p,
|
|
1608
|
+
...m ? { taskStatus: "working" } : {},
|
|
1609
|
+
...re && this.state.taskStatus === "working" ? { taskStatus: re } : {},
|
|
1610
|
+
...Q ? {
|
|
1570
1611
|
assistantDraft: "",
|
|
1571
1612
|
assistantDraftItemId: null,
|
|
1572
1613
|
assistantDraftPhase: null,
|
|
1573
1614
|
assistantDraftRespondsToUserMessageId: null,
|
|
1574
1615
|
assistantDraftRunId: null
|
|
1575
|
-
} :
|
|
1576
|
-
assistantDraft:
|
|
1577
|
-
assistantDraftItemId:
|
|
1578
|
-
assistantDraftPhase:
|
|
1579
|
-
assistantDraftRespondsToUserMessageId:
|
|
1580
|
-
assistantDraftRunId:
|
|
1616
|
+
} : R ? {
|
|
1617
|
+
assistantDraft: f?.content ?? "",
|
|
1618
|
+
assistantDraftItemId: f?.itemId ?? null,
|
|
1619
|
+
assistantDraftPhase: f?.phase ?? null,
|
|
1620
|
+
assistantDraftRespondsToUserMessageId: f?.respondsToUserMessageId ?? null,
|
|
1621
|
+
assistantDraftRunId: f?.runId ?? null
|
|
1581
1622
|
} : {},
|
|
1582
|
-
...
|
|
1623
|
+
...pe ? {
|
|
1583
1624
|
isThinking: !0,
|
|
1584
1625
|
turnPhase: "thinking",
|
|
1585
1626
|
lastError: null
|
|
1586
|
-
} :
|
|
1627
|
+
} : m ? {
|
|
1628
|
+
isThinking: !0,
|
|
1629
|
+
lastError: null,
|
|
1630
|
+
lastErrorCode: null,
|
|
1631
|
+
lastErrorSecuritySettingsUrl: null
|
|
1632
|
+
} : B ? {
|
|
1587
1633
|
isThinking: !1,
|
|
1588
1634
|
status: "connected",
|
|
1589
1635
|
lastError: null,
|
|
@@ -1591,25 +1637,25 @@ class Gt {
|
|
|
1591
1637
|
lastErrorSecuritySettingsUrl: null
|
|
1592
1638
|
} : F ? {
|
|
1593
1639
|
isThinking: !0,
|
|
1594
|
-
turnPhase:
|
|
1640
|
+
turnPhase: m ?? this.state.turnPhase ?? "starting",
|
|
1595
1641
|
lastError: null
|
|
1596
1642
|
} : {}
|
|
1597
|
-
}),
|
|
1643
|
+
}), B)
|
|
1598
1644
|
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1599
|
-
else if (!
|
|
1645
|
+
else if (!h && (pe || F)) {
|
|
1600
1646
|
if (F) {
|
|
1601
1647
|
this.activeClientMessageId = F;
|
|
1602
|
-
const k = se(
|
|
1603
|
-
this.activeResponseUserMessageId =
|
|
1648
|
+
const k = se(g), v = k === null ? null : g[k];
|
|
1649
|
+
this.activeResponseUserMessageId = M(v, "id");
|
|
1604
1650
|
}
|
|
1605
1651
|
this.markThinkingProgress();
|
|
1606
1652
|
}
|
|
1607
|
-
if (
|
|
1608
|
-
const k =
|
|
1609
|
-
k && this.retryAfterInterruptedRun(k,
|
|
1653
|
+
if (S) {
|
|
1654
|
+
const k = M(e.session, "id") ?? this.state.sessionId;
|
|
1655
|
+
k && this.retryAfterInterruptedRun(k, S);
|
|
1610
1656
|
}
|
|
1611
|
-
|
|
1612
|
-
this.autoLoadSessionActivity(
|
|
1657
|
+
a && i && window.setTimeout(() => {
|
|
1658
|
+
this.autoLoadSessionActivity(i);
|
|
1613
1659
|
}, 0);
|
|
1614
1660
|
return;
|
|
1615
1661
|
}
|
|
@@ -1617,19 +1663,19 @@ class Gt {
|
|
|
1617
1663
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1618
1664
|
if (!s || n !== this.state.sessionId)
|
|
1619
1665
|
return;
|
|
1620
|
-
const r =
|
|
1666
|
+
const r = vt(
|
|
1621
1667
|
Array.isArray(e.items) ? e.items : [],
|
|
1622
1668
|
this.options.backendUrl
|
|
1623
1669
|
);
|
|
1624
1670
|
s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
1625
|
-
messages:
|
|
1671
|
+
messages: br(this.state.messages, r)
|
|
1626
1672
|
});
|
|
1627
1673
|
return;
|
|
1628
1674
|
}
|
|
1629
1675
|
if (e.type === "sessions.page") {
|
|
1630
1676
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1631
1677
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1632
|
-
sessions:
|
|
1678
|
+
sessions: pr(e.sessions),
|
|
1633
1679
|
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1634
1680
|
}));
|
|
1635
1681
|
return;
|
|
@@ -1644,7 +1690,7 @@ class Gt {
|
|
|
1644
1690
|
}
|
|
1645
1691
|
if (e.type === "session.updated") {
|
|
1646
1692
|
this.clearRunAckResyncRetryTimer();
|
|
1647
|
-
const s =
|
|
1693
|
+
const s = M(e.session, "id");
|
|
1648
1694
|
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1649
1695
|
...this.pendingComposerWarmup.event,
|
|
1650
1696
|
sessionId: s
|
|
@@ -1655,10 +1701,10 @@ class Gt {
|
|
|
1655
1701
|
}
|
|
1656
1702
|
if (e.type === "session.item") {
|
|
1657
1703
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1658
|
-
const s =
|
|
1659
|
-
if (
|
|
1704
|
+
const s = _(e.item);
|
|
1705
|
+
if (ke(s)) {
|
|
1660
1706
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1661
|
-
const r =
|
|
1707
|
+
const r = M(e.item, "sessionId") ?? this.state.sessionId, i = s ? q(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1662
1708
|
if (r && a) {
|
|
1663
1709
|
this.retryAfterInterruptedRun(r, a);
|
|
1664
1710
|
return;
|
|
@@ -1668,23 +1714,23 @@ class Gt {
|
|
|
1668
1714
|
return;
|
|
1669
1715
|
}
|
|
1670
1716
|
}
|
|
1671
|
-
if (
|
|
1717
|
+
if (Ot(s))
|
|
1672
1718
|
return;
|
|
1673
|
-
const n =
|
|
1719
|
+
const n = ss(e.item, this.options.backendUrl);
|
|
1674
1720
|
if (n) {
|
|
1675
|
-
const r =
|
|
1676
|
-
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
1677
|
-
const o = Qe(this.state.messages, n), a =
|
|
1721
|
+
const r = jr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1722
|
+
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), H(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Hr(s) && this.clearRunAckResyncRetryTimer();
|
|
1723
|
+
const o = Qe(this.state.messages, n), a = Dt(o), l = qt(
|
|
1678
1724
|
s,
|
|
1679
1725
|
this.state.assistantDraft,
|
|
1680
1726
|
this.state.assistantDraftItemId,
|
|
1681
1727
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1682
1728
|
this.state.assistantDraftRunId,
|
|
1683
|
-
|
|
1729
|
+
ls(
|
|
1684
1730
|
o,
|
|
1685
1731
|
o.findIndex((h) => h.id === n.id)
|
|
1686
1732
|
)
|
|
1687
|
-
), c = a && (!this.state.assistantDraft || l), d =
|
|
1733
|
+
), c = a && (!this.state.assistantDraft || l), d = Ee(n) && (c || H(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
1688
1734
|
this.setState({
|
|
1689
1735
|
messages: o,
|
|
1690
1736
|
...l ? {
|
|
@@ -1742,7 +1788,7 @@ class Gt {
|
|
|
1742
1788
|
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;
|
|
1743
1789
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1744
1790
|
return;
|
|
1745
|
-
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 =
|
|
1791
|
+
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 = xs(
|
|
1746
1792
|
this.state.messages.filter(
|
|
1747
1793
|
(c) => c.dataType !== "assistant_draft" || !Ke(
|
|
1748
1794
|
c,
|
|
@@ -1752,11 +1798,11 @@ class Gt {
|
|
|
1752
1798
|
),
|
|
1753
1799
|
n,
|
|
1754
1800
|
r,
|
|
1755
|
-
|
|
1801
|
+
rs
|
|
1756
1802
|
);
|
|
1757
1803
|
this.setState({
|
|
1758
1804
|
sessionId: s,
|
|
1759
|
-
messages:
|
|
1805
|
+
messages: Ar(
|
|
1760
1806
|
l,
|
|
1761
1807
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
1762
1808
|
n,
|
|
@@ -1779,9 +1825,9 @@ class Gt {
|
|
|
1779
1825
|
if (s)
|
|
1780
1826
|
this.nonTranscriptToolCallIds.add(s);
|
|
1781
1827
|
else {
|
|
1782
|
-
const n =
|
|
1828
|
+
const n = kr(e);
|
|
1783
1829
|
if (n) {
|
|
1784
|
-
const r =
|
|
1830
|
+
const r = Rr(
|
|
1785
1831
|
this.state.messages,
|
|
1786
1832
|
n
|
|
1787
1833
|
);
|
|
@@ -1842,19 +1888,19 @@ class Gt {
|
|
|
1842
1888
|
return;
|
|
1843
1889
|
}
|
|
1844
1890
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1845
|
-
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l =
|
|
1891
|
+
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Gn(a.message);
|
|
1846
1892
|
l && console.error(l);
|
|
1847
|
-
const c = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null, h =
|
|
1893
|
+
const c = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null, h = Lt(
|
|
1848
1894
|
this.state.messages,
|
|
1849
1895
|
c,
|
|
1850
1896
|
d
|
|
1851
|
-
),
|
|
1897
|
+
), g = Dr(
|
|
1852
1898
|
h,
|
|
1853
1899
|
c,
|
|
1854
1900
|
d
|
|
1855
1901
|
);
|
|
1856
1902
|
this.setState({
|
|
1857
|
-
status:
|
|
1903
|
+
status: g ? "connected" : "error",
|
|
1858
1904
|
messages: h,
|
|
1859
1905
|
assistantDraft: "",
|
|
1860
1906
|
assistantDraftItemId: null,
|
|
@@ -1864,9 +1910,9 @@ class Gt {
|
|
|
1864
1910
|
isThinking: !1,
|
|
1865
1911
|
...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
|
|
1866
1912
|
isRetrying: !1,
|
|
1867
|
-
lastError:
|
|
1868
|
-
lastErrorCode:
|
|
1869
|
-
lastErrorSecuritySettingsUrl:
|
|
1913
|
+
lastError: g ? null : a.message,
|
|
1914
|
+
lastErrorCode: g ? null : typeof e.code == "string" ? e.code : null,
|
|
1915
|
+
lastErrorSecuritySettingsUrl: g ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
|
|
1870
1916
|
}), this.clearThinkingWatchdog(), this.emit("error", a);
|
|
1871
1917
|
}
|
|
1872
1918
|
}
|
|
@@ -1880,21 +1926,21 @@ class Gt {
|
|
|
1880
1926
|
this.options.model = He(n) ? n : "gpt-5.6-sol";
|
|
1881
1927
|
}
|
|
1882
1928
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1883
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1929
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !ye(e))
|
|
1884
1930
|
return !1;
|
|
1885
|
-
const s =
|
|
1931
|
+
const s = K(e);
|
|
1886
1932
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1887
1933
|
}
|
|
1888
1934
|
shouldIgnoreDetachedSessionEvent(e) {
|
|
1889
|
-
if (this.options.keepRunsActiveOnSessionNavigation || !
|
|
1935
|
+
if (this.options.keepRunsActiveOnSessionNavigation || !ye(e))
|
|
1890
1936
|
return !1;
|
|
1891
|
-
const s =
|
|
1937
|
+
const s = K(e);
|
|
1892
1938
|
return !!(s && this.detachedSessionIds.has(s));
|
|
1893
1939
|
}
|
|
1894
1940
|
shouldDeferDetachedSessionEvent(e) {
|
|
1895
|
-
if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !
|
|
1941
|
+
if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !ye(e))
|
|
1896
1942
|
return !1;
|
|
1897
|
-
const s =
|
|
1943
|
+
const s = K(e);
|
|
1898
1944
|
if (!s || s === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(s))
|
|
1899
1945
|
return !1;
|
|
1900
1946
|
const n = this.deferredDetachedSessionEvents.get(s) ?? [];
|
|
@@ -1917,7 +1963,7 @@ class Gt {
|
|
|
1917
1963
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1918
1964
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1919
1965
|
return !1;
|
|
1920
|
-
if (
|
|
1966
|
+
if (Ie())
|
|
1921
1967
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1922
1968
|
if (e.code === "run_still_active") {
|
|
1923
1969
|
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) {
|
|
@@ -1948,7 +1994,7 @@ class Gt {
|
|
|
1948
1994
|
}, o), !0;
|
|
1949
1995
|
}
|
|
1950
1996
|
retryAfterInterruptedRun(e, s) {
|
|
1951
|
-
if (
|
|
1997
|
+
if (Ie()) {
|
|
1952
1998
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1953
1999
|
return;
|
|
1954
2000
|
}
|
|
@@ -1964,7 +2010,7 @@ class Gt {
|
|
|
1964
2010
|
}, le(n));
|
|
1965
2011
|
}
|
|
1966
2012
|
requestSessionRecoveryExhaustion(e, s) {
|
|
1967
|
-
this.retryableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.recoveryExhaustionRequestedClientMessageIds.has(s) ? this.resyncThinkingSession() : (this.recoveryExhaustionRequestedClientMessageIds.add(s), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 })), this.scheduleThinkingWatchdog(
|
|
2013
|
+
this.retryableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.recoveryExhaustionRequestedClientMessageIds.has(s) ? this.resyncThinkingSession() : (this.recoveryExhaustionRequestedClientMessageIds.add(s), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 })), this.scheduleThinkingWatchdog(wt);
|
|
1968
2014
|
}
|
|
1969
2015
|
clearRetryTimers() {
|
|
1970
2016
|
for (const e of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1973,10 +2019,10 @@ class Gt {
|
|
|
1973
2019
|
}
|
|
1974
2020
|
rememberUserMessageClientMessageIds(e) {
|
|
1975
2021
|
for (const s of e) {
|
|
1976
|
-
const n =
|
|
2022
|
+
const n = M(s, "id"), r = _(s);
|
|
1977
2023
|
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(
|
|
1978
2024
|
r.clientMessageId,
|
|
1979
|
-
|
|
2025
|
+
M(s, "sessionId") ?? this.state.sessionId,
|
|
1980
2026
|
n,
|
|
1981
2027
|
null
|
|
1982
2028
|
), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
|
|
@@ -1995,7 +2041,7 @@ class Gt {
|
|
|
1995
2041
|
const r = new Promise((i, o) => {
|
|
1996
2042
|
const a = window.setTimeout(() => {
|
|
1997
2043
|
e.delete(s.requestId), o(new Error(n));
|
|
1998
|
-
},
|
|
2044
|
+
}, Et);
|
|
1999
2045
|
e.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
2000
2046
|
});
|
|
2001
2047
|
if (!this.sendNow(s)) {
|
|
@@ -2018,7 +2064,7 @@ class Gt {
|
|
|
2018
2064
|
e.clear();
|
|
2019
2065
|
}
|
|
2020
2066
|
markThinkingProgress() {
|
|
2021
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
2067
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Tt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
2022
2068
|
}
|
|
2023
2069
|
scheduleThinkingWatchdog(e) {
|
|
2024
2070
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -2062,9 +2108,9 @@ class Gt {
|
|
|
2062
2108
|
}), this.markThinkingProgress();
|
|
2063
2109
|
}
|
|
2064
2110
|
schedulePendingDeliveryAck(e) {
|
|
2065
|
-
this.clearPendingDeliveryTimers(), !
|
|
2111
|
+
this.clearPendingDeliveryTimers(), !Ie() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
2066
2112
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
2067
|
-
},
|
|
2113
|
+
}, At));
|
|
2068
2114
|
}
|
|
2069
2115
|
retryPendingDelivery(e) {
|
|
2070
2116
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
@@ -2076,7 +2122,7 @@ class Gt {
|
|
|
2076
2122
|
}
|
|
2077
2123
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
2078
2124
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
2079
|
-
}, le(s,
|
|
2125
|
+
}, le(s, Rt));
|
|
2080
2126
|
}
|
|
2081
2127
|
failPendingDelivery(e) {
|
|
2082
2128
|
if (this.pendingClientMessageId !== e)
|
|
@@ -2088,7 +2134,7 @@ class Gt {
|
|
|
2088
2134
|
...this.state.isThinking ? {} : { turnPhase: null },
|
|
2089
2135
|
isRetrying: !1,
|
|
2090
2136
|
...this.state.isThinking ? {} : { taskStatus: "failed" },
|
|
2091
|
-
lastError:
|
|
2137
|
+
lastError: mn,
|
|
2092
2138
|
lastErrorCode: "message_delivery_failed"
|
|
2093
2139
|
});
|
|
2094
2140
|
}
|
|
@@ -2103,7 +2149,7 @@ class Gt {
|
|
|
2103
2149
|
s,
|
|
2104
2150
|
typeof e.runId == "string" ? e.runId : null
|
|
2105
2151
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
2106
|
-
messages:
|
|
2152
|
+
messages: Kr(
|
|
2107
2153
|
this.state.messages,
|
|
2108
2154
|
s
|
|
2109
2155
|
)
|
|
@@ -2112,7 +2158,7 @@ class Gt {
|
|
|
2112
2158
|
scheduleRunAckWatchdog(e) {
|
|
2113
2159
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
2114
2160
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
2115
|
-
},
|
|
2161
|
+
}, At);
|
|
2116
2162
|
}
|
|
2117
2163
|
recoverMissedRunAck(e) {
|
|
2118
2164
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (A("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -2136,8 +2182,8 @@ class Gt {
|
|
|
2136
2182
|
sessionId: this.state.sessionId,
|
|
2137
2183
|
clientMessageId: e,
|
|
2138
2184
|
automatic: !0
|
|
2139
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
2140
|
-
}, le(s,
|
|
2185
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(Tt)));
|
|
2186
|
+
}, le(s, Rt)));
|
|
2141
2187
|
}
|
|
2142
2188
|
clearRunAckResyncRetryTimer() {
|
|
2143
2189
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -2156,11 +2202,11 @@ class Gt {
|
|
|
2156
2202
|
reason: "missing_client_message_id"
|
|
2157
2203
|
}), this.setState({
|
|
2158
2204
|
messages: this.state.messages.filter(
|
|
2159
|
-
(r) => !
|
|
2205
|
+
(r) => !X(r)
|
|
2160
2206
|
),
|
|
2161
2207
|
isThinking: !1,
|
|
2162
2208
|
taskStatus: "failed",
|
|
2163
|
-
lastError:
|
|
2209
|
+
lastError: Mt,
|
|
2164
2210
|
lastErrorCode: "run_recovery_exhausted"
|
|
2165
2211
|
}), this.clearThinkingWatchdog();
|
|
2166
2212
|
return;
|
|
@@ -2173,7 +2219,7 @@ class Gt {
|
|
|
2173
2219
|
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
2174
2220
|
isThinking: !1,
|
|
2175
2221
|
taskStatus: "failed",
|
|
2176
|
-
lastError:
|
|
2222
|
+
lastError: Mt,
|
|
2177
2223
|
lastErrorCode: "connection_failed"
|
|
2178
2224
|
}), this.clearThinkingWatchdog());
|
|
2179
2225
|
return;
|
|
@@ -2183,7 +2229,7 @@ class Gt {
|
|
|
2183
2229
|
sessionId: this.state.sessionId,
|
|
2184
2230
|
clientMessageId: e,
|
|
2185
2231
|
resyncAttempts: s + 1
|
|
2186
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
2232
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(wt);
|
|
2187
2233
|
return;
|
|
2188
2234
|
}
|
|
2189
2235
|
this.setState({
|
|
@@ -2218,15 +2264,15 @@ class Gt {
|
|
|
2218
2264
|
if (!s || !n || !r)
|
|
2219
2265
|
return;
|
|
2220
2266
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
2221
|
-
if (!a && !l || !
|
|
2267
|
+
if (!a && !l || !pi(o)) {
|
|
2222
2268
|
this.setToolMessageLoading(n, !1), this.send({
|
|
2223
2269
|
type: "tool.result",
|
|
2224
2270
|
sessionId: s,
|
|
2225
2271
|
callId: n,
|
|
2226
2272
|
toolName: r,
|
|
2227
2273
|
summary: i,
|
|
2228
|
-
rawInput:
|
|
2229
|
-
rawOutput:
|
|
2274
|
+
rawInput: O(o),
|
|
2275
|
+
rawOutput: O({
|
|
2230
2276
|
ok: !1,
|
|
2231
2277
|
toolName: r,
|
|
2232
2278
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -2241,7 +2287,7 @@ class Gt {
|
|
|
2241
2287
|
callId: n,
|
|
2242
2288
|
toolName: r,
|
|
2243
2289
|
summary: i,
|
|
2244
|
-
rawInput:
|
|
2290
|
+
rawInput: O(o),
|
|
2245
2291
|
rawOutput: {
|
|
2246
2292
|
ok: !1,
|
|
2247
2293
|
toolName: r,
|
|
@@ -2257,7 +2303,7 @@ class Gt {
|
|
|
2257
2303
|
callId: n,
|
|
2258
2304
|
toolName: r,
|
|
2259
2305
|
summary: i,
|
|
2260
|
-
rawInput:
|
|
2306
|
+
rawInput: O(o),
|
|
2261
2307
|
rawOutput: null
|
|
2262
2308
|
},
|
|
2263
2309
|
startedAtMs: Date.now(),
|
|
@@ -2265,9 +2311,9 @@ class Gt {
|
|
|
2265
2311
|
startedAtOrigin: location.origin
|
|
2266
2312
|
}), this.installSessionBrowserApis();
|
|
2267
2313
|
let c = null, d;
|
|
2268
|
-
c = await this.executeRuntimeHelper(), d = await
|
|
2314
|
+
c = await this.executeRuntimeHelper(), d = await bt(
|
|
2269
2315
|
o,
|
|
2270
|
-
|
|
2316
|
+
$n(e.runtimeContext, this.options.backendUrl)
|
|
2271
2317
|
).catch((h) => ({
|
|
2272
2318
|
ok: !1,
|
|
2273
2319
|
exception: {
|
|
@@ -2279,12 +2325,12 @@ class Gt {
|
|
|
2279
2325
|
callId: n,
|
|
2280
2326
|
toolName: r,
|
|
2281
2327
|
summary: o.summary,
|
|
2282
|
-
rawInput:
|
|
2283
|
-
rawOutput:
|
|
2284
|
-
}),
|
|
2328
|
+
rawInput: O(o),
|
|
2329
|
+
rawOutput: O(lr(d, c))
|
|
2330
|
+
}), xt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
2285
2331
|
}
|
|
2286
2332
|
setToolMessageLoading(e, s) {
|
|
2287
|
-
const n =
|
|
2333
|
+
const n = Er(
|
|
2288
2334
|
this.state.messages,
|
|
2289
2335
|
e,
|
|
2290
2336
|
s
|
|
@@ -2295,33 +2341,33 @@ class Gt {
|
|
|
2295
2341
|
if (this.pageLifecycleCleanup)
|
|
2296
2342
|
return;
|
|
2297
2343
|
const e = () => {
|
|
2298
|
-
|
|
2344
|
+
ds(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
2299
2345
|
};
|
|
2300
2346
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
2301
2347
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
2302
2348
|
};
|
|
2303
2349
|
}
|
|
2304
2350
|
installSessionBrowserApis() {
|
|
2305
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
2351
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = vn();
|
|
2306
2352
|
}
|
|
2307
2353
|
cleanupSessionBrowserApis() {
|
|
2308
|
-
this.sessionBrowserApisCleanup && (
|
|
2354
|
+
this.sessionBrowserApisCleanup && (Wn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
2309
2355
|
}
|
|
2310
2356
|
async executeRuntimeHelper() {
|
|
2311
2357
|
if (!this.runtimeHelperJavascript?.trim())
|
|
2312
2358
|
return null;
|
|
2313
|
-
const e = await
|
|
2359
|
+
const e = await bt({
|
|
2314
2360
|
javascript: this.runtimeHelperJavascript
|
|
2315
2361
|
});
|
|
2316
|
-
return e.ok === !1 ?
|
|
2362
|
+
return e.ok === !1 ? cr(e) : null;
|
|
2317
2363
|
}
|
|
2318
2364
|
enableNetworkCapture() {
|
|
2319
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
2320
|
-
|
|
2365
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = Cn((e) => {
|
|
2366
|
+
Ii(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
2321
2367
|
}));
|
|
2322
2368
|
}
|
|
2323
2369
|
enqueueNetworkEvent(e) {
|
|
2324
|
-
this.queuedNetworkEvents.length >=
|
|
2370
|
+
this.queuedNetworkEvents.length >= In || (this.queuedNetworkEvents.push(yi(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
2325
2371
|
this.networkBatchTimer = null;
|
|
2326
2372
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
2327
2373
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -2330,12 +2376,12 @@ class Gt {
|
|
|
2330
2376
|
page: b(),
|
|
2331
2377
|
events: s
|
|
2332
2378
|
});
|
|
2333
|
-
},
|
|
2379
|
+
}, yn)));
|
|
2334
2380
|
}
|
|
2335
2381
|
scheduleReconnect() {
|
|
2336
2382
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
2337
2383
|
return;
|
|
2338
|
-
const e =
|
|
2384
|
+
const e = En(this.reconnectAttempts);
|
|
2339
2385
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
2340
2386
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
2341
2387
|
A("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -2351,8 +2397,8 @@ class Gt {
|
|
|
2351
2397
|
const e = this.socket;
|
|
2352
2398
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
2353
2399
|
this.socket === e && (A("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
2354
|
-
},
|
|
2355
|
-
},
|
|
2400
|
+
}, cn));
|
|
2401
|
+
}, ln);
|
|
2356
2402
|
}
|
|
2357
2403
|
stopHeartbeat() {
|
|
2358
2404
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -2390,7 +2436,7 @@ class Gt {
|
|
|
2390
2436
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2391
2437
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2392
2438
|
};
|
|
2393
|
-
this.state = o,
|
|
2439
|
+
this.state = o, ei(this.options.clientId, this.state), this.emit("state", this.getState()), $e("state", this.state.status, {
|
|
2394
2440
|
status: this.state.status,
|
|
2395
2441
|
sessionId: this.state.sessionId,
|
|
2396
2442
|
messageCount: this.state.messages.length,
|
|
@@ -2413,54 +2459,54 @@ class Gt {
|
|
|
2413
2459
|
}
|
|
2414
2460
|
}
|
|
2415
2461
|
const je = /* @__PURE__ */ new WeakMap();
|
|
2416
|
-
function
|
|
2417
|
-
const e = window.__plunoProductAgentNetworkCapture ??
|
|
2462
|
+
function Cn(t) {
|
|
2463
|
+
const e = window.__plunoProductAgentNetworkCapture ?? bn();
|
|
2418
2464
|
return e.subscribers.add(t), () => {
|
|
2419
2465
|
e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
2420
2466
|
};
|
|
2421
2467
|
}
|
|
2422
|
-
function
|
|
2423
|
-
const t = /* @__PURE__ */ new Set(), e = (
|
|
2424
|
-
t.forEach((
|
|
2468
|
+
function bn() {
|
|
2469
|
+
const t = /* @__PURE__ */ new Set(), e = (g) => {
|
|
2470
|
+
t.forEach((y) => {
|
|
2425
2471
|
try {
|
|
2426
|
-
|
|
2472
|
+
y(g);
|
|
2427
2473
|
} catch {
|
|
2428
2474
|
}
|
|
2429
2475
|
});
|
|
2430
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(
|
|
2476
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(y, u) {
|
|
2431
2477
|
const p = Date.now();
|
|
2432
|
-
let
|
|
2478
|
+
let m;
|
|
2433
2479
|
try {
|
|
2434
|
-
|
|
2435
|
-
} catch (
|
|
2436
|
-
throw
|
|
2480
|
+
m = s.call(this, y, u);
|
|
2481
|
+
} catch (f) {
|
|
2482
|
+
throw f;
|
|
2437
2483
|
}
|
|
2438
2484
|
try {
|
|
2439
|
-
const
|
|
2440
|
-
if (!Z(
|
|
2441
|
-
const
|
|
2485
|
+
const f = y instanceof Request ? y : null, R = hi(y, f), S = fs(u?.headers ?? f?.headers);
|
|
2486
|
+
if (!Z(R, S, u?.body)) {
|
|
2487
|
+
const x = {
|
|
2442
2488
|
requestId: Ge("fetch"),
|
|
2443
|
-
url:
|
|
2444
|
-
method: (u?.method ??
|
|
2445
|
-
requestHeaders:
|
|
2446
|
-
requestBody:
|
|
2489
|
+
url: W(R, Fe),
|
|
2490
|
+
method: (u?.method ?? f?.method ?? "GET").toUpperCase(),
|
|
2491
|
+
requestHeaders: S,
|
|
2492
|
+
requestBody: Wt(u?.body),
|
|
2447
2493
|
resourceType: "fetch",
|
|
2448
2494
|
startedAt: new Date(p).toISOString()
|
|
2449
2495
|
};
|
|
2450
|
-
|
|
2451
|
-
(
|
|
2452
|
-
|
|
2496
|
+
m.then(
|
|
2497
|
+
(T) => {
|
|
2498
|
+
gi(T, x, p, e).catch(() => {
|
|
2453
2499
|
e({
|
|
2454
|
-
...
|
|
2455
|
-
responseStatus:
|
|
2500
|
+
...x,
|
|
2501
|
+
responseStatus: T.status,
|
|
2456
2502
|
durationMs: Date.now() - p
|
|
2457
2503
|
});
|
|
2458
2504
|
});
|
|
2459
2505
|
},
|
|
2460
|
-
(
|
|
2506
|
+
(T) => {
|
|
2461
2507
|
e({
|
|
2462
|
-
...
|
|
2463
|
-
errorText:
|
|
2508
|
+
...x,
|
|
2509
|
+
errorText: W(T instanceof Error ? T.message : String(T)),
|
|
2464
2510
|
durationMs: Date.now() - p
|
|
2465
2511
|
});
|
|
2466
2512
|
}
|
|
@@ -2468,30 +2514,30 @@ function Mn() {
|
|
|
2468
2514
|
}
|
|
2469
2515
|
} catch {
|
|
2470
2516
|
}
|
|
2471
|
-
return
|
|
2472
|
-
}, a = function(
|
|
2473
|
-
const
|
|
2517
|
+
return m;
|
|
2518
|
+
}, a = function(y, u, p, m, f) {
|
|
2519
|
+
const R = n.call(this, y, u, p ?? !0, m ?? void 0, f ?? void 0), S = typeof u == "string" ? u : u.toString();
|
|
2474
2520
|
return je.set(this, {
|
|
2475
2521
|
requestId: Ge("xhr"),
|
|
2476
|
-
method: String(
|
|
2477
|
-
url:
|
|
2522
|
+
method: String(y ?? "GET").toUpperCase(),
|
|
2523
|
+
url: W(S, Fe),
|
|
2478
2524
|
requestHeaders: {},
|
|
2479
2525
|
startedAtMs: Date.now(),
|
|
2480
2526
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2481
|
-
excluded: Z(
|
|
2482
|
-
}),
|
|
2483
|
-
}, l = function(
|
|
2484
|
-
const p = r.call(this,
|
|
2485
|
-
return
|
|
2486
|
-
}, c = function(
|
|
2527
|
+
excluded: Z(S)
|
|
2528
|
+
}), R;
|
|
2529
|
+
}, l = function(y, u) {
|
|
2530
|
+
const p = r.call(this, y, u), m = je.get(this);
|
|
2531
|
+
return m && Object.keys(m.requestHeaders).length < ot && (m.requestHeaders[y] = ct(y, u), m.excluded = m.excluded || Z(m.url, m.requestHeaders)), p;
|
|
2532
|
+
}, c = function(y) {
|
|
2487
2533
|
try {
|
|
2488
2534
|
const u = je.get(this);
|
|
2489
|
-
u && (u.excluded = u.excluded || Z(u.url, u.requestHeaders,
|
|
2535
|
+
u && (u.excluded = u.excluded || Z(u.url, u.requestHeaders, y), u.requestBody = Wt(y), u.excluded || this.addEventListener(
|
|
2490
2536
|
"loadend",
|
|
2491
2537
|
() => {
|
|
2492
2538
|
queueMicrotask(() => {
|
|
2493
2539
|
try {
|
|
2494
|
-
const p =
|
|
2540
|
+
const p = Ti(this.getAllResponseHeaders());
|
|
2495
2541
|
e({
|
|
2496
2542
|
requestId: u.requestId,
|
|
2497
2543
|
url: u.url,
|
|
@@ -2501,7 +2547,7 @@ function Mn() {
|
|
|
2501
2547
|
resourceType: "xhr",
|
|
2502
2548
|
responseStatus: this.status,
|
|
2503
2549
|
responseHeaders: p,
|
|
2504
|
-
responseBody:
|
|
2550
|
+
responseBody: mi(this, p),
|
|
2505
2551
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2506
2552
|
startedAt: u.startedAt,
|
|
2507
2553
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -2515,7 +2561,7 @@ function Mn() {
|
|
|
2515
2561
|
));
|
|
2516
2562
|
} catch {
|
|
2517
2563
|
}
|
|
2518
|
-
return i.call(this,
|
|
2564
|
+
return i.call(this, y ?? null);
|
|
2519
2565
|
};
|
|
2520
2566
|
try {
|
|
2521
2567
|
window.fetch = o;
|
|
@@ -2535,15 +2581,15 @@ function Mn() {
|
|
|
2535
2581
|
}
|
|
2536
2582
|
let d = null;
|
|
2537
2583
|
if (typeof PerformanceObserver < "u") {
|
|
2538
|
-
d = new PerformanceObserver((
|
|
2539
|
-
for (const
|
|
2540
|
-
const u =
|
|
2584
|
+
d = new PerformanceObserver((g) => {
|
|
2585
|
+
for (const y of g.getEntries()) {
|
|
2586
|
+
const u = y;
|
|
2541
2587
|
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || Z(u.name))
|
|
2542
2588
|
continue;
|
|
2543
2589
|
const p = performance.timeOrigin + u.startTime;
|
|
2544
2590
|
e({
|
|
2545
2591
|
requestId: Ge("resource"),
|
|
2546
|
-
url:
|
|
2592
|
+
url: W(u.name, Fe),
|
|
2547
2593
|
method: "GET",
|
|
2548
2594
|
resourceType: "resource",
|
|
2549
2595
|
responseStatus: u.responseStatus,
|
|
@@ -2593,17 +2639,17 @@ function A(t, e, s) {
|
|
|
2593
2639
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
2594
2640
|
i.push(r), i.length > 120 && i.splice(0, i.length - 120), n.__plunoProductAgentDiagnostics__ = i, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: r }));
|
|
2595
2641
|
}
|
|
2596
|
-
function
|
|
2642
|
+
function Ct(t) {
|
|
2597
2643
|
const e = typeof t == "function" ? t() : t;
|
|
2598
2644
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2599
2645
|
}
|
|
2600
|
-
function
|
|
2646
|
+
function _n(t) {
|
|
2601
2647
|
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";
|
|
2602
2648
|
}
|
|
2603
|
-
function
|
|
2649
|
+
function ye(t) {
|
|
2604
2650
|
return t.type === "run.steered" || t.type === "run.ack" || t.type === "run.model_started" || t.type === "conversation.state" || t.type === "scheduled_follow_ups.updated" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
|
|
2605
2651
|
}
|
|
2606
|
-
function
|
|
2652
|
+
function K(t) {
|
|
2607
2653
|
if (typeof t.sessionId == "string")
|
|
2608
2654
|
return t.sessionId;
|
|
2609
2655
|
if (t.session && typeof t.session == "object") {
|
|
@@ -2618,31 +2664,31 @@ function G(t) {
|
|
|
2618
2664
|
}
|
|
2619
2665
|
return null;
|
|
2620
2666
|
}
|
|
2621
|
-
const
|
|
2622
|
-
function
|
|
2667
|
+
const Pn = 5e3, Un = 12e4;
|
|
2668
|
+
function vn() {
|
|
2623
2669
|
const t = [
|
|
2624
|
-
|
|
2625
|
-
|
|
2670
|
+
On(),
|
|
2671
|
+
Dn()
|
|
2626
2672
|
].filter((e) => typeof e == "function");
|
|
2627
2673
|
return () => {
|
|
2628
2674
|
for (const e of t.reverse())
|
|
2629
2675
|
e();
|
|
2630
2676
|
};
|
|
2631
2677
|
}
|
|
2632
|
-
function
|
|
2633
|
-
return
|
|
2678
|
+
function Dn() {
|
|
2679
|
+
return $t(globalThis, "getPageSnapshot", async () => at());
|
|
2634
2680
|
}
|
|
2635
|
-
function
|
|
2636
|
-
return
|
|
2637
|
-
inspectImage: async (e, s) => await
|
|
2681
|
+
function On() {
|
|
2682
|
+
return $t(globalThis, "pageImages", {
|
|
2683
|
+
inspectImage: async (e, s) => await qn(e, s)
|
|
2638
2684
|
});
|
|
2639
2685
|
}
|
|
2640
|
-
async function
|
|
2641
|
-
const s =
|
|
2686
|
+
async function qn(t, e = {}) {
|
|
2687
|
+
const s = Bn(e.name), n = await Ln(t);
|
|
2642
2688
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2643
2689
|
type: "pluno.pageImages.inspectImage",
|
|
2644
2690
|
imageAttached: !1,
|
|
2645
|
-
imageAttachmentError:
|
|
2691
|
+
imageAttachmentError: Xt
|
|
2646
2692
|
} : {
|
|
2647
2693
|
type: "pluno.pageImages.inspectImage",
|
|
2648
2694
|
imageAttached: !0,
|
|
@@ -2656,15 +2702,15 @@ async function _n(t, e = {}) {
|
|
|
2656
2702
|
imageAttachmentError: n.error
|
|
2657
2703
|
};
|
|
2658
2704
|
}
|
|
2659
|
-
async function
|
|
2660
|
-
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:
|
|
2705
|
+
async function Ln(t) {
|
|
2706
|
+
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: Xt } : {
|
|
2661
2707
|
ok: !0,
|
|
2662
2708
|
mimeType: t.type,
|
|
2663
2709
|
sizeBytes: t.size,
|
|
2664
|
-
dataUrl: await
|
|
2665
|
-
} : { 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." } :
|
|
2710
|
+
dataUrl: await Hn(t)
|
|
2711
|
+
} : { 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." } : Nn(t);
|
|
2666
2712
|
}
|
|
2667
|
-
function
|
|
2713
|
+
function Nn(t) {
|
|
2668
2714
|
if (!t.startsWith("data:") || !t.includes(","))
|
|
2669
2715
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
2670
2716
|
const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -2675,7 +2721,7 @@ function Un(t) {
|
|
|
2675
2721
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
2676
2722
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
2677
2723
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
2678
|
-
const o =
|
|
2724
|
+
const o = xn(i);
|
|
2679
2725
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
2680
2726
|
ok: !0,
|
|
2681
2727
|
mimeType: r,
|
|
@@ -2683,22 +2729,22 @@ function Un(t) {
|
|
|
2683
2729
|
dataUrl: `data:${r};base64,${i}`
|
|
2684
2730
|
};
|
|
2685
2731
|
}
|
|
2686
|
-
function
|
|
2732
|
+
function xn(t) {
|
|
2687
2733
|
if (t.length === 0 || t.length % 4 !== 0)
|
|
2688
2734
|
return null;
|
|
2689
2735
|
const e = t.length - t.replace(/=+$/, "").length;
|
|
2690
2736
|
return e > 2 ? null : t.length / 4 * 3 - e;
|
|
2691
2737
|
}
|
|
2692
|
-
function
|
|
2738
|
+
function Bn(t) {
|
|
2693
2739
|
return (typeof t == "string" ? t.trim() : "") || "Page image";
|
|
2694
2740
|
}
|
|
2695
|
-
function
|
|
2741
|
+
function Wn(t) {
|
|
2696
2742
|
try {
|
|
2697
2743
|
t();
|
|
2698
2744
|
} catch {
|
|
2699
2745
|
}
|
|
2700
2746
|
}
|
|
2701
|
-
function
|
|
2747
|
+
function Hn(t) {
|
|
2702
2748
|
return new Promise((e, s) => {
|
|
2703
2749
|
const n = new FileReader();
|
|
2704
2750
|
n.onload = () => {
|
|
@@ -2710,9 +2756,9 @@ function qn(t) {
|
|
|
2710
2756
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(t);
|
|
2711
2757
|
});
|
|
2712
2758
|
}
|
|
2713
|
-
async function
|
|
2759
|
+
async function bt(t, e) {
|
|
2714
2760
|
const s = Object.getPrototypeOf(async function() {
|
|
2715
|
-
}).constructor, n = t.timeoutMs ??
|
|
2761
|
+
}).constructor, n = t.timeoutMs ?? Pn, r = Date.now(), i = [];
|
|
2716
2762
|
let o;
|
|
2717
2763
|
const a = {
|
|
2718
2764
|
log: console.log,
|
|
@@ -2730,7 +2776,7 @@ async function Ct(t, e) {
|
|
|
2730
2776
|
o = window.setTimeout(() => h(c), n);
|
|
2731
2777
|
})
|
|
2732
2778
|
]);
|
|
2733
|
-
return d === c ?
|
|
2779
|
+
return d === c ? Fn(n) : {
|
|
2734
2780
|
ok: !0,
|
|
2735
2781
|
result: d,
|
|
2736
2782
|
console: i,
|
|
@@ -2759,7 +2805,7 @@ async function Ct(t, e) {
|
|
|
2759
2805
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2760
2806
|
}
|
|
2761
2807
|
}
|
|
2762
|
-
function
|
|
2808
|
+
function $n(t, e) {
|
|
2763
2809
|
if (!t || typeof t != "object")
|
|
2764
2810
|
return;
|
|
2765
2811
|
const s = t.sandboxFilesToken;
|
|
@@ -2769,7 +2815,7 @@ function Ln(t, e) {
|
|
|
2769
2815
|
const r = () => {
|
|
2770
2816
|
if (!n)
|
|
2771
2817
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2772
|
-
}, i = async (a, l) => await
|
|
2818
|
+
}, i = async (a, l) => await en(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2773
2819
|
return {
|
|
2774
2820
|
value: Object.freeze({
|
|
2775
2821
|
upload: async (a) => {
|
|
@@ -2803,7 +2849,7 @@ function Ln(t, e) {
|
|
|
2803
2849
|
}
|
|
2804
2850
|
};
|
|
2805
2851
|
}
|
|
2806
|
-
function
|
|
2852
|
+
function Fn(t) {
|
|
2807
2853
|
return {
|
|
2808
2854
|
ok: !1,
|
|
2809
2855
|
exception: {
|
|
@@ -2817,10 +2863,10 @@ function Nn(t) {
|
|
|
2817
2863
|
}
|
|
2818
2864
|
};
|
|
2819
2865
|
}
|
|
2820
|
-
function
|
|
2866
|
+
function jn(t) {
|
|
2821
2867
|
return t.replace(/\/+$/, "");
|
|
2822
2868
|
}
|
|
2823
|
-
function
|
|
2869
|
+
function zn(t) {
|
|
2824
2870
|
const e = {
|
|
2825
2871
|
sidepanel: "extension_sidepanel",
|
|
2826
2872
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2832,18 +2878,18 @@ function Bn(t) {
|
|
|
2832
2878
|
};
|
|
2833
2879
|
return t && t in e ? e[t] : t ?? "embedded_custom_ui";
|
|
2834
2880
|
}
|
|
2835
|
-
function
|
|
2881
|
+
function Kn(t) {
|
|
2836
2882
|
return t === "pluno" ? "scheduled_continuation" : t ?? "user";
|
|
2837
2883
|
}
|
|
2838
|
-
function
|
|
2884
|
+
function Gn(t, e = location.origin) {
|
|
2839
2885
|
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;
|
|
2840
2886
|
}
|
|
2841
|
-
function
|
|
2887
|
+
function Vn(t) {
|
|
2842
2888
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2843
2889
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2844
2890
|
}
|
|
2845
2891
|
function b() {
|
|
2846
|
-
const t =
|
|
2892
|
+
const t = ts();
|
|
2847
2893
|
return {
|
|
2848
2894
|
url: location.href,
|
|
2849
2895
|
title: document.title,
|
|
@@ -2851,21 +2897,21 @@ function b() {
|
|
|
2851
2897
|
...t ? { plunoProductAgentUi: t } : {}
|
|
2852
2898
|
};
|
|
2853
2899
|
}
|
|
2854
|
-
function
|
|
2900
|
+
function Xn() {
|
|
2855
2901
|
return {
|
|
2856
2902
|
pageUrl: location.href,
|
|
2857
2903
|
pageTitle: document.title,
|
|
2858
2904
|
htmlContent: at()
|
|
2859
2905
|
};
|
|
2860
2906
|
}
|
|
2861
|
-
function
|
|
2862
|
-
return
|
|
2863
|
-
|
|
2907
|
+
function Jn(t) {
|
|
2908
|
+
return Me.add(t), me || (me = Qn()), () => {
|
|
2909
|
+
Me.delete(t), Me.size === 0 && (me?.(), me = null);
|
|
2864
2910
|
};
|
|
2865
2911
|
}
|
|
2866
|
-
function
|
|
2912
|
+
function Qn() {
|
|
2867
2913
|
const t = () => {
|
|
2868
|
-
for (const i of Array.from(
|
|
2914
|
+
for (const i of Array.from(Me))
|
|
2869
2915
|
i();
|
|
2870
2916
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2871
2917
|
const o = e(...i);
|
|
@@ -2878,33 +2924,33 @@ function zn() {
|
|
|
2878
2924
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2879
2925
|
};
|
|
2880
2926
|
}
|
|
2881
|
-
function
|
|
2882
|
-
return
|
|
2927
|
+
function Ie() {
|
|
2928
|
+
return ts()?.surface === "browser_extension_sdk_preview";
|
|
2883
2929
|
}
|
|
2884
2930
|
function at() {
|
|
2885
2931
|
if (!document.body)
|
|
2886
2932
|
return "";
|
|
2887
|
-
const t = [], e = [], s = (p,
|
|
2888
|
-
const
|
|
2889
|
-
!
|
|
2933
|
+
const t = [], e = [], s = (p, m) => {
|
|
2934
|
+
const f = te(m);
|
|
2935
|
+
!f || e.includes(f) || (t.push([p, f]), e.push(f));
|
|
2890
2936
|
};
|
|
2891
2937
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2892
2938
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2893
|
-
(p) =>
|
|
2939
|
+
(p) => Yt(p) && !p.parentElement?.closest(n)
|
|
2894
2940
|
);
|
|
2895
2941
|
for (const p of r.slice(0, 3))
|
|
2896
2942
|
s("Active overlay", ze(ue(p), e));
|
|
2897
|
-
const i =
|
|
2943
|
+
const i = Yn(), o = i ? ze(ue(i), e) : "";
|
|
2898
2944
|
s("Main page content", o), s("Additional visible page text", ze(ue(document.body), e));
|
|
2899
|
-
const a = t.map(([p,
|
|
2900
|
-
${
|
|
2945
|
+
const a = t.map(([p, m]) => `${p}:
|
|
2946
|
+
${m}`).join(`
|
|
2901
2947
|
|
|
2902
|
-
`).trim().slice(0, 12e3), l =
|
|
2948
|
+
`).trim().slice(0, 12e3), l = Zn(r, i).trim(), c = `Simplified DOM outline:
|
|
2903
2949
|
`, d = `
|
|
2904
2950
|
|
|
2905
2951
|
Visible page text:
|
|
2906
|
-
`, h = 12e3 - c.length - d.length,
|
|
2907
|
-
return `${c}${
|
|
2952
|
+
`, h = 12e3 - c.length - d.length, g = Math.min(a.length, 7900), y = l.slice(0, h - g), u = a.slice(0, h - y.length);
|
|
2953
|
+
return `${c}${y}${d}${u}`;
|
|
2908
2954
|
}
|
|
2909
2955
|
function ue(t) {
|
|
2910
2956
|
return t.innerText ?? t.textContent ?? "";
|
|
@@ -2923,14 +2969,14 @@ function ze(t, e) {
|
|
|
2923
2969
|
s = s.replace(n, "");
|
|
2924
2970
|
return te(s);
|
|
2925
2971
|
}
|
|
2926
|
-
function
|
|
2972
|
+
function Yt(t) {
|
|
2927
2973
|
const e = window.getComputedStyle(t);
|
|
2928
2974
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2929
2975
|
}
|
|
2930
|
-
function
|
|
2931
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2976
|
+
function Yn() {
|
|
2977
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Yt).sort((t, e) => ue(e).length - ue(t).length)[0] ?? null;
|
|
2932
2978
|
}
|
|
2933
|
-
function
|
|
2979
|
+
function Zn(t, e) {
|
|
2934
2980
|
const s = /* @__PURE__ */ new Set([
|
|
2935
2981
|
"main",
|
|
2936
2982
|
"nav",
|
|
@@ -3010,92 +3056,92 @@ function Gn(t, e) {
|
|
|
3010
3056
|
"data-test",
|
|
3011
3057
|
"data-qa",
|
|
3012
3058
|
"data-cy"
|
|
3013
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: h } =
|
|
3014
|
-
e &&
|
|
3015
|
-
let
|
|
3016
|
-
const u = (
|
|
3017
|
-
const
|
|
3018
|
-
return
|
|
3019
|
-
}, p = (
|
|
3020
|
-
const
|
|
3021
|
-
return `${
|
|
3022
|
-
},
|
|
3023
|
-
const
|
|
3024
|
-
const
|
|
3025
|
-
if (
|
|
3059
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: h } = er(), g = new Set(t);
|
|
3060
|
+
e && g.add(e);
|
|
3061
|
+
let y = 0;
|
|
3062
|
+
const u = (S) => {
|
|
3063
|
+
const U = S.getAttribute("role");
|
|
3064
|
+
return U && !o.has(U) ? U : "";
|
|
3065
|
+
}, p = (S) => {
|
|
3066
|
+
const U = S.getAttribute("data-testid") || S.getAttribute("data-test") || S.getAttribute("data-qa") || S.getAttribute("data-cy") || "";
|
|
3067
|
+
return `${S.tagName.toLowerCase()}|${u(S)}|${U}`;
|
|
3068
|
+
}, m = (S, U, x) => {
|
|
3069
|
+
const T = (w, L) => {
|
|
3070
|
+
const P = w.tagName.toLowerCase(), ne = window.getComputedStyle(w), J = d.has(w);
|
|
3071
|
+
if (y >= 1e3 && !J || x.has(w) || i.has(P) || w.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ne.display === "none" || ne.visibility === "hidden")
|
|
3026
3072
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
3027
|
-
|
|
3028
|
-
const
|
|
3029
|
-
for (const I of
|
|
3073
|
+
y += 1;
|
|
3074
|
+
const Q = u(w), Y = es(w), pe = a.has(Q) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(P) || P === "a" && w.hasAttribute("href"), B = Array.from(w.children).filter((I) => I instanceof HTMLElement), z = /* @__PURE__ */ new Map();
|
|
3075
|
+
for (const I of B) {
|
|
3030
3076
|
const E = p(I);
|
|
3031
|
-
|
|
3077
|
+
z.set(E, (z.get(E) ?? 0) + 1);
|
|
3032
3078
|
}
|
|
3033
|
-
const
|
|
3034
|
-
for (const I of
|
|
3035
|
-
const E = p(I), j =
|
|
3036
|
-
|
|
3079
|
+
const he = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map();
|
|
3080
|
+
for (const I of B) {
|
|
3081
|
+
const E = p(I), j = re.get(E) ?? 0;
|
|
3082
|
+
re.set(E, j + 1), (z.get(E) ?? 0) > 8 && j >= 6 && !d.has(I) && he.set(E, (he.get(E) ?? 0) + 1);
|
|
3037
3083
|
}
|
|
3038
|
-
const
|
|
3039
|
-
for (const I of
|
|
3040
|
-
const E = p(I), j =
|
|
3041
|
-
if (
|
|
3042
|
-
|
|
3084
|
+
const F = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set(), v = [], ut = [];
|
|
3085
|
+
for (const I of B) {
|
|
3086
|
+
const E = p(I), j = z.get(E) ?? 0, ht = F.get(E) ?? 0;
|
|
3087
|
+
if (F.set(E, ht + 1), j > 8 && ht >= 6 && !d.has(I)) {
|
|
3088
|
+
k.has(E) || (v.push([`… ${he.get(E) ?? 0} similar siblings omitted`]), k.add(E));
|
|
3043
3089
|
continue;
|
|
3044
3090
|
}
|
|
3045
|
-
const gt =
|
|
3046
|
-
ut.push(gt),
|
|
3091
|
+
const gt = T(I, L);
|
|
3092
|
+
ut.push(gt), v.push(gt.lines);
|
|
3047
3093
|
}
|
|
3048
3094
|
const De = [];
|
|
3049
|
-
if (
|
|
3050
|
-
for (const I of Array.from(
|
|
3051
|
-
I instanceof HTMLElement && De.push(
|
|
3052
|
-
const
|
|
3053
|
-
[
|
|
3054
|
-
).slice(0, 180),
|
|
3095
|
+
if (w.shadowRoot)
|
|
3096
|
+
for (const I of Array.from(w.shadowRoot.children))
|
|
3097
|
+
I instanceof HTMLElement && De.push(T(I, L + 1));
|
|
3098
|
+
const ge = [...ut, ...De], Oe = Y.length > 0 || pe || ge.some((I) => I.hasUsefulContent), dt = te(
|
|
3099
|
+
[Y, ...ge.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
3100
|
+
).slice(0, 180), As = w.hasAttribute("contenteditable") && (Y.length > 0 || !w.querySelector("[contenteditable]")), pt = c.some((I) => w.hasAttribute(I)) || !!Q || As, qe = (w.getClientRects().length > 0 || ne.display === "contents") && (s.has(P) || pt || J) && (Oe || J) && (!r.has(P) || Oe || pt || J), Le = qe ? 1 : 0, ie = [];
|
|
3055
3101
|
if (qe) {
|
|
3056
|
-
const I =
|
|
3057
|
-
ie.push(
|
|
3102
|
+
const I = ge.some((j) => j.containsTextElement), E = n.has(P) && !I ? dt : Y;
|
|
3103
|
+
ie.push(Zt(w, l, o, E.slice(0, 180)));
|
|
3058
3104
|
}
|
|
3059
|
-
for (const I of
|
|
3060
|
-
ie.push(...
|
|
3105
|
+
for (const I of v)
|
|
3106
|
+
ie.push(...Se(I, Le));
|
|
3061
3107
|
const Ne = De.flatMap((I) => I.lines);
|
|
3062
3108
|
if (Ne.length > 0) {
|
|
3063
3109
|
const I = Ne.slice(0, 20);
|
|
3064
3110
|
Ne.length > I.length && I.push("… shadow DOM omitted");
|
|
3065
|
-
const E =
|
|
3066
|
-
if (
|
|
3067
|
-
const j = qe ? "#shadow-root" : `${
|
|
3068
|
-
ie.push(...
|
|
3111
|
+
const E = P.includes("tooltip") || P.includes("popper") || P.includes("loader");
|
|
3112
|
+
if (L < 2 && !E) {
|
|
3113
|
+
const j = qe ? "#shadow-root" : `${P} #shadow-root`;
|
|
3114
|
+
ie.push(...Se([j, ...Se(I, 1)], Le));
|
|
3069
3115
|
} else
|
|
3070
|
-
ie.push(...
|
|
3116
|
+
ie.push(...Se(I, Le));
|
|
3071
3117
|
}
|
|
3072
3118
|
return {
|
|
3073
3119
|
lines: ie,
|
|
3074
3120
|
hasUsefulContent: Oe,
|
|
3075
3121
|
textPreview: dt,
|
|
3076
|
-
containsTextElement: n.has(
|
|
3122
|
+
containsTextElement: n.has(P) || ge.some((I) => I.containsTextElement)
|
|
3077
3123
|
};
|
|
3078
3124
|
};
|
|
3079
|
-
return [`--- ${
|
|
3125
|
+
return [`--- ${U} ---`, ...T(S, 0).lines].join(`
|
|
3080
3126
|
`);
|
|
3081
|
-
},
|
|
3082
|
-
|
|
3083
|
-
${JSON.stringify(
|
|
3084
|
-
for (const
|
|
3085
|
-
|
|
3086
|
-
if (e &&
|
|
3087
|
-
const
|
|
3088
|
-
|
|
3089
|
-
}
|
|
3090
|
-
return
|
|
3127
|
+
}, f = [], R = te(window.getSelection()?.toString() ?? "");
|
|
3128
|
+
R && f.push(`--- selected text ---
|
|
3129
|
+
${JSON.stringify(R)}`), h.length > 0 && f.push(tr(h, s, l, o));
|
|
3130
|
+
for (const S of t.slice(0, 3))
|
|
3131
|
+
f.push(m(S, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
3132
|
+
if (e && f.push(m(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
3133
|
+
const S = e || t.length ? "other visible DOM" : "visible DOM";
|
|
3134
|
+
f.push(m(document.body, S, g));
|
|
3135
|
+
}
|
|
3136
|
+
return f.join(`
|
|
3091
3137
|
|
|
3092
3138
|
`);
|
|
3093
3139
|
}
|
|
3094
|
-
function
|
|
3140
|
+
function Zt(t, e, s, n) {
|
|
3095
3141
|
const r = t.tagName.toLowerCase();
|
|
3096
3142
|
let i = r;
|
|
3097
3143
|
const o = t.getAttribute("id");
|
|
3098
|
-
o &&
|
|
3144
|
+
o && sr(o) && (i += `#${o}`);
|
|
3099
3145
|
for (const a of e) {
|
|
3100
3146
|
const l = t.getAttribute(a);
|
|
3101
3147
|
l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
|
|
@@ -3108,7 +3154,7 @@ function Xt(t, e, s, n) {
|
|
|
3108
3154
|
t.hasAttribute(a) && (i += `[${a}]`);
|
|
3109
3155
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
3110
3156
|
}
|
|
3111
|
-
function
|
|
3157
|
+
function er() {
|
|
3112
3158
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
|
|
3113
3159
|
if (!a)
|
|
3114
3160
|
return;
|
|
@@ -3120,8 +3166,8 @@ function Vn() {
|
|
|
3120
3166
|
let h = a;
|
|
3121
3167
|
for (; h; ) {
|
|
3122
3168
|
t.add(h);
|
|
3123
|
-
const
|
|
3124
|
-
h = h.parentElement ?? (
|
|
3169
|
+
const g = h.getRootNode();
|
|
3170
|
+
h = h.parentElement ?? (g instanceof ShadowRoot && g.host instanceof HTMLElement ? g.host : null);
|
|
3125
3171
|
}
|
|
3126
3172
|
};
|
|
3127
3173
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -3129,7 +3175,7 @@ function Vn() {
|
|
|
3129
3175
|
n = n.shadowRoot.activeElement;
|
|
3130
3176
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
3131
3177
|
const r = window.getSelection();
|
|
3132
|
-
r && !r.isCollapsed && (s(
|
|
3178
|
+
r && !r.isCollapsed && (s(_t(r.anchorNode), "selected text"), s(_t(r.focusNode), "selected text"));
|
|
3133
3179
|
const i = [
|
|
3134
3180
|
["[aria-selected='true']", "selected"],
|
|
3135
3181
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -3151,7 +3197,7 @@ function Vn() {
|
|
|
3151
3197
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
3152
3198
|
};
|
|
3153
3199
|
}
|
|
3154
|
-
function
|
|
3200
|
+
function tr(t, e, s, n) {
|
|
3155
3201
|
const r = ["--- active/current elements ---"];
|
|
3156
3202
|
for (const i of t) {
|
|
3157
3203
|
const o = [];
|
|
@@ -3162,36 +3208,36 @@ function Xn(t, e, s, n) {
|
|
|
3162
3208
|
const h = a.getRootNode();
|
|
3163
3209
|
a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
|
|
3164
3210
|
}
|
|
3165
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d, h) =>
|
|
3211
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d, h) => Zt(
|
|
3166
3212
|
d,
|
|
3167
3213
|
s,
|
|
3168
3214
|
n,
|
|
3169
|
-
h === l.length - 1 ?
|
|
3215
|
+
h === l.length - 1 ? es(d).slice(0, 180) : ""
|
|
3170
3216
|
));
|
|
3171
3217
|
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
3172
3218
|
}
|
|
3173
3219
|
return r.join(`
|
|
3174
3220
|
`);
|
|
3175
3221
|
}
|
|
3176
|
-
function
|
|
3222
|
+
function _t(t) {
|
|
3177
3223
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
3178
3224
|
}
|
|
3179
|
-
function
|
|
3225
|
+
function Se(t, e) {
|
|
3180
3226
|
if (e === 0)
|
|
3181
3227
|
return t;
|
|
3182
3228
|
const s = " ".repeat(e);
|
|
3183
3229
|
return t.map((n) => `${s}${n}`);
|
|
3184
3230
|
}
|
|
3185
|
-
function
|
|
3231
|
+
function es(t) {
|
|
3186
3232
|
return te(
|
|
3187
3233
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
3188
3234
|
);
|
|
3189
3235
|
}
|
|
3190
|
-
function
|
|
3236
|
+
function sr(t) {
|
|
3191
3237
|
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);
|
|
3192
3238
|
}
|
|
3193
|
-
function
|
|
3194
|
-
const t = document.querySelector(
|
|
3239
|
+
function ts() {
|
|
3240
|
+
const t = document.querySelector(mt);
|
|
3195
3241
|
if (!(t ?? document.querySelector(Xe)))
|
|
3196
3242
|
return;
|
|
3197
3243
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
@@ -3201,28 +3247,28 @@ function Qt() {
|
|
|
3201
3247
|
selectors: [
|
|
3202
3248
|
{
|
|
3203
3249
|
name: "widget_host",
|
|
3204
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
3250
|
+
selector: s === "browser_extension_sdk_preview" ? mt : Xe,
|
|
3205
3251
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
3206
3252
|
},
|
|
3207
3253
|
{
|
|
3208
3254
|
name: "widget_root",
|
|
3209
|
-
selector:
|
|
3255
|
+
selector: tn,
|
|
3210
3256
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
3211
3257
|
},
|
|
3212
3258
|
{
|
|
3213
3259
|
name: "widget_panel",
|
|
3214
|
-
selector:
|
|
3260
|
+
selector: sn,
|
|
3215
3261
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
3216
3262
|
},
|
|
3217
3263
|
{
|
|
3218
3264
|
name: "widget_timeline",
|
|
3219
|
-
selector:
|
|
3265
|
+
selector: nn,
|
|
3220
3266
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
3221
3267
|
}
|
|
3222
3268
|
]
|
|
3223
3269
|
};
|
|
3224
3270
|
}
|
|
3225
|
-
function
|
|
3271
|
+
function nr(t) {
|
|
3226
3272
|
try {
|
|
3227
3273
|
const e = JSON.parse(t);
|
|
3228
3274
|
return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
|
|
@@ -3230,7 +3276,7 @@ function Qn(t) {
|
|
|
3230
3276
|
return { type: "error", message: "Invalid server event" };
|
|
3231
3277
|
}
|
|
3232
3278
|
}
|
|
3233
|
-
function
|
|
3279
|
+
function rr(t) {
|
|
3234
3280
|
if (typeof t != "string")
|
|
3235
3281
|
return null;
|
|
3236
3282
|
try {
|
|
@@ -3240,13 +3286,13 @@ function Yn(t) {
|
|
|
3240
3286
|
return null;
|
|
3241
3287
|
}
|
|
3242
3288
|
}
|
|
3243
|
-
function
|
|
3289
|
+
function Pt(t, e) {
|
|
3244
3290
|
if (!t || typeof t != "object")
|
|
3245
3291
|
return [];
|
|
3246
3292
|
const s = t[e];
|
|
3247
3293
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
3248
3294
|
}
|
|
3249
|
-
function
|
|
3295
|
+
function Ut(t) {
|
|
3250
3296
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3251
3297
|
if (!e || typeof e != "object")
|
|
3252
3298
|
return [];
|
|
@@ -3254,10 +3300,10 @@ function Pt(t) {
|
|
|
3254
3300
|
return typeof s.taskId != "string" || !s.taskId || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? [] : [{ taskId: s.taskId, dueAt: s.dueAt }];
|
|
3255
3301
|
}) : [];
|
|
3256
3302
|
}
|
|
3257
|
-
function
|
|
3303
|
+
function ir(t) {
|
|
3258
3304
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
3259
3305
|
}
|
|
3260
|
-
function
|
|
3306
|
+
function or(t) {
|
|
3261
3307
|
if (!t || typeof t != "object")
|
|
3262
3308
|
return null;
|
|
3263
3309
|
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;
|
|
@@ -3268,13 +3314,13 @@ function er(t) {
|
|
|
3268
3314
|
...a !== null ? { scribbleStyle: a } : {}
|
|
3269
3315
|
};
|
|
3270
3316
|
}
|
|
3271
|
-
function
|
|
3317
|
+
function ar(t) {
|
|
3272
3318
|
if (!t || typeof t != "object")
|
|
3273
3319
|
return null;
|
|
3274
3320
|
const e = t.javascript;
|
|
3275
3321
|
return typeof e != "string" || !e.trim() ? null : { javascript: e };
|
|
3276
3322
|
}
|
|
3277
|
-
function
|
|
3323
|
+
function lr(t, e) {
|
|
3278
3324
|
return e ? t && typeof t == "object" ? {
|
|
3279
3325
|
...t,
|
|
3280
3326
|
helperError: e
|
|
@@ -3284,23 +3330,23 @@ function sr(t, e) {
|
|
|
3284
3330
|
helperError: e
|
|
3285
3331
|
} : t;
|
|
3286
3332
|
}
|
|
3287
|
-
function
|
|
3333
|
+
function cr(t) {
|
|
3288
3334
|
if (!t || typeof t != "object")
|
|
3289
3335
|
return t;
|
|
3290
3336
|
const e = t;
|
|
3291
3337
|
return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : t;
|
|
3292
3338
|
}
|
|
3293
|
-
function
|
|
3339
|
+
function ur() {
|
|
3294
3340
|
const t = "pluno.productAgent.clientId", e = window.localStorage.getItem(t);
|
|
3295
3341
|
if (e)
|
|
3296
3342
|
return e;
|
|
3297
3343
|
const s = crypto.randomUUID();
|
|
3298
3344
|
return window.localStorage.setItem(t, s), s;
|
|
3299
3345
|
}
|
|
3300
|
-
function
|
|
3346
|
+
function N() {
|
|
3301
3347
|
return crypto.randomUUID();
|
|
3302
3348
|
}
|
|
3303
|
-
function
|
|
3349
|
+
function dr(t) {
|
|
3304
3350
|
if (!t || typeof t != "object")
|
|
3305
3351
|
return null;
|
|
3306
3352
|
const e = t, s = typeof e.id == "string" ? e.id : null;
|
|
@@ -3311,22 +3357,22 @@ function ir(t) {
|
|
|
3311
3357
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
3312
3358
|
} : null;
|
|
3313
3359
|
}
|
|
3314
|
-
function
|
|
3360
|
+
function vt(t, e) {
|
|
3315
3361
|
return Array.isArray(t) ? et(
|
|
3316
|
-
t.map((s) =>
|
|
3362
|
+
t.map((s) => ss(s, e)).filter((s) => s !== null)
|
|
3317
3363
|
) : [];
|
|
3318
3364
|
}
|
|
3319
|
-
function
|
|
3365
|
+
function pr(t) {
|
|
3320
3366
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3321
3367
|
if (!e || typeof e != "object")
|
|
3322
3368
|
return [];
|
|
3323
|
-
const s = e, n =
|
|
3369
|
+
const s = e, n = M(s, "id"), r = M(s, "createdAt"), i = M(s, "updatedAt"), o = M(s, "lastActiveAt");
|
|
3324
3370
|
return !n || !r || !i || !o ? [] : [
|
|
3325
3371
|
{
|
|
3326
3372
|
id: n,
|
|
3327
|
-
title:
|
|
3328
|
-
customTitle:
|
|
3329
|
-
firstUserMessage:
|
|
3373
|
+
title: M(s, "title"),
|
|
3374
|
+
customTitle: M(s, "customTitle"),
|
|
3375
|
+
firstUserMessage: M(s, "firstUserMessage"),
|
|
3330
3376
|
currentPage: s.currentPage ?? null,
|
|
3331
3377
|
createdAt: r,
|
|
3332
3378
|
updatedAt: i,
|
|
@@ -3337,29 +3383,29 @@ function or(t) {
|
|
|
3337
3383
|
];
|
|
3338
3384
|
}) : [];
|
|
3339
3385
|
}
|
|
3340
|
-
function
|
|
3386
|
+
function ss(t, e) {
|
|
3341
3387
|
if (!t || typeof t != "object")
|
|
3342
3388
|
return null;
|
|
3343
3389
|
const s = t, n = s.data;
|
|
3344
3390
|
if (!n || typeof n != "object")
|
|
3345
3391
|
return null;
|
|
3346
3392
|
const r = n;
|
|
3347
|
-
if (r.hiddenFromTranscript === !0 ||
|
|
3393
|
+
if (r.hiddenFromTranscript === !0 || Ls(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
3348
3394
|
return null;
|
|
3349
3395
|
if (r.type === "message") {
|
|
3350
3396
|
const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
|
|
3351
3397
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3352
3398
|
role: i,
|
|
3353
3399
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
3354
|
-
content:
|
|
3355
|
-
|
|
3400
|
+
content: Us(
|
|
3401
|
+
Tr(r.content),
|
|
3356
3402
|
e
|
|
3357
3403
|
),
|
|
3358
3404
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3359
|
-
...
|
|
3360
|
-
respondsToUserMessageId:
|
|
3405
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3406
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3361
3407
|
...C(r) ? { runId: C(r) } : {},
|
|
3362
|
-
attachments:
|
|
3408
|
+
attachments: ps(r.attachments, e)
|
|
3363
3409
|
};
|
|
3364
3410
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
3365
3411
|
value: r.id,
|
|
@@ -3373,43 +3419,43 @@ function Yt(t, e) {
|
|
|
3373
3419
|
}), o;
|
|
3374
3420
|
}
|
|
3375
3421
|
if (r.type === "function_call_output") {
|
|
3376
|
-
const i =
|
|
3422
|
+
const i = Ds(r.output);
|
|
3377
3423
|
if (i !== null)
|
|
3378
3424
|
return {
|
|
3379
3425
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3380
3426
|
role: "tool",
|
|
3381
3427
|
content: "",
|
|
3382
3428
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3383
|
-
respondsToUserMessageId:
|
|
3429
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3384
3430
|
...C(r) ? { runId: C(r) } : {},
|
|
3385
3431
|
dataType: "function_call_output",
|
|
3386
|
-
toolName:
|
|
3432
|
+
toolName: vs,
|
|
3387
3433
|
callId: ce(r) ?? void 0,
|
|
3388
3434
|
sharePromptAllowed: i
|
|
3389
3435
|
};
|
|
3390
|
-
const o =
|
|
3436
|
+
const o = Vs(r.output);
|
|
3391
3437
|
if (o)
|
|
3392
3438
|
return {
|
|
3393
3439
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3394
3440
|
role: "tool",
|
|
3395
3441
|
content: "",
|
|
3396
3442
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3397
|
-
respondsToUserMessageId:
|
|
3443
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3398
3444
|
...C(r) ? { runId: C(r) } : {},
|
|
3399
3445
|
dataType: "scheduled_check_in",
|
|
3400
|
-
toolName:
|
|
3446
|
+
toolName: jt,
|
|
3401
3447
|
callId: ce(r) ?? void 0,
|
|
3402
3448
|
scheduledCheckInId: o.id ?? void 0,
|
|
3403
3449
|
scheduledCheckInAt: o.dueAt
|
|
3404
3450
|
};
|
|
3405
|
-
const a =
|
|
3451
|
+
const a = gr(r.output), l = fr(r.output);
|
|
3406
3452
|
return a ? {
|
|
3407
3453
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3408
3454
|
role: "tool",
|
|
3409
3455
|
content: `Connect ${a.appName} to continue`,
|
|
3410
3456
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3411
|
-
...
|
|
3412
|
-
respondsToUserMessageId:
|
|
3457
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3458
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3413
3459
|
...C(r) ? { runId: C(r) } : {},
|
|
3414
3460
|
dataType: "function_call_output",
|
|
3415
3461
|
toolName: "authenticate_pipedream_app",
|
|
@@ -3420,8 +3466,8 @@ function Yt(t, e) {
|
|
|
3420
3466
|
role: "tool",
|
|
3421
3467
|
content: "Connect WhatsApp to continue",
|
|
3422
3468
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3423
|
-
...
|
|
3424
|
-
respondsToUserMessageId:
|
|
3469
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3470
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3425
3471
|
...C(r) ? { runId: C(r) } : {},
|
|
3426
3472
|
dataType: "function_call_output",
|
|
3427
3473
|
toolName: "request_personal_channel_connection",
|
|
@@ -3432,10 +3478,10 @@ function Yt(t, e) {
|
|
|
3432
3478
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
3433
3479
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3434
3480
|
role: "tool",
|
|
3435
|
-
content: r.type === "mcp_call" ?
|
|
3481
|
+
content: r.type === "mcp_call" ? hr(r) : yr(r),
|
|
3436
3482
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3437
|
-
...
|
|
3438
|
-
respondsToUserMessageId:
|
|
3483
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3484
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3439
3485
|
...C(r) ? { runId: C(r) } : {},
|
|
3440
3486
|
dataType: String(r.type),
|
|
3441
3487
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
@@ -3444,10 +3490,10 @@ function Yt(t, e) {
|
|
|
3444
3490
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
3445
3491
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3446
3492
|
role: "system",
|
|
3447
|
-
content:
|
|
3493
|
+
content: mr(r),
|
|
3448
3494
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3449
|
-
...
|
|
3450
|
-
respondsToUserMessageId:
|
|
3495
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3496
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3451
3497
|
...C(r) ? { runId: C(r) } : {},
|
|
3452
3498
|
dataType: String(r.type),
|
|
3453
3499
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -3456,11 +3502,11 @@ function Yt(t, e) {
|
|
|
3456
3502
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
3457
3503
|
} : null;
|
|
3458
3504
|
}
|
|
3459
|
-
function
|
|
3505
|
+
function hr(t) {
|
|
3460
3506
|
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(" ");
|
|
3461
3507
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
3462
3508
|
}
|
|
3463
|
-
function
|
|
3509
|
+
function gr(t) {
|
|
3464
3510
|
if (typeof t != "string")
|
|
3465
3511
|
return null;
|
|
3466
3512
|
try {
|
|
@@ -3477,7 +3523,7 @@ function lr(t) {
|
|
|
3477
3523
|
return null;
|
|
3478
3524
|
}
|
|
3479
3525
|
}
|
|
3480
|
-
function
|
|
3526
|
+
function fr(t) {
|
|
3481
3527
|
if (typeof t != "string")
|
|
3482
3528
|
return null;
|
|
3483
3529
|
try {
|
|
@@ -3492,10 +3538,10 @@ function cr(t) {
|
|
|
3492
3538
|
return null;
|
|
3493
3539
|
}
|
|
3494
3540
|
}
|
|
3495
|
-
function
|
|
3541
|
+
function mr(t) {
|
|
3496
3542
|
return t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message : "";
|
|
3497
3543
|
}
|
|
3498
|
-
function
|
|
3544
|
+
function yr(t) {
|
|
3499
3545
|
if (t.type === "web_search_call") {
|
|
3500
3546
|
const e = t.action;
|
|
3501
3547
|
if (e && typeof e == "object") {
|
|
@@ -3507,9 +3553,9 @@ function dr(t) {
|
|
|
3507
3553
|
}
|
|
3508
3554
|
return "🔎 Searching the web";
|
|
3509
3555
|
}
|
|
3510
|
-
return
|
|
3556
|
+
return Ir(t);
|
|
3511
3557
|
}
|
|
3512
|
-
function
|
|
3558
|
+
function Ir(t) {
|
|
3513
3559
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3514
3560
|
return ee(t.summary);
|
|
3515
3561
|
if (typeof t.arguments == "string")
|
|
@@ -3526,7 +3572,7 @@ function ee(t) {
|
|
|
3526
3572
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3527
3573
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3528
3574
|
}
|
|
3529
|
-
function
|
|
3575
|
+
function Sr(t) {
|
|
3530
3576
|
if (t == null)
|
|
3531
3577
|
return t;
|
|
3532
3578
|
if (typeof t != "object")
|
|
@@ -3545,10 +3591,10 @@ function ce(t) {
|
|
|
3545
3591
|
const e = t.callId ?? t.call_id;
|
|
3546
3592
|
return typeof e == "string" && e ? e : null;
|
|
3547
3593
|
}
|
|
3548
|
-
function
|
|
3594
|
+
function D(t) {
|
|
3549
3595
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
3550
3596
|
}
|
|
3551
|
-
function
|
|
3597
|
+
function Tr(t) {
|
|
3552
3598
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
3553
3599
|
if (!e || typeof e != "object")
|
|
3554
3600
|
return "";
|
|
@@ -3557,10 +3603,10 @@ function gr(t) {
|
|
|
3557
3603
|
}).filter(Boolean).join("") : "";
|
|
3558
3604
|
}
|
|
3559
3605
|
function Qe(t, e) {
|
|
3560
|
-
const s =
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3606
|
+
const s = is(t, e), n = Cr(
|
|
3607
|
+
Mr(
|
|
3608
|
+
vr(
|
|
3609
|
+
wr(t, e),
|
|
3564
3610
|
e
|
|
3565
3611
|
),
|
|
3566
3612
|
s
|
|
@@ -3574,7 +3620,7 @@ function Qe(t, e) {
|
|
|
3574
3620
|
const i = [...n];
|
|
3575
3621
|
return i[r] = s, et(i);
|
|
3576
3622
|
}
|
|
3577
|
-
function
|
|
3623
|
+
function wr(t, e) {
|
|
3578
3624
|
const s = e.proactiveSuggestionClientMessageId;
|
|
3579
3625
|
if (!s)
|
|
3580
3626
|
return t;
|
|
@@ -3584,7 +3630,7 @@ function fr(t, e) {
|
|
|
3584
3630
|
const i = [...t];
|
|
3585
3631
|
return i[r] = e, i;
|
|
3586
3632
|
}
|
|
3587
|
-
function
|
|
3633
|
+
function Mr(t, e) {
|
|
3588
3634
|
const s = e.assistantDraftItemId;
|
|
3589
3635
|
return s ? t.map(
|
|
3590
3636
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
@@ -3593,7 +3639,7 @@ function mr(t, e) {
|
|
|
3593
3639
|
function Ke(t, e, s) {
|
|
3594
3640
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3595
3641
|
}
|
|
3596
|
-
function
|
|
3642
|
+
function Ar(t, e, s, n) {
|
|
3597
3643
|
if (s === null) return t;
|
|
3598
3644
|
let r = -1;
|
|
3599
3645
|
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
@@ -3610,7 +3656,7 @@ function yr(t, e, s, n) {
|
|
|
3610
3656
|
respondsToUserMessageId: s
|
|
3611
3657
|
}, i;
|
|
3612
3658
|
}
|
|
3613
|
-
function
|
|
3659
|
+
function Rr(t, e) {
|
|
3614
3660
|
const s = t.findIndex(
|
|
3615
3661
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3616
3662
|
);
|
|
@@ -3627,12 +3673,12 @@ function Ir(t, e) {
|
|
|
3627
3673
|
...n[s].runId ? {} : { runId: e.runId }
|
|
3628
3674
|
}, n;
|
|
3629
3675
|
}
|
|
3630
|
-
function
|
|
3676
|
+
function Er(t, e, s) {
|
|
3631
3677
|
let n = !1;
|
|
3632
3678
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
3633
3679
|
return n ? r : t;
|
|
3634
3680
|
}
|
|
3635
|
-
function
|
|
3681
|
+
function kr(t) {
|
|
3636
3682
|
if (t.hiddenFromTranscript === !0)
|
|
3637
3683
|
return null;
|
|
3638
3684
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
@@ -3652,7 +3698,7 @@ function Tr(t) {
|
|
|
3652
3698
|
loading: !0
|
|
3653
3699
|
};
|
|
3654
3700
|
}
|
|
3655
|
-
function
|
|
3701
|
+
function Cr(t, e) {
|
|
3656
3702
|
if (e.id.startsWith("transient-activity:"))
|
|
3657
3703
|
return t;
|
|
3658
3704
|
const s = e.toolName === "tab_lifecycle";
|
|
@@ -3661,32 +3707,32 @@ function wr(t, e) {
|
|
|
3661
3707
|
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);
|
|
3662
3708
|
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
3663
3709
|
}
|
|
3664
|
-
function
|
|
3665
|
-
return
|
|
3710
|
+
function ns(t, e) {
|
|
3711
|
+
return Ns(
|
|
3666
3712
|
t,
|
|
3667
3713
|
e.map(
|
|
3668
|
-
(s) =>
|
|
3714
|
+
(s) => is(t, s)
|
|
3669
3715
|
),
|
|
3670
|
-
|
|
3716
|
+
rs
|
|
3671
3717
|
);
|
|
3672
3718
|
}
|
|
3673
|
-
function
|
|
3719
|
+
function br(t, e) {
|
|
3674
3720
|
const s = new Map(t.map((n) => [n.id, n]));
|
|
3675
3721
|
for (const n of e)
|
|
3676
3722
|
s.set(n.id, n);
|
|
3677
|
-
return
|
|
3723
|
+
return ns(
|
|
3678
3724
|
t,
|
|
3679
3725
|
[...s.values()]
|
|
3680
|
-
).sort(
|
|
3726
|
+
).sort(_r);
|
|
3681
3727
|
}
|
|
3682
|
-
function
|
|
3728
|
+
function _r(t, e) {
|
|
3683
3729
|
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)
|
|
3684
3730
|
return t.causalSequence - e.causalSequence;
|
|
3685
3731
|
const n = Date.parse(t.createdAt) - Date.parse(e.createdAt);
|
|
3686
3732
|
return Number.isNaN(n) ? 0 : n;
|
|
3687
3733
|
}
|
|
3688
|
-
function
|
|
3689
|
-
const e =
|
|
3734
|
+
function rs(t) {
|
|
3735
|
+
const e = V(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3690
3736
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3691
3737
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3692
3738
|
];
|
|
@@ -3697,55 +3743,55 @@ function es(t) {
|
|
|
3697
3743
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3698
3744
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3699
3745
|
...t.runId ? { runId: t.runId } : {},
|
|
3700
|
-
isOptimistic:
|
|
3746
|
+
isOptimistic: Ue(t),
|
|
3701
3747
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3702
3748
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3703
3749
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3704
3750
|
};
|
|
3705
3751
|
}
|
|
3706
|
-
function
|
|
3752
|
+
function is(t, e) {
|
|
3707
3753
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3708
3754
|
return e;
|
|
3709
3755
|
const s = t.find(
|
|
3710
|
-
(o) => o.role === "user" && (o.id === e.id ||
|
|
3756
|
+
(o) => o.role === "user" && (o.id === e.id || Ue(o) && os(o, e))
|
|
3711
3757
|
);
|
|
3712
3758
|
if (!s?.attachments?.length)
|
|
3713
3759
|
return e;
|
|
3714
3760
|
const n = e.attachments.map((o) => {
|
|
3715
|
-
const a =
|
|
3716
|
-
return a ?
|
|
3717
|
-
}), r = { ...e, attachments: n }, i =
|
|
3761
|
+
const a = Pr(s.attachments ?? [], o);
|
|
3762
|
+
return a ? Ur(o, a) : o;
|
|
3763
|
+
}), r = { ...e, attachments: n }, i = V(e);
|
|
3718
3764
|
return i && Object.defineProperty(r, "clientMessageId", {
|
|
3719
3765
|
value: i,
|
|
3720
3766
|
enumerable: !1
|
|
3721
3767
|
}), r;
|
|
3722
3768
|
}
|
|
3723
|
-
function
|
|
3769
|
+
function Pr(t, e) {
|
|
3724
3770
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
3725
3771
|
}
|
|
3726
|
-
function
|
|
3772
|
+
function Ur(t, e) {
|
|
3727
3773
|
const { previewUrl: s } = e;
|
|
3728
3774
|
return s ? { ...t, previewUrl: s } : t;
|
|
3729
3775
|
}
|
|
3730
|
-
function
|
|
3776
|
+
function vr(t, e) {
|
|
3731
3777
|
if (e.role !== "user")
|
|
3732
3778
|
return t;
|
|
3733
3779
|
const s = t.findIndex(
|
|
3734
|
-
(r) =>
|
|
3780
|
+
(r) => Ue(r) && os(r, e)
|
|
3735
3781
|
);
|
|
3736
3782
|
if (s === -1)
|
|
3737
3783
|
return t;
|
|
3738
3784
|
const n = [...t];
|
|
3739
3785
|
return n.splice(s, 1), n;
|
|
3740
3786
|
}
|
|
3741
|
-
function
|
|
3742
|
-
const s =
|
|
3787
|
+
function os(t, e) {
|
|
3788
|
+
const s = V(t), n = V(e);
|
|
3743
3789
|
return s && n ? s === n : t.content === e.content;
|
|
3744
3790
|
}
|
|
3745
|
-
function
|
|
3791
|
+
function Ue(t) {
|
|
3746
3792
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3747
3793
|
}
|
|
3748
|
-
function
|
|
3794
|
+
function V(t) {
|
|
3749
3795
|
const e = t.clientMessageId;
|
|
3750
3796
|
if (e)
|
|
3751
3797
|
return e;
|
|
@@ -3754,19 +3800,19 @@ function X(t) {
|
|
|
3754
3800
|
);
|
|
3755
3801
|
return n ? t.id.slice(n.length) : null;
|
|
3756
3802
|
}
|
|
3757
|
-
function
|
|
3758
|
-
const e =
|
|
3803
|
+
function Dt(t) {
|
|
3804
|
+
const e = as(t);
|
|
3759
3805
|
if (e === null)
|
|
3760
3806
|
return !1;
|
|
3761
3807
|
const s = t[e].id;
|
|
3762
3808
|
if (t.some(
|
|
3763
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3809
|
+
(r) => r.respondsToUserMessageId === s && Ee(r)
|
|
3764
3810
|
))
|
|
3765
3811
|
return !0;
|
|
3766
3812
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3767
3813
|
const i = t[r];
|
|
3768
3814
|
if (!i.respondsToUserMessageId) {
|
|
3769
|
-
if (
|
|
3815
|
+
if (H(i))
|
|
3770
3816
|
return !0;
|
|
3771
3817
|
if (i.role === "system") {
|
|
3772
3818
|
if (i.dataType === "run_error")
|
|
@@ -3778,10 +3824,10 @@ function vt(t) {
|
|
|
3778
3824
|
}
|
|
3779
3825
|
return !1;
|
|
3780
3826
|
}
|
|
3781
|
-
function
|
|
3827
|
+
function Dr(t, e, s) {
|
|
3782
3828
|
const n = new Set(
|
|
3783
3829
|
t.filter(
|
|
3784
|
-
(r) => r.role === "user" && e !== null &&
|
|
3830
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3785
3831
|
).map((r) => r.id)
|
|
3786
3832
|
);
|
|
3787
3833
|
return t.some((r, i) => {
|
|
@@ -3792,29 +3838,29 @@ function Cr(t, e, s) {
|
|
|
3792
3838
|
if (s && r.runId === s) {
|
|
3793
3839
|
if (n.size === 0)
|
|
3794
3840
|
return !0;
|
|
3795
|
-
const o =
|
|
3841
|
+
const o = ls(t, i);
|
|
3796
3842
|
return !r.respondsToUserMessageId && o !== null && n.has(o);
|
|
3797
3843
|
}
|
|
3798
3844
|
return !1;
|
|
3799
3845
|
});
|
|
3800
3846
|
}
|
|
3801
|
-
function
|
|
3802
|
-
const e =
|
|
3847
|
+
function Or(t) {
|
|
3848
|
+
const e = as(t);
|
|
3803
3849
|
if (e === null)
|
|
3804
|
-
return t.some(
|
|
3850
|
+
return t.some(H);
|
|
3805
3851
|
const s = t[e].id;
|
|
3806
3852
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3807
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3808
|
-
) : t.slice(e + 1).some(
|
|
3853
|
+
(n) => n.respondsToUserMessageId === s && H(n)
|
|
3854
|
+
) : t.slice(e + 1).some(H);
|
|
3809
3855
|
}
|
|
3810
|
-
function
|
|
3856
|
+
function as(t) {
|
|
3811
3857
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3812
|
-
if (t[e].role === "user" && !
|
|
3858
|
+
if (t[e].role === "user" && !Ue(t[e]))
|
|
3813
3859
|
return e;
|
|
3814
3860
|
return null;
|
|
3815
3861
|
}
|
|
3816
|
-
function
|
|
3817
|
-
return
|
|
3862
|
+
function Ee(t) {
|
|
3863
|
+
return H(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3818
3864
|
}
|
|
3819
3865
|
function se(t) {
|
|
3820
3866
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
@@ -3830,29 +3876,29 @@ function se(t) {
|
|
|
3830
3876
|
}
|
|
3831
3877
|
return null;
|
|
3832
3878
|
}
|
|
3833
|
-
function
|
|
3879
|
+
function qr(t) {
|
|
3834
3880
|
const e = se(t);
|
|
3835
3881
|
if (e === null)
|
|
3836
3882
|
return null;
|
|
3837
|
-
const n =
|
|
3883
|
+
const n = _(t[e])?.page;
|
|
3838
3884
|
if (!n || typeof n != "object")
|
|
3839
3885
|
return null;
|
|
3840
3886
|
const r = n.url;
|
|
3841
3887
|
return typeof r == "string" ? r : null;
|
|
3842
3888
|
}
|
|
3843
|
-
function
|
|
3889
|
+
function _(t) {
|
|
3844
3890
|
if (!t || typeof t != "object")
|
|
3845
3891
|
return null;
|
|
3846
3892
|
const e = t.data;
|
|
3847
3893
|
return e && typeof e == "object" ? e : null;
|
|
3848
3894
|
}
|
|
3849
|
-
function
|
|
3895
|
+
function ke(t) {
|
|
3850
3896
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3851
3897
|
}
|
|
3852
|
-
function
|
|
3898
|
+
function Ot(t) {
|
|
3853
3899
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3854
3900
|
}
|
|
3855
|
-
function
|
|
3901
|
+
function Lr(t, e) {
|
|
3856
3902
|
const s = se(e);
|
|
3857
3903
|
if (s === null)
|
|
3858
3904
|
return !1;
|
|
@@ -3861,8 +3907,8 @@ function Pr(t, e) {
|
|
|
3861
3907
|
return !1;
|
|
3862
3908
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3863
3909
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3864
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3865
|
-
) : t.slice(i + 1).some(
|
|
3910
|
+
(o) => o.respondsToUserMessageId === r && Ee(o)
|
|
3911
|
+
) : t.slice(i + 1).some(Ee);
|
|
3866
3912
|
}
|
|
3867
3913
|
function Ye(t) {
|
|
3868
3914
|
const e = se(t);
|
|
@@ -3877,7 +3923,7 @@ function Ye(t) {
|
|
|
3877
3923
|
const r = n.clientMessageId;
|
|
3878
3924
|
return typeof r == "string" ? r : null;
|
|
3879
3925
|
}
|
|
3880
|
-
function
|
|
3926
|
+
function Nr(t) {
|
|
3881
3927
|
const e = se(t);
|
|
3882
3928
|
if (e === null)
|
|
3883
3929
|
return null;
|
|
@@ -3901,13 +3947,13 @@ function Ur(t) {
|
|
|
3901
3947
|
function Ze(t, e) {
|
|
3902
3948
|
if (typeof e.clientMessageId == "string")
|
|
3903
3949
|
return e.clientMessageId;
|
|
3904
|
-
const s =
|
|
3950
|
+
const s = q(e);
|
|
3905
3951
|
if (!s)
|
|
3906
3952
|
return null;
|
|
3907
|
-
const n = t.find((i) =>
|
|
3953
|
+
const n = t.find((i) => M(i, "id") === s), r = _(n);
|
|
3908
3954
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3909
3955
|
}
|
|
3910
|
-
function
|
|
3956
|
+
function xr(t, e) {
|
|
3911
3957
|
let s = 0;
|
|
3912
3958
|
for (const n of t) {
|
|
3913
3959
|
if (!n || typeof n != "object")
|
|
@@ -3920,91 +3966,91 @@ function vr(t, e) {
|
|
|
3920
3966
|
}
|
|
3921
3967
|
return s;
|
|
3922
3968
|
}
|
|
3923
|
-
function
|
|
3924
|
-
if (!e || !
|
|
3969
|
+
function qt(t, e, s, n, r, i) {
|
|
3970
|
+
if (!e || !Wr(t))
|
|
3925
3971
|
return !1;
|
|
3926
3972
|
const o = t;
|
|
3927
|
-
if (
|
|
3973
|
+
if (ke(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3928
3974
|
return !1;
|
|
3929
|
-
const a =
|
|
3975
|
+
const a = q(o);
|
|
3930
3976
|
return n !== null ? a !== null ? a === n : r !== null && C(o) === r && i === n : r === null || C(o) === r;
|
|
3931
3977
|
}
|
|
3932
|
-
function
|
|
3978
|
+
function Br(t, e) {
|
|
3933
3979
|
for (let s = e - 1; s >= 0; s -= 1) {
|
|
3934
|
-
const n =
|
|
3980
|
+
const n = _(t[s]);
|
|
3935
3981
|
if (n?.type === "message" && n.role === "user")
|
|
3936
|
-
return
|
|
3982
|
+
return M(t[s], "id");
|
|
3937
3983
|
}
|
|
3938
3984
|
return null;
|
|
3939
3985
|
}
|
|
3940
|
-
function
|
|
3986
|
+
function ls(t, e) {
|
|
3941
3987
|
for (let s = e - 1; s >= 0; s -= 1)
|
|
3942
3988
|
if (t[s].role === "user")
|
|
3943
3989
|
return t[s].id;
|
|
3944
3990
|
return null;
|
|
3945
3991
|
}
|
|
3946
|
-
function
|
|
3992
|
+
function Wr(t) {
|
|
3947
3993
|
if (!t || typeof t != "object")
|
|
3948
3994
|
return !1;
|
|
3949
3995
|
const e = t;
|
|
3950
3996
|
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");
|
|
3951
3997
|
}
|
|
3952
|
-
function
|
|
3998
|
+
function H(t) {
|
|
3953
3999
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3954
4000
|
}
|
|
3955
|
-
function
|
|
4001
|
+
function Hr(t) {
|
|
3956
4002
|
if (!t || typeof t != "object")
|
|
3957
4003
|
return !1;
|
|
3958
4004
|
const e = t;
|
|
3959
4005
|
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";
|
|
3960
4006
|
}
|
|
3961
4007
|
function et(t) {
|
|
3962
|
-
return t.filter((e, s) =>
|
|
4008
|
+
return t.filter((e, s) => X(e) ? !Yr(t, s) && !cs(t, s) && !Jr(t, s) && !Qr(t, s) : $r(e) ? e.retryable === !0 && Xr(t, s) ? !1 : !Vr(t, s) : !0);
|
|
3963
4009
|
}
|
|
3964
|
-
function
|
|
4010
|
+
function $r(t) {
|
|
3965
4011
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3966
4012
|
}
|
|
3967
|
-
function
|
|
4013
|
+
function X(t) {
|
|
3968
4014
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3969
4015
|
}
|
|
3970
|
-
function
|
|
4016
|
+
function Fr(t, e, s, n) {
|
|
3971
4017
|
const r = t.findIndex(
|
|
3972
|
-
(l, c) =>
|
|
4018
|
+
(l, c) => X(l) && !cs(t, c)
|
|
3973
4019
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3974
4020
|
(l) => l.role === "user" && l.id === o
|
|
3975
4021
|
) : null;
|
|
3976
4022
|
return {
|
|
3977
|
-
clientMessageId: a ?
|
|
4023
|
+
clientMessageId: a ? V(a) : o ? null : n,
|
|
3978
4024
|
respondsToUserMessageId: o,
|
|
3979
4025
|
runId: s ?? i?.runId ?? null
|
|
3980
4026
|
};
|
|
3981
4027
|
}
|
|
3982
|
-
function
|
|
4028
|
+
function Ae(t) {
|
|
3983
4029
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3984
4030
|
}
|
|
3985
|
-
function
|
|
3986
|
-
return
|
|
4031
|
+
function jr(t, e) {
|
|
4032
|
+
return H(e) ? "completed" : Ae(t) ? "stopped" : !ke(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
|
|
3987
4033
|
}
|
|
3988
|
-
function
|
|
4034
|
+
function Lt(t, e, s) {
|
|
3989
4035
|
const n = new Set(
|
|
3990
4036
|
t.filter(
|
|
3991
|
-
(r) => r.role === "user" && e !== null &&
|
|
4037
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3992
4038
|
).map((r) => r.id)
|
|
3993
4039
|
);
|
|
3994
4040
|
return t.filter(
|
|
3995
|
-
(r) => !
|
|
4041
|
+
(r) => !X(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3996
4042
|
);
|
|
3997
4043
|
}
|
|
3998
|
-
function
|
|
4044
|
+
function cs(t, e) {
|
|
3999
4045
|
return t.some(
|
|
4000
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
4046
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && zr(
|
|
4001
4047
|
t,
|
|
4002
4048
|
e,
|
|
4003
4049
|
n
|
|
4004
4050
|
)
|
|
4005
4051
|
);
|
|
4006
4052
|
}
|
|
4007
|
-
function
|
|
4053
|
+
function zr(t, e, s) {
|
|
4008
4054
|
const n = t[e], r = t[s];
|
|
4009
4055
|
if (de(n, r))
|
|
4010
4056
|
return !0;
|
|
@@ -4015,26 +4061,26 @@ function Br(t, e, s) {
|
|
|
4015
4061
|
return t[i].id === n.respondsToUserMessageId;
|
|
4016
4062
|
return !1;
|
|
4017
4063
|
}
|
|
4018
|
-
function
|
|
4064
|
+
function Kr(t, e) {
|
|
4019
4065
|
const s = [...t].reverse().find(
|
|
4020
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
4066
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Nt(n) && !Gr(
|
|
4021
4067
|
t,
|
|
4022
4068
|
n.respondsToUserMessageId
|
|
4023
4069
|
)
|
|
4024
4070
|
)?.respondsToUserMessageId;
|
|
4025
4071
|
return s ? t.map(
|
|
4026
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
4072
|
+
(n) => n.respondsToUserMessageId === s && Nt(n) ? { ...n, steered: !0 } : n
|
|
4027
4073
|
) : t;
|
|
4028
4074
|
}
|
|
4029
|
-
function
|
|
4030
|
-
return t.role === "tool" ||
|
|
4075
|
+
function Nt(t) {
|
|
4076
|
+
return t.role === "tool" || X(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
4031
4077
|
}
|
|
4032
|
-
function
|
|
4078
|
+
function Gr(t, e) {
|
|
4033
4079
|
return t.some(
|
|
4034
|
-
(s) => s.respondsToUserMessageId === e && (
|
|
4080
|
+
(s) => s.respondsToUserMessageId === e && (H(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
4035
4081
|
);
|
|
4036
4082
|
}
|
|
4037
|
-
function
|
|
4083
|
+
function Vr(t, e) {
|
|
4038
4084
|
const s = t[e];
|
|
4039
4085
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
4040
4086
|
const r = t[n];
|
|
@@ -4043,7 +4089,7 @@ function $r(t, e) {
|
|
|
4043
4089
|
}
|
|
4044
4090
|
return !1;
|
|
4045
4091
|
}
|
|
4046
|
-
function
|
|
4092
|
+
function Xr(t, e) {
|
|
4047
4093
|
const s = t[e];
|
|
4048
4094
|
if (!s.respondsToUserMessageId)
|
|
4049
4095
|
return !1;
|
|
@@ -4051,45 +4097,45 @@ function Fr(t, e) {
|
|
|
4051
4097
|
const r = t[n];
|
|
4052
4098
|
if (r.role === "user")
|
|
4053
4099
|
return !1;
|
|
4054
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
4100
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || X(r)))
|
|
4055
4101
|
return !0;
|
|
4056
4102
|
}
|
|
4057
4103
|
return !1;
|
|
4058
4104
|
}
|
|
4059
|
-
function
|
|
4105
|
+
function Jr(t, e) {
|
|
4060
4106
|
const s = t[e];
|
|
4061
4107
|
return t.some(
|
|
4062
4108
|
(n, r) => r !== e && n.role === "assistant" && de(s, n)
|
|
4063
4109
|
);
|
|
4064
4110
|
}
|
|
4065
|
-
function
|
|
4111
|
+
function Qr(t, e) {
|
|
4066
4112
|
const s = t[e];
|
|
4067
4113
|
return t.some(
|
|
4068
4114
|
(n, r) => r !== e && n.role === "tool" && de(s, n)
|
|
4069
4115
|
);
|
|
4070
4116
|
}
|
|
4071
|
-
function
|
|
4117
|
+
function Yr(t, e) {
|
|
4072
4118
|
const s = t[e];
|
|
4073
4119
|
for (let n = e + 1; n < t.length; n += 1)
|
|
4074
|
-
if (
|
|
4120
|
+
if (X(t[n]) && de(s, t[n]))
|
|
4075
4121
|
return !0;
|
|
4076
4122
|
return !1;
|
|
4077
4123
|
}
|
|
4078
4124
|
function de(t, e) {
|
|
4079
4125
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
4080
4126
|
}
|
|
4081
|
-
function
|
|
4127
|
+
function M(t, e) {
|
|
4082
4128
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
4083
4129
|
}
|
|
4084
|
-
function
|
|
4130
|
+
function Zr(t, e) {
|
|
4085
4131
|
try {
|
|
4086
|
-
const s = window.localStorage.getItem(`${
|
|
4132
|
+
const s = window.localStorage.getItem(`${Jt}${t}`);
|
|
4087
4133
|
if (!s)
|
|
4088
4134
|
return null;
|
|
4089
4135
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
4090
4136
|
if (e !== void 0 && r !== e)
|
|
4091
4137
|
return null;
|
|
4092
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
4138
|
+
const i = Array.isArray(n.messages) ? n.messages.map(ui).filter((o) => !!o) : [];
|
|
4093
4139
|
return {
|
|
4094
4140
|
sessionId: r,
|
|
4095
4141
|
messages: i
|
|
@@ -4098,23 +4144,23 @@ function Gr(t, e) {
|
|
|
4098
4144
|
return null;
|
|
4099
4145
|
}
|
|
4100
4146
|
}
|
|
4101
|
-
function
|
|
4147
|
+
function us(t) {
|
|
4102
4148
|
return t.role === "user" || t.role === "assistant" || t.dataType === "run_status" || t.dataType === "run_error";
|
|
4103
4149
|
}
|
|
4104
|
-
function
|
|
4150
|
+
function ei(t, e) {
|
|
4105
4151
|
try {
|
|
4106
4152
|
window.localStorage.setItem(
|
|
4107
|
-
`${
|
|
4153
|
+
`${Jt}${t}`,
|
|
4108
4154
|
JSON.stringify({
|
|
4109
4155
|
sessionId: e.sessionId,
|
|
4110
|
-
messages: e.messages.filter(
|
|
4156
|
+
messages: e.messages.filter(us).slice(-An).map(di)
|
|
4111
4157
|
})
|
|
4112
4158
|
);
|
|
4113
4159
|
} catch {
|
|
4114
4160
|
return;
|
|
4115
4161
|
}
|
|
4116
4162
|
}
|
|
4117
|
-
function
|
|
4163
|
+
function ti(t) {
|
|
4118
4164
|
try {
|
|
4119
4165
|
const e = window.localStorage.getItem(`${Je}${t}`);
|
|
4120
4166
|
if (!e)
|
|
@@ -4125,7 +4171,7 @@ function Xr(t) {
|
|
|
4125
4171
|
return [];
|
|
4126
4172
|
}
|
|
4127
4173
|
}
|
|
4128
|
-
function
|
|
4174
|
+
function G(t, e) {
|
|
4129
4175
|
try {
|
|
4130
4176
|
const s = e.filter(lt);
|
|
4131
4177
|
if (s.length === 0) {
|
|
@@ -4140,9 +4186,9 @@ function V(t, e) {
|
|
|
4140
4186
|
return;
|
|
4141
4187
|
}
|
|
4142
4188
|
}
|
|
4143
|
-
function
|
|
4189
|
+
function ds(t, e) {
|
|
4144
4190
|
try {
|
|
4145
|
-
const s = `${
|
|
4191
|
+
const s = `${Pe}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
4146
4192
|
...o,
|
|
4147
4193
|
storedAt: Date.now(),
|
|
4148
4194
|
unloadUrl: n,
|
|
@@ -4156,28 +4202,28 @@ function as(t, e) {
|
|
|
4156
4202
|
} catch {
|
|
4157
4203
|
}
|
|
4158
4204
|
}
|
|
4159
|
-
function
|
|
4205
|
+
function xt(t, e) {
|
|
4160
4206
|
try {
|
|
4161
|
-
if (window.sessionStorage.getItem(`${
|
|
4207
|
+
if (window.sessionStorage.getItem(`${Pe}${t}`) === null)
|
|
4162
4208
|
return;
|
|
4163
4209
|
} catch {
|
|
4164
4210
|
return;
|
|
4165
4211
|
}
|
|
4166
|
-
|
|
4212
|
+
ds(t, e);
|
|
4167
4213
|
}
|
|
4168
|
-
function
|
|
4214
|
+
function si(t) {
|
|
4169
4215
|
try {
|
|
4170
|
-
const e = `${
|
|
4216
|
+
const e = `${Pe}${t}`, s = window.sessionStorage.getItem(e);
|
|
4171
4217
|
if (window.sessionStorage.removeItem(e), !s)
|
|
4172
4218
|
return [];
|
|
4173
4219
|
const n = JSON.parse(s);
|
|
4174
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
4220
|
+
return Array.isArray(n) ? n.flatMap((r) => ri(r) ? [{
|
|
4175
4221
|
...r.event,
|
|
4176
4222
|
page: b(),
|
|
4177
4223
|
rawOutput: {
|
|
4178
4224
|
pageContextRestarted: !0,
|
|
4179
4225
|
outcome: "unknown",
|
|
4180
|
-
message:
|
|
4226
|
+
message: ni(location.href),
|
|
4181
4227
|
currentUrl: location.href,
|
|
4182
4228
|
console: [],
|
|
4183
4229
|
metadata: {
|
|
@@ -4194,17 +4240,17 @@ function Jr(t) {
|
|
|
4194
4240
|
return [];
|
|
4195
4241
|
}
|
|
4196
4242
|
}
|
|
4197
|
-
function
|
|
4243
|
+
function ni(t) {
|
|
4198
4244
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
4199
4245
|
Current URL: ${t}`;
|
|
4200
4246
|
}
|
|
4201
|
-
function
|
|
4247
|
+
function ri(t) {
|
|
4202
4248
|
if (!t || typeof t != "object")
|
|
4203
4249
|
return !1;
|
|
4204
4250
|
const e = t, s = e.event;
|
|
4205
4251
|
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && lt(s) && s.type === "tool.result";
|
|
4206
4252
|
}
|
|
4207
|
-
function
|
|
4253
|
+
function ii(t, e) {
|
|
4208
4254
|
const s = new Set(
|
|
4209
4255
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
4210
4256
|
);
|
|
@@ -4213,9 +4259,9 @@ function Zr(t, e) {
|
|
|
4213
4259
|
...e.filter((n) => !s.has(n.callId))
|
|
4214
4260
|
];
|
|
4215
4261
|
}
|
|
4216
|
-
function
|
|
4262
|
+
function oi(t) {
|
|
4217
4263
|
try {
|
|
4218
|
-
window.sessionStorage.removeItem(`${
|
|
4264
|
+
window.sessionStorage.removeItem(`${Pe}${t}`);
|
|
4219
4265
|
} catch {
|
|
4220
4266
|
return;
|
|
4221
4267
|
}
|
|
@@ -4224,15 +4270,15 @@ function lt(t) {
|
|
|
4224
4270
|
if (!t || typeof t != "object")
|
|
4225
4271
|
return !1;
|
|
4226
4272
|
const e = t;
|
|
4227
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
4273
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && Bt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Bt(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;
|
|
4228
4274
|
}
|
|
4229
|
-
function
|
|
4275
|
+
function Bt(t) {
|
|
4230
4276
|
if (!t || typeof t != "object")
|
|
4231
4277
|
return !1;
|
|
4232
4278
|
const e = t;
|
|
4233
4279
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
4234
4280
|
}
|
|
4235
|
-
function
|
|
4281
|
+
function ps(t, e) {
|
|
4236
4282
|
if (!Array.isArray(t))
|
|
4237
4283
|
return;
|
|
4238
4284
|
const s = t.filter((r) => {
|
|
@@ -4240,41 +4286,41 @@ function ls(t, e) {
|
|
|
4240
4286
|
return !1;
|
|
4241
4287
|
const i = r;
|
|
4242
4288
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
4243
|
-
}), n = e ? s.map((r) =>
|
|
4289
|
+
}), n = e ? s.map((r) => hs(r, e)) : s;
|
|
4244
4290
|
return n.length > 0 ? n : void 0;
|
|
4245
4291
|
}
|
|
4246
|
-
function
|
|
4292
|
+
function hs(t, e) {
|
|
4247
4293
|
return t.fileUrl?.startsWith("/") ? {
|
|
4248
4294
|
...t,
|
|
4249
4295
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
4250
4296
|
} : t;
|
|
4251
4297
|
}
|
|
4252
4298
|
function tt(t) {
|
|
4253
|
-
return t.type ||
|
|
4299
|
+
return t.type || ci(t.name) || "application/octet-stream";
|
|
4254
4300
|
}
|
|
4255
|
-
function
|
|
4256
|
-
|
|
4301
|
+
function ai(t) {
|
|
4302
|
+
gs({
|
|
4257
4303
|
name: t.name,
|
|
4258
4304
|
mimeType: tt(t),
|
|
4259
4305
|
sizeBytes: t.size
|
|
4260
4306
|
});
|
|
4261
4307
|
}
|
|
4262
|
-
function
|
|
4263
|
-
const e =
|
|
4264
|
-
if (!
|
|
4308
|
+
function gs(t) {
|
|
4309
|
+
const e = li(t.name), s = t.mimeType.trim().toLowerCase();
|
|
4310
|
+
if (!Tn.has(`${e}:${s}`))
|
|
4265
4311
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
4266
|
-
if (t.sizeBytes <= 0 || t.sizeBytes >=
|
|
4312
|
+
if (t.sizeBytes <= 0 || t.sizeBytes >= Vt)
|
|
4267
4313
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
4268
4314
|
}
|
|
4269
|
-
function
|
|
4315
|
+
function li(t) {
|
|
4270
4316
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
4271
4317
|
return s >= 0 ? e.slice(s) : "";
|
|
4272
4318
|
}
|
|
4273
|
-
function
|
|
4319
|
+
function ci(t) {
|
|
4274
4320
|
const e = t.toLowerCase();
|
|
4275
4321
|
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;
|
|
4276
4322
|
}
|
|
4277
|
-
function
|
|
4323
|
+
function ui(t) {
|
|
4278
4324
|
if (!t || typeof t != "object")
|
|
4279
4325
|
return null;
|
|
4280
4326
|
const e = t;
|
|
@@ -4292,17 +4338,17 @@ function ri(t) {
|
|
|
4292
4338
|
scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
|
|
4293
4339
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
4294
4340
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
4295
|
-
attachments:
|
|
4341
|
+
attachments: ps(e.attachments)?.map(Ce),
|
|
4296
4342
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
4297
4343
|
};
|
|
4298
4344
|
}
|
|
4299
|
-
function
|
|
4345
|
+
function di(t) {
|
|
4300
4346
|
return t.attachments?.length ? {
|
|
4301
4347
|
...t,
|
|
4302
|
-
attachments: t.attachments.map(
|
|
4348
|
+
attachments: t.attachments.map(Ce)
|
|
4303
4349
|
} : t;
|
|
4304
4350
|
}
|
|
4305
|
-
function
|
|
4351
|
+
function Ce(t) {
|
|
4306
4352
|
const {
|
|
4307
4353
|
dataUrl: e,
|
|
4308
4354
|
objectUrl: s,
|
|
@@ -4312,7 +4358,7 @@ function ke(t) {
|
|
|
4312
4358
|
} = t;
|
|
4313
4359
|
return i;
|
|
4314
4360
|
}
|
|
4315
|
-
function
|
|
4361
|
+
function q(t) {
|
|
4316
4362
|
const e = t.respondsToUserMessageId;
|
|
4317
4363
|
return typeof e == "string" && e ? e : null;
|
|
4318
4364
|
}
|
|
@@ -4320,11 +4366,11 @@ function C(t) {
|
|
|
4320
4366
|
const e = t.runId;
|
|
4321
4367
|
return typeof e == "string" && e ? e : null;
|
|
4322
4368
|
}
|
|
4323
|
-
function
|
|
4369
|
+
function pi(t) {
|
|
4324
4370
|
const e = t?.timeoutMs;
|
|
4325
|
-
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 <=
|
|
4371
|
+
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 <= Un);
|
|
4326
4372
|
}
|
|
4327
|
-
function
|
|
4373
|
+
function fs(t) {
|
|
4328
4374
|
const e = {};
|
|
4329
4375
|
try {
|
|
4330
4376
|
new Headers(t).forEach((s, n) => {
|
|
@@ -4336,23 +4382,23 @@ function ds(t) {
|
|
|
4336
4382
|
return e;
|
|
4337
4383
|
}
|
|
4338
4384
|
function ct(t, e) {
|
|
4339
|
-
return
|
|
4385
|
+
return ws(t) ? ve : W(_e(e), wn);
|
|
4340
4386
|
}
|
|
4341
|
-
function
|
|
4387
|
+
function hi(t, e) {
|
|
4342
4388
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
4343
4389
|
}
|
|
4344
|
-
async function
|
|
4345
|
-
const r =
|
|
4390
|
+
async function gi(t, e, s, n) {
|
|
4391
|
+
const r = fs(t.headers);
|
|
4346
4392
|
n({
|
|
4347
4393
|
...e,
|
|
4348
4394
|
responseStatus: t.status,
|
|
4349
4395
|
responseHeaders: r,
|
|
4350
|
-
responseBody: await
|
|
4396
|
+
responseBody: await fi(t),
|
|
4351
4397
|
durationMs: Date.now() - s
|
|
4352
4398
|
});
|
|
4353
4399
|
}
|
|
4354
|
-
async function
|
|
4355
|
-
if (!
|
|
4400
|
+
async function fi(t) {
|
|
4401
|
+
if (!ms(t.headers))
|
|
4356
4402
|
return;
|
|
4357
4403
|
let e = null, s = null;
|
|
4358
4404
|
try {
|
|
@@ -4361,7 +4407,7 @@ async function ci(t) {
|
|
|
4361
4407
|
const n = new Promise((a) => {
|
|
4362
4408
|
s = window.setTimeout(() => {
|
|
4363
4409
|
e?.cancel(), a("timeout");
|
|
4364
|
-
},
|
|
4410
|
+
}, Mn);
|
|
4365
4411
|
}), r = new TextDecoder();
|
|
4366
4412
|
let i = "", o = 0;
|
|
4367
4413
|
for (; ; ) {
|
|
@@ -4370,10 +4416,10 @@ async function ci(t) {
|
|
|
4370
4416
|
return;
|
|
4371
4417
|
const { done: l, value: c } = a;
|
|
4372
4418
|
if (l)
|
|
4373
|
-
return
|
|
4419
|
+
return W(i + r.decode());
|
|
4374
4420
|
const d = it - o;
|
|
4375
4421
|
if (c.byteLength > d)
|
|
4376
|
-
return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${
|
|
4422
|
+
return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${W(i)}... [truncated]`;
|
|
4377
4423
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
4378
4424
|
}
|
|
4379
4425
|
} catch {
|
|
@@ -4383,45 +4429,45 @@ async function ci(t) {
|
|
|
4383
4429
|
s !== null && window.clearTimeout(s);
|
|
4384
4430
|
}
|
|
4385
4431
|
}
|
|
4386
|
-
function
|
|
4387
|
-
if (
|
|
4432
|
+
function mi(t, e) {
|
|
4433
|
+
if (ms(new Headers(e)))
|
|
4388
4434
|
try {
|
|
4389
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
4435
|
+
return t.responseType === "" || t.responseType === "text" ? W(t.responseText ?? "") : void 0;
|
|
4390
4436
|
} catch {
|
|
4391
4437
|
return;
|
|
4392
4438
|
}
|
|
4393
4439
|
}
|
|
4394
|
-
function
|
|
4440
|
+
function Wt(t) {
|
|
4395
4441
|
if (typeof t == "string")
|
|
4396
|
-
return
|
|
4442
|
+
return W(t);
|
|
4397
4443
|
}
|
|
4398
|
-
function
|
|
4399
|
-
return
|
|
4444
|
+
function yi(t) {
|
|
4445
|
+
return O({
|
|
4400
4446
|
...t,
|
|
4401
|
-
requestBody:
|
|
4402
|
-
responseBody:
|
|
4447
|
+
requestBody: Ht(t.requestBody),
|
|
4448
|
+
responseBody: Ht(t.responseBody)
|
|
4403
4449
|
});
|
|
4404
4450
|
}
|
|
4405
|
-
function
|
|
4451
|
+
function Ht(t) {
|
|
4406
4452
|
if (typeof t != "string")
|
|
4407
4453
|
return t;
|
|
4408
4454
|
const e = t.trim();
|
|
4409
4455
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4410
|
-
return
|
|
4456
|
+
return _e(t);
|
|
4411
4457
|
try {
|
|
4412
|
-
return JSON.stringify(
|
|
4458
|
+
return JSON.stringify(O(JSON.parse(t)));
|
|
4413
4459
|
} catch {
|
|
4414
|
-
return
|
|
4460
|
+
return _e(t);
|
|
4415
4461
|
}
|
|
4416
4462
|
}
|
|
4417
|
-
function
|
|
4463
|
+
function ms(t) {
|
|
4418
4464
|
if (!t)
|
|
4419
4465
|
return !1;
|
|
4420
4466
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4421
4467
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= it && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4422
4468
|
}
|
|
4423
4469
|
function Z(t, e = {}, s) {
|
|
4424
|
-
if (
|
|
4470
|
+
if (Si(s))
|
|
4425
4471
|
return !0;
|
|
4426
4472
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
4427
4473
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -4436,7 +4482,7 @@ function Z(t, e = {}, s) {
|
|
|
4436
4482
|
return !0;
|
|
4437
4483
|
}
|
|
4438
4484
|
}
|
|
4439
|
-
function
|
|
4485
|
+
function Ii(t, e) {
|
|
4440
4486
|
if (Z(t))
|
|
4441
4487
|
return !0;
|
|
4442
4488
|
try {
|
|
@@ -4446,10 +4492,10 @@ function hi(t, e) {
|
|
|
4446
4492
|
return !0;
|
|
4447
4493
|
}
|
|
4448
4494
|
}
|
|
4449
|
-
function
|
|
4495
|
+
function Si(t) {
|
|
4450
4496
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4451
4497
|
}
|
|
4452
|
-
function
|
|
4498
|
+
function Ti(t) {
|
|
4453
4499
|
const e = {};
|
|
4454
4500
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4455
4501
|
const n = s.indexOf(":");
|
|
@@ -4462,101 +4508,101 @@ function gi(t) {
|
|
|
4462
4508
|
}
|
|
4463
4509
|
return e;
|
|
4464
4510
|
}
|
|
4465
|
-
function
|
|
4511
|
+
function W(t, e = it) {
|
|
4466
4512
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4467
4513
|
}
|
|
4468
4514
|
function Ge(t) {
|
|
4469
4515
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4470
4516
|
}
|
|
4471
|
-
class
|
|
4517
|
+
class Re extends Error {
|
|
4472
4518
|
constructor(e, s) {
|
|
4473
4519
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4474
4520
|
}
|
|
4475
4521
|
status;
|
|
4476
4522
|
}
|
|
4477
|
-
async function
|
|
4523
|
+
async function Te(t, e) {
|
|
4478
4524
|
let s = null;
|
|
4479
|
-
for (let n = 0; n <
|
|
4525
|
+
for (let n = 0; n < kt; n += 1)
|
|
4480
4526
|
try {
|
|
4481
4527
|
return await t();
|
|
4482
4528
|
} catch (r) {
|
|
4483
|
-
if (s = r, n >=
|
|
4529
|
+
if (s = r, n >= kt - 1 || !Mi(r))
|
|
4484
4530
|
throw r;
|
|
4485
|
-
await
|
|
4531
|
+
await wi(n);
|
|
4486
4532
|
}
|
|
4487
4533
|
throw s instanceof Error ? s : new Error(e);
|
|
4488
4534
|
}
|
|
4489
|
-
function
|
|
4535
|
+
function wi(t) {
|
|
4490
4536
|
return new Promise((e) => {
|
|
4491
|
-
window.setTimeout(e,
|
|
4537
|
+
window.setTimeout(e, Sn[t] ?? 0);
|
|
4492
4538
|
});
|
|
4493
4539
|
}
|
|
4494
|
-
function
|
|
4495
|
-
return t instanceof
|
|
4540
|
+
function Mi(t) {
|
|
4541
|
+
return t instanceof Re ? Ai(t.status) : t instanceof TypeError;
|
|
4496
4542
|
}
|
|
4497
|
-
function
|
|
4543
|
+
function Ai(t) {
|
|
4498
4544
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
4499
4545
|
}
|
|
4500
|
-
function
|
|
4546
|
+
function Ri(t) {
|
|
4501
4547
|
return t === 401 || t === 403;
|
|
4502
4548
|
}
|
|
4503
|
-
const
|
|
4504
|
-
function
|
|
4505
|
-
return
|
|
4549
|
+
const ve = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", Ei = "[REDACTED_SIGNED_URL]", ki = 20, Ci = /^(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, ys = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Is = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ss = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ts = /\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, bi = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, _i = /\bhttps?:\/\/[^\s"'<>]+/gi, Pi = /[),.;\]]+$/;
|
|
4550
|
+
function O(t) {
|
|
4551
|
+
return be(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4506
4552
|
}
|
|
4507
|
-
function
|
|
4553
|
+
function be(t, e, s) {
|
|
4508
4554
|
if (typeof t == "string")
|
|
4509
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4555
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : _e(t);
|
|
4510
4556
|
if (t === null || typeof t != "object")
|
|
4511
4557
|
return t;
|
|
4512
|
-
if (e >=
|
|
4558
|
+
if (e >= ki)
|
|
4513
4559
|
return "[REDACTED_MAX_DEPTH]";
|
|
4514
4560
|
if (s.has(t))
|
|
4515
4561
|
return "[REDACTED_CIRCULAR]";
|
|
4516
4562
|
if (s.add(t), Array.isArray(t))
|
|
4517
|
-
return t.map((r) =>
|
|
4563
|
+
return t.map((r) => be(r, e + 1, s));
|
|
4518
4564
|
const n = {};
|
|
4519
4565
|
for (const [r, i] of Object.entries(t))
|
|
4520
|
-
r === "pageContent" ? n[r] = i :
|
|
4566
|
+
r === "pageContent" ? n[r] = i : ws(r) ? n[r] = ve : n[r] = r.toLowerCase() === "url" ? Ui(i) : be(i, e + 1, s);
|
|
4521
4567
|
return n;
|
|
4522
4568
|
}
|
|
4523
|
-
function
|
|
4569
|
+
function ws(t) {
|
|
4524
4570
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
4525
4571
|
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");
|
|
4526
4572
|
}
|
|
4527
|
-
function
|
|
4528
|
-
return typeof t == "string" ?
|
|
4573
|
+
function Ui(t) {
|
|
4574
|
+
return typeof t == "string" ? Ms(t) : be(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4529
4575
|
}
|
|
4530
|
-
function
|
|
4576
|
+
function Ms(t) {
|
|
4531
4577
|
try {
|
|
4532
4578
|
const e = new URL(t, location.href);
|
|
4533
4579
|
for (const s of Array.from(e.searchParams.keys()))
|
|
4534
|
-
|
|
4535
|
-
return e.username && (e.username =
|
|
4580
|
+
Ci.test(s) && e.searchParams.set(s, $);
|
|
4581
|
+
return e.username && (e.username = $), e.password && (e.password = $), e.toString();
|
|
4536
4582
|
} catch {
|
|
4537
|
-
return
|
|
4583
|
+
return vi(t);
|
|
4538
4584
|
}
|
|
4539
4585
|
}
|
|
4540
|
-
function
|
|
4541
|
-
return t.replace(
|
|
4586
|
+
function _e(t) {
|
|
4587
|
+
return t.replace(bi, Ei).replace(_i, Di).replace(ys, `Bearer ${$}`).replace(Is, `Basic ${$}`).replace(Ss, $).replace(Ts, (e, s) => `${s}: ${ve}`);
|
|
4542
4588
|
}
|
|
4543
|
-
function
|
|
4544
|
-
return t.replace(
|
|
4589
|
+
function vi(t) {
|
|
4590
|
+
return t.replace(ys, `Bearer ${$}`).replace(Is, `Basic ${$}`).replace(Ss, $).replace(Ts, (e, s) => `${s}: ${ve}`);
|
|
4545
4591
|
}
|
|
4546
|
-
function
|
|
4547
|
-
const e = t.match(
|
|
4548
|
-
return `${
|
|
4592
|
+
function Di(t) {
|
|
4593
|
+
const e = t.match(Pi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4594
|
+
return `${Ms(s)}${e}`;
|
|
4549
4595
|
}
|
|
4550
4596
|
export {
|
|
4551
|
-
|
|
4597
|
+
mt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4552
4598
|
Xe as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4599
|
+
sn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4600
|
+
tn as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4601
|
+
nn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
4602
|
+
Oi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
4603
|
+
Qt as PlunoProductAgent,
|
|
4604
|
+
En as calculateReconnectDelay,
|
|
4605
|
+
Qt as default,
|
|
4606
|
+
Gn as getProductAgentOriginAccessErrorMessage,
|
|
4607
|
+
ai as validateProductAgentProviderInputFile
|
|
4562
4608
|
};
|