@pluno/product-agent-web 0.1.157 → 0.1.159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/product-agent-sdk.js +636 -626
- package/dist/product-agent-widget.js +2799 -2596
- package/dist/widget.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const e = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
1
|
+
const as = "pluno-product-agent-attachments";
|
|
2
|
+
const xe = "files";
|
|
3
|
+
async function ls(t) {
|
|
4
|
+
const e = await Ke();
|
|
5
|
+
await ds(e, "readwrite", (s) => s.put(t));
|
|
6
|
+
}
|
|
7
|
+
async function cs(t, e) {
|
|
8
|
+
const s = await Ke();
|
|
9
|
+
await Ge(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await Xe(
|
|
11
11
|
n.get(t)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,28 +16,28 @@ async function ls(t, e) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const e = await
|
|
21
|
-
await
|
|
19
|
+
async function us(t = 864e5) {
|
|
20
|
+
const e = await Ke(), s = Date.now() - t;
|
|
21
|
+
await Ge(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await Xe(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Ke() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
|
|
28
|
-
const s = indexedDB.open(
|
|
28
|
+
const s = indexedDB.open(as, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(xe, { keyPath: "attachmentId" });
|
|
31
31
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
32
32
|
}, s.onsuccess = () => t(s.result), s.onerror = () => e(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
return await
|
|
35
|
+
async function ds(t, e, s) {
|
|
36
|
+
return await Ge(t, e, async (n) => await Xe(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Ge(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(xe, e), o = i.objectStore(xe);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
s(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -57,16 +57,16 @@ function Ke(t, e, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Xe(t) {
|
|
61
61
|
return new Promise((e, s) => {
|
|
62
62
|
t.onsuccess = () => e(t.result), t.onerror = () => s(t.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function hs(t) {
|
|
66
66
|
return t !== null && (typeof t == "object" || typeof t == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const n = Reflect.get(t, "pluno"), r =
|
|
68
|
+
function Ut(t, e, s) {
|
|
69
|
+
const n = Reflect.get(t, "pluno"), r = hs(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(t, "pluno", r))
|
|
71
71
|
return null;
|
|
72
72
|
const i = Object.getOwnPropertyDescriptor(r, e);
|
|
@@ -80,14 +80,14 @@ function _t(t, e, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const ps = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function gs(t, e) {
|
|
85
85
|
return e ? t.replace(
|
|
86
|
-
|
|
86
|
+
ps,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
|
|
88
88
|
) : t;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function fs(t, e, s) {
|
|
91
91
|
const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
92
92
|
n.flatMap(
|
|
93
93
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
@@ -125,17 +125,17 @@ function gs(t, e, s) {
|
|
|
125
125
|
w.has(u) || y.push(u);
|
|
126
126
|
return y;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function ms(t, e, s, n) {
|
|
129
129
|
return t.filter((r) => {
|
|
130
130
|
const i = n(r);
|
|
131
131
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
let
|
|
136
|
-
const
|
|
137
|
-
async function
|
|
138
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
134
|
+
const be = "pluno.productAgent.transportId", ys = "pluno.productAgent.transportIdentity", Ce = "pluno.productAgent.transportIdentity.event", Is = 50, Ts = globalThis.setTimeout.bind(globalThis);
|
|
135
|
+
let z = null;
|
|
136
|
+
const le = /* @__PURE__ */ new Set(), ke = /* @__PURE__ */ new Map();
|
|
137
|
+
async function ws(t = Pt()) {
|
|
138
|
+
const e = t.randomUUID(), s = t.storage.getItem(be);
|
|
139
139
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
140
140
|
const o = t.channel.subscribe((l) => {
|
|
141
141
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -153,14 +153,14 @@ async function Ts(t = Ut()) {
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
if (!s)
|
|
156
|
-
t.storage.setItem(
|
|
156
|
+
t.storage.setItem(be, n), r = !0;
|
|
157
157
|
else
|
|
158
158
|
for (; ; ) {
|
|
159
159
|
if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
|
|
160
160
|
r = !0;
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
163
|
+
n = t.randomUUID(), t.storage.setItem(be, n);
|
|
164
164
|
}
|
|
165
165
|
let a = !1;
|
|
166
166
|
return {
|
|
@@ -170,49 +170,49 @@ async function Ts(t = Ut()) {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
174
|
-
|
|
173
|
+
async function Ss() {
|
|
174
|
+
z || (z = ws(Pt()), z.then((n) => {
|
|
175
175
|
const r = (i) => {
|
|
176
|
-
i.persisted || (n.release(),
|
|
176
|
+
i.persisted || (n.release(), z = null, le.clear(), window.removeEventListener("pagehide", r));
|
|
177
177
|
};
|
|
178
178
|
window.addEventListener("pagehide", r);
|
|
179
179
|
}));
|
|
180
|
-
const t = await
|
|
181
|
-
|
|
180
|
+
const t = await z, e = Ms();
|
|
181
|
+
le.add(e);
|
|
182
182
|
let s = !1;
|
|
183
183
|
return {
|
|
184
184
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
185
185
|
transportId: e === 0 ? t.transportId : `${t.transportId}.${e}`,
|
|
186
186
|
release: () => {
|
|
187
|
-
s || (s = !0,
|
|
187
|
+
s || (s = !0, le.delete(e));
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function Ms() {
|
|
192
192
|
let t = 0;
|
|
193
|
-
for (;
|
|
193
|
+
for (; le.has(t); )
|
|
194
194
|
t += 1;
|
|
195
195
|
return t;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function Pt() {
|
|
198
198
|
return {
|
|
199
|
-
storage:
|
|
200
|
-
channel:
|
|
199
|
+
storage: As(),
|
|
200
|
+
channel: Rs(),
|
|
201
201
|
randomUUID: () => crypto.randomUUID(),
|
|
202
|
-
settle: () => new Promise((t) =>
|
|
202
|
+
settle: () => new Promise((t) => Ts(t, Is))
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function As() {
|
|
206
206
|
return {
|
|
207
207
|
getItem: (t) => {
|
|
208
208
|
try {
|
|
209
|
-
return window.sessionStorage?.getItem(t) ??
|
|
209
|
+
return window.sessionStorage?.getItem(t) ?? ke.get(t) ?? null;
|
|
210
210
|
} catch {
|
|
211
|
-
return
|
|
211
|
+
return ke.get(t) ?? null;
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
setItem: (t, e) => {
|
|
215
|
-
|
|
215
|
+
ke.set(t, e);
|
|
216
216
|
try {
|
|
217
217
|
window.sessionStorage?.setItem(t, e);
|
|
218
218
|
} catch {
|
|
@@ -220,9 +220,9 @@ function Ms() {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function Rs() {
|
|
224
224
|
if (typeof BroadcastChannel < "u") {
|
|
225
|
-
const t = new BroadcastChannel(
|
|
225
|
+
const t = new BroadcastChannel(ys);
|
|
226
226
|
return {
|
|
227
227
|
postMessage: (e) => t.postMessage(e),
|
|
228
228
|
subscribe: (e) => {
|
|
@@ -232,11 +232,11 @@ function As() {
|
|
|
232
232
|
close: () => t.close()
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
-
return
|
|
235
|
+
return Es();
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function Es() {
|
|
238
238
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
239
|
-
if (s.key !==
|
|
239
|
+
if (s.key !== Ce || !s.newValue)
|
|
240
240
|
return;
|
|
241
241
|
const n = JSON.parse(s.newValue);
|
|
242
242
|
for (const r of t)
|
|
@@ -245,9 +245,9 @@ function Rs() {
|
|
|
245
245
|
return window.addEventListener("storage", e), {
|
|
246
246
|
postMessage: (s) => {
|
|
247
247
|
window.localStorage.setItem(
|
|
248
|
-
|
|
248
|
+
Ce,
|
|
249
249
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
250
|
-
), window.localStorage.removeItem(
|
|
250
|
+
), window.localStorage.removeItem(Ce);
|
|
251
251
|
},
|
|
252
252
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
253
253
|
close: () => {
|
|
@@ -255,8 +255,8 @@ function Rs() {
|
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
-
const
|
|
259
|
-
function
|
|
258
|
+
const Dt = "schedule_follow_up";
|
|
259
|
+
function bs(t) {
|
|
260
260
|
let e = t;
|
|
261
261
|
if (typeof e == "string")
|
|
262
262
|
try {
|
|
@@ -267,11 +267,11 @@ function Es(t) {
|
|
|
267
267
|
if (!e || typeof e != "object")
|
|
268
268
|
return null;
|
|
269
269
|
const s = e;
|
|
270
|
-
return s.ok !== !0 || s.toolName !==
|
|
270
|
+
return s.ok !== !0 || s.toolName !== Dt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
let
|
|
274
|
-
function
|
|
272
|
+
const Cs = globalThis.fetch.bind(globalThis), Le = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ks = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', _s = ".pluno-pa-widget__panel", Us = ".pluno-pa-widget__timeline", ut = `${Le}[data-pluno-sdk-preview-channel]`;
|
|
273
|
+
let Ps = 0;
|
|
274
|
+
function dt(t) {
|
|
275
275
|
const e = {};
|
|
276
276
|
for (const o of [
|
|
277
277
|
"type",
|
|
@@ -308,7 +308,7 @@ function ut(t) {
|
|
|
308
308
|
}
|
|
309
309
|
return e;
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function _e(t, e, s) {
|
|
312
312
|
if (typeof window > "u")
|
|
313
313
|
return;
|
|
314
314
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -320,31 +320,31 @@ function ke(t, e, s) {
|
|
|
320
320
|
source: "web_sdk",
|
|
321
321
|
category: t,
|
|
322
322
|
name: e,
|
|
323
|
-
sequence: ++
|
|
323
|
+
sequence: ++Ps,
|
|
324
324
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
325
325
|
monotonicMs: performance.now(),
|
|
326
326
|
data: s
|
|
327
327
|
};
|
|
328
328
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const Ds = "https://app.pluno.ai", vs = "gpt-5.6-terra", Ns = 2e4, Os = 1e4, xs = 1e4, Ls = 1e4, qs = 1e4, Bs = 1e3, ht = 3e4, pt = 0.2, gt = 6e4, Hs = 15e3, K = 8, Ws = "Pluno could not finish this message. Try it again.", js = "Browser connection was interrupted.", ft = 15e3, Fs = "Pluno could not send this message. Try it again.", mt = 2e3, $s = 1e3, zs = 100, yt = 8e3, It = 3, Ks = [300, 1e3], vt = 50 * 1024 * 1024, Gs = /* @__PURE__ */ new Set([
|
|
331
331
|
".jpeg:image/jpeg",
|
|
332
332
|
".jpg:image/jpeg",
|
|
333
333
|
".pdf:application/pdf",
|
|
334
334
|
".png:image/png",
|
|
335
335
|
".webp:image/webp"
|
|
336
|
-
]),
|
|
337
|
-
function
|
|
336
|
+
]), oi = ".pdf,.png,.jpg,.jpeg,.webp", Je = 64e3, Ue = 4e3, Ve = 30, Xs = 2e3, Js = 1e3, Nt = "Image is too large for model vision input.", Vs = 100, Ot = "pluno.productAgent.state.", qe = "pluno.productAgent.pendingEvents.", pe = "pluno.productAgent.activeToolCalls.", Ys = 100;
|
|
337
|
+
function G(t, e = 0) {
|
|
338
338
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
339
339
|
return Math.max(e, s);
|
|
340
340
|
}
|
|
341
|
-
const
|
|
342
|
-
let
|
|
343
|
-
function
|
|
344
|
-
const s = Math.min(
|
|
345
|
-
return Math.min(
|
|
341
|
+
const ce = /* @__PURE__ */ new Set();
|
|
342
|
+
let ne = null;
|
|
343
|
+
function Qs(t, e = Math.random) {
|
|
344
|
+
const s = Math.min(ht, Bs * 2 ** t), n = 1 - pt + e() * pt * 2;
|
|
345
|
+
return Math.min(ht, Math.round(s * n));
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function Zs(t, e, s) {
|
|
348
348
|
return new Promise((n, r) => {
|
|
349
349
|
const i = setTimeout(() => r(new Error(s)), e);
|
|
350
350
|
t.then(
|
|
@@ -357,13 +357,13 @@ function Qs(t, e, s) {
|
|
|
357
357
|
);
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
|
-
class
|
|
360
|
+
class xt {
|
|
361
361
|
constructor(e, s) {
|
|
362
362
|
this.options = e, this.transportIdentity = s, this.state = {
|
|
363
363
|
...this.state,
|
|
364
|
-
starterPrompts:
|
|
364
|
+
starterPrompts: Nn(e.initialStarterPrompts)
|
|
365
365
|
};
|
|
366
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
366
|
+
const n = e.restorePersistedState === !1 ? null : Rr(e.clientId, e.expectedPersistedSessionId);
|
|
367
367
|
n && (this.state = {
|
|
368
368
|
...this.state,
|
|
369
369
|
...n,
|
|
@@ -378,14 +378,14 @@ class Nt {
|
|
|
378
378
|
isThinking: !1,
|
|
379
379
|
isRetrying: !1,
|
|
380
380
|
lastError: null
|
|
381
|
-
}), this.queuedClientEvents =
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
}), this.queuedClientEvents = Pr(
|
|
382
|
+
br(e.clientId),
|
|
383
|
+
kr(e.clientId)
|
|
384
384
|
);
|
|
385
385
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
386
386
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
387
387
|
);
|
|
388
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting"),
|
|
388
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting"), L(e.clientId, this.queuedClientEvents);
|
|
389
389
|
}
|
|
390
390
|
options;
|
|
391
391
|
listeners = {};
|
|
@@ -468,15 +468,15 @@ class Nt {
|
|
|
468
468
|
lastErrorSecuritySettingsUrl: null
|
|
469
469
|
};
|
|
470
470
|
static async init(e) {
|
|
471
|
-
const s = await
|
|
471
|
+
const s = await Ss(), n = new xt({
|
|
472
472
|
...e,
|
|
473
|
-
backendUrl:
|
|
473
|
+
backendUrl: Tn(e.backendUrl ?? Ds),
|
|
474
474
|
clientId: e.clientId ?? Bn(),
|
|
475
|
-
model: e.model ??
|
|
476
|
-
entrySurface:
|
|
475
|
+
model: e.model ?? vs,
|
|
476
|
+
entrySurface: wn(e.entrySurface)
|
|
477
477
|
}, s);
|
|
478
478
|
try {
|
|
479
|
-
|
|
479
|
+
us().catch((r) => {
|
|
480
480
|
M("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
481
481
|
message: r instanceof Error ? r.message : String(r)
|
|
482
482
|
});
|
|
@@ -507,14 +507,14 @@ class Nt {
|
|
|
507
507
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
508
508
|
);
|
|
509
509
|
try {
|
|
510
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
510
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await Zs(this.options.tokenProvider(), xs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
511
511
|
return;
|
|
512
512
|
if (!this.token && !this.options.webSocketFactory)
|
|
513
513
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
514
|
-
const s =
|
|
514
|
+
const s = An(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
515
515
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
516
516
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (M("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
517
|
-
},
|
|
517
|
+
}, Ls), n.addEventListener("open", () => {
|
|
518
518
|
this.socket !== n || (this.clearSocketConnectTimer(), M("web-sdk.agent", "Pluno socket opened", {
|
|
519
519
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
520
520
|
isThinking: this.state.isThinking
|
|
@@ -526,16 +526,16 @@ class Nt {
|
|
|
526
526
|
pageUrl: location.href
|
|
527
527
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
528
528
|
this.socket === n && (M("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
529
|
-
},
|
|
529
|
+
}, qs));
|
|
530
530
|
}), n.addEventListener("message", (r) => {
|
|
531
|
-
this.socket === n && this.handleServerEvent(
|
|
531
|
+
this.socket === n && this.handleServerEvent(Dn(r.data));
|
|
532
532
|
}), n.addEventListener("sendfailure", (r) => {
|
|
533
533
|
if (this.socket !== n)
|
|
534
534
|
return;
|
|
535
|
-
const i =
|
|
535
|
+
const i = vn(r?.detail?.data);
|
|
536
536
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
537
537
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
538
|
-
) && (this.queuedClientEvents.push(i),
|
|
538
|
+
) && (this.queuedClientEvents.push(i), L(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
|
|
539
539
|
}), n.addEventListener("close", (r) => {
|
|
540
540
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), M("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
541
541
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -568,7 +568,7 @@ class Nt {
|
|
|
568
568
|
this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.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;
|
|
569
569
|
}
|
|
570
570
|
destroy() {
|
|
571
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
571
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Dr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
572
572
|
for (const e of Object.values(this.listeners))
|
|
573
573
|
e?.clear();
|
|
574
574
|
}
|
|
@@ -584,17 +584,17 @@ class Nt {
|
|
|
584
584
|
}
|
|
585
585
|
async sendMessage(e, s = {}) {
|
|
586
586
|
const n = e.trim(), r = s.attachments ?? [];
|
|
587
|
-
if (!this.options.persistAttachmentUpload && (r.forEach(
|
|
587
|
+
if (!this.options.persistAttachmentUpload && (r.forEach(Vt), r.reduce(
|
|
588
588
|
(T, f) => T + f.sizeBytes,
|
|
589
589
|
0
|
|
590
|
-
) >
|
|
590
|
+
) > vt))
|
|
591
591
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
592
|
-
let i = r.map(
|
|
592
|
+
let i = r.map(Ze);
|
|
593
593
|
if (!n && i.length === 0)
|
|
594
594
|
return null;
|
|
595
595
|
if (this.pendingClientMessageId)
|
|
596
596
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
597
|
-
const o = C(), a = s.clientMessageId ??
|
|
597
|
+
const o = C(), a = s.clientMessageId ?? X(), l = {
|
|
598
598
|
id: `local-${a}`,
|
|
599
599
|
role: "user",
|
|
600
600
|
content: n,
|
|
@@ -648,14 +648,14 @@ class Nt {
|
|
|
648
648
|
sessionId: this.state.sessionId ?? void 0,
|
|
649
649
|
clientMessageId: a,
|
|
650
650
|
initiatedBy: s.initiatedBy,
|
|
651
|
-
invocation:
|
|
651
|
+
invocation: Sn(s.invocation ?? s.initiatedBy),
|
|
652
652
|
entrySurface: this.options.entrySurface,
|
|
653
653
|
content: n,
|
|
654
|
-
pageContent: d &&
|
|
654
|
+
pageContent: d && Ye() || void 0,
|
|
655
655
|
attachments: i.length > 0 ? i : void 0,
|
|
656
656
|
page: o,
|
|
657
657
|
model: this.options.model,
|
|
658
|
-
metadata:
|
|
658
|
+
metadata: Tt(this.options.metadata)
|
|
659
659
|
};
|
|
660
660
|
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = g, this.browserConnectionInterruptedClientMessageIds.delete(a), this.send(g), this.schedulePendingDeliveryAck(a), a;
|
|
661
661
|
}
|
|
@@ -675,16 +675,16 @@ class Nt {
|
|
|
675
675
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(s), this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
|
|
676
676
|
}
|
|
677
677
|
createLocalAttachment(e) {
|
|
678
|
-
this.options.persistAttachmentUpload ||
|
|
679
|
-
const s =
|
|
678
|
+
this.options.persistAttachmentUpload || vr(e);
|
|
679
|
+
const s = X(), n = {
|
|
680
680
|
id: s,
|
|
681
681
|
name: e.name || "attachment",
|
|
682
|
-
mimeType:
|
|
682
|
+
mimeType: ze(e),
|
|
683
683
|
sizeBytes: e.size
|
|
684
684
|
};
|
|
685
685
|
this.attachmentFiles.set(s, e);
|
|
686
686
|
const r = Date.now();
|
|
687
|
-
return
|
|
687
|
+
return ls({
|
|
688
688
|
attachmentId: s,
|
|
689
689
|
name: n.name,
|
|
690
690
|
mimeType: n.mimeType,
|
|
@@ -713,7 +713,7 @@ class Nt {
|
|
|
713
713
|
file: e,
|
|
714
714
|
attachment: s
|
|
715
715
|
}) {
|
|
716
|
-
const n = this.state.sessionId, r =
|
|
716
|
+
const n = this.state.sessionId, r = ze(e), i = {
|
|
717
717
|
sessionId: n ?? void 0,
|
|
718
718
|
attachmentId: s.id,
|
|
719
719
|
clientId: this.options.clientId,
|
|
@@ -723,34 +723,34 @@ class Nt {
|
|
|
723
723
|
sizeBytes: e.size,
|
|
724
724
|
page: C(),
|
|
725
725
|
model: this.options.model,
|
|
726
|
-
metadata:
|
|
726
|
+
metadata: Tt(this.options.metadata),
|
|
727
727
|
entrySurface: this.options.entrySurface
|
|
728
728
|
};
|
|
729
729
|
let o;
|
|
730
730
|
if (this.options.persistAttachmentUpload)
|
|
731
|
-
o = await
|
|
731
|
+
o = await ae(
|
|
732
732
|
() => this.options.persistAttachmentUpload(i, e),
|
|
733
733
|
"Failed to upload attachment"
|
|
734
734
|
);
|
|
735
735
|
else {
|
|
736
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
736
|
+
const l = this.options.prepareAttachmentUpload ? await ae(
|
|
737
737
|
() => this.options.prepareAttachmentUpload(i),
|
|
738
738
|
"Failed to prepare attachment upload"
|
|
739
739
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
740
|
-
await
|
|
740
|
+
await ae(async () => {
|
|
741
741
|
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
742
742
|
method: l.uploadMethod,
|
|
743
743
|
headers: l.uploadHeaders,
|
|
744
744
|
body: e
|
|
745
745
|
});
|
|
746
746
|
if (!c.ok)
|
|
747
|
-
throw new
|
|
747
|
+
throw new ue("Failed to upload attachment", c.status);
|
|
748
748
|
return c;
|
|
749
749
|
}, "Failed to upload attachment"), o = l;
|
|
750
750
|
}
|
|
751
751
|
this.setState({ sessionId: o.sessionId });
|
|
752
|
-
const a =
|
|
753
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
752
|
+
const a = Jt(o.attachment, this.options.backendUrl);
|
|
753
|
+
return this.updateAttachmentInState(s.id, a), s.id && cs(s.id, {
|
|
754
754
|
sessionId: o.sessionId,
|
|
755
755
|
fileUrl: a.fileUrl,
|
|
756
756
|
sandboxPath: a.sandboxPath,
|
|
@@ -777,18 +777,18 @@ class Nt {
|
|
|
777
777
|
}
|
|
778
778
|
async prepareEmbedAttachmentUpload(e) {
|
|
779
779
|
let s = !1;
|
|
780
|
-
return await
|
|
780
|
+
return await ae(async () => {
|
|
781
781
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
782
782
|
if (n.ok)
|
|
783
783
|
return await n.json();
|
|
784
|
-
if (
|
|
784
|
+
if (Vr(n.status) && this.options.tokenProvider && !s) {
|
|
785
785
|
s = !0;
|
|
786
786
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
787
787
|
if (r.ok)
|
|
788
788
|
return await r.json();
|
|
789
|
-
throw new
|
|
789
|
+
throw new ue("Failed to prepare attachment upload", r.status);
|
|
790
790
|
}
|
|
791
|
-
throw new
|
|
791
|
+
throw new ue("Failed to prepare attachment upload", n.status);
|
|
792
792
|
}, "Failed to prepare attachment upload");
|
|
793
793
|
}
|
|
794
794
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -806,14 +806,14 @@ class Nt {
|
|
|
806
806
|
if (!this.state.sessionId)
|
|
807
807
|
return;
|
|
808
808
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
809
|
-
const e =
|
|
809
|
+
const e = fr(
|
|
810
810
|
this.state.messages,
|
|
811
811
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
812
812
|
this.state.assistantDraftRunId,
|
|
813
813
|
this.activeClientMessageId
|
|
814
814
|
);
|
|
815
815
|
this.setState({
|
|
816
|
-
messages:
|
|
816
|
+
messages: oe(
|
|
817
817
|
this.state.messages,
|
|
818
818
|
e.clientMessageId,
|
|
819
819
|
e.runId
|
|
@@ -844,10 +844,10 @@ class Nt {
|
|
|
844
844
|
});
|
|
845
845
|
}
|
|
846
846
|
listSessions(e = {}) {
|
|
847
|
-
const s =
|
|
847
|
+
const s = X(), n = new Promise((i, o) => {
|
|
848
848
|
const a = window.setTimeout(() => {
|
|
849
849
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
850
|
-
},
|
|
850
|
+
}, yt);
|
|
851
851
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
852
852
|
}), r = {
|
|
853
853
|
type: "sessions.list",
|
|
@@ -866,14 +866,14 @@ class Nt {
|
|
|
866
866
|
setSessionPinned(e, s) {
|
|
867
867
|
return this.sendSessionMutation(
|
|
868
868
|
this.pendingSessionPinRequests,
|
|
869
|
-
{ type: "session.pin", requestId:
|
|
869
|
+
{ type: "session.pin", requestId: X(), sessionId: e, pinned: s },
|
|
870
870
|
"Session pin did not respond in time"
|
|
871
871
|
);
|
|
872
872
|
}
|
|
873
873
|
renameSession(e, s) {
|
|
874
874
|
return this.sendSessionMutation(
|
|
875
875
|
this.pendingSessionRenameRequests,
|
|
876
|
-
{ type: "session.rename", requestId:
|
|
876
|
+
{ type: "session.rename", requestId: X(), sessionId: e, title: s },
|
|
877
877
|
"Session rename did not respond in time"
|
|
878
878
|
);
|
|
879
879
|
}
|
|
@@ -899,7 +899,7 @@ class Nt {
|
|
|
899
899
|
send(e) {
|
|
900
900
|
this.sendNow(_(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
901
901
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
902
|
-
) || this.queuedClientEvents.push(e),
|
|
902
|
+
) || this.queuedClientEvents.push(e), L(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
903
903
|
status: "reconnecting",
|
|
904
904
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
905
905
|
}), this.scheduleReconnect());
|
|
@@ -915,7 +915,7 @@ class Nt {
|
|
|
915
915
|
return !1;
|
|
916
916
|
const s = this.socket;
|
|
917
917
|
try {
|
|
918
|
-
return s.send(JSON.stringify(e)),
|
|
918
|
+
return s.send(JSON.stringify(e)), _e("client_event", e.type, dt(e)), !0;
|
|
919
919
|
} catch (n) {
|
|
920
920
|
return M("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
921
921
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -928,7 +928,7 @@ class Nt {
|
|
|
928
928
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
929
929
|
return;
|
|
930
930
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
931
|
-
const e =
|
|
931
|
+
const e = Rn();
|
|
932
932
|
this.sendNow(
|
|
933
933
|
_({
|
|
934
934
|
type: "starter_prompts.page_context",
|
|
@@ -939,13 +939,13 @@ class Nt {
|
|
|
939
939
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
940
940
|
}
|
|
941
941
|
startStarterPromptUrlWatcher() {
|
|
942
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
942
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = En(() => this.handleStarterPromptUrlChange()));
|
|
943
943
|
}
|
|
944
944
|
handleStarterPromptUrlChange() {
|
|
945
945
|
const e = location.href;
|
|
946
946
|
e !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
947
947
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
948
|
-
},
|
|
948
|
+
}, Ys));
|
|
949
949
|
}
|
|
950
950
|
refreshStarterPromptsForCurrentUrl() {
|
|
951
951
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -960,27 +960,27 @@ class Nt {
|
|
|
960
960
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
961
961
|
return;
|
|
962
962
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
963
|
-
|
|
963
|
+
L(this.options.clientId, this.queuedClientEvents);
|
|
964
964
|
for (let s = 0; s < e.length; s += 1) {
|
|
965
965
|
const n = e[s];
|
|
966
966
|
if (!this.sendNow(_(n))) {
|
|
967
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
967
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), L(this.options.clientId, this.queuedClientEvents);
|
|
968
968
|
return;
|
|
969
969
|
}
|
|
970
|
-
|
|
970
|
+
L(this.options.clientId, this.queuedClientEvents);
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
flushPendingWarmupEvent() {
|
|
974
974
|
!this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
|
|
975
975
|
}
|
|
976
976
|
handleServerEvent(e) {
|
|
977
|
-
if (
|
|
978
|
-
const s =
|
|
977
|
+
if (_e("server_event", e.type, dt(e)), e.type === "run.ack") {
|
|
978
|
+
const s = De(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
979
979
|
s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && (n === this.activeClientMessageId || n === this.pendingClientMessageId) && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(e);
|
|
980
980
|
return;
|
|
981
981
|
}
|
|
982
982
|
if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
983
|
-
const s =
|
|
983
|
+
const s = De(e);
|
|
984
984
|
if (s) {
|
|
985
985
|
this.deferredSessionUpdatedSessionIds.add(s);
|
|
986
986
|
return;
|
|
@@ -995,20 +995,20 @@ class Nt {
|
|
|
995
995
|
this.clearHeartbeatAckTimer();
|
|
996
996
|
return;
|
|
997
997
|
}
|
|
998
|
-
if (
|
|
998
|
+
if (sn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
999
999
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingWarmupEvent(), this.startHeartbeat();
|
|
1000
1000
|
const s = On(e), n = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1001
1001
|
M("web-sdk.agent", "Received auth.ok appearance", {
|
|
1002
1002
|
hasAppearance: n,
|
|
1003
1003
|
rawAppearance: e.appearance,
|
|
1004
1004
|
normalizedAppearance: s
|
|
1005
|
-
}), this.runtimeHelperJavascript =
|
|
1006
|
-
const r =
|
|
1007
|
-
user:
|
|
1005
|
+
}), this.runtimeHelperJavascript = xn(e.runtimeHelpers)?.javascript ?? null;
|
|
1006
|
+
const r = Mt(e, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), o = e.starterPromptsLoading === !0, a = {
|
|
1007
|
+
user: Hn(e.user),
|
|
1008
1008
|
status: "connected",
|
|
1009
1009
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1010
1010
|
};
|
|
1011
|
-
(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 && !
|
|
1011
|
+
(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 && !re() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1012
1012
|
type: "page.upsert",
|
|
1013
1013
|
sessionId: this.state.sessionId,
|
|
1014
1014
|
page: C(),
|
|
@@ -1018,7 +1018,7 @@ class Nt {
|
|
|
1018
1018
|
}
|
|
1019
1019
|
if (e.type === "starterPrompts.updated") {
|
|
1020
1020
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1021
|
-
starterPrompts:
|
|
1021
|
+
starterPrompts: Mt(e, "starterPrompts"),
|
|
1022
1022
|
starterPromptsLoading: !1
|
|
1023
1023
|
});
|
|
1024
1024
|
return;
|
|
@@ -1026,37 +1026,37 @@ class Nt {
|
|
|
1026
1026
|
if (e.type === "conversation.state") {
|
|
1027
1027
|
const s = Array.isArray(e.items) ? e.items : [], n = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, r = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, i = e.isRetrying === !0;
|
|
1028
1028
|
n && r && (this.pendingClientMessageId = r);
|
|
1029
|
-
const o =
|
|
1029
|
+
const o = Xn(
|
|
1030
1030
|
e.assistantDraft
|
|
1031
1031
|
), a = o !== void 0;
|
|
1032
1032
|
this.rememberUserMessageClientMessageIds(s);
|
|
1033
|
-
const l =
|
|
1033
|
+
const l = ur(s);
|
|
1034
1034
|
if (l) {
|
|
1035
|
-
const f =
|
|
1035
|
+
const f = dr(s, l);
|
|
1036
1036
|
this.retryAttemptsByClientMessageId[l] = Math.max(
|
|
1037
1037
|
this.retryAttemptsByClientMessageId[l] ?? 0,
|
|
1038
1038
|
f
|
|
1039
1039
|
);
|
|
1040
1040
|
}
|
|
1041
1041
|
const c = s.filter((f) => {
|
|
1042
|
-
const R =
|
|
1043
|
-
return
|
|
1044
|
-
}), h =
|
|
1042
|
+
const R = H(f);
|
|
1043
|
+
return Rt(R) ? !1 : !R || !l || !We(R) ? !0 : Fe(s, R) !== l;
|
|
1044
|
+
}), h = nr(
|
|
1045
1045
|
this.state.messages,
|
|
1046
|
-
|
|
1047
|
-
), p =
|
|
1048
|
-
(f) =>
|
|
1049
|
-
|
|
1046
|
+
Wn(c, this.options.backendUrl)
|
|
1047
|
+
), p = At(h), w = !a && s.some(
|
|
1048
|
+
(f) => Et(
|
|
1049
|
+
H(f),
|
|
1050
1050
|
this.state.assistantDraft,
|
|
1051
1051
|
this.state.assistantDraftItemId,
|
|
1052
1052
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1053
1053
|
this.state.assistantDraftRunId
|
|
1054
1054
|
)
|
|
1055
|
-
), y = a ? o?.content ?? "" : this.state.assistantDraft, u = !!o?.content, d = p && (!y || w), g =
|
|
1056
|
-
if (!p &&
|
|
1055
|
+
), y = a ? o?.content ?? "" : this.state.assistantDraft, u = !!o?.content, d = p && (!y || w), g = ar(h), m = d && g;
|
|
1056
|
+
if (!p && cr(this.state.messages, s))
|
|
1057
1057
|
return;
|
|
1058
|
-
this.lastUserMessagePageUrl =
|
|
1059
|
-
const T = d ? null :
|
|
1058
|
+
this.lastUserMessagePageUrl = lr(s);
|
|
1059
|
+
const T = d ? null : je(s);
|
|
1060
1060
|
if (this.latestRecoverableClientMessageId = T, g && this.clearRetryTimers(), this.setState({
|
|
1061
1061
|
sessionId: E(e.session, "id") ?? this.state.sessionId,
|
|
1062
1062
|
messages: h,
|
|
@@ -1095,7 +1095,7 @@ class Nt {
|
|
|
1095
1095
|
else if (u || T) {
|
|
1096
1096
|
if (T) {
|
|
1097
1097
|
this.activeClientMessageId = T;
|
|
1098
|
-
const f =
|
|
1098
|
+
const f = Y(s), R = f === null ? null : s[f];
|
|
1099
1099
|
this.activeResponseUserMessageId = E(R, "id");
|
|
1100
1100
|
}
|
|
1101
1101
|
this.markThinkingProgress();
|
|
@@ -1109,7 +1109,7 @@ class Nt {
|
|
|
1109
1109
|
if (e.type === "sessions.page") {
|
|
1110
1110
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1111
1111
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1112
|
-
sessions:
|
|
1112
|
+
sessions: jn(e.sessions),
|
|
1113
1113
|
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1114
1114
|
}));
|
|
1115
1115
|
return;
|
|
@@ -1128,8 +1128,8 @@ class Nt {
|
|
|
1128
1128
|
}
|
|
1129
1129
|
if (e.type === "session.item") {
|
|
1130
1130
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1131
|
-
const s =
|
|
1132
|
-
if (
|
|
1131
|
+
const s = H(e.item);
|
|
1132
|
+
if (We(s)) {
|
|
1133
1133
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1134
1134
|
const r = E(e.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1135
1135
|
if (r && a) {
|
|
@@ -1141,21 +1141,21 @@ class Nt {
|
|
|
1141
1141
|
return;
|
|
1142
1142
|
}
|
|
1143
1143
|
}
|
|
1144
|
-
if (
|
|
1144
|
+
if (Rt(s))
|
|
1145
1145
|
return;
|
|
1146
|
-
const n =
|
|
1146
|
+
const n = Wt(e.item, this.options.backendUrl);
|
|
1147
1147
|
if (n) {
|
|
1148
1148
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1149
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
1149
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), x(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1150
1150
|
const i = e.item.data;
|
|
1151
|
-
|
|
1152
|
-
const o = Be(this.state.messages, n), a =
|
|
1151
|
+
pr(i) && this.clearRunAckResyncRetryTimer();
|
|
1152
|
+
const o = Be(this.state.messages, n), a = At(o), l = Et(
|
|
1153
1153
|
i,
|
|
1154
1154
|
this.state.assistantDraft,
|
|
1155
1155
|
this.state.assistantDraftItemId,
|
|
1156
1156
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1157
1157
|
this.state.assistantDraftRunId
|
|
1158
|
-
), c = a && (!this.state.assistantDraft || l), h =
|
|
1158
|
+
), c = a && (!this.state.assistantDraft || l), h = x(n) && (c || !this.state.isThinking && this.activeClientMessageId === null);
|
|
1159
1159
|
this.setState({
|
|
1160
1160
|
messages: o,
|
|
1161
1161
|
...l ? {
|
|
@@ -1188,6 +1188,7 @@ class Nt {
|
|
|
1188
1188
|
role: "assistant",
|
|
1189
1189
|
content: i,
|
|
1190
1190
|
createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1191
|
+
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1191
1192
|
dataType: "assistant_draft",
|
|
1192
1193
|
...l ? { phase: l } : {},
|
|
1193
1194
|
...c ? { respondsToUserMessageId: c } : {},
|
|
@@ -1210,9 +1211,9 @@ class Nt {
|
|
|
1210
1211
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null;
|
|
1211
1212
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1212
1213
|
return;
|
|
1213
|
-
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l =
|
|
1214
|
+
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = ms(
|
|
1214
1215
|
this.state.messages.filter(
|
|
1215
|
-
(c) => c.dataType !== "assistant_draft" || !
|
|
1216
|
+
(c) => c.dataType !== "assistant_draft" || !Yn(
|
|
1216
1217
|
c,
|
|
1217
1218
|
n,
|
|
1218
1219
|
r
|
|
@@ -1220,11 +1221,11 @@ class Nt {
|
|
|
1220
1221
|
),
|
|
1221
1222
|
n,
|
|
1222
1223
|
r,
|
|
1223
|
-
|
|
1224
|
+
jt
|
|
1224
1225
|
);
|
|
1225
1226
|
this.setState({
|
|
1226
1227
|
sessionId: s,
|
|
1227
|
-
messages:
|
|
1228
|
+
messages: Qn(
|
|
1228
1229
|
l,
|
|
1229
1230
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
1230
1231
|
n,
|
|
@@ -1246,9 +1247,9 @@ class Nt {
|
|
|
1246
1247
|
if (s)
|
|
1247
1248
|
this.nonTranscriptToolCallIds.add(s);
|
|
1248
1249
|
else {
|
|
1249
|
-
const n =
|
|
1250
|
+
const n = tr(e);
|
|
1250
1251
|
if (n) {
|
|
1251
|
-
const r =
|
|
1252
|
+
const r = Zn(
|
|
1252
1253
|
this.state.messages,
|
|
1253
1254
|
n
|
|
1254
1255
|
);
|
|
@@ -1301,9 +1302,9 @@ class Nt {
|
|
|
1301
1302
|
return;
|
|
1302
1303
|
}
|
|
1303
1304
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1304
|
-
const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l =
|
|
1305
|
+
const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l = Mn(a.message);
|
|
1305
1306
|
l && console.error(l), this.setState({
|
|
1306
|
-
messages:
|
|
1307
|
+
messages: oe(
|
|
1307
1308
|
this.state.messages,
|
|
1308
1309
|
i ?? this.activeClientMessageId,
|
|
1309
1310
|
typeof e.runId == "string" ? e.runId : null
|
|
@@ -1319,9 +1320,9 @@ class Nt {
|
|
|
1319
1320
|
}
|
|
1320
1321
|
}
|
|
1321
1322
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1322
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1323
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !nn(e))
|
|
1323
1324
|
return !1;
|
|
1324
|
-
const s =
|
|
1325
|
+
const s = De(e);
|
|
1325
1326
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1326
1327
|
}
|
|
1327
1328
|
rememberCurrentRunAsBackground() {
|
|
@@ -1331,7 +1332,7 @@ class Nt {
|
|
|
1331
1332
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1332
1333
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1333
1334
|
return !1;
|
|
1334
|
-
if (
|
|
1335
|
+
if (re())
|
|
1335
1336
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1336
1337
|
if (e.code === "run_still_active") {
|
|
1337
1338
|
if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
|
|
@@ -1345,10 +1346,10 @@ class Nt {
|
|
|
1345
1346
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1346
1347
|
return !0;
|
|
1347
1348
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1348
|
-
if (i >=
|
|
1349
|
+
if (i >= K)
|
|
1349
1350
|
return !1;
|
|
1350
1351
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1351
|
-
const o =
|
|
1352
|
+
const o = G(
|
|
1352
1353
|
i,
|
|
1353
1354
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1354
1355
|
);
|
|
@@ -1362,16 +1363,16 @@ class Nt {
|
|
|
1362
1363
|
}, o), !0;
|
|
1363
1364
|
}
|
|
1364
1365
|
retryAfterInterruptedRun(e, s) {
|
|
1365
|
-
if (
|
|
1366
|
+
if (re()) {
|
|
1366
1367
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1367
1368
|
return;
|
|
1368
1369
|
}
|
|
1369
1370
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1370
1371
|
return;
|
|
1371
1372
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1372
|
-
if (n >=
|
|
1373
|
+
if (n >= K) {
|
|
1373
1374
|
this.retryableClientMessageId = s, this.setState({
|
|
1374
|
-
messages:
|
|
1375
|
+
messages: oe(
|
|
1375
1376
|
this.state.messages,
|
|
1376
1377
|
s,
|
|
1377
1378
|
null
|
|
@@ -1385,7 +1386,7 @@ class Nt {
|
|
|
1385
1386
|
}
|
|
1386
1387
|
this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
|
|
1387
1388
|
delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 });
|
|
1388
|
-
},
|
|
1389
|
+
}, G(n));
|
|
1389
1390
|
}
|
|
1390
1391
|
clearRetryTimers() {
|
|
1391
1392
|
for (const e of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1394,7 +1395,7 @@ class Nt {
|
|
|
1394
1395
|
}
|
|
1395
1396
|
rememberUserMessageClientMessageIds(e) {
|
|
1396
1397
|
for (const s of e) {
|
|
1397
|
-
const n = E(s, "id"), r =
|
|
1398
|
+
const n = E(s, "id"), r = H(s);
|
|
1398
1399
|
n && r?.type === "message" && r.role === "user" && r.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof r.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId), r.clientMessageId === this.pendingClientMessageId && this.promotePendingDelivery(
|
|
1399
1400
|
r.clientMessageId,
|
|
1400
1401
|
E(s, "sessionId") ?? this.state.sessionId,
|
|
@@ -1412,7 +1413,7 @@ class Nt {
|
|
|
1412
1413
|
const r = new Promise((i, o) => {
|
|
1413
1414
|
const a = window.setTimeout(() => {
|
|
1414
1415
|
e.delete(s.requestId), o(new Error(n));
|
|
1415
|
-
},
|
|
1416
|
+
}, yt);
|
|
1416
1417
|
e.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1417
1418
|
});
|
|
1418
1419
|
if (!this.sendNow(s)) {
|
|
@@ -1435,7 +1436,7 @@ class Nt {
|
|
|
1435
1436
|
e.clear();
|
|
1436
1437
|
}
|
|
1437
1438
|
markThinkingProgress() {
|
|
1438
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1439
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(gt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1439
1440
|
}
|
|
1440
1441
|
scheduleThinkingWatchdog(e) {
|
|
1441
1442
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1478,21 +1479,21 @@ class Nt {
|
|
|
1478
1479
|
}), this.markThinkingProgress();
|
|
1479
1480
|
}
|
|
1480
1481
|
schedulePendingDeliveryAck(e) {
|
|
1481
|
-
this.clearPendingDeliveryTimers(), !
|
|
1482
|
+
this.clearPendingDeliveryTimers(), !re() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
1482
1483
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
1483
|
-
},
|
|
1484
|
+
}, ft));
|
|
1484
1485
|
}
|
|
1485
1486
|
retryPendingDelivery(e) {
|
|
1486
1487
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
1487
1488
|
return;
|
|
1488
1489
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1489
|
-
if (s >=
|
|
1490
|
+
if (s >= K) {
|
|
1490
1491
|
this.failPendingDelivery(e);
|
|
1491
1492
|
return;
|
|
1492
1493
|
}
|
|
1493
1494
|
this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
1494
1495
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
1495
|
-
},
|
|
1496
|
+
}, G(s, mt));
|
|
1496
1497
|
}
|
|
1497
1498
|
failPendingDelivery(e) {
|
|
1498
1499
|
if (this.pendingClientMessageId !== e)
|
|
@@ -1501,7 +1502,7 @@ class Nt {
|
|
|
1501
1502
|
this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = s, this.retryableClientMessageId = e, this.setState({
|
|
1502
1503
|
pendingMessageStatus: null,
|
|
1503
1504
|
isRetrying: !1,
|
|
1504
|
-
lastError:
|
|
1505
|
+
lastError: Fs,
|
|
1505
1506
|
lastErrorCode: "message_delivery_failed"
|
|
1506
1507
|
});
|
|
1507
1508
|
}
|
|
@@ -1516,7 +1517,7 @@ class Nt {
|
|
|
1516
1517
|
s,
|
|
1517
1518
|
typeof e.runId == "string" ? e.runId : null
|
|
1518
1519
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
1519
|
-
messages:
|
|
1520
|
+
messages: yr(
|
|
1520
1521
|
this.state.messages,
|
|
1521
1522
|
s
|
|
1522
1523
|
)
|
|
@@ -1525,7 +1526,7 @@ class Nt {
|
|
|
1525
1526
|
scheduleRunAckWatchdog(e) {
|
|
1526
1527
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1527
1528
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
1528
|
-
},
|
|
1529
|
+
}, ft);
|
|
1529
1530
|
}
|
|
1530
1531
|
recoverMissedRunAck(e) {
|
|
1531
1532
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (M("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1536,7 +1537,7 @@ class Nt {
|
|
|
1536
1537
|
scheduleRunAckResyncRetry(e) {
|
|
1537
1538
|
this.clearRunAckResyncRetryTimer();
|
|
1538
1539
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1539
|
-
s >=
|
|
1540
|
+
s >= K || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1540
1541
|
this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[e] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || this.latestRecoverableClientMessageId !== e || (this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({
|
|
1541
1542
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1542
1543
|
isThinking: !0,
|
|
@@ -1549,8 +1550,8 @@ class Nt {
|
|
|
1549
1550
|
sessionId: this.state.sessionId,
|
|
1550
1551
|
clientMessageId: e,
|
|
1551
1552
|
automatic: !0
|
|
1552
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1553
|
-
},
|
|
1553
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(gt)));
|
|
1554
|
+
}, G(s, mt)));
|
|
1554
1555
|
}
|
|
1555
1556
|
clearRunAckResyncRetryTimer() {
|
|
1556
1557
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1573,12 +1574,12 @@ class Nt {
|
|
|
1573
1574
|
return;
|
|
1574
1575
|
}
|
|
1575
1576
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1576
|
-
if (n >=
|
|
1577
|
+
if (n >= K) {
|
|
1577
1578
|
M("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1578
1579
|
sessionId: this.state.sessionId,
|
|
1579
1580
|
clientMessageId: e
|
|
1580
1581
|
}), this.retryableClientMessageId = e, this.setState({
|
|
1581
|
-
messages:
|
|
1582
|
+
messages: oe(
|
|
1582
1583
|
this.state.messages,
|
|
1583
1584
|
e,
|
|
1584
1585
|
null
|
|
@@ -1594,7 +1595,7 @@ class Nt {
|
|
|
1594
1595
|
sessionId: this.state.sessionId,
|
|
1595
1596
|
clientMessageId: e,
|
|
1596
1597
|
resyncAttempts: s + 1
|
|
1597
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1598
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Hs);
|
|
1598
1599
|
return;
|
|
1599
1600
|
}
|
|
1600
1601
|
this.setState({
|
|
@@ -1612,7 +1613,7 @@ class Nt {
|
|
|
1612
1613
|
clientMessageId: e,
|
|
1613
1614
|
automatic: !0
|
|
1614
1615
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1615
|
-
},
|
|
1616
|
+
}, G(n)));
|
|
1616
1617
|
}
|
|
1617
1618
|
resyncThinkingSession() {
|
|
1618
1619
|
this.state.sessionId ? this.send({
|
|
@@ -1629,7 +1630,7 @@ class Nt {
|
|
|
1629
1630
|
if (!s || !n || !r)
|
|
1630
1631
|
return;
|
|
1631
1632
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1632
|
-
if (!a && !l || !
|
|
1633
|
+
if (!a && !l || !qr(o)) {
|
|
1633
1634
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1634
1635
|
type: "tool.result",
|
|
1635
1636
|
sessionId: s,
|
|
@@ -1676,9 +1677,9 @@ class Nt {
|
|
|
1676
1677
|
startedAtOrigin: location.origin
|
|
1677
1678
|
}), this.installSessionBrowserApis();
|
|
1678
1679
|
let c = null, h;
|
|
1679
|
-
c = await this.executeRuntimeHelper(), h = await
|
|
1680
|
+
c = await this.executeRuntimeHelper(), h = await wt(
|
|
1680
1681
|
o,
|
|
1681
|
-
|
|
1682
|
+
yn(e.runtimeContext, this.options.backendUrl)
|
|
1682
1683
|
).catch((p) => ({
|
|
1683
1684
|
ok: !1,
|
|
1684
1685
|
exception: {
|
|
@@ -1691,11 +1692,11 @@ class Nt {
|
|
|
1691
1692
|
toolName: r,
|
|
1692
1693
|
summary: o.summary,
|
|
1693
1694
|
rawInput: _(o),
|
|
1694
|
-
rawOutput: _(
|
|
1695
|
-
}),
|
|
1695
|
+
rawOutput: _(Ln(h, c))
|
|
1696
|
+
}), Cr(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1696
1697
|
}
|
|
1697
1698
|
setToolMessageLoading(e, s) {
|
|
1698
|
-
const n =
|
|
1699
|
+
const n = er(
|
|
1699
1700
|
this.state.messages,
|
|
1700
1701
|
e,
|
|
1701
1702
|
s
|
|
@@ -1706,33 +1707,33 @@ class Nt {
|
|
|
1706
1707
|
if (this.pageLifecycleCleanup)
|
|
1707
1708
|
return;
|
|
1708
1709
|
const e = () => {
|
|
1709
|
-
|
|
1710
|
+
Gt(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1710
1711
|
};
|
|
1711
1712
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
1712
1713
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
1713
1714
|
};
|
|
1714
1715
|
}
|
|
1715
1716
|
installSessionBrowserApis() {
|
|
1716
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
1717
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = an();
|
|
1717
1718
|
}
|
|
1718
1719
|
cleanupSessionBrowserApis() {
|
|
1719
|
-
this.sessionBrowserApisCleanup && (
|
|
1720
|
+
this.sessionBrowserApisCleanup && (fn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
1720
1721
|
}
|
|
1721
1722
|
async executeRuntimeHelper() {
|
|
1722
1723
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1723
1724
|
return null;
|
|
1724
|
-
const e = await
|
|
1725
|
+
const e = await wt({
|
|
1725
1726
|
javascript: this.runtimeHelperJavascript
|
|
1726
1727
|
});
|
|
1727
|
-
return e.ok === !1 ?
|
|
1728
|
+
return e.ok === !1 ? qn(e) : null;
|
|
1728
1729
|
}
|
|
1729
1730
|
enableNetworkCapture() {
|
|
1730
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1731
|
-
|
|
1731
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = en((e) => {
|
|
1732
|
+
$r(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
1732
1733
|
}));
|
|
1733
1734
|
}
|
|
1734
1735
|
enqueueNetworkEvent(e) {
|
|
1735
|
-
this.queuedNetworkEvents.length >=
|
|
1736
|
+
this.queuedNetworkEvents.length >= zs || (this.queuedNetworkEvents.push(Fr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1736
1737
|
this.networkBatchTimer = null;
|
|
1737
1738
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1738
1739
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1741,12 +1742,12 @@ class Nt {
|
|
|
1741
1742
|
page: C(),
|
|
1742
1743
|
events: s
|
|
1743
1744
|
});
|
|
1744
|
-
},
|
|
1745
|
+
}, $s)));
|
|
1745
1746
|
}
|
|
1746
1747
|
scheduleReconnect() {
|
|
1747
1748
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1748
1749
|
return;
|
|
1749
|
-
const e =
|
|
1750
|
+
const e = Qs(this.reconnectAttempts);
|
|
1750
1751
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1751
1752
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1752
1753
|
M("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1763,7 +1764,7 @@ class Nt {
|
|
|
1763
1764
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1764
1765
|
this.socket === e && (M("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
1765
1766
|
}, Os));
|
|
1766
|
-
},
|
|
1767
|
+
}, Ns);
|
|
1767
1768
|
}
|
|
1768
1769
|
stopHeartbeat() {
|
|
1769
1770
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1789,7 +1790,7 @@ class Nt {
|
|
|
1789
1790
|
...e,
|
|
1790
1791
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1791
1792
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1792
|
-
},
|
|
1793
|
+
}, Er(this.options.clientId, this.state), this.emit("state", this.getState()), _e("state", this.state.status, {
|
|
1793
1794
|
status: this.state.status,
|
|
1794
1795
|
sessionId: this.state.sessionId,
|
|
1795
1796
|
messageCount: this.state.messages.length,
|
|
@@ -1809,20 +1810,20 @@ class Nt {
|
|
|
1809
1810
|
this.state.isThinking && this.activeClientMessageId ? this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId) : this.pendingClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.pendingClientMessageId);
|
|
1810
1811
|
}
|
|
1811
1812
|
getRunRecoveryExhaustedErrorMessage(e) {
|
|
1812
|
-
return e && this.browserConnectionInterruptedClientMessageIds.has(e) ?
|
|
1813
|
+
return e && this.browserConnectionInterruptedClientMessageIds.has(e) ? js : Ws;
|
|
1813
1814
|
}
|
|
1814
1815
|
emit(e, s) {
|
|
1815
1816
|
this.listeners[e]?.forEach((r) => r(s));
|
|
1816
1817
|
}
|
|
1817
1818
|
}
|
|
1818
|
-
const
|
|
1819
|
-
function
|
|
1820
|
-
const e = window.__plunoProductAgentNetworkCapture ??
|
|
1819
|
+
const Pe = /* @__PURE__ */ new WeakMap();
|
|
1820
|
+
function en(t) {
|
|
1821
|
+
const e = window.__plunoProductAgentNetworkCapture ?? tn();
|
|
1821
1822
|
return e.subscribers.add(t), () => {
|
|
1822
1823
|
e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
1823
1824
|
};
|
|
1824
1825
|
}
|
|
1825
|
-
function
|
|
1826
|
+
function tn() {
|
|
1826
1827
|
const t = /* @__PURE__ */ new Set(), e = (w) => {
|
|
1827
1828
|
t.forEach((y) => {
|
|
1828
1829
|
try {
|
|
@@ -1839,22 +1840,22 @@ function en() {
|
|
|
1839
1840
|
throw m;
|
|
1840
1841
|
}
|
|
1841
1842
|
try {
|
|
1842
|
-
const m = y instanceof Request ? y : null, T = Br(y, m), f =
|
|
1843
|
-
if (!
|
|
1844
|
-
const
|
|
1843
|
+
const m = y instanceof Request ? y : null, T = Br(y, m), f = Yt(u?.headers ?? m?.headers);
|
|
1844
|
+
if (!q(T, f, u?.body)) {
|
|
1845
|
+
const F = {
|
|
1845
1846
|
requestId: Oe("fetch"),
|
|
1846
|
-
url: P(T,
|
|
1847
|
+
url: P(T, Ue),
|
|
1847
1848
|
method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
1848
1849
|
requestHeaders: f,
|
|
1849
|
-
requestBody:
|
|
1850
|
+
requestBody: kt(u?.body),
|
|
1850
1851
|
resourceType: "fetch",
|
|
1851
1852
|
startedAt: new Date(d).toISOString()
|
|
1852
1853
|
};
|
|
1853
1854
|
g.then(
|
|
1854
1855
|
(U) => {
|
|
1855
|
-
|
|
1856
|
+
Hr(U, F, d, e).catch(() => {
|
|
1856
1857
|
e({
|
|
1857
|
-
...
|
|
1858
|
+
...F,
|
|
1858
1859
|
responseStatus: U.status,
|
|
1859
1860
|
durationMs: Date.now() - d
|
|
1860
1861
|
});
|
|
@@ -1862,7 +1863,7 @@ function en() {
|
|
|
1862
1863
|
},
|
|
1863
1864
|
(U) => {
|
|
1864
1865
|
e({
|
|
1865
|
-
...
|
|
1866
|
+
...F,
|
|
1866
1867
|
errorText: P(U instanceof Error ? U.message : String(U)),
|
|
1867
1868
|
durationMs: Date.now() - d
|
|
1868
1869
|
});
|
|
@@ -1874,27 +1875,27 @@ function en() {
|
|
|
1874
1875
|
return g;
|
|
1875
1876
|
}, a = function(y, u, d, g, m) {
|
|
1876
1877
|
const T = n.call(this, y, u, d ?? !0, g ?? void 0, m ?? void 0), f = typeof u == "string" ? u : u.toString();
|
|
1877
|
-
return
|
|
1878
|
+
return Pe.set(this, {
|
|
1878
1879
|
requestId: Oe("xhr"),
|
|
1879
1880
|
method: String(y ?? "GET").toUpperCase(),
|
|
1880
|
-
url: P(f,
|
|
1881
|
+
url: P(f, Ue),
|
|
1881
1882
|
requestHeaders: {},
|
|
1882
1883
|
startedAtMs: Date.now(),
|
|
1883
1884
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1884
|
-
excluded:
|
|
1885
|
+
excluded: q(f)
|
|
1885
1886
|
}), T;
|
|
1886
1887
|
}, l = function(y, u) {
|
|
1887
|
-
const d = r.call(this, y, u), g =
|
|
1888
|
-
return g && Object.keys(g.requestHeaders).length <
|
|
1888
|
+
const d = r.call(this, y, u), g = Pe.get(this);
|
|
1889
|
+
return g && Object.keys(g.requestHeaders).length < Ve && (g.requestHeaders[y] = et(y, u), g.excluded = g.excluded || q(g.url, g.requestHeaders)), d;
|
|
1889
1890
|
}, c = function(y) {
|
|
1890
1891
|
try {
|
|
1891
|
-
const u =
|
|
1892
|
-
u && (u.excluded = u.excluded ||
|
|
1892
|
+
const u = Pe.get(this);
|
|
1893
|
+
u && (u.excluded = u.excluded || q(u.url, u.requestHeaders, y), u.requestBody = kt(y), u.excluded || this.addEventListener(
|
|
1893
1894
|
"loadend",
|
|
1894
1895
|
() => {
|
|
1895
1896
|
queueMicrotask(() => {
|
|
1896
1897
|
try {
|
|
1897
|
-
const d =
|
|
1898
|
+
const d = Kr(this.getAllResponseHeaders());
|
|
1898
1899
|
e({
|
|
1899
1900
|
requestId: u.requestId,
|
|
1900
1901
|
url: u.url,
|
|
@@ -1904,7 +1905,7 @@ function en() {
|
|
|
1904
1905
|
resourceType: "xhr",
|
|
1905
1906
|
responseStatus: this.status,
|
|
1906
1907
|
responseHeaders: d,
|
|
1907
|
-
responseBody:
|
|
1908
|
+
responseBody: jr(this, d),
|
|
1908
1909
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1909
1910
|
startedAt: u.startedAt,
|
|
1910
1911
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -1941,12 +1942,12 @@ function en() {
|
|
|
1941
1942
|
h = new PerformanceObserver((w) => {
|
|
1942
1943
|
for (const y of w.getEntries()) {
|
|
1943
1944
|
const u = y;
|
|
1944
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
1945
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || q(u.name))
|
|
1945
1946
|
continue;
|
|
1946
1947
|
const d = performance.timeOrigin + u.startTime;
|
|
1947
1948
|
e({
|
|
1948
1949
|
requestId: Oe("resource"),
|
|
1949
|
-
url: P(u.name,
|
|
1950
|
+
url: P(u.name, Ue),
|
|
1950
1951
|
method: "GET",
|
|
1951
1952
|
resourceType: "resource",
|
|
1952
1953
|
responseStatus: u.responseStatus,
|
|
@@ -1996,17 +1997,17 @@ function M(t, e, s) {
|
|
|
1996
1997
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1997
1998
|
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 }));
|
|
1998
1999
|
}
|
|
1999
|
-
function
|
|
2000
|
+
function Tt(t) {
|
|
2000
2001
|
const e = typeof t == "function" ? t() : t;
|
|
2001
2002
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2002
2003
|
}
|
|
2003
|
-
function
|
|
2004
|
+
function sn(t) {
|
|
2004
2005
|
return t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call";
|
|
2005
2006
|
}
|
|
2006
|
-
function
|
|
2007
|
+
function nn(t) {
|
|
2007
2008
|
return t.type === "run.steered" || t.type === "run.ack" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
|
|
2008
2009
|
}
|
|
2009
|
-
function
|
|
2010
|
+
function De(t) {
|
|
2010
2011
|
if (typeof t.sessionId == "string")
|
|
2011
2012
|
return t.sessionId;
|
|
2012
2013
|
if (t.session && typeof t.session == "object") {
|
|
@@ -2021,31 +2022,31 @@ function Pe(t) {
|
|
|
2021
2022
|
}
|
|
2022
2023
|
return null;
|
|
2023
2024
|
}
|
|
2024
|
-
const
|
|
2025
|
-
function
|
|
2025
|
+
const rn = 5e3, on = 12e4;
|
|
2026
|
+
function an() {
|
|
2026
2027
|
const t = [
|
|
2027
|
-
|
|
2028
|
-
|
|
2028
|
+
cn(),
|
|
2029
|
+
ln()
|
|
2029
2030
|
].filter((e) => typeof e == "function");
|
|
2030
2031
|
return () => {
|
|
2031
2032
|
for (const e of t.reverse())
|
|
2032
2033
|
e();
|
|
2033
2034
|
};
|
|
2034
2035
|
}
|
|
2035
|
-
function an() {
|
|
2036
|
-
return _t(globalThis, "getPageSnapshot", async () => Ve());
|
|
2037
|
-
}
|
|
2038
2036
|
function ln() {
|
|
2039
|
-
return
|
|
2040
|
-
|
|
2037
|
+
return Ut(globalThis, "getPageSnapshot", async () => Ye());
|
|
2038
|
+
}
|
|
2039
|
+
function cn() {
|
|
2040
|
+
return Ut(globalThis, "pageImages", {
|
|
2041
|
+
inspectImage: async (e, s) => await un(e, s)
|
|
2041
2042
|
});
|
|
2042
2043
|
}
|
|
2043
|
-
async function
|
|
2044
|
-
const s =
|
|
2044
|
+
async function un(t, e = {}) {
|
|
2045
|
+
const s = gn(e.name), n = await dn(t);
|
|
2045
2046
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2046
2047
|
type: "pluno.pageImages.inspectImage",
|
|
2047
2048
|
imageAttached: !1,
|
|
2048
|
-
imageAttachmentError:
|
|
2049
|
+
imageAttachmentError: Nt
|
|
2049
2050
|
} : {
|
|
2050
2051
|
type: "pluno.pageImages.inspectImage",
|
|
2051
2052
|
imageAttached: !0,
|
|
@@ -2059,15 +2060,15 @@ async function cn(t, e = {}) {
|
|
|
2059
2060
|
imageAttachmentError: n.error
|
|
2060
2061
|
};
|
|
2061
2062
|
}
|
|
2062
|
-
async function
|
|
2063
|
-
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error:
|
|
2063
|
+
async function dn(t) {
|
|
2064
|
+
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: Nt } : {
|
|
2064
2065
|
ok: !0,
|
|
2065
2066
|
mimeType: t.type,
|
|
2066
2067
|
sizeBytes: t.size,
|
|
2067
|
-
dataUrl: await
|
|
2068
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
2068
|
+
dataUrl: await mn(t)
|
|
2069
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : hn(t);
|
|
2069
2070
|
}
|
|
2070
|
-
function
|
|
2071
|
+
function hn(t) {
|
|
2071
2072
|
if (!t.startsWith("data:") || !t.includes(","))
|
|
2072
2073
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
2073
2074
|
const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -2078,7 +2079,7 @@ function dn(t) {
|
|
|
2078
2079
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
2079
2080
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
2080
2081
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
2081
|
-
const o =
|
|
2082
|
+
const o = pn(i);
|
|
2082
2083
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
2083
2084
|
ok: !0,
|
|
2084
2085
|
mimeType: r,
|
|
@@ -2086,22 +2087,22 @@ function dn(t) {
|
|
|
2086
2087
|
dataUrl: `data:${r};base64,${i}`
|
|
2087
2088
|
};
|
|
2088
2089
|
}
|
|
2089
|
-
function
|
|
2090
|
+
function pn(t) {
|
|
2090
2091
|
if (t.length === 0 || t.length % 4 !== 0)
|
|
2091
2092
|
return null;
|
|
2092
2093
|
const e = t.length - t.replace(/=+$/, "").length;
|
|
2093
2094
|
return e > 2 ? null : t.length / 4 * 3 - e;
|
|
2094
2095
|
}
|
|
2095
|
-
function
|
|
2096
|
+
function gn(t) {
|
|
2096
2097
|
return (typeof t == "string" ? t.trim() : "") || "Page image";
|
|
2097
2098
|
}
|
|
2098
|
-
function
|
|
2099
|
+
function fn(t) {
|
|
2099
2100
|
try {
|
|
2100
2101
|
t();
|
|
2101
2102
|
} catch {
|
|
2102
2103
|
}
|
|
2103
2104
|
}
|
|
2104
|
-
function
|
|
2105
|
+
function mn(t) {
|
|
2105
2106
|
return new Promise((e, s) => {
|
|
2106
2107
|
const n = new FileReader();
|
|
2107
2108
|
n.onload = () => {
|
|
@@ -2113,9 +2114,9 @@ function fn(t) {
|
|
|
2113
2114
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(t);
|
|
2114
2115
|
});
|
|
2115
2116
|
}
|
|
2116
|
-
async function
|
|
2117
|
+
async function wt(t, e) {
|
|
2117
2118
|
const s = Object.getPrototypeOf(async function() {
|
|
2118
|
-
}).constructor, n = t.timeoutMs ??
|
|
2119
|
+
}).constructor, n = t.timeoutMs ?? rn, r = Date.now(), i = [];
|
|
2119
2120
|
let o;
|
|
2120
2121
|
const a = {
|
|
2121
2122
|
log: console.log,
|
|
@@ -2133,7 +2134,7 @@ async function Tt(t, e) {
|
|
|
2133
2134
|
o = window.setTimeout(() => p(c), n);
|
|
2134
2135
|
})
|
|
2135
2136
|
]);
|
|
2136
|
-
return h === c ?
|
|
2137
|
+
return h === c ? In(n) : {
|
|
2137
2138
|
ok: !0,
|
|
2138
2139
|
result: h,
|
|
2139
2140
|
console: i,
|
|
@@ -2162,7 +2163,7 @@ async function Tt(t, e) {
|
|
|
2162
2163
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2163
2164
|
}
|
|
2164
2165
|
}
|
|
2165
|
-
function
|
|
2166
|
+
function yn(t, e) {
|
|
2166
2167
|
if (!t || typeof t != "object")
|
|
2167
2168
|
return;
|
|
2168
2169
|
const s = t.sandboxFilesToken;
|
|
@@ -2172,7 +2173,7 @@ function mn(t, e) {
|
|
|
2172
2173
|
const r = () => {
|
|
2173
2174
|
if (!n)
|
|
2174
2175
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2175
|
-
}, i = async (a, l) => await
|
|
2176
|
+
}, i = async (a, l) => await Cs(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2176
2177
|
return {
|
|
2177
2178
|
value: Object.freeze({
|
|
2178
2179
|
upload: async (a) => {
|
|
@@ -2206,7 +2207,7 @@ function mn(t, e) {
|
|
|
2206
2207
|
}
|
|
2207
2208
|
};
|
|
2208
2209
|
}
|
|
2209
|
-
function
|
|
2210
|
+
function In(t) {
|
|
2210
2211
|
return {
|
|
2211
2212
|
ok: !1,
|
|
2212
2213
|
exception: {
|
|
@@ -2220,10 +2221,10 @@ function yn(t) {
|
|
|
2220
2221
|
}
|
|
2221
2222
|
};
|
|
2222
2223
|
}
|
|
2223
|
-
function
|
|
2224
|
+
function Tn(t) {
|
|
2224
2225
|
return t.replace(/\/+$/, "");
|
|
2225
2226
|
}
|
|
2226
|
-
function
|
|
2227
|
+
function wn(t) {
|
|
2227
2228
|
const e = {
|
|
2228
2229
|
sidepanel: "extension_sidepanel",
|
|
2229
2230
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2235,18 +2236,18 @@ function Tn(t) {
|
|
|
2235
2236
|
};
|
|
2236
2237
|
return t && t in e ? e[t] : t ?? "embedded_custom_ui";
|
|
2237
2238
|
}
|
|
2238
|
-
function
|
|
2239
|
+
function Sn(t) {
|
|
2239
2240
|
return t === "pluno" ? "scheduled_continuation" : t ?? "user";
|
|
2240
2241
|
}
|
|
2241
|
-
function
|
|
2242
|
+
function Mn(t, e = location.origin) {
|
|
2242
2243
|
return /origin (?:is not allowed|does not match browser origin)/i.test(t) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
|
|
2243
2244
|
}
|
|
2244
|
-
function
|
|
2245
|
+
function An(t) {
|
|
2245
2246
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2246
2247
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2247
2248
|
}
|
|
2248
2249
|
function C() {
|
|
2249
|
-
const t =
|
|
2250
|
+
const t = Ht();
|
|
2250
2251
|
return {
|
|
2251
2252
|
url: location.href,
|
|
2252
2253
|
title: document.title,
|
|
@@ -2254,21 +2255,21 @@ function C() {
|
|
|
2254
2255
|
...t ? { plunoProductAgentUi: t } : {}
|
|
2255
2256
|
};
|
|
2256
2257
|
}
|
|
2257
|
-
function
|
|
2258
|
+
function Rn() {
|
|
2258
2259
|
return {
|
|
2259
2260
|
pageUrl: location.href,
|
|
2260
2261
|
pageTitle: document.title,
|
|
2261
|
-
htmlContent:
|
|
2262
|
+
htmlContent: Ye()
|
|
2262
2263
|
};
|
|
2263
2264
|
}
|
|
2264
|
-
function
|
|
2265
|
-
return
|
|
2266
|
-
|
|
2265
|
+
function En(t) {
|
|
2266
|
+
return ce.add(t), ne || (ne = bn()), () => {
|
|
2267
|
+
ce.delete(t), ce.size === 0 && (ne?.(), ne = null);
|
|
2267
2268
|
};
|
|
2268
2269
|
}
|
|
2269
|
-
function
|
|
2270
|
+
function bn() {
|
|
2270
2271
|
const t = () => {
|
|
2271
|
-
for (const i of Array.from(
|
|
2272
|
+
for (const i of Array.from(ce))
|
|
2272
2273
|
i();
|
|
2273
2274
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2274
2275
|
const o = e(...i);
|
|
@@ -2281,38 +2282,38 @@ function En() {
|
|
|
2281
2282
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2282
2283
|
};
|
|
2283
2284
|
}
|
|
2284
|
-
function
|
|
2285
|
-
return
|
|
2285
|
+
function re() {
|
|
2286
|
+
return Ht()?.surface === "browser_extension_sdk_preview";
|
|
2286
2287
|
}
|
|
2287
|
-
function
|
|
2288
|
+
function Ye() {
|
|
2288
2289
|
if (!document.body)
|
|
2289
2290
|
return "";
|
|
2290
2291
|
const t = [], e = [], s = (d, g) => {
|
|
2291
|
-
const m =
|
|
2292
|
+
const m = W(g);
|
|
2292
2293
|
!m || e.includes(m) || (t.push([d, m]), e.push(m));
|
|
2293
2294
|
};
|
|
2294
2295
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2295
2296
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2296
|
-
(d) =>
|
|
2297
|
+
(d) => Lt(d) && !d.parentElement?.closest(n)
|
|
2297
2298
|
);
|
|
2298
2299
|
for (const d of r.slice(0, 3))
|
|
2299
|
-
s("Active overlay",
|
|
2300
|
-
const i =
|
|
2301
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2300
|
+
s("Active overlay", ve(J(d), e));
|
|
2301
|
+
const i = Cn(), o = i ? ve(J(i), e) : "";
|
|
2302
|
+
s("Main page content", o), s("Additional visible page text", ve(J(document.body), e));
|
|
2302
2303
|
const a = t.map(([d, g]) => `${d}:
|
|
2303
2304
|
${g}`).join(`
|
|
2304
2305
|
|
|
2305
|
-
`).trim().slice(0, 12e3), l =
|
|
2306
|
+
`).trim().slice(0, 12e3), l = kn(r, i).trim(), c = `Simplified DOM outline:
|
|
2306
2307
|
`, h = `
|
|
2307
2308
|
|
|
2308
2309
|
Visible page text:
|
|
2309
2310
|
`, p = 12e3 - c.length - h.length, w = Math.min(a.length, 7900), y = l.slice(0, p - w), u = a.slice(0, p - y.length);
|
|
2310
2311
|
return `${c}${y}${h}${u}`;
|
|
2311
2312
|
}
|
|
2312
|
-
function
|
|
2313
|
+
function J(t) {
|
|
2313
2314
|
return t.innerText ?? t.textContent ?? "";
|
|
2314
2315
|
}
|
|
2315
|
-
function
|
|
2316
|
+
function W(t) {
|
|
2316
2317
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2317
2318
|
`).split(`
|
|
2318
2319
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2320,20 +2321,20 @@ function H(t) {
|
|
|
2320
2321
|
|
|
2321
2322
|
`).trim();
|
|
2322
2323
|
}
|
|
2323
|
-
function
|
|
2324
|
-
let s =
|
|
2324
|
+
function ve(t, e) {
|
|
2325
|
+
let s = W(t);
|
|
2325
2326
|
for (const n of e)
|
|
2326
2327
|
s = s.replace(n, "");
|
|
2327
|
-
return
|
|
2328
|
+
return W(s);
|
|
2328
2329
|
}
|
|
2329
|
-
function
|
|
2330
|
+
function Lt(t) {
|
|
2330
2331
|
const e = window.getComputedStyle(t);
|
|
2331
2332
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2332
2333
|
}
|
|
2333
|
-
function
|
|
2334
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2334
|
+
function Cn() {
|
|
2335
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Lt).sort((t, e) => J(e).length - J(t).length)[0] ?? null;
|
|
2335
2336
|
}
|
|
2336
|
-
function
|
|
2337
|
+
function kn(t, e) {
|
|
2337
2338
|
const s = /* @__PURE__ */ new Set([
|
|
2338
2339
|
"main",
|
|
2339
2340
|
"nav",
|
|
@@ -2413,7 +2414,7 @@ function Cn(t, e) {
|
|
|
2413
2414
|
"data-test",
|
|
2414
2415
|
"data-qa",
|
|
2415
2416
|
"data-cy"
|
|
2416
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: p } =
|
|
2417
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: p } = _n(), w = new Set(t);
|
|
2417
2418
|
e && w.add(e);
|
|
2418
2419
|
let y = 0;
|
|
2419
2420
|
const u = (f) => {
|
|
@@ -2422,68 +2423,68 @@ function Cn(t, e) {
|
|
|
2422
2423
|
}, d = (f) => {
|
|
2423
2424
|
const R = f.getAttribute("data-testid") || f.getAttribute("data-test") || f.getAttribute("data-qa") || f.getAttribute("data-cy") || "";
|
|
2424
2425
|
return `${f.tagName.toLowerCase()}|${u(f)}|${R}`;
|
|
2425
|
-
}, g = (f, R,
|
|
2426
|
-
const U = (A,
|
|
2427
|
-
const b = A.tagName.toLowerCase(),
|
|
2428
|
-
if (y >= 1e3 && !
|
|
2426
|
+
}, g = (f, R, F) => {
|
|
2427
|
+
const U = (A, me) => {
|
|
2428
|
+
const b = A.tagName.toLowerCase(), ye = window.getComputedStyle(A), Z = h.has(A);
|
|
2429
|
+
if (y >= 1e3 && !Z || F.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ye.display === "none" || ye.visibility === "hidden")
|
|
2429
2430
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2430
2431
|
y += 1;
|
|
2431
|
-
const
|
|
2432
|
-
for (const I of
|
|
2432
|
+
const tt = u(A), ee = Bt(A), is = a.has(tt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && A.hasAttribute("href"), Ie = Array.from(A.children).filter((I) => I instanceof HTMLElement), te = /* @__PURE__ */ new Map();
|
|
2433
|
+
for (const I of Ie) {
|
|
2433
2434
|
const S = d(I);
|
|
2434
|
-
|
|
2435
|
+
te.set(S, (te.get(S) ?? 0) + 1);
|
|
2435
2436
|
}
|
|
2436
|
-
const
|
|
2437
|
-
for (const I of
|
|
2438
|
-
const S = d(I), v =
|
|
2439
|
-
|
|
2437
|
+
const Te = /* @__PURE__ */ new Map(), st = /* @__PURE__ */ new Map();
|
|
2438
|
+
for (const I of Ie) {
|
|
2439
|
+
const S = d(I), v = st.get(S) ?? 0;
|
|
2440
|
+
st.set(S, v + 1), (te.get(S) ?? 0) > 8 && v >= 6 && !h.has(I) && Te.set(S, (Te.get(S) ?? 0) + 1);
|
|
2440
2441
|
}
|
|
2441
|
-
const
|
|
2442
|
-
for (const I of
|
|
2443
|
-
const S = d(I), v =
|
|
2444
|
-
if (
|
|
2445
|
-
|
|
2442
|
+
const nt = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Set(), we = [], it = [];
|
|
2443
|
+
for (const I of Ie) {
|
|
2444
|
+
const S = d(I), v = te.get(S) ?? 0, lt = nt.get(S) ?? 0;
|
|
2445
|
+
if (nt.set(S, lt + 1), v > 8 && lt >= 6 && !h.has(I)) {
|
|
2446
|
+
rt.has(S) || (we.push([`… ${Te.get(S) ?? 0} similar siblings omitted`]), rt.add(S));
|
|
2446
2447
|
continue;
|
|
2447
2448
|
}
|
|
2448
|
-
const
|
|
2449
|
-
|
|
2449
|
+
const ct = U(I, me);
|
|
2450
|
+
it.push(ct), we.push(ct.lines);
|
|
2450
2451
|
}
|
|
2451
|
-
const
|
|
2452
|
+
const Se = [];
|
|
2452
2453
|
if (A.shadowRoot)
|
|
2453
2454
|
for (const I of Array.from(A.shadowRoot.children))
|
|
2454
|
-
I instanceof HTMLElement &&
|
|
2455
|
-
const
|
|
2456
|
-
[
|
|
2457
|
-
).slice(0, 180),
|
|
2458
|
-
if (
|
|
2459
|
-
const I =
|
|
2460
|
-
|
|
2455
|
+
I instanceof HTMLElement && Se.push(U(I, me + 1));
|
|
2456
|
+
const se = [...it, ...Se], Me = ee.length > 0 || is || se.some((I) => I.hasUsefulContent), ot = W(
|
|
2457
|
+
[ee, ...se.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
2458
|
+
).slice(0, 180), os = A.hasAttribute("contenteditable") && (ee.length > 0 || !A.querySelector("[contenteditable]")), at = c.some((I) => A.hasAttribute(I)) || !!tt || os, Ae = (A.getClientRects().length > 0 || ye.display === "contents") && (s.has(b) || at || Z) && (Me || Z) && (!r.has(b) || Me || at || Z), Re = Ae ? 1 : 0, $ = [];
|
|
2459
|
+
if (Ae) {
|
|
2460
|
+
const I = se.some((v) => v.containsTextElement), S = n.has(b) && !I ? ot : ee;
|
|
2461
|
+
$.push(qt(A, l, o, S.slice(0, 180)));
|
|
2461
2462
|
}
|
|
2462
|
-
for (const I of
|
|
2463
|
-
|
|
2464
|
-
const
|
|
2465
|
-
if (
|
|
2466
|
-
const I =
|
|
2467
|
-
|
|
2463
|
+
for (const I of we)
|
|
2464
|
+
$.push(...ie(I, Re));
|
|
2465
|
+
const Ee = Se.flatMap((I) => I.lines);
|
|
2466
|
+
if (Ee.length > 0) {
|
|
2467
|
+
const I = Ee.slice(0, 20);
|
|
2468
|
+
Ee.length > I.length && I.push("… shadow DOM omitted");
|
|
2468
2469
|
const S = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
|
|
2469
|
-
if (
|
|
2470
|
-
const v =
|
|
2471
|
-
|
|
2470
|
+
if (me < 2 && !S) {
|
|
2471
|
+
const v = Ae ? "#shadow-root" : `${b} #shadow-root`;
|
|
2472
|
+
$.push(...ie([v, ...ie(I, 1)], Re));
|
|
2472
2473
|
} else
|
|
2473
|
-
|
|
2474
|
+
$.push(...ie(I, Re));
|
|
2474
2475
|
}
|
|
2475
2476
|
return {
|
|
2476
|
-
lines:
|
|
2477
|
-
hasUsefulContent:
|
|
2478
|
-
textPreview:
|
|
2479
|
-
containsTextElement: n.has(b) ||
|
|
2477
|
+
lines: $,
|
|
2478
|
+
hasUsefulContent: Me,
|
|
2479
|
+
textPreview: ot,
|
|
2480
|
+
containsTextElement: n.has(b) || se.some((I) => I.containsTextElement)
|
|
2480
2481
|
};
|
|
2481
2482
|
};
|
|
2482
2483
|
return [`--- ${R} ---`, ...U(f, 0).lines].join(`
|
|
2483
2484
|
`);
|
|
2484
|
-
}, m = [], T =
|
|
2485
|
+
}, m = [], T = W(window.getSelection()?.toString() ?? "");
|
|
2485
2486
|
T && m.push(`--- selected text ---
|
|
2486
|
-
${JSON.stringify(T)}`), p.length > 0 && m.push(
|
|
2487
|
+
${JSON.stringify(T)}`), p.length > 0 && m.push(Un(p, s, l, o));
|
|
2487
2488
|
for (const f of t.slice(0, 3))
|
|
2488
2489
|
m.push(g(f, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2489
2490
|
if (e && m.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2494,11 +2495,11 @@ ${JSON.stringify(T)}`), p.length > 0 && m.push(_n(p, s, l, o));
|
|
|
2494
2495
|
|
|
2495
2496
|
`);
|
|
2496
2497
|
}
|
|
2497
|
-
function
|
|
2498
|
+
function qt(t, e, s, n) {
|
|
2498
2499
|
const r = t.tagName.toLowerCase();
|
|
2499
2500
|
let i = r;
|
|
2500
2501
|
const o = t.getAttribute("id");
|
|
2501
|
-
o &&
|
|
2502
|
+
o && Pn(o) && (i += `#${o}`);
|
|
2502
2503
|
for (const a of e) {
|
|
2503
2504
|
const l = t.getAttribute(a);
|
|
2504
2505
|
l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
|
|
@@ -2511,7 +2512,7 @@ function Lt(t, e, s, n) {
|
|
|
2511
2512
|
t.hasAttribute(a) && (i += `[${a}]`);
|
|
2512
2513
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2513
2514
|
}
|
|
2514
|
-
function
|
|
2515
|
+
function _n() {
|
|
2515
2516
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
|
|
2516
2517
|
if (!a)
|
|
2517
2518
|
return;
|
|
@@ -2532,7 +2533,7 @@ function kn() {
|
|
|
2532
2533
|
n = n.shadowRoot.activeElement;
|
|
2533
2534
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2534
2535
|
const r = window.getSelection();
|
|
2535
|
-
r && !r.isCollapsed && (s(
|
|
2536
|
+
r && !r.isCollapsed && (s(St(r.anchorNode), "selected text"), s(St(r.focusNode), "selected text"));
|
|
2536
2537
|
const i = [
|
|
2537
2538
|
["[aria-selected='true']", "selected"],
|
|
2538
2539
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2554,7 +2555,7 @@ function kn() {
|
|
|
2554
2555
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
2555
2556
|
};
|
|
2556
2557
|
}
|
|
2557
|
-
function
|
|
2558
|
+
function Un(t, e, s, n) {
|
|
2558
2559
|
const r = ["--- active/current elements ---"];
|
|
2559
2560
|
for (const i of t) {
|
|
2560
2561
|
const o = [];
|
|
@@ -2565,7 +2566,7 @@ function _n(t, e, s, n) {
|
|
|
2565
2566
|
const p = a.getRootNode();
|
|
2566
2567
|
a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
|
|
2567
2568
|
}
|
|
2568
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((h, p) =>
|
|
2569
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((h, p) => qt(
|
|
2569
2570
|
h,
|
|
2570
2571
|
s,
|
|
2571
2572
|
n,
|
|
@@ -2576,26 +2577,26 @@ function _n(t, e, s, n) {
|
|
|
2576
2577
|
return r.join(`
|
|
2577
2578
|
`);
|
|
2578
2579
|
}
|
|
2579
|
-
function
|
|
2580
|
+
function St(t) {
|
|
2580
2581
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
2581
2582
|
}
|
|
2582
|
-
function
|
|
2583
|
+
function ie(t, e) {
|
|
2583
2584
|
if (e === 0)
|
|
2584
2585
|
return t;
|
|
2585
2586
|
const s = " ".repeat(e);
|
|
2586
2587
|
return t.map((n) => `${s}${n}`);
|
|
2587
2588
|
}
|
|
2588
2589
|
function Bt(t) {
|
|
2589
|
-
return
|
|
2590
|
+
return W(
|
|
2590
2591
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
2591
2592
|
);
|
|
2592
2593
|
}
|
|
2593
|
-
function
|
|
2594
|
+
function Pn(t) {
|
|
2594
2595
|
return t.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(t) && !/[a-f0-9]{12,}/i.test(t) && !/:r[0-9a-z]+:/i.test(t);
|
|
2595
2596
|
}
|
|
2596
|
-
function
|
|
2597
|
-
const t = document.querySelector(
|
|
2598
|
-
if (!(t ?? document.querySelector(
|
|
2597
|
+
function Ht() {
|
|
2598
|
+
const t = document.querySelector(ut);
|
|
2599
|
+
if (!(t ?? document.querySelector(Le)))
|
|
2599
2600
|
return;
|
|
2600
2601
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2601
2602
|
return {
|
|
@@ -2604,28 +2605,28 @@ function qt() {
|
|
|
2604
2605
|
selectors: [
|
|
2605
2606
|
{
|
|
2606
2607
|
name: "widget_host",
|
|
2607
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2608
|
+
selector: s === "browser_extension_sdk_preview" ? ut : Le,
|
|
2608
2609
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2609
2610
|
},
|
|
2610
2611
|
{
|
|
2611
2612
|
name: "widget_root",
|
|
2612
|
-
selector:
|
|
2613
|
+
selector: ks,
|
|
2613
2614
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2614
2615
|
},
|
|
2615
2616
|
{
|
|
2616
2617
|
name: "widget_panel",
|
|
2617
|
-
selector:
|
|
2618
|
+
selector: _s,
|
|
2618
2619
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2619
2620
|
},
|
|
2620
2621
|
{
|
|
2621
2622
|
name: "widget_timeline",
|
|
2622
|
-
selector:
|
|
2623
|
+
selector: Us,
|
|
2623
2624
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2624
2625
|
}
|
|
2625
2626
|
]
|
|
2626
2627
|
};
|
|
2627
2628
|
}
|
|
2628
|
-
function
|
|
2629
|
+
function Dn(t) {
|
|
2629
2630
|
try {
|
|
2630
2631
|
const e = JSON.parse(t);
|
|
2631
2632
|
return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
|
|
@@ -2633,7 +2634,7 @@ function Pn(t) {
|
|
|
2633
2634
|
return { type: "error", message: "Invalid server event" };
|
|
2634
2635
|
}
|
|
2635
2636
|
}
|
|
2636
|
-
function
|
|
2637
|
+
function vn(t) {
|
|
2637
2638
|
if (typeof t != "string")
|
|
2638
2639
|
return null;
|
|
2639
2640
|
try {
|
|
@@ -2643,13 +2644,13 @@ function Dn(t) {
|
|
|
2643
2644
|
return null;
|
|
2644
2645
|
}
|
|
2645
2646
|
}
|
|
2646
|
-
function
|
|
2647
|
+
function Mt(t, e) {
|
|
2647
2648
|
if (!t || typeof t != "object")
|
|
2648
2649
|
return [];
|
|
2649
2650
|
const s = t[e];
|
|
2650
2651
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2651
2652
|
}
|
|
2652
|
-
function
|
|
2653
|
+
function Nn(t) {
|
|
2653
2654
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
2654
2655
|
}
|
|
2655
2656
|
function On(t) {
|
|
@@ -2663,13 +2664,13 @@ function On(t) {
|
|
|
2663
2664
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2664
2665
|
};
|
|
2665
2666
|
}
|
|
2666
|
-
function
|
|
2667
|
+
function xn(t) {
|
|
2667
2668
|
if (!t || typeof t != "object")
|
|
2668
2669
|
return null;
|
|
2669
2670
|
const e = t.javascript;
|
|
2670
2671
|
return typeof e != "string" || !e.trim() ? null : { javascript: e };
|
|
2671
2672
|
}
|
|
2672
|
-
function
|
|
2673
|
+
function Ln(t, e) {
|
|
2673
2674
|
return e ? t && typeof t == "object" ? {
|
|
2674
2675
|
...t,
|
|
2675
2676
|
helperError: e
|
|
@@ -2679,7 +2680,7 @@ function xn(t, e) {
|
|
|
2679
2680
|
helperError: e
|
|
2680
2681
|
} : t;
|
|
2681
2682
|
}
|
|
2682
|
-
function
|
|
2683
|
+
function qn(t) {
|
|
2683
2684
|
if (!t || typeof t != "object")
|
|
2684
2685
|
return t;
|
|
2685
2686
|
const e = t;
|
|
@@ -2692,10 +2693,10 @@ function Bn() {
|
|
|
2692
2693
|
const s = crypto.randomUUID();
|
|
2693
2694
|
return window.localStorage.setItem(t, s), s;
|
|
2694
2695
|
}
|
|
2695
|
-
function
|
|
2696
|
+
function X() {
|
|
2696
2697
|
return crypto.randomUUID();
|
|
2697
2698
|
}
|
|
2698
|
-
function
|
|
2699
|
+
function Hn(t) {
|
|
2699
2700
|
if (!t || typeof t != "object")
|
|
2700
2701
|
return null;
|
|
2701
2702
|
const e = t, s = typeof e.id == "string" ? e.id : null;
|
|
@@ -2706,12 +2707,12 @@ function qn(t) {
|
|
|
2706
2707
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
2707
2708
|
} : null;
|
|
2708
2709
|
}
|
|
2709
|
-
function
|
|
2710
|
-
return Array.isArray(t) ?
|
|
2711
|
-
t.map((s) =>
|
|
2710
|
+
function Wn(t, e) {
|
|
2711
|
+
return Array.isArray(t) ? $e(
|
|
2712
|
+
t.map((s) => Wt(s, e)).filter((s) => s !== null)
|
|
2712
2713
|
) : [];
|
|
2713
2714
|
}
|
|
2714
|
-
function
|
|
2715
|
+
function jn(t) {
|
|
2715
2716
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
2716
2717
|
if (!e || typeof e != "object")
|
|
2717
2718
|
return [];
|
|
@@ -2732,7 +2733,7 @@ function Wn(t) {
|
|
|
2732
2733
|
];
|
|
2733
2734
|
}) : [];
|
|
2734
2735
|
}
|
|
2735
|
-
function
|
|
2736
|
+
function Wt(t, e) {
|
|
2736
2737
|
if (!t || typeof t != "object")
|
|
2737
2738
|
return null;
|
|
2738
2739
|
const s = t, n = s.data;
|
|
@@ -2746,14 +2747,15 @@ function Ht(t, e) {
|
|
|
2746
2747
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2747
2748
|
role: i,
|
|
2748
2749
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2749
|
-
content:
|
|
2750
|
-
|
|
2750
|
+
content: gs(
|
|
2751
|
+
Jn(r.content),
|
|
2751
2752
|
e
|
|
2752
2753
|
),
|
|
2753
2754
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2755
|
+
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2754
2756
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2755
2757
|
...k(r) ? { runId: k(r) } : {},
|
|
2756
|
-
attachments:
|
|
2758
|
+
attachments: Xt(r.attachments, e)
|
|
2757
2759
|
};
|
|
2758
2760
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2759
2761
|
value: r.id,
|
|
@@ -2764,7 +2766,7 @@ function Ht(t, e) {
|
|
|
2764
2766
|
}), o;
|
|
2765
2767
|
}
|
|
2766
2768
|
if (r.type === "function_call_output") {
|
|
2767
|
-
const i =
|
|
2769
|
+
const i = bs(r.output);
|
|
2768
2770
|
if (i)
|
|
2769
2771
|
return {
|
|
2770
2772
|
id: String(s.id ?? crypto.randomUUID()),
|
|
@@ -2774,40 +2776,43 @@ function Ht(t, e) {
|
|
|
2774
2776
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2775
2777
|
...k(r) ? { runId: k(r) } : {},
|
|
2776
2778
|
dataType: "scheduled_check_in",
|
|
2777
|
-
toolName:
|
|
2778
|
-
callId:
|
|
2779
|
+
toolName: Dt,
|
|
2780
|
+
callId: Ne(r) ?? void 0,
|
|
2779
2781
|
scheduledCheckInAt: i
|
|
2780
2782
|
};
|
|
2781
|
-
const o =
|
|
2783
|
+
const o = $n(r.output);
|
|
2782
2784
|
return o ? {
|
|
2783
2785
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2784
2786
|
role: "tool",
|
|
2785
2787
|
content: `Connect ${o.appName} to continue`,
|
|
2786
2788
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2789
|
+
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2787
2790
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2788
2791
|
...k(r) ? { runId: k(r) } : {},
|
|
2789
2792
|
dataType: "function_call_output",
|
|
2790
2793
|
toolName: "authenticate_pipedream_app",
|
|
2791
|
-
callId:
|
|
2794
|
+
callId: Ne(r) ?? void 0,
|
|
2792
2795
|
integrationAuthRequest: o
|
|
2793
2796
|
} : null;
|
|
2794
2797
|
}
|
|
2795
2798
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2796
2799
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2797
2800
|
role: "tool",
|
|
2798
|
-
content: r.type === "mcp_call" ?
|
|
2801
|
+
content: r.type === "mcp_call" ? Fn(r) : Kn(r),
|
|
2799
2802
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2803
|
+
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2800
2804
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2801
2805
|
...k(r) ? { runId: k(r) } : {},
|
|
2802
2806
|
dataType: String(r.type),
|
|
2803
2807
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2804
|
-
callId:
|
|
2808
|
+
callId: Ne(r) ?? void 0,
|
|
2805
2809
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
2806
2810
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2807
2811
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2808
2812
|
role: "system",
|
|
2809
|
-
content:
|
|
2813
|
+
content: zn(r),
|
|
2810
2814
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2815
|
+
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2811
2816
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2812
2817
|
...k(r) ? { runId: k(r) } : {},
|
|
2813
2818
|
dataType: String(r.type),
|
|
@@ -2817,11 +2822,11 @@ function Ht(t, e) {
|
|
|
2817
2822
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2818
2823
|
} : null;
|
|
2819
2824
|
}
|
|
2820
|
-
function
|
|
2825
|
+
function Fn(t) {
|
|
2821
2826
|
const s = (typeof t.server_label == "string" ? t.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
2822
2827
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2823
2828
|
}
|
|
2824
|
-
function
|
|
2829
|
+
function $n(t) {
|
|
2825
2830
|
if (typeof t != "string")
|
|
2826
2831
|
return null;
|
|
2827
2832
|
try {
|
|
@@ -2838,10 +2843,10 @@ function Fn(t) {
|
|
|
2838
2843
|
return null;
|
|
2839
2844
|
}
|
|
2840
2845
|
}
|
|
2841
|
-
function
|
|
2846
|
+
function zn(t) {
|
|
2842
2847
|
return t.type === "run_status" && t.status === "stopped" ? "Run stopped by user" : t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message.replace(/Product Agent/g, "Pluno") : t.type === "run_status" && t.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
|
|
2843
2848
|
}
|
|
2844
|
-
function
|
|
2849
|
+
function Kn(t) {
|
|
2845
2850
|
if (t.type === "web_search_call") {
|
|
2846
2851
|
const e = t.action;
|
|
2847
2852
|
if (e && typeof e == "object") {
|
|
@@ -2853,9 +2858,9 @@ function zn(t) {
|
|
|
2853
2858
|
}
|
|
2854
2859
|
return "🔎 Searching the web";
|
|
2855
2860
|
}
|
|
2856
|
-
return
|
|
2861
|
+
return Gn(t);
|
|
2857
2862
|
}
|
|
2858
|
-
function
|
|
2863
|
+
function Gn(t) {
|
|
2859
2864
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
2860
2865
|
return B(t.summary);
|
|
2861
2866
|
if (typeof t.arguments == "string")
|
|
@@ -2872,7 +2877,7 @@ function B(t) {
|
|
|
2872
2877
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
2873
2878
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
2874
2879
|
}
|
|
2875
|
-
function
|
|
2880
|
+
function Xn(t) {
|
|
2876
2881
|
if (t == null)
|
|
2877
2882
|
return t;
|
|
2878
2883
|
if (typeof t != "object")
|
|
@@ -2887,11 +2892,14 @@ function Gn(t) {
|
|
|
2887
2892
|
runId: typeof e.runId == "string" ? e.runId : null
|
|
2888
2893
|
};
|
|
2889
2894
|
}
|
|
2890
|
-
function
|
|
2895
|
+
function Ne(t) {
|
|
2891
2896
|
const e = t.callId ?? t.call_id;
|
|
2892
2897
|
return typeof e == "string" && e ? e : null;
|
|
2893
2898
|
}
|
|
2894
|
-
function
|
|
2899
|
+
function N(t) {
|
|
2900
|
+
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
2901
|
+
}
|
|
2902
|
+
function Jn(t) {
|
|
2895
2903
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
2896
2904
|
if (!e || typeof e != "object")
|
|
2897
2905
|
return "";
|
|
@@ -2900,30 +2908,30 @@ function Xn(t) {
|
|
|
2900
2908
|
}).filter(Boolean).join("") : "";
|
|
2901
2909
|
}
|
|
2902
2910
|
function Be(t, e) {
|
|
2903
|
-
const s =
|
|
2904
|
-
|
|
2905
|
-
|
|
2911
|
+
const s = Ft(t, e), n = sr(
|
|
2912
|
+
Vn(
|
|
2913
|
+
or(t, e),
|
|
2906
2914
|
s
|
|
2907
2915
|
),
|
|
2908
2916
|
s
|
|
2909
2917
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2910
2918
|
if (r === -1)
|
|
2911
|
-
return
|
|
2919
|
+
return $e(
|
|
2912
2920
|
[...n, s]
|
|
2913
2921
|
);
|
|
2914
2922
|
const i = [...n];
|
|
2915
|
-
return i[r] = s,
|
|
2923
|
+
return i[r] = s, $e(i);
|
|
2916
2924
|
}
|
|
2917
|
-
function
|
|
2925
|
+
function Vn(t, e) {
|
|
2918
2926
|
const s = e.assistantDraftItemId;
|
|
2919
2927
|
return s ? t.map(
|
|
2920
2928
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
2921
2929
|
) : t;
|
|
2922
2930
|
}
|
|
2923
|
-
function
|
|
2931
|
+
function Yn(t, e, s) {
|
|
2924
2932
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
2925
2933
|
}
|
|
2926
|
-
function
|
|
2934
|
+
function Qn(t, e, s, n) {
|
|
2927
2935
|
if (s === null) return t;
|
|
2928
2936
|
let r = -1;
|
|
2929
2937
|
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
@@ -2940,7 +2948,7 @@ function Yn(t, e, s, n) {
|
|
|
2940
2948
|
respondsToUserMessageId: s
|
|
2941
2949
|
}, i;
|
|
2942
2950
|
}
|
|
2943
|
-
function
|
|
2951
|
+
function Zn(t, e) {
|
|
2944
2952
|
const s = t.findIndex(
|
|
2945
2953
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
2946
2954
|
);
|
|
@@ -2957,12 +2965,12 @@ function Qn(t, e) {
|
|
|
2957
2965
|
...n[s].runId ? {} : { runId: e.runId }
|
|
2958
2966
|
}, n;
|
|
2959
2967
|
}
|
|
2960
|
-
function
|
|
2968
|
+
function er(t, e, s) {
|
|
2961
2969
|
let n = !1;
|
|
2962
2970
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2963
2971
|
return n ? r : t;
|
|
2964
2972
|
}
|
|
2965
|
-
function
|
|
2973
|
+
function tr(t) {
|
|
2966
2974
|
if (t.hiddenFromTranscript === !0)
|
|
2967
2975
|
return null;
|
|
2968
2976
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
@@ -2973,6 +2981,7 @@ function er(t) {
|
|
|
2973
2981
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
2974
2982
|
),
|
|
2975
2983
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2984
|
+
...typeof t.causalSequence == "number" ? { causalSequence: t.causalSequence } : {},
|
|
2976
2985
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
2977
2986
|
runId: typeof t.runId == "string" ? t.runId : void 0,
|
|
2978
2987
|
dataType: "function_call",
|
|
@@ -2981,25 +2990,26 @@ function er(t) {
|
|
|
2981
2990
|
loading: !0
|
|
2982
2991
|
};
|
|
2983
2992
|
}
|
|
2984
|
-
function
|
|
2993
|
+
function sr(t, e) {
|
|
2985
2994
|
if (e.id.startsWith("transient-activity:"))
|
|
2986
2995
|
return t;
|
|
2987
2996
|
const s = e.toolName === "tab_lifecycle";
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
);
|
|
2997
|
+
if (!e.callId && !s)
|
|
2998
|
+
return t;
|
|
2999
|
+
const n = (i) => i.id === `transient-activity:${e.callId}` && i.callId === e.callId || s && i.id.startsWith("transient-activity:") && i.toolName === "browser_tabs" && !!i.runId && i.runId === e.runId, r = t.findIndex(n);
|
|
3000
|
+
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
2991
3001
|
}
|
|
2992
|
-
function
|
|
2993
|
-
return
|
|
3002
|
+
function nr(t, e) {
|
|
3003
|
+
return fs(
|
|
2994
3004
|
t,
|
|
2995
3005
|
e.map(
|
|
2996
|
-
(s) =>
|
|
3006
|
+
(s) => Ft(t, s)
|
|
2997
3007
|
),
|
|
2998
|
-
|
|
3008
|
+
jt
|
|
2999
3009
|
);
|
|
3000
3010
|
}
|
|
3001
|
-
function
|
|
3002
|
-
const e =
|
|
3011
|
+
function jt(t) {
|
|
3012
|
+
const e = V(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3003
3013
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3004
3014
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3005
3015
|
];
|
|
@@ -3010,52 +3020,52 @@ function Wt(t) {
|
|
|
3010
3020
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3011
3021
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3012
3022
|
...t.runId ? { runId: t.runId } : {},
|
|
3013
|
-
isOptimistic:
|
|
3023
|
+
isOptimistic: ge(t),
|
|
3014
3024
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3015
3025
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3016
3026
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3017
3027
|
};
|
|
3018
3028
|
}
|
|
3019
|
-
function
|
|
3029
|
+
function Ft(t, e) {
|
|
3020
3030
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3021
3031
|
return e;
|
|
3022
3032
|
const s = t.find(
|
|
3023
|
-
(r) => r.role === "user" && (r.id === e.id ||
|
|
3033
|
+
(r) => r.role === "user" && (r.id === e.id || ge(r) && $t(r, e))
|
|
3024
3034
|
);
|
|
3025
3035
|
if (!s?.attachments?.length)
|
|
3026
3036
|
return e;
|
|
3027
3037
|
const n = e.attachments.map((r) => {
|
|
3028
|
-
const i =
|
|
3029
|
-
return i ?
|
|
3038
|
+
const i = rr(s.attachments ?? [], r);
|
|
3039
|
+
return i ? ir(r, i) : r;
|
|
3030
3040
|
});
|
|
3031
3041
|
return { ...e, attachments: n };
|
|
3032
3042
|
}
|
|
3033
|
-
function
|
|
3043
|
+
function rr(t, e) {
|
|
3034
3044
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
3035
3045
|
}
|
|
3036
|
-
function
|
|
3046
|
+
function ir(t, e) {
|
|
3037
3047
|
const { previewUrl: s } = e;
|
|
3038
3048
|
return s ? { ...t, previewUrl: s } : t;
|
|
3039
3049
|
}
|
|
3040
|
-
function
|
|
3050
|
+
function or(t, e) {
|
|
3041
3051
|
if (e.role !== "user")
|
|
3042
3052
|
return t;
|
|
3043
3053
|
const s = t.findIndex(
|
|
3044
|
-
(r) =>
|
|
3054
|
+
(r) => ge(r) && $t(r, e)
|
|
3045
3055
|
);
|
|
3046
3056
|
if (s === -1)
|
|
3047
3057
|
return t;
|
|
3048
3058
|
const n = [...t];
|
|
3049
3059
|
return n.splice(s, 1), n;
|
|
3050
3060
|
}
|
|
3051
|
-
function
|
|
3052
|
-
const s =
|
|
3061
|
+
function $t(t, e) {
|
|
3062
|
+
const s = V(t), n = V(e);
|
|
3053
3063
|
return s && n ? s === n : t.content === e.content;
|
|
3054
3064
|
}
|
|
3055
|
-
function
|
|
3065
|
+
function ge(t) {
|
|
3056
3066
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3057
3067
|
}
|
|
3058
|
-
function
|
|
3068
|
+
function V(t) {
|
|
3059
3069
|
const e = t.clientMessageId;
|
|
3060
3070
|
if (e)
|
|
3061
3071
|
return e;
|
|
@@ -3064,18 +3074,18 @@ function J(t) {
|
|
|
3064
3074
|
);
|
|
3065
3075
|
return n ? t.id.slice(n.length) : null;
|
|
3066
3076
|
}
|
|
3067
|
-
function
|
|
3068
|
-
const e =
|
|
3077
|
+
function At(t) {
|
|
3078
|
+
const e = zt(t);
|
|
3069
3079
|
if (e === null)
|
|
3070
3080
|
return !1;
|
|
3071
3081
|
const s = t[e].id, n = t.some(
|
|
3072
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3082
|
+
(r) => r.respondsToUserMessageId === s && He(r)
|
|
3073
3083
|
);
|
|
3074
3084
|
if (t.some((r) => r.respondsToUserMessageId === s))
|
|
3075
3085
|
return n;
|
|
3076
3086
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3077
3087
|
const i = t[r];
|
|
3078
|
-
if (
|
|
3088
|
+
if (x(i))
|
|
3079
3089
|
return !0;
|
|
3080
3090
|
if (i.role === "system") {
|
|
3081
3091
|
if (i.dataType === "run_error")
|
|
@@ -3086,25 +3096,25 @@ function Mt(t) {
|
|
|
3086
3096
|
}
|
|
3087
3097
|
return !1;
|
|
3088
3098
|
}
|
|
3089
|
-
function
|
|
3090
|
-
const e =
|
|
3099
|
+
function ar(t) {
|
|
3100
|
+
const e = zt(t);
|
|
3091
3101
|
if (e === null)
|
|
3092
|
-
return t.some(
|
|
3102
|
+
return t.some(x);
|
|
3093
3103
|
const s = t[e].id;
|
|
3094
3104
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3095
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3096
|
-
) : t.slice(e + 1).some(
|
|
3105
|
+
(n) => n.respondsToUserMessageId === s && x(n)
|
|
3106
|
+
) : t.slice(e + 1).some(x);
|
|
3097
3107
|
}
|
|
3098
|
-
function
|
|
3108
|
+
function zt(t) {
|
|
3099
3109
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3100
|
-
if (t[e].role === "user" && !
|
|
3110
|
+
if (t[e].role === "user" && !ge(t[e]))
|
|
3101
3111
|
return e;
|
|
3102
3112
|
return null;
|
|
3103
3113
|
}
|
|
3104
|
-
function
|
|
3105
|
-
return
|
|
3114
|
+
function He(t) {
|
|
3115
|
+
return x(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3106
3116
|
}
|
|
3107
|
-
function
|
|
3117
|
+
function Y(t) {
|
|
3108
3118
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
3109
3119
|
const s = t[e];
|
|
3110
3120
|
if (!s || typeof s != "object")
|
|
@@ -3118,30 +3128,30 @@ function V(t) {
|
|
|
3118
3128
|
}
|
|
3119
3129
|
return null;
|
|
3120
3130
|
}
|
|
3121
|
-
function
|
|
3122
|
-
const e =
|
|
3131
|
+
function lr(t) {
|
|
3132
|
+
const e = Y(t);
|
|
3123
3133
|
if (e === null)
|
|
3124
3134
|
return null;
|
|
3125
|
-
const n =
|
|
3135
|
+
const n = H(t[e])?.page;
|
|
3126
3136
|
if (!n || typeof n != "object")
|
|
3127
3137
|
return null;
|
|
3128
3138
|
const r = n.url;
|
|
3129
3139
|
return typeof r == "string" ? r : null;
|
|
3130
3140
|
}
|
|
3131
|
-
function
|
|
3141
|
+
function H(t) {
|
|
3132
3142
|
if (!t || typeof t != "object")
|
|
3133
3143
|
return null;
|
|
3134
3144
|
const e = t.data;
|
|
3135
3145
|
return e && typeof e == "object" ? e : null;
|
|
3136
3146
|
}
|
|
3137
|
-
function
|
|
3147
|
+
function We(t) {
|
|
3138
3148
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3139
3149
|
}
|
|
3140
|
-
function
|
|
3150
|
+
function Rt(t) {
|
|
3141
3151
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3142
3152
|
}
|
|
3143
|
-
function
|
|
3144
|
-
const s =
|
|
3153
|
+
function cr(t, e) {
|
|
3154
|
+
const s = Y(e);
|
|
3145
3155
|
if (s === null)
|
|
3146
3156
|
return !1;
|
|
3147
3157
|
const n = e[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -3149,11 +3159,11 @@ function lr(t, e) {
|
|
|
3149
3159
|
return !1;
|
|
3150
3160
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3151
3161
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3152
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3153
|
-
) : t.slice(i + 1).some(
|
|
3162
|
+
(o) => o.respondsToUserMessageId === r && He(o)
|
|
3163
|
+
) : t.slice(i + 1).some(He);
|
|
3154
3164
|
}
|
|
3155
|
-
function
|
|
3156
|
-
const e =
|
|
3165
|
+
function je(t) {
|
|
3166
|
+
const e = Y(t);
|
|
3157
3167
|
if (e === null)
|
|
3158
3168
|
return null;
|
|
3159
3169
|
const s = t[e];
|
|
@@ -3165,8 +3175,8 @@ function We(t) {
|
|
|
3165
3175
|
const r = n.clientMessageId;
|
|
3166
3176
|
return typeof r == "string" ? r : null;
|
|
3167
3177
|
}
|
|
3168
|
-
function
|
|
3169
|
-
const e =
|
|
3178
|
+
function ur(t) {
|
|
3179
|
+
const e = Y(t);
|
|
3170
3180
|
if (e === null)
|
|
3171
3181
|
return null;
|
|
3172
3182
|
for (let s = t.length - 1; s > e; s -= 1) {
|
|
@@ -3180,22 +3190,22 @@ function cr(t) {
|
|
|
3180
3190
|
if (i.type === "message" && i.role === "assistant")
|
|
3181
3191
|
return null;
|
|
3182
3192
|
if (i.type === "run_error")
|
|
3183
|
-
return i.retryable !== !0 ? null :
|
|
3193
|
+
return i.retryable !== !0 ? null : Fe(t, i) ?? je(t);
|
|
3184
3194
|
if (i.type === "run_status")
|
|
3185
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3195
|
+
return i.status === "interrupted" && i.retryable === !0 ? Fe(t, i) ?? je(t) : null;
|
|
3186
3196
|
}
|
|
3187
3197
|
return null;
|
|
3188
3198
|
}
|
|
3189
|
-
function
|
|
3199
|
+
function Fe(t, e) {
|
|
3190
3200
|
if (typeof e.clientMessageId == "string")
|
|
3191
3201
|
return e.clientMessageId;
|
|
3192
3202
|
const s = O(e);
|
|
3193
3203
|
if (!s)
|
|
3194
3204
|
return null;
|
|
3195
|
-
const n = t.find((i) => E(i, "id") === s), r =
|
|
3205
|
+
const n = t.find((i) => E(i, "id") === s), r = H(n);
|
|
3196
3206
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3197
3207
|
}
|
|
3198
|
-
function
|
|
3208
|
+
function dr(t, e) {
|
|
3199
3209
|
let s = 0;
|
|
3200
3210
|
for (const n of t) {
|
|
3201
3211
|
if (!n || typeof n != "object")
|
|
@@ -3208,69 +3218,69 @@ function ur(t, e) {
|
|
|
3208
3218
|
}
|
|
3209
3219
|
return s;
|
|
3210
3220
|
}
|
|
3211
|
-
function
|
|
3212
|
-
if (!e || !
|
|
3221
|
+
function Et(t, e, s, n, r) {
|
|
3222
|
+
if (!e || !hr(t))
|
|
3213
3223
|
return !1;
|
|
3214
3224
|
const i = t;
|
|
3215
|
-
return !(
|
|
3225
|
+
return !(We(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && k(i) !== r));
|
|
3216
3226
|
}
|
|
3217
|
-
function
|
|
3227
|
+
function hr(t) {
|
|
3218
3228
|
if (!t || typeof t != "object")
|
|
3219
3229
|
return !1;
|
|
3220
3230
|
const e = t;
|
|
3221
3231
|
return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
|
|
3222
3232
|
}
|
|
3223
|
-
function
|
|
3233
|
+
function x(t) {
|
|
3224
3234
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3225
3235
|
}
|
|
3226
|
-
function
|
|
3236
|
+
function pr(t) {
|
|
3227
3237
|
if (!t || typeof t != "object")
|
|
3228
3238
|
return !1;
|
|
3229
3239
|
const e = t;
|
|
3230
3240
|
return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
|
|
3231
3241
|
}
|
|
3232
|
-
function
|
|
3233
|
-
return t.filter((e, s) =>
|
|
3242
|
+
function $e(t) {
|
|
3243
|
+
return t.filter((e, s) => j(e) ? !Ar(t, s) && !Kt(t, s) && !Sr(t, s) && !Mr(t, s) : gr(e) ? e.retryable === !0 && wr(t, s) ? !1 : !Tr(t, s) : !0);
|
|
3234
3244
|
}
|
|
3235
|
-
function
|
|
3245
|
+
function gr(t) {
|
|
3236
3246
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3237
3247
|
}
|
|
3238
|
-
function
|
|
3248
|
+
function j(t) {
|
|
3239
3249
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3240
3250
|
}
|
|
3241
|
-
function
|
|
3251
|
+
function fr(t, e, s, n) {
|
|
3242
3252
|
const r = t.findIndex(
|
|
3243
|
-
(l, c) =>
|
|
3253
|
+
(l, c) => j(l) && !Kt(t, c)
|
|
3244
3254
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3245
3255
|
(l) => l.role === "user" && l.id === o
|
|
3246
3256
|
) : null;
|
|
3247
3257
|
return {
|
|
3248
|
-
clientMessageId: a ?
|
|
3258
|
+
clientMessageId: a ? V(a) : o ? null : n,
|
|
3249
3259
|
runId: s ?? i?.runId ?? null
|
|
3250
3260
|
};
|
|
3251
3261
|
}
|
|
3252
|
-
function
|
|
3262
|
+
function oe(t, e, s) {
|
|
3253
3263
|
const n = new Set(
|
|
3254
3264
|
t.filter(
|
|
3255
|
-
(r) => r.role === "user" && e !== null &&
|
|
3265
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3256
3266
|
).map((r) => r.id)
|
|
3257
3267
|
);
|
|
3258
3268
|
return t.filter(
|
|
3259
|
-
(r) => !
|
|
3269
|
+
(r) => !j(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3260
3270
|
);
|
|
3261
3271
|
}
|
|
3262
|
-
function
|
|
3272
|
+
function Kt(t, e) {
|
|
3263
3273
|
return t.some(
|
|
3264
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
3274
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && mr(
|
|
3265
3275
|
t,
|
|
3266
3276
|
e,
|
|
3267
3277
|
n
|
|
3268
3278
|
)
|
|
3269
3279
|
);
|
|
3270
3280
|
}
|
|
3271
|
-
function
|
|
3281
|
+
function mr(t, e, s) {
|
|
3272
3282
|
const n = t[e], r = t[s];
|
|
3273
|
-
if (
|
|
3283
|
+
if (Q(n, r))
|
|
3274
3284
|
return !0;
|
|
3275
3285
|
if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
|
|
3276
3286
|
return !1;
|
|
@@ -3279,35 +3289,35 @@ function fr(t, e, s) {
|
|
|
3279
3289
|
return t[i].id === n.respondsToUserMessageId;
|
|
3280
3290
|
return !1;
|
|
3281
3291
|
}
|
|
3282
|
-
function
|
|
3292
|
+
function yr(t, e) {
|
|
3283
3293
|
const s = [...t].reverse().find(
|
|
3284
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
3294
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && bt(n) && !Ir(
|
|
3285
3295
|
t,
|
|
3286
3296
|
n.respondsToUserMessageId
|
|
3287
3297
|
)
|
|
3288
3298
|
)?.respondsToUserMessageId;
|
|
3289
3299
|
return s ? t.map(
|
|
3290
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3300
|
+
(n) => n.respondsToUserMessageId === s && bt(n) ? { ...n, steered: !0 } : n
|
|
3291
3301
|
) : t;
|
|
3292
3302
|
}
|
|
3293
|
-
function
|
|
3294
|
-
return t.role === "tool" ||
|
|
3303
|
+
function bt(t) {
|
|
3304
|
+
return t.role === "tool" || j(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3295
3305
|
}
|
|
3296
|
-
function
|
|
3306
|
+
function Ir(t, e) {
|
|
3297
3307
|
return t.some(
|
|
3298
|
-
(s) => s.respondsToUserMessageId === e && (
|
|
3308
|
+
(s) => s.respondsToUserMessageId === e && (x(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3299
3309
|
);
|
|
3300
3310
|
}
|
|
3301
|
-
function
|
|
3311
|
+
function Tr(t, e) {
|
|
3302
3312
|
const s = t[e];
|
|
3303
3313
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
3304
3314
|
const r = t[n];
|
|
3305
|
-
if (r.role === "assistant" &&
|
|
3315
|
+
if (r.role === "assistant" && Q(s, r))
|
|
3306
3316
|
return !0;
|
|
3307
3317
|
}
|
|
3308
3318
|
return !1;
|
|
3309
3319
|
}
|
|
3310
|
-
function
|
|
3320
|
+
function wr(t, e) {
|
|
3311
3321
|
const s = t[e];
|
|
3312
3322
|
if (!s.respondsToUserMessageId)
|
|
3313
3323
|
return !1;
|
|
@@ -3315,37 +3325,37 @@ function Tr(t, e) {
|
|
|
3315
3325
|
const r = t[n];
|
|
3316
3326
|
if (r.role === "user")
|
|
3317
3327
|
return !1;
|
|
3318
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3328
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || j(r)))
|
|
3319
3329
|
return !0;
|
|
3320
3330
|
}
|
|
3321
3331
|
return !1;
|
|
3322
3332
|
}
|
|
3323
|
-
function
|
|
3333
|
+
function Sr(t, e) {
|
|
3324
3334
|
const s = t[e];
|
|
3325
3335
|
return t.some(
|
|
3326
|
-
(n, r) => r !== e && n.role === "assistant" &&
|
|
3336
|
+
(n, r) => r !== e && n.role === "assistant" && Q(s, n)
|
|
3327
3337
|
);
|
|
3328
3338
|
}
|
|
3329
|
-
function
|
|
3339
|
+
function Mr(t, e) {
|
|
3330
3340
|
const s = t[e];
|
|
3331
3341
|
return t.some(
|
|
3332
|
-
(n, r) => r !== e && n.role === "tool" &&
|
|
3342
|
+
(n, r) => r !== e && n.role === "tool" && Q(s, n)
|
|
3333
3343
|
);
|
|
3334
3344
|
}
|
|
3335
|
-
function
|
|
3345
|
+
function Ar(t, e) {
|
|
3336
3346
|
const s = t[e];
|
|
3337
3347
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3338
|
-
if (
|
|
3348
|
+
if (j(t[n]) && Q(s, t[n]))
|
|
3339
3349
|
return !0;
|
|
3340
3350
|
return !1;
|
|
3341
3351
|
}
|
|
3342
|
-
function
|
|
3352
|
+
function Q(t, e) {
|
|
3343
3353
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
3344
3354
|
}
|
|
3345
3355
|
function E(t, e) {
|
|
3346
3356
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
3347
3357
|
}
|
|
3348
|
-
function
|
|
3358
|
+
function Rr(t, e) {
|
|
3349
3359
|
try {
|
|
3350
3360
|
const s = window.localStorage.getItem(`${Ot}${t}`);
|
|
3351
3361
|
if (!s)
|
|
@@ -3353,7 +3363,7 @@ function Ar(t, e) {
|
|
|
3353
3363
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3354
3364
|
if (e !== void 0 && r !== e)
|
|
3355
3365
|
return null;
|
|
3356
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3366
|
+
const i = Array.isArray(n.messages) ? n.messages.map(xr).filter((o) => !!o) : [];
|
|
3357
3367
|
return {
|
|
3358
3368
|
sessionId: r,
|
|
3359
3369
|
messages: i
|
|
@@ -3362,48 +3372,48 @@ function Ar(t, e) {
|
|
|
3362
3372
|
return null;
|
|
3363
3373
|
}
|
|
3364
3374
|
}
|
|
3365
|
-
function
|
|
3375
|
+
function Er(t, e) {
|
|
3366
3376
|
try {
|
|
3367
3377
|
window.localStorage.setItem(
|
|
3368
3378
|
`${Ot}${t}`,
|
|
3369
3379
|
JSON.stringify({
|
|
3370
3380
|
sessionId: e.sessionId,
|
|
3371
|
-
messages: e.messages.slice(-
|
|
3381
|
+
messages: e.messages.slice(-Vs).map(Lr)
|
|
3372
3382
|
})
|
|
3373
3383
|
);
|
|
3374
3384
|
} catch {
|
|
3375
3385
|
return;
|
|
3376
3386
|
}
|
|
3377
3387
|
}
|
|
3378
|
-
function
|
|
3388
|
+
function br(t) {
|
|
3379
3389
|
try {
|
|
3380
|
-
const e = window.localStorage.getItem(`${
|
|
3390
|
+
const e = window.localStorage.getItem(`${qe}${t}`);
|
|
3381
3391
|
if (!e)
|
|
3382
3392
|
return [];
|
|
3383
3393
|
const s = JSON.parse(e);
|
|
3384
|
-
return Array.isArray(s) ? s.filter(
|
|
3394
|
+
return Array.isArray(s) ? s.filter(Qe) : [];
|
|
3385
3395
|
} catch {
|
|
3386
3396
|
return [];
|
|
3387
3397
|
}
|
|
3388
3398
|
}
|
|
3389
|
-
function
|
|
3399
|
+
function L(t, e) {
|
|
3390
3400
|
try {
|
|
3391
|
-
const s = e.filter(
|
|
3401
|
+
const s = e.filter(Qe);
|
|
3392
3402
|
if (s.length === 0) {
|
|
3393
|
-
window.localStorage.removeItem(`${
|
|
3403
|
+
window.localStorage.removeItem(`${qe}${t}`);
|
|
3394
3404
|
return;
|
|
3395
3405
|
}
|
|
3396
3406
|
window.localStorage.setItem(
|
|
3397
|
-
`${
|
|
3407
|
+
`${qe}${t}`,
|
|
3398
3408
|
JSON.stringify(s.slice(-25))
|
|
3399
3409
|
);
|
|
3400
3410
|
} catch {
|
|
3401
3411
|
return;
|
|
3402
3412
|
}
|
|
3403
3413
|
}
|
|
3404
|
-
function
|
|
3414
|
+
function Gt(t, e) {
|
|
3405
3415
|
try {
|
|
3406
|
-
const s = `${
|
|
3416
|
+
const s = `${pe}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
3407
3417
|
...o,
|
|
3408
3418
|
storedAt: Date.now(),
|
|
3409
3419
|
unloadUrl: n,
|
|
@@ -3417,28 +3427,28 @@ function Kt(t, e) {
|
|
|
3417
3427
|
} catch {
|
|
3418
3428
|
}
|
|
3419
3429
|
}
|
|
3420
|
-
function
|
|
3430
|
+
function Cr(t, e) {
|
|
3421
3431
|
try {
|
|
3422
|
-
if (window.sessionStorage.getItem(`${
|
|
3432
|
+
if (window.sessionStorage.getItem(`${pe}${t}`) === null)
|
|
3423
3433
|
return;
|
|
3424
3434
|
} catch {
|
|
3425
3435
|
return;
|
|
3426
3436
|
}
|
|
3427
|
-
|
|
3437
|
+
Gt(t, e);
|
|
3428
3438
|
}
|
|
3429
|
-
function
|
|
3439
|
+
function kr(t) {
|
|
3430
3440
|
try {
|
|
3431
|
-
const e = `${
|
|
3441
|
+
const e = `${pe}${t}`, s = window.sessionStorage.getItem(e);
|
|
3432
3442
|
if (window.sessionStorage.removeItem(e), !s)
|
|
3433
3443
|
return [];
|
|
3434
3444
|
const n = JSON.parse(s);
|
|
3435
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3445
|
+
return Array.isArray(n) ? n.flatMap((r) => Ur(r) ? [{
|
|
3436
3446
|
...r.event,
|
|
3437
3447
|
page: C(),
|
|
3438
3448
|
rawOutput: {
|
|
3439
3449
|
pageContextRestarted: !0,
|
|
3440
3450
|
outcome: "unknown",
|
|
3441
|
-
message:
|
|
3451
|
+
message: _r(location.href),
|
|
3442
3452
|
currentUrl: location.href,
|
|
3443
3453
|
console: [],
|
|
3444
3454
|
metadata: {
|
|
@@ -3455,17 +3465,17 @@ function Cr(t) {
|
|
|
3455
3465
|
return [];
|
|
3456
3466
|
}
|
|
3457
3467
|
}
|
|
3458
|
-
function
|
|
3468
|
+
function _r(t) {
|
|
3459
3469
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3460
3470
|
Current URL: ${t}`;
|
|
3461
3471
|
}
|
|
3462
|
-
function
|
|
3472
|
+
function Ur(t) {
|
|
3463
3473
|
if (!t || typeof t != "object")
|
|
3464
3474
|
return !1;
|
|
3465
3475
|
const e = t, s = e.event;
|
|
3466
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
3476
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && Qe(s) && s.type === "tool.result";
|
|
3467
3477
|
}
|
|
3468
|
-
function
|
|
3478
|
+
function Pr(t, e) {
|
|
3469
3479
|
const s = new Set(
|
|
3470
3480
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3471
3481
|
);
|
|
@@ -3474,26 +3484,26 @@ function Ur(t, e) {
|
|
|
3474
3484
|
...e.filter((n) => !s.has(n.callId))
|
|
3475
3485
|
];
|
|
3476
3486
|
}
|
|
3477
|
-
function
|
|
3487
|
+
function Dr(t) {
|
|
3478
3488
|
try {
|
|
3479
|
-
window.sessionStorage.removeItem(`${
|
|
3489
|
+
window.sessionStorage.removeItem(`${pe}${t}`);
|
|
3480
3490
|
} catch {
|
|
3481
3491
|
return;
|
|
3482
3492
|
}
|
|
3483
3493
|
}
|
|
3484
|
-
function
|
|
3494
|
+
function Qe(t) {
|
|
3485
3495
|
if (!t || typeof t != "object")
|
|
3486
3496
|
return !1;
|
|
3487
3497
|
const e = t;
|
|
3488
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
3498
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && Ct(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Ct(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
|
|
3489
3499
|
}
|
|
3490
|
-
function
|
|
3500
|
+
function Ct(t) {
|
|
3491
3501
|
if (!t || typeof t != "object")
|
|
3492
3502
|
return !1;
|
|
3493
3503
|
const e = t;
|
|
3494
3504
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
3495
3505
|
}
|
|
3496
|
-
function
|
|
3506
|
+
function Xt(t, e) {
|
|
3497
3507
|
if (!Array.isArray(t))
|
|
3498
3508
|
return;
|
|
3499
3509
|
const s = t.filter((r) => {
|
|
@@ -3501,33 +3511,33 @@ function Gt(t, e) {
|
|
|
3501
3511
|
return !1;
|
|
3502
3512
|
const i = r;
|
|
3503
3513
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3504
|
-
}), n = e ? s.map((r) =>
|
|
3514
|
+
}), n = e ? s.map((r) => Jt(r, e)) : s;
|
|
3505
3515
|
return n.length > 0 ? n : void 0;
|
|
3506
3516
|
}
|
|
3507
|
-
function
|
|
3517
|
+
function Jt(t, e) {
|
|
3508
3518
|
return t.fileUrl?.startsWith("/") ? {
|
|
3509
3519
|
...t,
|
|
3510
3520
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
3511
3521
|
} : t;
|
|
3512
3522
|
}
|
|
3513
|
-
function
|
|
3523
|
+
function ze(t) {
|
|
3514
3524
|
return t.type || Or(t.name) || "application/octet-stream";
|
|
3515
3525
|
}
|
|
3516
|
-
function
|
|
3517
|
-
|
|
3526
|
+
function vr(t) {
|
|
3527
|
+
Vt({
|
|
3518
3528
|
name: t.name,
|
|
3519
|
-
mimeType:
|
|
3529
|
+
mimeType: ze(t),
|
|
3520
3530
|
sizeBytes: t.size
|
|
3521
3531
|
});
|
|
3522
3532
|
}
|
|
3523
|
-
function
|
|
3524
|
-
const e =
|
|
3525
|
-
if (!
|
|
3533
|
+
function Vt(t) {
|
|
3534
|
+
const e = Nr(t.name), s = t.mimeType.trim().toLowerCase();
|
|
3535
|
+
if (!Gs.has(`${e}:${s}`))
|
|
3526
3536
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
3527
|
-
if (t.sizeBytes <= 0 || t.sizeBytes >=
|
|
3537
|
+
if (t.sizeBytes <= 0 || t.sizeBytes >= vt)
|
|
3528
3538
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
3529
3539
|
}
|
|
3530
|
-
function
|
|
3540
|
+
function Nr(t) {
|
|
3531
3541
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
3532
3542
|
return s >= 0 ? e.slice(s) : "";
|
|
3533
3543
|
}
|
|
@@ -3535,7 +3545,7 @@ function Or(t) {
|
|
|
3535
3545
|
const e = t.toLowerCase();
|
|
3536
3546
|
return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
|
|
3537
3547
|
}
|
|
3538
|
-
function
|
|
3548
|
+
function xr(t) {
|
|
3539
3549
|
if (!t || typeof t != "object")
|
|
3540
3550
|
return null;
|
|
3541
3551
|
const e = t;
|
|
@@ -3552,17 +3562,17 @@ function Nr(t) {
|
|
|
3552
3562
|
dataType: typeof e.dataType == "string" ? e.dataType : void 0,
|
|
3553
3563
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
3554
3564
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
3555
|
-
attachments:
|
|
3565
|
+
attachments: Xt(e.attachments)?.map(Ze),
|
|
3556
3566
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
3557
3567
|
};
|
|
3558
3568
|
}
|
|
3559
|
-
function
|
|
3569
|
+
function Lr(t) {
|
|
3560
3570
|
return t.attachments?.length ? {
|
|
3561
3571
|
...t,
|
|
3562
|
-
attachments: t.attachments.map(
|
|
3572
|
+
attachments: t.attachments.map(Ze)
|
|
3563
3573
|
} : t;
|
|
3564
3574
|
}
|
|
3565
|
-
function
|
|
3575
|
+
function Ze(t) {
|
|
3566
3576
|
const {
|
|
3567
3577
|
dataUrl: e,
|
|
3568
3578
|
objectUrl: s,
|
|
@@ -3579,39 +3589,39 @@ function k(t) {
|
|
|
3579
3589
|
const e = t.runId;
|
|
3580
3590
|
return typeof e == "string" && e ? e : null;
|
|
3581
3591
|
}
|
|
3582
|
-
function
|
|
3592
|
+
function qr(t) {
|
|
3583
3593
|
const e = t?.timeoutMs;
|
|
3584
|
-
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <=
|
|
3594
|
+
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= on);
|
|
3585
3595
|
}
|
|
3586
|
-
function
|
|
3596
|
+
function Yt(t) {
|
|
3587
3597
|
const e = {};
|
|
3588
3598
|
try {
|
|
3589
3599
|
new Headers(t).forEach((s, n) => {
|
|
3590
|
-
Object.keys(e).length <
|
|
3600
|
+
Object.keys(e).length < Ve && (e[n] = et(n, s));
|
|
3591
3601
|
});
|
|
3592
3602
|
} catch {
|
|
3593
3603
|
return {};
|
|
3594
3604
|
}
|
|
3595
3605
|
return e;
|
|
3596
3606
|
}
|
|
3597
|
-
function
|
|
3598
|
-
return
|
|
3607
|
+
function et(t, e) {
|
|
3608
|
+
return ns(t) ? fe : P(he(e), Xs);
|
|
3599
3609
|
}
|
|
3600
3610
|
function Br(t, e) {
|
|
3601
3611
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
3602
3612
|
}
|
|
3603
|
-
async function
|
|
3604
|
-
const r =
|
|
3613
|
+
async function Hr(t, e, s, n) {
|
|
3614
|
+
const r = Yt(t.headers);
|
|
3605
3615
|
n({
|
|
3606
3616
|
...e,
|
|
3607
3617
|
responseStatus: t.status,
|
|
3608
3618
|
responseHeaders: r,
|
|
3609
|
-
responseBody: await
|
|
3619
|
+
responseBody: await Wr(t),
|
|
3610
3620
|
durationMs: Date.now() - s
|
|
3611
3621
|
});
|
|
3612
3622
|
}
|
|
3613
|
-
async function
|
|
3614
|
-
if (!
|
|
3623
|
+
async function Wr(t) {
|
|
3624
|
+
if (!Qt(t.headers))
|
|
3615
3625
|
return;
|
|
3616
3626
|
let e = null, s = null;
|
|
3617
3627
|
try {
|
|
@@ -3620,7 +3630,7 @@ async function Hr(t) {
|
|
|
3620
3630
|
const n = new Promise((a) => {
|
|
3621
3631
|
s = window.setTimeout(() => {
|
|
3622
3632
|
e?.cancel(), a("timeout");
|
|
3623
|
-
},
|
|
3633
|
+
}, Js);
|
|
3624
3634
|
}), r = new TextDecoder();
|
|
3625
3635
|
let i = "", o = 0;
|
|
3626
3636
|
for (; ; ) {
|
|
@@ -3630,7 +3640,7 @@ async function Hr(t) {
|
|
|
3630
3640
|
const { done: l, value: c } = a;
|
|
3631
3641
|
if (l)
|
|
3632
3642
|
return P(i + r.decode());
|
|
3633
|
-
const h =
|
|
3643
|
+
const h = Je - o;
|
|
3634
3644
|
if (c.byteLength > h)
|
|
3635
3645
|
return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${P(i)}... [truncated]`;
|
|
3636
3646
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
@@ -3642,45 +3652,45 @@ async function Hr(t) {
|
|
|
3642
3652
|
s !== null && window.clearTimeout(s);
|
|
3643
3653
|
}
|
|
3644
3654
|
}
|
|
3645
|
-
function
|
|
3646
|
-
if (
|
|
3655
|
+
function jr(t, e) {
|
|
3656
|
+
if (Qt(new Headers(e)))
|
|
3647
3657
|
try {
|
|
3648
3658
|
return t.responseType === "" || t.responseType === "text" ? P(t.responseText ?? "") : void 0;
|
|
3649
3659
|
} catch {
|
|
3650
3660
|
return;
|
|
3651
3661
|
}
|
|
3652
3662
|
}
|
|
3653
|
-
function
|
|
3663
|
+
function kt(t) {
|
|
3654
3664
|
if (typeof t == "string")
|
|
3655
3665
|
return P(t);
|
|
3656
3666
|
}
|
|
3657
|
-
function
|
|
3667
|
+
function Fr(t) {
|
|
3658
3668
|
return _({
|
|
3659
3669
|
...t,
|
|
3660
|
-
requestBody:
|
|
3661
|
-
responseBody:
|
|
3670
|
+
requestBody: _t(t.requestBody),
|
|
3671
|
+
responseBody: _t(t.responseBody)
|
|
3662
3672
|
});
|
|
3663
3673
|
}
|
|
3664
|
-
function
|
|
3674
|
+
function _t(t) {
|
|
3665
3675
|
if (typeof t != "string")
|
|
3666
3676
|
return t;
|
|
3667
3677
|
const e = t.trim();
|
|
3668
3678
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
3669
|
-
return
|
|
3679
|
+
return he(t);
|
|
3670
3680
|
try {
|
|
3671
3681
|
return JSON.stringify(_(JSON.parse(t)));
|
|
3672
3682
|
} catch {
|
|
3673
|
-
return
|
|
3683
|
+
return he(t);
|
|
3674
3684
|
}
|
|
3675
3685
|
}
|
|
3676
|
-
function
|
|
3686
|
+
function Qt(t) {
|
|
3677
3687
|
if (!t)
|
|
3678
3688
|
return !1;
|
|
3679
3689
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
3680
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3690
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= Je && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
3681
3691
|
}
|
|
3682
|
-
function
|
|
3683
|
-
if (
|
|
3692
|
+
function q(t, e = {}, s) {
|
|
3693
|
+
if (zr(s))
|
|
3684
3694
|
return !0;
|
|
3685
3695
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3686
3696
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3695,8 +3705,8 @@ function L(t, e = {}, s) {
|
|
|
3695
3705
|
return !0;
|
|
3696
3706
|
}
|
|
3697
3707
|
}
|
|
3698
|
-
function
|
|
3699
|
-
if (
|
|
3708
|
+
function $r(t, e) {
|
|
3709
|
+
if (q(t))
|
|
3700
3710
|
return !0;
|
|
3701
3711
|
try {
|
|
3702
3712
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -3705,117 +3715,117 @@ function Fr(t, e) {
|
|
|
3705
3715
|
return !0;
|
|
3706
3716
|
}
|
|
3707
3717
|
}
|
|
3708
|
-
function
|
|
3718
|
+
function zr(t) {
|
|
3709
3719
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
3710
3720
|
}
|
|
3711
|
-
function
|
|
3721
|
+
function Kr(t) {
|
|
3712
3722
|
const e = {};
|
|
3713
3723
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
3714
3724
|
const n = s.indexOf(":");
|
|
3715
3725
|
if (n <= 0)
|
|
3716
3726
|
continue;
|
|
3717
|
-
if (Object.keys(e).length >=
|
|
3727
|
+
if (Object.keys(e).length >= Ve)
|
|
3718
3728
|
break;
|
|
3719
3729
|
const r = s.slice(0, n).trim();
|
|
3720
|
-
e[r] =
|
|
3730
|
+
e[r] = et(r, s.slice(n + 1).trim());
|
|
3721
3731
|
}
|
|
3722
3732
|
return e;
|
|
3723
3733
|
}
|
|
3724
|
-
function P(t, e =
|
|
3734
|
+
function P(t, e = Je) {
|
|
3725
3735
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
3726
3736
|
}
|
|
3727
3737
|
function Oe(t) {
|
|
3728
3738
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3729
3739
|
}
|
|
3730
|
-
class
|
|
3740
|
+
class ue extends Error {
|
|
3731
3741
|
constructor(e, s) {
|
|
3732
3742
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
3733
3743
|
}
|
|
3734
3744
|
status;
|
|
3735
3745
|
}
|
|
3736
|
-
async function
|
|
3746
|
+
async function ae(t, e) {
|
|
3737
3747
|
let s = null;
|
|
3738
|
-
for (let n = 0; n <
|
|
3748
|
+
for (let n = 0; n < It; n += 1)
|
|
3739
3749
|
try {
|
|
3740
3750
|
return await t();
|
|
3741
3751
|
} catch (r) {
|
|
3742
|
-
if (s = r, n >=
|
|
3752
|
+
if (s = r, n >= It - 1 || !Xr(r))
|
|
3743
3753
|
throw r;
|
|
3744
|
-
await
|
|
3754
|
+
await Gr(n);
|
|
3745
3755
|
}
|
|
3746
3756
|
throw s instanceof Error ? s : new Error(e);
|
|
3747
3757
|
}
|
|
3748
|
-
function
|
|
3758
|
+
function Gr(t) {
|
|
3749
3759
|
return new Promise((e) => {
|
|
3750
|
-
window.setTimeout(e,
|
|
3760
|
+
window.setTimeout(e, Ks[t] ?? 0);
|
|
3751
3761
|
});
|
|
3752
3762
|
}
|
|
3753
|
-
function Gr(t) {
|
|
3754
|
-
return t instanceof ce ? Xr(t.status) : t instanceof TypeError;
|
|
3755
|
-
}
|
|
3756
3763
|
function Xr(t) {
|
|
3757
|
-
return t
|
|
3764
|
+
return t instanceof ue ? Jr(t.status) : t instanceof TypeError;
|
|
3758
3765
|
}
|
|
3759
3766
|
function Jr(t) {
|
|
3767
|
+
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
3768
|
+
}
|
|
3769
|
+
function Vr(t) {
|
|
3760
3770
|
return t === 401 || t === 403;
|
|
3761
3771
|
}
|
|
3762
|
-
const
|
|
3772
|
+
const fe = "[REDACTED_SECRET]", D = "[REDACTED_TOKEN]", Yr = "[REDACTED_SIGNED_URL]", Qr = 20, Zr = /^(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, Zt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, es = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ts = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ss = /\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, ei = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, ti = /\bhttps?:\/\/[^\s"'<>]+/gi, si = /[),.;\]]+$/;
|
|
3763
3773
|
function _(t) {
|
|
3764
|
-
return
|
|
3774
|
+
return de(t, 0, /* @__PURE__ */ new WeakSet());
|
|
3765
3775
|
}
|
|
3766
|
-
function
|
|
3776
|
+
function de(t, e, s) {
|
|
3767
3777
|
if (typeof t == "string")
|
|
3768
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
3778
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : he(t);
|
|
3769
3779
|
if (t === null || typeof t != "object")
|
|
3770
3780
|
return t;
|
|
3771
|
-
if (e >=
|
|
3781
|
+
if (e >= Qr)
|
|
3772
3782
|
return "[REDACTED_MAX_DEPTH]";
|
|
3773
3783
|
if (s.has(t))
|
|
3774
3784
|
return "[REDACTED_CIRCULAR]";
|
|
3775
3785
|
if (s.add(t), Array.isArray(t))
|
|
3776
|
-
return t.map((r) =>
|
|
3786
|
+
return t.map((r) => de(r, e + 1, s));
|
|
3777
3787
|
const n = {};
|
|
3778
3788
|
for (const [r, i] of Object.entries(t))
|
|
3779
|
-
r === "pageContent" ? n[r] = i :
|
|
3789
|
+
r === "pageContent" ? n[r] = i : ns(r) ? n[r] = fe : n[r] = r.toLowerCase() === "url" ? ni(i) : de(i, e + 1, s);
|
|
3780
3790
|
return n;
|
|
3781
3791
|
}
|
|
3782
|
-
function
|
|
3792
|
+
function ns(t) {
|
|
3783
3793
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3784
3794
|
return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
|
|
3785
3795
|
}
|
|
3786
|
-
function
|
|
3787
|
-
return typeof t == "string" ?
|
|
3796
|
+
function ni(t) {
|
|
3797
|
+
return typeof t == "string" ? rs(t) : de(t, 0, /* @__PURE__ */ new WeakSet());
|
|
3788
3798
|
}
|
|
3789
|
-
function
|
|
3799
|
+
function rs(t) {
|
|
3790
3800
|
try {
|
|
3791
3801
|
const e = new URL(t, location.href);
|
|
3792
3802
|
for (const s of Array.from(e.searchParams.keys()))
|
|
3793
|
-
|
|
3803
|
+
Zr.test(s) && e.searchParams.set(s, D);
|
|
3794
3804
|
return e.username && (e.username = D), e.password && (e.password = D), e.toString();
|
|
3795
3805
|
} catch {
|
|
3796
|
-
return
|
|
3806
|
+
return ri(t);
|
|
3797
3807
|
}
|
|
3798
3808
|
}
|
|
3799
|
-
function
|
|
3800
|
-
return t.replace(
|
|
3801
|
-
}
|
|
3802
|
-
function ni(t) {
|
|
3803
|
-
return t.replace(Qt, `Bearer ${D}`).replace(Zt, `Basic ${D}`).replace(es, D).replace(ts, (e, s) => `${s}: ${ge}`);
|
|
3809
|
+
function he(t) {
|
|
3810
|
+
return t.replace(ei, Yr).replace(ti, ii).replace(Zt, `Bearer ${D}`).replace(es, `Basic ${D}`).replace(ts, D).replace(ss, (e, s) => `${s}: ${fe}`);
|
|
3804
3811
|
}
|
|
3805
3812
|
function ri(t) {
|
|
3806
|
-
|
|
3807
|
-
|
|
3813
|
+
return t.replace(Zt, `Bearer ${D}`).replace(es, `Basic ${D}`).replace(ts, D).replace(ss, (e, s) => `${s}: ${fe}`);
|
|
3814
|
+
}
|
|
3815
|
+
function ii(t) {
|
|
3816
|
+
const e = t.match(si)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
3817
|
+
return `${rs(s)}${e}`;
|
|
3808
3818
|
}
|
|
3809
3819
|
export {
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3820
|
+
ut as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3821
|
+
Le as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3822
|
+
_s as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3823
|
+
ks as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3824
|
+
Us as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3825
|
+
oi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
3826
|
+
xt as PlunoProductAgent,
|
|
3827
|
+
Qs as calculateReconnectDelay,
|
|
3828
|
+
xt as default,
|
|
3829
|
+
Mn as getProductAgentOriginAccessErrorMessage,
|
|
3830
|
+
vr as validateProductAgentProviderInputFile
|
|
3821
3831
|
};
|