@pluno/product-agent-web 0.1.148 → 0.1.150
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +6 -0
- package/dist/product-agent-sdk.js +830 -761
- package/dist/product-agent-widget.js +3428 -3250
- package/dist/scheduledCheckIn.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const t = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
1
|
+
const Qe = "pluno-product-agent-attachments";
|
|
2
|
+
const Ut = "files";
|
|
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,28 +16,28 @@ async function Qe(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
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(Ut, { 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
|
-
const i = e.transaction(
|
|
40
|
+
const i = e.transaction(Ut, t), o = i.objectStore(Ut);
|
|
41
41
|
let a, c = !1;
|
|
42
42
|
s(o).then((l) => {
|
|
43
43
|
a = l;
|
|
@@ -57,16 +57,16 @@ function Bt(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
68
|
function Re(e, t, s) {
|
|
69
|
-
const n = Reflect.get(e, "pluno"), r =
|
|
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 is(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((b) => l.get(b)).find((b) => b !== 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 is(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(), bt = /* @__PURE__ */ new Map();
|
|
137
|
+
async function hs(e = ke()) {
|
|
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 us(e = be()) {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
174
|
-
W || (W =
|
|
173
|
+
async function ps() {
|
|
174
|
+
W || (W = hs(ke()), 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 ds() {
|
|
|
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 ke() {
|
|
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) ?? bt.get(e) ?? null;
|
|
210
210
|
} catch {
|
|
211
|
-
return
|
|
211
|
+
return bt.get(e) ?? null;
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
setItem: (e, t) => {
|
|
215
|
-
|
|
215
|
+
bt.set(e, t);
|
|
216
216
|
try {
|
|
217
217
|
window.sessionStorage?.setItem(e, t);
|
|
218
218
|
} catch {
|
|
@@ -220,9 +220,9 @@ function ps() {
|
|
|
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 fs() {
|
|
|
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 gs() {
|
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
const Me = "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 !== Me || 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 bs = 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 re(e) {
|
|
|
270
284
|
const r = e.attachments;
|
|
271
285
|
return Array.isArray(r) && (t.attachmentCount = r.length), t;
|
|
272
286
|
}
|
|
273
|
-
function
|
|
287
|
+
function Et(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 Rt(e, t, s) {
|
|
|
282
296
|
source: "web_sdk",
|
|
283
297
|
category: e,
|
|
284
298
|
name: t,
|
|
285
|
-
sequence: ++
|
|
299
|
+
sequence: ++bs,
|
|
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 Es = "https://app.pluno.ai", Rs = "gpt-5.6-terra", ks = 2e4, Ms = 1e4, _s = 1e4, Cs = 1e4, Ps = 1e4, Us = 1e3, ae = 3e4, ce = 0.2, le = 6e4, Ds = 15e3, V = 8, Os = 15e3, Ns = 2e3, vs = 1e3, xs = 100, ue = 8e3, de = 3, Ls = [300, 1e3], $t = 64e3, Rt = 4e3, jt = 30, qs = 2e3, Bs = 1e3, _e = "Image is too large for model vision input.", Fs = 100, Ce = "pluno.productAgent.state.", Ot = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Hs = 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 Ws(e, t = Math.random) {
|
|
314
|
+
const s = Math.min(ae, Us * 2 ** e), n = 1 - ce + t() * ce * 2;
|
|
315
|
+
return Math.min(ae, Math.round(s * n));
|
|
302
316
|
}
|
|
303
|
-
function
|
|
317
|
+
function $s(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 Fs(e, t, s) {
|
|
|
313
327
|
);
|
|
314
328
|
});
|
|
315
329
|
}
|
|
316
|
-
class
|
|
330
|
+
class Pe {
|
|
317
331
|
constructor(t, s) {
|
|
318
332
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
319
333
|
...this.state,
|
|
320
|
-
starterPrompts:
|
|
334
|
+
starterPrompts: Rn(t.initialStarterPrompts)
|
|
321
335
|
};
|
|
322
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
336
|
+
const n = t.restorePersistedState === !1 ? null : pr(t.clientId, t.expectedPersistedSessionId);
|
|
323
337
|
n && (this.state = {
|
|
324
338
|
...this.state,
|
|
325
339
|
...n,
|
|
@@ -332,9 +346,9 @@ class _e {
|
|
|
332
346
|
assistantDraftRunId: null,
|
|
333
347
|
isThinking: !1,
|
|
334
348
|
lastError: null
|
|
335
|
-
}), this.queuedClientEvents =
|
|
336
|
-
|
|
337
|
-
|
|
349
|
+
}), this.queuedClientEvents = wr(
|
|
350
|
+
gr(t.clientId),
|
|
351
|
+
yr(t.clientId)
|
|
338
352
|
), j(t.clientId, this.queuedClientEvents);
|
|
339
353
|
}
|
|
340
354
|
options;
|
|
@@ -361,6 +375,9 @@ class _e {
|
|
|
361
375
|
retryAttemptsByClientMessageId = {};
|
|
362
376
|
retryTimersByClientMessageId = {};
|
|
363
377
|
clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
|
|
378
|
+
backgroundSessionIds = /* @__PURE__ */ new Set();
|
|
379
|
+
backgroundClientMessageIds = /* @__PURE__ */ new Set();
|
|
380
|
+
deferredSessionUpdatedSessionIds = /* @__PURE__ */ new Set();
|
|
364
381
|
// The backend closes a retryable failed run with assistant_done; that paired event is recovery control flow,
|
|
365
382
|
// not successful completion of the user turn.
|
|
366
383
|
retryableFailureRunIdsAwaitingDone = /* @__PURE__ */ new Set();
|
|
@@ -406,15 +423,15 @@ class _e {
|
|
|
406
423
|
lastErrorSecuritySettingsUrl: null
|
|
407
424
|
};
|
|
408
425
|
static async init(t) {
|
|
409
|
-
const s = await
|
|
426
|
+
const s = await ps(), n = new Pe({
|
|
410
427
|
...t,
|
|
411
|
-
backendUrl:
|
|
412
|
-
clientId: t.clientId ??
|
|
413
|
-
model: t.model ??
|
|
414
|
-
entrySurface:
|
|
428
|
+
backendUrl: un(t.backendUrl ?? Es),
|
|
429
|
+
clientId: t.clientId ?? Pn(),
|
|
430
|
+
model: t.model ?? Rs,
|
|
431
|
+
entrySurface: dn(t.entrySurface)
|
|
415
432
|
}, s);
|
|
416
433
|
try {
|
|
417
|
-
|
|
434
|
+
ss().catch((r) => {
|
|
418
435
|
S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
419
436
|
message: r instanceof Error ? r.message : String(r)
|
|
420
437
|
});
|
|
@@ -445,14 +462,14 @@ class _e {
|
|
|
445
462
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
446
463
|
);
|
|
447
464
|
try {
|
|
448
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
465
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await $s(this.options.tokenProvider(), _s, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
449
466
|
return;
|
|
450
467
|
if (!this.token && !this.options.webSocketFactory)
|
|
451
468
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
452
|
-
const s =
|
|
469
|
+
const s = fn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
453
470
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
454
471
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
455
|
-
},
|
|
472
|
+
}, Cs), n.addEventListener("open", () => {
|
|
456
473
|
this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
|
|
457
474
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
458
475
|
isThinking: this.state.isThinking
|
|
@@ -464,9 +481,9 @@ class _e {
|
|
|
464
481
|
pageUrl: location.href
|
|
465
482
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
466
483
|
this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
467
|
-
},
|
|
484
|
+
}, Ps));
|
|
468
485
|
}), n.addEventListener("message", (r) => {
|
|
469
|
-
this.socket === n && this.handleServerEvent(
|
|
486
|
+
this.socket === n && this.handleServerEvent(En(r.data));
|
|
470
487
|
}), n.addEventListener("close", (r) => {
|
|
471
488
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
472
489
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -499,7 +516,7 @@ class _e {
|
|
|
499
516
|
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;
|
|
500
517
|
}
|
|
501
518
|
destroy() {
|
|
502
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
519
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Sr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
503
520
|
for (const t of Object.values(this.listeners))
|
|
504
521
|
t?.clear();
|
|
505
522
|
}
|
|
@@ -509,16 +526,16 @@ class _e {
|
|
|
509
526
|
reason: t,
|
|
510
527
|
entrySurface: this.options.entrySurface,
|
|
511
528
|
sessionId: this.state.sessionId ?? void 0,
|
|
512
|
-
page:
|
|
529
|
+
page: k()
|
|
513
530
|
};
|
|
514
531
|
this.sendNow(s) || (this.pendingWarmupEvent = s);
|
|
515
532
|
}
|
|
516
533
|
async sendMessage(t, s = {}) {
|
|
517
534
|
const n = t.trim(), r = s.attachments ?? [];
|
|
518
|
-
let i = r.map(
|
|
535
|
+
let i = r.map(Xt);
|
|
519
536
|
if (!n && i.length === 0)
|
|
520
537
|
return null;
|
|
521
|
-
const o =
|
|
538
|
+
const o = k(), a = s.clientMessageId ?? $(), c = {
|
|
522
539
|
id: `local-${a}`,
|
|
523
540
|
role: "user",
|
|
524
541
|
content: n,
|
|
@@ -547,14 +564,14 @@ class _e {
|
|
|
547
564
|
try {
|
|
548
565
|
const p = [];
|
|
549
566
|
for (const m of i) {
|
|
550
|
-
const
|
|
567
|
+
const b = m.id ? this.attachmentFiles.get(m.id) : void 0;
|
|
551
568
|
if (m.sandboxPath) {
|
|
552
569
|
p.push(m);
|
|
553
570
|
continue;
|
|
554
571
|
}
|
|
555
|
-
if (!
|
|
572
|
+
if (!b)
|
|
556
573
|
throw new Error(`Attachment bytes are unavailable for ${m.name}`);
|
|
557
|
-
p.push(await this.uploadAttachmentForMessage({ file:
|
|
574
|
+
p.push(await this.uploadAttachmentForMessage({ file: b, attachment: m }));
|
|
558
575
|
}
|
|
559
576
|
i = p;
|
|
560
577
|
} catch (p) {
|
|
@@ -569,14 +586,14 @@ class _e {
|
|
|
569
586
|
sessionId: this.state.sessionId ?? void 0,
|
|
570
587
|
clientMessageId: a,
|
|
571
588
|
initiatedBy: s.initiatedBy,
|
|
572
|
-
invocation:
|
|
589
|
+
invocation: hn(s.invocation ?? s.initiatedBy),
|
|
573
590
|
entrySurface: this.options.entrySurface,
|
|
574
591
|
content: n,
|
|
575
|
-
pageContent: u &&
|
|
592
|
+
pageContent: u && zt() || void 0,
|
|
576
593
|
attachments: i.length > 0 ? i : void 0,
|
|
577
594
|
page: o,
|
|
578
595
|
model: this.options.model,
|
|
579
|
-
metadata:
|
|
596
|
+
metadata: he(this.options.metadata)
|
|
580
597
|
};
|
|
581
598
|
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.markThinkingProgress(), this.send(d), a;
|
|
582
599
|
}
|
|
@@ -588,18 +605,18 @@ class _e {
|
|
|
588
605
|
const s = $(), n = {
|
|
589
606
|
id: s,
|
|
590
607
|
name: t.name || "attachment",
|
|
591
|
-
mimeType:
|
|
608
|
+
mimeType: Ae(t),
|
|
592
609
|
sizeBytes: t.size
|
|
593
610
|
};
|
|
594
611
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
595
612
|
const r = Date.now();
|
|
596
|
-
return
|
|
613
|
+
return ts({
|
|
597
614
|
attachmentId: s,
|
|
598
615
|
name: n.name,
|
|
599
616
|
mimeType: n.mimeType,
|
|
600
617
|
sizeBytes: n.sizeBytes,
|
|
601
618
|
blob: t,
|
|
602
|
-
origin:
|
|
619
|
+
origin: k().origin,
|
|
603
620
|
sessionId: this.state.sessionId ?? void 0,
|
|
604
621
|
createdAt: r,
|
|
605
622
|
lastUsedAt: r
|
|
@@ -622,7 +639,7 @@ class _e {
|
|
|
622
639
|
file: t,
|
|
623
640
|
attachment: s
|
|
624
641
|
}) {
|
|
625
|
-
const n = this.state.sessionId, r =
|
|
642
|
+
const n = this.state.sessionId, r = Ae(t), i = {
|
|
626
643
|
sessionId: n ?? void 0,
|
|
627
644
|
attachmentId: s.id,
|
|
628
645
|
clientId: this.options.clientId,
|
|
@@ -630,9 +647,9 @@ class _e {
|
|
|
630
647
|
name: t.name || "attachment",
|
|
631
648
|
mimeType: r,
|
|
632
649
|
sizeBytes: t.size,
|
|
633
|
-
page:
|
|
650
|
+
page: k(),
|
|
634
651
|
model: this.options.model,
|
|
635
|
-
metadata:
|
|
652
|
+
metadata: he(this.options.metadata),
|
|
636
653
|
entrySurface: this.options.entrySurface
|
|
637
654
|
};
|
|
638
655
|
let o;
|
|
@@ -658,8 +675,8 @@ class _e {
|
|
|
658
675
|
}, "Failed to upload attachment"), o = c;
|
|
659
676
|
}
|
|
660
677
|
this.setState({ sessionId: o.sessionId });
|
|
661
|
-
const a =
|
|
662
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
678
|
+
const a = We(o.attachment, this.options.backendUrl);
|
|
679
|
+
return this.updateAttachmentInState(s.id, a), s.id && es(s.id, {
|
|
663
680
|
sessionId: o.sessionId,
|
|
664
681
|
fileUrl: a.fileUrl,
|
|
665
682
|
sandboxPath: a.sandboxPath,
|
|
@@ -689,7 +706,7 @@ class _e {
|
|
|
689
706
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
690
707
|
if (n.ok)
|
|
691
708
|
return await n.json();
|
|
692
|
-
if (
|
|
709
|
+
if (Lr(n.status) && this.options.tokenProvider && !s) {
|
|
693
710
|
s = !0;
|
|
694
711
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
695
712
|
if (r.ok)
|
|
@@ -715,10 +732,10 @@ class _e {
|
|
|
715
732
|
}
|
|
716
733
|
startNewSession(t = {}) {
|
|
717
734
|
const s = t.notifyTransport !== !1;
|
|
718
|
-
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), 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({
|
|
735
|
+
!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({
|
|
719
736
|
type: "session.reset",
|
|
720
737
|
sessionId: this.state.sessionId ?? void 0,
|
|
721
|
-
page:
|
|
738
|
+
page: k()
|
|
722
739
|
}), this.setState({
|
|
723
740
|
sessionId: null,
|
|
724
741
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -736,12 +753,12 @@ class _e {
|
|
|
736
753
|
const s = $(), n = new Promise((i, o) => {
|
|
737
754
|
const a = window.setTimeout(() => {
|
|
738
755
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
739
|
-
},
|
|
756
|
+
}, ue);
|
|
740
757
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
741
758
|
}), r = {
|
|
742
759
|
type: "sessions.list",
|
|
743
760
|
requestId: s,
|
|
744
|
-
page:
|
|
761
|
+
page: k(),
|
|
745
762
|
...t.cursor ? { cursor: t.cursor } : {},
|
|
746
763
|
...t.limit ? { limit: t.limit } : {},
|
|
747
764
|
...typeof t.pinned == "boolean" ? { pinned: t.pinned } : {}
|
|
@@ -767,7 +784,7 @@ class _e {
|
|
|
767
784
|
);
|
|
768
785
|
}
|
|
769
786
|
loadSession(t) {
|
|
770
|
-
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.clearThinkingWatchdog(), this.lastUserMessagePageUrl = null, this.setState({
|
|
787
|
+
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(t), this.deferredSessionUpdatedSessionIds.delete(t)), this.clearThinkingWatchdog(), this.lastUserMessagePageUrl = null, this.setState({
|
|
771
788
|
sessionId: t,
|
|
772
789
|
assistantDraft: "",
|
|
773
790
|
assistantDraftItemId: null,
|
|
@@ -780,11 +797,11 @@ class _e {
|
|
|
780
797
|
}), this.send({
|
|
781
798
|
type: "session.load",
|
|
782
799
|
sessionId: t,
|
|
783
|
-
page:
|
|
800
|
+
page: k()
|
|
784
801
|
});
|
|
785
802
|
}
|
|
786
803
|
send(t) {
|
|
787
|
-
this.sendNow(
|
|
804
|
+
this.sendNow(_(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
788
805
|
}
|
|
789
806
|
async getUploadToken() {
|
|
790
807
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -797,7 +814,7 @@ class _e {
|
|
|
797
814
|
return !1;
|
|
798
815
|
const s = this.socket;
|
|
799
816
|
try {
|
|
800
|
-
return s.send(JSON.stringify(t)),
|
|
817
|
+
return s.send(JSON.stringify(t)), Et("client_event", t.type, oe(t)), !0;
|
|
801
818
|
} catch (n) {
|
|
802
819
|
return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
803
820
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -810,9 +827,9 @@ class _e {
|
|
|
810
827
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
811
828
|
return;
|
|
812
829
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
813
|
-
const t =
|
|
830
|
+
const t = gn();
|
|
814
831
|
this.sendNow(
|
|
815
|
-
|
|
832
|
+
_({
|
|
816
833
|
type: "starter_prompts.page_context",
|
|
817
834
|
pageUrl: t.pageUrl,
|
|
818
835
|
pageTitle: t.pageTitle,
|
|
@@ -821,13 +838,13 @@ class _e {
|
|
|
821
838
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
822
839
|
}
|
|
823
840
|
startStarterPromptUrlWatcher() {
|
|
824
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
841
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = mn(() => this.handleStarterPromptUrlChange()));
|
|
825
842
|
}
|
|
826
843
|
handleStarterPromptUrlChange() {
|
|
827
844
|
const t = location.href;
|
|
828
845
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
829
846
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
830
|
-
},
|
|
847
|
+
}, Hs));
|
|
831
848
|
}
|
|
832
849
|
refreshStarterPromptsForCurrentUrl() {
|
|
833
850
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -845,7 +862,7 @@ class _e {
|
|
|
845
862
|
j(this.options.clientId, this.queuedClientEvents);
|
|
846
863
|
for (let s = 0; s < t.length; s += 1) {
|
|
847
864
|
const n = t[s];
|
|
848
|
-
if (!this.sendNow(
|
|
865
|
+
if (!this.sendNow(_(n))) {
|
|
849
866
|
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), j(this.options.clientId, this.queuedClientEvents);
|
|
850
867
|
return;
|
|
851
868
|
}
|
|
@@ -856,308 +873,327 @@ class _e {
|
|
|
856
873
|
!this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
|
|
857
874
|
}
|
|
858
875
|
handleServerEvent(t) {
|
|
859
|
-
if (
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
}
|
|
863
|
-
if (t.type === "run.ack") {
|
|
864
|
-
this.handleRunAck(t);
|
|
876
|
+
if (Et("server_event", t.type, oe(t)), t.type === "run.ack") {
|
|
877
|
+
const s = Mt(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
|
|
878
|
+
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
879
|
return;
|
|
866
880
|
}
|
|
867
|
-
if (t.type === "
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
const s = An(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
874
|
-
S("web-sdk.agent", "Received auth.ok appearance", {
|
|
875
|
-
hasAppearance: n,
|
|
876
|
-
rawAppearance: t.appearance,
|
|
877
|
-
normalizedAppearance: s
|
|
878
|
-
}), this.runtimeHelperJavascript = En(t.runtimeHelpers)?.javascript ?? null;
|
|
879
|
-
const r = pe(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
880
|
-
user: kn(t.user),
|
|
881
|
-
status: "connected",
|
|
882
|
-
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
883
|
-
};
|
|
884
|
-
(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 && !fn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
885
|
-
type: "page.upsert",
|
|
886
|
-
sessionId: this.state.sessionId,
|
|
887
|
-
page: M(),
|
|
888
|
-
model: this.options.model
|
|
889
|
-
});
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
if (t.type === "starterPrompts.updated") {
|
|
893
|
-
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
894
|
-
starterPrompts: pe(t, "starterPrompts"),
|
|
895
|
-
starterPromptsLoading: !1
|
|
896
|
-
});
|
|
897
|
-
return;
|
|
881
|
+
if (t.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
882
|
+
const s = Mt(t);
|
|
883
|
+
if (s) {
|
|
884
|
+
this.deferredSessionUpdatedSessionIds.add(s);
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
898
887
|
}
|
|
899
|
-
if (t
|
|
900
|
-
|
|
901
|
-
t
|
|
902
|
-
|
|
903
|
-
this.rememberUserMessageClientMessageIds(s);
|
|
904
|
-
const i = Yn(s);
|
|
905
|
-
if (i) {
|
|
906
|
-
const p = Zn(s, i);
|
|
907
|
-
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
908
|
-
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
909
|
-
p
|
|
910
|
-
);
|
|
888
|
+
if (!this.shouldIgnoreBackgroundSessionEvent(t)) {
|
|
889
|
+
if (t.type === "run.steered") {
|
|
890
|
+
this.handleRunSteered(t);
|
|
891
|
+
return;
|
|
911
892
|
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
return !me(m) && (!i || !Nt(m));
|
|
915
|
-
}), a = jn(
|
|
916
|
-
this.state.messages,
|
|
917
|
-
_n(o, this.options.backendUrl)
|
|
918
|
-
), c = ge(a), l = !r && s.some(
|
|
919
|
-
(p) => Ie(
|
|
920
|
-
q(p),
|
|
921
|
-
this.state.assistantDraft,
|
|
922
|
-
this.state.assistantDraftItemId,
|
|
923
|
-
this.state.assistantDraftRespondsToUserMessageId,
|
|
924
|
-
this.state.assistantDraftRunId
|
|
925
|
-
)
|
|
926
|
-
), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = Xn(a), u = I && g;
|
|
927
|
-
if (!c && Vn(this.state.messages, s))
|
|
893
|
+
if (t.type === "runtime.pong") {
|
|
894
|
+
this.clearHeartbeatAckTimer();
|
|
928
895
|
return;
|
|
929
|
-
this.lastUserMessagePageUrl = Jn(s);
|
|
930
|
-
const d = I ? null : xt(s);
|
|
931
|
-
if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
|
|
932
|
-
sessionId: R(t.session, "id") ?? this.state.sessionId,
|
|
933
|
-
messages: a,
|
|
934
|
-
...r ? {
|
|
935
|
-
assistantDraft: n?.content ?? "",
|
|
936
|
-
assistantDraftItemId: n?.itemId ?? null,
|
|
937
|
-
assistantDraftPhase: n?.phase ?? null,
|
|
938
|
-
assistantDraftRespondsToUserMessageId: n?.respondsToUserMessageId ?? null,
|
|
939
|
-
assistantDraftRunId: n?.runId ?? null
|
|
940
|
-
} : l ? {
|
|
941
|
-
assistantDraft: "",
|
|
942
|
-
assistantDraftItemId: null,
|
|
943
|
-
assistantDraftPhase: null,
|
|
944
|
-
assistantDraftRespondsToUserMessageId: null,
|
|
945
|
-
assistantDraftRunId: null
|
|
946
|
-
} : {},
|
|
947
|
-
...f ? {
|
|
948
|
-
isThinking: !0,
|
|
949
|
-
lastError: null
|
|
950
|
-
} : I ? {
|
|
951
|
-
isThinking: !1,
|
|
952
|
-
...u ? {
|
|
953
|
-
status: "connected",
|
|
954
|
-
lastError: null,
|
|
955
|
-
lastErrorCode: null,
|
|
956
|
-
lastErrorSecuritySettingsUrl: null
|
|
957
|
-
} : {}
|
|
958
|
-
} : d ? {
|
|
959
|
-
isThinking: !0,
|
|
960
|
-
lastError: null
|
|
961
|
-
} : {}
|
|
962
|
-
}), I ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (f || d) && (d && (this.activeClientMessageId = d), this.markThinkingProgress()), i) {
|
|
963
|
-
const p = R(t.session, "id") ?? this.state.sessionId;
|
|
964
|
-
p && this.retryAfterInterruptedRun(p, i);
|
|
965
896
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
if (t.type === "session.item") {
|
|
989
|
-
this.rememberUserMessageClientMessageIds([t.item]);
|
|
990
|
-
const s = q(t.item);
|
|
991
|
-
if (Nt(s)) {
|
|
992
|
-
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
993
|
-
const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
994
|
-
if (r && a) {
|
|
995
|
-
this.retryAfterInterruptedRun(r, a);
|
|
996
|
-
return;
|
|
997
|
-
}
|
|
998
|
-
if (r && i) {
|
|
999
|
-
this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
|
|
1000
|
-
return;
|
|
1001
|
-
}
|
|
897
|
+
if (Ks(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
898
|
+
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
|
|
899
|
+
const s = kn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
900
|
+
S("web-sdk.agent", "Received auth.ok appearance", {
|
|
901
|
+
hasAppearance: n,
|
|
902
|
+
rawAppearance: t.appearance,
|
|
903
|
+
normalizedAppearance: s
|
|
904
|
+
}), this.runtimeHelperJavascript = Mn(t.runtimeHelpers)?.javascript ?? null;
|
|
905
|
+
const r = ge(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
906
|
+
user: Un(t.user),
|
|
907
|
+
status: "connected",
|
|
908
|
+
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
909
|
+
};
|
|
910
|
+
(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 && !In() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
911
|
+
type: "page.upsert",
|
|
912
|
+
sessionId: this.state.sessionId,
|
|
913
|
+
page: k(),
|
|
914
|
+
model: this.options.model
|
|
915
|
+
});
|
|
916
|
+
return;
|
|
1002
917
|
}
|
|
1003
|
-
if (
|
|
918
|
+
if (t.type === "starterPrompts.updated") {
|
|
919
|
+
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
920
|
+
starterPrompts: ge(t, "starterPrompts"),
|
|
921
|
+
starterPromptsLoading: !1
|
|
922
|
+
});
|
|
1004
923
|
return;
|
|
1005
|
-
|
|
1006
|
-
if (
|
|
1007
|
-
const
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
this.
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
924
|
+
}
|
|
925
|
+
if (t.type === "conversation.state") {
|
|
926
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Bn(
|
|
927
|
+
t.assistantDraft
|
|
928
|
+
), r = n !== void 0;
|
|
929
|
+
this.rememberUserMessageClientMessageIds(s);
|
|
930
|
+
const i = er(s);
|
|
931
|
+
if (i) {
|
|
932
|
+
const p = sr(s, i);
|
|
933
|
+
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
934
|
+
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
935
|
+
p
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
const o = s.filter((p) => {
|
|
939
|
+
const m = q(p);
|
|
940
|
+
return !ye(m) && (!i || !Lt(m));
|
|
941
|
+
}), a = Xn(
|
|
942
|
+
this.state.messages,
|
|
943
|
+
Dn(o, this.options.backendUrl)
|
|
944
|
+
), c = me(a), l = !r && s.some(
|
|
945
|
+
(p) => Te(
|
|
946
|
+
q(p),
|
|
947
|
+
this.state.assistantDraft,
|
|
948
|
+
this.state.assistantDraftItemId,
|
|
949
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
950
|
+
this.state.assistantDraftRunId
|
|
951
|
+
)
|
|
952
|
+
), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = Zn(a), u = I && g;
|
|
953
|
+
if (!c && tr(this.state.messages, s))
|
|
954
|
+
return;
|
|
955
|
+
this.lastUserMessagePageUrl = Qn(s);
|
|
956
|
+
const d = I ? null : qt(s);
|
|
957
|
+
if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
|
|
958
|
+
sessionId: E(t.session, "id") ?? this.state.sessionId,
|
|
959
|
+
messages: a,
|
|
960
|
+
...r ? {
|
|
961
|
+
assistantDraft: n?.content ?? "",
|
|
962
|
+
assistantDraftItemId: n?.itemId ?? null,
|
|
963
|
+
assistantDraftPhase: n?.phase ?? null,
|
|
964
|
+
assistantDraftRespondsToUserMessageId: n?.respondsToUserMessageId ?? null,
|
|
965
|
+
assistantDraftRunId: n?.runId ?? null
|
|
966
|
+
} : l ? {
|
|
1021
967
|
assistantDraft: "",
|
|
1022
968
|
assistantDraftItemId: null,
|
|
1023
969
|
assistantDraftPhase: null,
|
|
1024
970
|
assistantDraftRespondsToUserMessageId: null,
|
|
1025
971
|
assistantDraftRunId: null
|
|
1026
972
|
} : {},
|
|
1027
|
-
...
|
|
1028
|
-
isThinking: !
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
973
|
+
...f ? {
|
|
974
|
+
isThinking: !0,
|
|
975
|
+
lastError: null
|
|
976
|
+
} : I ? {
|
|
977
|
+
isThinking: !1,
|
|
978
|
+
...u ? {
|
|
979
|
+
status: "connected",
|
|
980
|
+
lastError: null,
|
|
981
|
+
lastErrorCode: null,
|
|
982
|
+
lastErrorSecuritySettingsUrl: null
|
|
983
|
+
} : {}
|
|
984
|
+
} : d ? {
|
|
985
|
+
isThinking: !0,
|
|
986
|
+
lastError: null
|
|
1035
987
|
} : {}
|
|
1036
|
-
}),
|
|
988
|
+
}), I ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (f || d) && (d && (this.activeClientMessageId = d), this.markThinkingProgress()), i) {
|
|
989
|
+
const p = E(t.session, "id") ?? this.state.sessionId;
|
|
990
|
+
p && this.retryAfterInterruptedRun(p, i);
|
|
991
|
+
}
|
|
992
|
+
return;
|
|
1037
993
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
messages: Dt(this.state.messages, {
|
|
1045
|
-
id: o,
|
|
1046
|
-
role: "assistant",
|
|
1047
|
-
content: i,
|
|
1048
|
-
createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1049
|
-
dataType: "assistant_draft",
|
|
1050
|
-
...c ? { phase: c } : {},
|
|
1051
|
-
...l ? { respondsToUserMessageId: l } : {},
|
|
1052
|
-
...h ? { runId: h } : {}
|
|
1053
|
-
}),
|
|
1054
|
-
assistantDraft: i,
|
|
1055
|
-
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1056
|
-
assistantDraftPhase: c,
|
|
1057
|
-
assistantDraftRespondsToUserMessageId: l,
|
|
1058
|
-
assistantDraftRunId: h,
|
|
1059
|
-
isThinking: !0
|
|
1060
|
-
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1061
|
-
return;
|
|
1062
|
-
}
|
|
1063
|
-
if (t.type === "chat.assistant_done") {
|
|
1064
|
-
if (typeof t.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(t.runId))
|
|
994
|
+
if (t.type === "sessions.page") {
|
|
995
|
+
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
996
|
+
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
997
|
+
sessions: On(t.sessions),
|
|
998
|
+
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
999
|
+
}));
|
|
1065
1000
|
return;
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1001
|
+
}
|
|
1002
|
+
if (t.type === "session.pin.updated") {
|
|
1003
|
+
this.resolvePendingSessionMutation(this.pendingSessionPinRequests, t);
|
|
1069
1004
|
return;
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
if (t.type === "tool.call") {
|
|
1100
|
-
this.clearRunAckResyncRetryTimer();
|
|
1101
|
-
const s = t.hiddenFromTranscript === !0 && typeof t.callId == "string" ? t.callId : null;
|
|
1102
|
-
if (s)
|
|
1103
|
-
this.nonTranscriptToolCallIds.add(s);
|
|
1104
|
-
else {
|
|
1105
|
-
const n = Wn(t);
|
|
1005
|
+
}
|
|
1006
|
+
if (t.type === "session.rename.updated") {
|
|
1007
|
+
this.resolvePendingSessionMutation(this.pendingSessionRenameRequests, t);
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
if (t.type === "session.updated") {
|
|
1011
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: E(t.session, "id") ?? this.state.sessionId });
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (t.type === "session.item") {
|
|
1015
|
+
this.rememberUserMessageClientMessageIds([t.item]);
|
|
1016
|
+
const s = q(t.item);
|
|
1017
|
+
if (Lt(s)) {
|
|
1018
|
+
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1019
|
+
const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1020
|
+
if (r && a) {
|
|
1021
|
+
this.retryAfterInterruptedRun(r, a);
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
if (r && i) {
|
|
1025
|
+
this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
if (ye(s))
|
|
1030
|
+
return;
|
|
1031
|
+
const n = ve(t.item, this.options.backendUrl);
|
|
1106
1032
|
if (n) {
|
|
1107
|
-
const r =
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
);
|
|
1033
|
+
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1034
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), v(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1035
|
+
const i = t.item.data;
|
|
1036
|
+
rr(i) && this.clearRunAckResyncRetryTimer();
|
|
1037
|
+
const o = Nt(this.state.messages, n), a = me(o), c = Te(
|
|
1038
|
+
i,
|
|
1039
|
+
this.state.assistantDraft,
|
|
1040
|
+
this.state.assistantDraftItemId,
|
|
1041
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
1042
|
+
this.state.assistantDraftRunId
|
|
1043
|
+
), l = a && (!this.state.assistantDraft || c), h = l && v(n);
|
|
1111
1044
|
this.setState({
|
|
1112
|
-
messages:
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1045
|
+
messages: o,
|
|
1046
|
+
...c ? {
|
|
1047
|
+
assistantDraft: "",
|
|
1048
|
+
assistantDraftItemId: null,
|
|
1049
|
+
assistantDraftPhase: null,
|
|
1050
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1051
|
+
assistantDraftRunId: null
|
|
1052
|
+
} : {},
|
|
1053
|
+
...l ? {
|
|
1054
|
+
isThinking: !1
|
|
1055
|
+
} : {},
|
|
1056
|
+
...h ? {
|
|
1057
|
+
status: "connected",
|
|
1058
|
+
lastError: null,
|
|
1059
|
+
lastErrorCode: null,
|
|
1060
|
+
lastErrorSecuritySettingsUrl: null
|
|
1061
|
+
} : {}
|
|
1062
|
+
}), l && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
1120
1063
|
}
|
|
1121
|
-
}
|
|
1122
|
-
this.executeToolCall(t);
|
|
1123
|
-
return;
|
|
1124
|
-
}
|
|
1125
|
-
if (t.type === "tool.status") {
|
|
1126
|
-
const s = typeof t.callId == "string" ? t.callId : null;
|
|
1127
|
-
if (!s)
|
|
1128
1064
|
return;
|
|
1129
|
-
|
|
1130
|
-
if (
|
|
1065
|
+
}
|
|
1066
|
+
if (t.type === "chat.assistant_delta") {
|
|
1067
|
+
this.clearRunAckResyncRetryTimer();
|
|
1068
|
+
const s = typeof t.delta == "string" ? t.delta : "", n = typeof t.itemId == "string" ? t.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((f) => f.id === o), c = t.phase === "commentary" || t.phase === "final_answer" ? t.phase : r ? null : this.state.assistantDraftPhase, l = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
|
|
1069
|
+
this.setState({
|
|
1070
|
+
messages: Nt(this.state.messages, {
|
|
1071
|
+
id: o,
|
|
1072
|
+
role: "assistant",
|
|
1073
|
+
content: i,
|
|
1074
|
+
createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1075
|
+
dataType: "assistant_draft",
|
|
1076
|
+
...c ? { phase: c } : {},
|
|
1077
|
+
...l ? { respondsToUserMessageId: l } : {},
|
|
1078
|
+
...h ? { runId: h } : {}
|
|
1079
|
+
}),
|
|
1080
|
+
assistantDraft: i,
|
|
1081
|
+
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1082
|
+
assistantDraftPhase: c,
|
|
1083
|
+
assistantDraftRespondsToUserMessageId: l,
|
|
1084
|
+
assistantDraftRunId: h,
|
|
1085
|
+
isThinking: !0
|
|
1086
|
+
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1131
1087
|
return;
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1088
|
+
}
|
|
1089
|
+
if (t.type === "chat.assistant_done") {
|
|
1090
|
+
if (typeof t.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(t.runId))
|
|
1091
|
+
return;
|
|
1092
|
+
this.retryableClientMessageId = null;
|
|
1093
|
+
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;
|
|
1094
|
+
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1095
|
+
return;
|
|
1096
|
+
const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = cs(
|
|
1097
|
+
this.state.messages.filter(
|
|
1098
|
+
(l) => l.dataType !== "assistant_draft" || !Wn(
|
|
1099
|
+
l,
|
|
1100
|
+
n,
|
|
1101
|
+
r
|
|
1102
|
+
)
|
|
1103
|
+
),
|
|
1104
|
+
n,
|
|
1105
|
+
r,
|
|
1106
|
+
xe
|
|
1107
|
+
);
|
|
1108
|
+
this.setState({
|
|
1109
|
+
sessionId: s,
|
|
1110
|
+
messages: $n(
|
|
1111
|
+
c,
|
|
1112
|
+
typeof t.responseId == "string" ? t.responseId : null,
|
|
1113
|
+
n,
|
|
1114
|
+
r
|
|
1115
|
+
),
|
|
1116
|
+
assistantDraft: "",
|
|
1117
|
+
assistantDraftItemId: null,
|
|
1118
|
+
assistantDraftPhase: null,
|
|
1119
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1120
|
+
assistantDraftRunId: null,
|
|
1121
|
+
isThinking: a ? !1 : this.state.isThinking
|
|
1122
|
+
}), a && this.clearThinkingWatchdog();
|
|
1141
1123
|
return;
|
|
1142
1124
|
}
|
|
1143
|
-
if (
|
|
1125
|
+
if (t.type === "tool.call") {
|
|
1126
|
+
this.clearRunAckResyncRetryTimer();
|
|
1127
|
+
const s = t.hiddenFromTranscript === !0 && typeof t.callId == "string" ? t.callId : null;
|
|
1128
|
+
if (s)
|
|
1129
|
+
this.nonTranscriptToolCallIds.add(s);
|
|
1130
|
+
else {
|
|
1131
|
+
const n = Kn(t);
|
|
1132
|
+
if (n) {
|
|
1133
|
+
const r = jn(
|
|
1134
|
+
this.state.messages,
|
|
1135
|
+
n
|
|
1136
|
+
);
|
|
1137
|
+
this.setState({
|
|
1138
|
+
messages: r,
|
|
1139
|
+
isThinking: !0
|
|
1140
|
+
}), this.emit(
|
|
1141
|
+
"message",
|
|
1142
|
+
r.find(
|
|
1143
|
+
(i) => i.callId === n.callId
|
|
1144
|
+
) ?? n
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
this.executeToolCall(t);
|
|
1144
1149
|
return;
|
|
1145
|
-
|
|
1146
|
-
if (
|
|
1147
|
-
|
|
1150
|
+
}
|
|
1151
|
+
if (t.type === "tool.status") {
|
|
1152
|
+
const s = typeof t.callId == "string" ? t.callId : null;
|
|
1153
|
+
if (!s)
|
|
1154
|
+
return;
|
|
1155
|
+
const n = t.status === "queued" || t.status === "running";
|
|
1156
|
+
if (this.nonTranscriptToolCallIds.has(s) || n && this.terminalToolCallIds.has(s))
|
|
1157
|
+
return;
|
|
1158
|
+
n || this.terminalToolCallIds.add(s), this.state.messages.some(
|
|
1159
|
+
(i) => i.callId === s
|
|
1160
|
+
) ? this.setToolMessageLoading(s, n) : this.pendingToolLoadingByCallId.set(s, n);
|
|
1148
1161
|
return;
|
|
1149
1162
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1163
|
+
if (t.type === "error") {
|
|
1164
|
+
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1165
|
+
if (s && n) {
|
|
1166
|
+
window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof t.message == "string" ? t.message : "Pluno error"));
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
if (this.rejectPendingSessionMutation(this.pendingSessionPinRequests, t) || this.rejectPendingSessionMutation(this.pendingSessionRenameRequests, t))
|
|
1170
|
+
return;
|
|
1171
|
+
const r = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, i = typeof t.clientMessageId == "string" ? t.clientMessageId : null, o = t.retryable === !0 || t.code === "transient_model_error";
|
|
1172
|
+
if (this.retryAfterRetryableError(t)) {
|
|
1173
|
+
t.code !== "run_still_active" && typeof t.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(t.runId);
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
o && r && i && (this.retryableClientMessageId = i);
|
|
1177
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = pn(a.message);
|
|
1178
|
+
c && console.error(c), this.setState({
|
|
1179
|
+
status: "error",
|
|
1180
|
+
isThinking: !1,
|
|
1181
|
+
lastError: a.message,
|
|
1182
|
+
lastErrorCode: typeof t.code == "string" ? t.code : null,
|
|
1183
|
+
lastErrorSecuritySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : null
|
|
1184
|
+
}), this.clearThinkingWatchdog(), this.emit("error", a);
|
|
1185
|
+
}
|
|
1159
1186
|
}
|
|
1160
1187
|
}
|
|
1188
|
+
shouldIgnoreBackgroundSessionEvent(t) {
|
|
1189
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !Gs(t))
|
|
1190
|
+
return !1;
|
|
1191
|
+
const s = Mt(t);
|
|
1192
|
+
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1193
|
+
}
|
|
1194
|
+
rememberCurrentRunAsBackground() {
|
|
1195
|
+
this.options.keepRunsActiveOnSessionNavigation && (this.state.sessionId ? this.backgroundSessionIds.add(this.state.sessionId) : this.state.isThinking && this.activeClientMessageId && this.backgroundClientMessageIds.add(this.activeClientMessageId));
|
|
1196
|
+
}
|
|
1161
1197
|
retryAfterRetryableError(t) {
|
|
1162
1198
|
const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
|
|
1163
1199
|
if (!(t.retryable === !0 || t.code === "transient_model_error") || !s || !n || t.code === "run_recovery_exhausted")
|
|
@@ -1213,7 +1249,7 @@ class _e {
|
|
|
1213
1249
|
}
|
|
1214
1250
|
rememberUserMessageClientMessageIds(t) {
|
|
1215
1251
|
for (const s of t) {
|
|
1216
|
-
const n =
|
|
1252
|
+
const n = E(s, "id"), r = q(s);
|
|
1217
1253
|
n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
|
|
1218
1254
|
}
|
|
1219
1255
|
}
|
|
@@ -1226,7 +1262,7 @@ class _e {
|
|
|
1226
1262
|
const r = new Promise((i, o) => {
|
|
1227
1263
|
const a = window.setTimeout(() => {
|
|
1228
1264
|
t.delete(s.requestId), o(new Error(n));
|
|
1229
|
-
},
|
|
1265
|
+
}, ue);
|
|
1230
1266
|
t.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1231
1267
|
});
|
|
1232
1268
|
if (!this.sendNow(s)) {
|
|
@@ -1249,7 +1285,7 @@ class _e {
|
|
|
1249
1285
|
t.clear();
|
|
1250
1286
|
}
|
|
1251
1287
|
markThinkingProgress() {
|
|
1252
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1288
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(le), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1253
1289
|
}
|
|
1254
1290
|
scheduleThinkingWatchdog(t) {
|
|
1255
1291
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1269,7 +1305,7 @@ class _e {
|
|
|
1269
1305
|
handleRunSteered(t) {
|
|
1270
1306
|
const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
|
|
1271
1307
|
!this.state.isThinking || !s || this.setState({
|
|
1272
|
-
messages:
|
|
1308
|
+
messages: or(
|
|
1273
1309
|
this.state.messages,
|
|
1274
1310
|
s
|
|
1275
1311
|
)
|
|
@@ -1278,7 +1314,7 @@ class _e {
|
|
|
1278
1314
|
scheduleRunAckWatchdog(t) {
|
|
1279
1315
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1280
1316
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1281
|
-
},
|
|
1317
|
+
}, Os);
|
|
1282
1318
|
}
|
|
1283
1319
|
recoverMissedRunAck(t) {
|
|
1284
1320
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1302,8 +1338,8 @@ class _e {
|
|
|
1302
1338
|
sessionId: this.state.sessionId,
|
|
1303
1339
|
clientMessageId: t,
|
|
1304
1340
|
automatic: !0
|
|
1305
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1306
|
-
}, Y(s,
|
|
1341
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(le)));
|
|
1342
|
+
}, Y(s, Ns)));
|
|
1307
1343
|
}
|
|
1308
1344
|
clearRunAckResyncRetryTimer() {
|
|
1309
1345
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1342,7 +1378,7 @@ class _e {
|
|
|
1342
1378
|
sessionId: this.state.sessionId,
|
|
1343
1379
|
clientMessageId: t,
|
|
1344
1380
|
resyncAttempts: s + 1
|
|
1345
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1381
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ds);
|
|
1346
1382
|
return;
|
|
1347
1383
|
}
|
|
1348
1384
|
this.setState({
|
|
@@ -1366,7 +1402,7 @@ class _e {
|
|
|
1366
1402
|
this.state.sessionId ? this.send({
|
|
1367
1403
|
type: "page.upsert",
|
|
1368
1404
|
sessionId: this.state.sessionId,
|
|
1369
|
-
page:
|
|
1405
|
+
page: k(),
|
|
1370
1406
|
model: this.options.model
|
|
1371
1407
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1372
1408
|
}
|
|
@@ -1377,15 +1413,15 @@ class _e {
|
|
|
1377
1413
|
if (!s || !n || !r)
|
|
1378
1414
|
return;
|
|
1379
1415
|
const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1380
|
-
if (!a && !c || !
|
|
1416
|
+
if (!a && !c || !Rr(o)) {
|
|
1381
1417
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1382
1418
|
type: "tool.result",
|
|
1383
1419
|
sessionId: s,
|
|
1384
1420
|
callId: n,
|
|
1385
1421
|
toolName: r,
|
|
1386
1422
|
summary: i,
|
|
1387
|
-
rawInput:
|
|
1388
|
-
rawOutput:
|
|
1423
|
+
rawInput: _(o),
|
|
1424
|
+
rawOutput: _({
|
|
1389
1425
|
ok: !1,
|
|
1390
1426
|
toolName: r,
|
|
1391
1427
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -1400,7 +1436,7 @@ class _e {
|
|
|
1400
1436
|
callId: n,
|
|
1401
1437
|
toolName: r,
|
|
1402
1438
|
summary: i,
|
|
1403
|
-
rawInput:
|
|
1439
|
+
rawInput: _(o),
|
|
1404
1440
|
rawOutput: {
|
|
1405
1441
|
ok: !1,
|
|
1406
1442
|
toolName: r,
|
|
@@ -1409,7 +1445,7 @@ class _e {
|
|
|
1409
1445
|
});
|
|
1410
1446
|
return;
|
|
1411
1447
|
}
|
|
1412
|
-
const l =
|
|
1448
|
+
const l = Vs(this.state.messages);
|
|
1413
1449
|
this.activeBrowserToolCalls.set(n, {
|
|
1414
1450
|
event: {
|
|
1415
1451
|
type: "tool.result",
|
|
@@ -1417,7 +1453,7 @@ class _e {
|
|
|
1417
1453
|
callId: n,
|
|
1418
1454
|
toolName: r,
|
|
1419
1455
|
summary: i,
|
|
1420
|
-
rawInput:
|
|
1456
|
+
rawInput: _(o),
|
|
1421
1457
|
rawOutput: null
|
|
1422
1458
|
},
|
|
1423
1459
|
startedAtMs: Date.now(),
|
|
@@ -1425,9 +1461,9 @@ class _e {
|
|
|
1425
1461
|
startedAtOrigin: location.origin
|
|
1426
1462
|
}), this.installSessionUserFilesApi(l);
|
|
1427
1463
|
let h = null, f;
|
|
1428
|
-
h = await this.executeRuntimeHelper(), f = await
|
|
1464
|
+
h = await this.executeRuntimeHelper(), f = await pe(
|
|
1429
1465
|
o,
|
|
1430
|
-
|
|
1466
|
+
cn(t.runtimeContext, this.options.backendUrl)
|
|
1431
1467
|
).catch((I) => ({
|
|
1432
1468
|
ok: !1,
|
|
1433
1469
|
exception: {
|
|
@@ -1439,12 +1475,12 @@ class _e {
|
|
|
1439
1475
|
callId: n,
|
|
1440
1476
|
toolName: r,
|
|
1441
1477
|
summary: o.summary,
|
|
1442
|
-
rawInput:
|
|
1443
|
-
rawOutput:
|
|
1444
|
-
}),
|
|
1478
|
+
rawInput: _(o),
|
|
1479
|
+
rawOutput: _(_n(f, h))
|
|
1480
|
+
}), mr(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1445
1481
|
}
|
|
1446
1482
|
setToolMessageLoading(t, s) {
|
|
1447
|
-
const n =
|
|
1483
|
+
const n = zn(
|
|
1448
1484
|
this.state.messages,
|
|
1449
1485
|
t,
|
|
1450
1486
|
s
|
|
@@ -1455,47 +1491,47 @@ class _e {
|
|
|
1455
1491
|
if (this.pageLifecycleCleanup)
|
|
1456
1492
|
return;
|
|
1457
1493
|
const t = () => {
|
|
1458
|
-
|
|
1494
|
+
Fe(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1459
1495
|
};
|
|
1460
1496
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1461
1497
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1462
1498
|
};
|
|
1463
1499
|
}
|
|
1464
1500
|
installSessionUserFilesApi(t) {
|
|
1465
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1501
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Ys(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1466
1502
|
}
|
|
1467
1503
|
cleanupSessionUserFilesApi() {
|
|
1468
|
-
this.sessionUserFilesApiCleanup && (
|
|
1504
|
+
this.sessionUserFilesApiCleanup && (on(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1469
1505
|
}
|
|
1470
1506
|
async executeRuntimeHelper() {
|
|
1471
1507
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1472
1508
|
return null;
|
|
1473
|
-
const t = await
|
|
1509
|
+
const t = await pe({
|
|
1474
1510
|
javascript: this.runtimeHelperJavascript
|
|
1475
1511
|
});
|
|
1476
|
-
return t.ok === !1 ?
|
|
1512
|
+
return t.ok === !1 ? Cn(t) : null;
|
|
1477
1513
|
}
|
|
1478
1514
|
enableNetworkCapture() {
|
|
1479
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1480
|
-
|
|
1515
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = js((t) => {
|
|
1516
|
+
Ur(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1481
1517
|
}));
|
|
1482
1518
|
}
|
|
1483
1519
|
enqueueNetworkEvent(t) {
|
|
1484
|
-
this.queuedNetworkEvents.length >=
|
|
1520
|
+
this.queuedNetworkEvents.length >= xs || (this.queuedNetworkEvents.push(Pr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1485
1521
|
this.networkBatchTimer = null;
|
|
1486
1522
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1487
1523
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
1488
1524
|
type: "network.batch",
|
|
1489
1525
|
sessionId: this.state.sessionId ?? void 0,
|
|
1490
|
-
page:
|
|
1526
|
+
page: k(),
|
|
1491
1527
|
events: s
|
|
1492
1528
|
});
|
|
1493
|
-
},
|
|
1529
|
+
}, vs)));
|
|
1494
1530
|
}
|
|
1495
1531
|
scheduleReconnect() {
|
|
1496
1532
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1497
1533
|
return;
|
|
1498
|
-
const t =
|
|
1534
|
+
const t = Ws(this.reconnectAttempts);
|
|
1499
1535
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1500
1536
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1501
1537
|
S("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1511,8 +1547,8 @@ class _e {
|
|
|
1511
1547
|
const t = this.socket;
|
|
1512
1548
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1513
1549
|
this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1514
|
-
},
|
|
1515
|
-
},
|
|
1550
|
+
}, Ms));
|
|
1551
|
+
}, ks);
|
|
1516
1552
|
}
|
|
1517
1553
|
stopHeartbeat() {
|
|
1518
1554
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1538,7 +1574,7 @@ class _e {
|
|
|
1538
1574
|
...t,
|
|
1539
1575
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1540
1576
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1541
|
-
},
|
|
1577
|
+
}, fr(this.options.clientId, this.state), this.emit("state", this.getState()), Et("state", this.state.status, {
|
|
1542
1578
|
status: this.state.status,
|
|
1543
1579
|
sessionId: this.state.sessionId,
|
|
1544
1580
|
messageCount: this.state.messages.length,
|
|
@@ -1555,14 +1591,14 @@ class _e {
|
|
|
1555
1591
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1556
1592
|
}
|
|
1557
1593
|
}
|
|
1558
|
-
const
|
|
1559
|
-
function
|
|
1560
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1594
|
+
const kt = /* @__PURE__ */ new WeakMap();
|
|
1595
|
+
function js(e) {
|
|
1596
|
+
const t = window.__plunoProductAgentNetworkCapture ?? zs();
|
|
1561
1597
|
return t.subscribers.add(e), () => {
|
|
1562
1598
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1563
1599
|
};
|
|
1564
1600
|
}
|
|
1565
|
-
function
|
|
1601
|
+
function zs() {
|
|
1566
1602
|
const e = /* @__PURE__ */ new Set(), t = (I) => {
|
|
1567
1603
|
e.forEach((g) => {
|
|
1568
1604
|
try {
|
|
@@ -1579,31 +1615,31 @@ function Ws() {
|
|
|
1579
1615
|
throw m;
|
|
1580
1616
|
}
|
|
1581
1617
|
try {
|
|
1582
|
-
const m = g instanceof Request ? g : null,
|
|
1583
|
-
if (!x(
|
|
1618
|
+
const m = g instanceof Request ? g : null, b = kr(g, m), T = $e(u?.headers ?? m?.headers);
|
|
1619
|
+
if (!x(b, T, u?.body)) {
|
|
1584
1620
|
const F = {
|
|
1585
|
-
requestId:
|
|
1586
|
-
url: P(
|
|
1621
|
+
requestId: Pt("fetch"),
|
|
1622
|
+
url: P(b, Rt),
|
|
1587
1623
|
method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
1588
1624
|
requestHeaders: T,
|
|
1589
|
-
requestBody:
|
|
1625
|
+
requestBody: be(u?.body),
|
|
1590
1626
|
resourceType: "fetch",
|
|
1591
1627
|
startedAt: new Date(d).toISOString()
|
|
1592
1628
|
};
|
|
1593
1629
|
p.then(
|
|
1594
|
-
(
|
|
1595
|
-
|
|
1630
|
+
(C) => {
|
|
1631
|
+
Mr(C, F, d, t).catch(() => {
|
|
1596
1632
|
t({
|
|
1597
1633
|
...F,
|
|
1598
|
-
responseStatus:
|
|
1634
|
+
responseStatus: C.status,
|
|
1599
1635
|
durationMs: Date.now() - d
|
|
1600
1636
|
});
|
|
1601
1637
|
});
|
|
1602
1638
|
},
|
|
1603
|
-
(
|
|
1639
|
+
(C) => {
|
|
1604
1640
|
t({
|
|
1605
1641
|
...F,
|
|
1606
|
-
errorText: P(
|
|
1642
|
+
errorText: P(C instanceof Error ? C.message : String(C)),
|
|
1607
1643
|
durationMs: Date.now() - d
|
|
1608
1644
|
});
|
|
1609
1645
|
}
|
|
@@ -1613,28 +1649,28 @@ function Ws() {
|
|
|
1613
1649
|
}
|
|
1614
1650
|
return p;
|
|
1615
1651
|
}, a = function(g, u, d, p, m) {
|
|
1616
|
-
const
|
|
1617
|
-
return
|
|
1618
|
-
requestId:
|
|
1652
|
+
const b = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
1653
|
+
return kt.set(this, {
|
|
1654
|
+
requestId: Pt("xhr"),
|
|
1619
1655
|
method: String(g ?? "GET").toUpperCase(),
|
|
1620
|
-
url: P(T,
|
|
1656
|
+
url: P(T, Rt),
|
|
1621
1657
|
requestHeaders: {},
|
|
1622
1658
|
startedAtMs: Date.now(),
|
|
1623
1659
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1624
1660
|
excluded: x(T)
|
|
1625
|
-
}),
|
|
1661
|
+
}), b;
|
|
1626
1662
|
}, c = function(g, u) {
|
|
1627
|
-
const d = r.call(this, g, u), p =
|
|
1628
|
-
return p && Object.keys(p.requestHeaders).length <
|
|
1663
|
+
const d = r.call(this, g, u), p = kt.get(this);
|
|
1664
|
+
return p && Object.keys(p.requestHeaders).length < jt && (p.requestHeaders[g] = Jt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
|
|
1629
1665
|
}, l = function(g) {
|
|
1630
1666
|
try {
|
|
1631
|
-
const u =
|
|
1632
|
-
u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody =
|
|
1667
|
+
const u = kt.get(this);
|
|
1668
|
+
u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody = be(g), u.excluded || this.addEventListener(
|
|
1633
1669
|
"loadend",
|
|
1634
1670
|
() => {
|
|
1635
1671
|
queueMicrotask(() => {
|
|
1636
1672
|
try {
|
|
1637
|
-
const d =
|
|
1673
|
+
const d = Or(this.getAllResponseHeaders());
|
|
1638
1674
|
t({
|
|
1639
1675
|
requestId: u.requestId,
|
|
1640
1676
|
url: u.url,
|
|
@@ -1644,7 +1680,7 @@ function Ws() {
|
|
|
1644
1680
|
resourceType: "xhr",
|
|
1645
1681
|
responseStatus: this.status,
|
|
1646
1682
|
responseHeaders: d,
|
|
1647
|
-
responseBody:
|
|
1683
|
+
responseBody: Cr(this, d),
|
|
1648
1684
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1649
1685
|
startedAt: u.startedAt,
|
|
1650
1686
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -1685,8 +1721,8 @@ function Ws() {
|
|
|
1685
1721
|
continue;
|
|
1686
1722
|
const d = performance.timeOrigin + u.startTime;
|
|
1687
1723
|
t({
|
|
1688
|
-
requestId:
|
|
1689
|
-
url: P(u.name,
|
|
1724
|
+
requestId: Pt("resource"),
|
|
1725
|
+
url: P(u.name, Rt),
|
|
1690
1726
|
method: "GET",
|
|
1691
1727
|
resourceType: "resource",
|
|
1692
1728
|
responseStatus: u.responseStatus,
|
|
@@ -1736,15 +1772,33 @@ function S(e, t, s) {
|
|
|
1736
1772
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1737
1773
|
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 }));
|
|
1738
1774
|
}
|
|
1739
|
-
function
|
|
1775
|
+
function he(e) {
|
|
1740
1776
|
const t = typeof e == "function" ? e() : e;
|
|
1741
1777
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1742
1778
|
}
|
|
1743
|
-
function
|
|
1779
|
+
function Ks(e) {
|
|
1744
1780
|
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";
|
|
1745
1781
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1782
|
+
function Gs(e) {
|
|
1783
|
+
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";
|
|
1784
|
+
}
|
|
1785
|
+
function Mt(e) {
|
|
1786
|
+
if (typeof e.sessionId == "string")
|
|
1787
|
+
return e.sessionId;
|
|
1788
|
+
if (e.session && typeof e.session == "object") {
|
|
1789
|
+
const t = e.session.id;
|
|
1790
|
+
if (typeof t == "string")
|
|
1791
|
+
return t;
|
|
1792
|
+
}
|
|
1793
|
+
if (e.item && typeof e.item == "object") {
|
|
1794
|
+
const t = e.item.sessionId;
|
|
1795
|
+
if (typeof t == "string")
|
|
1796
|
+
return t;
|
|
1797
|
+
}
|
|
1798
|
+
return null;
|
|
1799
|
+
}
|
|
1800
|
+
const Xs = 5e3, Js = 12e4;
|
|
1801
|
+
function Vs(e) {
|
|
1748
1802
|
const t = [];
|
|
1749
1803
|
for (const s of e)
|
|
1750
1804
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1755,30 +1809,30 @@ function Ks(e) {
|
|
|
1755
1809
|
});
|
|
1756
1810
|
return t;
|
|
1757
1811
|
}
|
|
1758
|
-
function
|
|
1812
|
+
function Ys(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1759
1813
|
const n = [
|
|
1760
|
-
|
|
1761
|
-
|
|
1814
|
+
Qs(),
|
|
1815
|
+
Zs()
|
|
1762
1816
|
].filter((r) => typeof r == "function");
|
|
1763
1817
|
return () => {
|
|
1764
1818
|
for (const r of n.reverse())
|
|
1765
1819
|
r();
|
|
1766
1820
|
};
|
|
1767
1821
|
}
|
|
1768
|
-
function
|
|
1769
|
-
return Re(globalThis, "getPageSnapshot", async () =>
|
|
1822
|
+
function Zs() {
|
|
1823
|
+
return Re(globalThis, "getPageSnapshot", async () => zt());
|
|
1770
1824
|
}
|
|
1771
|
-
function
|
|
1825
|
+
function Qs() {
|
|
1772
1826
|
return Re(globalThis, "pageImages", {
|
|
1773
|
-
inspectImage: async (t, s) => await
|
|
1827
|
+
inspectImage: async (t, s) => await tn(t, s)
|
|
1774
1828
|
});
|
|
1775
1829
|
}
|
|
1776
|
-
async function
|
|
1777
|
-
const s =
|
|
1830
|
+
async function tn(e, t = {}) {
|
|
1831
|
+
const s = rn(t.name), n = await en(e);
|
|
1778
1832
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1779
1833
|
type: "pluno.pageImages.inspectImage",
|
|
1780
1834
|
imageAttached: !1,
|
|
1781
|
-
imageAttachmentError:
|
|
1835
|
+
imageAttachmentError: _e
|
|
1782
1836
|
} : {
|
|
1783
1837
|
type: "pluno.pageImages.inspectImage",
|
|
1784
1838
|
imageAttached: !0,
|
|
@@ -1792,15 +1846,15 @@ async function Vs(e, t = {}) {
|
|
|
1792
1846
|
imageAttachmentError: n.error
|
|
1793
1847
|
};
|
|
1794
1848
|
}
|
|
1795
|
-
async function
|
|
1796
|
-
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:
|
|
1849
|
+
async function en(e) {
|
|
1850
|
+
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 } : {
|
|
1797
1851
|
ok: !0,
|
|
1798
1852
|
mimeType: e.type,
|
|
1799
1853
|
sizeBytes: e.size,
|
|
1800
|
-
dataUrl: await
|
|
1801
|
-
} : { 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." } :
|
|
1854
|
+
dataUrl: await an(e)
|
|
1855
|
+
} : { 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." } : sn(e);
|
|
1802
1856
|
}
|
|
1803
|
-
function
|
|
1857
|
+
function sn(e) {
|
|
1804
1858
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1805
1859
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1806
1860
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1811,7 +1865,7 @@ function Zs(e) {
|
|
|
1811
1865
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1812
1866
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1813
1867
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1814
|
-
const o =
|
|
1868
|
+
const o = nn(i);
|
|
1815
1869
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1816
1870
|
ok: !0,
|
|
1817
1871
|
mimeType: r,
|
|
@@ -1819,22 +1873,22 @@ function Zs(e) {
|
|
|
1819
1873
|
dataUrl: `data:${r};base64,${i}`
|
|
1820
1874
|
};
|
|
1821
1875
|
}
|
|
1822
|
-
function
|
|
1876
|
+
function nn(e) {
|
|
1823
1877
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1824
1878
|
return null;
|
|
1825
1879
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1826
1880
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1827
1881
|
}
|
|
1828
|
-
function
|
|
1882
|
+
function rn(e) {
|
|
1829
1883
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1830
1884
|
}
|
|
1831
|
-
function
|
|
1885
|
+
function on(e) {
|
|
1832
1886
|
try {
|
|
1833
1887
|
e();
|
|
1834
1888
|
} catch {
|
|
1835
1889
|
}
|
|
1836
1890
|
}
|
|
1837
|
-
function
|
|
1891
|
+
function an(e) {
|
|
1838
1892
|
return new Promise((t, s) => {
|
|
1839
1893
|
const n = new FileReader();
|
|
1840
1894
|
n.onload = () => {
|
|
@@ -1846,9 +1900,9 @@ function sn(e) {
|
|
|
1846
1900
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1847
1901
|
});
|
|
1848
1902
|
}
|
|
1849
|
-
async function
|
|
1903
|
+
async function pe(e, t) {
|
|
1850
1904
|
const s = Object.getPrototypeOf(async function() {
|
|
1851
|
-
}).constructor, n = e.timeoutMs ??
|
|
1905
|
+
}).constructor, n = e.timeoutMs ?? Xs, r = Date.now(), i = [];
|
|
1852
1906
|
let o;
|
|
1853
1907
|
const a = {
|
|
1854
1908
|
log: console.log,
|
|
@@ -1866,7 +1920,7 @@ async function de(e, t) {
|
|
|
1866
1920
|
o = window.setTimeout(() => f(l), n);
|
|
1867
1921
|
})
|
|
1868
1922
|
]);
|
|
1869
|
-
return h === l ?
|
|
1923
|
+
return h === l ? ln(n) : {
|
|
1870
1924
|
ok: !0,
|
|
1871
1925
|
result: h,
|
|
1872
1926
|
console: i,
|
|
@@ -1895,7 +1949,7 @@ async function de(e, t) {
|
|
|
1895
1949
|
t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
1896
1950
|
}
|
|
1897
1951
|
}
|
|
1898
|
-
function
|
|
1952
|
+
function cn(e, t) {
|
|
1899
1953
|
if (!e || typeof e != "object")
|
|
1900
1954
|
return;
|
|
1901
1955
|
const s = e.sandboxFilesToken;
|
|
@@ -1905,7 +1959,7 @@ function nn(e, t) {
|
|
|
1905
1959
|
const r = () => {
|
|
1906
1960
|
if (!n)
|
|
1907
1961
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
1908
|
-
}, i = async (a, c) => await
|
|
1962
|
+
}, i = async (a, c) => await Ts(`${t.replace(/\/$/, "")}${a}`, c);
|
|
1909
1963
|
return {
|
|
1910
1964
|
value: Object.freeze({
|
|
1911
1965
|
upload: async (a) => {
|
|
@@ -1939,7 +1993,7 @@ function nn(e, t) {
|
|
|
1939
1993
|
}
|
|
1940
1994
|
};
|
|
1941
1995
|
}
|
|
1942
|
-
function
|
|
1996
|
+
function ln(e) {
|
|
1943
1997
|
return {
|
|
1944
1998
|
ok: !1,
|
|
1945
1999
|
exception: {
|
|
@@ -1953,10 +2007,10 @@ function rn(e) {
|
|
|
1953
2007
|
}
|
|
1954
2008
|
};
|
|
1955
2009
|
}
|
|
1956
|
-
function
|
|
2010
|
+
function un(e) {
|
|
1957
2011
|
return e.replace(/\/+$/, "");
|
|
1958
2012
|
}
|
|
1959
|
-
function
|
|
2013
|
+
function dn(e) {
|
|
1960
2014
|
const t = {
|
|
1961
2015
|
sidepanel: "extension_sidepanel",
|
|
1962
2016
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -1968,18 +2022,18 @@ function an(e) {
|
|
|
1968
2022
|
};
|
|
1969
2023
|
return e && e in t ? t[e] : e ?? "embedded_custom_ui";
|
|
1970
2024
|
}
|
|
1971
|
-
function
|
|
2025
|
+
function hn(e) {
|
|
1972
2026
|
return e === "pluno" ? "scheduled_continuation" : e ?? "user";
|
|
1973
2027
|
}
|
|
1974
|
-
function
|
|
2028
|
+
function pn(e, t = location.origin) {
|
|
1975
2029
|
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;
|
|
1976
2030
|
}
|
|
1977
|
-
function
|
|
2031
|
+
function fn(e) {
|
|
1978
2032
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1979
2033
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1980
2034
|
}
|
|
1981
|
-
function
|
|
1982
|
-
const e =
|
|
2035
|
+
function k() {
|
|
2036
|
+
const e = Ne();
|
|
1983
2037
|
return {
|
|
1984
2038
|
url: location.href,
|
|
1985
2039
|
title: document.title,
|
|
@@ -1987,19 +2041,19 @@ function M() {
|
|
|
1987
2041
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1988
2042
|
};
|
|
1989
2043
|
}
|
|
1990
|
-
function
|
|
2044
|
+
function gn() {
|
|
1991
2045
|
return {
|
|
1992
2046
|
pageUrl: location.href,
|
|
1993
2047
|
pageTitle: document.title,
|
|
1994
|
-
htmlContent:
|
|
2048
|
+
htmlContent: zt()
|
|
1995
2049
|
};
|
|
1996
2050
|
}
|
|
1997
|
-
function
|
|
1998
|
-
return st.add(e), Z || (Z =
|
|
2051
|
+
function mn(e) {
|
|
2052
|
+
return st.add(e), Z || (Z = yn()), () => {
|
|
1999
2053
|
st.delete(e), st.size === 0 && (Z?.(), Z = null);
|
|
2000
2054
|
};
|
|
2001
2055
|
}
|
|
2002
|
-
function
|
|
2056
|
+
function yn() {
|
|
2003
2057
|
const e = () => {
|
|
2004
2058
|
for (const i of Array.from(st))
|
|
2005
2059
|
i();
|
|
@@ -2014,10 +2068,10 @@ function pn() {
|
|
|
2014
2068
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
2015
2069
|
};
|
|
2016
2070
|
}
|
|
2017
|
-
function
|
|
2018
|
-
return
|
|
2071
|
+
function In() {
|
|
2072
|
+
return Ne()?.surface === "browser_extension_sdk_preview";
|
|
2019
2073
|
}
|
|
2020
|
-
function
|
|
2074
|
+
function zt() {
|
|
2021
2075
|
if (!document.body)
|
|
2022
2076
|
return "";
|
|
2023
2077
|
const e = [], t = [], s = (d, p) => {
|
|
@@ -2026,16 +2080,16 @@ function $t() {
|
|
|
2026
2080
|
};
|
|
2027
2081
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2028
2082
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2029
|
-
(d) =>
|
|
2083
|
+
(d) => Ue(d) && !d.parentElement?.closest(n)
|
|
2030
2084
|
);
|
|
2031
2085
|
for (const d of r.slice(0, 3))
|
|
2032
|
-
s("Active overlay",
|
|
2033
|
-
const i =
|
|
2034
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2086
|
+
s("Active overlay", _t(z(d), t));
|
|
2087
|
+
const i = Tn(), o = i ? _t(z(i), t) : "";
|
|
2088
|
+
s("Main page content", o), s("Additional visible page text", _t(z(document.body), t));
|
|
2035
2089
|
const a = e.map(([d, p]) => `${d}:
|
|
2036
2090
|
${p}`).join(`
|
|
2037
2091
|
|
|
2038
|
-
`).trim().slice(0, 12e3), c =
|
|
2092
|
+
`).trim().slice(0, 12e3), c = wn(r, i).trim(), l = `Simplified DOM outline:
|
|
2039
2093
|
`, h = `
|
|
2040
2094
|
|
|
2041
2095
|
Visible page text:
|
|
@@ -2053,20 +2107,20 @@ function B(e) {
|
|
|
2053
2107
|
|
|
2054
2108
|
`).trim();
|
|
2055
2109
|
}
|
|
2056
|
-
function
|
|
2110
|
+
function _t(e, t) {
|
|
2057
2111
|
let s = B(e);
|
|
2058
2112
|
for (const n of t)
|
|
2059
2113
|
s = s.replace(n, "");
|
|
2060
2114
|
return B(s);
|
|
2061
2115
|
}
|
|
2062
|
-
function
|
|
2116
|
+
function Ue(e) {
|
|
2063
2117
|
const t = window.getComputedStyle(e);
|
|
2064
2118
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
2065
2119
|
}
|
|
2066
|
-
function
|
|
2067
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2120
|
+
function Tn() {
|
|
2121
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ue).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
|
|
2068
2122
|
}
|
|
2069
|
-
function
|
|
2123
|
+
function wn(e, t) {
|
|
2070
2124
|
const s = /* @__PURE__ */ new Set([
|
|
2071
2125
|
"main",
|
|
2072
2126
|
"nav",
|
|
@@ -2146,7 +2200,7 @@ function mn(e, t) {
|
|
|
2146
2200
|
"data-test",
|
|
2147
2201
|
"data-qa",
|
|
2148
2202
|
"data-cy"
|
|
2149
|
-
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } =
|
|
2203
|
+
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = Sn(), I = new Set(e);
|
|
2150
2204
|
t && I.add(t);
|
|
2151
2205
|
let g = 0;
|
|
2152
2206
|
const u = (T) => {
|
|
@@ -2156,41 +2210,41 @@ function mn(e, t) {
|
|
|
2156
2210
|
const D = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
|
|
2157
2211
|
return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
|
|
2158
2212
|
}, p = (T, D, F) => {
|
|
2159
|
-
const
|
|
2160
|
-
const
|
|
2161
|
-
if (g >= 1e3 && !K || F.has(A) || i.has(
|
|
2213
|
+
const C = (A, dt) => {
|
|
2214
|
+
const R = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
|
|
2215
|
+
if (g >= 1e3 && !K || F.has(A) || i.has(R) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
|
|
2162
2216
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2163
2217
|
g += 1;
|
|
2164
|
-
const
|
|
2218
|
+
const Vt = u(A), G = Oe(A), Ye = a.has(Vt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(R) || R === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
|
|
2165
2219
|
for (const y of pt) {
|
|
2166
2220
|
const w = d(y);
|
|
2167
2221
|
X.set(w, (X.get(w) ?? 0) + 1);
|
|
2168
2222
|
}
|
|
2169
|
-
const ft = /* @__PURE__ */ new Map(),
|
|
2223
|
+
const ft = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Map();
|
|
2170
2224
|
for (const y of pt) {
|
|
2171
|
-
const w = d(y),
|
|
2172
|
-
|
|
2225
|
+
const w = d(y), O = Yt.get(w) ?? 0;
|
|
2226
|
+
Yt.set(w, O + 1), (X.get(w) ?? 0) > 8 && O >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
|
|
2173
2227
|
}
|
|
2174
|
-
const
|
|
2228
|
+
const Zt = /* @__PURE__ */ new Map(), Qt = /* @__PURE__ */ new Set(), gt = [], te = [];
|
|
2175
2229
|
for (const y of pt) {
|
|
2176
|
-
const w = d(y),
|
|
2177
|
-
if (
|
|
2178
|
-
|
|
2230
|
+
const w = d(y), O = X.get(w) ?? 0, ne = Zt.get(w) ?? 0;
|
|
2231
|
+
if (Zt.set(w, ne + 1), O > 8 && ne >= 6 && !h.has(y)) {
|
|
2232
|
+
Qt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Qt.add(w));
|
|
2179
2233
|
continue;
|
|
2180
2234
|
}
|
|
2181
|
-
const
|
|
2182
|
-
|
|
2235
|
+
const re = C(y, dt);
|
|
2236
|
+
te.push(re), gt.push(re.lines);
|
|
2183
2237
|
}
|
|
2184
2238
|
const mt = [];
|
|
2185
2239
|
if (A.shadowRoot)
|
|
2186
2240
|
for (const y of Array.from(A.shadowRoot.children))
|
|
2187
|
-
y instanceof HTMLElement && mt.push(
|
|
2188
|
-
const J = [...
|
|
2241
|
+
y instanceof HTMLElement && mt.push(C(y, dt + 1));
|
|
2242
|
+
const J = [...te, ...mt], yt = G.length > 0 || Ye || J.some((y) => y.hasUsefulContent), ee = B(
|
|
2189
2243
|
[G, ...J.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2190
|
-
).slice(0, 180),
|
|
2244
|
+
).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(R) || se || K) && (yt || K) && (!r.has(R) || yt || se || K), Tt = It ? 1 : 0, H = [];
|
|
2191
2245
|
if (It) {
|
|
2192
|
-
const y = J.some((
|
|
2193
|
-
H.push(
|
|
2246
|
+
const y = J.some((O) => O.containsTextElement), w = n.has(R) && !y ? ee : G;
|
|
2247
|
+
H.push(De(A, c, o, w.slice(0, 180)));
|
|
2194
2248
|
}
|
|
2195
2249
|
for (const y of gt)
|
|
2196
2250
|
H.push(...Q(y, Tt));
|
|
@@ -2198,25 +2252,25 @@ function mn(e, t) {
|
|
|
2198
2252
|
if (wt.length > 0) {
|
|
2199
2253
|
const y = wt.slice(0, 20);
|
|
2200
2254
|
wt.length > y.length && y.push("… shadow DOM omitted");
|
|
2201
|
-
const w =
|
|
2255
|
+
const w = R.includes("tooltip") || R.includes("popper") || R.includes("loader");
|
|
2202
2256
|
if (dt < 2 && !w) {
|
|
2203
|
-
const
|
|
2204
|
-
H.push(...Q([
|
|
2257
|
+
const O = It ? "#shadow-root" : `${R} #shadow-root`;
|
|
2258
|
+
H.push(...Q([O, ...Q(y, 1)], Tt));
|
|
2205
2259
|
} else
|
|
2206
2260
|
H.push(...Q(y, Tt));
|
|
2207
2261
|
}
|
|
2208
2262
|
return {
|
|
2209
2263
|
lines: H,
|
|
2210
2264
|
hasUsefulContent: yt,
|
|
2211
|
-
textPreview:
|
|
2212
|
-
containsTextElement: n.has(
|
|
2265
|
+
textPreview: ee,
|
|
2266
|
+
containsTextElement: n.has(R) || J.some((y) => y.containsTextElement)
|
|
2213
2267
|
};
|
|
2214
2268
|
};
|
|
2215
|
-
return [`--- ${D} ---`, ...
|
|
2269
|
+
return [`--- ${D} ---`, ...C(T, 0).lines].join(`
|
|
2216
2270
|
`);
|
|
2217
|
-
}, m = [],
|
|
2218
|
-
|
|
2219
|
-
${JSON.stringify(
|
|
2271
|
+
}, m = [], b = B(window.getSelection()?.toString() ?? "");
|
|
2272
|
+
b && m.push(`--- selected text ---
|
|
2273
|
+
${JSON.stringify(b)}`), f.length > 0 && m.push(An(f, s, c, o));
|
|
2220
2274
|
for (const T of e.slice(0, 3))
|
|
2221
2275
|
m.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2222
2276
|
if (t && m.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2227,11 +2281,11 @@ ${JSON.stringify(E)}`), f.length > 0 && m.push(In(f, s, c, o));
|
|
|
2227
2281
|
|
|
2228
2282
|
`);
|
|
2229
2283
|
}
|
|
2230
|
-
function
|
|
2284
|
+
function De(e, t, s, n) {
|
|
2231
2285
|
const r = e.tagName.toLowerCase();
|
|
2232
2286
|
let i = r;
|
|
2233
2287
|
const o = e.getAttribute("id");
|
|
2234
|
-
o &&
|
|
2288
|
+
o && bn(o) && (i += `#${o}`);
|
|
2235
2289
|
for (const a of t) {
|
|
2236
2290
|
const c = e.getAttribute(a);
|
|
2237
2291
|
c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
|
|
@@ -2244,7 +2298,7 @@ function Pe(e, t, s, n) {
|
|
|
2244
2298
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2245
2299
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2246
2300
|
}
|
|
2247
|
-
function
|
|
2301
|
+
function Sn() {
|
|
2248
2302
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
|
|
2249
2303
|
if (!a)
|
|
2250
2304
|
return;
|
|
@@ -2265,7 +2319,7 @@ function yn() {
|
|
|
2265
2319
|
n = n.shadowRoot.activeElement;
|
|
2266
2320
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2267
2321
|
const r = window.getSelection();
|
|
2268
|
-
r && !r.isCollapsed && (s(
|
|
2322
|
+
r && !r.isCollapsed && (s(fe(r.anchorNode), "selected text"), s(fe(r.focusNode), "selected text"));
|
|
2269
2323
|
const i = [
|
|
2270
2324
|
["[aria-selected='true']", "selected"],
|
|
2271
2325
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2287,7 +2341,7 @@ function yn() {
|
|
|
2287
2341
|
priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
|
|
2288
2342
|
};
|
|
2289
2343
|
}
|
|
2290
|
-
function
|
|
2344
|
+
function An(e, t, s, n) {
|
|
2291
2345
|
const r = ["--- active/current elements ---"];
|
|
2292
2346
|
for (const i of e) {
|
|
2293
2347
|
const o = [];
|
|
@@ -2298,18 +2352,18 @@ function In(e, t, s, n) {
|
|
|
2298
2352
|
const f = a.getRootNode();
|
|
2299
2353
|
a = a.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
|
|
2300
2354
|
}
|
|
2301
|
-
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) =>
|
|
2355
|
+
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => De(
|
|
2302
2356
|
h,
|
|
2303
2357
|
s,
|
|
2304
2358
|
n,
|
|
2305
|
-
f === c.length - 1 ?
|
|
2359
|
+
f === c.length - 1 ? Oe(h).slice(0, 180) : ""
|
|
2306
2360
|
));
|
|
2307
2361
|
o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
|
|
2308
2362
|
}
|
|
2309
2363
|
return r.join(`
|
|
2310
2364
|
`);
|
|
2311
2365
|
}
|
|
2312
|
-
function
|
|
2366
|
+
function fe(e) {
|
|
2313
2367
|
return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
|
|
2314
2368
|
}
|
|
2315
2369
|
function Q(e, t) {
|
|
@@ -2318,17 +2372,17 @@ function Q(e, t) {
|
|
|
2318
2372
|
const s = " ".repeat(t);
|
|
2319
2373
|
return e.map((n) => `${s}${n}`);
|
|
2320
2374
|
}
|
|
2321
|
-
function
|
|
2375
|
+
function Oe(e) {
|
|
2322
2376
|
return B(
|
|
2323
2377
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2324
2378
|
);
|
|
2325
2379
|
}
|
|
2326
|
-
function
|
|
2380
|
+
function bn(e) {
|
|
2327
2381
|
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);
|
|
2328
2382
|
}
|
|
2329
|
-
function
|
|
2330
|
-
const e = document.querySelector(
|
|
2331
|
-
if (!(e ?? document.querySelector(
|
|
2383
|
+
function Ne() {
|
|
2384
|
+
const e = document.querySelector(ie);
|
|
2385
|
+
if (!(e ?? document.querySelector(Dt)))
|
|
2332
2386
|
return;
|
|
2333
2387
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2334
2388
|
return {
|
|
@@ -2337,28 +2391,28 @@ function De() {
|
|
|
2337
2391
|
selectors: [
|
|
2338
2392
|
{
|
|
2339
2393
|
name: "widget_host",
|
|
2340
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2394
|
+
selector: s === "browser_extension_sdk_preview" ? ie : Dt,
|
|
2341
2395
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2342
2396
|
},
|
|
2343
2397
|
{
|
|
2344
2398
|
name: "widget_root",
|
|
2345
|
-
selector:
|
|
2399
|
+
selector: ws,
|
|
2346
2400
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2347
2401
|
},
|
|
2348
2402
|
{
|
|
2349
2403
|
name: "widget_panel",
|
|
2350
|
-
selector:
|
|
2404
|
+
selector: Ss,
|
|
2351
2405
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2352
2406
|
},
|
|
2353
2407
|
{
|
|
2354
2408
|
name: "widget_timeline",
|
|
2355
|
-
selector:
|
|
2409
|
+
selector: As,
|
|
2356
2410
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2357
2411
|
}
|
|
2358
2412
|
]
|
|
2359
2413
|
};
|
|
2360
2414
|
}
|
|
2361
|
-
function
|
|
2415
|
+
function En(e) {
|
|
2362
2416
|
try {
|
|
2363
2417
|
const t = JSON.parse(e);
|
|
2364
2418
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2366,16 +2420,16 @@ function wn(e) {
|
|
|
2366
2420
|
return { type: "error", message: "Invalid server event" };
|
|
2367
2421
|
}
|
|
2368
2422
|
}
|
|
2369
|
-
function
|
|
2423
|
+
function ge(e, t) {
|
|
2370
2424
|
if (!e || typeof e != "object")
|
|
2371
2425
|
return [];
|
|
2372
2426
|
const s = e[t];
|
|
2373
2427
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2374
2428
|
}
|
|
2375
|
-
function
|
|
2429
|
+
function Rn(e) {
|
|
2376
2430
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2377
2431
|
}
|
|
2378
|
-
function
|
|
2432
|
+
function kn(e) {
|
|
2379
2433
|
if (!e || typeof e != "object")
|
|
2380
2434
|
return null;
|
|
2381
2435
|
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;
|
|
@@ -2386,13 +2440,13 @@ function An(e) {
|
|
|
2386
2440
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2387
2441
|
};
|
|
2388
2442
|
}
|
|
2389
|
-
function
|
|
2443
|
+
function Mn(e) {
|
|
2390
2444
|
if (!e || typeof e != "object")
|
|
2391
2445
|
return null;
|
|
2392
2446
|
const t = e.javascript;
|
|
2393
2447
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2394
2448
|
}
|
|
2395
|
-
function
|
|
2449
|
+
function _n(e, t) {
|
|
2396
2450
|
return t ? e && typeof e == "object" ? {
|
|
2397
2451
|
...e,
|
|
2398
2452
|
helperError: t
|
|
@@ -2402,13 +2456,13 @@ function Rn(e, t) {
|
|
|
2402
2456
|
helperError: t
|
|
2403
2457
|
} : e;
|
|
2404
2458
|
}
|
|
2405
|
-
function
|
|
2459
|
+
function Cn(e) {
|
|
2406
2460
|
if (!e || typeof e != "object")
|
|
2407
2461
|
return e;
|
|
2408
2462
|
const t = e;
|
|
2409
2463
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2410
2464
|
}
|
|
2411
|
-
function
|
|
2465
|
+
function Pn() {
|
|
2412
2466
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2413
2467
|
if (t)
|
|
2414
2468
|
return t;
|
|
@@ -2418,7 +2472,7 @@ function Mn() {
|
|
|
2418
2472
|
function $() {
|
|
2419
2473
|
return crypto.randomUUID();
|
|
2420
2474
|
}
|
|
2421
|
-
function
|
|
2475
|
+
function Un(e) {
|
|
2422
2476
|
if (!e || typeof e != "object")
|
|
2423
2477
|
return null;
|
|
2424
2478
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2429,22 +2483,22 @@ function kn(e) {
|
|
|
2429
2483
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2430
2484
|
} : null;
|
|
2431
2485
|
}
|
|
2432
|
-
function
|
|
2433
|
-
return Array.isArray(e) ?
|
|
2486
|
+
function Dn(e, t) {
|
|
2487
|
+
return Array.isArray(e) ? Bt(
|
|
2434
2488
|
e.map((s) => ve(s, t)).filter((s) => s !== null)
|
|
2435
2489
|
) : [];
|
|
2436
2490
|
}
|
|
2437
|
-
function
|
|
2491
|
+
function On(e) {
|
|
2438
2492
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2439
2493
|
if (!t || typeof t != "object")
|
|
2440
2494
|
return [];
|
|
2441
|
-
const s = t, n =
|
|
2495
|
+
const s = t, n = E(s, "id"), r = E(s, "createdAt"), i = E(s, "updatedAt"), o = E(s, "lastActiveAt");
|
|
2442
2496
|
return !n || !r || !i || !o ? [] : [
|
|
2443
2497
|
{
|
|
2444
2498
|
id: n,
|
|
2445
|
-
title:
|
|
2446
|
-
customTitle:
|
|
2447
|
-
firstUserMessage:
|
|
2499
|
+
title: E(s, "title"),
|
|
2500
|
+
customTitle: E(s, "customTitle"),
|
|
2501
|
+
firstUserMessage: E(s, "firstUserMessage"),
|
|
2448
2502
|
currentPage: s.currentPage ?? null,
|
|
2449
2503
|
createdAt: r,
|
|
2450
2504
|
updatedAt: i,
|
|
@@ -2469,14 +2523,14 @@ function ve(e, t) {
|
|
|
2469
2523
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2470
2524
|
role: i,
|
|
2471
2525
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2472
|
-
content:
|
|
2473
|
-
|
|
2526
|
+
content: os(
|
|
2527
|
+
Fn(r.content),
|
|
2474
2528
|
t
|
|
2475
2529
|
),
|
|
2476
2530
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2477
2531
|
respondsToUserMessageId: N(r) ?? void 0,
|
|
2478
|
-
...
|
|
2479
|
-
attachments:
|
|
2532
|
+
...M(r) ? { runId: M(r) } : {},
|
|
2533
|
+
attachments: He(r.attachments, t)
|
|
2480
2534
|
};
|
|
2481
2535
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2482
2536
|
value: r.id,
|
|
@@ -2487,38 +2541,52 @@ function ve(e, t) {
|
|
|
2487
2541
|
}), o;
|
|
2488
2542
|
}
|
|
2489
2543
|
if (r.type === "function_call_output") {
|
|
2490
|
-
const i =
|
|
2491
|
-
|
|
2544
|
+
const i = Is(r.output);
|
|
2545
|
+
if (i)
|
|
2546
|
+
return {
|
|
2547
|
+
id: String(s.id ?? crypto.randomUUID()),
|
|
2548
|
+
role: "tool",
|
|
2549
|
+
content: "",
|
|
2550
|
+
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2551
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
2552
|
+
...M(r) ? { runId: M(r) } : {},
|
|
2553
|
+
dataType: "scheduled_check_in",
|
|
2554
|
+
toolName: Me,
|
|
2555
|
+
callId: Ct(r) ?? void 0,
|
|
2556
|
+
scheduledCheckInAt: i
|
|
2557
|
+
};
|
|
2558
|
+
const o = vn(r.output);
|
|
2559
|
+
return o ? {
|
|
2492
2560
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2493
2561
|
role: "tool",
|
|
2494
|
-
content: `Connect ${
|
|
2562
|
+
content: `Connect ${o.appName} to continue`,
|
|
2495
2563
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2496
2564
|
respondsToUserMessageId: N(r) ?? void 0,
|
|
2497
|
-
...
|
|
2565
|
+
...M(r) ? { runId: M(r) } : {},
|
|
2498
2566
|
dataType: "function_call_output",
|
|
2499
2567
|
toolName: "authenticate_pipedream_app",
|
|
2500
|
-
callId:
|
|
2501
|
-
integrationAuthRequest:
|
|
2568
|
+
callId: Ct(r) ?? void 0,
|
|
2569
|
+
integrationAuthRequest: o
|
|
2502
2570
|
} : null;
|
|
2503
2571
|
}
|
|
2504
2572
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2505
2573
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2506
2574
|
role: "tool",
|
|
2507
|
-
content: r.type === "mcp_call" ?
|
|
2575
|
+
content: r.type === "mcp_call" ? Nn(r) : Ln(r),
|
|
2508
2576
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2509
2577
|
respondsToUserMessageId: N(r) ?? void 0,
|
|
2510
|
-
...
|
|
2578
|
+
...M(r) ? { runId: M(r) } : {},
|
|
2511
2579
|
dataType: String(r.type),
|
|
2512
2580
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2513
|
-
callId:
|
|
2581
|
+
callId: Ct(r) ?? void 0,
|
|
2514
2582
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
2515
2583
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2516
2584
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2517
2585
|
role: "system",
|
|
2518
|
-
content:
|
|
2586
|
+
content: xn(r),
|
|
2519
2587
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2520
2588
|
respondsToUserMessageId: N(r) ?? void 0,
|
|
2521
|
-
...
|
|
2589
|
+
...M(r) ? { runId: M(r) } : {},
|
|
2522
2590
|
dataType: String(r.type),
|
|
2523
2591
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
2524
2592
|
...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
|
|
@@ -2526,11 +2594,11 @@ function ve(e, t) {
|
|
|
2526
2594
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2527
2595
|
} : null;
|
|
2528
2596
|
}
|
|
2529
|
-
function
|
|
2597
|
+
function Nn(e) {
|
|
2530
2598
|
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(" ");
|
|
2531
2599
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2532
2600
|
}
|
|
2533
|
-
function
|
|
2601
|
+
function vn(e) {
|
|
2534
2602
|
if (typeof e != "string")
|
|
2535
2603
|
return null;
|
|
2536
2604
|
try {
|
|
@@ -2547,10 +2615,10 @@ function Un(e) {
|
|
|
2547
2615
|
return null;
|
|
2548
2616
|
}
|
|
2549
2617
|
}
|
|
2550
|
-
function
|
|
2618
|
+
function xn(e) {
|
|
2551
2619
|
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.";
|
|
2552
2620
|
}
|
|
2553
|
-
function
|
|
2621
|
+
function Ln(e) {
|
|
2554
2622
|
if (e.type === "web_search_call") {
|
|
2555
2623
|
const t = e.action;
|
|
2556
2624
|
if (t && typeof t == "object") {
|
|
@@ -2562,9 +2630,9 @@ function vn(e) {
|
|
|
2562
2630
|
}
|
|
2563
2631
|
return "🔎 Searching the web";
|
|
2564
2632
|
}
|
|
2565
|
-
return
|
|
2633
|
+
return qn(e);
|
|
2566
2634
|
}
|
|
2567
|
-
function
|
|
2635
|
+
function qn(e) {
|
|
2568
2636
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2569
2637
|
return L(e.summary);
|
|
2570
2638
|
if (typeof e.arguments == "string")
|
|
@@ -2581,7 +2649,7 @@ function L(e) {
|
|
|
2581
2649
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2582
2650
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2583
2651
|
}
|
|
2584
|
-
function
|
|
2652
|
+
function Bn(e) {
|
|
2585
2653
|
if (e == null)
|
|
2586
2654
|
return e;
|
|
2587
2655
|
if (typeof e != "object")
|
|
@@ -2596,11 +2664,11 @@ function Nn(e) {
|
|
|
2596
2664
|
runId: typeof t.runId == "string" ? t.runId : null
|
|
2597
2665
|
};
|
|
2598
2666
|
}
|
|
2599
|
-
function
|
|
2667
|
+
function Ct(e) {
|
|
2600
2668
|
const t = e.callId ?? e.call_id;
|
|
2601
2669
|
return typeof t == "string" && t ? t : null;
|
|
2602
2670
|
}
|
|
2603
|
-
function
|
|
2671
|
+
function Fn(e) {
|
|
2604
2672
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2605
2673
|
if (!t || typeof t != "object")
|
|
2606
2674
|
return "";
|
|
@@ -2608,31 +2676,31 @@ function xn(e) {
|
|
|
2608
2676
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2609
2677
|
}).filter(Boolean).join("") : "";
|
|
2610
2678
|
}
|
|
2611
|
-
function
|
|
2612
|
-
const s =
|
|
2613
|
-
|
|
2614
|
-
|
|
2679
|
+
function Nt(e, t) {
|
|
2680
|
+
const s = Le(e, t), n = Gn(
|
|
2681
|
+
Hn(
|
|
2682
|
+
Yn(e, t),
|
|
2615
2683
|
s
|
|
2616
2684
|
),
|
|
2617
2685
|
s
|
|
2618
2686
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2619
2687
|
if (r === -1)
|
|
2620
|
-
return
|
|
2688
|
+
return Bt(
|
|
2621
2689
|
[...n, s]
|
|
2622
2690
|
);
|
|
2623
2691
|
const i = [...n];
|
|
2624
|
-
return i[r] = s,
|
|
2692
|
+
return i[r] = s, Bt(i);
|
|
2625
2693
|
}
|
|
2626
|
-
function
|
|
2694
|
+
function Hn(e, t) {
|
|
2627
2695
|
const s = t.assistantDraftItemId;
|
|
2628
2696
|
return s ? e.map(
|
|
2629
2697
|
(n) => n.dataType === "assistant_draft" && n.id === s ? t : n
|
|
2630
2698
|
) : e;
|
|
2631
2699
|
}
|
|
2632
|
-
function
|
|
2700
|
+
function Wn(e, t, s) {
|
|
2633
2701
|
return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
|
|
2634
2702
|
}
|
|
2635
|
-
function
|
|
2703
|
+
function $n(e, t, s, n) {
|
|
2636
2704
|
if (s === null) return e;
|
|
2637
2705
|
let r = -1;
|
|
2638
2706
|
for (let o = e.length - 1; o >= 0; o -= 1) {
|
|
@@ -2649,12 +2717,12 @@ function Bn(e, t, s, n) {
|
|
|
2649
2717
|
respondsToUserMessageId: s
|
|
2650
2718
|
}, i;
|
|
2651
2719
|
}
|
|
2652
|
-
function
|
|
2720
|
+
function jn(e, t) {
|
|
2653
2721
|
const s = e.findIndex(
|
|
2654
2722
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2655
2723
|
);
|
|
2656
2724
|
if (s === -1)
|
|
2657
|
-
return
|
|
2725
|
+
return Nt(e, t);
|
|
2658
2726
|
const n = [...e];
|
|
2659
2727
|
return n[s] = {
|
|
2660
2728
|
...n[s],
|
|
@@ -2666,12 +2734,12 @@ function Fn(e, t) {
|
|
|
2666
2734
|
...n[s].runId ? {} : { runId: t.runId }
|
|
2667
2735
|
}, n;
|
|
2668
2736
|
}
|
|
2669
|
-
function
|
|
2737
|
+
function zn(e, t, s) {
|
|
2670
2738
|
let n = !1;
|
|
2671
2739
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2672
2740
|
return n ? r : e;
|
|
2673
2741
|
}
|
|
2674
|
-
function
|
|
2742
|
+
function Kn(e) {
|
|
2675
2743
|
if (e.hiddenFromTranscript === !0)
|
|
2676
2744
|
return null;
|
|
2677
2745
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
@@ -2690,7 +2758,7 @@ function Wn(e) {
|
|
|
2690
2758
|
loading: !0
|
|
2691
2759
|
};
|
|
2692
2760
|
}
|
|
2693
|
-
function
|
|
2761
|
+
function Gn(e, t) {
|
|
2694
2762
|
if (t.id.startsWith("transient-activity:"))
|
|
2695
2763
|
return e;
|
|
2696
2764
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2698,16 +2766,16 @@ function $n(e, t) {
|
|
|
2698
2766
|
(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)
|
|
2699
2767
|
);
|
|
2700
2768
|
}
|
|
2701
|
-
function
|
|
2702
|
-
return
|
|
2769
|
+
function Xn(e, t) {
|
|
2770
|
+
return as(
|
|
2703
2771
|
e,
|
|
2704
2772
|
t.map(
|
|
2705
|
-
(s) =>
|
|
2773
|
+
(s) => Le(e, s)
|
|
2706
2774
|
),
|
|
2707
|
-
|
|
2775
|
+
xe
|
|
2708
2776
|
);
|
|
2709
2777
|
}
|
|
2710
|
-
function
|
|
2778
|
+
function xe(e) {
|
|
2711
2779
|
const t = vt(e) ?? void 0, s = e.assistantDraftItemId, n = [
|
|
2712
2780
|
...e.callId ? [`call:${e.callId}`] : [],
|
|
2713
2781
|
...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
|
|
@@ -2719,49 +2787,49 @@ function Oe(e) {
|
|
|
2719
2787
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
2720
2788
|
...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
|
|
2721
2789
|
...e.runId ? { runId: e.runId } : {},
|
|
2722
|
-
isOptimistic:
|
|
2790
|
+
isOptimistic: Kt(e),
|
|
2723
2791
|
isAssistantDraft: e.dataType === "assistant_draft",
|
|
2724
2792
|
isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
|
|
2725
2793
|
isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
|
|
2726
2794
|
};
|
|
2727
2795
|
}
|
|
2728
|
-
function
|
|
2796
|
+
function Le(e, t) {
|
|
2729
2797
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2730
2798
|
return t;
|
|
2731
2799
|
const s = e.find(
|
|
2732
|
-
(r) => r.role === "user" && (r.id === t.id ||
|
|
2800
|
+
(r) => r.role === "user" && (r.id === t.id || Kt(r) && qe(r, t))
|
|
2733
2801
|
);
|
|
2734
2802
|
if (!s?.attachments?.length)
|
|
2735
2803
|
return t;
|
|
2736
2804
|
const n = t.attachments.map((r) => {
|
|
2737
|
-
const i =
|
|
2738
|
-
return i ?
|
|
2805
|
+
const i = Jn(s.attachments ?? [], r);
|
|
2806
|
+
return i ? Vn(r, i) : r;
|
|
2739
2807
|
});
|
|
2740
2808
|
return { ...t, attachments: n };
|
|
2741
2809
|
}
|
|
2742
|
-
function
|
|
2810
|
+
function Jn(e, t) {
|
|
2743
2811
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2744
2812
|
}
|
|
2745
|
-
function
|
|
2813
|
+
function Vn(e, t) {
|
|
2746
2814
|
const { previewUrl: s } = t;
|
|
2747
2815
|
return s ? { ...e, previewUrl: s } : e;
|
|
2748
2816
|
}
|
|
2749
|
-
function
|
|
2817
|
+
function Yn(e, t) {
|
|
2750
2818
|
if (t.role !== "user")
|
|
2751
2819
|
return e;
|
|
2752
2820
|
const s = e.findIndex(
|
|
2753
|
-
(r) =>
|
|
2821
|
+
(r) => Kt(r) && qe(r, t)
|
|
2754
2822
|
);
|
|
2755
2823
|
if (s === -1)
|
|
2756
2824
|
return e;
|
|
2757
2825
|
const n = [...e];
|
|
2758
2826
|
return n.splice(s, 1), n;
|
|
2759
2827
|
}
|
|
2760
|
-
function
|
|
2828
|
+
function qe(e, t) {
|
|
2761
2829
|
const s = vt(e), n = vt(t);
|
|
2762
2830
|
return s && n ? s === n : e.content === t.content;
|
|
2763
2831
|
}
|
|
2764
|
-
function
|
|
2832
|
+
function Kt(e) {
|
|
2765
2833
|
return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
|
|
2766
2834
|
}
|
|
2767
2835
|
function vt(e) {
|
|
@@ -2773,18 +2841,18 @@ function vt(e) {
|
|
|
2773
2841
|
);
|
|
2774
2842
|
return n ? e.id.slice(n.length) : null;
|
|
2775
2843
|
}
|
|
2776
|
-
function
|
|
2777
|
-
const t =
|
|
2844
|
+
function me(e) {
|
|
2845
|
+
const t = Be(e);
|
|
2778
2846
|
if (t === null)
|
|
2779
2847
|
return !1;
|
|
2780
2848
|
const s = e[t].id, n = e.some(
|
|
2781
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
2849
|
+
(r) => r.respondsToUserMessageId === s && xt(r)
|
|
2782
2850
|
);
|
|
2783
2851
|
if (e.some((r) => r.respondsToUserMessageId === s))
|
|
2784
2852
|
return n;
|
|
2785
2853
|
for (let r = e.length - 1; r > t; r -= 1) {
|
|
2786
2854
|
const i = e[r];
|
|
2787
|
-
if (
|
|
2855
|
+
if (v(i))
|
|
2788
2856
|
return !0;
|
|
2789
2857
|
if (i.role === "system") {
|
|
2790
2858
|
if (i.dataType === "run_error")
|
|
@@ -2795,23 +2863,23 @@ function ge(e) {
|
|
|
2795
2863
|
}
|
|
2796
2864
|
return !1;
|
|
2797
2865
|
}
|
|
2798
|
-
function
|
|
2799
|
-
const t =
|
|
2866
|
+
function Zn(e) {
|
|
2867
|
+
const t = Be(e);
|
|
2800
2868
|
if (t === null)
|
|
2801
|
-
return e.some(
|
|
2869
|
+
return e.some(v);
|
|
2802
2870
|
const s = e[t].id;
|
|
2803
2871
|
return e.some((n) => n.respondsToUserMessageId === s) ? e.some(
|
|
2804
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
2805
|
-
) : e.slice(t + 1).some(
|
|
2872
|
+
(n) => n.respondsToUserMessageId === s && v(n)
|
|
2873
|
+
) : e.slice(t + 1).some(v);
|
|
2806
2874
|
}
|
|
2807
|
-
function
|
|
2875
|
+
function Be(e) {
|
|
2808
2876
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2809
2877
|
if (e[t].role === "user")
|
|
2810
2878
|
return t;
|
|
2811
2879
|
return null;
|
|
2812
2880
|
}
|
|
2813
|
-
function
|
|
2814
|
-
return
|
|
2881
|
+
function xt(e) {
|
|
2882
|
+
return v(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2815
2883
|
}
|
|
2816
2884
|
function at(e) {
|
|
2817
2885
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
@@ -2827,7 +2895,7 @@ function at(e) {
|
|
|
2827
2895
|
}
|
|
2828
2896
|
return null;
|
|
2829
2897
|
}
|
|
2830
|
-
function
|
|
2898
|
+
function Qn(e) {
|
|
2831
2899
|
const t = at(e);
|
|
2832
2900
|
if (t === null)
|
|
2833
2901
|
return null;
|
|
@@ -2843,13 +2911,13 @@ function q(e) {
|
|
|
2843
2911
|
const t = e.data;
|
|
2844
2912
|
return t && typeof t == "object" ? t : null;
|
|
2845
2913
|
}
|
|
2846
|
-
function
|
|
2914
|
+
function Lt(e) {
|
|
2847
2915
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2848
2916
|
}
|
|
2849
|
-
function
|
|
2917
|
+
function ye(e) {
|
|
2850
2918
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2851
2919
|
}
|
|
2852
|
-
function
|
|
2920
|
+
function tr(e, t) {
|
|
2853
2921
|
const s = at(t);
|
|
2854
2922
|
if (s === null)
|
|
2855
2923
|
return !1;
|
|
@@ -2858,10 +2926,10 @@ function Vn(e, t) {
|
|
|
2858
2926
|
return !1;
|
|
2859
2927
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2860
2928
|
return i === -1 ? !1 : e.some((o) => o.respondsToUserMessageId === r) ? e.some(
|
|
2861
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
2862
|
-
) : e.slice(i + 1).some(
|
|
2929
|
+
(o) => o.respondsToUserMessageId === r && xt(o)
|
|
2930
|
+
) : e.slice(i + 1).some(xt);
|
|
2863
2931
|
}
|
|
2864
|
-
function
|
|
2932
|
+
function qt(e) {
|
|
2865
2933
|
const t = at(e);
|
|
2866
2934
|
if (t === null)
|
|
2867
2935
|
return null;
|
|
@@ -2874,7 +2942,7 @@ function xt(e) {
|
|
|
2874
2942
|
const r = n.clientMessageId;
|
|
2875
2943
|
return typeof r == "string" ? r : null;
|
|
2876
2944
|
}
|
|
2877
|
-
function
|
|
2945
|
+
function er(e) {
|
|
2878
2946
|
const t = at(e);
|
|
2879
2947
|
if (t === null)
|
|
2880
2948
|
return null;
|
|
@@ -2889,22 +2957,22 @@ function Yn(e) {
|
|
|
2889
2957
|
if (i.type === "message" && i.role === "assistant")
|
|
2890
2958
|
return null;
|
|
2891
2959
|
if (i.type === "run_error")
|
|
2892
|
-
return i.retryable !== !0 ? null :
|
|
2960
|
+
return i.retryable !== !0 ? null : Ie(e, i) ?? qt(e);
|
|
2893
2961
|
if (i.type === "run_status")
|
|
2894
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
2962
|
+
return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ?? qt(e) : null;
|
|
2895
2963
|
}
|
|
2896
2964
|
return null;
|
|
2897
2965
|
}
|
|
2898
|
-
function
|
|
2966
|
+
function Ie(e, t) {
|
|
2899
2967
|
if (typeof t.clientMessageId == "string")
|
|
2900
2968
|
return t.clientMessageId;
|
|
2901
2969
|
const s = N(t);
|
|
2902
2970
|
if (!s)
|
|
2903
2971
|
return null;
|
|
2904
|
-
const n = e.find((i) =>
|
|
2972
|
+
const n = e.find((i) => E(i, "id") === s), r = q(n);
|
|
2905
2973
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2906
2974
|
}
|
|
2907
|
-
function
|
|
2975
|
+
function sr(e, t) {
|
|
2908
2976
|
let s = 0;
|
|
2909
2977
|
for (const n of e) {
|
|
2910
2978
|
if (!n || typeof n != "object")
|
|
@@ -2917,56 +2985,56 @@ function Zn(e, t) {
|
|
|
2917
2985
|
}
|
|
2918
2986
|
return s;
|
|
2919
2987
|
}
|
|
2920
|
-
function
|
|
2921
|
-
if (!t || !
|
|
2988
|
+
function Te(e, t, s, n, r) {
|
|
2989
|
+
if (!t || !nr(e))
|
|
2922
2990
|
return !1;
|
|
2923
2991
|
const i = e;
|
|
2924
|
-
return !(
|
|
2992
|
+
return !(Lt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? N(i) !== n : r !== null && M(i) !== r));
|
|
2925
2993
|
}
|
|
2926
|
-
function
|
|
2994
|
+
function nr(e) {
|
|
2927
2995
|
if (!e || typeof e != "object")
|
|
2928
2996
|
return !1;
|
|
2929
2997
|
const t = e;
|
|
2930
2998
|
return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted" || t.status === "failed");
|
|
2931
2999
|
}
|
|
2932
|
-
function
|
|
3000
|
+
function v(e) {
|
|
2933
3001
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
2934
3002
|
}
|
|
2935
|
-
function
|
|
3003
|
+
function rr(e) {
|
|
2936
3004
|
if (!e || typeof e != "object")
|
|
2937
3005
|
return !1;
|
|
2938
3006
|
const t = e;
|
|
2939
3007
|
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";
|
|
2940
3008
|
}
|
|
2941
|
-
function
|
|
2942
|
-
return e.filter((t, s) => ct(t) ? !
|
|
3009
|
+
function Bt(e) {
|
|
3010
|
+
return e.filter((t, s) => ct(t) ? !hr(e, s) && !ur(e, s) && !dr(e, s) : ir(t) ? t.retryable === !0 && lr(e, s) ? !1 : !cr(e, s) : !0);
|
|
2943
3011
|
}
|
|
2944
|
-
function
|
|
3012
|
+
function ir(e) {
|
|
2945
3013
|
return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
|
|
2946
3014
|
}
|
|
2947
3015
|
function ct(e) {
|
|
2948
3016
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
2949
3017
|
}
|
|
2950
|
-
function
|
|
3018
|
+
function or(e, t) {
|
|
2951
3019
|
const s = [...e].reverse().find(
|
|
2952
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t &&
|
|
3020
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !ar(
|
|
2953
3021
|
e,
|
|
2954
3022
|
n.respondsToUserMessageId
|
|
2955
3023
|
)
|
|
2956
3024
|
)?.respondsToUserMessageId;
|
|
2957
3025
|
return s ? e.map(
|
|
2958
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3026
|
+
(n) => n.respondsToUserMessageId === s && we(n) ? { ...n, steered: !0 } : n
|
|
2959
3027
|
) : e;
|
|
2960
3028
|
}
|
|
2961
|
-
function
|
|
3029
|
+
function we(e) {
|
|
2962
3030
|
return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
|
|
2963
3031
|
}
|
|
2964
|
-
function
|
|
3032
|
+
function ar(e, t) {
|
|
2965
3033
|
return e.some(
|
|
2966
|
-
(s) => s.respondsToUserMessageId === t && (
|
|
3034
|
+
(s) => s.respondsToUserMessageId === t && (v(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
2967
3035
|
);
|
|
2968
3036
|
}
|
|
2969
|
-
function
|
|
3037
|
+
function cr(e, t) {
|
|
2970
3038
|
const s = e[t];
|
|
2971
3039
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2972
3040
|
const r = e[n];
|
|
@@ -2975,7 +3043,7 @@ function rr(e, t) {
|
|
|
2975
3043
|
}
|
|
2976
3044
|
return !1;
|
|
2977
3045
|
}
|
|
2978
|
-
function
|
|
3046
|
+
function lr(e, t) {
|
|
2979
3047
|
const s = e[t];
|
|
2980
3048
|
if (!s.respondsToUserMessageId)
|
|
2981
3049
|
return !1;
|
|
@@ -2988,19 +3056,19 @@ function ir(e, t) {
|
|
|
2988
3056
|
}
|
|
2989
3057
|
return !1;
|
|
2990
3058
|
}
|
|
2991
|
-
function
|
|
3059
|
+
function ur(e, t) {
|
|
2992
3060
|
const s = e[t];
|
|
2993
3061
|
return e.some(
|
|
2994
3062
|
(n, r) => r !== t && n.role === "assistant" && lt(s, n)
|
|
2995
3063
|
);
|
|
2996
3064
|
}
|
|
2997
|
-
function
|
|
3065
|
+
function dr(e, t) {
|
|
2998
3066
|
const s = e[t];
|
|
2999
3067
|
return e.some(
|
|
3000
3068
|
(n, r) => r !== t && n.role === "tool" && lt(s, n)
|
|
3001
3069
|
);
|
|
3002
3070
|
}
|
|
3003
|
-
function
|
|
3071
|
+
function hr(e, t) {
|
|
3004
3072
|
const s = e[t];
|
|
3005
3073
|
for (let n = t + 1; n < e.length; n += 1)
|
|
3006
3074
|
if (ct(e[n]) && lt(s, e[n]))
|
|
@@ -3010,18 +3078,18 @@ function cr(e, t) {
|
|
|
3010
3078
|
function lt(e, t) {
|
|
3011
3079
|
return !!(e.respondsToUserMessageId && e.respondsToUserMessageId === t.respondsToUserMessageId);
|
|
3012
3080
|
}
|
|
3013
|
-
function
|
|
3081
|
+
function E(e, t) {
|
|
3014
3082
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
3015
3083
|
}
|
|
3016
|
-
function
|
|
3084
|
+
function pr(e, t) {
|
|
3017
3085
|
try {
|
|
3018
|
-
const s = window.localStorage.getItem(`${
|
|
3086
|
+
const s = window.localStorage.getItem(`${Ce}${e}`);
|
|
3019
3087
|
if (!s)
|
|
3020
3088
|
return null;
|
|
3021
3089
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3022
3090
|
if (t !== void 0 && r !== t)
|
|
3023
3091
|
return null;
|
|
3024
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3092
|
+
const i = Array.isArray(n.messages) ? n.messages.map(br).filter((o) => !!o) : [];
|
|
3025
3093
|
return {
|
|
3026
3094
|
sessionId: r,
|
|
3027
3095
|
messages: i
|
|
@@ -3030,46 +3098,46 @@ function lr(e, t) {
|
|
|
3030
3098
|
return null;
|
|
3031
3099
|
}
|
|
3032
3100
|
}
|
|
3033
|
-
function
|
|
3101
|
+
function fr(e, t) {
|
|
3034
3102
|
try {
|
|
3035
3103
|
window.localStorage.setItem(
|
|
3036
|
-
`${
|
|
3104
|
+
`${Ce}${e}`,
|
|
3037
3105
|
JSON.stringify({
|
|
3038
3106
|
sessionId: t.sessionId,
|
|
3039
|
-
messages: t.messages.slice(-
|
|
3107
|
+
messages: t.messages.slice(-Fs).map(Er)
|
|
3040
3108
|
})
|
|
3041
3109
|
);
|
|
3042
3110
|
} catch {
|
|
3043
3111
|
return;
|
|
3044
3112
|
}
|
|
3045
3113
|
}
|
|
3046
|
-
function
|
|
3114
|
+
function gr(e) {
|
|
3047
3115
|
try {
|
|
3048
|
-
const t = window.localStorage.getItem(`${
|
|
3116
|
+
const t = window.localStorage.getItem(`${Ot}${e}`);
|
|
3049
3117
|
if (!t)
|
|
3050
3118
|
return [];
|
|
3051
3119
|
const s = JSON.parse(t);
|
|
3052
|
-
return Array.isArray(s) ? s.filter(
|
|
3120
|
+
return Array.isArray(s) ? s.filter(Gt) : [];
|
|
3053
3121
|
} catch {
|
|
3054
3122
|
return [];
|
|
3055
3123
|
}
|
|
3056
3124
|
}
|
|
3057
3125
|
function j(e, t) {
|
|
3058
3126
|
try {
|
|
3059
|
-
const s = t.filter(
|
|
3127
|
+
const s = t.filter(Gt);
|
|
3060
3128
|
if (s.length === 0) {
|
|
3061
|
-
window.localStorage.removeItem(`${
|
|
3129
|
+
window.localStorage.removeItem(`${Ot}${e}`);
|
|
3062
3130
|
return;
|
|
3063
3131
|
}
|
|
3064
3132
|
window.localStorage.setItem(
|
|
3065
|
-
`${
|
|
3133
|
+
`${Ot}${e}`,
|
|
3066
3134
|
JSON.stringify(s.slice(-25))
|
|
3067
3135
|
);
|
|
3068
3136
|
} catch {
|
|
3069
3137
|
return;
|
|
3070
3138
|
}
|
|
3071
3139
|
}
|
|
3072
|
-
function
|
|
3140
|
+
function Fe(e, t) {
|
|
3073
3141
|
try {
|
|
3074
3142
|
const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
3075
3143
|
...o,
|
|
@@ -3085,28 +3153,28 @@ function qe(e, t) {
|
|
|
3085
3153
|
} catch {
|
|
3086
3154
|
}
|
|
3087
3155
|
}
|
|
3088
|
-
function
|
|
3156
|
+
function mr(e, t) {
|
|
3089
3157
|
try {
|
|
3090
3158
|
if (window.sessionStorage.getItem(`${ot}${e}`) === null)
|
|
3091
3159
|
return;
|
|
3092
3160
|
} catch {
|
|
3093
3161
|
return;
|
|
3094
3162
|
}
|
|
3095
|
-
|
|
3163
|
+
Fe(e, t);
|
|
3096
3164
|
}
|
|
3097
|
-
function
|
|
3165
|
+
function yr(e) {
|
|
3098
3166
|
try {
|
|
3099
3167
|
const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
|
|
3100
3168
|
if (window.sessionStorage.removeItem(t), !s)
|
|
3101
3169
|
return [];
|
|
3102
3170
|
const n = JSON.parse(s);
|
|
3103
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3171
|
+
return Array.isArray(n) ? n.flatMap((r) => Tr(r) ? [{
|
|
3104
3172
|
...r.event,
|
|
3105
|
-
page:
|
|
3173
|
+
page: k(),
|
|
3106
3174
|
rawOutput: {
|
|
3107
3175
|
pageContextRestarted: !0,
|
|
3108
3176
|
outcome: "unknown",
|
|
3109
|
-
message:
|
|
3177
|
+
message: Ir(location.href),
|
|
3110
3178
|
currentUrl: location.href,
|
|
3111
3179
|
console: [],
|
|
3112
3180
|
metadata: {
|
|
@@ -3123,17 +3191,17 @@ function pr(e) {
|
|
|
3123
3191
|
return [];
|
|
3124
3192
|
}
|
|
3125
3193
|
}
|
|
3126
|
-
function
|
|
3194
|
+
function Ir(e) {
|
|
3127
3195
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3128
3196
|
Current URL: ${e}`;
|
|
3129
3197
|
}
|
|
3130
|
-
function
|
|
3198
|
+
function Tr(e) {
|
|
3131
3199
|
if (!e || typeof e != "object")
|
|
3132
3200
|
return !1;
|
|
3133
3201
|
const t = e, s = t.event;
|
|
3134
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
3202
|
+
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";
|
|
3135
3203
|
}
|
|
3136
|
-
function
|
|
3204
|
+
function wr(e, t) {
|
|
3137
3205
|
const s = new Set(
|
|
3138
3206
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3139
3207
|
);
|
|
@@ -3142,26 +3210,26 @@ function mr(e, t) {
|
|
|
3142
3210
|
...t.filter((n) => !s.has(n.callId))
|
|
3143
3211
|
];
|
|
3144
3212
|
}
|
|
3145
|
-
function
|
|
3213
|
+
function Sr(e) {
|
|
3146
3214
|
try {
|
|
3147
3215
|
window.sessionStorage.removeItem(`${ot}${e}`);
|
|
3148
3216
|
} catch {
|
|
3149
3217
|
return;
|
|
3150
3218
|
}
|
|
3151
3219
|
}
|
|
3152
|
-
function
|
|
3220
|
+
function Gt(e) {
|
|
3153
3221
|
if (!e || typeof e != "object")
|
|
3154
3222
|
return !1;
|
|
3155
3223
|
const t = e;
|
|
3156
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
3224
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && Se(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Se(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
|
|
3157
3225
|
}
|
|
3158
|
-
function
|
|
3226
|
+
function Se(e) {
|
|
3159
3227
|
if (!e || typeof e != "object")
|
|
3160
3228
|
return !1;
|
|
3161
3229
|
const t = e;
|
|
3162
3230
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
3163
3231
|
}
|
|
3164
|
-
function
|
|
3232
|
+
function He(e, t) {
|
|
3165
3233
|
if (!Array.isArray(e))
|
|
3166
3234
|
return;
|
|
3167
3235
|
const s = e.filter((r) => {
|
|
@@ -3169,23 +3237,23 @@ function Be(e, t) {
|
|
|
3169
3237
|
return !1;
|
|
3170
3238
|
const i = r;
|
|
3171
3239
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3172
|
-
}), n = t ? s.map((r) =>
|
|
3240
|
+
}), n = t ? s.map((r) => We(r, t)) : s;
|
|
3173
3241
|
return n.length > 0 ? n : void 0;
|
|
3174
3242
|
}
|
|
3175
|
-
function
|
|
3243
|
+
function We(e, t) {
|
|
3176
3244
|
return e.fileUrl?.startsWith("/") ? {
|
|
3177
3245
|
...e,
|
|
3178
3246
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
3179
3247
|
} : e;
|
|
3180
3248
|
}
|
|
3181
|
-
function
|
|
3182
|
-
return e.type ||
|
|
3249
|
+
function Ae(e) {
|
|
3250
|
+
return e.type || Ar(e.name) || "application/octet-stream";
|
|
3183
3251
|
}
|
|
3184
|
-
function
|
|
3252
|
+
function Ar(e) {
|
|
3185
3253
|
const t = e.toLowerCase();
|
|
3186
3254
|
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;
|
|
3187
3255
|
}
|
|
3188
|
-
function
|
|
3256
|
+
function br(e) {
|
|
3189
3257
|
if (!e || typeof e != "object")
|
|
3190
3258
|
return null;
|
|
3191
3259
|
const t = e;
|
|
@@ -3197,18 +3265,19 @@ function Tr(e) {
|
|
|
3197
3265
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
3198
3266
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
3199
3267
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
3268
|
+
scheduledCheckInAt: typeof t.scheduledCheckInAt == "string" ? t.scheduledCheckInAt : void 0,
|
|
3200
3269
|
securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
|
|
3201
|
-
attachments:
|
|
3270
|
+
attachments: He(t.attachments)?.map(Xt),
|
|
3202
3271
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
3203
3272
|
};
|
|
3204
3273
|
}
|
|
3205
|
-
function
|
|
3274
|
+
function Er(e) {
|
|
3206
3275
|
return e.attachments?.length ? {
|
|
3207
3276
|
...e,
|
|
3208
|
-
attachments: e.attachments.map(
|
|
3277
|
+
attachments: e.attachments.map(Xt)
|
|
3209
3278
|
} : e;
|
|
3210
3279
|
}
|
|
3211
|
-
function
|
|
3280
|
+
function Xt(e) {
|
|
3212
3281
|
const {
|
|
3213
3282
|
dataUrl: t,
|
|
3214
3283
|
objectUrl: s,
|
|
@@ -3221,43 +3290,43 @@ function N(e) {
|
|
|
3221
3290
|
const t = e.respondsToUserMessageId;
|
|
3222
3291
|
return typeof t == "string" && t ? t : null;
|
|
3223
3292
|
}
|
|
3224
|
-
function
|
|
3293
|
+
function M(e) {
|
|
3225
3294
|
const t = e.runId;
|
|
3226
3295
|
return typeof t == "string" && t ? t : null;
|
|
3227
3296
|
}
|
|
3228
|
-
function
|
|
3297
|
+
function Rr(e) {
|
|
3229
3298
|
const t = e?.timeoutMs;
|
|
3230
|
-
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 <=
|
|
3299
|
+
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 <= Js);
|
|
3231
3300
|
}
|
|
3232
|
-
function
|
|
3301
|
+
function $e(e) {
|
|
3233
3302
|
const t = {};
|
|
3234
3303
|
try {
|
|
3235
3304
|
new Headers(e).forEach((s, n) => {
|
|
3236
|
-
Object.keys(t).length <
|
|
3305
|
+
Object.keys(t).length < jt && (t[n] = Jt(n, s));
|
|
3237
3306
|
});
|
|
3238
3307
|
} catch {
|
|
3239
3308
|
return {};
|
|
3240
3309
|
}
|
|
3241
3310
|
return t;
|
|
3242
3311
|
}
|
|
3243
|
-
function
|
|
3244
|
-
return
|
|
3312
|
+
function Jt(e, t) {
|
|
3313
|
+
return Je(e) ? ut : P(it(t), qs);
|
|
3245
3314
|
}
|
|
3246
|
-
function
|
|
3315
|
+
function kr(e, t) {
|
|
3247
3316
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
3248
3317
|
}
|
|
3249
|
-
async function
|
|
3250
|
-
const r =
|
|
3318
|
+
async function Mr(e, t, s, n) {
|
|
3319
|
+
const r = $e(e.headers);
|
|
3251
3320
|
n({
|
|
3252
3321
|
...t,
|
|
3253
3322
|
responseStatus: e.status,
|
|
3254
3323
|
responseHeaders: r,
|
|
3255
|
-
responseBody: await
|
|
3324
|
+
responseBody: await _r(e),
|
|
3256
3325
|
durationMs: Date.now() - s
|
|
3257
3326
|
});
|
|
3258
3327
|
}
|
|
3259
|
-
async function
|
|
3260
|
-
if (!
|
|
3328
|
+
async function _r(e) {
|
|
3329
|
+
if (!je(e.headers))
|
|
3261
3330
|
return;
|
|
3262
3331
|
let t = null, s = null;
|
|
3263
3332
|
try {
|
|
@@ -3266,7 +3335,7 @@ async function Rr(e) {
|
|
|
3266
3335
|
const n = new Promise((a) => {
|
|
3267
3336
|
s = window.setTimeout(() => {
|
|
3268
3337
|
t?.cancel(), a("timeout");
|
|
3269
|
-
},
|
|
3338
|
+
}, Bs);
|
|
3270
3339
|
}), r = new TextDecoder();
|
|
3271
3340
|
let i = "", o = 0;
|
|
3272
3341
|
for (; ; ) {
|
|
@@ -3276,7 +3345,7 @@ async function Rr(e) {
|
|
|
3276
3345
|
const { done: c, value: l } = a;
|
|
3277
3346
|
if (c)
|
|
3278
3347
|
return P(i + r.decode());
|
|
3279
|
-
const h =
|
|
3348
|
+
const h = $t - o;
|
|
3280
3349
|
if (l.byteLength > h)
|
|
3281
3350
|
return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
|
|
3282
3351
|
o += l.byteLength, i += r.decode(l, { stream: !0 });
|
|
@@ -3288,20 +3357,20 @@ async function Rr(e) {
|
|
|
3288
3357
|
s !== null && window.clearTimeout(s);
|
|
3289
3358
|
}
|
|
3290
3359
|
}
|
|
3291
|
-
function
|
|
3292
|
-
if (
|
|
3360
|
+
function Cr(e, t) {
|
|
3361
|
+
if (je(new Headers(t)))
|
|
3293
3362
|
try {
|
|
3294
3363
|
return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
|
|
3295
3364
|
} catch {
|
|
3296
3365
|
return;
|
|
3297
3366
|
}
|
|
3298
3367
|
}
|
|
3299
|
-
function
|
|
3368
|
+
function be(e) {
|
|
3300
3369
|
if (typeof e == "string")
|
|
3301
3370
|
return P(e);
|
|
3302
3371
|
}
|
|
3303
|
-
function
|
|
3304
|
-
return
|
|
3372
|
+
function Pr(e) {
|
|
3373
|
+
return _({
|
|
3305
3374
|
...e,
|
|
3306
3375
|
requestBody: Ee(e.requestBody),
|
|
3307
3376
|
responseBody: Ee(e.responseBody)
|
|
@@ -3314,19 +3383,19 @@ function Ee(e) {
|
|
|
3314
3383
|
if (!t.startsWith("{") && !t.startsWith("["))
|
|
3315
3384
|
return it(e);
|
|
3316
3385
|
try {
|
|
3317
|
-
return JSON.stringify(
|
|
3386
|
+
return JSON.stringify(_(JSON.parse(e)));
|
|
3318
3387
|
} catch {
|
|
3319
3388
|
return it(e);
|
|
3320
3389
|
}
|
|
3321
3390
|
}
|
|
3322
|
-
function
|
|
3391
|
+
function je(e) {
|
|
3323
3392
|
if (!e)
|
|
3324
3393
|
return !1;
|
|
3325
3394
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3326
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3395
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= $t && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3327
3396
|
}
|
|
3328
3397
|
function x(e, t = {}, s) {
|
|
3329
|
-
if (
|
|
3398
|
+
if (Dr(s))
|
|
3330
3399
|
return !0;
|
|
3331
3400
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3332
3401
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3341,7 +3410,7 @@ function x(e, t = {}, s) {
|
|
|
3341
3410
|
return !0;
|
|
3342
3411
|
}
|
|
3343
3412
|
}
|
|
3344
|
-
function
|
|
3413
|
+
function Ur(e, t) {
|
|
3345
3414
|
if (x(e))
|
|
3346
3415
|
return !0;
|
|
3347
3416
|
try {
|
|
@@ -3351,26 +3420,26 @@ function kr(e, t) {
|
|
|
3351
3420
|
return !0;
|
|
3352
3421
|
}
|
|
3353
3422
|
}
|
|
3354
|
-
function
|
|
3423
|
+
function Dr(e) {
|
|
3355
3424
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3356
3425
|
}
|
|
3357
|
-
function
|
|
3426
|
+
function Or(e) {
|
|
3358
3427
|
const t = {};
|
|
3359
3428
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3360
3429
|
const n = s.indexOf(":");
|
|
3361
3430
|
if (n <= 0)
|
|
3362
3431
|
continue;
|
|
3363
|
-
if (Object.keys(t).length >=
|
|
3432
|
+
if (Object.keys(t).length >= jt)
|
|
3364
3433
|
break;
|
|
3365
3434
|
const r = s.slice(0, n).trim();
|
|
3366
|
-
t[r] =
|
|
3435
|
+
t[r] = Jt(r, s.slice(n + 1).trim());
|
|
3367
3436
|
}
|
|
3368
3437
|
return t;
|
|
3369
3438
|
}
|
|
3370
|
-
function P(e, t =
|
|
3439
|
+
function P(e, t = $t) {
|
|
3371
3440
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
3372
3441
|
}
|
|
3373
|
-
function
|
|
3442
|
+
function Pt(e) {
|
|
3374
3443
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3375
3444
|
}
|
|
3376
3445
|
class nt extends Error {
|
|
@@ -3381,32 +3450,32 @@ class nt extends Error {
|
|
|
3381
3450
|
}
|
|
3382
3451
|
async function tt(e, t) {
|
|
3383
3452
|
let s = null;
|
|
3384
|
-
for (let n = 0; n <
|
|
3453
|
+
for (let n = 0; n < de; n += 1)
|
|
3385
3454
|
try {
|
|
3386
3455
|
return await e();
|
|
3387
3456
|
} catch (r) {
|
|
3388
|
-
if (s = r, n >=
|
|
3457
|
+
if (s = r, n >= de - 1 || !vr(r))
|
|
3389
3458
|
throw r;
|
|
3390
|
-
await
|
|
3459
|
+
await Nr(n);
|
|
3391
3460
|
}
|
|
3392
3461
|
throw s instanceof Error ? s : new Error(t);
|
|
3393
3462
|
}
|
|
3394
|
-
function
|
|
3463
|
+
function Nr(e) {
|
|
3395
3464
|
return new Promise((t) => {
|
|
3396
|
-
window.setTimeout(t,
|
|
3465
|
+
window.setTimeout(t, Ls[e] ?? 0);
|
|
3397
3466
|
});
|
|
3398
3467
|
}
|
|
3399
|
-
function
|
|
3400
|
-
return e instanceof nt ?
|
|
3468
|
+
function vr(e) {
|
|
3469
|
+
return e instanceof nt ? xr(e.status) : e instanceof TypeError;
|
|
3401
3470
|
}
|
|
3402
|
-
function
|
|
3471
|
+
function xr(e) {
|
|
3403
3472
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3404
3473
|
}
|
|
3405
|
-
function
|
|
3474
|
+
function Lr(e) {
|
|
3406
3475
|
return e === 401 || e === 403;
|
|
3407
3476
|
}
|
|
3408
|
-
const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]",
|
|
3409
|
-
function
|
|
3477
|
+
const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", qr = "[REDACTED_SIGNED_URL]", Br = 20, Fr = /^(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, Hr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Wr = /\bhttps?:\/\/[^\s"'<>]+/gi, $r = /[),.;\]]+$/;
|
|
3478
|
+
function _(e) {
|
|
3410
3479
|
return rt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3411
3480
|
}
|
|
3412
3481
|
function rt(e, t, s) {
|
|
@@ -3414,7 +3483,7 @@ function rt(e, t, s) {
|
|
|
3414
3483
|
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
|
|
3415
3484
|
if (e === null || typeof e != "object")
|
|
3416
3485
|
return e;
|
|
3417
|
-
if (t >=
|
|
3486
|
+
if (t >= Br)
|
|
3418
3487
|
return "[REDACTED_MAX_DEPTH]";
|
|
3419
3488
|
if (s.has(e))
|
|
3420
3489
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -3422,44 +3491,44 @@ function rt(e, t, s) {
|
|
|
3422
3491
|
return e.map((r) => rt(r, t + 1, s));
|
|
3423
3492
|
const n = {};
|
|
3424
3493
|
for (const [r, i] of Object.entries(e))
|
|
3425
|
-
r === "pageContent" ? n[r] = i :
|
|
3494
|
+
r === "pageContent" ? n[r] = i : Je(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? jr(i) : rt(i, t + 1, s);
|
|
3426
3495
|
return n;
|
|
3427
3496
|
}
|
|
3428
|
-
function
|
|
3497
|
+
function Je(e) {
|
|
3429
3498
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3430
3499
|
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");
|
|
3431
3500
|
}
|
|
3432
|
-
function
|
|
3433
|
-
return typeof e == "string" ?
|
|
3501
|
+
function jr(e) {
|
|
3502
|
+
return typeof e == "string" ? Ve(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3434
3503
|
}
|
|
3435
|
-
function
|
|
3504
|
+
function Ve(e) {
|
|
3436
3505
|
try {
|
|
3437
3506
|
const t = new URL(e, location.href);
|
|
3438
3507
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3439
|
-
|
|
3508
|
+
Fr.test(s) && t.searchParams.set(s, U);
|
|
3440
3509
|
return t.username && (t.username = U), t.password && (t.password = U), t.toString();
|
|
3441
3510
|
} catch {
|
|
3442
|
-
return
|
|
3511
|
+
return zr(e);
|
|
3443
3512
|
}
|
|
3444
3513
|
}
|
|
3445
3514
|
function it(e) {
|
|
3446
|
-
return e.replace(
|
|
3515
|
+
return e.replace(Hr, qr).replace(Wr, Kr).replace(ze, `Bearer ${U}`).replace(Ke, `Basic ${U}`).replace(Ge, U).replace(Xe, (t, s) => `${s}: ${ut}`);
|
|
3447
3516
|
}
|
|
3448
|
-
function
|
|
3449
|
-
return e.replace(
|
|
3517
|
+
function zr(e) {
|
|
3518
|
+
return e.replace(ze, `Bearer ${U}`).replace(Ke, `Basic ${U}`).replace(Ge, U).replace(Xe, (t, s) => `${s}: ${ut}`);
|
|
3450
3519
|
}
|
|
3451
|
-
function
|
|
3452
|
-
const t = e.match(
|
|
3453
|
-
return `${
|
|
3520
|
+
function Kr(e) {
|
|
3521
|
+
const t = e.match($r)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3522
|
+
return `${Ve(s)}${t}`;
|
|
3454
3523
|
}
|
|
3455
3524
|
export {
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3525
|
+
ie as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3526
|
+
Dt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3527
|
+
Ss as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3528
|
+
ws as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3529
|
+
As as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3530
|
+
Pe as PlunoProductAgent,
|
|
3531
|
+
Ws as calculateReconnectDelay,
|
|
3532
|
+
Pe as default,
|
|
3533
|
+
pn as getProductAgentOriginAccessErrorMessage
|
|
3465
3534
|
};
|