@pluno/product-agent-web 0.1.190 → 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 +859 -809
- package/dist/product-agent-widget.js +2152 -2102
- 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,22 +1496,26 @@ 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 } : {}
|
|
1471
1513
|
};
|
|
1472
|
-
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l),
|
|
1514
|
+
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), this.sendNow({
|
|
1515
|
+
type: "runtime.auth_ack",
|
|
1516
|
+
connectionAttempt: this.connectionAttemptId,
|
|
1517
|
+
entrySurface: this.options.entrySurface
|
|
1518
|
+
}), o && i.length === 0 && !a && !Ie() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1473
1519
|
type: "page.upsert",
|
|
1474
1520
|
sessionId: this.state.sessionId,
|
|
1475
1521
|
page: b(),
|
|
@@ -1479,107 +1525,111 @@ class Gt {
|
|
|
1479
1525
|
}
|
|
1480
1526
|
if (e.type === "starterPrompts.updated") {
|
|
1481
1527
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1482
|
-
starterPrompts:
|
|
1528
|
+
starterPrompts: Pt(e, "starterPrompts"),
|
|
1483
1529
|
starterPromptsLoading: !1
|
|
1484
1530
|
});
|
|
1485
1531
|
return;
|
|
1486
1532
|
}
|
|
1487
1533
|
if (e.type === "scheduled_follow_ups.updated") {
|
|
1488
1534
|
typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
|
|
1489
|
-
activeScheduledFollowUps:
|
|
1535
|
+
activeScheduledFollowUps: Ut(
|
|
1490
1536
|
e.activeScheduledFollowUps
|
|
1491
1537
|
)
|
|
1492
1538
|
});
|
|
1493
1539
|
return;
|
|
1494
1540
|
}
|
|
1495
1541
|
if (e.type === "conversation.state") {
|
|
1496
|
-
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(
|
|
1497
1543
|
e,
|
|
1498
1544
|
"activeScheduledFollowUps"
|
|
1499
|
-
),
|
|
1500
|
-
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)
|
|
1501
1547
|
return;
|
|
1502
|
-
this.updatePersonalModelFromSession(e.session),
|
|
1503
|
-
for (const k of
|
|
1504
|
-
this.
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
m && f && (this.pendingClientMessageId = f);
|
|
1515
|
-
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(
|
|
1516
1560
|
e.assistantDraft
|
|
1517
1561
|
);
|
|
1518
|
-
|
|
1519
|
-
respondsToUserMessageId:
|
|
1520
|
-
runId:
|
|
1521
|
-
}) && (
|
|
1522
|
-
const
|
|
1523
|
-
this.rememberUserMessageClientMessageIds(
|
|
1524
|
-
const
|
|
1525
|
-
if (
|
|
1526
|
-
const k =
|
|
1527
|
-
this.retryAttemptsByClientMessageId[
|
|
1528
|
-
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,
|
|
1529
1573
|
k
|
|
1530
1574
|
);
|
|
1531
1575
|
}
|
|
1532
|
-
const
|
|
1533
|
-
const
|
|
1534
|
-
return
|
|
1535
|
-
}),
|
|
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(
|
|
1536
1580
|
this.state.messages,
|
|
1537
|
-
|
|
1538
|
-
),
|
|
1539
|
-
(k,
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
_,
|
|
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,
|
|
1544
1587
|
ne,
|
|
1545
|
-
|
|
1588
|
+
J,
|
|
1589
|
+
Br(g, v)
|
|
1546
1590
|
)
|
|
1547
|
-
),
|
|
1548
|
-
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))
|
|
1549
1593
|
return;
|
|
1550
|
-
this.lastUserMessagePageUrl =
|
|
1551
|
-
const F =
|
|
1552
|
-
if (this.latestRecoverableClientMessageId = F,
|
|
1553
|
-
sessionId:
|
|
1554
|
-
messages:
|
|
1555
|
-
...
|
|
1556
|
-
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(
|
|
1557
1601
|
e.activeScheduledFollowUps
|
|
1558
1602
|
)
|
|
1559
1603
|
} : {},
|
|
1560
1604
|
isLoadingSession: !1,
|
|
1561
|
-
...
|
|
1562
|
-
...
|
|
1563
|
-
isRetrying:
|
|
1564
|
-
...
|
|
1565
|
-
|
|
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 ? {
|
|
1566
1611
|
assistantDraft: "",
|
|
1567
1612
|
assistantDraftItemId: null,
|
|
1568
1613
|
assistantDraftPhase: null,
|
|
1569
1614
|
assistantDraftRespondsToUserMessageId: null,
|
|
1570
1615
|
assistantDraftRunId: null
|
|
1571
|
-
} :
|
|
1572
|
-
assistantDraft:
|
|
1573
|
-
assistantDraftItemId:
|
|
1574
|
-
assistantDraftPhase:
|
|
1575
|
-
assistantDraftRespondsToUserMessageId:
|
|
1576
|
-
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
|
|
1577
1622
|
} : {},
|
|
1578
|
-
...
|
|
1623
|
+
...pe ? {
|
|
1579
1624
|
isThinking: !0,
|
|
1580
1625
|
turnPhase: "thinking",
|
|
1581
1626
|
lastError: null
|
|
1582
|
-
} :
|
|
1627
|
+
} : m ? {
|
|
1628
|
+
isThinking: !0,
|
|
1629
|
+
lastError: null,
|
|
1630
|
+
lastErrorCode: null,
|
|
1631
|
+
lastErrorSecuritySettingsUrl: null
|
|
1632
|
+
} : B ? {
|
|
1583
1633
|
isThinking: !1,
|
|
1584
1634
|
status: "connected",
|
|
1585
1635
|
lastError: null,
|
|
@@ -1587,25 +1637,25 @@ class Gt {
|
|
|
1587
1637
|
lastErrorSecuritySettingsUrl: null
|
|
1588
1638
|
} : F ? {
|
|
1589
1639
|
isThinking: !0,
|
|
1590
|
-
turnPhase:
|
|
1640
|
+
turnPhase: m ?? this.state.turnPhase ?? "starting",
|
|
1591
1641
|
lastError: null
|
|
1592
1642
|
} : {}
|
|
1593
|
-
}),
|
|
1643
|
+
}), B)
|
|
1594
1644
|
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1595
|
-
else if (!
|
|
1645
|
+
else if (!h && (pe || F)) {
|
|
1596
1646
|
if (F) {
|
|
1597
1647
|
this.activeClientMessageId = F;
|
|
1598
|
-
const k = se(
|
|
1599
|
-
this.activeResponseUserMessageId =
|
|
1648
|
+
const k = se(g), v = k === null ? null : g[k];
|
|
1649
|
+
this.activeResponseUserMessageId = M(v, "id");
|
|
1600
1650
|
}
|
|
1601
1651
|
this.markThinkingProgress();
|
|
1602
1652
|
}
|
|
1603
|
-
if (
|
|
1604
|
-
const k =
|
|
1605
|
-
k && this.retryAfterInterruptedRun(k,
|
|
1653
|
+
if (S) {
|
|
1654
|
+
const k = M(e.session, "id") ?? this.state.sessionId;
|
|
1655
|
+
k && this.retryAfterInterruptedRun(k, S);
|
|
1606
1656
|
}
|
|
1607
|
-
|
|
1608
|
-
this.autoLoadSessionActivity(
|
|
1657
|
+
a && i && window.setTimeout(() => {
|
|
1658
|
+
this.autoLoadSessionActivity(i);
|
|
1609
1659
|
}, 0);
|
|
1610
1660
|
return;
|
|
1611
1661
|
}
|
|
@@ -1613,19 +1663,19 @@ class Gt {
|
|
|
1613
1663
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1614
1664
|
if (!s || n !== this.state.sessionId)
|
|
1615
1665
|
return;
|
|
1616
|
-
const r =
|
|
1666
|
+
const r = vt(
|
|
1617
1667
|
Array.isArray(e.items) ? e.items : [],
|
|
1618
1668
|
this.options.backendUrl
|
|
1619
1669
|
);
|
|
1620
1670
|
s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
1621
|
-
messages:
|
|
1671
|
+
messages: br(this.state.messages, r)
|
|
1622
1672
|
});
|
|
1623
1673
|
return;
|
|
1624
1674
|
}
|
|
1625
1675
|
if (e.type === "sessions.page") {
|
|
1626
1676
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1627
1677
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1628
|
-
sessions:
|
|
1678
|
+
sessions: pr(e.sessions),
|
|
1629
1679
|
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1630
1680
|
}));
|
|
1631
1681
|
return;
|
|
@@ -1640,7 +1690,7 @@ class Gt {
|
|
|
1640
1690
|
}
|
|
1641
1691
|
if (e.type === "session.updated") {
|
|
1642
1692
|
this.clearRunAckResyncRetryTimer();
|
|
1643
|
-
const s =
|
|
1693
|
+
const s = M(e.session, "id");
|
|
1644
1694
|
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1645
1695
|
...this.pendingComposerWarmup.event,
|
|
1646
1696
|
sessionId: s
|
|
@@ -1651,10 +1701,10 @@ class Gt {
|
|
|
1651
1701
|
}
|
|
1652
1702
|
if (e.type === "session.item") {
|
|
1653
1703
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1654
|
-
const s =
|
|
1655
|
-
if (
|
|
1704
|
+
const s = _(e.item);
|
|
1705
|
+
if (ke(s)) {
|
|
1656
1706
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1657
|
-
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);
|
|
1658
1708
|
if (r && a) {
|
|
1659
1709
|
this.retryAfterInterruptedRun(r, a);
|
|
1660
1710
|
return;
|
|
@@ -1664,23 +1714,23 @@ class Gt {
|
|
|
1664
1714
|
return;
|
|
1665
1715
|
}
|
|
1666
1716
|
}
|
|
1667
|
-
if (
|
|
1717
|
+
if (Ot(s))
|
|
1668
1718
|
return;
|
|
1669
|
-
const n =
|
|
1719
|
+
const n = ss(e.item, this.options.backendUrl);
|
|
1670
1720
|
if (n) {
|
|
1671
|
-
const r =
|
|
1672
|
-
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
1673
|
-
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(
|
|
1674
1724
|
s,
|
|
1675
1725
|
this.state.assistantDraft,
|
|
1676
1726
|
this.state.assistantDraftItemId,
|
|
1677
1727
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1678
1728
|
this.state.assistantDraftRunId,
|
|
1679
|
-
|
|
1729
|
+
ls(
|
|
1680
1730
|
o,
|
|
1681
1731
|
o.findIndex((h) => h.id === n.id)
|
|
1682
1732
|
)
|
|
1683
|
-
), 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);
|
|
1684
1734
|
this.setState({
|
|
1685
1735
|
messages: o,
|
|
1686
1736
|
...l ? {
|
|
@@ -1738,7 +1788,7 @@ class Gt {
|
|
|
1738
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;
|
|
1739
1789
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1740
1790
|
return;
|
|
1741
|
-
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(
|
|
1742
1792
|
this.state.messages.filter(
|
|
1743
1793
|
(c) => c.dataType !== "assistant_draft" || !Ke(
|
|
1744
1794
|
c,
|
|
@@ -1748,11 +1798,11 @@ class Gt {
|
|
|
1748
1798
|
),
|
|
1749
1799
|
n,
|
|
1750
1800
|
r,
|
|
1751
|
-
|
|
1801
|
+
rs
|
|
1752
1802
|
);
|
|
1753
1803
|
this.setState({
|
|
1754
1804
|
sessionId: s,
|
|
1755
|
-
messages:
|
|
1805
|
+
messages: Ar(
|
|
1756
1806
|
l,
|
|
1757
1807
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
1758
1808
|
n,
|
|
@@ -1775,9 +1825,9 @@ class Gt {
|
|
|
1775
1825
|
if (s)
|
|
1776
1826
|
this.nonTranscriptToolCallIds.add(s);
|
|
1777
1827
|
else {
|
|
1778
|
-
const n =
|
|
1828
|
+
const n = kr(e);
|
|
1779
1829
|
if (n) {
|
|
1780
|
-
const r =
|
|
1830
|
+
const r = Rr(
|
|
1781
1831
|
this.state.messages,
|
|
1782
1832
|
n
|
|
1783
1833
|
);
|
|
@@ -1838,19 +1888,19 @@ class Gt {
|
|
|
1838
1888
|
return;
|
|
1839
1889
|
}
|
|
1840
1890
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1841
|
-
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);
|
|
1842
1892
|
l && console.error(l);
|
|
1843
|
-
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(
|
|
1844
1894
|
this.state.messages,
|
|
1845
1895
|
c,
|
|
1846
1896
|
d
|
|
1847
|
-
),
|
|
1897
|
+
), g = Dr(
|
|
1848
1898
|
h,
|
|
1849
1899
|
c,
|
|
1850
1900
|
d
|
|
1851
1901
|
);
|
|
1852
1902
|
this.setState({
|
|
1853
|
-
status:
|
|
1903
|
+
status: g ? "connected" : "error",
|
|
1854
1904
|
messages: h,
|
|
1855
1905
|
assistantDraft: "",
|
|
1856
1906
|
assistantDraftItemId: null,
|
|
@@ -1860,9 +1910,9 @@ class Gt {
|
|
|
1860
1910
|
isThinking: !1,
|
|
1861
1911
|
...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
|
|
1862
1912
|
isRetrying: !1,
|
|
1863
|
-
lastError:
|
|
1864
|
-
lastErrorCode:
|
|
1865
|
-
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
|
|
1866
1916
|
}), this.clearThinkingWatchdog(), this.emit("error", a);
|
|
1867
1917
|
}
|
|
1868
1918
|
}
|
|
@@ -1876,21 +1926,21 @@ class Gt {
|
|
|
1876
1926
|
this.options.model = He(n) ? n : "gpt-5.6-sol";
|
|
1877
1927
|
}
|
|
1878
1928
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1879
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1929
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !ye(e))
|
|
1880
1930
|
return !1;
|
|
1881
|
-
const s =
|
|
1931
|
+
const s = K(e);
|
|
1882
1932
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1883
1933
|
}
|
|
1884
1934
|
shouldIgnoreDetachedSessionEvent(e) {
|
|
1885
|
-
if (this.options.keepRunsActiveOnSessionNavigation || !
|
|
1935
|
+
if (this.options.keepRunsActiveOnSessionNavigation || !ye(e))
|
|
1886
1936
|
return !1;
|
|
1887
|
-
const s =
|
|
1937
|
+
const s = K(e);
|
|
1888
1938
|
return !!(s && this.detachedSessionIds.has(s));
|
|
1889
1939
|
}
|
|
1890
1940
|
shouldDeferDetachedSessionEvent(e) {
|
|
1891
|
-
if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !
|
|
1941
|
+
if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !ye(e))
|
|
1892
1942
|
return !1;
|
|
1893
|
-
const s =
|
|
1943
|
+
const s = K(e);
|
|
1894
1944
|
if (!s || s === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(s))
|
|
1895
1945
|
return !1;
|
|
1896
1946
|
const n = this.deferredDetachedSessionEvents.get(s) ?? [];
|
|
@@ -1913,7 +1963,7 @@ class Gt {
|
|
|
1913
1963
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1914
1964
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1915
1965
|
return !1;
|
|
1916
|
-
if (
|
|
1966
|
+
if (Ie())
|
|
1917
1967
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1918
1968
|
if (e.code === "run_still_active") {
|
|
1919
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) {
|
|
@@ -1944,7 +1994,7 @@ class Gt {
|
|
|
1944
1994
|
}, o), !0;
|
|
1945
1995
|
}
|
|
1946
1996
|
retryAfterInterruptedRun(e, s) {
|
|
1947
|
-
if (
|
|
1997
|
+
if (Ie()) {
|
|
1948
1998
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1949
1999
|
return;
|
|
1950
2000
|
}
|
|
@@ -1960,7 +2010,7 @@ class Gt {
|
|
|
1960
2010
|
}, le(n));
|
|
1961
2011
|
}
|
|
1962
2012
|
requestSessionRecoveryExhaustion(e, s) {
|
|
1963
|
-
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);
|
|
1964
2014
|
}
|
|
1965
2015
|
clearRetryTimers() {
|
|
1966
2016
|
for (const e of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1969,10 +2019,10 @@ class Gt {
|
|
|
1969
2019
|
}
|
|
1970
2020
|
rememberUserMessageClientMessageIds(e) {
|
|
1971
2021
|
for (const s of e) {
|
|
1972
|
-
const n =
|
|
2022
|
+
const n = M(s, "id"), r = _(s);
|
|
1973
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(
|
|
1974
2024
|
r.clientMessageId,
|
|
1975
|
-
|
|
2025
|
+
M(s, "sessionId") ?? this.state.sessionId,
|
|
1976
2026
|
n,
|
|
1977
2027
|
null
|
|
1978
2028
|
), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
|
|
@@ -1991,7 +2041,7 @@ class Gt {
|
|
|
1991
2041
|
const r = new Promise((i, o) => {
|
|
1992
2042
|
const a = window.setTimeout(() => {
|
|
1993
2043
|
e.delete(s.requestId), o(new Error(n));
|
|
1994
|
-
},
|
|
2044
|
+
}, Et);
|
|
1995
2045
|
e.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1996
2046
|
});
|
|
1997
2047
|
if (!this.sendNow(s)) {
|
|
@@ -2014,7 +2064,7 @@ class Gt {
|
|
|
2014
2064
|
e.clear();
|
|
2015
2065
|
}
|
|
2016
2066
|
markThinkingProgress() {
|
|
2017
|
-
!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));
|
|
2018
2068
|
}
|
|
2019
2069
|
scheduleThinkingWatchdog(e) {
|
|
2020
2070
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -2058,9 +2108,9 @@ class Gt {
|
|
|
2058
2108
|
}), this.markThinkingProgress();
|
|
2059
2109
|
}
|
|
2060
2110
|
schedulePendingDeliveryAck(e) {
|
|
2061
|
-
this.clearPendingDeliveryTimers(), !
|
|
2111
|
+
this.clearPendingDeliveryTimers(), !Ie() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
2062
2112
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
2063
|
-
},
|
|
2113
|
+
}, At));
|
|
2064
2114
|
}
|
|
2065
2115
|
retryPendingDelivery(e) {
|
|
2066
2116
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
@@ -2072,7 +2122,7 @@ class Gt {
|
|
|
2072
2122
|
}
|
|
2073
2123
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
2074
2124
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
2075
|
-
}, le(s,
|
|
2125
|
+
}, le(s, Rt));
|
|
2076
2126
|
}
|
|
2077
2127
|
failPendingDelivery(e) {
|
|
2078
2128
|
if (this.pendingClientMessageId !== e)
|
|
@@ -2084,7 +2134,7 @@ class Gt {
|
|
|
2084
2134
|
...this.state.isThinking ? {} : { turnPhase: null },
|
|
2085
2135
|
isRetrying: !1,
|
|
2086
2136
|
...this.state.isThinking ? {} : { taskStatus: "failed" },
|
|
2087
|
-
lastError:
|
|
2137
|
+
lastError: mn,
|
|
2088
2138
|
lastErrorCode: "message_delivery_failed"
|
|
2089
2139
|
});
|
|
2090
2140
|
}
|
|
@@ -2099,7 +2149,7 @@ class Gt {
|
|
|
2099
2149
|
s,
|
|
2100
2150
|
typeof e.runId == "string" ? e.runId : null
|
|
2101
2151
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
2102
|
-
messages:
|
|
2152
|
+
messages: Kr(
|
|
2103
2153
|
this.state.messages,
|
|
2104
2154
|
s
|
|
2105
2155
|
)
|
|
@@ -2108,7 +2158,7 @@ class Gt {
|
|
|
2108
2158
|
scheduleRunAckWatchdog(e) {
|
|
2109
2159
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
2110
2160
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
2111
|
-
},
|
|
2161
|
+
}, At);
|
|
2112
2162
|
}
|
|
2113
2163
|
recoverMissedRunAck(e) {
|
|
2114
2164
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (A("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -2132,8 +2182,8 @@ class Gt {
|
|
|
2132
2182
|
sessionId: this.state.sessionId,
|
|
2133
2183
|
clientMessageId: e,
|
|
2134
2184
|
automatic: !0
|
|
2135
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
2136
|
-
}, le(s,
|
|
2185
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(Tt)));
|
|
2186
|
+
}, le(s, Rt)));
|
|
2137
2187
|
}
|
|
2138
2188
|
clearRunAckResyncRetryTimer() {
|
|
2139
2189
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -2152,11 +2202,11 @@ class Gt {
|
|
|
2152
2202
|
reason: "missing_client_message_id"
|
|
2153
2203
|
}), this.setState({
|
|
2154
2204
|
messages: this.state.messages.filter(
|
|
2155
|
-
(r) => !
|
|
2205
|
+
(r) => !X(r)
|
|
2156
2206
|
),
|
|
2157
2207
|
isThinking: !1,
|
|
2158
2208
|
taskStatus: "failed",
|
|
2159
|
-
lastError:
|
|
2209
|
+
lastError: Mt,
|
|
2160
2210
|
lastErrorCode: "run_recovery_exhausted"
|
|
2161
2211
|
}), this.clearThinkingWatchdog();
|
|
2162
2212
|
return;
|
|
@@ -2169,7 +2219,7 @@ class Gt {
|
|
|
2169
2219
|
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
2170
2220
|
isThinking: !1,
|
|
2171
2221
|
taskStatus: "failed",
|
|
2172
|
-
lastError:
|
|
2222
|
+
lastError: Mt,
|
|
2173
2223
|
lastErrorCode: "connection_failed"
|
|
2174
2224
|
}), this.clearThinkingWatchdog());
|
|
2175
2225
|
return;
|
|
@@ -2179,7 +2229,7 @@ class Gt {
|
|
|
2179
2229
|
sessionId: this.state.sessionId,
|
|
2180
2230
|
clientMessageId: e,
|
|
2181
2231
|
resyncAttempts: s + 1
|
|
2182
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
2232
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(wt);
|
|
2183
2233
|
return;
|
|
2184
2234
|
}
|
|
2185
2235
|
this.setState({
|
|
@@ -2214,15 +2264,15 @@ class Gt {
|
|
|
2214
2264
|
if (!s || !n || !r)
|
|
2215
2265
|
return;
|
|
2216
2266
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
2217
|
-
if (!a && !l || !
|
|
2267
|
+
if (!a && !l || !pi(o)) {
|
|
2218
2268
|
this.setToolMessageLoading(n, !1), this.send({
|
|
2219
2269
|
type: "tool.result",
|
|
2220
2270
|
sessionId: s,
|
|
2221
2271
|
callId: n,
|
|
2222
2272
|
toolName: r,
|
|
2223
2273
|
summary: i,
|
|
2224
|
-
rawInput:
|
|
2225
|
-
rawOutput:
|
|
2274
|
+
rawInput: O(o),
|
|
2275
|
+
rawOutput: O({
|
|
2226
2276
|
ok: !1,
|
|
2227
2277
|
toolName: r,
|
|
2228
2278
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -2237,7 +2287,7 @@ class Gt {
|
|
|
2237
2287
|
callId: n,
|
|
2238
2288
|
toolName: r,
|
|
2239
2289
|
summary: i,
|
|
2240
|
-
rawInput:
|
|
2290
|
+
rawInput: O(o),
|
|
2241
2291
|
rawOutput: {
|
|
2242
2292
|
ok: !1,
|
|
2243
2293
|
toolName: r,
|
|
@@ -2253,7 +2303,7 @@ class Gt {
|
|
|
2253
2303
|
callId: n,
|
|
2254
2304
|
toolName: r,
|
|
2255
2305
|
summary: i,
|
|
2256
|
-
rawInput:
|
|
2306
|
+
rawInput: O(o),
|
|
2257
2307
|
rawOutput: null
|
|
2258
2308
|
},
|
|
2259
2309
|
startedAtMs: Date.now(),
|
|
@@ -2261,9 +2311,9 @@ class Gt {
|
|
|
2261
2311
|
startedAtOrigin: location.origin
|
|
2262
2312
|
}), this.installSessionBrowserApis();
|
|
2263
2313
|
let c = null, d;
|
|
2264
|
-
c = await this.executeRuntimeHelper(), d = await
|
|
2314
|
+
c = await this.executeRuntimeHelper(), d = await bt(
|
|
2265
2315
|
o,
|
|
2266
|
-
|
|
2316
|
+
$n(e.runtimeContext, this.options.backendUrl)
|
|
2267
2317
|
).catch((h) => ({
|
|
2268
2318
|
ok: !1,
|
|
2269
2319
|
exception: {
|
|
@@ -2275,12 +2325,12 @@ class Gt {
|
|
|
2275
2325
|
callId: n,
|
|
2276
2326
|
toolName: r,
|
|
2277
2327
|
summary: o.summary,
|
|
2278
|
-
rawInput:
|
|
2279
|
-
rawOutput:
|
|
2280
|
-
}),
|
|
2328
|
+
rawInput: O(o),
|
|
2329
|
+
rawOutput: O(lr(d, c))
|
|
2330
|
+
}), xt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
2281
2331
|
}
|
|
2282
2332
|
setToolMessageLoading(e, s) {
|
|
2283
|
-
const n =
|
|
2333
|
+
const n = Er(
|
|
2284
2334
|
this.state.messages,
|
|
2285
2335
|
e,
|
|
2286
2336
|
s
|
|
@@ -2291,33 +2341,33 @@ class Gt {
|
|
|
2291
2341
|
if (this.pageLifecycleCleanup)
|
|
2292
2342
|
return;
|
|
2293
2343
|
const e = () => {
|
|
2294
|
-
|
|
2344
|
+
ds(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
2295
2345
|
};
|
|
2296
2346
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
2297
2347
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
2298
2348
|
};
|
|
2299
2349
|
}
|
|
2300
2350
|
installSessionBrowserApis() {
|
|
2301
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
2351
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = vn();
|
|
2302
2352
|
}
|
|
2303
2353
|
cleanupSessionBrowserApis() {
|
|
2304
|
-
this.sessionBrowserApisCleanup && (
|
|
2354
|
+
this.sessionBrowserApisCleanup && (Wn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
2305
2355
|
}
|
|
2306
2356
|
async executeRuntimeHelper() {
|
|
2307
2357
|
if (!this.runtimeHelperJavascript?.trim())
|
|
2308
2358
|
return null;
|
|
2309
|
-
const e = await
|
|
2359
|
+
const e = await bt({
|
|
2310
2360
|
javascript: this.runtimeHelperJavascript
|
|
2311
2361
|
});
|
|
2312
|
-
return e.ok === !1 ?
|
|
2362
|
+
return e.ok === !1 ? cr(e) : null;
|
|
2313
2363
|
}
|
|
2314
2364
|
enableNetworkCapture() {
|
|
2315
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
2316
|
-
|
|
2365
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = Cn((e) => {
|
|
2366
|
+
Ii(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
2317
2367
|
}));
|
|
2318
2368
|
}
|
|
2319
2369
|
enqueueNetworkEvent(e) {
|
|
2320
|
-
this.queuedNetworkEvents.length >=
|
|
2370
|
+
this.queuedNetworkEvents.length >= In || (this.queuedNetworkEvents.push(yi(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
2321
2371
|
this.networkBatchTimer = null;
|
|
2322
2372
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
2323
2373
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -2326,12 +2376,12 @@ class Gt {
|
|
|
2326
2376
|
page: b(),
|
|
2327
2377
|
events: s
|
|
2328
2378
|
});
|
|
2329
|
-
},
|
|
2379
|
+
}, yn)));
|
|
2330
2380
|
}
|
|
2331
2381
|
scheduleReconnect() {
|
|
2332
2382
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
2333
2383
|
return;
|
|
2334
|
-
const e =
|
|
2384
|
+
const e = En(this.reconnectAttempts);
|
|
2335
2385
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
2336
2386
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
2337
2387
|
A("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -2347,8 +2397,8 @@ class Gt {
|
|
|
2347
2397
|
const e = this.socket;
|
|
2348
2398
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
2349
2399
|
this.socket === e && (A("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
2350
|
-
},
|
|
2351
|
-
},
|
|
2400
|
+
}, cn));
|
|
2401
|
+
}, ln);
|
|
2352
2402
|
}
|
|
2353
2403
|
stopHeartbeat() {
|
|
2354
2404
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -2386,7 +2436,7 @@ class Gt {
|
|
|
2386
2436
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2387
2437
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2388
2438
|
};
|
|
2389
|
-
this.state = o,
|
|
2439
|
+
this.state = o, ei(this.options.clientId, this.state), this.emit("state", this.getState()), $e("state", this.state.status, {
|
|
2390
2440
|
status: this.state.status,
|
|
2391
2441
|
sessionId: this.state.sessionId,
|
|
2392
2442
|
messageCount: this.state.messages.length,
|
|
@@ -2409,54 +2459,54 @@ class Gt {
|
|
|
2409
2459
|
}
|
|
2410
2460
|
}
|
|
2411
2461
|
const je = /* @__PURE__ */ new WeakMap();
|
|
2412
|
-
function
|
|
2413
|
-
const e = window.__plunoProductAgentNetworkCapture ??
|
|
2462
|
+
function Cn(t) {
|
|
2463
|
+
const e = window.__plunoProductAgentNetworkCapture ?? bn();
|
|
2414
2464
|
return e.subscribers.add(t), () => {
|
|
2415
2465
|
e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
2416
2466
|
};
|
|
2417
2467
|
}
|
|
2418
|
-
function
|
|
2419
|
-
const t = /* @__PURE__ */ new Set(), e = (
|
|
2420
|
-
t.forEach((
|
|
2468
|
+
function bn() {
|
|
2469
|
+
const t = /* @__PURE__ */ new Set(), e = (g) => {
|
|
2470
|
+
t.forEach((y) => {
|
|
2421
2471
|
try {
|
|
2422
|
-
|
|
2472
|
+
y(g);
|
|
2423
2473
|
} catch {
|
|
2424
2474
|
}
|
|
2425
2475
|
});
|
|
2426
|
-
}, 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) {
|
|
2427
2477
|
const p = Date.now();
|
|
2428
|
-
let
|
|
2478
|
+
let m;
|
|
2429
2479
|
try {
|
|
2430
|
-
|
|
2431
|
-
} catch (
|
|
2432
|
-
throw
|
|
2480
|
+
m = s.call(this, y, u);
|
|
2481
|
+
} catch (f) {
|
|
2482
|
+
throw f;
|
|
2433
2483
|
}
|
|
2434
2484
|
try {
|
|
2435
|
-
const
|
|
2436
|
-
if (!Z(
|
|
2437
|
-
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 = {
|
|
2438
2488
|
requestId: Ge("fetch"),
|
|
2439
|
-
url:
|
|
2440
|
-
method: (u?.method ??
|
|
2441
|
-
requestHeaders:
|
|
2442
|
-
requestBody:
|
|
2489
|
+
url: W(R, Fe),
|
|
2490
|
+
method: (u?.method ?? f?.method ?? "GET").toUpperCase(),
|
|
2491
|
+
requestHeaders: S,
|
|
2492
|
+
requestBody: Wt(u?.body),
|
|
2443
2493
|
resourceType: "fetch",
|
|
2444
2494
|
startedAt: new Date(p).toISOString()
|
|
2445
2495
|
};
|
|
2446
|
-
|
|
2447
|
-
(
|
|
2448
|
-
|
|
2496
|
+
m.then(
|
|
2497
|
+
(T) => {
|
|
2498
|
+
gi(T, x, p, e).catch(() => {
|
|
2449
2499
|
e({
|
|
2450
|
-
...
|
|
2451
|
-
responseStatus:
|
|
2500
|
+
...x,
|
|
2501
|
+
responseStatus: T.status,
|
|
2452
2502
|
durationMs: Date.now() - p
|
|
2453
2503
|
});
|
|
2454
2504
|
});
|
|
2455
2505
|
},
|
|
2456
|
-
(
|
|
2506
|
+
(T) => {
|
|
2457
2507
|
e({
|
|
2458
|
-
...
|
|
2459
|
-
errorText:
|
|
2508
|
+
...x,
|
|
2509
|
+
errorText: W(T instanceof Error ? T.message : String(T)),
|
|
2460
2510
|
durationMs: Date.now() - p
|
|
2461
2511
|
});
|
|
2462
2512
|
}
|
|
@@ -2464,30 +2514,30 @@ function Mn() {
|
|
|
2464
2514
|
}
|
|
2465
2515
|
} catch {
|
|
2466
2516
|
}
|
|
2467
|
-
return
|
|
2468
|
-
}, a = function(
|
|
2469
|
-
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();
|
|
2470
2520
|
return je.set(this, {
|
|
2471
2521
|
requestId: Ge("xhr"),
|
|
2472
|
-
method: String(
|
|
2473
|
-
url:
|
|
2522
|
+
method: String(y ?? "GET").toUpperCase(),
|
|
2523
|
+
url: W(S, Fe),
|
|
2474
2524
|
requestHeaders: {},
|
|
2475
2525
|
startedAtMs: Date.now(),
|
|
2476
2526
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2477
|
-
excluded: Z(
|
|
2478
|
-
}),
|
|
2479
|
-
}, l = function(
|
|
2480
|
-
const p = r.call(this,
|
|
2481
|
-
return
|
|
2482
|
-
}, 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) {
|
|
2483
2533
|
try {
|
|
2484
2534
|
const u = je.get(this);
|
|
2485
|
-
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(
|
|
2486
2536
|
"loadend",
|
|
2487
2537
|
() => {
|
|
2488
2538
|
queueMicrotask(() => {
|
|
2489
2539
|
try {
|
|
2490
|
-
const p =
|
|
2540
|
+
const p = Ti(this.getAllResponseHeaders());
|
|
2491
2541
|
e({
|
|
2492
2542
|
requestId: u.requestId,
|
|
2493
2543
|
url: u.url,
|
|
@@ -2497,7 +2547,7 @@ function Mn() {
|
|
|
2497
2547
|
resourceType: "xhr",
|
|
2498
2548
|
responseStatus: this.status,
|
|
2499
2549
|
responseHeaders: p,
|
|
2500
|
-
responseBody:
|
|
2550
|
+
responseBody: mi(this, p),
|
|
2501
2551
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2502
2552
|
startedAt: u.startedAt,
|
|
2503
2553
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -2511,7 +2561,7 @@ function Mn() {
|
|
|
2511
2561
|
));
|
|
2512
2562
|
} catch {
|
|
2513
2563
|
}
|
|
2514
|
-
return i.call(this,
|
|
2564
|
+
return i.call(this, y ?? null);
|
|
2515
2565
|
};
|
|
2516
2566
|
try {
|
|
2517
2567
|
window.fetch = o;
|
|
@@ -2531,15 +2581,15 @@ function Mn() {
|
|
|
2531
2581
|
}
|
|
2532
2582
|
let d = null;
|
|
2533
2583
|
if (typeof PerformanceObserver < "u") {
|
|
2534
|
-
d = new PerformanceObserver((
|
|
2535
|
-
for (const
|
|
2536
|
-
const u =
|
|
2584
|
+
d = new PerformanceObserver((g) => {
|
|
2585
|
+
for (const y of g.getEntries()) {
|
|
2586
|
+
const u = y;
|
|
2537
2587
|
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || Z(u.name))
|
|
2538
2588
|
continue;
|
|
2539
2589
|
const p = performance.timeOrigin + u.startTime;
|
|
2540
2590
|
e({
|
|
2541
2591
|
requestId: Ge("resource"),
|
|
2542
|
-
url:
|
|
2592
|
+
url: W(u.name, Fe),
|
|
2543
2593
|
method: "GET",
|
|
2544
2594
|
resourceType: "resource",
|
|
2545
2595
|
responseStatus: u.responseStatus,
|
|
@@ -2589,17 +2639,17 @@ function A(t, e, s) {
|
|
|
2589
2639
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
2590
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 }));
|
|
2591
2641
|
}
|
|
2592
|
-
function
|
|
2642
|
+
function Ct(t) {
|
|
2593
2643
|
const e = typeof t == "function" ? t() : t;
|
|
2594
2644
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2595
2645
|
}
|
|
2596
|
-
function
|
|
2646
|
+
function _n(t) {
|
|
2597
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";
|
|
2598
2648
|
}
|
|
2599
|
-
function
|
|
2649
|
+
function ye(t) {
|
|
2600
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";
|
|
2601
2651
|
}
|
|
2602
|
-
function
|
|
2652
|
+
function K(t) {
|
|
2603
2653
|
if (typeof t.sessionId == "string")
|
|
2604
2654
|
return t.sessionId;
|
|
2605
2655
|
if (t.session && typeof t.session == "object") {
|
|
@@ -2614,31 +2664,31 @@ function G(t) {
|
|
|
2614
2664
|
}
|
|
2615
2665
|
return null;
|
|
2616
2666
|
}
|
|
2617
|
-
const
|
|
2618
|
-
function
|
|
2667
|
+
const Pn = 5e3, Un = 12e4;
|
|
2668
|
+
function vn() {
|
|
2619
2669
|
const t = [
|
|
2620
|
-
|
|
2621
|
-
|
|
2670
|
+
On(),
|
|
2671
|
+
Dn()
|
|
2622
2672
|
].filter((e) => typeof e == "function");
|
|
2623
2673
|
return () => {
|
|
2624
2674
|
for (const e of t.reverse())
|
|
2625
2675
|
e();
|
|
2626
2676
|
};
|
|
2627
2677
|
}
|
|
2628
|
-
function
|
|
2629
|
-
return
|
|
2678
|
+
function Dn() {
|
|
2679
|
+
return $t(globalThis, "getPageSnapshot", async () => at());
|
|
2630
2680
|
}
|
|
2631
|
-
function
|
|
2632
|
-
return
|
|
2633
|
-
inspectImage: async (e, s) => await
|
|
2681
|
+
function On() {
|
|
2682
|
+
return $t(globalThis, "pageImages", {
|
|
2683
|
+
inspectImage: async (e, s) => await qn(e, s)
|
|
2634
2684
|
});
|
|
2635
2685
|
}
|
|
2636
|
-
async function
|
|
2637
|
-
const s =
|
|
2686
|
+
async function qn(t, e = {}) {
|
|
2687
|
+
const s = Bn(e.name), n = await Ln(t);
|
|
2638
2688
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2639
2689
|
type: "pluno.pageImages.inspectImage",
|
|
2640
2690
|
imageAttached: !1,
|
|
2641
|
-
imageAttachmentError:
|
|
2691
|
+
imageAttachmentError: Xt
|
|
2642
2692
|
} : {
|
|
2643
2693
|
type: "pluno.pageImages.inspectImage",
|
|
2644
2694
|
imageAttached: !0,
|
|
@@ -2652,15 +2702,15 @@ async function _n(t, e = {}) {
|
|
|
2652
2702
|
imageAttachmentError: n.error
|
|
2653
2703
|
};
|
|
2654
2704
|
}
|
|
2655
|
-
async function
|
|
2656
|
-
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 } : {
|
|
2657
2707
|
ok: !0,
|
|
2658
2708
|
mimeType: t.type,
|
|
2659
2709
|
sizeBytes: t.size,
|
|
2660
|
-
dataUrl: await
|
|
2661
|
-
} : { 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);
|
|
2662
2712
|
}
|
|
2663
|
-
function
|
|
2713
|
+
function Nn(t) {
|
|
2664
2714
|
if (!t.startsWith("data:") || !t.includes(","))
|
|
2665
2715
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
2666
2716
|
const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -2671,7 +2721,7 @@ function Un(t) {
|
|
|
2671
2721
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
2672
2722
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
2673
2723
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
2674
|
-
const o =
|
|
2724
|
+
const o = xn(i);
|
|
2675
2725
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
2676
2726
|
ok: !0,
|
|
2677
2727
|
mimeType: r,
|
|
@@ -2679,22 +2729,22 @@ function Un(t) {
|
|
|
2679
2729
|
dataUrl: `data:${r};base64,${i}`
|
|
2680
2730
|
};
|
|
2681
2731
|
}
|
|
2682
|
-
function
|
|
2732
|
+
function xn(t) {
|
|
2683
2733
|
if (t.length === 0 || t.length % 4 !== 0)
|
|
2684
2734
|
return null;
|
|
2685
2735
|
const e = t.length - t.replace(/=+$/, "").length;
|
|
2686
2736
|
return e > 2 ? null : t.length / 4 * 3 - e;
|
|
2687
2737
|
}
|
|
2688
|
-
function
|
|
2738
|
+
function Bn(t) {
|
|
2689
2739
|
return (typeof t == "string" ? t.trim() : "") || "Page image";
|
|
2690
2740
|
}
|
|
2691
|
-
function
|
|
2741
|
+
function Wn(t) {
|
|
2692
2742
|
try {
|
|
2693
2743
|
t();
|
|
2694
2744
|
} catch {
|
|
2695
2745
|
}
|
|
2696
2746
|
}
|
|
2697
|
-
function
|
|
2747
|
+
function Hn(t) {
|
|
2698
2748
|
return new Promise((e, s) => {
|
|
2699
2749
|
const n = new FileReader();
|
|
2700
2750
|
n.onload = () => {
|
|
@@ -2706,9 +2756,9 @@ function qn(t) {
|
|
|
2706
2756
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(t);
|
|
2707
2757
|
});
|
|
2708
2758
|
}
|
|
2709
|
-
async function
|
|
2759
|
+
async function bt(t, e) {
|
|
2710
2760
|
const s = Object.getPrototypeOf(async function() {
|
|
2711
|
-
}).constructor, n = t.timeoutMs ??
|
|
2761
|
+
}).constructor, n = t.timeoutMs ?? Pn, r = Date.now(), i = [];
|
|
2712
2762
|
let o;
|
|
2713
2763
|
const a = {
|
|
2714
2764
|
log: console.log,
|
|
@@ -2726,7 +2776,7 @@ async function Ct(t, e) {
|
|
|
2726
2776
|
o = window.setTimeout(() => h(c), n);
|
|
2727
2777
|
})
|
|
2728
2778
|
]);
|
|
2729
|
-
return d === c ?
|
|
2779
|
+
return d === c ? Fn(n) : {
|
|
2730
2780
|
ok: !0,
|
|
2731
2781
|
result: d,
|
|
2732
2782
|
console: i,
|
|
@@ -2755,7 +2805,7 @@ async function Ct(t, e) {
|
|
|
2755
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;
|
|
2756
2806
|
}
|
|
2757
2807
|
}
|
|
2758
|
-
function
|
|
2808
|
+
function $n(t, e) {
|
|
2759
2809
|
if (!t || typeof t != "object")
|
|
2760
2810
|
return;
|
|
2761
2811
|
const s = t.sandboxFilesToken;
|
|
@@ -2765,7 +2815,7 @@ function Ln(t, e) {
|
|
|
2765
2815
|
const r = () => {
|
|
2766
2816
|
if (!n)
|
|
2767
2817
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2768
|
-
}, i = async (a, l) => await
|
|
2818
|
+
}, i = async (a, l) => await en(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2769
2819
|
return {
|
|
2770
2820
|
value: Object.freeze({
|
|
2771
2821
|
upload: async (a) => {
|
|
@@ -2799,7 +2849,7 @@ function Ln(t, e) {
|
|
|
2799
2849
|
}
|
|
2800
2850
|
};
|
|
2801
2851
|
}
|
|
2802
|
-
function
|
|
2852
|
+
function Fn(t) {
|
|
2803
2853
|
return {
|
|
2804
2854
|
ok: !1,
|
|
2805
2855
|
exception: {
|
|
@@ -2813,10 +2863,10 @@ function Nn(t) {
|
|
|
2813
2863
|
}
|
|
2814
2864
|
};
|
|
2815
2865
|
}
|
|
2816
|
-
function
|
|
2866
|
+
function jn(t) {
|
|
2817
2867
|
return t.replace(/\/+$/, "");
|
|
2818
2868
|
}
|
|
2819
|
-
function
|
|
2869
|
+
function zn(t) {
|
|
2820
2870
|
const e = {
|
|
2821
2871
|
sidepanel: "extension_sidepanel",
|
|
2822
2872
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2828,18 +2878,18 @@ function Bn(t) {
|
|
|
2828
2878
|
};
|
|
2829
2879
|
return t && t in e ? e[t] : t ?? "embedded_custom_ui";
|
|
2830
2880
|
}
|
|
2831
|
-
function
|
|
2881
|
+
function Kn(t) {
|
|
2832
2882
|
return t === "pluno" ? "scheduled_continuation" : t ?? "user";
|
|
2833
2883
|
}
|
|
2834
|
-
function
|
|
2884
|
+
function Gn(t, e = location.origin) {
|
|
2835
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;
|
|
2836
2886
|
}
|
|
2837
|
-
function
|
|
2887
|
+
function Vn(t) {
|
|
2838
2888
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2839
2889
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2840
2890
|
}
|
|
2841
2891
|
function b() {
|
|
2842
|
-
const t =
|
|
2892
|
+
const t = ts();
|
|
2843
2893
|
return {
|
|
2844
2894
|
url: location.href,
|
|
2845
2895
|
title: document.title,
|
|
@@ -2847,21 +2897,21 @@ function b() {
|
|
|
2847
2897
|
...t ? { plunoProductAgentUi: t } : {}
|
|
2848
2898
|
};
|
|
2849
2899
|
}
|
|
2850
|
-
function
|
|
2900
|
+
function Xn() {
|
|
2851
2901
|
return {
|
|
2852
2902
|
pageUrl: location.href,
|
|
2853
2903
|
pageTitle: document.title,
|
|
2854
2904
|
htmlContent: at()
|
|
2855
2905
|
};
|
|
2856
2906
|
}
|
|
2857
|
-
function
|
|
2858
|
-
return
|
|
2859
|
-
|
|
2907
|
+
function Jn(t) {
|
|
2908
|
+
return Me.add(t), me || (me = Qn()), () => {
|
|
2909
|
+
Me.delete(t), Me.size === 0 && (me?.(), me = null);
|
|
2860
2910
|
};
|
|
2861
2911
|
}
|
|
2862
|
-
function
|
|
2912
|
+
function Qn() {
|
|
2863
2913
|
const t = () => {
|
|
2864
|
-
for (const i of Array.from(
|
|
2914
|
+
for (const i of Array.from(Me))
|
|
2865
2915
|
i();
|
|
2866
2916
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2867
2917
|
const o = e(...i);
|
|
@@ -2874,33 +2924,33 @@ function zn() {
|
|
|
2874
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);
|
|
2875
2925
|
};
|
|
2876
2926
|
}
|
|
2877
|
-
function
|
|
2878
|
-
return
|
|
2927
|
+
function Ie() {
|
|
2928
|
+
return ts()?.surface === "browser_extension_sdk_preview";
|
|
2879
2929
|
}
|
|
2880
2930
|
function at() {
|
|
2881
2931
|
if (!document.body)
|
|
2882
2932
|
return "";
|
|
2883
|
-
const t = [], e = [], s = (p,
|
|
2884
|
-
const
|
|
2885
|
-
!
|
|
2933
|
+
const t = [], e = [], s = (p, m) => {
|
|
2934
|
+
const f = te(m);
|
|
2935
|
+
!f || e.includes(f) || (t.push([p, f]), e.push(f));
|
|
2886
2936
|
};
|
|
2887
2937
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2888
2938
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2889
|
-
(p) =>
|
|
2939
|
+
(p) => Yt(p) && !p.parentElement?.closest(n)
|
|
2890
2940
|
);
|
|
2891
2941
|
for (const p of r.slice(0, 3))
|
|
2892
2942
|
s("Active overlay", ze(ue(p), e));
|
|
2893
|
-
const i =
|
|
2943
|
+
const i = Yn(), o = i ? ze(ue(i), e) : "";
|
|
2894
2944
|
s("Main page content", o), s("Additional visible page text", ze(ue(document.body), e));
|
|
2895
|
-
const a = t.map(([p,
|
|
2896
|
-
${
|
|
2945
|
+
const a = t.map(([p, m]) => `${p}:
|
|
2946
|
+
${m}`).join(`
|
|
2897
2947
|
|
|
2898
|
-
`).trim().slice(0, 12e3), l =
|
|
2948
|
+
`).trim().slice(0, 12e3), l = Zn(r, i).trim(), c = `Simplified DOM outline:
|
|
2899
2949
|
`, d = `
|
|
2900
2950
|
|
|
2901
2951
|
Visible page text:
|
|
2902
|
-
`, h = 12e3 - c.length - d.length,
|
|
2903
|
-
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}`;
|
|
2904
2954
|
}
|
|
2905
2955
|
function ue(t) {
|
|
2906
2956
|
return t.innerText ?? t.textContent ?? "";
|
|
@@ -2919,14 +2969,14 @@ function ze(t, e) {
|
|
|
2919
2969
|
s = s.replace(n, "");
|
|
2920
2970
|
return te(s);
|
|
2921
2971
|
}
|
|
2922
|
-
function
|
|
2972
|
+
function Yt(t) {
|
|
2923
2973
|
const e = window.getComputedStyle(t);
|
|
2924
2974
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2925
2975
|
}
|
|
2926
|
-
function
|
|
2927
|
-
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;
|
|
2928
2978
|
}
|
|
2929
|
-
function
|
|
2979
|
+
function Zn(t, e) {
|
|
2930
2980
|
const s = /* @__PURE__ */ new Set([
|
|
2931
2981
|
"main",
|
|
2932
2982
|
"nav",
|
|
@@ -3006,92 +3056,92 @@ function Gn(t, e) {
|
|
|
3006
3056
|
"data-test",
|
|
3007
3057
|
"data-qa",
|
|
3008
3058
|
"data-cy"
|
|
3009
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: h } =
|
|
3010
|
-
e &&
|
|
3011
|
-
let
|
|
3012
|
-
const u = (
|
|
3013
|
-
const
|
|
3014
|
-
return
|
|
3015
|
-
}, p = (
|
|
3016
|
-
const
|
|
3017
|
-
return `${
|
|
3018
|
-
},
|
|
3019
|
-
const
|
|
3020
|
-
const
|
|
3021
|
-
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")
|
|
3022
3072
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
3023
|
-
|
|
3024
|
-
const
|
|
3025
|
-
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) {
|
|
3026
3076
|
const E = p(I);
|
|
3027
|
-
|
|
3077
|
+
z.set(E, (z.get(E) ?? 0) + 1);
|
|
3028
3078
|
}
|
|
3029
|
-
const
|
|
3030
|
-
for (const I of
|
|
3031
|
-
const E = p(I), j =
|
|
3032
|
-
|
|
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);
|
|
3033
3083
|
}
|
|
3034
|
-
const
|
|
3035
|
-
for (const I of
|
|
3036
|
-
const E = p(I), j =
|
|
3037
|
-
if (
|
|
3038
|
-
|
|
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));
|
|
3039
3089
|
continue;
|
|
3040
3090
|
}
|
|
3041
|
-
const gt =
|
|
3042
|
-
ut.push(gt),
|
|
3091
|
+
const gt = T(I, L);
|
|
3092
|
+
ut.push(gt), v.push(gt.lines);
|
|
3043
3093
|
}
|
|
3044
3094
|
const De = [];
|
|
3045
|
-
if (
|
|
3046
|
-
for (const I of Array.from(
|
|
3047
|
-
I instanceof HTMLElement && De.push(
|
|
3048
|
-
const
|
|
3049
|
-
[
|
|
3050
|
-
).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 = [];
|
|
3051
3101
|
if (qe) {
|
|
3052
|
-
const I =
|
|
3053
|
-
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)));
|
|
3054
3104
|
}
|
|
3055
|
-
for (const I of
|
|
3056
|
-
ie.push(...
|
|
3105
|
+
for (const I of v)
|
|
3106
|
+
ie.push(...Se(I, Le));
|
|
3057
3107
|
const Ne = De.flatMap((I) => I.lines);
|
|
3058
3108
|
if (Ne.length > 0) {
|
|
3059
3109
|
const I = Ne.slice(0, 20);
|
|
3060
3110
|
Ne.length > I.length && I.push("… shadow DOM omitted");
|
|
3061
|
-
const E =
|
|
3062
|
-
if (
|
|
3063
|
-
const j = qe ? "#shadow-root" : `${
|
|
3064
|
-
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));
|
|
3065
3115
|
} else
|
|
3066
|
-
ie.push(...
|
|
3116
|
+
ie.push(...Se(I, Le));
|
|
3067
3117
|
}
|
|
3068
3118
|
return {
|
|
3069
3119
|
lines: ie,
|
|
3070
3120
|
hasUsefulContent: Oe,
|
|
3071
3121
|
textPreview: dt,
|
|
3072
|
-
containsTextElement: n.has(
|
|
3122
|
+
containsTextElement: n.has(P) || ge.some((I) => I.containsTextElement)
|
|
3073
3123
|
};
|
|
3074
3124
|
};
|
|
3075
|
-
return [`--- ${
|
|
3125
|
+
return [`--- ${U} ---`, ...T(S, 0).lines].join(`
|
|
3076
3126
|
`);
|
|
3077
|
-
},
|
|
3078
|
-
|
|
3079
|
-
${JSON.stringify(
|
|
3080
|
-
for (const
|
|
3081
|
-
|
|
3082
|
-
if (e &&
|
|
3083
|
-
const
|
|
3084
|
-
|
|
3085
|
-
}
|
|
3086
|
-
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(`
|
|
3087
3137
|
|
|
3088
3138
|
`);
|
|
3089
3139
|
}
|
|
3090
|
-
function
|
|
3140
|
+
function Zt(t, e, s, n) {
|
|
3091
3141
|
const r = t.tagName.toLowerCase();
|
|
3092
3142
|
let i = r;
|
|
3093
3143
|
const o = t.getAttribute("id");
|
|
3094
|
-
o &&
|
|
3144
|
+
o && sr(o) && (i += `#${o}`);
|
|
3095
3145
|
for (const a of e) {
|
|
3096
3146
|
const l = t.getAttribute(a);
|
|
3097
3147
|
l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
|
|
@@ -3104,7 +3154,7 @@ function Xt(t, e, s, n) {
|
|
|
3104
3154
|
t.hasAttribute(a) && (i += `[${a}]`);
|
|
3105
3155
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
3106
3156
|
}
|
|
3107
|
-
function
|
|
3157
|
+
function er() {
|
|
3108
3158
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
|
|
3109
3159
|
if (!a)
|
|
3110
3160
|
return;
|
|
@@ -3116,8 +3166,8 @@ function Vn() {
|
|
|
3116
3166
|
let h = a;
|
|
3117
3167
|
for (; h; ) {
|
|
3118
3168
|
t.add(h);
|
|
3119
|
-
const
|
|
3120
|
-
h = h.parentElement ?? (
|
|
3169
|
+
const g = h.getRootNode();
|
|
3170
|
+
h = h.parentElement ?? (g instanceof ShadowRoot && g.host instanceof HTMLElement ? g.host : null);
|
|
3121
3171
|
}
|
|
3122
3172
|
};
|
|
3123
3173
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -3125,7 +3175,7 @@ function Vn() {
|
|
|
3125
3175
|
n = n.shadowRoot.activeElement;
|
|
3126
3176
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
3127
3177
|
const r = window.getSelection();
|
|
3128
|
-
r && !r.isCollapsed && (s(
|
|
3178
|
+
r && !r.isCollapsed && (s(_t(r.anchorNode), "selected text"), s(_t(r.focusNode), "selected text"));
|
|
3129
3179
|
const i = [
|
|
3130
3180
|
["[aria-selected='true']", "selected"],
|
|
3131
3181
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -3147,7 +3197,7 @@ function Vn() {
|
|
|
3147
3197
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
3148
3198
|
};
|
|
3149
3199
|
}
|
|
3150
|
-
function
|
|
3200
|
+
function tr(t, e, s, n) {
|
|
3151
3201
|
const r = ["--- active/current elements ---"];
|
|
3152
3202
|
for (const i of t) {
|
|
3153
3203
|
const o = [];
|
|
@@ -3158,36 +3208,36 @@ function Xn(t, e, s, n) {
|
|
|
3158
3208
|
const h = a.getRootNode();
|
|
3159
3209
|
a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
|
|
3160
3210
|
}
|
|
3161
|
-
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(
|
|
3162
3212
|
d,
|
|
3163
3213
|
s,
|
|
3164
3214
|
n,
|
|
3165
|
-
h === l.length - 1 ?
|
|
3215
|
+
h === l.length - 1 ? es(d).slice(0, 180) : ""
|
|
3166
3216
|
));
|
|
3167
3217
|
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
3168
3218
|
}
|
|
3169
3219
|
return r.join(`
|
|
3170
3220
|
`);
|
|
3171
3221
|
}
|
|
3172
|
-
function
|
|
3222
|
+
function _t(t) {
|
|
3173
3223
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
3174
3224
|
}
|
|
3175
|
-
function
|
|
3225
|
+
function Se(t, e) {
|
|
3176
3226
|
if (e === 0)
|
|
3177
3227
|
return t;
|
|
3178
3228
|
const s = " ".repeat(e);
|
|
3179
3229
|
return t.map((n) => `${s}${n}`);
|
|
3180
3230
|
}
|
|
3181
|
-
function
|
|
3231
|
+
function es(t) {
|
|
3182
3232
|
return te(
|
|
3183
3233
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
3184
3234
|
);
|
|
3185
3235
|
}
|
|
3186
|
-
function
|
|
3236
|
+
function sr(t) {
|
|
3187
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);
|
|
3188
3238
|
}
|
|
3189
|
-
function
|
|
3190
|
-
const t = document.querySelector(
|
|
3239
|
+
function ts() {
|
|
3240
|
+
const t = document.querySelector(mt);
|
|
3191
3241
|
if (!(t ?? document.querySelector(Xe)))
|
|
3192
3242
|
return;
|
|
3193
3243
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
@@ -3197,28 +3247,28 @@ function Qt() {
|
|
|
3197
3247
|
selectors: [
|
|
3198
3248
|
{
|
|
3199
3249
|
name: "widget_host",
|
|
3200
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
3250
|
+
selector: s === "browser_extension_sdk_preview" ? mt : Xe,
|
|
3201
3251
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
3202
3252
|
},
|
|
3203
3253
|
{
|
|
3204
3254
|
name: "widget_root",
|
|
3205
|
-
selector:
|
|
3255
|
+
selector: tn,
|
|
3206
3256
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
3207
3257
|
},
|
|
3208
3258
|
{
|
|
3209
3259
|
name: "widget_panel",
|
|
3210
|
-
selector:
|
|
3260
|
+
selector: sn,
|
|
3211
3261
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
3212
3262
|
},
|
|
3213
3263
|
{
|
|
3214
3264
|
name: "widget_timeline",
|
|
3215
|
-
selector:
|
|
3265
|
+
selector: nn,
|
|
3216
3266
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
3217
3267
|
}
|
|
3218
3268
|
]
|
|
3219
3269
|
};
|
|
3220
3270
|
}
|
|
3221
|
-
function
|
|
3271
|
+
function nr(t) {
|
|
3222
3272
|
try {
|
|
3223
3273
|
const e = JSON.parse(t);
|
|
3224
3274
|
return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
|
|
@@ -3226,7 +3276,7 @@ function Qn(t) {
|
|
|
3226
3276
|
return { type: "error", message: "Invalid server event" };
|
|
3227
3277
|
}
|
|
3228
3278
|
}
|
|
3229
|
-
function
|
|
3279
|
+
function rr(t) {
|
|
3230
3280
|
if (typeof t != "string")
|
|
3231
3281
|
return null;
|
|
3232
3282
|
try {
|
|
@@ -3236,13 +3286,13 @@ function Yn(t) {
|
|
|
3236
3286
|
return null;
|
|
3237
3287
|
}
|
|
3238
3288
|
}
|
|
3239
|
-
function
|
|
3289
|
+
function Pt(t, e) {
|
|
3240
3290
|
if (!t || typeof t != "object")
|
|
3241
3291
|
return [];
|
|
3242
3292
|
const s = t[e];
|
|
3243
3293
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
3244
3294
|
}
|
|
3245
|
-
function
|
|
3295
|
+
function Ut(t) {
|
|
3246
3296
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3247
3297
|
if (!e || typeof e != "object")
|
|
3248
3298
|
return [];
|
|
@@ -3250,10 +3300,10 @@ function Pt(t) {
|
|
|
3250
3300
|
return typeof s.taskId != "string" || !s.taskId || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? [] : [{ taskId: s.taskId, dueAt: s.dueAt }];
|
|
3251
3301
|
}) : [];
|
|
3252
3302
|
}
|
|
3253
|
-
function
|
|
3303
|
+
function ir(t) {
|
|
3254
3304
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
3255
3305
|
}
|
|
3256
|
-
function
|
|
3306
|
+
function or(t) {
|
|
3257
3307
|
if (!t || typeof t != "object")
|
|
3258
3308
|
return null;
|
|
3259
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;
|
|
@@ -3264,13 +3314,13 @@ function er(t) {
|
|
|
3264
3314
|
...a !== null ? { scribbleStyle: a } : {}
|
|
3265
3315
|
};
|
|
3266
3316
|
}
|
|
3267
|
-
function
|
|
3317
|
+
function ar(t) {
|
|
3268
3318
|
if (!t || typeof t != "object")
|
|
3269
3319
|
return null;
|
|
3270
3320
|
const e = t.javascript;
|
|
3271
3321
|
return typeof e != "string" || !e.trim() ? null : { javascript: e };
|
|
3272
3322
|
}
|
|
3273
|
-
function
|
|
3323
|
+
function lr(t, e) {
|
|
3274
3324
|
return e ? t && typeof t == "object" ? {
|
|
3275
3325
|
...t,
|
|
3276
3326
|
helperError: e
|
|
@@ -3280,23 +3330,23 @@ function sr(t, e) {
|
|
|
3280
3330
|
helperError: e
|
|
3281
3331
|
} : t;
|
|
3282
3332
|
}
|
|
3283
|
-
function
|
|
3333
|
+
function cr(t) {
|
|
3284
3334
|
if (!t || typeof t != "object")
|
|
3285
3335
|
return t;
|
|
3286
3336
|
const e = t;
|
|
3287
3337
|
return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : t;
|
|
3288
3338
|
}
|
|
3289
|
-
function
|
|
3339
|
+
function ur() {
|
|
3290
3340
|
const t = "pluno.productAgent.clientId", e = window.localStorage.getItem(t);
|
|
3291
3341
|
if (e)
|
|
3292
3342
|
return e;
|
|
3293
3343
|
const s = crypto.randomUUID();
|
|
3294
3344
|
return window.localStorage.setItem(t, s), s;
|
|
3295
3345
|
}
|
|
3296
|
-
function
|
|
3346
|
+
function N() {
|
|
3297
3347
|
return crypto.randomUUID();
|
|
3298
3348
|
}
|
|
3299
|
-
function
|
|
3349
|
+
function dr(t) {
|
|
3300
3350
|
if (!t || typeof t != "object")
|
|
3301
3351
|
return null;
|
|
3302
3352
|
const e = t, s = typeof e.id == "string" ? e.id : null;
|
|
@@ -3307,22 +3357,22 @@ function ir(t) {
|
|
|
3307
3357
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
3308
3358
|
} : null;
|
|
3309
3359
|
}
|
|
3310
|
-
function
|
|
3360
|
+
function vt(t, e) {
|
|
3311
3361
|
return Array.isArray(t) ? et(
|
|
3312
|
-
t.map((s) =>
|
|
3362
|
+
t.map((s) => ss(s, e)).filter((s) => s !== null)
|
|
3313
3363
|
) : [];
|
|
3314
3364
|
}
|
|
3315
|
-
function
|
|
3365
|
+
function pr(t) {
|
|
3316
3366
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3317
3367
|
if (!e || typeof e != "object")
|
|
3318
3368
|
return [];
|
|
3319
|
-
const s = e, n =
|
|
3369
|
+
const s = e, n = M(s, "id"), r = M(s, "createdAt"), i = M(s, "updatedAt"), o = M(s, "lastActiveAt");
|
|
3320
3370
|
return !n || !r || !i || !o ? [] : [
|
|
3321
3371
|
{
|
|
3322
3372
|
id: n,
|
|
3323
|
-
title:
|
|
3324
|
-
customTitle:
|
|
3325
|
-
firstUserMessage:
|
|
3373
|
+
title: M(s, "title"),
|
|
3374
|
+
customTitle: M(s, "customTitle"),
|
|
3375
|
+
firstUserMessage: M(s, "firstUserMessage"),
|
|
3326
3376
|
currentPage: s.currentPage ?? null,
|
|
3327
3377
|
createdAt: r,
|
|
3328
3378
|
updatedAt: i,
|
|
@@ -3333,29 +3383,29 @@ function or(t) {
|
|
|
3333
3383
|
];
|
|
3334
3384
|
}) : [];
|
|
3335
3385
|
}
|
|
3336
|
-
function
|
|
3386
|
+
function ss(t, e) {
|
|
3337
3387
|
if (!t || typeof t != "object")
|
|
3338
3388
|
return null;
|
|
3339
3389
|
const s = t, n = s.data;
|
|
3340
3390
|
if (!n || typeof n != "object")
|
|
3341
3391
|
return null;
|
|
3342
3392
|
const r = n;
|
|
3343
|
-
if (r.hiddenFromTranscript === !0 ||
|
|
3393
|
+
if (r.hiddenFromTranscript === !0 || Ls(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
3344
3394
|
return null;
|
|
3345
3395
|
if (r.type === "message") {
|
|
3346
3396
|
const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
|
|
3347
3397
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3348
3398
|
role: i,
|
|
3349
3399
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
3350
|
-
content:
|
|
3351
|
-
|
|
3400
|
+
content: Us(
|
|
3401
|
+
Tr(r.content),
|
|
3352
3402
|
e
|
|
3353
3403
|
),
|
|
3354
3404
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3355
|
-
...
|
|
3356
|
-
respondsToUserMessageId:
|
|
3405
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3406
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3357
3407
|
...C(r) ? { runId: C(r) } : {},
|
|
3358
|
-
attachments:
|
|
3408
|
+
attachments: ps(r.attachments, e)
|
|
3359
3409
|
};
|
|
3360
3410
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
3361
3411
|
value: r.id,
|
|
@@ -3369,43 +3419,43 @@ function Yt(t, e) {
|
|
|
3369
3419
|
}), o;
|
|
3370
3420
|
}
|
|
3371
3421
|
if (r.type === "function_call_output") {
|
|
3372
|
-
const i =
|
|
3422
|
+
const i = Ds(r.output);
|
|
3373
3423
|
if (i !== null)
|
|
3374
3424
|
return {
|
|
3375
3425
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3376
3426
|
role: "tool",
|
|
3377
3427
|
content: "",
|
|
3378
3428
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3379
|
-
respondsToUserMessageId:
|
|
3429
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3380
3430
|
...C(r) ? { runId: C(r) } : {},
|
|
3381
3431
|
dataType: "function_call_output",
|
|
3382
|
-
toolName:
|
|
3432
|
+
toolName: vs,
|
|
3383
3433
|
callId: ce(r) ?? void 0,
|
|
3384
3434
|
sharePromptAllowed: i
|
|
3385
3435
|
};
|
|
3386
|
-
const o =
|
|
3436
|
+
const o = Vs(r.output);
|
|
3387
3437
|
if (o)
|
|
3388
3438
|
return {
|
|
3389
3439
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3390
3440
|
role: "tool",
|
|
3391
3441
|
content: "",
|
|
3392
3442
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3393
|
-
respondsToUserMessageId:
|
|
3443
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3394
3444
|
...C(r) ? { runId: C(r) } : {},
|
|
3395
3445
|
dataType: "scheduled_check_in",
|
|
3396
|
-
toolName:
|
|
3446
|
+
toolName: jt,
|
|
3397
3447
|
callId: ce(r) ?? void 0,
|
|
3398
3448
|
scheduledCheckInId: o.id ?? void 0,
|
|
3399
3449
|
scheduledCheckInAt: o.dueAt
|
|
3400
3450
|
};
|
|
3401
|
-
const a =
|
|
3451
|
+
const a = gr(r.output), l = fr(r.output);
|
|
3402
3452
|
return a ? {
|
|
3403
3453
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3404
3454
|
role: "tool",
|
|
3405
3455
|
content: `Connect ${a.appName} to continue`,
|
|
3406
3456
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3407
|
-
...
|
|
3408
|
-
respondsToUserMessageId:
|
|
3457
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3458
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3409
3459
|
...C(r) ? { runId: C(r) } : {},
|
|
3410
3460
|
dataType: "function_call_output",
|
|
3411
3461
|
toolName: "authenticate_pipedream_app",
|
|
@@ -3416,8 +3466,8 @@ function Yt(t, e) {
|
|
|
3416
3466
|
role: "tool",
|
|
3417
3467
|
content: "Connect WhatsApp to continue",
|
|
3418
3468
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3419
|
-
...
|
|
3420
|
-
respondsToUserMessageId:
|
|
3469
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3470
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3421
3471
|
...C(r) ? { runId: C(r) } : {},
|
|
3422
3472
|
dataType: "function_call_output",
|
|
3423
3473
|
toolName: "request_personal_channel_connection",
|
|
@@ -3428,10 +3478,10 @@ function Yt(t, e) {
|
|
|
3428
3478
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
3429
3479
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3430
3480
|
role: "tool",
|
|
3431
|
-
content: r.type === "mcp_call" ?
|
|
3481
|
+
content: r.type === "mcp_call" ? hr(r) : yr(r),
|
|
3432
3482
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3433
|
-
...
|
|
3434
|
-
respondsToUserMessageId:
|
|
3483
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3484
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3435
3485
|
...C(r) ? { runId: C(r) } : {},
|
|
3436
3486
|
dataType: String(r.type),
|
|
3437
3487
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
@@ -3440,10 +3490,10 @@ function Yt(t, e) {
|
|
|
3440
3490
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
3441
3491
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3442
3492
|
role: "system",
|
|
3443
|
-
content:
|
|
3493
|
+
content: mr(r),
|
|
3444
3494
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3445
|
-
...
|
|
3446
|
-
respondsToUserMessageId:
|
|
3495
|
+
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3496
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3447
3497
|
...C(r) ? { runId: C(r) } : {},
|
|
3448
3498
|
dataType: String(r.type),
|
|
3449
3499
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -3452,11 +3502,11 @@ function Yt(t, e) {
|
|
|
3452
3502
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
3453
3503
|
} : null;
|
|
3454
3504
|
}
|
|
3455
|
-
function
|
|
3505
|
+
function hr(t) {
|
|
3456
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(" ");
|
|
3457
3507
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
3458
3508
|
}
|
|
3459
|
-
function
|
|
3509
|
+
function gr(t) {
|
|
3460
3510
|
if (typeof t != "string")
|
|
3461
3511
|
return null;
|
|
3462
3512
|
try {
|
|
@@ -3473,7 +3523,7 @@ function lr(t) {
|
|
|
3473
3523
|
return null;
|
|
3474
3524
|
}
|
|
3475
3525
|
}
|
|
3476
|
-
function
|
|
3526
|
+
function fr(t) {
|
|
3477
3527
|
if (typeof t != "string")
|
|
3478
3528
|
return null;
|
|
3479
3529
|
try {
|
|
@@ -3488,10 +3538,10 @@ function cr(t) {
|
|
|
3488
3538
|
return null;
|
|
3489
3539
|
}
|
|
3490
3540
|
}
|
|
3491
|
-
function
|
|
3541
|
+
function mr(t) {
|
|
3492
3542
|
return t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message : "";
|
|
3493
3543
|
}
|
|
3494
|
-
function
|
|
3544
|
+
function yr(t) {
|
|
3495
3545
|
if (t.type === "web_search_call") {
|
|
3496
3546
|
const e = t.action;
|
|
3497
3547
|
if (e && typeof e == "object") {
|
|
@@ -3503,9 +3553,9 @@ function dr(t) {
|
|
|
3503
3553
|
}
|
|
3504
3554
|
return "🔎 Searching the web";
|
|
3505
3555
|
}
|
|
3506
|
-
return
|
|
3556
|
+
return Ir(t);
|
|
3507
3557
|
}
|
|
3508
|
-
function
|
|
3558
|
+
function Ir(t) {
|
|
3509
3559
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3510
3560
|
return ee(t.summary);
|
|
3511
3561
|
if (typeof t.arguments == "string")
|
|
@@ -3522,7 +3572,7 @@ function ee(t) {
|
|
|
3522
3572
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3523
3573
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3524
3574
|
}
|
|
3525
|
-
function
|
|
3575
|
+
function Sr(t) {
|
|
3526
3576
|
if (t == null)
|
|
3527
3577
|
return t;
|
|
3528
3578
|
if (typeof t != "object")
|
|
@@ -3541,10 +3591,10 @@ function ce(t) {
|
|
|
3541
3591
|
const e = t.callId ?? t.call_id;
|
|
3542
3592
|
return typeof e == "string" && e ? e : null;
|
|
3543
3593
|
}
|
|
3544
|
-
function
|
|
3594
|
+
function D(t) {
|
|
3545
3595
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
3546
3596
|
}
|
|
3547
|
-
function
|
|
3597
|
+
function Tr(t) {
|
|
3548
3598
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
3549
3599
|
if (!e || typeof e != "object")
|
|
3550
3600
|
return "";
|
|
@@ -3553,10 +3603,10 @@ function gr(t) {
|
|
|
3553
3603
|
}).filter(Boolean).join("") : "";
|
|
3554
3604
|
}
|
|
3555
3605
|
function Qe(t, e) {
|
|
3556
|
-
const s =
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3606
|
+
const s = is(t, e), n = Cr(
|
|
3607
|
+
Mr(
|
|
3608
|
+
vr(
|
|
3609
|
+
wr(t, e),
|
|
3560
3610
|
e
|
|
3561
3611
|
),
|
|
3562
3612
|
s
|
|
@@ -3570,7 +3620,7 @@ function Qe(t, e) {
|
|
|
3570
3620
|
const i = [...n];
|
|
3571
3621
|
return i[r] = s, et(i);
|
|
3572
3622
|
}
|
|
3573
|
-
function
|
|
3623
|
+
function wr(t, e) {
|
|
3574
3624
|
const s = e.proactiveSuggestionClientMessageId;
|
|
3575
3625
|
if (!s)
|
|
3576
3626
|
return t;
|
|
@@ -3580,7 +3630,7 @@ function fr(t, e) {
|
|
|
3580
3630
|
const i = [...t];
|
|
3581
3631
|
return i[r] = e, i;
|
|
3582
3632
|
}
|
|
3583
|
-
function
|
|
3633
|
+
function Mr(t, e) {
|
|
3584
3634
|
const s = e.assistantDraftItemId;
|
|
3585
3635
|
return s ? t.map(
|
|
3586
3636
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
@@ -3589,7 +3639,7 @@ function mr(t, e) {
|
|
|
3589
3639
|
function Ke(t, e, s) {
|
|
3590
3640
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3591
3641
|
}
|
|
3592
|
-
function
|
|
3642
|
+
function Ar(t, e, s, n) {
|
|
3593
3643
|
if (s === null) return t;
|
|
3594
3644
|
let r = -1;
|
|
3595
3645
|
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
@@ -3606,7 +3656,7 @@ function yr(t, e, s, n) {
|
|
|
3606
3656
|
respondsToUserMessageId: s
|
|
3607
3657
|
}, i;
|
|
3608
3658
|
}
|
|
3609
|
-
function
|
|
3659
|
+
function Rr(t, e) {
|
|
3610
3660
|
const s = t.findIndex(
|
|
3611
3661
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3612
3662
|
);
|
|
@@ -3623,12 +3673,12 @@ function Ir(t, e) {
|
|
|
3623
3673
|
...n[s].runId ? {} : { runId: e.runId }
|
|
3624
3674
|
}, n;
|
|
3625
3675
|
}
|
|
3626
|
-
function
|
|
3676
|
+
function Er(t, e, s) {
|
|
3627
3677
|
let n = !1;
|
|
3628
3678
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
3629
3679
|
return n ? r : t;
|
|
3630
3680
|
}
|
|
3631
|
-
function
|
|
3681
|
+
function kr(t) {
|
|
3632
3682
|
if (t.hiddenFromTranscript === !0)
|
|
3633
3683
|
return null;
|
|
3634
3684
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
@@ -3648,7 +3698,7 @@ function Tr(t) {
|
|
|
3648
3698
|
loading: !0
|
|
3649
3699
|
};
|
|
3650
3700
|
}
|
|
3651
|
-
function
|
|
3701
|
+
function Cr(t, e) {
|
|
3652
3702
|
if (e.id.startsWith("transient-activity:"))
|
|
3653
3703
|
return t;
|
|
3654
3704
|
const s = e.toolName === "tab_lifecycle";
|
|
@@ -3657,32 +3707,32 @@ function wr(t, e) {
|
|
|
3657
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);
|
|
3658
3708
|
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
3659
3709
|
}
|
|
3660
|
-
function
|
|
3661
|
-
return
|
|
3710
|
+
function ns(t, e) {
|
|
3711
|
+
return Ns(
|
|
3662
3712
|
t,
|
|
3663
3713
|
e.map(
|
|
3664
|
-
(s) =>
|
|
3714
|
+
(s) => is(t, s)
|
|
3665
3715
|
),
|
|
3666
|
-
|
|
3716
|
+
rs
|
|
3667
3717
|
);
|
|
3668
3718
|
}
|
|
3669
|
-
function
|
|
3719
|
+
function br(t, e) {
|
|
3670
3720
|
const s = new Map(t.map((n) => [n.id, n]));
|
|
3671
3721
|
for (const n of e)
|
|
3672
3722
|
s.set(n.id, n);
|
|
3673
|
-
return
|
|
3723
|
+
return ns(
|
|
3674
3724
|
t,
|
|
3675
3725
|
[...s.values()]
|
|
3676
|
-
).sort(
|
|
3726
|
+
).sort(_r);
|
|
3677
3727
|
}
|
|
3678
|
-
function
|
|
3728
|
+
function _r(t, e) {
|
|
3679
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)
|
|
3680
3730
|
return t.causalSequence - e.causalSequence;
|
|
3681
3731
|
const n = Date.parse(t.createdAt) - Date.parse(e.createdAt);
|
|
3682
3732
|
return Number.isNaN(n) ? 0 : n;
|
|
3683
3733
|
}
|
|
3684
|
-
function
|
|
3685
|
-
const e =
|
|
3734
|
+
function rs(t) {
|
|
3735
|
+
const e = V(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3686
3736
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3687
3737
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3688
3738
|
];
|
|
@@ -3693,55 +3743,55 @@ function es(t) {
|
|
|
3693
3743
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3694
3744
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3695
3745
|
...t.runId ? { runId: t.runId } : {},
|
|
3696
|
-
isOptimistic:
|
|
3746
|
+
isOptimistic: Ue(t),
|
|
3697
3747
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3698
3748
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3699
3749
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3700
3750
|
};
|
|
3701
3751
|
}
|
|
3702
|
-
function
|
|
3752
|
+
function is(t, e) {
|
|
3703
3753
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3704
3754
|
return e;
|
|
3705
3755
|
const s = t.find(
|
|
3706
|
-
(o) => o.role === "user" && (o.id === e.id ||
|
|
3756
|
+
(o) => o.role === "user" && (o.id === e.id || Ue(o) && os(o, e))
|
|
3707
3757
|
);
|
|
3708
3758
|
if (!s?.attachments?.length)
|
|
3709
3759
|
return e;
|
|
3710
3760
|
const n = e.attachments.map((o) => {
|
|
3711
|
-
const a =
|
|
3712
|
-
return a ?
|
|
3713
|
-
}), 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);
|
|
3714
3764
|
return i && Object.defineProperty(r, "clientMessageId", {
|
|
3715
3765
|
value: i,
|
|
3716
3766
|
enumerable: !1
|
|
3717
3767
|
}), r;
|
|
3718
3768
|
}
|
|
3719
|
-
function
|
|
3769
|
+
function Pr(t, e) {
|
|
3720
3770
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
3721
3771
|
}
|
|
3722
|
-
function
|
|
3772
|
+
function Ur(t, e) {
|
|
3723
3773
|
const { previewUrl: s } = e;
|
|
3724
3774
|
return s ? { ...t, previewUrl: s } : t;
|
|
3725
3775
|
}
|
|
3726
|
-
function
|
|
3776
|
+
function vr(t, e) {
|
|
3727
3777
|
if (e.role !== "user")
|
|
3728
3778
|
return t;
|
|
3729
3779
|
const s = t.findIndex(
|
|
3730
|
-
(r) =>
|
|
3780
|
+
(r) => Ue(r) && os(r, e)
|
|
3731
3781
|
);
|
|
3732
3782
|
if (s === -1)
|
|
3733
3783
|
return t;
|
|
3734
3784
|
const n = [...t];
|
|
3735
3785
|
return n.splice(s, 1), n;
|
|
3736
3786
|
}
|
|
3737
|
-
function
|
|
3738
|
-
const s =
|
|
3787
|
+
function os(t, e) {
|
|
3788
|
+
const s = V(t), n = V(e);
|
|
3739
3789
|
return s && n ? s === n : t.content === e.content;
|
|
3740
3790
|
}
|
|
3741
|
-
function
|
|
3791
|
+
function Ue(t) {
|
|
3742
3792
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3743
3793
|
}
|
|
3744
|
-
function
|
|
3794
|
+
function V(t) {
|
|
3745
3795
|
const e = t.clientMessageId;
|
|
3746
3796
|
if (e)
|
|
3747
3797
|
return e;
|
|
@@ -3750,19 +3800,19 @@ function X(t) {
|
|
|
3750
3800
|
);
|
|
3751
3801
|
return n ? t.id.slice(n.length) : null;
|
|
3752
3802
|
}
|
|
3753
|
-
function
|
|
3754
|
-
const e =
|
|
3803
|
+
function Dt(t) {
|
|
3804
|
+
const e = as(t);
|
|
3755
3805
|
if (e === null)
|
|
3756
3806
|
return !1;
|
|
3757
3807
|
const s = t[e].id;
|
|
3758
3808
|
if (t.some(
|
|
3759
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3809
|
+
(r) => r.respondsToUserMessageId === s && Ee(r)
|
|
3760
3810
|
))
|
|
3761
3811
|
return !0;
|
|
3762
3812
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3763
3813
|
const i = t[r];
|
|
3764
3814
|
if (!i.respondsToUserMessageId) {
|
|
3765
|
-
if (
|
|
3815
|
+
if (H(i))
|
|
3766
3816
|
return !0;
|
|
3767
3817
|
if (i.role === "system") {
|
|
3768
3818
|
if (i.dataType === "run_error")
|
|
@@ -3774,10 +3824,10 @@ function vt(t) {
|
|
|
3774
3824
|
}
|
|
3775
3825
|
return !1;
|
|
3776
3826
|
}
|
|
3777
|
-
function
|
|
3827
|
+
function Dr(t, e, s) {
|
|
3778
3828
|
const n = new Set(
|
|
3779
3829
|
t.filter(
|
|
3780
|
-
(r) => r.role === "user" && e !== null &&
|
|
3830
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3781
3831
|
).map((r) => r.id)
|
|
3782
3832
|
);
|
|
3783
3833
|
return t.some((r, i) => {
|
|
@@ -3788,29 +3838,29 @@ function Cr(t, e, s) {
|
|
|
3788
3838
|
if (s && r.runId === s) {
|
|
3789
3839
|
if (n.size === 0)
|
|
3790
3840
|
return !0;
|
|
3791
|
-
const o =
|
|
3841
|
+
const o = ls(t, i);
|
|
3792
3842
|
return !r.respondsToUserMessageId && o !== null && n.has(o);
|
|
3793
3843
|
}
|
|
3794
3844
|
return !1;
|
|
3795
3845
|
});
|
|
3796
3846
|
}
|
|
3797
|
-
function
|
|
3798
|
-
const e =
|
|
3847
|
+
function Or(t) {
|
|
3848
|
+
const e = as(t);
|
|
3799
3849
|
if (e === null)
|
|
3800
|
-
return t.some(
|
|
3850
|
+
return t.some(H);
|
|
3801
3851
|
const s = t[e].id;
|
|
3802
3852
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3803
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3804
|
-
) : t.slice(e + 1).some(
|
|
3853
|
+
(n) => n.respondsToUserMessageId === s && H(n)
|
|
3854
|
+
) : t.slice(e + 1).some(H);
|
|
3805
3855
|
}
|
|
3806
|
-
function
|
|
3856
|
+
function as(t) {
|
|
3807
3857
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3808
|
-
if (t[e].role === "user" && !
|
|
3858
|
+
if (t[e].role === "user" && !Ue(t[e]))
|
|
3809
3859
|
return e;
|
|
3810
3860
|
return null;
|
|
3811
3861
|
}
|
|
3812
|
-
function
|
|
3813
|
-
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;
|
|
3814
3864
|
}
|
|
3815
3865
|
function se(t) {
|
|
3816
3866
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
@@ -3826,29 +3876,29 @@ function se(t) {
|
|
|
3826
3876
|
}
|
|
3827
3877
|
return null;
|
|
3828
3878
|
}
|
|
3829
|
-
function
|
|
3879
|
+
function qr(t) {
|
|
3830
3880
|
const e = se(t);
|
|
3831
3881
|
if (e === null)
|
|
3832
3882
|
return null;
|
|
3833
|
-
const n =
|
|
3883
|
+
const n = _(t[e])?.page;
|
|
3834
3884
|
if (!n || typeof n != "object")
|
|
3835
3885
|
return null;
|
|
3836
3886
|
const r = n.url;
|
|
3837
3887
|
return typeof r == "string" ? r : null;
|
|
3838
3888
|
}
|
|
3839
|
-
function
|
|
3889
|
+
function _(t) {
|
|
3840
3890
|
if (!t || typeof t != "object")
|
|
3841
3891
|
return null;
|
|
3842
3892
|
const e = t.data;
|
|
3843
3893
|
return e && typeof e == "object" ? e : null;
|
|
3844
3894
|
}
|
|
3845
|
-
function
|
|
3895
|
+
function ke(t) {
|
|
3846
3896
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3847
3897
|
}
|
|
3848
|
-
function
|
|
3898
|
+
function Ot(t) {
|
|
3849
3899
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3850
3900
|
}
|
|
3851
|
-
function
|
|
3901
|
+
function Lr(t, e) {
|
|
3852
3902
|
const s = se(e);
|
|
3853
3903
|
if (s === null)
|
|
3854
3904
|
return !1;
|
|
@@ -3857,8 +3907,8 @@ function Pr(t, e) {
|
|
|
3857
3907
|
return !1;
|
|
3858
3908
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3859
3909
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3860
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3861
|
-
) : t.slice(i + 1).some(
|
|
3910
|
+
(o) => o.respondsToUserMessageId === r && Ee(o)
|
|
3911
|
+
) : t.slice(i + 1).some(Ee);
|
|
3862
3912
|
}
|
|
3863
3913
|
function Ye(t) {
|
|
3864
3914
|
const e = se(t);
|
|
@@ -3873,7 +3923,7 @@ function Ye(t) {
|
|
|
3873
3923
|
const r = n.clientMessageId;
|
|
3874
3924
|
return typeof r == "string" ? r : null;
|
|
3875
3925
|
}
|
|
3876
|
-
function
|
|
3926
|
+
function Nr(t) {
|
|
3877
3927
|
const e = se(t);
|
|
3878
3928
|
if (e === null)
|
|
3879
3929
|
return null;
|
|
@@ -3897,13 +3947,13 @@ function Ur(t) {
|
|
|
3897
3947
|
function Ze(t, e) {
|
|
3898
3948
|
if (typeof e.clientMessageId == "string")
|
|
3899
3949
|
return e.clientMessageId;
|
|
3900
|
-
const s =
|
|
3950
|
+
const s = q(e);
|
|
3901
3951
|
if (!s)
|
|
3902
3952
|
return null;
|
|
3903
|
-
const n = t.find((i) =>
|
|
3953
|
+
const n = t.find((i) => M(i, "id") === s), r = _(n);
|
|
3904
3954
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3905
3955
|
}
|
|
3906
|
-
function
|
|
3956
|
+
function xr(t, e) {
|
|
3907
3957
|
let s = 0;
|
|
3908
3958
|
for (const n of t) {
|
|
3909
3959
|
if (!n || typeof n != "object")
|
|
@@ -3916,91 +3966,91 @@ function vr(t, e) {
|
|
|
3916
3966
|
}
|
|
3917
3967
|
return s;
|
|
3918
3968
|
}
|
|
3919
|
-
function
|
|
3920
|
-
if (!e || !
|
|
3969
|
+
function qt(t, e, s, n, r, i) {
|
|
3970
|
+
if (!e || !Wr(t))
|
|
3921
3971
|
return !1;
|
|
3922
3972
|
const o = t;
|
|
3923
|
-
if (
|
|
3973
|
+
if (ke(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3924
3974
|
return !1;
|
|
3925
|
-
const a =
|
|
3975
|
+
const a = q(o);
|
|
3926
3976
|
return n !== null ? a !== null ? a === n : r !== null && C(o) === r && i === n : r === null || C(o) === r;
|
|
3927
3977
|
}
|
|
3928
|
-
function
|
|
3978
|
+
function Br(t, e) {
|
|
3929
3979
|
for (let s = e - 1; s >= 0; s -= 1) {
|
|
3930
|
-
const n =
|
|
3980
|
+
const n = _(t[s]);
|
|
3931
3981
|
if (n?.type === "message" && n.role === "user")
|
|
3932
|
-
return
|
|
3982
|
+
return M(t[s], "id");
|
|
3933
3983
|
}
|
|
3934
3984
|
return null;
|
|
3935
3985
|
}
|
|
3936
|
-
function
|
|
3986
|
+
function ls(t, e) {
|
|
3937
3987
|
for (let s = e - 1; s >= 0; s -= 1)
|
|
3938
3988
|
if (t[s].role === "user")
|
|
3939
3989
|
return t[s].id;
|
|
3940
3990
|
return null;
|
|
3941
3991
|
}
|
|
3942
|
-
function
|
|
3992
|
+
function Wr(t) {
|
|
3943
3993
|
if (!t || typeof t != "object")
|
|
3944
3994
|
return !1;
|
|
3945
3995
|
const e = t;
|
|
3946
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");
|
|
3947
3997
|
}
|
|
3948
|
-
function
|
|
3998
|
+
function H(t) {
|
|
3949
3999
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3950
4000
|
}
|
|
3951
|
-
function
|
|
4001
|
+
function Hr(t) {
|
|
3952
4002
|
if (!t || typeof t != "object")
|
|
3953
4003
|
return !1;
|
|
3954
4004
|
const e = t;
|
|
3955
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";
|
|
3956
4006
|
}
|
|
3957
4007
|
function et(t) {
|
|
3958
|
-
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);
|
|
3959
4009
|
}
|
|
3960
|
-
function
|
|
4010
|
+
function $r(t) {
|
|
3961
4011
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3962
4012
|
}
|
|
3963
|
-
function
|
|
4013
|
+
function X(t) {
|
|
3964
4014
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3965
4015
|
}
|
|
3966
|
-
function
|
|
4016
|
+
function Fr(t, e, s, n) {
|
|
3967
4017
|
const r = t.findIndex(
|
|
3968
|
-
(l, c) =>
|
|
4018
|
+
(l, c) => X(l) && !cs(t, c)
|
|
3969
4019
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3970
4020
|
(l) => l.role === "user" && l.id === o
|
|
3971
4021
|
) : null;
|
|
3972
4022
|
return {
|
|
3973
|
-
clientMessageId: a ?
|
|
4023
|
+
clientMessageId: a ? V(a) : o ? null : n,
|
|
3974
4024
|
respondsToUserMessageId: o,
|
|
3975
4025
|
runId: s ?? i?.runId ?? null
|
|
3976
4026
|
};
|
|
3977
4027
|
}
|
|
3978
|
-
function
|
|
4028
|
+
function Ae(t) {
|
|
3979
4029
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3980
4030
|
}
|
|
3981
|
-
function
|
|
3982
|
-
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;
|
|
3983
4033
|
}
|
|
3984
|
-
function
|
|
4034
|
+
function Lt(t, e, s) {
|
|
3985
4035
|
const n = new Set(
|
|
3986
4036
|
t.filter(
|
|
3987
|
-
(r) => r.role === "user" && e !== null &&
|
|
4037
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3988
4038
|
).map((r) => r.id)
|
|
3989
4039
|
);
|
|
3990
4040
|
return t.filter(
|
|
3991
|
-
(r) => !
|
|
4041
|
+
(r) => !X(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3992
4042
|
);
|
|
3993
4043
|
}
|
|
3994
|
-
function
|
|
4044
|
+
function cs(t, e) {
|
|
3995
4045
|
return t.some(
|
|
3996
|
-
(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(
|
|
3997
4047
|
t,
|
|
3998
4048
|
e,
|
|
3999
4049
|
n
|
|
4000
4050
|
)
|
|
4001
4051
|
);
|
|
4002
4052
|
}
|
|
4003
|
-
function
|
|
4053
|
+
function zr(t, e, s) {
|
|
4004
4054
|
const n = t[e], r = t[s];
|
|
4005
4055
|
if (de(n, r))
|
|
4006
4056
|
return !0;
|
|
@@ -4011,26 +4061,26 @@ function Br(t, e, s) {
|
|
|
4011
4061
|
return t[i].id === n.respondsToUserMessageId;
|
|
4012
4062
|
return !1;
|
|
4013
4063
|
}
|
|
4014
|
-
function
|
|
4064
|
+
function Kr(t, e) {
|
|
4015
4065
|
const s = [...t].reverse().find(
|
|
4016
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
4066
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Nt(n) && !Gr(
|
|
4017
4067
|
t,
|
|
4018
4068
|
n.respondsToUserMessageId
|
|
4019
4069
|
)
|
|
4020
4070
|
)?.respondsToUserMessageId;
|
|
4021
4071
|
return s ? t.map(
|
|
4022
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
4072
|
+
(n) => n.respondsToUserMessageId === s && Nt(n) ? { ...n, steered: !0 } : n
|
|
4023
4073
|
) : t;
|
|
4024
4074
|
}
|
|
4025
|
-
function
|
|
4026
|
-
return t.role === "tool" ||
|
|
4075
|
+
function Nt(t) {
|
|
4076
|
+
return t.role === "tool" || X(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
4027
4077
|
}
|
|
4028
|
-
function
|
|
4078
|
+
function Gr(t, e) {
|
|
4029
4079
|
return t.some(
|
|
4030
|
-
(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))
|
|
4031
4081
|
);
|
|
4032
4082
|
}
|
|
4033
|
-
function
|
|
4083
|
+
function Vr(t, e) {
|
|
4034
4084
|
const s = t[e];
|
|
4035
4085
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
4036
4086
|
const r = t[n];
|
|
@@ -4039,7 +4089,7 @@ function $r(t, e) {
|
|
|
4039
4089
|
}
|
|
4040
4090
|
return !1;
|
|
4041
4091
|
}
|
|
4042
|
-
function
|
|
4092
|
+
function Xr(t, e) {
|
|
4043
4093
|
const s = t[e];
|
|
4044
4094
|
if (!s.respondsToUserMessageId)
|
|
4045
4095
|
return !1;
|
|
@@ -4047,45 +4097,45 @@ function Fr(t, e) {
|
|
|
4047
4097
|
const r = t[n];
|
|
4048
4098
|
if (r.role === "user")
|
|
4049
4099
|
return !1;
|
|
4050
|
-
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)))
|
|
4051
4101
|
return !0;
|
|
4052
4102
|
}
|
|
4053
4103
|
return !1;
|
|
4054
4104
|
}
|
|
4055
|
-
function
|
|
4105
|
+
function Jr(t, e) {
|
|
4056
4106
|
const s = t[e];
|
|
4057
4107
|
return t.some(
|
|
4058
4108
|
(n, r) => r !== e && n.role === "assistant" && de(s, n)
|
|
4059
4109
|
);
|
|
4060
4110
|
}
|
|
4061
|
-
function
|
|
4111
|
+
function Qr(t, e) {
|
|
4062
4112
|
const s = t[e];
|
|
4063
4113
|
return t.some(
|
|
4064
4114
|
(n, r) => r !== e && n.role === "tool" && de(s, n)
|
|
4065
4115
|
);
|
|
4066
4116
|
}
|
|
4067
|
-
function
|
|
4117
|
+
function Yr(t, e) {
|
|
4068
4118
|
const s = t[e];
|
|
4069
4119
|
for (let n = e + 1; n < t.length; n += 1)
|
|
4070
|
-
if (
|
|
4120
|
+
if (X(t[n]) && de(s, t[n]))
|
|
4071
4121
|
return !0;
|
|
4072
4122
|
return !1;
|
|
4073
4123
|
}
|
|
4074
4124
|
function de(t, e) {
|
|
4075
4125
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
4076
4126
|
}
|
|
4077
|
-
function
|
|
4127
|
+
function M(t, e) {
|
|
4078
4128
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
4079
4129
|
}
|
|
4080
|
-
function
|
|
4130
|
+
function Zr(t, e) {
|
|
4081
4131
|
try {
|
|
4082
|
-
const s = window.localStorage.getItem(`${
|
|
4132
|
+
const s = window.localStorage.getItem(`${Jt}${t}`);
|
|
4083
4133
|
if (!s)
|
|
4084
4134
|
return null;
|
|
4085
4135
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
4086
4136
|
if (e !== void 0 && r !== e)
|
|
4087
4137
|
return null;
|
|
4088
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
4138
|
+
const i = Array.isArray(n.messages) ? n.messages.map(ui).filter((o) => !!o) : [];
|
|
4089
4139
|
return {
|
|
4090
4140
|
sessionId: r,
|
|
4091
4141
|
messages: i
|
|
@@ -4094,23 +4144,23 @@ function Gr(t, e) {
|
|
|
4094
4144
|
return null;
|
|
4095
4145
|
}
|
|
4096
4146
|
}
|
|
4097
|
-
function
|
|
4147
|
+
function us(t) {
|
|
4098
4148
|
return t.role === "user" || t.role === "assistant" || t.dataType === "run_status" || t.dataType === "run_error";
|
|
4099
4149
|
}
|
|
4100
|
-
function
|
|
4150
|
+
function ei(t, e) {
|
|
4101
4151
|
try {
|
|
4102
4152
|
window.localStorage.setItem(
|
|
4103
|
-
`${
|
|
4153
|
+
`${Jt}${t}`,
|
|
4104
4154
|
JSON.stringify({
|
|
4105
4155
|
sessionId: e.sessionId,
|
|
4106
|
-
messages: e.messages.filter(
|
|
4156
|
+
messages: e.messages.filter(us).slice(-An).map(di)
|
|
4107
4157
|
})
|
|
4108
4158
|
);
|
|
4109
4159
|
} catch {
|
|
4110
4160
|
return;
|
|
4111
4161
|
}
|
|
4112
4162
|
}
|
|
4113
|
-
function
|
|
4163
|
+
function ti(t) {
|
|
4114
4164
|
try {
|
|
4115
4165
|
const e = window.localStorage.getItem(`${Je}${t}`);
|
|
4116
4166
|
if (!e)
|
|
@@ -4121,7 +4171,7 @@ function Xr(t) {
|
|
|
4121
4171
|
return [];
|
|
4122
4172
|
}
|
|
4123
4173
|
}
|
|
4124
|
-
function
|
|
4174
|
+
function G(t, e) {
|
|
4125
4175
|
try {
|
|
4126
4176
|
const s = e.filter(lt);
|
|
4127
4177
|
if (s.length === 0) {
|
|
@@ -4136,9 +4186,9 @@ function V(t, e) {
|
|
|
4136
4186
|
return;
|
|
4137
4187
|
}
|
|
4138
4188
|
}
|
|
4139
|
-
function
|
|
4189
|
+
function ds(t, e) {
|
|
4140
4190
|
try {
|
|
4141
|
-
const s = `${
|
|
4191
|
+
const s = `${Pe}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
4142
4192
|
...o,
|
|
4143
4193
|
storedAt: Date.now(),
|
|
4144
4194
|
unloadUrl: n,
|
|
@@ -4152,28 +4202,28 @@ function as(t, e) {
|
|
|
4152
4202
|
} catch {
|
|
4153
4203
|
}
|
|
4154
4204
|
}
|
|
4155
|
-
function
|
|
4205
|
+
function xt(t, e) {
|
|
4156
4206
|
try {
|
|
4157
|
-
if (window.sessionStorage.getItem(`${
|
|
4207
|
+
if (window.sessionStorage.getItem(`${Pe}${t}`) === null)
|
|
4158
4208
|
return;
|
|
4159
4209
|
} catch {
|
|
4160
4210
|
return;
|
|
4161
4211
|
}
|
|
4162
|
-
|
|
4212
|
+
ds(t, e);
|
|
4163
4213
|
}
|
|
4164
|
-
function
|
|
4214
|
+
function si(t) {
|
|
4165
4215
|
try {
|
|
4166
|
-
const e = `${
|
|
4216
|
+
const e = `${Pe}${t}`, s = window.sessionStorage.getItem(e);
|
|
4167
4217
|
if (window.sessionStorage.removeItem(e), !s)
|
|
4168
4218
|
return [];
|
|
4169
4219
|
const n = JSON.parse(s);
|
|
4170
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
4220
|
+
return Array.isArray(n) ? n.flatMap((r) => ri(r) ? [{
|
|
4171
4221
|
...r.event,
|
|
4172
4222
|
page: b(),
|
|
4173
4223
|
rawOutput: {
|
|
4174
4224
|
pageContextRestarted: !0,
|
|
4175
4225
|
outcome: "unknown",
|
|
4176
|
-
message:
|
|
4226
|
+
message: ni(location.href),
|
|
4177
4227
|
currentUrl: location.href,
|
|
4178
4228
|
console: [],
|
|
4179
4229
|
metadata: {
|
|
@@ -4190,17 +4240,17 @@ function Jr(t) {
|
|
|
4190
4240
|
return [];
|
|
4191
4241
|
}
|
|
4192
4242
|
}
|
|
4193
|
-
function
|
|
4243
|
+
function ni(t) {
|
|
4194
4244
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
4195
4245
|
Current URL: ${t}`;
|
|
4196
4246
|
}
|
|
4197
|
-
function
|
|
4247
|
+
function ri(t) {
|
|
4198
4248
|
if (!t || typeof t != "object")
|
|
4199
4249
|
return !1;
|
|
4200
4250
|
const e = t, s = e.event;
|
|
4201
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";
|
|
4202
4252
|
}
|
|
4203
|
-
function
|
|
4253
|
+
function ii(t, e) {
|
|
4204
4254
|
const s = new Set(
|
|
4205
4255
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
4206
4256
|
);
|
|
@@ -4209,9 +4259,9 @@ function Zr(t, e) {
|
|
|
4209
4259
|
...e.filter((n) => !s.has(n.callId))
|
|
4210
4260
|
];
|
|
4211
4261
|
}
|
|
4212
|
-
function
|
|
4262
|
+
function oi(t) {
|
|
4213
4263
|
try {
|
|
4214
|
-
window.sessionStorage.removeItem(`${
|
|
4264
|
+
window.sessionStorage.removeItem(`${Pe}${t}`);
|
|
4215
4265
|
} catch {
|
|
4216
4266
|
return;
|
|
4217
4267
|
}
|
|
@@ -4220,15 +4270,15 @@ function lt(t) {
|
|
|
4220
4270
|
if (!t || typeof t != "object")
|
|
4221
4271
|
return !1;
|
|
4222
4272
|
const e = t;
|
|
4223
|
-
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;
|
|
4224
4274
|
}
|
|
4225
|
-
function
|
|
4275
|
+
function Bt(t) {
|
|
4226
4276
|
if (!t || typeof t != "object")
|
|
4227
4277
|
return !1;
|
|
4228
4278
|
const e = t;
|
|
4229
4279
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
4230
4280
|
}
|
|
4231
|
-
function
|
|
4281
|
+
function ps(t, e) {
|
|
4232
4282
|
if (!Array.isArray(t))
|
|
4233
4283
|
return;
|
|
4234
4284
|
const s = t.filter((r) => {
|
|
@@ -4236,41 +4286,41 @@ function ls(t, e) {
|
|
|
4236
4286
|
return !1;
|
|
4237
4287
|
const i = r;
|
|
4238
4288
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
4239
|
-
}), n = e ? s.map((r) =>
|
|
4289
|
+
}), n = e ? s.map((r) => hs(r, e)) : s;
|
|
4240
4290
|
return n.length > 0 ? n : void 0;
|
|
4241
4291
|
}
|
|
4242
|
-
function
|
|
4292
|
+
function hs(t, e) {
|
|
4243
4293
|
return t.fileUrl?.startsWith("/") ? {
|
|
4244
4294
|
...t,
|
|
4245
4295
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
4246
4296
|
} : t;
|
|
4247
4297
|
}
|
|
4248
4298
|
function tt(t) {
|
|
4249
|
-
return t.type ||
|
|
4299
|
+
return t.type || ci(t.name) || "application/octet-stream";
|
|
4250
4300
|
}
|
|
4251
|
-
function
|
|
4252
|
-
|
|
4301
|
+
function ai(t) {
|
|
4302
|
+
gs({
|
|
4253
4303
|
name: t.name,
|
|
4254
4304
|
mimeType: tt(t),
|
|
4255
4305
|
sizeBytes: t.size
|
|
4256
4306
|
});
|
|
4257
4307
|
}
|
|
4258
|
-
function
|
|
4259
|
-
const e =
|
|
4260
|
-
if (!
|
|
4308
|
+
function gs(t) {
|
|
4309
|
+
const e = li(t.name), s = t.mimeType.trim().toLowerCase();
|
|
4310
|
+
if (!Tn.has(`${e}:${s}`))
|
|
4261
4311
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
4262
|
-
if (t.sizeBytes <= 0 || t.sizeBytes >=
|
|
4312
|
+
if (t.sizeBytes <= 0 || t.sizeBytes >= Vt)
|
|
4263
4313
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
4264
4314
|
}
|
|
4265
|
-
function
|
|
4315
|
+
function li(t) {
|
|
4266
4316
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
4267
4317
|
return s >= 0 ? e.slice(s) : "";
|
|
4268
4318
|
}
|
|
4269
|
-
function
|
|
4319
|
+
function ci(t) {
|
|
4270
4320
|
const e = t.toLowerCase();
|
|
4271
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;
|
|
4272
4322
|
}
|
|
4273
|
-
function
|
|
4323
|
+
function ui(t) {
|
|
4274
4324
|
if (!t || typeof t != "object")
|
|
4275
4325
|
return null;
|
|
4276
4326
|
const e = t;
|
|
@@ -4288,17 +4338,17 @@ function ri(t) {
|
|
|
4288
4338
|
scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
|
|
4289
4339
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
4290
4340
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
4291
|
-
attachments:
|
|
4341
|
+
attachments: ps(e.attachments)?.map(Ce),
|
|
4292
4342
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
4293
4343
|
};
|
|
4294
4344
|
}
|
|
4295
|
-
function
|
|
4345
|
+
function di(t) {
|
|
4296
4346
|
return t.attachments?.length ? {
|
|
4297
4347
|
...t,
|
|
4298
|
-
attachments: t.attachments.map(
|
|
4348
|
+
attachments: t.attachments.map(Ce)
|
|
4299
4349
|
} : t;
|
|
4300
4350
|
}
|
|
4301
|
-
function
|
|
4351
|
+
function Ce(t) {
|
|
4302
4352
|
const {
|
|
4303
4353
|
dataUrl: e,
|
|
4304
4354
|
objectUrl: s,
|
|
@@ -4308,7 +4358,7 @@ function ke(t) {
|
|
|
4308
4358
|
} = t;
|
|
4309
4359
|
return i;
|
|
4310
4360
|
}
|
|
4311
|
-
function
|
|
4361
|
+
function q(t) {
|
|
4312
4362
|
const e = t.respondsToUserMessageId;
|
|
4313
4363
|
return typeof e == "string" && e ? e : null;
|
|
4314
4364
|
}
|
|
@@ -4316,11 +4366,11 @@ function C(t) {
|
|
|
4316
4366
|
const e = t.runId;
|
|
4317
4367
|
return typeof e == "string" && e ? e : null;
|
|
4318
4368
|
}
|
|
4319
|
-
function
|
|
4369
|
+
function pi(t) {
|
|
4320
4370
|
const e = t?.timeoutMs;
|
|
4321
|
-
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);
|
|
4322
4372
|
}
|
|
4323
|
-
function
|
|
4373
|
+
function fs(t) {
|
|
4324
4374
|
const e = {};
|
|
4325
4375
|
try {
|
|
4326
4376
|
new Headers(t).forEach((s, n) => {
|
|
@@ -4332,23 +4382,23 @@ function ds(t) {
|
|
|
4332
4382
|
return e;
|
|
4333
4383
|
}
|
|
4334
4384
|
function ct(t, e) {
|
|
4335
|
-
return
|
|
4385
|
+
return ws(t) ? ve : W(_e(e), wn);
|
|
4336
4386
|
}
|
|
4337
|
-
function
|
|
4387
|
+
function hi(t, e) {
|
|
4338
4388
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
4339
4389
|
}
|
|
4340
|
-
async function
|
|
4341
|
-
const r =
|
|
4390
|
+
async function gi(t, e, s, n) {
|
|
4391
|
+
const r = fs(t.headers);
|
|
4342
4392
|
n({
|
|
4343
4393
|
...e,
|
|
4344
4394
|
responseStatus: t.status,
|
|
4345
4395
|
responseHeaders: r,
|
|
4346
|
-
responseBody: await
|
|
4396
|
+
responseBody: await fi(t),
|
|
4347
4397
|
durationMs: Date.now() - s
|
|
4348
4398
|
});
|
|
4349
4399
|
}
|
|
4350
|
-
async function
|
|
4351
|
-
if (!
|
|
4400
|
+
async function fi(t) {
|
|
4401
|
+
if (!ms(t.headers))
|
|
4352
4402
|
return;
|
|
4353
4403
|
let e = null, s = null;
|
|
4354
4404
|
try {
|
|
@@ -4357,7 +4407,7 @@ async function ci(t) {
|
|
|
4357
4407
|
const n = new Promise((a) => {
|
|
4358
4408
|
s = window.setTimeout(() => {
|
|
4359
4409
|
e?.cancel(), a("timeout");
|
|
4360
|
-
},
|
|
4410
|
+
}, Mn);
|
|
4361
4411
|
}), r = new TextDecoder();
|
|
4362
4412
|
let i = "", o = 0;
|
|
4363
4413
|
for (; ; ) {
|
|
@@ -4366,10 +4416,10 @@ async function ci(t) {
|
|
|
4366
4416
|
return;
|
|
4367
4417
|
const { done: l, value: c } = a;
|
|
4368
4418
|
if (l)
|
|
4369
|
-
return
|
|
4419
|
+
return W(i + r.decode());
|
|
4370
4420
|
const d = it - o;
|
|
4371
4421
|
if (c.byteLength > d)
|
|
4372
|
-
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]`;
|
|
4373
4423
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
4374
4424
|
}
|
|
4375
4425
|
} catch {
|
|
@@ -4379,45 +4429,45 @@ async function ci(t) {
|
|
|
4379
4429
|
s !== null && window.clearTimeout(s);
|
|
4380
4430
|
}
|
|
4381
4431
|
}
|
|
4382
|
-
function
|
|
4383
|
-
if (
|
|
4432
|
+
function mi(t, e) {
|
|
4433
|
+
if (ms(new Headers(e)))
|
|
4384
4434
|
try {
|
|
4385
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
4435
|
+
return t.responseType === "" || t.responseType === "text" ? W(t.responseText ?? "") : void 0;
|
|
4386
4436
|
} catch {
|
|
4387
4437
|
return;
|
|
4388
4438
|
}
|
|
4389
4439
|
}
|
|
4390
|
-
function
|
|
4440
|
+
function Wt(t) {
|
|
4391
4441
|
if (typeof t == "string")
|
|
4392
|
-
return
|
|
4442
|
+
return W(t);
|
|
4393
4443
|
}
|
|
4394
|
-
function
|
|
4395
|
-
return
|
|
4444
|
+
function yi(t) {
|
|
4445
|
+
return O({
|
|
4396
4446
|
...t,
|
|
4397
|
-
requestBody:
|
|
4398
|
-
responseBody:
|
|
4447
|
+
requestBody: Ht(t.requestBody),
|
|
4448
|
+
responseBody: Ht(t.responseBody)
|
|
4399
4449
|
});
|
|
4400
4450
|
}
|
|
4401
|
-
function
|
|
4451
|
+
function Ht(t) {
|
|
4402
4452
|
if (typeof t != "string")
|
|
4403
4453
|
return t;
|
|
4404
4454
|
const e = t.trim();
|
|
4405
4455
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4406
|
-
return
|
|
4456
|
+
return _e(t);
|
|
4407
4457
|
try {
|
|
4408
|
-
return JSON.stringify(
|
|
4458
|
+
return JSON.stringify(O(JSON.parse(t)));
|
|
4409
4459
|
} catch {
|
|
4410
|
-
return
|
|
4460
|
+
return _e(t);
|
|
4411
4461
|
}
|
|
4412
4462
|
}
|
|
4413
|
-
function
|
|
4463
|
+
function ms(t) {
|
|
4414
4464
|
if (!t)
|
|
4415
4465
|
return !1;
|
|
4416
4466
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4417
4467
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= it && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4418
4468
|
}
|
|
4419
4469
|
function Z(t, e = {}, s) {
|
|
4420
|
-
if (
|
|
4470
|
+
if (Si(s))
|
|
4421
4471
|
return !0;
|
|
4422
4472
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
4423
4473
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -4432,7 +4482,7 @@ function Z(t, e = {}, s) {
|
|
|
4432
4482
|
return !0;
|
|
4433
4483
|
}
|
|
4434
4484
|
}
|
|
4435
|
-
function
|
|
4485
|
+
function Ii(t, e) {
|
|
4436
4486
|
if (Z(t))
|
|
4437
4487
|
return !0;
|
|
4438
4488
|
try {
|
|
@@ -4442,10 +4492,10 @@ function hi(t, e) {
|
|
|
4442
4492
|
return !0;
|
|
4443
4493
|
}
|
|
4444
4494
|
}
|
|
4445
|
-
function
|
|
4495
|
+
function Si(t) {
|
|
4446
4496
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4447
4497
|
}
|
|
4448
|
-
function
|
|
4498
|
+
function Ti(t) {
|
|
4449
4499
|
const e = {};
|
|
4450
4500
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4451
4501
|
const n = s.indexOf(":");
|
|
@@ -4458,101 +4508,101 @@ function gi(t) {
|
|
|
4458
4508
|
}
|
|
4459
4509
|
return e;
|
|
4460
4510
|
}
|
|
4461
|
-
function
|
|
4511
|
+
function W(t, e = it) {
|
|
4462
4512
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4463
4513
|
}
|
|
4464
4514
|
function Ge(t) {
|
|
4465
4515
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4466
4516
|
}
|
|
4467
|
-
class
|
|
4517
|
+
class Re extends Error {
|
|
4468
4518
|
constructor(e, s) {
|
|
4469
4519
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4470
4520
|
}
|
|
4471
4521
|
status;
|
|
4472
4522
|
}
|
|
4473
|
-
async function
|
|
4523
|
+
async function Te(t, e) {
|
|
4474
4524
|
let s = null;
|
|
4475
|
-
for (let n = 0; n <
|
|
4525
|
+
for (let n = 0; n < kt; n += 1)
|
|
4476
4526
|
try {
|
|
4477
4527
|
return await t();
|
|
4478
4528
|
} catch (r) {
|
|
4479
|
-
if (s = r, n >=
|
|
4529
|
+
if (s = r, n >= kt - 1 || !Mi(r))
|
|
4480
4530
|
throw r;
|
|
4481
|
-
await
|
|
4531
|
+
await wi(n);
|
|
4482
4532
|
}
|
|
4483
4533
|
throw s instanceof Error ? s : new Error(e);
|
|
4484
4534
|
}
|
|
4485
|
-
function
|
|
4535
|
+
function wi(t) {
|
|
4486
4536
|
return new Promise((e) => {
|
|
4487
|
-
window.setTimeout(e,
|
|
4537
|
+
window.setTimeout(e, Sn[t] ?? 0);
|
|
4488
4538
|
});
|
|
4489
4539
|
}
|
|
4490
|
-
function
|
|
4491
|
-
return t instanceof
|
|
4540
|
+
function Mi(t) {
|
|
4541
|
+
return t instanceof Re ? Ai(t.status) : t instanceof TypeError;
|
|
4492
4542
|
}
|
|
4493
|
-
function
|
|
4543
|
+
function Ai(t) {
|
|
4494
4544
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
4495
4545
|
}
|
|
4496
|
-
function
|
|
4546
|
+
function Ri(t) {
|
|
4497
4547
|
return t === 401 || t === 403;
|
|
4498
4548
|
}
|
|
4499
|
-
const
|
|
4500
|
-
function
|
|
4501
|
-
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());
|
|
4502
4552
|
}
|
|
4503
|
-
function
|
|
4553
|
+
function be(t, e, s) {
|
|
4504
4554
|
if (typeof t == "string")
|
|
4505
|
-
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);
|
|
4506
4556
|
if (t === null || typeof t != "object")
|
|
4507
4557
|
return t;
|
|
4508
|
-
if (e >=
|
|
4558
|
+
if (e >= ki)
|
|
4509
4559
|
return "[REDACTED_MAX_DEPTH]";
|
|
4510
4560
|
if (s.has(t))
|
|
4511
4561
|
return "[REDACTED_CIRCULAR]";
|
|
4512
4562
|
if (s.add(t), Array.isArray(t))
|
|
4513
|
-
return t.map((r) =>
|
|
4563
|
+
return t.map((r) => be(r, e + 1, s));
|
|
4514
4564
|
const n = {};
|
|
4515
4565
|
for (const [r, i] of Object.entries(t))
|
|
4516
|
-
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);
|
|
4517
4567
|
return n;
|
|
4518
4568
|
}
|
|
4519
|
-
function
|
|
4569
|
+
function ws(t) {
|
|
4520
4570
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
4521
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");
|
|
4522
4572
|
}
|
|
4523
|
-
function
|
|
4524
|
-
return typeof t == "string" ?
|
|
4573
|
+
function Ui(t) {
|
|
4574
|
+
return typeof t == "string" ? Ms(t) : be(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4525
4575
|
}
|
|
4526
|
-
function
|
|
4576
|
+
function Ms(t) {
|
|
4527
4577
|
try {
|
|
4528
4578
|
const e = new URL(t, location.href);
|
|
4529
4579
|
for (const s of Array.from(e.searchParams.keys()))
|
|
4530
|
-
|
|
4531
|
-
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();
|
|
4532
4582
|
} catch {
|
|
4533
|
-
return
|
|
4583
|
+
return vi(t);
|
|
4534
4584
|
}
|
|
4535
4585
|
}
|
|
4536
|
-
function
|
|
4537
|
-
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}`);
|
|
4538
4588
|
}
|
|
4539
|
-
function
|
|
4540
|
-
return t.replace(
|
|
4589
|
+
function vi(t) {
|
|
4590
|
+
return t.replace(ys, `Bearer ${$}`).replace(Is, `Basic ${$}`).replace(Ss, $).replace(Ts, (e, s) => `${s}: ${ve}`);
|
|
4541
4591
|
}
|
|
4542
|
-
function
|
|
4543
|
-
const e = t.match(
|
|
4544
|
-
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}`;
|
|
4545
4595
|
}
|
|
4546
4596
|
export {
|
|
4547
|
-
|
|
4597
|
+
mt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4548
4598
|
Xe as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
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
|
|
4558
4608
|
};
|