@pluno/product-agent-web 0.1.149 → 0.1.151
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 +4 -0
- package/dist/product-agent-sdk.js +554 -518
- package/dist/product-agent-widget.js +3206 -3061
- package/dist/scheduledCheckIn.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Qe = "pluno-product-agent-attachments";
|
|
2
2
|
const Pt = "files";
|
|
3
|
-
async function
|
|
4
|
-
const t = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
3
|
+
async function ts(e) {
|
|
4
|
+
const t = await Ft();
|
|
5
|
+
await ns(t, "readwrite", (s) => s.put(e));
|
|
6
|
+
}
|
|
7
|
+
async function es(e, t) {
|
|
8
|
+
const s = await Ft();
|
|
9
|
+
await Ht(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await Wt(
|
|
11
11
|
n.get(e)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,26 +16,26 @@ async function ts(e, t) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const t = await
|
|
21
|
-
await
|
|
19
|
+
async function ss(e = 864e5) {
|
|
20
|
+
const t = await Ft(), s = Date.now() - e;
|
|
21
|
+
await Ht(t, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await Wt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Ft() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
28
|
-
const s = indexedDB.open(
|
|
28
|
+
const s = indexedDB.open(Qe, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
30
|
const r = s.result.createObjectStore(Pt, { 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 = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
return await
|
|
35
|
+
async function ns(e, t, s) {
|
|
36
|
+
return await Ht(e, t, async (n) => await Wt(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Ht(e, t, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
40
|
const i = e.transaction(Pt, t), o = i.objectStore(Pt);
|
|
41
41
|
let a, c = !1;
|
|
@@ -57,16 +57,16 @@ function Ft(e, t, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Wt(e) {
|
|
61
61
|
return new Promise((t, s) => {
|
|
62
62
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function rs(e) {
|
|
66
66
|
return e !== null && (typeof e == "object" || typeof e == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const n = Reflect.get(e, "pluno"), r =
|
|
68
|
+
function be(e, t, s) {
|
|
69
|
+
const n = Reflect.get(e, "pluno"), r = rs(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(e, "pluno", r))
|
|
71
71
|
return null;
|
|
72
72
|
const i = Object.getOwnPropertyDescriptor(r, t);
|
|
@@ -80,14 +80,14 @@ function Re(e, t, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const is = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function os(e, t) {
|
|
85
85
|
return t ? e.replace(
|
|
86
|
-
|
|
86
|
+
is,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
|
|
88
88
|
) : e;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function as(e, t, s) {
|
|
91
91
|
const n = t.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
92
92
|
n.flatMap(
|
|
93
93
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
@@ -114,7 +114,7 @@ function os(e, t, s) {
|
|
|
114
114
|
for (const u of e) {
|
|
115
115
|
const d = s(u);
|
|
116
116
|
let p = o.get(d.id);
|
|
117
|
-
if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((
|
|
117
|
+
if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((E) => l.get(E)).find((E) => E !== void 0) ?? p), p && !I.has(p)) {
|
|
118
118
|
g.push(p), I.add(p);
|
|
119
119
|
continue;
|
|
120
120
|
}
|
|
@@ -125,16 +125,16 @@ function os(e, t, s) {
|
|
|
125
125
|
I.has(u) || g.push(u);
|
|
126
126
|
return g;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function cs(e, t, s, n) {
|
|
129
129
|
return e.filter((r) => {
|
|
130
130
|
const i = n(r);
|
|
131
131
|
return !i.isActivity || !i.isTransient ? !0 : t !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== t : s === null || i.runId !== s;
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
const St = "pluno.productAgent.transportId",
|
|
134
|
+
const St = "pluno.productAgent.transportId", ls = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", us = 50, ds = globalThis.setTimeout.bind(globalThis);
|
|
135
135
|
let W = null;
|
|
136
|
-
const et = /* @__PURE__ */ new Set(),
|
|
137
|
-
async function
|
|
136
|
+
const et = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Map();
|
|
137
|
+
async function hs(e = Me()) {
|
|
138
138
|
const t = e.randomUUID(), s = e.storage.getItem(St);
|
|
139
139
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
140
140
|
const o = e.channel.subscribe((c) => {
|
|
@@ -170,14 +170,14 @@ async function ds(e = ke()) {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
174
|
-
W || (W =
|
|
173
|
+
async function ps() {
|
|
174
|
+
W || (W = hs(Me()), W.then((n) => {
|
|
175
175
|
const r = (i) => {
|
|
176
176
|
i.persisted || (n.release(), W = null, et.clear(), window.removeEventListener("pagehide", r));
|
|
177
177
|
};
|
|
178
178
|
window.addEventListener("pagehide", r);
|
|
179
179
|
}));
|
|
180
|
-
const e = await W, t =
|
|
180
|
+
const e = await W, t = fs();
|
|
181
181
|
et.add(t);
|
|
182
182
|
let s = !1;
|
|
183
183
|
return {
|
|
@@ -188,31 +188,31 @@ async function hs() {
|
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function fs() {
|
|
192
192
|
let e = 0;
|
|
193
193
|
for (; et.has(e); )
|
|
194
194
|
e += 1;
|
|
195
195
|
return e;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function Me() {
|
|
198
198
|
return {
|
|
199
|
-
storage:
|
|
200
|
-
channel:
|
|
199
|
+
storage: gs(),
|
|
200
|
+
channel: ms(),
|
|
201
201
|
randomUUID: () => crypto.randomUUID(),
|
|
202
|
-
settle: () => new Promise((e) =>
|
|
202
|
+
settle: () => new Promise((e) => ds(e, us))
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function gs() {
|
|
206
206
|
return {
|
|
207
207
|
getItem: (e) => {
|
|
208
208
|
try {
|
|
209
|
-
return window.sessionStorage?.getItem(e) ??
|
|
209
|
+
return window.sessionStorage?.getItem(e) ?? Et.get(e) ?? null;
|
|
210
210
|
} catch {
|
|
211
|
-
return
|
|
211
|
+
return Et.get(e) ?? null;
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
setItem: (e, t) => {
|
|
215
|
-
|
|
215
|
+
Et.set(e, t);
|
|
216
216
|
try {
|
|
217
217
|
window.sessionStorage?.setItem(e, t);
|
|
218
218
|
} catch {
|
|
@@ -220,9 +220,9 @@ function fs() {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function ms() {
|
|
224
224
|
if (typeof BroadcastChannel < "u") {
|
|
225
|
-
const e = new BroadcastChannel(
|
|
225
|
+
const e = new BroadcastChannel(ls);
|
|
226
226
|
return {
|
|
227
227
|
postMessage: (t) => e.postMessage(t),
|
|
228
228
|
subscribe: (t) => {
|
|
@@ -232,9 +232,9 @@ function gs() {
|
|
|
232
232
|
close: () => e.close()
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
-
return
|
|
235
|
+
return ys();
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function ys() {
|
|
238
238
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
239
239
|
if (s.key !== At || !s.newValue)
|
|
240
240
|
return;
|
|
@@ -255,9 +255,23 @@ function ms() {
|
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
const ke = "schedule_follow_up";
|
|
259
|
+
function Is(e) {
|
|
260
|
+
let t = e;
|
|
261
|
+
if (typeof t == "string")
|
|
262
|
+
try {
|
|
263
|
+
t = JSON.parse(t);
|
|
264
|
+
} catch {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
if (!t || typeof t != "object")
|
|
268
|
+
return null;
|
|
269
|
+
const s = t;
|
|
270
|
+
return s.ok !== !0 || s.toolName !== ke || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
271
|
+
}
|
|
272
|
+
const Ts = globalThis.fetch.bind(globalThis), Dt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ws = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ss = ".pluno-pa-widget__panel", As = ".pluno-pa-widget__timeline", ie = `${Dt}[data-pluno-sdk-preview-channel]`;
|
|
273
|
+
let Es = 0;
|
|
274
|
+
function oe(e) {
|
|
261
275
|
const t = {};
|
|
262
276
|
for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
|
|
263
277
|
const o = e[i];
|
|
@@ -270,7 +284,7 @@ function ie(e) {
|
|
|
270
284
|
const r = e.attachments;
|
|
271
285
|
return Array.isArray(r) && (t.attachmentCount = r.length), t;
|
|
272
286
|
}
|
|
273
|
-
function
|
|
287
|
+
function Rt(e, t, s) {
|
|
274
288
|
if (typeof window > "u")
|
|
275
289
|
return;
|
|
276
290
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -282,25 +296,25 @@ function Et(e, t, s) {
|
|
|
282
296
|
source: "web_sdk",
|
|
283
297
|
category: e,
|
|
284
298
|
name: t,
|
|
285
|
-
sequence: ++
|
|
299
|
+
sequence: ++Es,
|
|
286
300
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
287
301
|
monotonicMs: performance.now(),
|
|
288
302
|
data: s
|
|
289
303
|
};
|
|
290
304
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
291
305
|
}
|
|
292
|
-
const
|
|
306
|
+
const Rs = "https://app.pluno.ai", bs = "gpt-5.6-terra", Ms = 2e4, ks = 1e4, _s = 1e4, Cs = 1e4, Us = 1e4, Ps = 1e3, ae = 3e4, ce = 0.2, le = 6e4, Ds = 15e3, V = 8, vs = "Pluno could not finish this message. Try it again.", Os = "Browser connection was interrupted.", Ns = 15e3, xs = 2e3, Ls = 1e3, qs = 100, ue = 8e3, de = 3, Bs = [300, 1e3], $t = 64e3, bt = 4e3, jt = 30, Fs = 2e3, Hs = 1e3, _e = "Image is too large for model vision input.", Ws = 100, Ce = "pluno.productAgent.state.", vt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", $s = 100;
|
|
293
307
|
function Y(e, t = 0) {
|
|
294
308
|
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
295
309
|
return Math.max(t, s);
|
|
296
310
|
}
|
|
297
311
|
const st = /* @__PURE__ */ new Set();
|
|
298
312
|
let Z = null;
|
|
299
|
-
function
|
|
300
|
-
const s = Math.min(
|
|
301
|
-
return Math.min(
|
|
313
|
+
function js(e, t = Math.random) {
|
|
314
|
+
const s = Math.min(ae, Ps * 2 ** e), n = 1 - ce + t() * ce * 2;
|
|
315
|
+
return Math.min(ae, Math.round(s * n));
|
|
302
316
|
}
|
|
303
|
-
function
|
|
317
|
+
function zs(e, t, s) {
|
|
304
318
|
return new Promise((n, r) => {
|
|
305
319
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
306
320
|
e.then(
|
|
@@ -313,13 +327,13 @@ function Hs(e, t, s) {
|
|
|
313
327
|
);
|
|
314
328
|
});
|
|
315
329
|
}
|
|
316
|
-
class
|
|
330
|
+
class Ue {
|
|
317
331
|
constructor(t, s) {
|
|
318
332
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
319
333
|
...this.state,
|
|
320
|
-
starterPrompts:
|
|
334
|
+
starterPrompts: kn(t.initialStarterPrompts)
|
|
321
335
|
};
|
|
322
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
336
|
+
const n = t.restorePersistedState === !1 ? null : gr(t.clientId, t.expectedPersistedSessionId);
|
|
323
337
|
n && (this.state = {
|
|
324
338
|
...this.state,
|
|
325
339
|
...n,
|
|
@@ -332,9 +346,9 @@ class Ce {
|
|
|
332
346
|
assistantDraftRunId: null,
|
|
333
347
|
isThinking: !1,
|
|
334
348
|
lastError: null
|
|
335
|
-
}), this.queuedClientEvents =
|
|
336
|
-
|
|
337
|
-
|
|
349
|
+
}), this.queuedClientEvents = Ar(
|
|
350
|
+
yr(t.clientId),
|
|
351
|
+
Tr(t.clientId)
|
|
338
352
|
), j(t.clientId, this.queuedClientEvents);
|
|
339
353
|
}
|
|
340
354
|
options;
|
|
@@ -372,6 +386,7 @@ class Ce {
|
|
|
372
386
|
runAckResyncRetryTimer = null;
|
|
373
387
|
activeClientMessageId = null;
|
|
374
388
|
activeUserMessageEvent = null;
|
|
389
|
+
browserConnectionInterruptedClientMessageIds = /* @__PURE__ */ new Set();
|
|
375
390
|
latestRecoverableClientMessageId = null;
|
|
376
391
|
lastUserMessagePageUrl = null;
|
|
377
392
|
thinkingWatchdogResyncAttemptsByClientMessageId = {};
|
|
@@ -409,15 +424,15 @@ class Ce {
|
|
|
409
424
|
lastErrorSecuritySettingsUrl: null
|
|
410
425
|
};
|
|
411
426
|
static async init(t) {
|
|
412
|
-
const s = await
|
|
427
|
+
const s = await ps(), n = new Ue({
|
|
413
428
|
...t,
|
|
414
|
-
backendUrl:
|
|
415
|
-
clientId: t.clientId ??
|
|
429
|
+
backendUrl: hn(t.backendUrl ?? Rs),
|
|
430
|
+
clientId: t.clientId ?? Dn(),
|
|
416
431
|
model: t.model ?? bs,
|
|
417
|
-
entrySurface:
|
|
432
|
+
entrySurface: pn(t.entrySurface)
|
|
418
433
|
}, s);
|
|
419
434
|
try {
|
|
420
|
-
|
|
435
|
+
ss().catch((r) => {
|
|
421
436
|
S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
422
437
|
message: r instanceof Error ? r.message : String(r)
|
|
423
438
|
});
|
|
@@ -448,14 +463,14 @@ class Ce {
|
|
|
448
463
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
449
464
|
);
|
|
450
465
|
try {
|
|
451
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
466
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await zs(this.options.tokenProvider(), _s, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
452
467
|
return;
|
|
453
468
|
if (!this.token && !this.options.webSocketFactory)
|
|
454
469
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
455
|
-
const s =
|
|
470
|
+
const s = mn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
456
471
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
457
472
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
458
|
-
},
|
|
473
|
+
}, Cs), n.addEventListener("open", () => {
|
|
459
474
|
this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
|
|
460
475
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
461
476
|
isThinking: this.state.isThinking
|
|
@@ -467,11 +482,11 @@ class Ce {
|
|
|
467
482
|
pageUrl: location.href
|
|
468
483
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
469
484
|
this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
470
|
-
},
|
|
485
|
+
}, Us));
|
|
471
486
|
}), n.addEventListener("message", (r) => {
|
|
472
|
-
this.socket === n && this.handleServerEvent(
|
|
487
|
+
this.socket === n && this.handleServerEvent(Mn(r.data));
|
|
473
488
|
}), n.addEventListener("close", (r) => {
|
|
474
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
489
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
475
490
|
code: typeof r?.code == "number" ? r.code : null,
|
|
476
491
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
477
492
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -482,7 +497,7 @@ class Ce {
|
|
|
482
497
|
this.socket !== n || this.state.status === "closed" || (S("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
483
498
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
484
499
|
isThinking: this.state.isThinking
|
|
485
|
-
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
500
|
+
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.rememberBrowserConnectionInterruptionForActiveRun(), this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
486
501
|
});
|
|
487
502
|
} catch (s) {
|
|
488
503
|
if (t === this.connectionAttemptId && this.state.status !== "closed") {
|
|
@@ -502,7 +517,7 @@ class Ce {
|
|
|
502
517
|
this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), 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.pendingWarmupEvent = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
503
518
|
}
|
|
504
519
|
destroy() {
|
|
505
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
520
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Er(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
506
521
|
for (const t of Object.values(this.listeners))
|
|
507
522
|
t?.clear();
|
|
508
523
|
}
|
|
@@ -512,16 +527,16 @@ class Ce {
|
|
|
512
527
|
reason: t,
|
|
513
528
|
entrySurface: this.options.entrySurface,
|
|
514
529
|
sessionId: this.state.sessionId ?? void 0,
|
|
515
|
-
page:
|
|
530
|
+
page: M()
|
|
516
531
|
};
|
|
517
532
|
this.sendNow(s) || (this.pendingWarmupEvent = s);
|
|
518
533
|
}
|
|
519
534
|
async sendMessage(t, s = {}) {
|
|
520
535
|
const n = t.trim(), r = s.attachments ?? [];
|
|
521
|
-
let i = r.map(
|
|
536
|
+
let i = r.map(Xt);
|
|
522
537
|
if (!n && i.length === 0)
|
|
523
538
|
return null;
|
|
524
|
-
const o =
|
|
539
|
+
const o = M(), a = s.clientMessageId ?? $(), c = {
|
|
525
540
|
id: `local-${a}`,
|
|
526
541
|
role: "user",
|
|
527
542
|
content: n,
|
|
@@ -550,14 +565,14 @@ class Ce {
|
|
|
550
565
|
try {
|
|
551
566
|
const p = [];
|
|
552
567
|
for (const m of i) {
|
|
553
|
-
const
|
|
568
|
+
const E = m.id ? this.attachmentFiles.get(m.id) : void 0;
|
|
554
569
|
if (m.sandboxPath) {
|
|
555
570
|
p.push(m);
|
|
556
571
|
continue;
|
|
557
572
|
}
|
|
558
|
-
if (!
|
|
573
|
+
if (!E)
|
|
559
574
|
throw new Error(`Attachment bytes are unavailable for ${m.name}`);
|
|
560
|
-
p.push(await this.uploadAttachmentForMessage({ file:
|
|
575
|
+
p.push(await this.uploadAttachmentForMessage({ file: E, attachment: m }));
|
|
561
576
|
}
|
|
562
577
|
i = p;
|
|
563
578
|
} catch (p) {
|
|
@@ -572,20 +587,20 @@ class Ce {
|
|
|
572
587
|
sessionId: this.state.sessionId ?? void 0,
|
|
573
588
|
clientMessageId: a,
|
|
574
589
|
initiatedBy: s.initiatedBy,
|
|
575
|
-
invocation:
|
|
590
|
+
invocation: fn(s.invocation ?? s.initiatedBy),
|
|
576
591
|
entrySurface: this.options.entrySurface,
|
|
577
592
|
content: n,
|
|
578
|
-
pageContent: u &&
|
|
593
|
+
pageContent: u && zt() || void 0,
|
|
579
594
|
attachments: i.length > 0 ? i : void 0,
|
|
580
595
|
page: o,
|
|
581
596
|
model: this.options.model,
|
|
582
|
-
metadata:
|
|
597
|
+
metadata: he(this.options.metadata)
|
|
583
598
|
};
|
|
584
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.markThinkingProgress(), this.send(d), a;
|
|
599
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.browserConnectionInterruptedClientMessageIds.delete(a), this.markThinkingProgress(), this.send(d), a;
|
|
585
600
|
}
|
|
586
601
|
retryLastMessage() {
|
|
587
602
|
const t = this.state.sessionId, s = this.retryableClientMessageId;
|
|
588
|
-
return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
|
|
603
|
+
return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(s), this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
|
|
589
604
|
}
|
|
590
605
|
createLocalAttachment(t) {
|
|
591
606
|
const s = $(), n = {
|
|
@@ -596,13 +611,13 @@ class Ce {
|
|
|
596
611
|
};
|
|
597
612
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
598
613
|
const r = Date.now();
|
|
599
|
-
return
|
|
614
|
+
return ts({
|
|
600
615
|
attachmentId: s,
|
|
601
616
|
name: n.name,
|
|
602
617
|
mimeType: n.mimeType,
|
|
603
618
|
sizeBytes: n.sizeBytes,
|
|
604
619
|
blob: t,
|
|
605
|
-
origin:
|
|
620
|
+
origin: M().origin,
|
|
606
621
|
sessionId: this.state.sessionId ?? void 0,
|
|
607
622
|
createdAt: r,
|
|
608
623
|
lastUsedAt: r
|
|
@@ -633,9 +648,9 @@ class Ce {
|
|
|
633
648
|
name: t.name || "attachment",
|
|
634
649
|
mimeType: r,
|
|
635
650
|
sizeBytes: t.size,
|
|
636
|
-
page:
|
|
651
|
+
page: M(),
|
|
637
652
|
model: this.options.model,
|
|
638
|
-
metadata:
|
|
653
|
+
metadata: he(this.options.metadata),
|
|
639
654
|
entrySurface: this.options.entrySurface
|
|
640
655
|
};
|
|
641
656
|
let o;
|
|
@@ -661,8 +676,8 @@ class Ce {
|
|
|
661
676
|
}, "Failed to upload attachment"), o = c;
|
|
662
677
|
}
|
|
663
678
|
this.setState({ sessionId: o.sessionId });
|
|
664
|
-
const a =
|
|
665
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
679
|
+
const a = We(o.attachment, this.options.backendUrl);
|
|
680
|
+
return this.updateAttachmentInState(s.id, a), s.id && es(s.id, {
|
|
666
681
|
sessionId: o.sessionId,
|
|
667
682
|
fileUrl: a.fileUrl,
|
|
668
683
|
sandboxPath: a.sandboxPath,
|
|
@@ -692,7 +707,7 @@ class Ce {
|
|
|
692
707
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
693
708
|
if (n.ok)
|
|
694
709
|
return await n.json();
|
|
695
|
-
if (
|
|
710
|
+
if (Br(n.status) && this.options.tokenProvider && !s) {
|
|
696
711
|
s = !0;
|
|
697
712
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
698
713
|
if (r.ok)
|
|
@@ -721,7 +736,7 @@ class Ce {
|
|
|
721
736
|
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
|
|
722
737
|
type: "session.reset",
|
|
723
738
|
sessionId: this.state.sessionId ?? void 0,
|
|
724
|
-
page:
|
|
739
|
+
page: M()
|
|
725
740
|
}), this.setState({
|
|
726
741
|
sessionId: null,
|
|
727
742
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -739,12 +754,12 @@ class Ce {
|
|
|
739
754
|
const s = $(), n = new Promise((i, o) => {
|
|
740
755
|
const a = window.setTimeout(() => {
|
|
741
756
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
742
|
-
},
|
|
757
|
+
}, ue);
|
|
743
758
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
744
759
|
}), r = {
|
|
745
760
|
type: "sessions.list",
|
|
746
761
|
requestId: s,
|
|
747
|
-
page:
|
|
762
|
+
page: M(),
|
|
748
763
|
...t.cursor ? { cursor: t.cursor } : {},
|
|
749
764
|
...t.limit ? { limit: t.limit } : {},
|
|
750
765
|
...typeof t.pinned == "boolean" ? { pinned: t.pinned } : {}
|
|
@@ -783,11 +798,11 @@ class Ce {
|
|
|
783
798
|
}), this.send({
|
|
784
799
|
type: "session.load",
|
|
785
800
|
sessionId: t,
|
|
786
|
-
page:
|
|
801
|
+
page: M()
|
|
787
802
|
});
|
|
788
803
|
}
|
|
789
804
|
send(t) {
|
|
790
|
-
this.sendNow(
|
|
805
|
+
this.sendNow(_(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
791
806
|
}
|
|
792
807
|
async getUploadToken() {
|
|
793
808
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -800,7 +815,7 @@ class Ce {
|
|
|
800
815
|
return !1;
|
|
801
816
|
const s = this.socket;
|
|
802
817
|
try {
|
|
803
|
-
return s.send(JSON.stringify(t)),
|
|
818
|
+
return s.send(JSON.stringify(t)), Rt("client_event", t.type, oe(t)), !0;
|
|
804
819
|
} catch (n) {
|
|
805
820
|
return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
806
821
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -813,9 +828,9 @@ class Ce {
|
|
|
813
828
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
814
829
|
return;
|
|
815
830
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
816
|
-
const t =
|
|
831
|
+
const t = yn();
|
|
817
832
|
this.sendNow(
|
|
818
|
-
|
|
833
|
+
_({
|
|
819
834
|
type: "starter_prompts.page_context",
|
|
820
835
|
pageUrl: t.pageUrl,
|
|
821
836
|
pageTitle: t.pageTitle,
|
|
@@ -824,13 +839,13 @@ class Ce {
|
|
|
824
839
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
825
840
|
}
|
|
826
841
|
startStarterPromptUrlWatcher() {
|
|
827
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
842
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = In(() => this.handleStarterPromptUrlChange()));
|
|
828
843
|
}
|
|
829
844
|
handleStarterPromptUrlChange() {
|
|
830
845
|
const t = location.href;
|
|
831
846
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
832
847
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
833
|
-
},
|
|
848
|
+
}, $s));
|
|
834
849
|
}
|
|
835
850
|
refreshStarterPromptsForCurrentUrl() {
|
|
836
851
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -848,7 +863,7 @@ class Ce {
|
|
|
848
863
|
j(this.options.clientId, this.queuedClientEvents);
|
|
849
864
|
for (let s = 0; s < t.length; s += 1) {
|
|
850
865
|
const n = t[s];
|
|
851
|
-
if (!this.sendNow(
|
|
866
|
+
if (!this.sendNow(_(n))) {
|
|
852
867
|
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), j(this.options.clientId, this.queuedClientEvents);
|
|
853
868
|
return;
|
|
854
869
|
}
|
|
@@ -859,13 +874,13 @@ class Ce {
|
|
|
859
874
|
!this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
|
|
860
875
|
}
|
|
861
876
|
handleServerEvent(t) {
|
|
862
|
-
if (
|
|
863
|
-
const s =
|
|
877
|
+
if (Rt("server_event", t.type, oe(t)), t.type === "run.ack") {
|
|
878
|
+
const s = kt(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
|
|
864
879
|
s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && n === this.activeClientMessageId && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(t);
|
|
865
880
|
return;
|
|
866
881
|
}
|
|
867
882
|
if (t.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
868
|
-
const s =
|
|
883
|
+
const s = kt(t);
|
|
869
884
|
if (s) {
|
|
870
885
|
this.deferredSessionUpdatedSessionIds.add(s);
|
|
871
886
|
return;
|
|
@@ -880,42 +895,42 @@ class Ce {
|
|
|
880
895
|
this.clearHeartbeatAckTimer();
|
|
881
896
|
return;
|
|
882
897
|
}
|
|
883
|
-
if (
|
|
898
|
+
if (Xs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
884
899
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
|
|
885
|
-
const s =
|
|
900
|
+
const s = _n(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
886
901
|
S("web-sdk.agent", "Received auth.ok appearance", {
|
|
887
902
|
hasAppearance: n,
|
|
888
903
|
rawAppearance: t.appearance,
|
|
889
904
|
normalizedAppearance: s
|
|
890
|
-
}), this.runtimeHelperJavascript =
|
|
891
|
-
const r =
|
|
892
|
-
user:
|
|
905
|
+
}), this.runtimeHelperJavascript = Cn(t.runtimeHelpers)?.javascript ?? null;
|
|
906
|
+
const r = ge(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
907
|
+
user: vn(t.user),
|
|
893
908
|
status: "connected",
|
|
894
909
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
895
910
|
};
|
|
896
|
-
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !
|
|
911
|
+
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !wn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
897
912
|
type: "page.upsert",
|
|
898
913
|
sessionId: this.state.sessionId,
|
|
899
|
-
page:
|
|
914
|
+
page: M(),
|
|
900
915
|
model: this.options.model
|
|
901
916
|
});
|
|
902
917
|
return;
|
|
903
918
|
}
|
|
904
919
|
if (t.type === "starterPrompts.updated") {
|
|
905
920
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
906
|
-
starterPrompts:
|
|
921
|
+
starterPrompts: ge(t, "starterPrompts"),
|
|
907
922
|
starterPromptsLoading: !1
|
|
908
923
|
});
|
|
909
924
|
return;
|
|
910
925
|
}
|
|
911
926
|
if (t.type === "conversation.state") {
|
|
912
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
927
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Hn(
|
|
913
928
|
t.assistantDraft
|
|
914
929
|
), r = n !== void 0;
|
|
915
930
|
this.rememberUserMessageClientMessageIds(s);
|
|
916
|
-
const i =
|
|
931
|
+
const i = nr(s);
|
|
917
932
|
if (i) {
|
|
918
|
-
const p =
|
|
933
|
+
const p = rr(s, i);
|
|
919
934
|
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
920
935
|
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
921
936
|
p
|
|
@@ -923,10 +938,10 @@ class Ce {
|
|
|
923
938
|
}
|
|
924
939
|
const o = s.filter((p) => {
|
|
925
940
|
const m = q(p);
|
|
926
|
-
return !ye(m) && (!i || !
|
|
927
|
-
}), a =
|
|
941
|
+
return !ye(m) && (!i || !Lt(m));
|
|
942
|
+
}), a = Vn(
|
|
928
943
|
this.state.messages,
|
|
929
|
-
|
|
944
|
+
On(o, this.options.backendUrl)
|
|
930
945
|
), c = me(a), l = !r && s.some(
|
|
931
946
|
(p) => Te(
|
|
932
947
|
q(p),
|
|
@@ -935,13 +950,13 @@ class Ce {
|
|
|
935
950
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
936
951
|
this.state.assistantDraftRunId
|
|
937
952
|
)
|
|
938
|
-
), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g =
|
|
939
|
-
if (!c &&
|
|
953
|
+
), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = tr(a), u = I && g;
|
|
954
|
+
if (!c && sr(this.state.messages, s))
|
|
940
955
|
return;
|
|
941
|
-
this.lastUserMessagePageUrl =
|
|
942
|
-
const d = I ? null :
|
|
956
|
+
this.lastUserMessagePageUrl = er(s);
|
|
957
|
+
const d = I ? null : qt(s);
|
|
943
958
|
if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
|
|
944
|
-
sessionId:
|
|
959
|
+
sessionId: R(t.session, "id") ?? this.state.sessionId,
|
|
945
960
|
messages: a,
|
|
946
961
|
...r ? {
|
|
947
962
|
assistantDraft: n?.content ?? "",
|
|
@@ -972,7 +987,7 @@ class Ce {
|
|
|
972
987
|
lastError: null
|
|
973
988
|
} : {}
|
|
974
989
|
}), I ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (f || d) && (d && (this.activeClientMessageId = d), this.markThinkingProgress()), i) {
|
|
975
|
-
const p =
|
|
990
|
+
const p = R(t.session, "id") ?? this.state.sessionId;
|
|
976
991
|
p && this.retryAfterInterruptedRun(p, i);
|
|
977
992
|
}
|
|
978
993
|
return;
|
|
@@ -980,7 +995,7 @@ class Ce {
|
|
|
980
995
|
if (t.type === "sessions.page") {
|
|
981
996
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
982
997
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
983
|
-
sessions:
|
|
998
|
+
sessions: Nn(t.sessions),
|
|
984
999
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
985
1000
|
}));
|
|
986
1001
|
return;
|
|
@@ -994,15 +1009,15 @@ class Ce {
|
|
|
994
1009
|
return;
|
|
995
1010
|
}
|
|
996
1011
|
if (t.type === "session.updated") {
|
|
997
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
1012
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: R(t.session, "id") ?? this.state.sessionId });
|
|
998
1013
|
return;
|
|
999
1014
|
}
|
|
1000
1015
|
if (t.type === "session.item") {
|
|
1001
1016
|
this.rememberUserMessageClientMessageIds([t.item]);
|
|
1002
1017
|
const s = q(t.item);
|
|
1003
|
-
if (
|
|
1018
|
+
if (Lt(s)) {
|
|
1004
1019
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1005
|
-
const r =
|
|
1020
|
+
const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1006
1021
|
if (r && a) {
|
|
1007
1022
|
this.retryAfterInterruptedRun(r, a);
|
|
1008
1023
|
return;
|
|
@@ -1019,7 +1034,7 @@ class Ce {
|
|
|
1019
1034
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1020
1035
|
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1021
1036
|
const i = t.item.data;
|
|
1022
|
-
|
|
1037
|
+
or(i) && this.clearRunAckResyncRetryTimer();
|
|
1023
1038
|
const o = Ot(this.state.messages, n), a = me(o), c = Te(
|
|
1024
1039
|
i,
|
|
1025
1040
|
this.state.assistantDraft,
|
|
@@ -1079,9 +1094,9 @@ class Ce {
|
|
|
1079
1094
|
const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null, r = typeof t.runId == "string" ? t.runId : null;
|
|
1080
1095
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1081
1096
|
return;
|
|
1082
|
-
const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c =
|
|
1097
|
+
const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = cs(
|
|
1083
1098
|
this.state.messages.filter(
|
|
1084
|
-
(l) => l.dataType !== "assistant_draft" || !
|
|
1099
|
+
(l) => l.dataType !== "assistant_draft" || !jn(
|
|
1085
1100
|
l,
|
|
1086
1101
|
n,
|
|
1087
1102
|
r
|
|
@@ -1089,11 +1104,11 @@ class Ce {
|
|
|
1089
1104
|
),
|
|
1090
1105
|
n,
|
|
1091
1106
|
r,
|
|
1092
|
-
|
|
1107
|
+
xe
|
|
1093
1108
|
);
|
|
1094
1109
|
this.setState({
|
|
1095
1110
|
sessionId: s,
|
|
1096
|
-
messages:
|
|
1111
|
+
messages: zn(
|
|
1097
1112
|
c,
|
|
1098
1113
|
typeof t.responseId == "string" ? t.responseId : null,
|
|
1099
1114
|
n,
|
|
@@ -1114,9 +1129,9 @@ class Ce {
|
|
|
1114
1129
|
if (s)
|
|
1115
1130
|
this.nonTranscriptToolCallIds.add(s);
|
|
1116
1131
|
else {
|
|
1117
|
-
const n =
|
|
1132
|
+
const n = Xn(t);
|
|
1118
1133
|
if (n) {
|
|
1119
|
-
const r =
|
|
1134
|
+
const r = Kn(
|
|
1120
1135
|
this.state.messages,
|
|
1121
1136
|
n
|
|
1122
1137
|
);
|
|
@@ -1160,7 +1175,7 @@ class Ce {
|
|
|
1160
1175
|
return;
|
|
1161
1176
|
}
|
|
1162
1177
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1163
|
-
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c =
|
|
1178
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = gn(a.message);
|
|
1164
1179
|
c && console.error(c), this.setState({
|
|
1165
1180
|
status: "error",
|
|
1166
1181
|
isThinking: !1,
|
|
@@ -1172,9 +1187,9 @@ class Ce {
|
|
|
1172
1187
|
}
|
|
1173
1188
|
}
|
|
1174
1189
|
shouldIgnoreBackgroundSessionEvent(t) {
|
|
1175
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1190
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !Js(t))
|
|
1176
1191
|
return !1;
|
|
1177
|
-
const s =
|
|
1192
|
+
const s = kt(t);
|
|
1178
1193
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1179
1194
|
}
|
|
1180
1195
|
rememberCurrentRunAsBackground() {
|
|
@@ -1219,7 +1234,7 @@ class Ce {
|
|
|
1219
1234
|
if (n >= V) {
|
|
1220
1235
|
this.retryableClientMessageId = s, this.setState({
|
|
1221
1236
|
isThinking: !1,
|
|
1222
|
-
lastError:
|
|
1237
|
+
lastError: this.getRunRecoveryExhaustedErrorMessage(s),
|
|
1223
1238
|
lastErrorCode: "run_recovery_exhausted"
|
|
1224
1239
|
}), this.clearThinkingWatchdog();
|
|
1225
1240
|
return;
|
|
@@ -1235,7 +1250,7 @@ class Ce {
|
|
|
1235
1250
|
}
|
|
1236
1251
|
rememberUserMessageClientMessageIds(t) {
|
|
1237
1252
|
for (const s of t) {
|
|
1238
|
-
const n =
|
|
1253
|
+
const n = R(s, "id"), r = q(s);
|
|
1239
1254
|
n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
|
|
1240
1255
|
}
|
|
1241
1256
|
}
|
|
@@ -1248,7 +1263,7 @@ class Ce {
|
|
|
1248
1263
|
const r = new Promise((i, o) => {
|
|
1249
1264
|
const a = window.setTimeout(() => {
|
|
1250
1265
|
t.delete(s.requestId), o(new Error(n));
|
|
1251
|
-
},
|
|
1266
|
+
}, ue);
|
|
1252
1267
|
t.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1253
1268
|
});
|
|
1254
1269
|
if (!this.sendNow(s)) {
|
|
@@ -1271,7 +1286,7 @@ class Ce {
|
|
|
1271
1286
|
t.clear();
|
|
1272
1287
|
}
|
|
1273
1288
|
markThinkingProgress() {
|
|
1274
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1289
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(le), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1275
1290
|
}
|
|
1276
1291
|
scheduleThinkingWatchdog(t) {
|
|
1277
1292
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1279,7 +1294,7 @@ class Ce {
|
|
|
1279
1294
|
}, t);
|
|
1280
1295
|
}
|
|
1281
1296
|
clearThinkingWatchdog() {
|
|
1282
|
-
this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId = null, this.activeUserMessageEvent = null;
|
|
1297
|
+
this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId && this.browserConnectionInterruptedClientMessageIds.delete(this.activeClientMessageId), this.activeClientMessageId = null, this.activeUserMessageEvent = null;
|
|
1283
1298
|
}
|
|
1284
1299
|
handleRunAck(t) {
|
|
1285
1300
|
const s = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
|
|
@@ -1291,7 +1306,7 @@ class Ce {
|
|
|
1291
1306
|
handleRunSteered(t) {
|
|
1292
1307
|
const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
|
|
1293
1308
|
!this.state.isThinking || !s || this.setState({
|
|
1294
|
-
messages:
|
|
1309
|
+
messages: cr(
|
|
1295
1310
|
this.state.messages,
|
|
1296
1311
|
s
|
|
1297
1312
|
)
|
|
@@ -1300,7 +1315,7 @@ class Ce {
|
|
|
1300
1315
|
scheduleRunAckWatchdog(t) {
|
|
1301
1316
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1302
1317
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1303
|
-
},
|
|
1318
|
+
}, Ns);
|
|
1304
1319
|
}
|
|
1305
1320
|
recoverMissedRunAck(t) {
|
|
1306
1321
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1324,8 +1339,8 @@ class Ce {
|
|
|
1324
1339
|
sessionId: this.state.sessionId,
|
|
1325
1340
|
clientMessageId: t,
|
|
1326
1341
|
automatic: !0
|
|
1327
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1328
|
-
}, Y(s,
|
|
1342
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(le)));
|
|
1343
|
+
}, Y(s, xs)));
|
|
1329
1344
|
}
|
|
1330
1345
|
clearRunAckResyncRetryTimer() {
|
|
1331
1346
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1342,7 +1357,7 @@ class Ce {
|
|
|
1342
1357
|
sessionId: this.state.sessionId
|
|
1343
1358
|
}), this.setState({
|
|
1344
1359
|
isThinking: !1,
|
|
1345
|
-
lastError:
|
|
1360
|
+
lastError: this.getRunRecoveryExhaustedErrorMessage(null),
|
|
1346
1361
|
lastErrorCode: "run_recovery_exhausted"
|
|
1347
1362
|
}), this.clearThinkingWatchdog();
|
|
1348
1363
|
return;
|
|
@@ -1354,7 +1369,7 @@ class Ce {
|
|
|
1354
1369
|
clientMessageId: t
|
|
1355
1370
|
}), this.retryableClientMessageId = t, this.setState({
|
|
1356
1371
|
isThinking: !1,
|
|
1357
|
-
lastError:
|
|
1372
|
+
lastError: this.getRunRecoveryExhaustedErrorMessage(t),
|
|
1358
1373
|
lastErrorCode: "run_recovery_exhausted"
|
|
1359
1374
|
}), this.clearThinkingWatchdog();
|
|
1360
1375
|
return;
|
|
@@ -1364,7 +1379,7 @@ class Ce {
|
|
|
1364
1379
|
sessionId: this.state.sessionId,
|
|
1365
1380
|
clientMessageId: t,
|
|
1366
1381
|
resyncAttempts: s + 1
|
|
1367
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1382
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ds);
|
|
1368
1383
|
return;
|
|
1369
1384
|
}
|
|
1370
1385
|
this.setState({
|
|
@@ -1388,7 +1403,7 @@ class Ce {
|
|
|
1388
1403
|
this.state.sessionId ? this.send({
|
|
1389
1404
|
type: "page.upsert",
|
|
1390
1405
|
sessionId: this.state.sessionId,
|
|
1391
|
-
page:
|
|
1406
|
+
page: M(),
|
|
1392
1407
|
model: this.options.model
|
|
1393
1408
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1394
1409
|
}
|
|
@@ -1399,15 +1414,15 @@ class Ce {
|
|
|
1399
1414
|
if (!s || !n || !r)
|
|
1400
1415
|
return;
|
|
1401
1416
|
const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1402
|
-
if (!a && !c || !
|
|
1417
|
+
if (!a && !c || !kr(o)) {
|
|
1403
1418
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1404
1419
|
type: "tool.result",
|
|
1405
1420
|
sessionId: s,
|
|
1406
1421
|
callId: n,
|
|
1407
1422
|
toolName: r,
|
|
1408
1423
|
summary: i,
|
|
1409
|
-
rawInput:
|
|
1410
|
-
rawOutput:
|
|
1424
|
+
rawInput: _(o),
|
|
1425
|
+
rawOutput: _({
|
|
1411
1426
|
ok: !1,
|
|
1412
1427
|
toolName: r,
|
|
1413
1428
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -1422,7 +1437,7 @@ class Ce {
|
|
|
1422
1437
|
callId: n,
|
|
1423
1438
|
toolName: r,
|
|
1424
1439
|
summary: i,
|
|
1425
|
-
rawInput:
|
|
1440
|
+
rawInput: _(o),
|
|
1426
1441
|
rawOutput: {
|
|
1427
1442
|
ok: !1,
|
|
1428
1443
|
toolName: r,
|
|
@@ -1431,7 +1446,7 @@ class Ce {
|
|
|
1431
1446
|
});
|
|
1432
1447
|
return;
|
|
1433
1448
|
}
|
|
1434
|
-
const l =
|
|
1449
|
+
const l = Zs(this.state.messages);
|
|
1435
1450
|
this.activeBrowserToolCalls.set(n, {
|
|
1436
1451
|
event: {
|
|
1437
1452
|
type: "tool.result",
|
|
@@ -1439,7 +1454,7 @@ class Ce {
|
|
|
1439
1454
|
callId: n,
|
|
1440
1455
|
toolName: r,
|
|
1441
1456
|
summary: i,
|
|
1442
|
-
rawInput:
|
|
1457
|
+
rawInput: _(o),
|
|
1443
1458
|
rawOutput: null
|
|
1444
1459
|
},
|
|
1445
1460
|
startedAtMs: Date.now(),
|
|
@@ -1447,9 +1462,9 @@ class Ce {
|
|
|
1447
1462
|
startedAtOrigin: location.origin
|
|
1448
1463
|
}), this.installSessionUserFilesApi(l);
|
|
1449
1464
|
let h = null, f;
|
|
1450
|
-
h = await this.executeRuntimeHelper(), f = await
|
|
1465
|
+
h = await this.executeRuntimeHelper(), f = await pe(
|
|
1451
1466
|
o,
|
|
1452
|
-
|
|
1467
|
+
un(t.runtimeContext, this.options.backendUrl)
|
|
1453
1468
|
).catch((I) => ({
|
|
1454
1469
|
ok: !1,
|
|
1455
1470
|
exception: {
|
|
@@ -1461,12 +1476,12 @@ class Ce {
|
|
|
1461
1476
|
callId: n,
|
|
1462
1477
|
toolName: r,
|
|
1463
1478
|
summary: o.summary,
|
|
1464
|
-
rawInput:
|
|
1465
|
-
rawOutput:
|
|
1466
|
-
}),
|
|
1479
|
+
rawInput: _(o),
|
|
1480
|
+
rawOutput: _(Un(f, h))
|
|
1481
|
+
}), Ir(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1467
1482
|
}
|
|
1468
1483
|
setToolMessageLoading(t, s) {
|
|
1469
|
-
const n =
|
|
1484
|
+
const n = Gn(
|
|
1470
1485
|
this.state.messages,
|
|
1471
1486
|
t,
|
|
1472
1487
|
s
|
|
@@ -1477,47 +1492,47 @@ class Ce {
|
|
|
1477
1492
|
if (this.pageLifecycleCleanup)
|
|
1478
1493
|
return;
|
|
1479
1494
|
const t = () => {
|
|
1480
|
-
|
|
1495
|
+
Fe(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1481
1496
|
};
|
|
1482
1497
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1483
1498
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1484
1499
|
};
|
|
1485
1500
|
}
|
|
1486
1501
|
installSessionUserFilesApi(t) {
|
|
1487
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1502
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Qs(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1488
1503
|
}
|
|
1489
1504
|
cleanupSessionUserFilesApi() {
|
|
1490
|
-
this.sessionUserFilesApiCleanup && (
|
|
1505
|
+
this.sessionUserFilesApiCleanup && (cn(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1491
1506
|
}
|
|
1492
1507
|
async executeRuntimeHelper() {
|
|
1493
1508
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1494
1509
|
return null;
|
|
1495
|
-
const t = await
|
|
1510
|
+
const t = await pe({
|
|
1496
1511
|
javascript: this.runtimeHelperJavascript
|
|
1497
1512
|
});
|
|
1498
|
-
return t.ok === !1 ?
|
|
1513
|
+
return t.ok === !1 ? Pn(t) : null;
|
|
1499
1514
|
}
|
|
1500
1515
|
enableNetworkCapture() {
|
|
1501
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1502
|
-
|
|
1516
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = Ks((t) => {
|
|
1517
|
+
vr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1503
1518
|
}));
|
|
1504
1519
|
}
|
|
1505
1520
|
enqueueNetworkEvent(t) {
|
|
1506
|
-
this.queuedNetworkEvents.length >=
|
|
1521
|
+
this.queuedNetworkEvents.length >= qs || (this.queuedNetworkEvents.push(Dr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1507
1522
|
this.networkBatchTimer = null;
|
|
1508
1523
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1509
1524
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
1510
1525
|
type: "network.batch",
|
|
1511
1526
|
sessionId: this.state.sessionId ?? void 0,
|
|
1512
|
-
page:
|
|
1527
|
+
page: M(),
|
|
1513
1528
|
events: s
|
|
1514
1529
|
});
|
|
1515
|
-
},
|
|
1530
|
+
}, Ls)));
|
|
1516
1531
|
}
|
|
1517
1532
|
scheduleReconnect() {
|
|
1518
1533
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1519
1534
|
return;
|
|
1520
|
-
const t =
|
|
1535
|
+
const t = js(this.reconnectAttempts);
|
|
1521
1536
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1522
1537
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1523
1538
|
S("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1533,8 +1548,8 @@ class Ce {
|
|
|
1533
1548
|
const t = this.socket;
|
|
1534
1549
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1535
1550
|
this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1536
|
-
},
|
|
1537
|
-
},
|
|
1551
|
+
}, ks));
|
|
1552
|
+
}, Ms);
|
|
1538
1553
|
}
|
|
1539
1554
|
stopHeartbeat() {
|
|
1540
1555
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1552,7 +1567,7 @@ class Ce {
|
|
|
1552
1567
|
this.clearSocketConnectTimer(), this.clearSocketAuthTimer();
|
|
1553
1568
|
}
|
|
1554
1569
|
replaceTimedOutSocket(t) {
|
|
1555
|
-
this.socket !== t || this.state.status === "closed" || (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), t.readyState !== WebSocket.CLOSED && t.readyState !== WebSocket.CLOSING && t.close());
|
|
1570
|
+
this.socket !== t || this.state.status === "closed" || (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.rememberBrowserConnectionInterruptionForActiveRun(), this.setReconnectingState(), this.scheduleReconnect(), t.readyState !== WebSocket.CLOSED && t.readyState !== WebSocket.CLOSING && t.close());
|
|
1556
1571
|
}
|
|
1557
1572
|
setState(t) {
|
|
1558
1573
|
this.state = {
|
|
@@ -1560,7 +1575,7 @@ class Ce {
|
|
|
1560
1575
|
...t,
|
|
1561
1576
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1562
1577
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1563
|
-
},
|
|
1578
|
+
}, mr(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
|
|
1564
1579
|
status: this.state.status,
|
|
1565
1580
|
sessionId: this.state.sessionId,
|
|
1566
1581
|
messageCount: this.state.messages.length,
|
|
@@ -1573,18 +1588,24 @@ class Ce {
|
|
|
1573
1588
|
const t = this.state.lastError !== null && !this.state.isThinking && this.state.lastErrorCode !== "connection_failed";
|
|
1574
1589
|
this.setState(t ? { status: "reconnecting" } : { status: "reconnecting", lastError: null });
|
|
1575
1590
|
}
|
|
1591
|
+
rememberBrowserConnectionInterruptionForActiveRun() {
|
|
1592
|
+
this.state.isThinking && this.activeClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId);
|
|
1593
|
+
}
|
|
1594
|
+
getRunRecoveryExhaustedErrorMessage(t) {
|
|
1595
|
+
return t && this.browserConnectionInterruptedClientMessageIds.has(t) ? Os : vs;
|
|
1596
|
+
}
|
|
1576
1597
|
emit(t, s) {
|
|
1577
1598
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1578
1599
|
}
|
|
1579
1600
|
}
|
|
1580
|
-
const
|
|
1581
|
-
function
|
|
1582
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1601
|
+
const Mt = /* @__PURE__ */ new WeakMap();
|
|
1602
|
+
function Ks(e) {
|
|
1603
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Gs();
|
|
1583
1604
|
return t.subscribers.add(e), () => {
|
|
1584
1605
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1585
1606
|
};
|
|
1586
1607
|
}
|
|
1587
|
-
function
|
|
1608
|
+
function Gs() {
|
|
1588
1609
|
const e = /* @__PURE__ */ new Set(), t = (I) => {
|
|
1589
1610
|
e.forEach((g) => {
|
|
1590
1611
|
try {
|
|
@@ -1601,31 +1622,31 @@ function $s() {
|
|
|
1601
1622
|
throw m;
|
|
1602
1623
|
}
|
|
1603
1624
|
try {
|
|
1604
|
-
const m = g instanceof Request ? g : null,
|
|
1605
|
-
if (!x(
|
|
1625
|
+
const m = g instanceof Request ? g : null, E = _r(g, m), T = $e(u?.headers ?? m?.headers);
|
|
1626
|
+
if (!x(E, T, u?.body)) {
|
|
1606
1627
|
const F = {
|
|
1607
|
-
requestId:
|
|
1608
|
-
url:
|
|
1628
|
+
requestId: Ut("fetch"),
|
|
1629
|
+
url: U(E, bt),
|
|
1609
1630
|
method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
1610
1631
|
requestHeaders: T,
|
|
1611
|
-
requestBody:
|
|
1632
|
+
requestBody: Ee(u?.body),
|
|
1612
1633
|
resourceType: "fetch",
|
|
1613
1634
|
startedAt: new Date(d).toISOString()
|
|
1614
1635
|
};
|
|
1615
1636
|
p.then(
|
|
1616
|
-
(
|
|
1617
|
-
|
|
1637
|
+
(C) => {
|
|
1638
|
+
Cr(C, F, d, t).catch(() => {
|
|
1618
1639
|
t({
|
|
1619
1640
|
...F,
|
|
1620
|
-
responseStatus:
|
|
1641
|
+
responseStatus: C.status,
|
|
1621
1642
|
durationMs: Date.now() - d
|
|
1622
1643
|
});
|
|
1623
1644
|
});
|
|
1624
1645
|
},
|
|
1625
|
-
(
|
|
1646
|
+
(C) => {
|
|
1626
1647
|
t({
|
|
1627
1648
|
...F,
|
|
1628
|
-
errorText:
|
|
1649
|
+
errorText: U(C instanceof Error ? C.message : String(C)),
|
|
1629
1650
|
durationMs: Date.now() - d
|
|
1630
1651
|
});
|
|
1631
1652
|
}
|
|
@@ -1635,28 +1656,28 @@ function $s() {
|
|
|
1635
1656
|
}
|
|
1636
1657
|
return p;
|
|
1637
1658
|
}, a = function(g, u, d, p, m) {
|
|
1638
|
-
const
|
|
1639
|
-
return
|
|
1640
|
-
requestId:
|
|
1659
|
+
const E = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
1660
|
+
return Mt.set(this, {
|
|
1661
|
+
requestId: Ut("xhr"),
|
|
1641
1662
|
method: String(g ?? "GET").toUpperCase(),
|
|
1642
|
-
url:
|
|
1663
|
+
url: U(T, bt),
|
|
1643
1664
|
requestHeaders: {},
|
|
1644
1665
|
startedAtMs: Date.now(),
|
|
1645
1666
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1646
1667
|
excluded: x(T)
|
|
1647
|
-
}),
|
|
1668
|
+
}), E;
|
|
1648
1669
|
}, c = function(g, u) {
|
|
1649
|
-
const d = r.call(this, g, u), p =
|
|
1650
|
-
return p && Object.keys(p.requestHeaders).length <
|
|
1670
|
+
const d = r.call(this, g, u), p = Mt.get(this);
|
|
1671
|
+
return p && Object.keys(p.requestHeaders).length < jt && (p.requestHeaders[g] = Jt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
|
|
1651
1672
|
}, l = function(g) {
|
|
1652
1673
|
try {
|
|
1653
|
-
const u =
|
|
1654
|
-
u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody =
|
|
1674
|
+
const u = Mt.get(this);
|
|
1675
|
+
u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody = Ee(g), u.excluded || this.addEventListener(
|
|
1655
1676
|
"loadend",
|
|
1656
1677
|
() => {
|
|
1657
1678
|
queueMicrotask(() => {
|
|
1658
1679
|
try {
|
|
1659
|
-
const d =
|
|
1680
|
+
const d = Nr(this.getAllResponseHeaders());
|
|
1660
1681
|
t({
|
|
1661
1682
|
requestId: u.requestId,
|
|
1662
1683
|
url: u.url,
|
|
@@ -1666,7 +1687,7 @@ function $s() {
|
|
|
1666
1687
|
resourceType: "xhr",
|
|
1667
1688
|
responseStatus: this.status,
|
|
1668
1689
|
responseHeaders: d,
|
|
1669
|
-
responseBody:
|
|
1690
|
+
responseBody: Pr(this, d),
|
|
1670
1691
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1671
1692
|
startedAt: u.startedAt,
|
|
1672
1693
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -1707,8 +1728,8 @@ function $s() {
|
|
|
1707
1728
|
continue;
|
|
1708
1729
|
const d = performance.timeOrigin + u.startTime;
|
|
1709
1730
|
t({
|
|
1710
|
-
requestId:
|
|
1711
|
-
url:
|
|
1731
|
+
requestId: Ut("resource"),
|
|
1732
|
+
url: U(u.name, bt),
|
|
1712
1733
|
method: "GET",
|
|
1713
1734
|
resourceType: "resource",
|
|
1714
1735
|
responseStatus: u.responseStatus,
|
|
@@ -1758,17 +1779,17 @@ function S(e, t, s) {
|
|
|
1758
1779
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1759
1780
|
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 }));
|
|
1760
1781
|
}
|
|
1761
|
-
function
|
|
1782
|
+
function he(e) {
|
|
1762
1783
|
const t = typeof e == "function" ? e() : e;
|
|
1763
1784
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1764
1785
|
}
|
|
1765
|
-
function
|
|
1786
|
+
function Xs(e) {
|
|
1766
1787
|
return e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call";
|
|
1767
1788
|
}
|
|
1768
|
-
function
|
|
1789
|
+
function Js(e) {
|
|
1769
1790
|
return e.type === "run.steered" || e.type === "run.ack" || e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call" || e.type === "tool.status" || e.type === "error" && typeof e.requestId != "string";
|
|
1770
1791
|
}
|
|
1771
|
-
function
|
|
1792
|
+
function kt(e) {
|
|
1772
1793
|
if (typeof e.sessionId == "string")
|
|
1773
1794
|
return e.sessionId;
|
|
1774
1795
|
if (e.session && typeof e.session == "object") {
|
|
@@ -1783,8 +1804,8 @@ function Mt(e) {
|
|
|
1783
1804
|
}
|
|
1784
1805
|
return null;
|
|
1785
1806
|
}
|
|
1786
|
-
const
|
|
1787
|
-
function
|
|
1807
|
+
const Vs = 5e3, Ys = 12e4;
|
|
1808
|
+
function Zs(e) {
|
|
1788
1809
|
const t = [];
|
|
1789
1810
|
for (const s of e)
|
|
1790
1811
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1795,30 +1816,30 @@ function Xs(e) {
|
|
|
1795
1816
|
});
|
|
1796
1817
|
return t;
|
|
1797
1818
|
}
|
|
1798
|
-
function
|
|
1819
|
+
function Qs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1799
1820
|
const n = [
|
|
1800
|
-
|
|
1801
|
-
|
|
1821
|
+
en(),
|
|
1822
|
+
tn()
|
|
1802
1823
|
].filter((r) => typeof r == "function");
|
|
1803
1824
|
return () => {
|
|
1804
1825
|
for (const r of n.reverse())
|
|
1805
1826
|
r();
|
|
1806
1827
|
};
|
|
1807
1828
|
}
|
|
1808
|
-
function
|
|
1809
|
-
return
|
|
1829
|
+
function tn() {
|
|
1830
|
+
return be(globalThis, "getPageSnapshot", async () => zt());
|
|
1810
1831
|
}
|
|
1811
|
-
function
|
|
1812
|
-
return
|
|
1813
|
-
inspectImage: async (t, s) => await
|
|
1832
|
+
function en() {
|
|
1833
|
+
return be(globalThis, "pageImages", {
|
|
1834
|
+
inspectImage: async (t, s) => await sn(t, s)
|
|
1814
1835
|
});
|
|
1815
1836
|
}
|
|
1816
|
-
async function
|
|
1817
|
-
const s =
|
|
1837
|
+
async function sn(e, t = {}) {
|
|
1838
|
+
const s = an(t.name), n = await nn(e);
|
|
1818
1839
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1819
1840
|
type: "pluno.pageImages.inspectImage",
|
|
1820
1841
|
imageAttached: !1,
|
|
1821
|
-
imageAttachmentError:
|
|
1842
|
+
imageAttachmentError: _e
|
|
1822
1843
|
} : {
|
|
1823
1844
|
type: "pluno.pageImages.inspectImage",
|
|
1824
1845
|
imageAttached: !0,
|
|
@@ -1832,15 +1853,15 @@ async function Zs(e, t = {}) {
|
|
|
1832
1853
|
imageAttachmentError: n.error
|
|
1833
1854
|
};
|
|
1834
1855
|
}
|
|
1835
|
-
async function
|
|
1836
|
-
return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error:
|
|
1856
|
+
async function nn(e) {
|
|
1857
|
+
return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: _e } : {
|
|
1837
1858
|
ok: !0,
|
|
1838
1859
|
mimeType: e.type,
|
|
1839
1860
|
sizeBytes: e.size,
|
|
1840
|
-
dataUrl: await
|
|
1841
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
1861
|
+
dataUrl: await ln(e)
|
|
1862
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : rn(e);
|
|
1842
1863
|
}
|
|
1843
|
-
function
|
|
1864
|
+
function rn(e) {
|
|
1844
1865
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1845
1866
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1846
1867
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1851,7 +1872,7 @@ function tn(e) {
|
|
|
1851
1872
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1852
1873
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1853
1874
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1854
|
-
const o =
|
|
1875
|
+
const o = on(i);
|
|
1855
1876
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1856
1877
|
ok: !0,
|
|
1857
1878
|
mimeType: r,
|
|
@@ -1859,22 +1880,22 @@ function tn(e) {
|
|
|
1859
1880
|
dataUrl: `data:${r};base64,${i}`
|
|
1860
1881
|
};
|
|
1861
1882
|
}
|
|
1862
|
-
function
|
|
1883
|
+
function on(e) {
|
|
1863
1884
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1864
1885
|
return null;
|
|
1865
1886
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1866
1887
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1867
1888
|
}
|
|
1868
|
-
function
|
|
1889
|
+
function an(e) {
|
|
1869
1890
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1870
1891
|
}
|
|
1871
|
-
function
|
|
1892
|
+
function cn(e) {
|
|
1872
1893
|
try {
|
|
1873
1894
|
e();
|
|
1874
1895
|
} catch {
|
|
1875
1896
|
}
|
|
1876
1897
|
}
|
|
1877
|
-
function
|
|
1898
|
+
function ln(e) {
|
|
1878
1899
|
return new Promise((t, s) => {
|
|
1879
1900
|
const n = new FileReader();
|
|
1880
1901
|
n.onload = () => {
|
|
@@ -1886,9 +1907,9 @@ function rn(e) {
|
|
|
1886
1907
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1887
1908
|
});
|
|
1888
1909
|
}
|
|
1889
|
-
async function
|
|
1910
|
+
async function pe(e, t) {
|
|
1890
1911
|
const s = Object.getPrototypeOf(async function() {
|
|
1891
|
-
}).constructor, n = e.timeoutMs ??
|
|
1912
|
+
}).constructor, n = e.timeoutMs ?? Vs, r = Date.now(), i = [];
|
|
1892
1913
|
let o;
|
|
1893
1914
|
const a = {
|
|
1894
1915
|
log: console.log,
|
|
@@ -1906,7 +1927,7 @@ async function he(e, t) {
|
|
|
1906
1927
|
o = window.setTimeout(() => f(l), n);
|
|
1907
1928
|
})
|
|
1908
1929
|
]);
|
|
1909
|
-
return h === l ?
|
|
1930
|
+
return h === l ? dn(n) : {
|
|
1910
1931
|
ok: !0,
|
|
1911
1932
|
result: h,
|
|
1912
1933
|
console: i,
|
|
@@ -1935,7 +1956,7 @@ async function he(e, t) {
|
|
|
1935
1956
|
t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
1936
1957
|
}
|
|
1937
1958
|
}
|
|
1938
|
-
function
|
|
1959
|
+
function un(e, t) {
|
|
1939
1960
|
if (!e || typeof e != "object")
|
|
1940
1961
|
return;
|
|
1941
1962
|
const s = e.sandboxFilesToken;
|
|
@@ -1945,7 +1966,7 @@ function on(e, t) {
|
|
|
1945
1966
|
const r = () => {
|
|
1946
1967
|
if (!n)
|
|
1947
1968
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
1948
|
-
}, i = async (a, c) => await
|
|
1969
|
+
}, i = async (a, c) => await Ts(`${t.replace(/\/$/, "")}${a}`, c);
|
|
1949
1970
|
return {
|
|
1950
1971
|
value: Object.freeze({
|
|
1951
1972
|
upload: async (a) => {
|
|
@@ -1979,7 +2000,7 @@ function on(e, t) {
|
|
|
1979
2000
|
}
|
|
1980
2001
|
};
|
|
1981
2002
|
}
|
|
1982
|
-
function
|
|
2003
|
+
function dn(e) {
|
|
1983
2004
|
return {
|
|
1984
2005
|
ok: !1,
|
|
1985
2006
|
exception: {
|
|
@@ -1993,10 +2014,10 @@ function an(e) {
|
|
|
1993
2014
|
}
|
|
1994
2015
|
};
|
|
1995
2016
|
}
|
|
1996
|
-
function
|
|
2017
|
+
function hn(e) {
|
|
1997
2018
|
return e.replace(/\/+$/, "");
|
|
1998
2019
|
}
|
|
1999
|
-
function
|
|
2020
|
+
function pn(e) {
|
|
2000
2021
|
const t = {
|
|
2001
2022
|
sidepanel: "extension_sidepanel",
|
|
2002
2023
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2008,17 +2029,17 @@ function ln(e) {
|
|
|
2008
2029
|
};
|
|
2009
2030
|
return e && e in t ? t[e] : e ?? "embedded_custom_ui";
|
|
2010
2031
|
}
|
|
2011
|
-
function
|
|
2032
|
+
function fn(e) {
|
|
2012
2033
|
return e === "pluno" ? "scheduled_continuation" : e ?? "user";
|
|
2013
2034
|
}
|
|
2014
|
-
function
|
|
2035
|
+
function gn(e, t = location.origin) {
|
|
2015
2036
|
return /origin (?:is not allowed|does not match browser origin)/i.test(e) ? `Pluno widget blocked on ${t}: this domain is not allowed. Add ${t} in Pluno under Integration > Domains.` : null;
|
|
2016
2037
|
}
|
|
2017
|
-
function
|
|
2038
|
+
function mn(e) {
|
|
2018
2039
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
2019
2040
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
2020
2041
|
}
|
|
2021
|
-
function
|
|
2042
|
+
function M() {
|
|
2022
2043
|
const e = Oe();
|
|
2023
2044
|
return {
|
|
2024
2045
|
url: location.href,
|
|
@@ -2027,19 +2048,19 @@ function k() {
|
|
|
2027
2048
|
...e ? { plunoProductAgentUi: e } : {}
|
|
2028
2049
|
};
|
|
2029
2050
|
}
|
|
2030
|
-
function
|
|
2051
|
+
function yn() {
|
|
2031
2052
|
return {
|
|
2032
2053
|
pageUrl: location.href,
|
|
2033
2054
|
pageTitle: document.title,
|
|
2034
|
-
htmlContent:
|
|
2055
|
+
htmlContent: zt()
|
|
2035
2056
|
};
|
|
2036
2057
|
}
|
|
2037
|
-
function
|
|
2038
|
-
return st.add(e), Z || (Z =
|
|
2058
|
+
function In(e) {
|
|
2059
|
+
return st.add(e), Z || (Z = Tn()), () => {
|
|
2039
2060
|
st.delete(e), st.size === 0 && (Z?.(), Z = null);
|
|
2040
2061
|
};
|
|
2041
2062
|
}
|
|
2042
|
-
function
|
|
2063
|
+
function Tn() {
|
|
2043
2064
|
const e = () => {
|
|
2044
2065
|
for (const i of Array.from(st))
|
|
2045
2066
|
i();
|
|
@@ -2054,10 +2075,10 @@ function gn() {
|
|
|
2054
2075
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
2055
2076
|
};
|
|
2056
2077
|
}
|
|
2057
|
-
function
|
|
2078
|
+
function wn() {
|
|
2058
2079
|
return Oe()?.surface === "browser_extension_sdk_preview";
|
|
2059
2080
|
}
|
|
2060
|
-
function
|
|
2081
|
+
function zt() {
|
|
2061
2082
|
if (!document.body)
|
|
2062
2083
|
return "";
|
|
2063
2084
|
const e = [], t = [], s = (d, p) => {
|
|
@@ -2070,12 +2091,12 @@ function jt() {
|
|
|
2070
2091
|
);
|
|
2071
2092
|
for (const d of r.slice(0, 3))
|
|
2072
2093
|
s("Active overlay", _t(z(d), t));
|
|
2073
|
-
const i =
|
|
2094
|
+
const i = Sn(), o = i ? _t(z(i), t) : "";
|
|
2074
2095
|
s("Main page content", o), s("Additional visible page text", _t(z(document.body), t));
|
|
2075
2096
|
const a = e.map(([d, p]) => `${d}:
|
|
2076
2097
|
${p}`).join(`
|
|
2077
2098
|
|
|
2078
|
-
`).trim().slice(0, 12e3), c =
|
|
2099
|
+
`).trim().slice(0, 12e3), c = An(r, i).trim(), l = `Simplified DOM outline:
|
|
2079
2100
|
`, h = `
|
|
2080
2101
|
|
|
2081
2102
|
Visible page text:
|
|
@@ -2103,10 +2124,10 @@ function Pe(e) {
|
|
|
2103
2124
|
const t = window.getComputedStyle(e);
|
|
2104
2125
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
2105
2126
|
}
|
|
2106
|
-
function
|
|
2127
|
+
function Sn() {
|
|
2107
2128
|
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Pe).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
|
|
2108
2129
|
}
|
|
2109
|
-
function
|
|
2130
|
+
function An(e, t) {
|
|
2110
2131
|
const s = /* @__PURE__ */ new Set([
|
|
2111
2132
|
"main",
|
|
2112
2133
|
"nav",
|
|
@@ -2186,7 +2207,7 @@ function In(e, t) {
|
|
|
2186
2207
|
"data-test",
|
|
2187
2208
|
"data-qa",
|
|
2188
2209
|
"data-cy"
|
|
2189
|
-
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } =
|
|
2210
|
+
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = En(), I = new Set(e);
|
|
2190
2211
|
t && I.add(t);
|
|
2191
2212
|
let g = 0;
|
|
2192
2213
|
const u = (T) => {
|
|
@@ -2196,41 +2217,41 @@ function In(e, t) {
|
|
|
2196
2217
|
const D = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
|
|
2197
2218
|
return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
|
|
2198
2219
|
}, p = (T, D, F) => {
|
|
2199
|
-
const
|
|
2200
|
-
const
|
|
2201
|
-
if (g >= 1e3 && !K || F.has(A) || i.has(
|
|
2220
|
+
const C = (A, dt) => {
|
|
2221
|
+
const b = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
|
|
2222
|
+
if (g >= 1e3 && !K || F.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
|
|
2202
2223
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2203
2224
|
g += 1;
|
|
2204
|
-
const
|
|
2225
|
+
const Vt = u(A), G = ve(A), Ye = a.has(Vt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
|
|
2205
2226
|
for (const y of pt) {
|
|
2206
2227
|
const w = d(y);
|
|
2207
2228
|
X.set(w, (X.get(w) ?? 0) + 1);
|
|
2208
2229
|
}
|
|
2209
|
-
const ft = /* @__PURE__ */ new Map(),
|
|
2230
|
+
const ft = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Map();
|
|
2210
2231
|
for (const y of pt) {
|
|
2211
|
-
const w = d(y),
|
|
2212
|
-
|
|
2232
|
+
const w = d(y), v = Yt.get(w) ?? 0;
|
|
2233
|
+
Yt.set(w, v + 1), (X.get(w) ?? 0) > 8 && v >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
|
|
2213
2234
|
}
|
|
2214
|
-
const
|
|
2235
|
+
const Zt = /* @__PURE__ */ new Map(), Qt = /* @__PURE__ */ new Set(), gt = [], te = [];
|
|
2215
2236
|
for (const y of pt) {
|
|
2216
|
-
const w = d(y),
|
|
2217
|
-
if (
|
|
2218
|
-
|
|
2237
|
+
const w = d(y), v = X.get(w) ?? 0, ne = Zt.get(w) ?? 0;
|
|
2238
|
+
if (Zt.set(w, ne + 1), v > 8 && ne >= 6 && !h.has(y)) {
|
|
2239
|
+
Qt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Qt.add(w));
|
|
2219
2240
|
continue;
|
|
2220
2241
|
}
|
|
2221
|
-
const
|
|
2222
|
-
|
|
2242
|
+
const re = C(y, dt);
|
|
2243
|
+
te.push(re), gt.push(re.lines);
|
|
2223
2244
|
}
|
|
2224
2245
|
const mt = [];
|
|
2225
2246
|
if (A.shadowRoot)
|
|
2226
2247
|
for (const y of Array.from(A.shadowRoot.children))
|
|
2227
|
-
y instanceof HTMLElement && mt.push(
|
|
2228
|
-
const J = [...
|
|
2248
|
+
y instanceof HTMLElement && mt.push(C(y, dt + 1));
|
|
2249
|
+
const J = [...te, ...mt], yt = G.length > 0 || Ye || J.some((y) => y.hasUsefulContent), ee = B(
|
|
2229
2250
|
[G, ...J.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2230
|
-
).slice(0, 180),
|
|
2251
|
+
).slice(0, 180), Ze = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), se = l.some((y) => A.hasAttribute(y)) || !!Vt || Ze, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(b) || se || K) && (yt || K) && (!r.has(b) || yt || se || K), Tt = It ? 1 : 0, H = [];
|
|
2231
2252
|
if (It) {
|
|
2232
|
-
const y = J.some((
|
|
2233
|
-
H.push(
|
|
2253
|
+
const y = J.some((v) => v.containsTextElement), w = n.has(b) && !y ? ee : G;
|
|
2254
|
+
H.push(De(A, c, o, w.slice(0, 180)));
|
|
2234
2255
|
}
|
|
2235
2256
|
for (const y of gt)
|
|
2236
2257
|
H.push(...Q(y, Tt));
|
|
@@ -2238,25 +2259,25 @@ function In(e, t) {
|
|
|
2238
2259
|
if (wt.length > 0) {
|
|
2239
2260
|
const y = wt.slice(0, 20);
|
|
2240
2261
|
wt.length > y.length && y.push("… shadow DOM omitted");
|
|
2241
|
-
const w =
|
|
2262
|
+
const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
|
|
2242
2263
|
if (dt < 2 && !w) {
|
|
2243
|
-
const
|
|
2244
|
-
H.push(...Q([
|
|
2264
|
+
const v = It ? "#shadow-root" : `${b} #shadow-root`;
|
|
2265
|
+
H.push(...Q([v, ...Q(y, 1)], Tt));
|
|
2245
2266
|
} else
|
|
2246
2267
|
H.push(...Q(y, Tt));
|
|
2247
2268
|
}
|
|
2248
2269
|
return {
|
|
2249
2270
|
lines: H,
|
|
2250
2271
|
hasUsefulContent: yt,
|
|
2251
|
-
textPreview:
|
|
2252
|
-
containsTextElement: n.has(
|
|
2272
|
+
textPreview: ee,
|
|
2273
|
+
containsTextElement: n.has(b) || J.some((y) => y.containsTextElement)
|
|
2253
2274
|
};
|
|
2254
2275
|
};
|
|
2255
|
-
return [`--- ${D} ---`, ...
|
|
2276
|
+
return [`--- ${D} ---`, ...C(T, 0).lines].join(`
|
|
2256
2277
|
`);
|
|
2257
|
-
}, m = [],
|
|
2258
|
-
|
|
2259
|
-
${JSON.stringify(
|
|
2278
|
+
}, m = [], E = B(window.getSelection()?.toString() ?? "");
|
|
2279
|
+
E && m.push(`--- selected text ---
|
|
2280
|
+
${JSON.stringify(E)}`), f.length > 0 && m.push(Rn(f, s, c, o));
|
|
2260
2281
|
for (const T of e.slice(0, 3))
|
|
2261
2282
|
m.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2262
2283
|
if (t && m.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2267,11 +2288,11 @@ ${JSON.stringify(b)}`), f.length > 0 && m.push(wn(f, s, c, o));
|
|
|
2267
2288
|
|
|
2268
2289
|
`);
|
|
2269
2290
|
}
|
|
2270
|
-
function
|
|
2291
|
+
function De(e, t, s, n) {
|
|
2271
2292
|
const r = e.tagName.toLowerCase();
|
|
2272
2293
|
let i = r;
|
|
2273
2294
|
const o = e.getAttribute("id");
|
|
2274
|
-
o &&
|
|
2295
|
+
o && bn(o) && (i += `#${o}`);
|
|
2275
2296
|
for (const a of t) {
|
|
2276
2297
|
const c = e.getAttribute(a);
|
|
2277
2298
|
c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
|
|
@@ -2284,7 +2305,7 @@ function Ue(e, t, s, n) {
|
|
|
2284
2305
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2285
2306
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2286
2307
|
}
|
|
2287
|
-
function
|
|
2308
|
+
function En() {
|
|
2288
2309
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
|
|
2289
2310
|
if (!a)
|
|
2290
2311
|
return;
|
|
@@ -2305,7 +2326,7 @@ function Tn() {
|
|
|
2305
2326
|
n = n.shadowRoot.activeElement;
|
|
2306
2327
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2307
2328
|
const r = window.getSelection();
|
|
2308
|
-
r && !r.isCollapsed && (s(
|
|
2329
|
+
r && !r.isCollapsed && (s(fe(r.anchorNode), "selected text"), s(fe(r.focusNode), "selected text"));
|
|
2309
2330
|
const i = [
|
|
2310
2331
|
["[aria-selected='true']", "selected"],
|
|
2311
2332
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2327,7 +2348,7 @@ function Tn() {
|
|
|
2327
2348
|
priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
|
|
2328
2349
|
};
|
|
2329
2350
|
}
|
|
2330
|
-
function
|
|
2351
|
+
function Rn(e, t, s, n) {
|
|
2331
2352
|
const r = ["--- active/current elements ---"];
|
|
2332
2353
|
for (const i of e) {
|
|
2333
2354
|
const o = [];
|
|
@@ -2338,18 +2359,18 @@ function wn(e, t, s, n) {
|
|
|
2338
2359
|
const f = a.getRootNode();
|
|
2339
2360
|
a = a.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
|
|
2340
2361
|
}
|
|
2341
|
-
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) =>
|
|
2362
|
+
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => De(
|
|
2342
2363
|
h,
|
|
2343
2364
|
s,
|
|
2344
2365
|
n,
|
|
2345
|
-
f === c.length - 1 ?
|
|
2366
|
+
f === c.length - 1 ? ve(h).slice(0, 180) : ""
|
|
2346
2367
|
));
|
|
2347
2368
|
o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
|
|
2348
2369
|
}
|
|
2349
2370
|
return r.join(`
|
|
2350
2371
|
`);
|
|
2351
2372
|
}
|
|
2352
|
-
function
|
|
2373
|
+
function fe(e) {
|
|
2353
2374
|
return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
|
|
2354
2375
|
}
|
|
2355
2376
|
function Q(e, t) {
|
|
@@ -2358,17 +2379,17 @@ function Q(e, t) {
|
|
|
2358
2379
|
const s = " ".repeat(t);
|
|
2359
2380
|
return e.map((n) => `${s}${n}`);
|
|
2360
2381
|
}
|
|
2361
|
-
function
|
|
2382
|
+
function ve(e) {
|
|
2362
2383
|
return B(
|
|
2363
2384
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2364
2385
|
);
|
|
2365
2386
|
}
|
|
2366
|
-
function
|
|
2387
|
+
function bn(e) {
|
|
2367
2388
|
return e.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(e) && !/[a-f0-9]{12,}/i.test(e) && !/:r[0-9a-z]+:/i.test(e);
|
|
2368
2389
|
}
|
|
2369
2390
|
function Oe() {
|
|
2370
|
-
const e = document.querySelector(
|
|
2371
|
-
if (!(e ?? document.querySelector(
|
|
2391
|
+
const e = document.querySelector(ie);
|
|
2392
|
+
if (!(e ?? document.querySelector(Dt)))
|
|
2372
2393
|
return;
|
|
2373
2394
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2374
2395
|
return {
|
|
@@ -2377,28 +2398,28 @@ function Oe() {
|
|
|
2377
2398
|
selectors: [
|
|
2378
2399
|
{
|
|
2379
2400
|
name: "widget_host",
|
|
2380
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2401
|
+
selector: s === "browser_extension_sdk_preview" ? ie : Dt,
|
|
2381
2402
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2382
2403
|
},
|
|
2383
2404
|
{
|
|
2384
2405
|
name: "widget_root",
|
|
2385
|
-
selector:
|
|
2406
|
+
selector: ws,
|
|
2386
2407
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2387
2408
|
},
|
|
2388
2409
|
{
|
|
2389
2410
|
name: "widget_panel",
|
|
2390
|
-
selector:
|
|
2411
|
+
selector: Ss,
|
|
2391
2412
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2392
2413
|
},
|
|
2393
2414
|
{
|
|
2394
2415
|
name: "widget_timeline",
|
|
2395
|
-
selector:
|
|
2416
|
+
selector: As,
|
|
2396
2417
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2397
2418
|
}
|
|
2398
2419
|
]
|
|
2399
2420
|
};
|
|
2400
2421
|
}
|
|
2401
|
-
function
|
|
2422
|
+
function Mn(e) {
|
|
2402
2423
|
try {
|
|
2403
2424
|
const t = JSON.parse(e);
|
|
2404
2425
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2406,16 +2427,16 @@ function An(e) {
|
|
|
2406
2427
|
return { type: "error", message: "Invalid server event" };
|
|
2407
2428
|
}
|
|
2408
2429
|
}
|
|
2409
|
-
function
|
|
2430
|
+
function ge(e, t) {
|
|
2410
2431
|
if (!e || typeof e != "object")
|
|
2411
2432
|
return [];
|
|
2412
2433
|
const s = e[t];
|
|
2413
2434
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2414
2435
|
}
|
|
2415
|
-
function
|
|
2436
|
+
function kn(e) {
|
|
2416
2437
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2417
2438
|
}
|
|
2418
|
-
function
|
|
2439
|
+
function _n(e) {
|
|
2419
2440
|
if (!e || typeof e != "object")
|
|
2420
2441
|
return null;
|
|
2421
2442
|
const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, 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;
|
|
@@ -2426,13 +2447,13 @@ function En(e) {
|
|
|
2426
2447
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2427
2448
|
};
|
|
2428
2449
|
}
|
|
2429
|
-
function
|
|
2450
|
+
function Cn(e) {
|
|
2430
2451
|
if (!e || typeof e != "object")
|
|
2431
2452
|
return null;
|
|
2432
2453
|
const t = e.javascript;
|
|
2433
2454
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2434
2455
|
}
|
|
2435
|
-
function
|
|
2456
|
+
function Un(e, t) {
|
|
2436
2457
|
return t ? e && typeof e == "object" ? {
|
|
2437
2458
|
...e,
|
|
2438
2459
|
helperError: t
|
|
@@ -2442,13 +2463,13 @@ function kn(e, t) {
|
|
|
2442
2463
|
helperError: t
|
|
2443
2464
|
} : e;
|
|
2444
2465
|
}
|
|
2445
|
-
function
|
|
2466
|
+
function Pn(e) {
|
|
2446
2467
|
if (!e || typeof e != "object")
|
|
2447
2468
|
return e;
|
|
2448
2469
|
const t = e;
|
|
2449
2470
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2450
2471
|
}
|
|
2451
|
-
function
|
|
2472
|
+
function Dn() {
|
|
2452
2473
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2453
2474
|
if (t)
|
|
2454
2475
|
return t;
|
|
@@ -2458,7 +2479,7 @@ function _n() {
|
|
|
2458
2479
|
function $() {
|
|
2459
2480
|
return crypto.randomUUID();
|
|
2460
2481
|
}
|
|
2461
|
-
function
|
|
2482
|
+
function vn(e) {
|
|
2462
2483
|
if (!e || typeof e != "object")
|
|
2463
2484
|
return null;
|
|
2464
2485
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2469,22 +2490,22 @@ function Cn(e) {
|
|
|
2469
2490
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2470
2491
|
} : null;
|
|
2471
2492
|
}
|
|
2472
|
-
function
|
|
2473
|
-
return Array.isArray(e) ?
|
|
2493
|
+
function On(e, t) {
|
|
2494
|
+
return Array.isArray(e) ? Bt(
|
|
2474
2495
|
e.map((s) => Ne(s, t)).filter((s) => s !== null)
|
|
2475
2496
|
) : [];
|
|
2476
2497
|
}
|
|
2477
|
-
function
|
|
2498
|
+
function Nn(e) {
|
|
2478
2499
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2479
2500
|
if (!t || typeof t != "object")
|
|
2480
2501
|
return [];
|
|
2481
|
-
const s = t, n =
|
|
2502
|
+
const s = t, n = R(s, "id"), r = R(s, "createdAt"), i = R(s, "updatedAt"), o = R(s, "lastActiveAt");
|
|
2482
2503
|
return !n || !r || !i || !o ? [] : [
|
|
2483
2504
|
{
|
|
2484
2505
|
id: n,
|
|
2485
|
-
title:
|
|
2486
|
-
customTitle:
|
|
2487
|
-
firstUserMessage:
|
|
2506
|
+
title: R(s, "title"),
|
|
2507
|
+
customTitle: R(s, "customTitle"),
|
|
2508
|
+
firstUserMessage: R(s, "firstUserMessage"),
|
|
2488
2509
|
currentPage: s.currentPage ?? null,
|
|
2489
2510
|
createdAt: r,
|
|
2490
2511
|
updatedAt: i,
|
|
@@ -2509,14 +2530,14 @@ function Ne(e, t) {
|
|
|
2509
2530
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2510
2531
|
role: i,
|
|
2511
2532
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2512
|
-
content:
|
|
2513
|
-
|
|
2533
|
+
content: os(
|
|
2534
|
+
Wn(r.content),
|
|
2514
2535
|
t
|
|
2515
2536
|
),
|
|
2516
2537
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2517
|
-
respondsToUserMessageId:
|
|
2518
|
-
...
|
|
2519
|
-
attachments:
|
|
2538
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2539
|
+
...k(r) ? { runId: k(r) } : {},
|
|
2540
|
+
attachments: He(r.attachments, t)
|
|
2520
2541
|
};
|
|
2521
2542
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2522
2543
|
value: r.id,
|
|
@@ -2527,38 +2548,52 @@ function Ne(e, t) {
|
|
|
2527
2548
|
}), o;
|
|
2528
2549
|
}
|
|
2529
2550
|
if (r.type === "function_call_output") {
|
|
2530
|
-
const i =
|
|
2531
|
-
|
|
2551
|
+
const i = Is(r.output);
|
|
2552
|
+
if (i)
|
|
2553
|
+
return {
|
|
2554
|
+
id: String(s.id ?? crypto.randomUUID()),
|
|
2555
|
+
role: "tool",
|
|
2556
|
+
content: "",
|
|
2557
|
+
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2558
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2559
|
+
...k(r) ? { runId: k(r) } : {},
|
|
2560
|
+
dataType: "scheduled_check_in",
|
|
2561
|
+
toolName: ke,
|
|
2562
|
+
callId: Ct(r) ?? void 0,
|
|
2563
|
+
scheduledCheckInAt: i
|
|
2564
|
+
};
|
|
2565
|
+
const o = Ln(r.output);
|
|
2566
|
+
return o ? {
|
|
2532
2567
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2533
2568
|
role: "tool",
|
|
2534
|
-
content: `Connect ${
|
|
2569
|
+
content: `Connect ${o.appName} to continue`,
|
|
2535
2570
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2536
|
-
respondsToUserMessageId:
|
|
2537
|
-
...
|
|
2571
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2572
|
+
...k(r) ? { runId: k(r) } : {},
|
|
2538
2573
|
dataType: "function_call_output",
|
|
2539
2574
|
toolName: "authenticate_pipedream_app",
|
|
2540
|
-
callId:
|
|
2541
|
-
integrationAuthRequest:
|
|
2575
|
+
callId: Ct(r) ?? void 0,
|
|
2576
|
+
integrationAuthRequest: o
|
|
2542
2577
|
} : null;
|
|
2543
2578
|
}
|
|
2544
2579
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2545
2580
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2546
2581
|
role: "tool",
|
|
2547
|
-
content: r.type === "mcp_call" ?
|
|
2582
|
+
content: r.type === "mcp_call" ? xn(r) : Bn(r),
|
|
2548
2583
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2549
|
-
respondsToUserMessageId:
|
|
2550
|
-
...
|
|
2584
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2585
|
+
...k(r) ? { runId: k(r) } : {},
|
|
2551
2586
|
dataType: String(r.type),
|
|
2552
2587
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2553
|
-
callId:
|
|
2588
|
+
callId: Ct(r) ?? void 0,
|
|
2554
2589
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
2555
2590
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2556
2591
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2557
2592
|
role: "system",
|
|
2558
|
-
content:
|
|
2593
|
+
content: qn(r),
|
|
2559
2594
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2560
|
-
respondsToUserMessageId:
|
|
2561
|
-
...
|
|
2595
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2596
|
+
...k(r) ? { runId: k(r) } : {},
|
|
2562
2597
|
dataType: String(r.type),
|
|
2563
2598
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
2564
2599
|
...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
|
|
@@ -2566,11 +2601,11 @@ function Ne(e, t) {
|
|
|
2566
2601
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2567
2602
|
} : null;
|
|
2568
2603
|
}
|
|
2569
|
-
function
|
|
2604
|
+
function xn(e) {
|
|
2570
2605
|
const s = (typeof e.server_label == "string" ? e.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
2571
2606
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2572
2607
|
}
|
|
2573
|
-
function
|
|
2608
|
+
function Ln(e) {
|
|
2574
2609
|
if (typeof e != "string")
|
|
2575
2610
|
return null;
|
|
2576
2611
|
try {
|
|
@@ -2587,10 +2622,10 @@ function On(e) {
|
|
|
2587
2622
|
return null;
|
|
2588
2623
|
}
|
|
2589
2624
|
}
|
|
2590
|
-
function
|
|
2625
|
+
function qn(e) {
|
|
2591
2626
|
return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : e.type === "run_status" && e.status === "steered" ? "Steered" : typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
|
|
2592
2627
|
}
|
|
2593
|
-
function
|
|
2628
|
+
function Bn(e) {
|
|
2594
2629
|
if (e.type === "web_search_call") {
|
|
2595
2630
|
const t = e.action;
|
|
2596
2631
|
if (t && typeof t == "object") {
|
|
@@ -2602,9 +2637,9 @@ function vn(e) {
|
|
|
2602
2637
|
}
|
|
2603
2638
|
return "🔎 Searching the web";
|
|
2604
2639
|
}
|
|
2605
|
-
return
|
|
2640
|
+
return Fn(e);
|
|
2606
2641
|
}
|
|
2607
|
-
function
|
|
2642
|
+
function Fn(e) {
|
|
2608
2643
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2609
2644
|
return L(e.summary);
|
|
2610
2645
|
if (typeof e.arguments == "string")
|
|
@@ -2621,7 +2656,7 @@ function L(e) {
|
|
|
2621
2656
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2622
2657
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2623
2658
|
}
|
|
2624
|
-
function
|
|
2659
|
+
function Hn(e) {
|
|
2625
2660
|
if (e == null)
|
|
2626
2661
|
return e;
|
|
2627
2662
|
if (typeof e != "object")
|
|
@@ -2636,11 +2671,11 @@ function Ln(e) {
|
|
|
2636
2671
|
runId: typeof t.runId == "string" ? t.runId : null
|
|
2637
2672
|
};
|
|
2638
2673
|
}
|
|
2639
|
-
function
|
|
2674
|
+
function Ct(e) {
|
|
2640
2675
|
const t = e.callId ?? e.call_id;
|
|
2641
2676
|
return typeof t == "string" && t ? t : null;
|
|
2642
2677
|
}
|
|
2643
|
-
function
|
|
2678
|
+
function Wn(e) {
|
|
2644
2679
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2645
2680
|
if (!t || typeof t != "object")
|
|
2646
2681
|
return "";
|
|
@@ -2649,30 +2684,30 @@ function qn(e) {
|
|
|
2649
2684
|
}).filter(Boolean).join("") : "";
|
|
2650
2685
|
}
|
|
2651
2686
|
function Ot(e, t) {
|
|
2652
|
-
const s =
|
|
2653
|
-
|
|
2654
|
-
|
|
2687
|
+
const s = Le(e, t), n = Jn(
|
|
2688
|
+
$n(
|
|
2689
|
+
Qn(e, t),
|
|
2655
2690
|
s
|
|
2656
2691
|
),
|
|
2657
2692
|
s
|
|
2658
2693
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2659
2694
|
if (r === -1)
|
|
2660
|
-
return
|
|
2695
|
+
return Bt(
|
|
2661
2696
|
[...n, s]
|
|
2662
2697
|
);
|
|
2663
2698
|
const i = [...n];
|
|
2664
|
-
return i[r] = s,
|
|
2699
|
+
return i[r] = s, Bt(i);
|
|
2665
2700
|
}
|
|
2666
|
-
function
|
|
2701
|
+
function $n(e, t) {
|
|
2667
2702
|
const s = t.assistantDraftItemId;
|
|
2668
2703
|
return s ? e.map(
|
|
2669
2704
|
(n) => n.dataType === "assistant_draft" && n.id === s ? t : n
|
|
2670
2705
|
) : e;
|
|
2671
2706
|
}
|
|
2672
|
-
function
|
|
2707
|
+
function jn(e, t, s) {
|
|
2673
2708
|
return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
|
|
2674
2709
|
}
|
|
2675
|
-
function
|
|
2710
|
+
function zn(e, t, s, n) {
|
|
2676
2711
|
if (s === null) return e;
|
|
2677
2712
|
let r = -1;
|
|
2678
2713
|
for (let o = e.length - 1; o >= 0; o -= 1) {
|
|
@@ -2689,7 +2724,7 @@ function Hn(e, t, s, n) {
|
|
|
2689
2724
|
respondsToUserMessageId: s
|
|
2690
2725
|
}, i;
|
|
2691
2726
|
}
|
|
2692
|
-
function
|
|
2727
|
+
function Kn(e, t) {
|
|
2693
2728
|
const s = e.findIndex(
|
|
2694
2729
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2695
2730
|
);
|
|
@@ -2706,12 +2741,12 @@ function Wn(e, t) {
|
|
|
2706
2741
|
...n[s].runId ? {} : { runId: t.runId }
|
|
2707
2742
|
}, n;
|
|
2708
2743
|
}
|
|
2709
|
-
function
|
|
2744
|
+
function Gn(e, t, s) {
|
|
2710
2745
|
let n = !1;
|
|
2711
2746
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2712
2747
|
return n ? r : e;
|
|
2713
2748
|
}
|
|
2714
|
-
function
|
|
2749
|
+
function Xn(e) {
|
|
2715
2750
|
if (e.hiddenFromTranscript === !0)
|
|
2716
2751
|
return null;
|
|
2717
2752
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
@@ -2730,7 +2765,7 @@ function jn(e) {
|
|
|
2730
2765
|
loading: !0
|
|
2731
2766
|
};
|
|
2732
2767
|
}
|
|
2733
|
-
function
|
|
2768
|
+
function Jn(e, t) {
|
|
2734
2769
|
if (t.id.startsWith("transient-activity:"))
|
|
2735
2770
|
return e;
|
|
2736
2771
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2738,16 +2773,16 @@ function zn(e, t) {
|
|
|
2738
2773
|
(n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId && n.runId === t.runId)
|
|
2739
2774
|
);
|
|
2740
2775
|
}
|
|
2741
|
-
function
|
|
2742
|
-
return
|
|
2776
|
+
function Vn(e, t) {
|
|
2777
|
+
return as(
|
|
2743
2778
|
e,
|
|
2744
2779
|
t.map(
|
|
2745
|
-
(s) =>
|
|
2780
|
+
(s) => Le(e, s)
|
|
2746
2781
|
),
|
|
2747
|
-
|
|
2782
|
+
xe
|
|
2748
2783
|
);
|
|
2749
2784
|
}
|
|
2750
|
-
function
|
|
2785
|
+
function xe(e) {
|
|
2751
2786
|
const t = Nt(e) ?? void 0, s = e.assistantDraftItemId, n = [
|
|
2752
2787
|
...e.callId ? [`call:${e.callId}`] : [],
|
|
2753
2788
|
...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
|
|
@@ -2759,49 +2794,49 @@ function ve(e) {
|
|
|
2759
2794
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
2760
2795
|
...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
|
|
2761
2796
|
...e.runId ? { runId: e.runId } : {},
|
|
2762
|
-
isOptimistic:
|
|
2797
|
+
isOptimistic: Kt(e),
|
|
2763
2798
|
isAssistantDraft: e.dataType === "assistant_draft",
|
|
2764
2799
|
isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
|
|
2765
2800
|
isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
|
|
2766
2801
|
};
|
|
2767
2802
|
}
|
|
2768
|
-
function
|
|
2803
|
+
function Le(e, t) {
|
|
2769
2804
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2770
2805
|
return t;
|
|
2771
2806
|
const s = e.find(
|
|
2772
|
-
(r) => r.role === "user" && (r.id === t.id ||
|
|
2807
|
+
(r) => r.role === "user" && (r.id === t.id || Kt(r) && qe(r, t))
|
|
2773
2808
|
);
|
|
2774
2809
|
if (!s?.attachments?.length)
|
|
2775
2810
|
return t;
|
|
2776
2811
|
const n = t.attachments.map((r) => {
|
|
2777
|
-
const i =
|
|
2778
|
-
return i ?
|
|
2812
|
+
const i = Yn(s.attachments ?? [], r);
|
|
2813
|
+
return i ? Zn(r, i) : r;
|
|
2779
2814
|
});
|
|
2780
2815
|
return { ...t, attachments: n };
|
|
2781
2816
|
}
|
|
2782
|
-
function
|
|
2817
|
+
function Yn(e, t) {
|
|
2783
2818
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2784
2819
|
}
|
|
2785
|
-
function
|
|
2820
|
+
function Zn(e, t) {
|
|
2786
2821
|
const { previewUrl: s } = t;
|
|
2787
2822
|
return s ? { ...e, previewUrl: s } : e;
|
|
2788
2823
|
}
|
|
2789
|
-
function
|
|
2824
|
+
function Qn(e, t) {
|
|
2790
2825
|
if (t.role !== "user")
|
|
2791
2826
|
return e;
|
|
2792
2827
|
const s = e.findIndex(
|
|
2793
|
-
(r) =>
|
|
2828
|
+
(r) => Kt(r) && qe(r, t)
|
|
2794
2829
|
);
|
|
2795
2830
|
if (s === -1)
|
|
2796
2831
|
return e;
|
|
2797
2832
|
const n = [...e];
|
|
2798
2833
|
return n.splice(s, 1), n;
|
|
2799
2834
|
}
|
|
2800
|
-
function
|
|
2835
|
+
function qe(e, t) {
|
|
2801
2836
|
const s = Nt(e), n = Nt(t);
|
|
2802
2837
|
return s && n ? s === n : e.content === t.content;
|
|
2803
2838
|
}
|
|
2804
|
-
function
|
|
2839
|
+
function Kt(e) {
|
|
2805
2840
|
return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
|
|
2806
2841
|
}
|
|
2807
2842
|
function Nt(e) {
|
|
@@ -2814,11 +2849,11 @@ function Nt(e) {
|
|
|
2814
2849
|
return n ? e.id.slice(n.length) : null;
|
|
2815
2850
|
}
|
|
2816
2851
|
function me(e) {
|
|
2817
|
-
const t =
|
|
2852
|
+
const t = Be(e);
|
|
2818
2853
|
if (t === null)
|
|
2819
2854
|
return !1;
|
|
2820
2855
|
const s = e[t].id, n = e.some(
|
|
2821
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
2856
|
+
(r) => r.respondsToUserMessageId === s && xt(r)
|
|
2822
2857
|
);
|
|
2823
2858
|
if (e.some((r) => r.respondsToUserMessageId === s))
|
|
2824
2859
|
return n;
|
|
@@ -2835,8 +2870,8 @@ function me(e) {
|
|
|
2835
2870
|
}
|
|
2836
2871
|
return !1;
|
|
2837
2872
|
}
|
|
2838
|
-
function
|
|
2839
|
-
const t =
|
|
2873
|
+
function tr(e) {
|
|
2874
|
+
const t = Be(e);
|
|
2840
2875
|
if (t === null)
|
|
2841
2876
|
return e.some(N);
|
|
2842
2877
|
const s = e[t].id;
|
|
@@ -2844,13 +2879,13 @@ function Vn(e) {
|
|
|
2844
2879
|
(n) => n.respondsToUserMessageId === s && N(n)
|
|
2845
2880
|
) : e.slice(t + 1).some(N);
|
|
2846
2881
|
}
|
|
2847
|
-
function
|
|
2882
|
+
function Be(e) {
|
|
2848
2883
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2849
2884
|
if (e[t].role === "user")
|
|
2850
2885
|
return t;
|
|
2851
2886
|
return null;
|
|
2852
2887
|
}
|
|
2853
|
-
function
|
|
2888
|
+
function xt(e) {
|
|
2854
2889
|
return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2855
2890
|
}
|
|
2856
2891
|
function at(e) {
|
|
@@ -2867,7 +2902,7 @@ function at(e) {
|
|
|
2867
2902
|
}
|
|
2868
2903
|
return null;
|
|
2869
2904
|
}
|
|
2870
|
-
function
|
|
2905
|
+
function er(e) {
|
|
2871
2906
|
const t = at(e);
|
|
2872
2907
|
if (t === null)
|
|
2873
2908
|
return null;
|
|
@@ -2883,13 +2918,13 @@ function q(e) {
|
|
|
2883
2918
|
const t = e.data;
|
|
2884
2919
|
return t && typeof t == "object" ? t : null;
|
|
2885
2920
|
}
|
|
2886
|
-
function
|
|
2921
|
+
function Lt(e) {
|
|
2887
2922
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2888
2923
|
}
|
|
2889
2924
|
function ye(e) {
|
|
2890
2925
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2891
2926
|
}
|
|
2892
|
-
function
|
|
2927
|
+
function sr(e, t) {
|
|
2893
2928
|
const s = at(t);
|
|
2894
2929
|
if (s === null)
|
|
2895
2930
|
return !1;
|
|
@@ -2898,10 +2933,10 @@ function Zn(e, t) {
|
|
|
2898
2933
|
return !1;
|
|
2899
2934
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2900
2935
|
return i === -1 ? !1 : e.some((o) => o.respondsToUserMessageId === r) ? e.some(
|
|
2901
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
2902
|
-
) : e.slice(i + 1).some(
|
|
2936
|
+
(o) => o.respondsToUserMessageId === r && xt(o)
|
|
2937
|
+
) : e.slice(i + 1).some(xt);
|
|
2903
2938
|
}
|
|
2904
|
-
function
|
|
2939
|
+
function qt(e) {
|
|
2905
2940
|
const t = at(e);
|
|
2906
2941
|
if (t === null)
|
|
2907
2942
|
return null;
|
|
@@ -2914,7 +2949,7 @@ function Lt(e) {
|
|
|
2914
2949
|
const r = n.clientMessageId;
|
|
2915
2950
|
return typeof r == "string" ? r : null;
|
|
2916
2951
|
}
|
|
2917
|
-
function
|
|
2952
|
+
function nr(e) {
|
|
2918
2953
|
const t = at(e);
|
|
2919
2954
|
if (t === null)
|
|
2920
2955
|
return null;
|
|
@@ -2929,22 +2964,22 @@ function Qn(e) {
|
|
|
2929
2964
|
if (i.type === "message" && i.role === "assistant")
|
|
2930
2965
|
return null;
|
|
2931
2966
|
if (i.type === "run_error")
|
|
2932
|
-
return i.retryable !== !0 ? null : Ie(e, i) ??
|
|
2967
|
+
return i.retryable !== !0 ? null : Ie(e, i) ?? qt(e);
|
|
2933
2968
|
if (i.type === "run_status")
|
|
2934
|
-
return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ??
|
|
2969
|
+
return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ?? qt(e) : null;
|
|
2935
2970
|
}
|
|
2936
2971
|
return null;
|
|
2937
2972
|
}
|
|
2938
2973
|
function Ie(e, t) {
|
|
2939
2974
|
if (typeof t.clientMessageId == "string")
|
|
2940
2975
|
return t.clientMessageId;
|
|
2941
|
-
const s =
|
|
2976
|
+
const s = O(t);
|
|
2942
2977
|
if (!s)
|
|
2943
2978
|
return null;
|
|
2944
|
-
const n = e.find((i) =>
|
|
2979
|
+
const n = e.find((i) => R(i, "id") === s), r = q(n);
|
|
2945
2980
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2946
2981
|
}
|
|
2947
|
-
function
|
|
2982
|
+
function rr(e, t) {
|
|
2948
2983
|
let s = 0;
|
|
2949
2984
|
for (const n of e) {
|
|
2950
2985
|
if (!n || typeof n != "object")
|
|
@@ -2958,12 +2993,12 @@ function tr(e, t) {
|
|
|
2958
2993
|
return s;
|
|
2959
2994
|
}
|
|
2960
2995
|
function Te(e, t, s, n, r) {
|
|
2961
|
-
if (!t || !
|
|
2996
|
+
if (!t || !ir(e))
|
|
2962
2997
|
return !1;
|
|
2963
2998
|
const i = e;
|
|
2964
|
-
return !(
|
|
2999
|
+
return !(Lt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && k(i) !== r));
|
|
2965
3000
|
}
|
|
2966
|
-
function
|
|
3001
|
+
function ir(e) {
|
|
2967
3002
|
if (!e || typeof e != "object")
|
|
2968
3003
|
return !1;
|
|
2969
3004
|
const t = e;
|
|
@@ -2972,24 +3007,24 @@ function er(e) {
|
|
|
2972
3007
|
function N(e) {
|
|
2973
3008
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
2974
3009
|
}
|
|
2975
|
-
function
|
|
3010
|
+
function or(e) {
|
|
2976
3011
|
if (!e || typeof e != "object")
|
|
2977
3012
|
return !1;
|
|
2978
3013
|
const t = e;
|
|
2979
3014
|
return t.type === "message" && t.role === "user" ? !1 : t.type === "message" || t.type === "function_call" || t.type === "function_call_output" || t.type === "run_error" || t.type === "run_status";
|
|
2980
3015
|
}
|
|
2981
|
-
function
|
|
2982
|
-
return e.filter((t, s) => ct(t) ? !
|
|
3016
|
+
function Bt(e) {
|
|
3017
|
+
return e.filter((t, s) => ct(t) ? !fr(e, s) && !hr(e, s) && !pr(e, s) : ar(t) ? t.retryable === !0 && dr(e, s) ? !1 : !ur(e, s) : !0);
|
|
2983
3018
|
}
|
|
2984
|
-
function
|
|
3019
|
+
function ar(e) {
|
|
2985
3020
|
return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
|
|
2986
3021
|
}
|
|
2987
3022
|
function ct(e) {
|
|
2988
3023
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
2989
3024
|
}
|
|
2990
|
-
function
|
|
3025
|
+
function cr(e, t) {
|
|
2991
3026
|
const s = [...e].reverse().find(
|
|
2992
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !
|
|
3027
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !lr(
|
|
2993
3028
|
e,
|
|
2994
3029
|
n.respondsToUserMessageId
|
|
2995
3030
|
)
|
|
@@ -3001,12 +3036,12 @@ function rr(e, t) {
|
|
|
3001
3036
|
function we(e) {
|
|
3002
3037
|
return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
|
|
3003
3038
|
}
|
|
3004
|
-
function
|
|
3039
|
+
function lr(e, t) {
|
|
3005
3040
|
return e.some(
|
|
3006
3041
|
(s) => s.respondsToUserMessageId === t && (N(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3007
3042
|
);
|
|
3008
3043
|
}
|
|
3009
|
-
function
|
|
3044
|
+
function ur(e, t) {
|
|
3010
3045
|
const s = e[t];
|
|
3011
3046
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
3012
3047
|
const r = e[n];
|
|
@@ -3015,7 +3050,7 @@ function or(e, t) {
|
|
|
3015
3050
|
}
|
|
3016
3051
|
return !1;
|
|
3017
3052
|
}
|
|
3018
|
-
function
|
|
3053
|
+
function dr(e, t) {
|
|
3019
3054
|
const s = e[t];
|
|
3020
3055
|
if (!s.respondsToUserMessageId)
|
|
3021
3056
|
return !1;
|
|
@@ -3028,19 +3063,19 @@ function ar(e, t) {
|
|
|
3028
3063
|
}
|
|
3029
3064
|
return !1;
|
|
3030
3065
|
}
|
|
3031
|
-
function
|
|
3066
|
+
function hr(e, t) {
|
|
3032
3067
|
const s = e[t];
|
|
3033
3068
|
return e.some(
|
|
3034
3069
|
(n, r) => r !== t && n.role === "assistant" && lt(s, n)
|
|
3035
3070
|
);
|
|
3036
3071
|
}
|
|
3037
|
-
function
|
|
3072
|
+
function pr(e, t) {
|
|
3038
3073
|
const s = e[t];
|
|
3039
3074
|
return e.some(
|
|
3040
3075
|
(n, r) => r !== t && n.role === "tool" && lt(s, n)
|
|
3041
3076
|
);
|
|
3042
3077
|
}
|
|
3043
|
-
function
|
|
3078
|
+
function fr(e, t) {
|
|
3044
3079
|
const s = e[t];
|
|
3045
3080
|
for (let n = t + 1; n < e.length; n += 1)
|
|
3046
3081
|
if (ct(e[n]) && lt(s, e[n]))
|
|
@@ -3050,18 +3085,18 @@ function ur(e, t) {
|
|
|
3050
3085
|
function lt(e, t) {
|
|
3051
3086
|
return !!(e.respondsToUserMessageId && e.respondsToUserMessageId === t.respondsToUserMessageId);
|
|
3052
3087
|
}
|
|
3053
|
-
function
|
|
3088
|
+
function R(e, t) {
|
|
3054
3089
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
3055
3090
|
}
|
|
3056
|
-
function
|
|
3091
|
+
function gr(e, t) {
|
|
3057
3092
|
try {
|
|
3058
|
-
const s = window.localStorage.getItem(`${
|
|
3093
|
+
const s = window.localStorage.getItem(`${Ce}${e}`);
|
|
3059
3094
|
if (!s)
|
|
3060
3095
|
return null;
|
|
3061
3096
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3062
3097
|
if (t !== void 0 && r !== t)
|
|
3063
3098
|
return null;
|
|
3064
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3099
|
+
const i = Array.isArray(n.messages) ? n.messages.map(br).filter((o) => !!o) : [];
|
|
3065
3100
|
return {
|
|
3066
3101
|
sessionId: r,
|
|
3067
3102
|
messages: i
|
|
@@ -3070,46 +3105,46 @@ function dr(e, t) {
|
|
|
3070
3105
|
return null;
|
|
3071
3106
|
}
|
|
3072
3107
|
}
|
|
3073
|
-
function
|
|
3108
|
+
function mr(e, t) {
|
|
3074
3109
|
try {
|
|
3075
3110
|
window.localStorage.setItem(
|
|
3076
|
-
`${
|
|
3111
|
+
`${Ce}${e}`,
|
|
3077
3112
|
JSON.stringify({
|
|
3078
3113
|
sessionId: t.sessionId,
|
|
3079
|
-
messages: t.messages.slice(-
|
|
3114
|
+
messages: t.messages.slice(-Ws).map(Mr)
|
|
3080
3115
|
})
|
|
3081
3116
|
);
|
|
3082
3117
|
} catch {
|
|
3083
3118
|
return;
|
|
3084
3119
|
}
|
|
3085
3120
|
}
|
|
3086
|
-
function
|
|
3121
|
+
function yr(e) {
|
|
3087
3122
|
try {
|
|
3088
|
-
const t = window.localStorage.getItem(`${
|
|
3123
|
+
const t = window.localStorage.getItem(`${vt}${e}`);
|
|
3089
3124
|
if (!t)
|
|
3090
3125
|
return [];
|
|
3091
3126
|
const s = JSON.parse(t);
|
|
3092
|
-
return Array.isArray(s) ? s.filter(
|
|
3127
|
+
return Array.isArray(s) ? s.filter(Gt) : [];
|
|
3093
3128
|
} catch {
|
|
3094
3129
|
return [];
|
|
3095
3130
|
}
|
|
3096
3131
|
}
|
|
3097
3132
|
function j(e, t) {
|
|
3098
3133
|
try {
|
|
3099
|
-
const s = t.filter(
|
|
3134
|
+
const s = t.filter(Gt);
|
|
3100
3135
|
if (s.length === 0) {
|
|
3101
|
-
window.localStorage.removeItem(`${
|
|
3136
|
+
window.localStorage.removeItem(`${vt}${e}`);
|
|
3102
3137
|
return;
|
|
3103
3138
|
}
|
|
3104
3139
|
window.localStorage.setItem(
|
|
3105
|
-
`${
|
|
3140
|
+
`${vt}${e}`,
|
|
3106
3141
|
JSON.stringify(s.slice(-25))
|
|
3107
3142
|
);
|
|
3108
3143
|
} catch {
|
|
3109
3144
|
return;
|
|
3110
3145
|
}
|
|
3111
3146
|
}
|
|
3112
|
-
function
|
|
3147
|
+
function Fe(e, t) {
|
|
3113
3148
|
try {
|
|
3114
3149
|
const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
3115
3150
|
...o,
|
|
@@ -3125,28 +3160,28 @@ function Be(e, t) {
|
|
|
3125
3160
|
} catch {
|
|
3126
3161
|
}
|
|
3127
3162
|
}
|
|
3128
|
-
function
|
|
3163
|
+
function Ir(e, t) {
|
|
3129
3164
|
try {
|
|
3130
3165
|
if (window.sessionStorage.getItem(`${ot}${e}`) === null)
|
|
3131
3166
|
return;
|
|
3132
3167
|
} catch {
|
|
3133
3168
|
return;
|
|
3134
3169
|
}
|
|
3135
|
-
|
|
3170
|
+
Fe(e, t);
|
|
3136
3171
|
}
|
|
3137
|
-
function
|
|
3172
|
+
function Tr(e) {
|
|
3138
3173
|
try {
|
|
3139
3174
|
const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
|
|
3140
3175
|
if (window.sessionStorage.removeItem(t), !s)
|
|
3141
3176
|
return [];
|
|
3142
3177
|
const n = JSON.parse(s);
|
|
3143
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3178
|
+
return Array.isArray(n) ? n.flatMap((r) => Sr(r) ? [{
|
|
3144
3179
|
...r.event,
|
|
3145
|
-
page:
|
|
3180
|
+
page: M(),
|
|
3146
3181
|
rawOutput: {
|
|
3147
3182
|
pageContextRestarted: !0,
|
|
3148
3183
|
outcome: "unknown",
|
|
3149
|
-
message:
|
|
3184
|
+
message: wr(location.href),
|
|
3150
3185
|
currentUrl: location.href,
|
|
3151
3186
|
console: [],
|
|
3152
3187
|
metadata: {
|
|
@@ -3163,17 +3198,17 @@ function gr(e) {
|
|
|
3163
3198
|
return [];
|
|
3164
3199
|
}
|
|
3165
3200
|
}
|
|
3166
|
-
function
|
|
3201
|
+
function wr(e) {
|
|
3167
3202
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3168
3203
|
Current URL: ${e}`;
|
|
3169
3204
|
}
|
|
3170
|
-
function
|
|
3205
|
+
function Sr(e) {
|
|
3171
3206
|
if (!e || typeof e != "object")
|
|
3172
3207
|
return !1;
|
|
3173
3208
|
const t = e, s = t.event;
|
|
3174
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
3209
|
+
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Gt(s) && s.type === "tool.result";
|
|
3175
3210
|
}
|
|
3176
|
-
function
|
|
3211
|
+
function Ar(e, t) {
|
|
3177
3212
|
const s = new Set(
|
|
3178
3213
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3179
3214
|
);
|
|
@@ -3182,14 +3217,14 @@ function Ir(e, t) {
|
|
|
3182
3217
|
...t.filter((n) => !s.has(n.callId))
|
|
3183
3218
|
];
|
|
3184
3219
|
}
|
|
3185
|
-
function
|
|
3220
|
+
function Er(e) {
|
|
3186
3221
|
try {
|
|
3187
3222
|
window.sessionStorage.removeItem(`${ot}${e}`);
|
|
3188
3223
|
} catch {
|
|
3189
3224
|
return;
|
|
3190
3225
|
}
|
|
3191
3226
|
}
|
|
3192
|
-
function
|
|
3227
|
+
function Gt(e) {
|
|
3193
3228
|
if (!e || typeof e != "object")
|
|
3194
3229
|
return !1;
|
|
3195
3230
|
const t = e;
|
|
@@ -3201,7 +3236,7 @@ function Se(e) {
|
|
|
3201
3236
|
const t = e;
|
|
3202
3237
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
3203
3238
|
}
|
|
3204
|
-
function
|
|
3239
|
+
function He(e, t) {
|
|
3205
3240
|
if (!Array.isArray(e))
|
|
3206
3241
|
return;
|
|
3207
3242
|
const s = e.filter((r) => {
|
|
@@ -3209,23 +3244,23 @@ function Fe(e, t) {
|
|
|
3209
3244
|
return !1;
|
|
3210
3245
|
const i = r;
|
|
3211
3246
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3212
|
-
}), n = t ? s.map((r) =>
|
|
3247
|
+
}), n = t ? s.map((r) => We(r, t)) : s;
|
|
3213
3248
|
return n.length > 0 ? n : void 0;
|
|
3214
3249
|
}
|
|
3215
|
-
function
|
|
3250
|
+
function We(e, t) {
|
|
3216
3251
|
return e.fileUrl?.startsWith("/") ? {
|
|
3217
3252
|
...e,
|
|
3218
3253
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
3219
3254
|
} : e;
|
|
3220
3255
|
}
|
|
3221
3256
|
function Ae(e) {
|
|
3222
|
-
return e.type ||
|
|
3257
|
+
return e.type || Rr(e.name) || "application/octet-stream";
|
|
3223
3258
|
}
|
|
3224
|
-
function
|
|
3259
|
+
function Rr(e) {
|
|
3225
3260
|
const t = e.toLowerCase();
|
|
3226
3261
|
return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
|
|
3227
3262
|
}
|
|
3228
|
-
function
|
|
3263
|
+
function br(e) {
|
|
3229
3264
|
if (!e || typeof e != "object")
|
|
3230
3265
|
return null;
|
|
3231
3266
|
const t = e;
|
|
@@ -3237,18 +3272,19 @@ function Sr(e) {
|
|
|
3237
3272
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
3238
3273
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
3239
3274
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
3275
|
+
scheduledCheckInAt: typeof t.scheduledCheckInAt == "string" ? t.scheduledCheckInAt : void 0,
|
|
3240
3276
|
securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
|
|
3241
|
-
attachments:
|
|
3277
|
+
attachments: He(t.attachments)?.map(Xt),
|
|
3242
3278
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
3243
3279
|
};
|
|
3244
3280
|
}
|
|
3245
|
-
function
|
|
3281
|
+
function Mr(e) {
|
|
3246
3282
|
return e.attachments?.length ? {
|
|
3247
3283
|
...e,
|
|
3248
|
-
attachments: e.attachments.map(
|
|
3284
|
+
attachments: e.attachments.map(Xt)
|
|
3249
3285
|
} : e;
|
|
3250
3286
|
}
|
|
3251
|
-
function
|
|
3287
|
+
function Xt(e) {
|
|
3252
3288
|
const {
|
|
3253
3289
|
dataUrl: t,
|
|
3254
3290
|
objectUrl: s,
|
|
@@ -3257,47 +3293,47 @@ function Gt(e) {
|
|
|
3257
3293
|
} = e;
|
|
3258
3294
|
return r;
|
|
3259
3295
|
}
|
|
3260
|
-
function
|
|
3296
|
+
function O(e) {
|
|
3261
3297
|
const t = e.respondsToUserMessageId;
|
|
3262
3298
|
return typeof t == "string" && t ? t : null;
|
|
3263
3299
|
}
|
|
3264
|
-
function
|
|
3300
|
+
function k(e) {
|
|
3265
3301
|
const t = e.runId;
|
|
3266
3302
|
return typeof t == "string" && t ? t : null;
|
|
3267
3303
|
}
|
|
3268
|
-
function
|
|
3304
|
+
function kr(e) {
|
|
3269
3305
|
const t = e?.timeoutMs;
|
|
3270
|
-
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <=
|
|
3306
|
+
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Ys);
|
|
3271
3307
|
}
|
|
3272
|
-
function
|
|
3308
|
+
function $e(e) {
|
|
3273
3309
|
const t = {};
|
|
3274
3310
|
try {
|
|
3275
3311
|
new Headers(e).forEach((s, n) => {
|
|
3276
|
-
Object.keys(t).length <
|
|
3312
|
+
Object.keys(t).length < jt && (t[n] = Jt(n, s));
|
|
3277
3313
|
});
|
|
3278
3314
|
} catch {
|
|
3279
3315
|
return {};
|
|
3280
3316
|
}
|
|
3281
3317
|
return t;
|
|
3282
3318
|
}
|
|
3283
|
-
function
|
|
3284
|
-
return
|
|
3319
|
+
function Jt(e, t) {
|
|
3320
|
+
return Je(e) ? ut : U(it(t), Fs);
|
|
3285
3321
|
}
|
|
3286
|
-
function
|
|
3322
|
+
function _r(e, t) {
|
|
3287
3323
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
3288
3324
|
}
|
|
3289
|
-
async function
|
|
3290
|
-
const r =
|
|
3325
|
+
async function Cr(e, t, s, n) {
|
|
3326
|
+
const r = $e(e.headers);
|
|
3291
3327
|
n({
|
|
3292
3328
|
...t,
|
|
3293
3329
|
responseStatus: e.status,
|
|
3294
3330
|
responseHeaders: r,
|
|
3295
|
-
responseBody: await
|
|
3331
|
+
responseBody: await Ur(e),
|
|
3296
3332
|
durationMs: Date.now() - s
|
|
3297
3333
|
});
|
|
3298
3334
|
}
|
|
3299
|
-
async function
|
|
3300
|
-
if (
|
|
3335
|
+
async function Ur(e) {
|
|
3336
|
+
if (!je(e.headers))
|
|
3301
3337
|
return;
|
|
3302
3338
|
let t = null, s = null;
|
|
3303
3339
|
try {
|
|
@@ -3306,7 +3342,7 @@ async function kr(e) {
|
|
|
3306
3342
|
const n = new Promise((a) => {
|
|
3307
3343
|
s = window.setTimeout(() => {
|
|
3308
3344
|
t?.cancel(), a("timeout");
|
|
3309
|
-
},
|
|
3345
|
+
}, Hs);
|
|
3310
3346
|
}), r = new TextDecoder();
|
|
3311
3347
|
let i = "", o = 0;
|
|
3312
3348
|
for (; ; ) {
|
|
@@ -3315,10 +3351,10 @@ async function kr(e) {
|
|
|
3315
3351
|
return;
|
|
3316
3352
|
const { done: c, value: l } = a;
|
|
3317
3353
|
if (c)
|
|
3318
|
-
return
|
|
3319
|
-
const h =
|
|
3354
|
+
return U(i + r.decode());
|
|
3355
|
+
const h = $t - o;
|
|
3320
3356
|
if (l.byteLength > h)
|
|
3321
|
-
return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${
|
|
3357
|
+
return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${U(i)}... [truncated]`;
|
|
3322
3358
|
o += l.byteLength, i += r.decode(l, { stream: !0 });
|
|
3323
3359
|
}
|
|
3324
3360
|
} catch {
|
|
@@ -3328,45 +3364,45 @@ async function kr(e) {
|
|
|
3328
3364
|
s !== null && window.clearTimeout(s);
|
|
3329
3365
|
}
|
|
3330
3366
|
}
|
|
3331
|
-
function
|
|
3332
|
-
if (
|
|
3367
|
+
function Pr(e, t) {
|
|
3368
|
+
if (je(new Headers(t)))
|
|
3333
3369
|
try {
|
|
3334
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
3370
|
+
return e.responseType === "" || e.responseType === "text" ? U(e.responseText ?? "") : void 0;
|
|
3335
3371
|
} catch {
|
|
3336
3372
|
return;
|
|
3337
3373
|
}
|
|
3338
3374
|
}
|
|
3339
|
-
function
|
|
3375
|
+
function Ee(e) {
|
|
3340
3376
|
if (typeof e == "string")
|
|
3341
|
-
return
|
|
3377
|
+
return U(e);
|
|
3342
3378
|
}
|
|
3343
|
-
function
|
|
3344
|
-
return
|
|
3379
|
+
function Dr(e) {
|
|
3380
|
+
return _({
|
|
3345
3381
|
...e,
|
|
3346
|
-
requestBody:
|
|
3347
|
-
responseBody:
|
|
3382
|
+
requestBody: Re(e.requestBody),
|
|
3383
|
+
responseBody: Re(e.responseBody)
|
|
3348
3384
|
});
|
|
3349
3385
|
}
|
|
3350
|
-
function
|
|
3386
|
+
function Re(e) {
|
|
3351
3387
|
if (typeof e != "string")
|
|
3352
3388
|
return e;
|
|
3353
3389
|
const t = e.trim();
|
|
3354
3390
|
if (!t.startsWith("{") && !t.startsWith("["))
|
|
3355
3391
|
return it(e);
|
|
3356
3392
|
try {
|
|
3357
|
-
return JSON.stringify(
|
|
3393
|
+
return JSON.stringify(_(JSON.parse(e)));
|
|
3358
3394
|
} catch {
|
|
3359
3395
|
return it(e);
|
|
3360
3396
|
}
|
|
3361
3397
|
}
|
|
3362
|
-
function
|
|
3398
|
+
function je(e) {
|
|
3363
3399
|
if (!e)
|
|
3364
3400
|
return !1;
|
|
3365
3401
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3366
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3402
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= $t && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3367
3403
|
}
|
|
3368
3404
|
function x(e, t = {}, s) {
|
|
3369
|
-
if (
|
|
3405
|
+
if (Or(s))
|
|
3370
3406
|
return !0;
|
|
3371
3407
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3372
3408
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3381,7 +3417,7 @@ function x(e, t = {}, s) {
|
|
|
3381
3417
|
return !0;
|
|
3382
3418
|
}
|
|
3383
3419
|
}
|
|
3384
|
-
function
|
|
3420
|
+
function vr(e, t) {
|
|
3385
3421
|
if (x(e))
|
|
3386
3422
|
return !0;
|
|
3387
3423
|
try {
|
|
@@ -3391,26 +3427,26 @@ function Cr(e, t) {
|
|
|
3391
3427
|
return !0;
|
|
3392
3428
|
}
|
|
3393
3429
|
}
|
|
3394
|
-
function
|
|
3430
|
+
function Or(e) {
|
|
3395
3431
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3396
3432
|
}
|
|
3397
|
-
function
|
|
3433
|
+
function Nr(e) {
|
|
3398
3434
|
const t = {};
|
|
3399
3435
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3400
3436
|
const n = s.indexOf(":");
|
|
3401
3437
|
if (n <= 0)
|
|
3402
3438
|
continue;
|
|
3403
|
-
if (Object.keys(t).length >=
|
|
3439
|
+
if (Object.keys(t).length >= jt)
|
|
3404
3440
|
break;
|
|
3405
3441
|
const r = s.slice(0, n).trim();
|
|
3406
|
-
t[r] =
|
|
3442
|
+
t[r] = Jt(r, s.slice(n + 1).trim());
|
|
3407
3443
|
}
|
|
3408
3444
|
return t;
|
|
3409
3445
|
}
|
|
3410
|
-
function
|
|
3446
|
+
function U(e, t = $t) {
|
|
3411
3447
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
3412
3448
|
}
|
|
3413
|
-
function
|
|
3449
|
+
function Ut(e) {
|
|
3414
3450
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3415
3451
|
}
|
|
3416
3452
|
class nt extends Error {
|
|
@@ -3421,32 +3457,32 @@ class nt extends Error {
|
|
|
3421
3457
|
}
|
|
3422
3458
|
async function tt(e, t) {
|
|
3423
3459
|
let s = null;
|
|
3424
|
-
for (let n = 0; n <
|
|
3460
|
+
for (let n = 0; n < de; n += 1)
|
|
3425
3461
|
try {
|
|
3426
3462
|
return await e();
|
|
3427
3463
|
} catch (r) {
|
|
3428
|
-
if (s = r, n >=
|
|
3464
|
+
if (s = r, n >= de - 1 || !Lr(r))
|
|
3429
3465
|
throw r;
|
|
3430
|
-
await
|
|
3466
|
+
await xr(n);
|
|
3431
3467
|
}
|
|
3432
3468
|
throw s instanceof Error ? s : new Error(t);
|
|
3433
3469
|
}
|
|
3434
|
-
function
|
|
3470
|
+
function xr(e) {
|
|
3435
3471
|
return new Promise((t) => {
|
|
3436
|
-
window.setTimeout(t,
|
|
3472
|
+
window.setTimeout(t, Bs[e] ?? 0);
|
|
3437
3473
|
});
|
|
3438
3474
|
}
|
|
3439
|
-
function
|
|
3440
|
-
return e instanceof nt ?
|
|
3475
|
+
function Lr(e) {
|
|
3476
|
+
return e instanceof nt ? qr(e.status) : e instanceof TypeError;
|
|
3441
3477
|
}
|
|
3442
|
-
function
|
|
3478
|
+
function qr(e) {
|
|
3443
3479
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3444
3480
|
}
|
|
3445
|
-
function
|
|
3481
|
+
function Br(e) {
|
|
3446
3482
|
return e === 401 || e === 403;
|
|
3447
3483
|
}
|
|
3448
|
-
const ut = "[REDACTED_SECRET]",
|
|
3449
|
-
function
|
|
3484
|
+
const ut = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", Fr = "[REDACTED_SIGNED_URL]", Hr = 20, Wr = /^(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, ze = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Ke = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ge = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Xe = /\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, $r = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, jr = /\bhttps?:\/\/[^\s"'<>]+/gi, zr = /[),.;\]]+$/;
|
|
3485
|
+
function _(e) {
|
|
3450
3486
|
return rt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3451
3487
|
}
|
|
3452
3488
|
function rt(e, t, s) {
|
|
@@ -3454,7 +3490,7 @@ function rt(e, t, s) {
|
|
|
3454
3490
|
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
|
|
3455
3491
|
if (e === null || typeof e != "object")
|
|
3456
3492
|
return e;
|
|
3457
|
-
if (t >=
|
|
3493
|
+
if (t >= Hr)
|
|
3458
3494
|
return "[REDACTED_MAX_DEPTH]";
|
|
3459
3495
|
if (s.has(e))
|
|
3460
3496
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -3462,44 +3498,44 @@ function rt(e, t, s) {
|
|
|
3462
3498
|
return e.map((r) => rt(r, t + 1, s));
|
|
3463
3499
|
const n = {};
|
|
3464
3500
|
for (const [r, i] of Object.entries(e))
|
|
3465
|
-
r === "pageContent" ? n[r] = i :
|
|
3501
|
+
r === "pageContent" ? n[r] = i : Je(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Kr(i) : rt(i, t + 1, s);
|
|
3466
3502
|
return n;
|
|
3467
3503
|
}
|
|
3468
|
-
function
|
|
3504
|
+
function Je(e) {
|
|
3469
3505
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3470
3506
|
return t.includes("authorization") || t.includes("cookie") || t.includes("password") || t.includes("passwd") || t === "pwd" || t.includes("secret") || t === "token" || t.endsWith("token") || t.includes("apikey") || t.includes("csrf") || t.includes("xsrf") || t === "jwt" || t === "session" || t === "signature" || t.includes("privatekey");
|
|
3471
3507
|
}
|
|
3472
|
-
function
|
|
3473
|
-
return typeof e == "string" ?
|
|
3508
|
+
function Kr(e) {
|
|
3509
|
+
return typeof e == "string" ? Ve(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3474
3510
|
}
|
|
3475
|
-
function
|
|
3511
|
+
function Ve(e) {
|
|
3476
3512
|
try {
|
|
3477
3513
|
const t = new URL(e, location.href);
|
|
3478
3514
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3479
|
-
|
|
3480
|
-
return t.username && (t.username =
|
|
3515
|
+
Wr.test(s) && t.searchParams.set(s, P);
|
|
3516
|
+
return t.username && (t.username = P), t.password && (t.password = P), t.toString();
|
|
3481
3517
|
} catch {
|
|
3482
|
-
return
|
|
3518
|
+
return Gr(e);
|
|
3483
3519
|
}
|
|
3484
3520
|
}
|
|
3485
3521
|
function it(e) {
|
|
3486
|
-
return e.replace(
|
|
3522
|
+
return e.replace($r, Fr).replace(jr, Xr).replace(ze, `Bearer ${P}`).replace(Ke, `Basic ${P}`).replace(Ge, P).replace(Xe, (t, s) => `${s}: ${ut}`);
|
|
3487
3523
|
}
|
|
3488
|
-
function
|
|
3489
|
-
return e.replace(
|
|
3524
|
+
function Gr(e) {
|
|
3525
|
+
return e.replace(ze, `Bearer ${P}`).replace(Ke, `Basic ${P}`).replace(Ge, P).replace(Xe, (t, s) => `${s}: ${ut}`);
|
|
3490
3526
|
}
|
|
3491
|
-
function
|
|
3492
|
-
const t = e.match(
|
|
3493
|
-
return `${
|
|
3527
|
+
function Xr(e) {
|
|
3528
|
+
const t = e.match(zr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3529
|
+
return `${Ve(s)}${t}`;
|
|
3494
3530
|
}
|
|
3495
3531
|
export {
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3532
|
+
ie as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3533
|
+
Dt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3534
|
+
Ss as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3535
|
+
ws as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3536
|
+
As as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3537
|
+
Ue as PlunoProductAgent,
|
|
3538
|
+
js as calculateReconnectDelay,
|
|
3539
|
+
Ue as default,
|
|
3540
|
+
gn as getProductAgentOriginAccessErrorMessage
|
|
3505
3541
|
};
|