@pluno/product-agent-web 0.1.94 → 0.1.96
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/product-agent-sdk.js +569 -533
- package/dist/product-agent-widget.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
1
|
+
const oe = "pluno-product-agent-attachments";
|
|
2
2
|
const st = "files";
|
|
3
|
-
async function
|
|
3
|
+
async function Bt(e) {
|
|
4
4
|
const t = await $();
|
|
5
|
-
await
|
|
5
|
+
await xt(t, "readwrite", (s) => s.put(e));
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
8
|
-
const t = await $(), s = await
|
|
7
|
+
async function ae(e) {
|
|
8
|
+
const t = await $(), s = await xt(
|
|
9
9
|
t,
|
|
10
10
|
"readonly",
|
|
11
11
|
(r) => r.get(e)
|
|
@@ -13,12 +13,12 @@ async function ie(e) {
|
|
|
13
13
|
if (!s)
|
|
14
14
|
return null;
|
|
15
15
|
const n = Date.now();
|
|
16
|
-
return await
|
|
16
|
+
return await qt(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
|
|
17
17
|
}
|
|
18
|
-
async function
|
|
18
|
+
async function qt(e, t) {
|
|
19
19
|
const s = await $();
|
|
20
|
-
await
|
|
21
|
-
const r = await
|
|
20
|
+
await dt(s, "readwrite", async (n) => {
|
|
21
|
+
const r = await ht(
|
|
22
22
|
n.get(e)
|
|
23
23
|
);
|
|
24
24
|
r && n.put({
|
|
@@ -27,31 +27,31 @@ async function Lt(e, t) {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
30
|
+
async function ce(e = 864e5) {
|
|
31
31
|
const t = await $(), s = Date.now() - e;
|
|
32
|
-
await
|
|
32
|
+
await dt(t, "readwrite", async (n) => {
|
|
33
33
|
const r = n.index("lastUsedAt");
|
|
34
|
-
(await
|
|
34
|
+
(await ht(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
function $() {
|
|
38
38
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
39
|
-
const s = indexedDB.open(
|
|
39
|
+
const s = indexedDB.open(oe, 1);
|
|
40
40
|
s.onupgradeneeded = () => {
|
|
41
41
|
const r = s.result.createObjectStore(st, { keyPath: "attachmentId" });
|
|
42
42
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
43
43
|
}, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
async function
|
|
47
|
-
return await
|
|
46
|
+
async function xt(e, t, s) {
|
|
47
|
+
return await dt(e, t, async (n) => await ht(s(n)));
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function dt(e, t, s) {
|
|
50
50
|
return new Promise((n, r) => {
|
|
51
51
|
const i = e.transaction(st, t), o = i.objectStore(st);
|
|
52
|
-
let
|
|
52
|
+
let c, u = !1;
|
|
53
53
|
s(o).then((l) => {
|
|
54
|
-
|
|
54
|
+
c = l;
|
|
55
55
|
}).catch((l) => {
|
|
56
56
|
u = !0;
|
|
57
57
|
try {
|
|
@@ -60,7 +60,7 @@ function ut(e, t, s) {
|
|
|
60
60
|
}
|
|
61
61
|
r(l);
|
|
62
62
|
}), i.oncomplete = () => {
|
|
63
|
-
u || n(
|
|
63
|
+
u || n(c);
|
|
64
64
|
}, i.onerror = () => {
|
|
65
65
|
u || (u = !0, r(i.error ?? new Error("Product Agent attachment storage transaction failed")));
|
|
66
66
|
}, i.onabort = () => {
|
|
@@ -68,16 +68,16 @@ function ut(e, t, s) {
|
|
|
68
68
|
};
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function ht(e) {
|
|
72
72
|
return new Promise((t, s) => {
|
|
73
73
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function le(e) {
|
|
77
77
|
return e !== null && (typeof e == "object" || typeof e == "function");
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
const n = Reflect.get(e, "pluno"), r =
|
|
79
|
+
function Ft(e, t, s) {
|
|
80
|
+
const n = Reflect.get(e, "pluno"), r = le(n) ? n : {};
|
|
81
81
|
if (r !== n && !Reflect.set(e, "pluno", r))
|
|
82
82
|
return null;
|
|
83
83
|
const i = Object.getOwnPropertyDescriptor(r, t);
|
|
@@ -91,8 +91,8 @@ function qt(e, t, s) {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
const H = "pluno.productAgent.scheduledChatContinuation.", nt = "pluno:scheduled-chat-continuation-changed",
|
|
95
|
-
function
|
|
94
|
+
const H = "pluno.productAgent.scheduledChatContinuation.", nt = "pluno:scheduled-chat-continuation-changed", Ht = 10080 * 6e4, ue = 5e3, de = 15e3;
|
|
95
|
+
function he(e, {
|
|
96
96
|
clientId: t,
|
|
97
97
|
sessionId: s,
|
|
98
98
|
callId: n
|
|
@@ -103,7 +103,7 @@ function ue(e, {
|
|
|
103
103
|
clientId: t,
|
|
104
104
|
sessionId: s,
|
|
105
105
|
defaultTaskId: `scheduled-${n}`,
|
|
106
|
-
expiresAfterDueMs:
|
|
106
|
+
expiresAfterDueMs: Ht
|
|
107
107
|
})});
|
|
108
108
|
const scheduleQuery = (query, delaySeconds) => {
|
|
109
109
|
if (typeof query !== "string" || query.trim().length === 0) {
|
|
@@ -132,16 +132,16 @@ const scheduleQuery = (query, delaySeconds) => {
|
|
|
132
132
|
};
|
|
133
133
|
${e}`;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
const t = e.storage === void 0 ?
|
|
135
|
+
function pe(e) {
|
|
136
|
+
const t = e.storage === void 0 ? fe() : e.storage;
|
|
137
137
|
let s = null, n = !1, r = !1, i = !1, o = t !== null;
|
|
138
|
-
const
|
|
138
|
+
const c = /* @__PURE__ */ new Map(), u = () => {
|
|
139
139
|
s !== null && (clearTimeout(s), s = null);
|
|
140
140
|
}, l = () => {
|
|
141
141
|
u(), !(i || !o) && (s = setTimeout(() => {
|
|
142
142
|
s = null, h();
|
|
143
|
-
},
|
|
144
|
-
},
|
|
143
|
+
}, ue));
|
|
144
|
+
}, a = () => {
|
|
145
145
|
o = !1, u();
|
|
146
146
|
}, h = async () => {
|
|
147
147
|
if (!(i || !o || !t)) {
|
|
@@ -151,53 +151,53 @@ function de(e) {
|
|
|
151
151
|
}
|
|
152
152
|
n = !0;
|
|
153
153
|
try {
|
|
154
|
-
const
|
|
155
|
-
for (const [
|
|
156
|
-
A <=
|
|
154
|
+
const f = Date.now();
|
|
155
|
+
for (const [g, A] of c)
|
|
156
|
+
A <= f && c.delete(g);
|
|
157
157
|
const w = await t.list(), m = [];
|
|
158
|
-
for (const
|
|
159
|
-
if (!
|
|
160
|
-
const A =
|
|
158
|
+
for (const g of w) {
|
|
159
|
+
if (!D(g)) {
|
|
160
|
+
const A = g && typeof g == "object" ? g.id : null;
|
|
161
161
|
typeof A == "string" && await t.remove(A);
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
if (
|
|
165
|
-
await t.remove(
|
|
164
|
+
if (g.expiresAt <= f) {
|
|
165
|
+
await t.remove(g.id), c.delete(g.id);
|
|
166
166
|
continue;
|
|
167
167
|
}
|
|
168
|
-
m.push(
|
|
168
|
+
m.push(g);
|
|
169
169
|
}
|
|
170
170
|
e.onTasksChanged?.(m);
|
|
171
|
-
for (const
|
|
172
|
-
if (!(
|
|
173
|
-
|
|
171
|
+
for (const g of m)
|
|
172
|
+
if (!(g.clientId !== e.clientId || g.dueAt > f || c.has(g.id) || !await e.canDeliver(g))) {
|
|
173
|
+
c.set(g.id, f + de);
|
|
174
174
|
try {
|
|
175
|
-
await e.deliver(
|
|
175
|
+
await e.deliver(g);
|
|
176
176
|
} catch {
|
|
177
|
-
|
|
177
|
+
c.delete(g.id);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
} catch {
|
|
181
|
-
|
|
181
|
+
a();
|
|
182
182
|
} finally {
|
|
183
183
|
n = !1, r ? (r = !1, h()) : l();
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
}, T = async (
|
|
187
|
-
if (i || !o || !t || !
|
|
186
|
+
}, T = async (f) => {
|
|
187
|
+
if (i || !o || !t || !D(f))
|
|
188
188
|
return !1;
|
|
189
189
|
try {
|
|
190
|
-
return await t.set(
|
|
190
|
+
return await t.set(f), e.onTasksChanged?.((await t.list()).filter(D)), await h(), !0;
|
|
191
191
|
} catch {
|
|
192
|
-
return
|
|
192
|
+
return a(), !1;
|
|
193
193
|
}
|
|
194
|
-
}, p = async (
|
|
195
|
-
if (
|
|
194
|
+
}, p = async (f) => {
|
|
195
|
+
if (c.delete(f), i || !o || !t)
|
|
196
196
|
return !1;
|
|
197
197
|
try {
|
|
198
|
-
return await t.remove(
|
|
198
|
+
return await t.remove(f), e.onTasksChanged?.((await t.list()).filter(D)), !0;
|
|
199
199
|
} catch {
|
|
200
|
-
return
|
|
200
|
+
return a(), !1;
|
|
201
201
|
}
|
|
202
202
|
}, d = t?.subscribe?.(() => {
|
|
203
203
|
h();
|
|
@@ -208,17 +208,17 @@ function de(e) {
|
|
|
208
208
|
acknowledgeTask: p,
|
|
209
209
|
isAvailable: () => o,
|
|
210
210
|
destroy() {
|
|
211
|
-
i = !0, u(), d?.(),
|
|
211
|
+
i = !0, u(), d?.(), c.clear();
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function D(e) {
|
|
216
216
|
if (!e || typeof e != "object")
|
|
217
217
|
return !1;
|
|
218
218
|
const t = e;
|
|
219
|
-
return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt +
|
|
219
|
+
return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt + Ht;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function fe() {
|
|
222
222
|
let e;
|
|
223
223
|
try {
|
|
224
224
|
e = window.localStorage, e.length;
|
|
@@ -236,7 +236,7 @@ function he() {
|
|
|
236
236
|
if (r)
|
|
237
237
|
try {
|
|
238
238
|
const i = JSON.parse(r);
|
|
239
|
-
|
|
239
|
+
D(i) && n === J(i.id) ? t.push(i) : (e.removeItem(n), s -= 1);
|
|
240
240
|
} catch {
|
|
241
241
|
e.removeItem(n), s -= 1;
|
|
242
242
|
}
|
|
@@ -262,11 +262,11 @@ function he() {
|
|
|
262
262
|
function J(e) {
|
|
263
263
|
return `${H}${e}`;
|
|
264
264
|
}
|
|
265
|
-
const
|
|
266
|
-
let
|
|
267
|
-
const
|
|
268
|
-
async function
|
|
269
|
-
const t = e.randomUUID(), s = e.storage.getItem(
|
|
265
|
+
const Y = "pluno.productAgent.transportId", ge = "pluno.productAgent.transportIdentity", V = "pluno.productAgent.transportIdentity.event", me = 50, ye = globalThis.setTimeout.bind(globalThis);
|
|
266
|
+
let P = null;
|
|
267
|
+
const q = /* @__PURE__ */ new Set();
|
|
268
|
+
async function Te(e = Wt()) {
|
|
269
|
+
const t = e.randomUUID(), s = e.storage.getItem(Y);
|
|
270
270
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
271
271
|
const o = e.channel.subscribe((u) => {
|
|
272
272
|
if (!(u.senderId === t || u.transportId !== n)) {
|
|
@@ -284,58 +284,58 @@ async function me(e = Ft()) {
|
|
|
284
284
|
}
|
|
285
285
|
});
|
|
286
286
|
if (!s)
|
|
287
|
-
e.storage.setItem(
|
|
287
|
+
e.storage.setItem(Y, n), r = !0;
|
|
288
288
|
else
|
|
289
289
|
for (; ; ) {
|
|
290
290
|
if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
|
|
291
291
|
r = !0;
|
|
292
292
|
break;
|
|
293
293
|
}
|
|
294
|
-
n = e.randomUUID(), e.storage.setItem(
|
|
294
|
+
n = e.randomUUID(), e.storage.setItem(Y, n);
|
|
295
295
|
}
|
|
296
|
-
let
|
|
296
|
+
let c = !1;
|
|
297
297
|
return {
|
|
298
298
|
transportId: n,
|
|
299
299
|
release: () => {
|
|
300
|
-
|
|
300
|
+
c || (c = !0, o(), e.channel.close());
|
|
301
301
|
}
|
|
302
302
|
};
|
|
303
303
|
}
|
|
304
|
-
async function
|
|
305
|
-
|
|
304
|
+
async function we() {
|
|
305
|
+
P || (P = Te(Wt()), P.then((n) => {
|
|
306
306
|
const r = (i) => {
|
|
307
|
-
i.persisted || (n.release(),
|
|
307
|
+
i.persisted || (n.release(), P = null, q.clear(), window.removeEventListener("pagehide", r));
|
|
308
308
|
};
|
|
309
309
|
window.addEventListener("pagehide", r);
|
|
310
310
|
}));
|
|
311
|
-
const e = await
|
|
312
|
-
|
|
311
|
+
const e = await P, t = Ie();
|
|
312
|
+
q.add(t);
|
|
313
313
|
let s = !1;
|
|
314
314
|
return {
|
|
315
315
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
316
316
|
transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
|
|
317
317
|
release: () => {
|
|
318
|
-
s || (s = !0,
|
|
318
|
+
s || (s = !0, q.delete(t));
|
|
319
319
|
}
|
|
320
320
|
};
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function Ie() {
|
|
323
323
|
let e = 0;
|
|
324
|
-
for (;
|
|
324
|
+
for (; q.has(e); )
|
|
325
325
|
e += 1;
|
|
326
326
|
return e;
|
|
327
327
|
}
|
|
328
|
-
function
|
|
328
|
+
function Wt() {
|
|
329
329
|
return {
|
|
330
330
|
storage: window.sessionStorage,
|
|
331
|
-
channel:
|
|
331
|
+
channel: Ae(),
|
|
332
332
|
randomUUID: () => crypto.randomUUID(),
|
|
333
|
-
settle: () => new Promise((e) =>
|
|
333
|
+
settle: () => new Promise((e) => ye(e, me))
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
|
-
function
|
|
336
|
+
function Ae() {
|
|
337
337
|
if (typeof BroadcastChannel < "u") {
|
|
338
|
-
const e = new BroadcastChannel(
|
|
338
|
+
const e = new BroadcastChannel(ge);
|
|
339
339
|
return {
|
|
340
340
|
postMessage: (t) => e.postMessage(t),
|
|
341
341
|
subscribe: (t) => {
|
|
@@ -345,11 +345,11 @@ function we() {
|
|
|
345
345
|
close: () => e.close()
|
|
346
346
|
};
|
|
347
347
|
}
|
|
348
|
-
return
|
|
348
|
+
return Se();
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function Se() {
|
|
351
351
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
352
|
-
if (s.key !==
|
|
352
|
+
if (s.key !== V || !s.newValue)
|
|
353
353
|
return;
|
|
354
354
|
const n = JSON.parse(s.newValue);
|
|
355
355
|
for (const r of e)
|
|
@@ -358,9 +358,9 @@ function Ie() {
|
|
|
358
358
|
return window.addEventListener("storage", t), {
|
|
359
359
|
postMessage: (s) => {
|
|
360
360
|
window.localStorage.setItem(
|
|
361
|
-
|
|
361
|
+
V,
|
|
362
362
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
363
|
-
), window.localStorage.removeItem(
|
|
363
|
+
), window.localStorage.removeItem(V);
|
|
364
364
|
},
|
|
365
365
|
subscribe: (s) => (e.add(s), () => e.delete(s)),
|
|
366
366
|
close: () => {
|
|
@@ -368,17 +368,18 @@ function Ie() {
|
|
|
368
368
|
}
|
|
369
369
|
};
|
|
370
370
|
}
|
|
371
|
-
const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]',
|
|
372
|
-
function
|
|
373
|
-
|
|
371
|
+
const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ke = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ee = ".pluno-pa-widget__panel", Re = ".pluno-pa-widget__timeline", At = `${rt}[data-pluno-sdk-preview-channel]`, _e = "https://app.pluno.ai", Ce = "gpt-5.6-terra", be = 2e4, Me = 1e4, Pe = 1e4, Ue = 1e4, De = 1e4, ve = 1e3, St = 3e4, kt = 0.2, Et = 6e4, Ne = 15e3, N = 8, Oe = 15e3, Le = 2e3, Be = 1e3, qe = 100, xe = 8e3, Fe = 15e3, Rt = 3, He = [300, 1e3], pt = 64e3, Z = 4e3, ft = 30, We = 2e3, je = 1e3, $e = 200 * 1024 * 1024, gt = "Image is too large for model vision input.", ze = 100, jt = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", Ge = 100;
|
|
372
|
+
function O(e, t = 0) {
|
|
373
|
+
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
374
|
+
return Math.max(t, s);
|
|
374
375
|
}
|
|
375
|
-
const
|
|
376
|
-
let
|
|
377
|
-
function
|
|
378
|
-
const s = Math.min(
|
|
379
|
-
return Math.min(
|
|
376
|
+
const x = /* @__PURE__ */ new Set();
|
|
377
|
+
let L = null;
|
|
378
|
+
function Xe(e, t = Math.random) {
|
|
379
|
+
const s = Math.min(St, ve * 2 ** e), n = 1 - kt + t() * kt * 2;
|
|
380
|
+
return Math.min(St, Math.round(s * n));
|
|
380
381
|
}
|
|
381
|
-
function
|
|
382
|
+
function Ke(e, t, s) {
|
|
382
383
|
return new Promise((n, r) => {
|
|
383
384
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
384
385
|
e.then(
|
|
@@ -391,13 +392,13 @@ function Ge(e, t, s) {
|
|
|
391
392
|
);
|
|
392
393
|
});
|
|
393
394
|
}
|
|
394
|
-
class
|
|
395
|
+
class $t {
|
|
395
396
|
constructor(t, s) {
|
|
396
397
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
397
398
|
...this.state,
|
|
398
|
-
starterPrompts:
|
|
399
|
+
starterPrompts: As(t.initialStarterPrompts)
|
|
399
400
|
};
|
|
400
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
401
|
+
const n = t.restorePersistedState === !1 ? null : Qs(t.clientId, t.expectedPersistedSessionId);
|
|
401
402
|
n && (this.state = {
|
|
402
403
|
...this.state,
|
|
403
404
|
...n,
|
|
@@ -408,10 +409,10 @@ class Wt {
|
|
|
408
409
|
assistantDraftRunId: null,
|
|
409
410
|
isThinking: !1,
|
|
410
411
|
lastError: null
|
|
411
|
-
}), this.queuedClientEvents =
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
),
|
|
412
|
+
}), this.queuedClientEvents = an(
|
|
413
|
+
en(t.clientId),
|
|
414
|
+
nn(t.clientId)
|
|
415
|
+
), U(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = pe({
|
|
415
416
|
clientId: t.clientId,
|
|
416
417
|
canDeliver: (r) => r.sessionId === this.state.sessionId,
|
|
417
418
|
deliver: async (r) => {
|
|
@@ -483,14 +484,14 @@ class Wt {
|
|
|
483
484
|
lastErrorCode: null
|
|
484
485
|
};
|
|
485
486
|
static async init(t) {
|
|
486
|
-
const s = await
|
|
487
|
+
const s = await we(), n = new $t({
|
|
487
488
|
...t,
|
|
488
|
-
backendUrl:
|
|
489
|
-
clientId: t.clientId ??
|
|
490
|
-
model: t.model ??
|
|
489
|
+
backendUrl: hs(t.backendUrl ?? _e),
|
|
490
|
+
clientId: t.clientId ?? _s(),
|
|
491
|
+
model: t.model ?? Ce
|
|
491
492
|
}, s);
|
|
492
493
|
try {
|
|
493
|
-
|
|
494
|
+
ce().catch((r) => {
|
|
494
495
|
y("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
495
496
|
message: r instanceof Error ? r.message : String(r)
|
|
496
497
|
});
|
|
@@ -522,14 +523,14 @@ class Wt {
|
|
|
522
523
|
lastError: null
|
|
523
524
|
});
|
|
524
525
|
try {
|
|
525
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
526
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ke(this.options.tokenProvider(), Pe, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
526
527
|
return;
|
|
527
528
|
if (!this.token && !this.options.webSocketFactory)
|
|
528
529
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
529
|
-
const s =
|
|
530
|
+
const s = fs(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
530
531
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
531
532
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (y("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
532
|
-
},
|
|
533
|
+
}, Ue), n.addEventListener("open", () => {
|
|
533
534
|
this.socket !== n || (this.clearSocketConnectTimer(), y("web-sdk.agent", "Pluno socket opened", {
|
|
534
535
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
535
536
|
isThinking: this.state.isThinking
|
|
@@ -541,9 +542,9 @@ class Wt {
|
|
|
541
542
|
pageUrl: location.href
|
|
542
543
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
543
544
|
this.socket === n && (y("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
544
|
-
},
|
|
545
|
+
}, De));
|
|
545
546
|
}), n.addEventListener("message", (r) => {
|
|
546
|
-
this.socket === n && this.handleServerEvent(
|
|
547
|
+
this.socket === n && this.handleServerEvent(Is(r.data));
|
|
547
548
|
}), n.addEventListener("close", (r) => {
|
|
548
549
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (y("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
549
550
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -576,23 +577,23 @@ class Wt {
|
|
|
576
577
|
this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
|
|
577
578
|
}
|
|
578
579
|
destroy() {
|
|
579
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(),
|
|
580
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), cn(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
580
581
|
for (const t of Object.values(this.listeners))
|
|
581
582
|
t?.clear();
|
|
582
583
|
}
|
|
583
584
|
sendMessage(t, s = {}) {
|
|
584
|
-
const n = t.trim(), r = s.attachments ?? [], i = r.map(
|
|
585
|
+
const n = t.trim(), r = s.attachments ?? [], i = r.map(wt);
|
|
585
586
|
if (!n && i.length === 0)
|
|
586
587
|
return null;
|
|
587
|
-
const o = S(),
|
|
588
|
+
const o = S(), c = s.clientMessageId ?? B();
|
|
588
589
|
this.retryableClientMessageId = null;
|
|
589
590
|
const u = {
|
|
590
|
-
id: `local-${
|
|
591
|
+
id: `local-${c}`,
|
|
591
592
|
role: "user",
|
|
592
593
|
content: n,
|
|
593
594
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
594
595
|
...r.length > 0 ? { attachments: r } : {}
|
|
595
|
-
}, l = this.state.messages.some((h) => h.id === u.id || h.clientMessageId ===
|
|
596
|
+
}, l = this.state.messages.some((h) => h.id === u.id || h.clientMessageId === c);
|
|
596
597
|
this.setState({
|
|
597
598
|
messages: l ? this.state.messages : [...this.state.messages, u],
|
|
598
599
|
...this.state.isThinking ? {} : {
|
|
@@ -603,33 +604,33 @@ class Wt {
|
|
|
603
604
|
isThinking: !0,
|
|
604
605
|
lastError: null
|
|
605
606
|
}), l || this.emit("message", u);
|
|
606
|
-
const
|
|
607
|
+
const a = {
|
|
607
608
|
type: "chat.user_message",
|
|
608
609
|
sessionId: this.state.sessionId ?? void 0,
|
|
609
|
-
clientMessageId:
|
|
610
|
+
clientMessageId: c,
|
|
610
611
|
initiatedBy: s.initiatedBy,
|
|
611
612
|
content: n,
|
|
612
613
|
attachments: i.length > 0 ? i : void 0,
|
|
613
614
|
page: o,
|
|
614
615
|
model: this.options.model,
|
|
615
|
-
metadata:
|
|
616
|
+
metadata: _t(this.options.metadata)
|
|
616
617
|
};
|
|
617
|
-
return this.activeClientMessageId =
|
|
618
|
+
return this.activeClientMessageId = c, this.activeUserMessageEvent = a, this.markThinkingProgress(), this.send(a), this.startBackgroundAttachmentUploads(c, i), c;
|
|
618
619
|
}
|
|
619
620
|
retryLastMessage() {
|
|
620
621
|
const t = this.state.sessionId, s = this.retryableClientMessageId;
|
|
621
622
|
return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
|
|
622
623
|
}
|
|
623
624
|
createLocalAttachment(t) {
|
|
624
|
-
const s =
|
|
625
|
+
const s = B(), n = {
|
|
625
626
|
id: s,
|
|
626
627
|
name: t.name || "attachment",
|
|
627
|
-
mimeType:
|
|
628
|
+
mimeType: Nt(t),
|
|
628
629
|
sizeBytes: t.size
|
|
629
630
|
};
|
|
630
631
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
631
632
|
const r = Date.now();
|
|
632
|
-
return
|
|
633
|
+
return Bt({
|
|
633
634
|
attachmentId: s,
|
|
634
635
|
name: n.name,
|
|
635
636
|
mimeType: n.mimeType,
|
|
@@ -652,7 +653,7 @@ class Wt {
|
|
|
652
653
|
return await this.uploadAttachmentForMessage({
|
|
653
654
|
file: t,
|
|
654
655
|
attachment: s,
|
|
655
|
-
clientMessageId:
|
|
656
|
+
clientMessageId: B(),
|
|
656
657
|
waitForSession: !1,
|
|
657
658
|
notifyCompletion: !1
|
|
658
659
|
});
|
|
@@ -684,17 +685,17 @@ class Wt {
|
|
|
684
685
|
waitForSession: r,
|
|
685
686
|
notifyCompletion: i
|
|
686
687
|
}) {
|
|
687
|
-
const o = r ? await this.waitForSessionId() : this.state.sessionId,
|
|
688
|
+
const o = r ? await this.waitForSessionId() : this.state.sessionId, c = Nt(t), u = {
|
|
688
689
|
sessionId: o ?? void 0,
|
|
689
690
|
attachmentId: s.id,
|
|
690
691
|
clientId: this.options.clientId,
|
|
691
692
|
transportId: this.transportIdentity.transportId,
|
|
692
693
|
name: t.name || "attachment",
|
|
693
|
-
mimeType:
|
|
694
|
+
mimeType: c,
|
|
694
695
|
sizeBytes: t.size,
|
|
695
696
|
page: S(),
|
|
696
697
|
model: this.options.model,
|
|
697
|
-
metadata:
|
|
698
|
+
metadata: _t(this.options.metadata)
|
|
698
699
|
}, l = this.options.prepareAttachmentUpload ? await et(
|
|
699
700
|
() => this.options.prepareAttachmentUpload(u),
|
|
700
701
|
"Failed to prepare attachment upload"
|
|
@@ -709,30 +710,30 @@ class Wt {
|
|
|
709
710
|
throw new F("Failed to upload attachment", h.status);
|
|
710
711
|
return h;
|
|
711
712
|
}, "Failed to upload attachment"), this.setState({ sessionId: l.sessionId });
|
|
712
|
-
const
|
|
713
|
-
return this.updateAttachmentInState(s.id,
|
|
713
|
+
const a = Vt(l.attachment, this.options.backendUrl);
|
|
714
|
+
return this.updateAttachmentInState(s.id, a), s.id && qt(s.id, {
|
|
714
715
|
sessionId: l.sessionId,
|
|
715
|
-
fileUrl:
|
|
716
|
-
gcsPath:
|
|
716
|
+
fileUrl: a.fileUrl,
|
|
717
|
+
gcsPath: a.gcsPath,
|
|
717
718
|
lastUsedAt: Date.now()
|
|
718
719
|
}).catch((h) => {
|
|
719
720
|
y("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
720
721
|
attachmentId: s.id,
|
|
721
|
-
name:
|
|
722
|
+
name: a.name,
|
|
722
723
|
message: h instanceof Error ? h.message : String(h)
|
|
723
724
|
});
|
|
724
|
-
}), i &&
|
|
725
|
+
}), i && a.gcsPath && this.send({
|
|
725
726
|
type: "attachment.upload_completed",
|
|
726
727
|
sessionId: l.sessionId,
|
|
727
728
|
clientMessageId: n,
|
|
728
|
-
attachment:
|
|
729
|
-
}),
|
|
729
|
+
attachment: a
|
|
730
|
+
}), a;
|
|
730
731
|
}
|
|
731
732
|
waitForSessionId() {
|
|
732
733
|
return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
|
|
733
734
|
const n = window.setTimeout(() => {
|
|
734
735
|
r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
|
|
735
|
-
},
|
|
736
|
+
}, Fe), r = this.on("state", (i) => {
|
|
736
737
|
i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
|
|
737
738
|
});
|
|
738
739
|
});
|
|
@@ -754,7 +755,7 @@ class Wt {
|
|
|
754
755
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
755
756
|
if (n.ok)
|
|
756
757
|
return await n.json();
|
|
757
|
-
if (
|
|
758
|
+
if (_n(n.status) && this.options.tokenProvider && !s) {
|
|
758
759
|
s = !0;
|
|
759
760
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
760
761
|
if (r.ok)
|
|
@@ -796,11 +797,11 @@ class Wt {
|
|
|
796
797
|
});
|
|
797
798
|
}
|
|
798
799
|
listSessions(t = {}) {
|
|
799
|
-
const s =
|
|
800
|
-
const
|
|
800
|
+
const s = B(), n = new Promise((i, o) => {
|
|
801
|
+
const c = window.setTimeout(() => {
|
|
801
802
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
802
|
-
},
|
|
803
|
-
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout:
|
|
803
|
+
}, xe);
|
|
804
|
+
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: c });
|
|
804
805
|
}), r = {
|
|
805
806
|
type: "sessions.list",
|
|
806
807
|
requestId: s,
|
|
@@ -830,7 +831,7 @@ class Wt {
|
|
|
830
831
|
});
|
|
831
832
|
}
|
|
832
833
|
send(t) {
|
|
833
|
-
this.sendNow(k(t)) || (this.queuedClientEvents.push(t),
|
|
834
|
+
this.sendNow(k(t)) || (this.queuedClientEvents.push(t), U(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
834
835
|
}
|
|
835
836
|
async getUploadToken() {
|
|
836
837
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -856,7 +857,7 @@ class Wt {
|
|
|
856
857
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
857
858
|
return;
|
|
858
859
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
859
|
-
const t =
|
|
860
|
+
const t = gs();
|
|
860
861
|
this.sendNow(
|
|
861
862
|
k({
|
|
862
863
|
type: "starter_prompts.page_context",
|
|
@@ -867,13 +868,13 @@ class Wt {
|
|
|
867
868
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
868
869
|
}
|
|
869
870
|
startStarterPromptUrlWatcher() {
|
|
870
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
871
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = ms(() => this.handleStarterPromptUrlChange()));
|
|
871
872
|
}
|
|
872
873
|
handleStarterPromptUrlChange() {
|
|
873
874
|
const t = location.href;
|
|
874
875
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
875
876
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
876
|
-
},
|
|
877
|
+
}, Ge));
|
|
877
878
|
}
|
|
878
879
|
refreshStarterPromptsForCurrentUrl() {
|
|
879
880
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -888,14 +889,14 @@ class Wt {
|
|
|
888
889
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
889
890
|
return;
|
|
890
891
|
const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
891
|
-
|
|
892
|
+
U(this.options.clientId, this.queuedClientEvents);
|
|
892
893
|
for (let s = 0; s < t.length; s += 1) {
|
|
893
894
|
const n = t[s];
|
|
894
895
|
if (!this.sendNow(k(n))) {
|
|
895
|
-
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)),
|
|
896
|
+
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), U(this.options.clientId, this.queuedClientEvents);
|
|
896
897
|
return;
|
|
897
898
|
}
|
|
898
|
-
|
|
899
|
+
U(this.options.clientId, this.queuedClientEvents);
|
|
899
900
|
}
|
|
900
901
|
}
|
|
901
902
|
handleServerEvent(t) {
|
|
@@ -907,19 +908,19 @@ class Wt {
|
|
|
907
908
|
this.clearHeartbeatAckTimer();
|
|
908
909
|
return;
|
|
909
910
|
}
|
|
910
|
-
if (
|
|
911
|
+
if (Ve(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
911
912
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
|
|
912
|
-
const s =
|
|
913
|
+
const s = Ss(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
913
914
|
y("web-sdk.agent", "Received auth.ok appearance", {
|
|
914
915
|
hasAppearance: n,
|
|
915
916
|
rawAppearance: t.appearance,
|
|
916
917
|
normalizedAppearance: s
|
|
917
|
-
}), this.runtimeHelperJavascript =
|
|
918
|
-
const r =
|
|
919
|
-
user:
|
|
918
|
+
}), this.runtimeHelperJavascript = ks(t.runtimeHelpers)?.javascript ?? null;
|
|
919
|
+
const r = bt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
|
|
920
|
+
user: Cs(t.user),
|
|
920
921
|
status: "connected"
|
|
921
922
|
};
|
|
922
|
-
(i || this.state.starterPrompts.length === 0) && (
|
|
923
|
+
(i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !Ts() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
923
924
|
type: "page.upsert",
|
|
924
925
|
sessionId: this.state.sessionId,
|
|
925
926
|
page: S(),
|
|
@@ -929,7 +930,7 @@ class Wt {
|
|
|
929
930
|
}
|
|
930
931
|
if (t.type === "starterPrompts.updated") {
|
|
931
932
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
932
|
-
starterPrompts:
|
|
933
|
+
starterPrompts: bt(t, "starterPrompts"),
|
|
933
934
|
starterPromptsLoading: !1
|
|
934
935
|
});
|
|
935
936
|
return;
|
|
@@ -937,41 +938,55 @@ class Wt {
|
|
|
937
938
|
if (t.type === "conversation.state") {
|
|
938
939
|
const s = Array.isArray(t.items) ? t.items : [];
|
|
939
940
|
this.rememberUserMessageClientMessageIds(s);
|
|
940
|
-
const n =
|
|
941
|
+
const n = js(s);
|
|
941
942
|
if (n) {
|
|
942
|
-
const
|
|
943
|
+
const a = $s(s, n);
|
|
943
944
|
this.retryAttemptsByClientMessageId[n] = Math.max(
|
|
944
945
|
this.retryAttemptsByClientMessageId[n] ?? 0,
|
|
945
|
-
|
|
946
|
+
a
|
|
946
947
|
);
|
|
947
948
|
}
|
|
948
|
-
const r =
|
|
949
|
+
const r = s.filter((a) => {
|
|
950
|
+
const h = v(a);
|
|
951
|
+
return !Pt(h) && (!n || !at(h));
|
|
952
|
+
}), i = Ls(
|
|
949
953
|
this.state.messages,
|
|
950
|
-
|
|
951
|
-
), o =
|
|
952
|
-
|
|
954
|
+
bs(r, this.options.backendUrl)
|
|
955
|
+
), o = Mt(i), c = s.some(
|
|
956
|
+
(a) => Dt(
|
|
957
|
+
v(a),
|
|
958
|
+
this.state.assistantDraft,
|
|
959
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
960
|
+
this.state.assistantDraftRunId
|
|
961
|
+
)
|
|
962
|
+
), u = o && (!this.state.assistantDraft || c);
|
|
963
|
+
if (!o && Ws(this.state.messages, s))
|
|
953
964
|
return;
|
|
954
|
-
const
|
|
955
|
-
if (this.latestRecoverableClientMessageId =
|
|
965
|
+
const l = u ? null : ct(s);
|
|
966
|
+
if (this.latestRecoverableClientMessageId = l, Fs(i) && this.clearRetryTimers(), this.setState({
|
|
956
967
|
sessionId: I(t.session, "id") ?? this.state.sessionId,
|
|
957
968
|
messages: i,
|
|
958
|
-
...
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
969
|
+
...u ? {
|
|
970
|
+
...c ? {
|
|
971
|
+
assistantDraft: "",
|
|
972
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
973
|
+
assistantDraftRunId: null
|
|
974
|
+
} : {},
|
|
975
|
+
isThinking: !1
|
|
976
|
+
} : l ? {
|
|
962
977
|
isThinking: !0,
|
|
963
978
|
lastError: null
|
|
964
979
|
} : {}
|
|
965
|
-
}),
|
|
966
|
-
const
|
|
967
|
-
|
|
980
|
+
}), u ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : l && (this.activeClientMessageId = l, this.markThinkingProgress()), n) {
|
|
981
|
+
const a = I(t.session, "id") ?? this.state.sessionId;
|
|
982
|
+
a && this.retryAfterInterruptedRun(a, n);
|
|
968
983
|
}
|
|
969
984
|
return;
|
|
970
985
|
}
|
|
971
986
|
if (t.type === "sessions.page") {
|
|
972
987
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
973
988
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
974
|
-
sessions:
|
|
989
|
+
sessions: Ms(t.sessions),
|
|
975
990
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
976
991
|
}));
|
|
977
992
|
return;
|
|
@@ -982,12 +997,12 @@ class Wt {
|
|
|
982
997
|
}
|
|
983
998
|
if (t.type === "session.item") {
|
|
984
999
|
this.rememberUserMessageClientMessageIds([t.item]);
|
|
985
|
-
const s =
|
|
986
|
-
if (
|
|
1000
|
+
const s = v(t.item);
|
|
1001
|
+
if (at(s)) {
|
|
987
1002
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
988
|
-
const r = I(t.item, "sessionId") ?? this.state.sessionId, i = s ?
|
|
989
|
-
if (r &&
|
|
990
|
-
this.retryAfterInterruptedRun(r,
|
|
1003
|
+
const r = I(t.item, "sessionId") ?? this.state.sessionId, i = s ? M(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, c = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1004
|
+
if (r && c) {
|
|
1005
|
+
this.retryAfterInterruptedRun(r, c);
|
|
991
1006
|
return;
|
|
992
1007
|
}
|
|
993
1008
|
if (r && i) {
|
|
@@ -995,19 +1010,23 @@ class Wt {
|
|
|
995
1010
|
return;
|
|
996
1011
|
}
|
|
997
1012
|
}
|
|
998
|
-
|
|
1013
|
+
if (Pt(s))
|
|
1014
|
+
return;
|
|
1015
|
+
const n = Gt(t.item, this.options.backendUrl);
|
|
999
1016
|
if (n) {
|
|
1000
1017
|
n.role === "assistant" && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1001
1018
|
const r = t.item.data;
|
|
1002
|
-
|
|
1003
|
-
const i =
|
|
1019
|
+
Gs(r) && this.clearRunAckResyncRetryTimer();
|
|
1020
|
+
const i = Os(this.state.messages, n), o = Mt(i), c = Dt(
|
|
1021
|
+
r,
|
|
1022
|
+
this.state.assistantDraft,
|
|
1023
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
1024
|
+
this.state.assistantDraftRunId
|
|
1025
|
+
), u = o && (!this.state.assistantDraft || c);
|
|
1004
1026
|
this.setState({
|
|
1005
1027
|
messages: i,
|
|
1006
|
-
assistantDraft:
|
|
1007
|
-
|
|
1008
|
-
assistantDraftRunId: n.role === "assistant" ? null : this.state.assistantDraftRunId,
|
|
1009
|
-
...o ? { assistantDraft: "", assistantDraftRespondsToUserMessageId: null, assistantDraftRunId: null, isThinking: !1 } : {}
|
|
1010
|
-
}), o && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
1028
|
+
...c ? { assistantDraft: "", assistantDraftRespondsToUserMessageId: null, assistantDraftRunId: null, isThinking: !1 } : u ? { isThinking: !1 } : {}
|
|
1029
|
+
}), u && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
1011
1030
|
}
|
|
1012
1031
|
return;
|
|
1013
1032
|
}
|
|
@@ -1052,13 +1071,13 @@ class Wt {
|
|
|
1052
1071
|
return;
|
|
1053
1072
|
}
|
|
1054
1073
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1055
|
-
const
|
|
1074
|
+
const c = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = ps(c.message);
|
|
1056
1075
|
u && console.error(u), this.setState({
|
|
1057
1076
|
status: "error",
|
|
1058
1077
|
isThinking: !1,
|
|
1059
|
-
lastError:
|
|
1078
|
+
lastError: c.message,
|
|
1060
1079
|
lastErrorCode: typeof t.code == "string" ? t.code : null
|
|
1061
|
-
}), this.clearThinkingWatchdog(), this.emit("error",
|
|
1080
|
+
}), this.clearThinkingWatchdog(), this.emit("error", c);
|
|
1062
1081
|
}
|
|
1063
1082
|
}
|
|
1064
1083
|
retryAfterRetryableError(t) {
|
|
@@ -1067,20 +1086,20 @@ class Wt {
|
|
|
1067
1086
|
return !1;
|
|
1068
1087
|
if (t.code === "run_still_active") {
|
|
1069
1088
|
if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
|
|
1070
|
-
const
|
|
1089
|
+
const c = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
|
|
1071
1090
|
this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
|
|
1072
1091
|
delete this.retryTimersByClientMessageId[n], this.resyncThinkingSession(), this.markThinkingProgress();
|
|
1073
|
-
},
|
|
1092
|
+
}, c);
|
|
1074
1093
|
}
|
|
1075
1094
|
return !0;
|
|
1076
1095
|
}
|
|
1077
1096
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1078
1097
|
return !0;
|
|
1079
1098
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1080
|
-
if (i >=
|
|
1099
|
+
if (i >= N)
|
|
1081
1100
|
return !1;
|
|
1082
1101
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1083
|
-
const o =
|
|
1102
|
+
const o = O(
|
|
1084
1103
|
i,
|
|
1085
1104
|
typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
|
|
1086
1105
|
);
|
|
@@ -1097,7 +1116,7 @@ class Wt {
|
|
|
1097
1116
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1098
1117
|
return;
|
|
1099
1118
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1100
|
-
if (n >=
|
|
1119
|
+
if (n >= N) {
|
|
1101
1120
|
this.retryableClientMessageId = s, this.setState({
|
|
1102
1121
|
isThinking: !1,
|
|
1103
1122
|
lastError: "Pluno could not finish this message. Try it again.",
|
|
@@ -1107,7 +1126,7 @@ class Wt {
|
|
|
1107
1126
|
}
|
|
1108
1127
|
this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
|
|
1109
1128
|
delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !0 });
|
|
1110
|
-
},
|
|
1129
|
+
}, O(n));
|
|
1111
1130
|
}
|
|
1112
1131
|
clearRetryTimers() {
|
|
1113
1132
|
for (const t of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1116,7 +1135,7 @@ class Wt {
|
|
|
1116
1135
|
}
|
|
1117
1136
|
rememberUserMessageClientMessageIds(t) {
|
|
1118
1137
|
for (const s of t) {
|
|
1119
|
-
const n = I(s, "id"), r =
|
|
1138
|
+
const n = I(s, "id"), r = v(s);
|
|
1120
1139
|
n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
|
|
1121
1140
|
}
|
|
1122
1141
|
}
|
|
@@ -1126,7 +1145,7 @@ class Wt {
|
|
|
1126
1145
|
this.pendingSessionHistoryRequests.clear();
|
|
1127
1146
|
}
|
|
1128
1147
|
markThinkingProgress() {
|
|
1129
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1148
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Et), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1130
1149
|
}
|
|
1131
1150
|
scheduleThinkingWatchdog(t) {
|
|
1132
1151
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1146,7 +1165,7 @@ class Wt {
|
|
|
1146
1165
|
scheduleRunAckWatchdog(t) {
|
|
1147
1166
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1148
1167
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1149
|
-
},
|
|
1168
|
+
}, Oe);
|
|
1150
1169
|
}
|
|
1151
1170
|
recoverMissedRunAck(t) {
|
|
1152
1171
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (y("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1157,7 +1176,7 @@ class Wt {
|
|
|
1157
1176
|
scheduleRunAckResyncRetry(t) {
|
|
1158
1177
|
this.clearRunAckResyncRetryTimer();
|
|
1159
1178
|
const s = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1160
|
-
s >=
|
|
1179
|
+
s >= N || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1161
1180
|
this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
|
|
1162
1181
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1163
1182
|
isThinking: !0,
|
|
@@ -1170,8 +1189,8 @@ class Wt {
|
|
|
1170
1189
|
sessionId: this.state.sessionId,
|
|
1171
1190
|
clientMessageId: t,
|
|
1172
1191
|
automatic: !0
|
|
1173
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1174
|
-
},
|
|
1192
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(Et)));
|
|
1193
|
+
}, O(s, Le)));
|
|
1175
1194
|
}
|
|
1176
1195
|
clearRunAckResyncRetryTimer() {
|
|
1177
1196
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1194,7 +1213,7 @@ class Wt {
|
|
|
1194
1213
|
return;
|
|
1195
1214
|
}
|
|
1196
1215
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1197
|
-
if (n >=
|
|
1216
|
+
if (n >= N) {
|
|
1198
1217
|
y("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1199
1218
|
sessionId: this.state.sessionId,
|
|
1200
1219
|
clientMessageId: t
|
|
@@ -1210,7 +1229,7 @@ class Wt {
|
|
|
1210
1229
|
sessionId: this.state.sessionId,
|
|
1211
1230
|
clientMessageId: t,
|
|
1212
1231
|
resyncAttempts: s + 1
|
|
1213
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1232
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ne);
|
|
1214
1233
|
return;
|
|
1215
1234
|
}
|
|
1216
1235
|
this.setState({
|
|
@@ -1228,7 +1247,7 @@ class Wt {
|
|
|
1228
1247
|
clientMessageId: t,
|
|
1229
1248
|
automatic: !0
|
|
1230
1249
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1231
|
-
},
|
|
1250
|
+
}, O(n)));
|
|
1232
1251
|
}
|
|
1233
1252
|
resyncThinkingSession() {
|
|
1234
1253
|
this.state.sessionId ? this.send({
|
|
@@ -1242,7 +1261,7 @@ class Wt {
|
|
|
1242
1261
|
const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = typeof t.summary == "string" ? t.summary : "Running browser tool", o = t.rawInput;
|
|
1243
1262
|
if (!s || !n || !r)
|
|
1244
1263
|
return;
|
|
1245
|
-
if (r !== "execute_code" || !
|
|
1264
|
+
if (r !== "execute_code" || !fn(o)) {
|
|
1246
1265
|
this.send({
|
|
1247
1266
|
type: "tool.result",
|
|
1248
1267
|
sessionId: s,
|
|
@@ -1258,7 +1277,7 @@ class Wt {
|
|
|
1258
1277
|
});
|
|
1259
1278
|
return;
|
|
1260
1279
|
}
|
|
1261
|
-
const
|
|
1280
|
+
const c = ts(this.state.messages);
|
|
1262
1281
|
this.activeBrowserToolCalls.set(n, {
|
|
1263
1282
|
event: {
|
|
1264
1283
|
type: "tool.result",
|
|
@@ -1272,19 +1291,19 @@ class Wt {
|
|
|
1272
1291
|
startedAtMs: Date.now(),
|
|
1273
1292
|
startedAtUrl: location.href,
|
|
1274
1293
|
startedAtOrigin: location.origin
|
|
1275
|
-
}), this.installSessionUserFilesApi(
|
|
1294
|
+
}), this.installSessionUserFilesApi(c);
|
|
1276
1295
|
let u = null, l;
|
|
1277
1296
|
u = await this.executeRuntimeHelper(), l = await Ct({
|
|
1278
1297
|
...o,
|
|
1279
|
-
javascript:
|
|
1298
|
+
javascript: he(o.javascript, {
|
|
1280
1299
|
clientId: this.options.clientId,
|
|
1281
1300
|
sessionId: s,
|
|
1282
1301
|
callId: n
|
|
1283
1302
|
})
|
|
1284
|
-
}).catch((
|
|
1303
|
+
}).catch((a) => ({
|
|
1285
1304
|
ok: !1,
|
|
1286
1305
|
exception: {
|
|
1287
|
-
message:
|
|
1306
|
+
message: a instanceof Error ? a.message : String(a)
|
|
1288
1307
|
}
|
|
1289
1308
|
})), this.activeBrowserToolCalls.delete(n), this.send({
|
|
1290
1309
|
type: "tool.result",
|
|
@@ -1293,24 +1312,24 @@ class Wt {
|
|
|
1293
1312
|
toolName: r,
|
|
1294
1313
|
summary: o.summary,
|
|
1295
1314
|
rawInput: k(o),
|
|
1296
|
-
rawOutput: k(
|
|
1297
|
-
}),
|
|
1315
|
+
rawOutput: k(Es(l, u))
|
|
1316
|
+
}), sn(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1298
1317
|
}
|
|
1299
1318
|
startPageLifecycleRecovery() {
|
|
1300
1319
|
if (this.pageLifecycleCleanup)
|
|
1301
1320
|
return;
|
|
1302
1321
|
const t = () => {
|
|
1303
|
-
|
|
1322
|
+
Jt(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1304
1323
|
};
|
|
1305
1324
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1306
1325
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1307
1326
|
};
|
|
1308
1327
|
}
|
|
1309
1328
|
installSessionUserFilesApi(t) {
|
|
1310
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1329
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = es(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1311
1330
|
}
|
|
1312
1331
|
cleanupSessionUserFilesApi() {
|
|
1313
|
-
this.sessionUserFilesApiCleanup && (
|
|
1332
|
+
this.sessionUserFilesApiCleanup && (ls(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1314
1333
|
}
|
|
1315
1334
|
async executeRuntimeHelper() {
|
|
1316
1335
|
if (!this.runtimeHelperJavascript?.trim())
|
|
@@ -1318,15 +1337,15 @@ class Wt {
|
|
|
1318
1337
|
const t = await Ct({
|
|
1319
1338
|
javascript: this.runtimeHelperJavascript
|
|
1320
1339
|
});
|
|
1321
|
-
return t.ok === !1 ?
|
|
1340
|
+
return t.ok === !1 ? Rs(t) : null;
|
|
1322
1341
|
}
|
|
1323
1342
|
enableNetworkCapture() {
|
|
1324
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1325
|
-
|
|
1343
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = Je((t) => {
|
|
1344
|
+
In(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1326
1345
|
}));
|
|
1327
1346
|
}
|
|
1328
1347
|
enqueueNetworkEvent(t) {
|
|
1329
|
-
this.queuedNetworkEvents.length >=
|
|
1348
|
+
this.queuedNetworkEvents.length >= qe || (this.queuedNetworkEvents.push(wn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1330
1349
|
this.networkBatchTimer = null;
|
|
1331
1350
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1332
1351
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1335,12 +1354,12 @@ class Wt {
|
|
|
1335
1354
|
page: S(),
|
|
1336
1355
|
events: s
|
|
1337
1356
|
});
|
|
1338
|
-
},
|
|
1357
|
+
}, Be)));
|
|
1339
1358
|
}
|
|
1340
1359
|
scheduleReconnect() {
|
|
1341
1360
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1342
1361
|
return;
|
|
1343
|
-
const t =
|
|
1362
|
+
const t = Xe(this.reconnectAttempts);
|
|
1344
1363
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1345
1364
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1346
1365
|
y("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1356,8 +1375,8 @@ class Wt {
|
|
|
1356
1375
|
const t = this.socket;
|
|
1357
1376
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1358
1377
|
this.socket === t && (y("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1359
|
-
},
|
|
1360
|
-
},
|
|
1378
|
+
}, Me));
|
|
1379
|
+
}, be);
|
|
1361
1380
|
}
|
|
1362
1381
|
stopHeartbeat() {
|
|
1363
1382
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1382,20 +1401,20 @@ class Wt {
|
|
|
1382
1401
|
...this.state,
|
|
1383
1402
|
...t,
|
|
1384
1403
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
|
|
1385
|
-
},
|
|
1404
|
+
}, tn(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
1386
1405
|
}
|
|
1387
1406
|
emit(t, s) {
|
|
1388
1407
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1389
1408
|
}
|
|
1390
1409
|
}
|
|
1391
1410
|
const Q = /* @__PURE__ */ new WeakMap();
|
|
1392
|
-
function
|
|
1393
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1411
|
+
function Je(e) {
|
|
1412
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Ye();
|
|
1394
1413
|
return t.subscribers.add(e), () => {
|
|
1395
1414
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1396
1415
|
};
|
|
1397
1416
|
}
|
|
1398
|
-
function
|
|
1417
|
+
function Ye() {
|
|
1399
1418
|
const e = /* @__PURE__ */ new Set(), t = (T) => {
|
|
1400
1419
|
e.forEach((p) => {
|
|
1401
1420
|
try {
|
|
@@ -1404,7 +1423,7 @@ function Ke() {
|
|
|
1404
1423
|
}
|
|
1405
1424
|
});
|
|
1406
1425
|
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p, d) {
|
|
1407
|
-
const
|
|
1426
|
+
const f = Date.now();
|
|
1408
1427
|
let w;
|
|
1409
1428
|
try {
|
|
1410
1429
|
w = s.call(this, p, d);
|
|
@@ -1412,24 +1431,24 @@ function Ke() {
|
|
|
1412
1431
|
throw m;
|
|
1413
1432
|
}
|
|
1414
1433
|
try {
|
|
1415
|
-
const m = p instanceof Request ? p : null,
|
|
1416
|
-
if (!b(
|
|
1434
|
+
const m = p instanceof Request ? p : null, g = gn(p, m), A = Zt(d?.headers ?? m?.headers);
|
|
1435
|
+
if (!b(g, A, d?.body)) {
|
|
1417
1436
|
const K = {
|
|
1418
1437
|
requestId: tt("fetch"),
|
|
1419
|
-
url: E(
|
|
1438
|
+
url: E(g, Z),
|
|
1420
1439
|
method: (d?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
1421
1440
|
requestHeaders: A,
|
|
1422
|
-
requestBody:
|
|
1441
|
+
requestBody: Ot(d?.body),
|
|
1423
1442
|
resourceType: "fetch",
|
|
1424
|
-
startedAt: new Date(
|
|
1443
|
+
startedAt: new Date(f).toISOString()
|
|
1425
1444
|
};
|
|
1426
1445
|
w.then(
|
|
1427
1446
|
(C) => {
|
|
1428
|
-
|
|
1447
|
+
mn(C, K, f, t).catch(() => {
|
|
1429
1448
|
t({
|
|
1430
1449
|
...K,
|
|
1431
1450
|
responseStatus: C.status,
|
|
1432
|
-
durationMs: Date.now() -
|
|
1451
|
+
durationMs: Date.now() - f
|
|
1433
1452
|
});
|
|
1434
1453
|
});
|
|
1435
1454
|
},
|
|
@@ -1437,7 +1456,7 @@ function Ke() {
|
|
|
1437
1456
|
t({
|
|
1438
1457
|
...K,
|
|
1439
1458
|
errorText: E(C instanceof Error ? C.message : String(C)),
|
|
1440
|
-
durationMs: Date.now() -
|
|
1459
|
+
durationMs: Date.now() - f
|
|
1441
1460
|
});
|
|
1442
1461
|
}
|
|
1443
1462
|
);
|
|
@@ -1445,8 +1464,8 @@ function Ke() {
|
|
|
1445
1464
|
} catch {
|
|
1446
1465
|
}
|
|
1447
1466
|
return w;
|
|
1448
|
-
},
|
|
1449
|
-
const
|
|
1467
|
+
}, c = function(p, d, f, w, m) {
|
|
1468
|
+
const g = n.call(this, p, d, f ?? !0, w ?? void 0, m ?? void 0), A = typeof d == "string" ? d : d.toString();
|
|
1450
1469
|
return Q.set(this, {
|
|
1451
1470
|
requestId: tt("xhr"),
|
|
1452
1471
|
method: String(p ?? "GET").toUpperCase(),
|
|
@@ -1455,19 +1474,19 @@ function Ke() {
|
|
|
1455
1474
|
startedAtMs: Date.now(),
|
|
1456
1475
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1457
1476
|
excluded: b(A)
|
|
1458
|
-
}),
|
|
1477
|
+
}), g;
|
|
1459
1478
|
}, u = function(p, d) {
|
|
1460
|
-
const
|
|
1461
|
-
return w && Object.keys(w.requestHeaders).length <
|
|
1479
|
+
const f = r.call(this, p, d), w = Q.get(this);
|
|
1480
|
+
return w && Object.keys(w.requestHeaders).length < ft && (w.requestHeaders[p] = It(p, d), w.excluded = w.excluded || b(w.url, w.requestHeaders)), f;
|
|
1462
1481
|
}, l = function(p) {
|
|
1463
1482
|
try {
|
|
1464
1483
|
const d = Q.get(this);
|
|
1465
|
-
d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody =
|
|
1484
|
+
d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = Ot(p), d.excluded || this.addEventListener(
|
|
1466
1485
|
"loadend",
|
|
1467
1486
|
() => {
|
|
1468
1487
|
queueMicrotask(() => {
|
|
1469
1488
|
try {
|
|
1470
|
-
const
|
|
1489
|
+
const f = Sn(this.getAllResponseHeaders());
|
|
1471
1490
|
t({
|
|
1472
1491
|
requestId: d.requestId,
|
|
1473
1492
|
url: d.url,
|
|
@@ -1476,8 +1495,8 @@ function Ke() {
|
|
|
1476
1495
|
requestBody: d.requestBody,
|
|
1477
1496
|
resourceType: "xhr",
|
|
1478
1497
|
responseStatus: this.status,
|
|
1479
|
-
responseHeaders:
|
|
1480
|
-
responseBody:
|
|
1498
|
+
responseHeaders: f,
|
|
1499
|
+
responseBody: Tn(this, f),
|
|
1481
1500
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1482
1501
|
startedAt: d.startedAt,
|
|
1483
1502
|
durationMs: Date.now() - d.startedAtMs
|
|
@@ -1498,7 +1517,7 @@ function Ke() {
|
|
|
1498
1517
|
} catch {
|
|
1499
1518
|
}
|
|
1500
1519
|
try {
|
|
1501
|
-
XMLHttpRequest.prototype.open =
|
|
1520
|
+
XMLHttpRequest.prototype.open = c;
|
|
1502
1521
|
} catch {
|
|
1503
1522
|
}
|
|
1504
1523
|
try {
|
|
@@ -1509,41 +1528,41 @@ function Ke() {
|
|
|
1509
1528
|
XMLHttpRequest.prototype.send = l;
|
|
1510
1529
|
} catch {
|
|
1511
1530
|
}
|
|
1512
|
-
let
|
|
1531
|
+
let a = null;
|
|
1513
1532
|
if (typeof PerformanceObserver < "u") {
|
|
1514
|
-
|
|
1533
|
+
a = new PerformanceObserver((T) => {
|
|
1515
1534
|
for (const p of T.getEntries()) {
|
|
1516
1535
|
const d = p;
|
|
1517
1536
|
if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || b(d.name))
|
|
1518
1537
|
continue;
|
|
1519
|
-
const
|
|
1538
|
+
const f = performance.timeOrigin + d.startTime;
|
|
1520
1539
|
t({
|
|
1521
1540
|
requestId: tt("resource"),
|
|
1522
1541
|
url: E(d.name, Z),
|
|
1523
1542
|
method: "GET",
|
|
1524
1543
|
resourceType: "resource",
|
|
1525
1544
|
responseStatus: d.responseStatus,
|
|
1526
|
-
startedAt: new Date(
|
|
1545
|
+
startedAt: new Date(f).toISOString(),
|
|
1527
1546
|
durationMs: d.duration
|
|
1528
1547
|
});
|
|
1529
1548
|
}
|
|
1530
1549
|
});
|
|
1531
1550
|
try {
|
|
1532
|
-
|
|
1551
|
+
a.observe({ type: "resource", buffered: !0 });
|
|
1533
1552
|
} catch {
|
|
1534
|
-
|
|
1553
|
+
a.disconnect(), a = null;
|
|
1535
1554
|
}
|
|
1536
1555
|
}
|
|
1537
1556
|
const h = {
|
|
1538
1557
|
subscribers: e,
|
|
1539
1558
|
destroy: () => {
|
|
1540
|
-
|
|
1559
|
+
a?.disconnect();
|
|
1541
1560
|
try {
|
|
1542
1561
|
window.fetch === o && (window.fetch = s);
|
|
1543
1562
|
} catch {
|
|
1544
1563
|
}
|
|
1545
1564
|
try {
|
|
1546
|
-
XMLHttpRequest.prototype.open ===
|
|
1565
|
+
XMLHttpRequest.prototype.open === c && (XMLHttpRequest.prototype.open = n);
|
|
1547
1566
|
} catch {
|
|
1548
1567
|
}
|
|
1549
1568
|
try {
|
|
@@ -1569,15 +1588,15 @@ function y(e, t, s) {
|
|
|
1569
1588
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1570
1589
|
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 }));
|
|
1571
1590
|
}
|
|
1572
|
-
function
|
|
1591
|
+
function _t(e) {
|
|
1573
1592
|
const t = typeof e == "function" ? e() : e;
|
|
1574
1593
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1575
1594
|
}
|
|
1576
|
-
function
|
|
1595
|
+
function Ve(e) {
|
|
1577
1596
|
return e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call";
|
|
1578
1597
|
}
|
|
1579
|
-
const
|
|
1580
|
-
function
|
|
1598
|
+
const Ze = 5e3, Qe = 12e4;
|
|
1599
|
+
function ts(e) {
|
|
1581
1600
|
const t = [];
|
|
1582
1601
|
for (const s of e)
|
|
1583
1602
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1588,17 +1607,17 @@ function Ze(e) {
|
|
|
1588
1607
|
});
|
|
1589
1608
|
return t;
|
|
1590
1609
|
}
|
|
1591
|
-
function
|
|
1610
|
+
function es(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1592
1611
|
const n = [
|
|
1593
|
-
|
|
1594
|
-
|
|
1612
|
+
ss(e, t, s),
|
|
1613
|
+
ns()
|
|
1595
1614
|
].filter((r) => typeof r == "function");
|
|
1596
1615
|
return () => {
|
|
1597
1616
|
for (const r of n.reverse())
|
|
1598
1617
|
r();
|
|
1599
1618
|
};
|
|
1600
1619
|
}
|
|
1601
|
-
function
|
|
1620
|
+
function ss(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1602
1621
|
const n = new Map(e.map((l) => [l.id, l])), r = (l) => ({
|
|
1603
1622
|
id: l.id,
|
|
1604
1623
|
name: l.name,
|
|
@@ -1607,75 +1626,75 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1607
1626
|
type: l.mimeType,
|
|
1608
1627
|
size: l.sizeBytes
|
|
1609
1628
|
}), i = (l) => {
|
|
1610
|
-
const
|
|
1611
|
-
if (!
|
|
1629
|
+
const a = n.get(l);
|
|
1630
|
+
if (!a)
|
|
1612
1631
|
throw new Error(`Unknown Pluno user file: ${l}`);
|
|
1613
|
-
return
|
|
1632
|
+
return a;
|
|
1614
1633
|
}, o = async (l) => {
|
|
1615
|
-
const
|
|
1634
|
+
const a = i(l), h = t.get(a.id);
|
|
1616
1635
|
if (h)
|
|
1617
1636
|
return h;
|
|
1618
|
-
const T = s.get(
|
|
1637
|
+
const T = s.get(a.id);
|
|
1619
1638
|
if (T)
|
|
1620
1639
|
return T;
|
|
1621
|
-
const p = await
|
|
1622
|
-
attachmentId:
|
|
1623
|
-
name:
|
|
1640
|
+
const p = await ae(a.id).then((m) => m?.blob ?? null).catch((m) => (y("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
|
|
1641
|
+
attachmentId: a.id,
|
|
1642
|
+
name: a.name,
|
|
1624
1643
|
message: m instanceof Error ? m.message : String(m)
|
|
1625
1644
|
}), null));
|
|
1626
1645
|
if (p)
|
|
1627
|
-
return s.set(
|
|
1628
|
-
if (!
|
|
1646
|
+
return s.set(a.id, p), p;
|
|
1647
|
+
if (!a.fileUrl)
|
|
1629
1648
|
throw new Error(`Pluno user file is missing content: ${l}`);
|
|
1630
|
-
const d = await fetch(
|
|
1649
|
+
const d = await fetch(a.fileUrl, ln(a.fileUrl));
|
|
1631
1650
|
if (!d.ok)
|
|
1632
1651
|
throw new Error(`Failed to load Pluno user file: ${l}`);
|
|
1633
|
-
const
|
|
1634
|
-
s.set(
|
|
1652
|
+
const f = await d.blob();
|
|
1653
|
+
s.set(a.id, f);
|
|
1635
1654
|
const w = Date.now();
|
|
1636
|
-
return
|
|
1637
|
-
attachmentId:
|
|
1638
|
-
name:
|
|
1639
|
-
mimeType:
|
|
1640
|
-
sizeBytes:
|
|
1641
|
-
blob:
|
|
1642
|
-
fileUrl:
|
|
1643
|
-
gcsPath:
|
|
1655
|
+
return Bt({
|
|
1656
|
+
attachmentId: a.id,
|
|
1657
|
+
name: a.name,
|
|
1658
|
+
mimeType: a.mimeType,
|
|
1659
|
+
sizeBytes: a.sizeBytes,
|
|
1660
|
+
blob: f,
|
|
1661
|
+
fileUrl: a.fileUrl,
|
|
1662
|
+
gcsPath: a.gcsPath,
|
|
1644
1663
|
createdAt: w,
|
|
1645
1664
|
lastUsedAt: w
|
|
1646
1665
|
}).catch((m) => {
|
|
1647
1666
|
y("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
|
|
1648
|
-
attachmentId:
|
|
1649
|
-
name:
|
|
1667
|
+
attachmentId: a.id,
|
|
1668
|
+
name: a.name,
|
|
1650
1669
|
message: m instanceof Error ? m.message : String(m)
|
|
1651
1670
|
});
|
|
1652
|
-
}),
|
|
1671
|
+
}), f;
|
|
1653
1672
|
};
|
|
1654
|
-
return
|
|
1673
|
+
return Ft(globalThis, "userFiles", {
|
|
1655
1674
|
list: () => e.map(r),
|
|
1656
1675
|
get: (l) => {
|
|
1657
|
-
const
|
|
1658
|
-
return
|
|
1676
|
+
const a = n.get(l);
|
|
1677
|
+
return a ? r(a) : null;
|
|
1659
1678
|
},
|
|
1660
1679
|
inspectImage: async (l) => {
|
|
1661
|
-
const
|
|
1680
|
+
const a = i(l), h = await o(l), T = a.mimeType.startsWith("image/") ? a.mimeType : h.type || a.mimeType;
|
|
1662
1681
|
if (!T.startsWith("image/"))
|
|
1663
1682
|
throw new Error(`Pluno user file is not an image: ${l}`);
|
|
1664
1683
|
const p = h.type === T ? h : new Blob([h], { type: T });
|
|
1665
|
-
return
|
|
1684
|
+
return us(T, p.size) > $e ? {
|
|
1666
1685
|
type: "pluno.userFiles.inspectImage",
|
|
1667
|
-
id:
|
|
1668
|
-
name:
|
|
1686
|
+
id: a.id,
|
|
1687
|
+
name: a.name,
|
|
1669
1688
|
mimeType: T,
|
|
1670
|
-
sizeBytes:
|
|
1689
|
+
sizeBytes: a.sizeBytes,
|
|
1671
1690
|
imageAttached: !1,
|
|
1672
1691
|
imageAttachmentError: gt
|
|
1673
1692
|
} : {
|
|
1674
1693
|
type: "pluno.userFiles.inspectImage",
|
|
1675
|
-
id:
|
|
1676
|
-
name:
|
|
1694
|
+
id: a.id,
|
|
1695
|
+
name: a.name,
|
|
1677
1696
|
mimeType: T,
|
|
1678
|
-
sizeBytes:
|
|
1697
|
+
sizeBytes: a.sizeBytes,
|
|
1679
1698
|
imageAttached: !0,
|
|
1680
1699
|
dataUrl: await ot(p)
|
|
1681
1700
|
};
|
|
@@ -1684,18 +1703,18 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1684
1703
|
getBlob: o,
|
|
1685
1704
|
getArrayBuffer: async (l) => await (await o(l)).arrayBuffer(),
|
|
1686
1705
|
getFile: async (l) => {
|
|
1687
|
-
const
|
|
1688
|
-
return new File([await o(l)],
|
|
1706
|
+
const a = i(l);
|
|
1707
|
+
return new File([await o(l)], a.name, { type: a.mimeType });
|
|
1689
1708
|
}
|
|
1690
1709
|
});
|
|
1691
1710
|
}
|
|
1692
|
-
function
|
|
1693
|
-
return
|
|
1694
|
-
inspectImage: async (t, s) => await
|
|
1711
|
+
function ns() {
|
|
1712
|
+
return Ft(globalThis, "pageImages", {
|
|
1713
|
+
inspectImage: async (t, s) => await rs(t, s)
|
|
1695
1714
|
});
|
|
1696
1715
|
}
|
|
1697
|
-
async function
|
|
1698
|
-
const s =
|
|
1716
|
+
async function rs(e, t = {}) {
|
|
1717
|
+
const s = cs(t.name), n = await is(e);
|
|
1699
1718
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1700
1719
|
type: "pluno.pageImages.inspectImage",
|
|
1701
1720
|
imageAttached: !1,
|
|
@@ -1713,26 +1732,26 @@ async function ss(e, t = {}) {
|
|
|
1713
1732
|
imageAttachmentError: n.error
|
|
1714
1733
|
};
|
|
1715
1734
|
}
|
|
1716
|
-
async function
|
|
1735
|
+
async function is(e) {
|
|
1717
1736
|
return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: gt } : {
|
|
1718
1737
|
ok: !0,
|
|
1719
1738
|
mimeType: e.type,
|
|
1720
1739
|
sizeBytes: e.size,
|
|
1721
1740
|
dataUrl: await ot(e)
|
|
1722
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
1741
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : os(e);
|
|
1723
1742
|
}
|
|
1724
|
-
function
|
|
1743
|
+
function os(e) {
|
|
1725
1744
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1726
1745
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1727
|
-
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((
|
|
1746
|
+
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((c) => c.trim()).filter(Boolean), r = n[0] ?? "";
|
|
1728
1747
|
if (!r.startsWith("image/"))
|
|
1729
1748
|
return { ok: !1, error: "Page image MIME type must be image/*." };
|
|
1730
|
-
if (!n.slice(1).some((
|
|
1749
|
+
if (!n.slice(1).some((c) => c.toLowerCase() === "base64"))
|
|
1731
1750
|
return { ok: !1, error: "Page image data URL must be base64 encoded." };
|
|
1732
1751
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1733
1752
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1734
1753
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1735
|
-
const o =
|
|
1754
|
+
const o = as(i);
|
|
1736
1755
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1737
1756
|
ok: !0,
|
|
1738
1757
|
mimeType: r,
|
|
@@ -1740,16 +1759,16 @@ function rs(e) {
|
|
|
1740
1759
|
dataUrl: `data:${r};base64,${i}`
|
|
1741
1760
|
};
|
|
1742
1761
|
}
|
|
1743
|
-
function
|
|
1762
|
+
function as(e) {
|
|
1744
1763
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1745
1764
|
return null;
|
|
1746
1765
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1747
1766
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1748
1767
|
}
|
|
1749
|
-
function
|
|
1768
|
+
function cs(e) {
|
|
1750
1769
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1751
1770
|
}
|
|
1752
|
-
function
|
|
1771
|
+
function ls(e) {
|
|
1753
1772
|
try {
|
|
1754
1773
|
e();
|
|
1755
1774
|
} catch {
|
|
@@ -1767,30 +1786,30 @@ function ot(e) {
|
|
|
1767
1786
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1768
1787
|
});
|
|
1769
1788
|
}
|
|
1770
|
-
function
|
|
1789
|
+
function us(e, t) {
|
|
1771
1790
|
return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
|
|
1772
1791
|
}
|
|
1773
1792
|
async function Ct(e) {
|
|
1774
1793
|
const t = Object.getPrototypeOf(async function() {
|
|
1775
|
-
}).constructor, s = e.timeoutMs ??
|
|
1794
|
+
}).constructor, s = e.timeoutMs ?? Ze, n = Date.now(), r = [];
|
|
1776
1795
|
let i;
|
|
1777
1796
|
const o = {
|
|
1778
1797
|
log: console.log,
|
|
1779
1798
|
info: console.info,
|
|
1780
1799
|
warn: console.warn,
|
|
1781
1800
|
error: console.error
|
|
1782
|
-
},
|
|
1801
|
+
}, c = (u) => (...l) => {
|
|
1783
1802
|
r.push({ level: u, args: l }), o[u](...l);
|
|
1784
1803
|
};
|
|
1785
|
-
console.log =
|
|
1804
|
+
console.log = c("log"), console.info = c("info"), console.warn = c("warn"), console.error = c("error");
|
|
1786
1805
|
try {
|
|
1787
1806
|
const u = /* @__PURE__ */ Symbol("execute_code_timeout"), l = await Promise.race([
|
|
1788
1807
|
new t(e.javascript)(),
|
|
1789
|
-
new Promise((
|
|
1790
|
-
i = window.setTimeout(() =>
|
|
1808
|
+
new Promise((a) => {
|
|
1809
|
+
i = window.setTimeout(() => a(u), s);
|
|
1791
1810
|
})
|
|
1792
1811
|
]);
|
|
1793
|
-
return l === u ?
|
|
1812
|
+
return l === u ? ds(s) : {
|
|
1794
1813
|
ok: !0,
|
|
1795
1814
|
result: l,
|
|
1796
1815
|
console: r,
|
|
@@ -1819,7 +1838,7 @@ async function Ct(e) {
|
|
|
1819
1838
|
i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
|
|
1820
1839
|
}
|
|
1821
1840
|
}
|
|
1822
|
-
function
|
|
1841
|
+
function ds(e) {
|
|
1823
1842
|
return {
|
|
1824
1843
|
ok: !1,
|
|
1825
1844
|
exception: {
|
|
@@ -1833,18 +1852,18 @@ function ls(e) {
|
|
|
1833
1852
|
}
|
|
1834
1853
|
};
|
|
1835
1854
|
}
|
|
1836
|
-
function
|
|
1855
|
+
function hs(e) {
|
|
1837
1856
|
return e.replace(/\/+$/, "");
|
|
1838
1857
|
}
|
|
1839
|
-
function
|
|
1858
|
+
function ps(e, t = location.origin) {
|
|
1840
1859
|
return /origin (?:is not allowed|does not match browser origin)/i.test(e) ? `Pluno widget blocked on ${t}: this domain is not allowed. Add ${t} in Pluno under Integration > Domains.` : null;
|
|
1841
1860
|
}
|
|
1842
|
-
function
|
|
1861
|
+
function fs(e) {
|
|
1843
1862
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1844
1863
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1845
1864
|
}
|
|
1846
1865
|
function S() {
|
|
1847
|
-
const e =
|
|
1866
|
+
const e = zt();
|
|
1848
1867
|
return {
|
|
1849
1868
|
url: location.href,
|
|
1850
1869
|
title: document.title,
|
|
@@ -1852,21 +1871,21 @@ function S() {
|
|
|
1852
1871
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1853
1872
|
};
|
|
1854
1873
|
}
|
|
1855
|
-
function
|
|
1874
|
+
function gs() {
|
|
1856
1875
|
return {
|
|
1857
1876
|
pageUrl: location.href,
|
|
1858
1877
|
pageTitle: document.title,
|
|
1859
|
-
htmlContent:
|
|
1878
|
+
htmlContent: ws()
|
|
1860
1879
|
};
|
|
1861
1880
|
}
|
|
1862
|
-
function
|
|
1863
|
-
return
|
|
1864
|
-
|
|
1881
|
+
function ms(e) {
|
|
1882
|
+
return x.add(e), L || (L = ys()), () => {
|
|
1883
|
+
x.delete(e), x.size === 0 && (L?.(), L = null);
|
|
1865
1884
|
};
|
|
1866
1885
|
}
|
|
1867
|
-
function
|
|
1886
|
+
function ys() {
|
|
1868
1887
|
const e = () => {
|
|
1869
|
-
for (const i of Array.from(
|
|
1888
|
+
for (const i of Array.from(x))
|
|
1870
1889
|
i();
|
|
1871
1890
|
}, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
1872
1891
|
const o = t(...i);
|
|
@@ -1879,10 +1898,10 @@ function fs() {
|
|
|
1879
1898
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
1880
1899
|
};
|
|
1881
1900
|
}
|
|
1882
|
-
function
|
|
1883
|
-
return
|
|
1901
|
+
function Ts() {
|
|
1902
|
+
return zt()?.surface === "browser_extension_sdk_preview";
|
|
1884
1903
|
}
|
|
1885
|
-
function
|
|
1904
|
+
function ws() {
|
|
1886
1905
|
const e = document.body?.cloneNode(!0);
|
|
1887
1906
|
return e instanceof HTMLElement ? (e.querySelectorAll(
|
|
1888
1907
|
[
|
|
@@ -1906,8 +1925,8 @@ function ys() {
|
|
|
1906
1925
|
s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
|
|
1907
1926
|
}), e.textContent?.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[email]").replace(/\b(?:\d[ -]*?){13,19}\b/g, "[number]").replace(/\b(?:sk|pk|tok|key|secret|token)_[A-Za-z0-9_-]{8,}\b/gi, "[secret]").replace(/\s+/g, " ").trim().slice(0, 12e3) ?? "") : "";
|
|
1908
1927
|
}
|
|
1909
|
-
function
|
|
1910
|
-
const e = document.querySelector(
|
|
1928
|
+
function zt() {
|
|
1929
|
+
const e = document.querySelector(At);
|
|
1911
1930
|
if (!(e ?? document.querySelector(rt)))
|
|
1912
1931
|
return;
|
|
1913
1932
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
@@ -1917,28 +1936,28 @@ function jt() {
|
|
|
1917
1936
|
selectors: [
|
|
1918
1937
|
{
|
|
1919
1938
|
name: "widget_host",
|
|
1920
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
1939
|
+
selector: s === "browser_extension_sdk_preview" ? At : rt,
|
|
1921
1940
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
1922
1941
|
},
|
|
1923
1942
|
{
|
|
1924
1943
|
name: "widget_root",
|
|
1925
|
-
selector:
|
|
1944
|
+
selector: ke,
|
|
1926
1945
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
1927
1946
|
},
|
|
1928
1947
|
{
|
|
1929
1948
|
name: "widget_panel",
|
|
1930
|
-
selector:
|
|
1949
|
+
selector: Ee,
|
|
1931
1950
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
1932
1951
|
},
|
|
1933
1952
|
{
|
|
1934
1953
|
name: "widget_timeline",
|
|
1935
|
-
selector:
|
|
1954
|
+
selector: Re,
|
|
1936
1955
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
1937
1956
|
}
|
|
1938
1957
|
]
|
|
1939
1958
|
};
|
|
1940
1959
|
}
|
|
1941
|
-
function
|
|
1960
|
+
function Is(e) {
|
|
1942
1961
|
try {
|
|
1943
1962
|
const t = JSON.parse(e);
|
|
1944
1963
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -1946,33 +1965,33 @@ function Ts(e) {
|
|
|
1946
1965
|
return { type: "error", message: "Invalid server event" };
|
|
1947
1966
|
}
|
|
1948
1967
|
}
|
|
1949
|
-
function
|
|
1968
|
+
function bt(e, t) {
|
|
1950
1969
|
if (!e || typeof e != "object")
|
|
1951
1970
|
return [];
|
|
1952
1971
|
const s = e[t];
|
|
1953
1972
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
1954
1973
|
}
|
|
1955
|
-
function
|
|
1974
|
+
function As(e) {
|
|
1956
1975
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
1957
1976
|
}
|
|
1958
|
-
function
|
|
1977
|
+
function Ss(e) {
|
|
1959
1978
|
if (!e || typeof e != "object")
|
|
1960
1979
|
return null;
|
|
1961
|
-
const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null,
|
|
1962
|
-
return !r && !i && !o &&
|
|
1980
|
+
const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, c = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
1981
|
+
return !r && !i && !o && c === null ? null : {
|
|
1963
1982
|
...r ? { accentColor: r } : {},
|
|
1964
1983
|
...i ? { colorScheme: i } : {},
|
|
1965
1984
|
...o ? { fontFamily: o } : {},
|
|
1966
|
-
...
|
|
1985
|
+
...c !== null ? { scribbleStyle: c } : {}
|
|
1967
1986
|
};
|
|
1968
1987
|
}
|
|
1969
|
-
function
|
|
1988
|
+
function ks(e) {
|
|
1970
1989
|
if (!e || typeof e != "object")
|
|
1971
1990
|
return null;
|
|
1972
1991
|
const t = e.javascript;
|
|
1973
1992
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
1974
1993
|
}
|
|
1975
|
-
function
|
|
1994
|
+
function Es(e, t) {
|
|
1976
1995
|
return t ? e && typeof e == "object" ? {
|
|
1977
1996
|
...e,
|
|
1978
1997
|
helperError: t
|
|
@@ -1982,23 +2001,23 @@ function Ss(e, t) {
|
|
|
1982
2001
|
helperError: t
|
|
1983
2002
|
} : e;
|
|
1984
2003
|
}
|
|
1985
|
-
function
|
|
2004
|
+
function Rs(e) {
|
|
1986
2005
|
if (!e || typeof e != "object")
|
|
1987
2006
|
return e;
|
|
1988
2007
|
const t = e;
|
|
1989
2008
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
1990
2009
|
}
|
|
1991
|
-
function
|
|
2010
|
+
function _s() {
|
|
1992
2011
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
1993
2012
|
if (t)
|
|
1994
2013
|
return t;
|
|
1995
2014
|
const s = crypto.randomUUID();
|
|
1996
2015
|
return window.localStorage.setItem(e, s), s;
|
|
1997
2016
|
}
|
|
1998
|
-
function
|
|
2017
|
+
function B() {
|
|
1999
2018
|
return crypto.randomUUID();
|
|
2000
2019
|
}
|
|
2001
|
-
function
|
|
2020
|
+
function Cs(e) {
|
|
2002
2021
|
if (!e || typeof e != "object")
|
|
2003
2022
|
return null;
|
|
2004
2023
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2009,14 +2028,14 @@ function Rs(e) {
|
|
|
2009
2028
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2010
2029
|
} : null;
|
|
2011
2030
|
}
|
|
2012
|
-
function
|
|
2013
|
-
return Array.isArray(e) ?
|
|
2014
|
-
|
|
2015
|
-
e.map((s) =>
|
|
2031
|
+
function bs(e, t) {
|
|
2032
|
+
return Array.isArray(e) ? lt(
|
|
2033
|
+
ut(
|
|
2034
|
+
e.map((s) => Gt(s, t)).filter((s) => s !== null)
|
|
2016
2035
|
)
|
|
2017
2036
|
) : [];
|
|
2018
2037
|
}
|
|
2019
|
-
function
|
|
2038
|
+
function Ms(e) {
|
|
2020
2039
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2021
2040
|
if (!t || typeof t != "object")
|
|
2022
2041
|
return [];
|
|
@@ -2035,52 +2054,54 @@ function _s(e) {
|
|
|
2035
2054
|
];
|
|
2036
2055
|
}) : [];
|
|
2037
2056
|
}
|
|
2038
|
-
function
|
|
2057
|
+
function Gt(e, t) {
|
|
2039
2058
|
if (!e || typeof e != "object")
|
|
2040
2059
|
return null;
|
|
2041
2060
|
const s = e, n = s.data;
|
|
2042
2061
|
if (!n || typeof n != "object")
|
|
2043
2062
|
return null;
|
|
2044
2063
|
const r = n;
|
|
2064
|
+
if (r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
2065
|
+
return null;
|
|
2045
2066
|
if (r.type === "message") {
|
|
2046
2067
|
const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system";
|
|
2047
2068
|
return {
|
|
2048
2069
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2049
2070
|
role: i,
|
|
2050
|
-
content:
|
|
2071
|
+
content: Ns(r.content),
|
|
2051
2072
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2052
|
-
respondsToUserMessageId:
|
|
2073
|
+
respondsToUserMessageId: M(r) ?? void 0,
|
|
2053
2074
|
..._(r) ? { runId: _(r) } : {},
|
|
2054
|
-
attachments:
|
|
2075
|
+
attachments: Yt(r.attachments, t)
|
|
2055
2076
|
};
|
|
2056
2077
|
}
|
|
2057
|
-
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" ? {
|
|
2078
|
+
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2058
2079
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2059
2080
|
role: "tool",
|
|
2060
|
-
content:
|
|
2081
|
+
content: Us(r),
|
|
2061
2082
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2062
|
-
respondsToUserMessageId:
|
|
2083
|
+
respondsToUserMessageId: M(r) ?? void 0,
|
|
2063
2084
|
..._(r) ? { runId: _(r) } : {},
|
|
2064
2085
|
dataType: String(r.type),
|
|
2065
|
-
toolName: typeof r.name == "string" ? r.name : void 0,
|
|
2066
|
-
callId:
|
|
2086
|
+
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2087
|
+
callId: vs(r) ?? void 0,
|
|
2067
2088
|
loading: r.localExecutionStatus === "running"
|
|
2068
2089
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2069
2090
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2070
2091
|
role: "system",
|
|
2071
|
-
content:
|
|
2092
|
+
content: Ps(r),
|
|
2072
2093
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2073
|
-
respondsToUserMessageId:
|
|
2094
|
+
respondsToUserMessageId: M(r) ?? void 0,
|
|
2074
2095
|
..._(r) ? { runId: _(r) } : {},
|
|
2075
2096
|
dataType: String(r.type),
|
|
2076
2097
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
2077
2098
|
...typeof r.retryable == "boolean" ? { retryable: r.retryable } : {}
|
|
2078
2099
|
} : null;
|
|
2079
2100
|
}
|
|
2080
|
-
function
|
|
2101
|
+
function Ps(e) {
|
|
2081
2102
|
return typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : e.type === "run_status" && e.status === "stopped" ? "Pluno stopped." : "Pluno run status changed.";
|
|
2082
2103
|
}
|
|
2083
|
-
function
|
|
2104
|
+
function Us(e) {
|
|
2084
2105
|
if (e.type === "web_search_call") {
|
|
2085
2106
|
const t = e.action;
|
|
2086
2107
|
if (t && typeof t == "object") {
|
|
@@ -2092,9 +2113,9 @@ function Ms(e) {
|
|
|
2092
2113
|
}
|
|
2093
2114
|
return "Searching the web";
|
|
2094
2115
|
}
|
|
2095
|
-
return
|
|
2116
|
+
return Ds(e);
|
|
2096
2117
|
}
|
|
2097
|
-
function
|
|
2118
|
+
function Ds(e) {
|
|
2098
2119
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2099
2120
|
return e.summary;
|
|
2100
2121
|
if (typeof e.arguments == "string")
|
|
@@ -2107,11 +2128,11 @@ function Ps(e) {
|
|
|
2107
2128
|
}
|
|
2108
2129
|
return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
|
|
2109
2130
|
}
|
|
2110
|
-
function
|
|
2131
|
+
function vs(e) {
|
|
2111
2132
|
const t = e.callId ?? e.call_id;
|
|
2112
2133
|
return typeof t == "string" && t ? t : null;
|
|
2113
2134
|
}
|
|
2114
|
-
function
|
|
2135
|
+
function Ns(e) {
|
|
2115
2136
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2116
2137
|
if (!t || typeof t != "object")
|
|
2117
2138
|
return "";
|
|
@@ -2119,24 +2140,24 @@ function Ds(e) {
|
|
|
2119
2140
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2120
2141
|
}).filter(Boolean).join("") : "";
|
|
2121
2142
|
}
|
|
2122
|
-
function
|
|
2123
|
-
const s =
|
|
2143
|
+
function Os(e, t) {
|
|
2144
|
+
const s = Xt(e, t), n = xs(e, t), r = n.findIndex((o) => o.id === s.id);
|
|
2124
2145
|
if (r === -1)
|
|
2125
|
-
return
|
|
2126
|
-
|
|
2146
|
+
return lt(
|
|
2147
|
+
ut([...n, s])
|
|
2127
2148
|
);
|
|
2128
2149
|
const i = [...n];
|
|
2129
|
-
return i[r] = s,
|
|
2150
|
+
return i[r] = s, lt(ut(i));
|
|
2130
2151
|
}
|
|
2131
|
-
function
|
|
2152
|
+
function Ls(e, t) {
|
|
2132
2153
|
const s = t.map(
|
|
2133
|
-
(n) =>
|
|
2154
|
+
(n) => Xt(e, n)
|
|
2134
2155
|
);
|
|
2135
2156
|
return t.length > 0 ? s : e.filter(
|
|
2136
2157
|
(n) => n.role === "user" && n.id.startsWith("local-")
|
|
2137
2158
|
);
|
|
2138
2159
|
}
|
|
2139
|
-
function
|
|
2160
|
+
function Xt(e, t) {
|
|
2140
2161
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2141
2162
|
return t;
|
|
2142
2163
|
const s = e.find(
|
|
@@ -2145,19 +2166,19 @@ function zt(e, t) {
|
|
|
2145
2166
|
if (!s?.attachments?.length)
|
|
2146
2167
|
return t;
|
|
2147
2168
|
const n = t.attachments.map((r) => {
|
|
2148
|
-
const i =
|
|
2149
|
-
return i ?
|
|
2169
|
+
const i = Bs(s.attachments ?? [], r);
|
|
2170
|
+
return i ? qs(r, i) : r;
|
|
2150
2171
|
});
|
|
2151
2172
|
return { ...t, attachments: n };
|
|
2152
2173
|
}
|
|
2153
|
-
function
|
|
2174
|
+
function Bs(e, t) {
|
|
2154
2175
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2155
2176
|
}
|
|
2156
|
-
function
|
|
2177
|
+
function qs(e, t) {
|
|
2157
2178
|
const { previewUrl: s } = t;
|
|
2158
2179
|
return s ? { ...e, previewUrl: s } : e;
|
|
2159
2180
|
}
|
|
2160
|
-
function
|
|
2181
|
+
function xs(e, t) {
|
|
2161
2182
|
if (t.role !== "user")
|
|
2162
2183
|
return e;
|
|
2163
2184
|
const s = e.findIndex(
|
|
@@ -2168,8 +2189,8 @@ function Bs(e, t) {
|
|
|
2168
2189
|
const n = [...e];
|
|
2169
2190
|
return n.splice(s, 1), n;
|
|
2170
2191
|
}
|
|
2171
|
-
function
|
|
2172
|
-
const t =
|
|
2192
|
+
function Mt(e) {
|
|
2193
|
+
const t = Kt(e);
|
|
2173
2194
|
if (t === null)
|
|
2174
2195
|
return !1;
|
|
2175
2196
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
@@ -2185,20 +2206,20 @@ function bt(e) {
|
|
|
2185
2206
|
}
|
|
2186
2207
|
return !1;
|
|
2187
2208
|
}
|
|
2188
|
-
function
|
|
2189
|
-
const t =
|
|
2209
|
+
function Fs(e) {
|
|
2210
|
+
const t = Kt(e);
|
|
2190
2211
|
return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
|
|
2191
2212
|
}
|
|
2192
|
-
function
|
|
2213
|
+
function Kt(e) {
|
|
2193
2214
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2194
2215
|
if (e[t].role === "user")
|
|
2195
2216
|
return t;
|
|
2196
2217
|
return null;
|
|
2197
2218
|
}
|
|
2198
|
-
function
|
|
2219
|
+
function Hs(e) {
|
|
2199
2220
|
return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2200
2221
|
}
|
|
2201
|
-
function
|
|
2222
|
+
function mt(e) {
|
|
2202
2223
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
2203
2224
|
const s = e[t];
|
|
2204
2225
|
if (!s || typeof s != "object")
|
|
@@ -2212,27 +2233,30 @@ function ft(e) {
|
|
|
2212
2233
|
}
|
|
2213
2234
|
return null;
|
|
2214
2235
|
}
|
|
2215
|
-
function
|
|
2236
|
+
function v(e) {
|
|
2216
2237
|
if (!e || typeof e != "object")
|
|
2217
2238
|
return null;
|
|
2218
2239
|
const t = e.data;
|
|
2219
2240
|
return t && typeof t == "object" ? t : null;
|
|
2220
2241
|
}
|
|
2221
|
-
function
|
|
2242
|
+
function at(e) {
|
|
2222
2243
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2223
2244
|
}
|
|
2224
|
-
function
|
|
2225
|
-
|
|
2245
|
+
function Pt(e) {
|
|
2246
|
+
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2247
|
+
}
|
|
2248
|
+
function Ws(e, t) {
|
|
2249
|
+
const s = mt(t);
|
|
2226
2250
|
if (s === null)
|
|
2227
2251
|
return !1;
|
|
2228
2252
|
const n = t[s], r = n && typeof n == "object" ? n.id : null;
|
|
2229
2253
|
if (typeof r != "string" || !r)
|
|
2230
2254
|
return !1;
|
|
2231
2255
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2232
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
2256
|
+
return i === -1 ? !1 : e.slice(i + 1).some(Hs);
|
|
2233
2257
|
}
|
|
2234
|
-
function
|
|
2235
|
-
const t =
|
|
2258
|
+
function ct(e) {
|
|
2259
|
+
const t = mt(e);
|
|
2236
2260
|
if (t === null)
|
|
2237
2261
|
return null;
|
|
2238
2262
|
const s = e[t];
|
|
@@ -2244,8 +2268,8 @@ function at(e) {
|
|
|
2244
2268
|
const r = n.clientMessageId;
|
|
2245
2269
|
return typeof r == "string" ? r : null;
|
|
2246
2270
|
}
|
|
2247
|
-
function
|
|
2248
|
-
const t =
|
|
2271
|
+
function js(e) {
|
|
2272
|
+
const t = mt(e);
|
|
2249
2273
|
if (t === null)
|
|
2250
2274
|
return null;
|
|
2251
2275
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
@@ -2259,22 +2283,22 @@ function Hs(e) {
|
|
|
2259
2283
|
if (i.type === "message" && i.role === "assistant")
|
|
2260
2284
|
return null;
|
|
2261
2285
|
if (i.type === "run_error")
|
|
2262
|
-
return i.retryable !== !0 ? null :
|
|
2286
|
+
return i.retryable !== !0 ? null : Ut(e, i) ?? ct(e);
|
|
2263
2287
|
if (i.type === "run_status")
|
|
2264
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
2288
|
+
return i.status === "interrupted" && i.retryable === !0 ? Ut(e, i) ?? ct(e) : null;
|
|
2265
2289
|
}
|
|
2266
2290
|
return null;
|
|
2267
2291
|
}
|
|
2268
|
-
function
|
|
2292
|
+
function Ut(e, t) {
|
|
2269
2293
|
if (typeof t.clientMessageId == "string")
|
|
2270
2294
|
return t.clientMessageId;
|
|
2271
|
-
const s =
|
|
2295
|
+
const s = M(t);
|
|
2272
2296
|
if (!s)
|
|
2273
2297
|
return null;
|
|
2274
|
-
const n = e.find((i) => I(i, "id") === s), r =
|
|
2298
|
+
const n = e.find((i) => I(i, "id") === s), r = v(n);
|
|
2275
2299
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2276
2300
|
}
|
|
2277
|
-
function
|
|
2301
|
+
function $s(e, t) {
|
|
2278
2302
|
let s = 0;
|
|
2279
2303
|
for (const n of e) {
|
|
2280
2304
|
if (!n || typeof n != "object")
|
|
@@ -2287,22 +2311,34 @@ function Ws(e, t) {
|
|
|
2287
2311
|
}
|
|
2288
2312
|
return s;
|
|
2289
2313
|
}
|
|
2290
|
-
function
|
|
2314
|
+
function Dt(e, t, s, n) {
|
|
2315
|
+
if (!t || !zs(e))
|
|
2316
|
+
return !1;
|
|
2317
|
+
const r = e;
|
|
2318
|
+
return !(at(r) || s !== null && M(r) !== s || n !== null && _(r) !== n);
|
|
2319
|
+
}
|
|
2320
|
+
function zs(e) {
|
|
2321
|
+
if (!e || typeof e != "object")
|
|
2322
|
+
return !1;
|
|
2323
|
+
const t = e;
|
|
2324
|
+
return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted");
|
|
2325
|
+
}
|
|
2326
|
+
function Gs(e) {
|
|
2291
2327
|
if (!e || typeof e != "object")
|
|
2292
2328
|
return !1;
|
|
2293
2329
|
const t = e;
|
|
2294
2330
|
return t.type === "message" && t.role === "user" ? !1 : t.type === "message" || t.type === "function_call" || t.type === "function_call_output" || t.type === "run_error" || t.type === "run_status";
|
|
2295
2331
|
}
|
|
2296
|
-
function
|
|
2297
|
-
return e.filter((t, s) =>
|
|
2332
|
+
function lt(e) {
|
|
2333
|
+
return e.filter((t, s) => yt(t) ? !Zs(e, s) && !Ys(e, s) && !Vs(e, s) : Xs(t) ? t.retryable === !0 && Js(e, s) ? !1 : !Ks(e, s) : !0);
|
|
2298
2334
|
}
|
|
2299
|
-
function
|
|
2335
|
+
function Xs(e) {
|
|
2300
2336
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
2301
2337
|
}
|
|
2302
|
-
function
|
|
2338
|
+
function yt(e) {
|
|
2303
2339
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
2304
2340
|
}
|
|
2305
|
-
function
|
|
2341
|
+
function ut(e) {
|
|
2306
2342
|
const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
2307
2343
|
for (const i of e) {
|
|
2308
2344
|
if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
|
|
@@ -2318,7 +2354,7 @@ function lt(e) {
|
|
|
2318
2354
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
2319
2355
|
return r;
|
|
2320
2356
|
}
|
|
2321
|
-
function
|
|
2357
|
+
function Ks(e, t) {
|
|
2322
2358
|
const s = e[t];
|
|
2323
2359
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2324
2360
|
const r = e[n];
|
|
@@ -2329,7 +2365,7 @@ function zs(e, t) {
|
|
|
2329
2365
|
}
|
|
2330
2366
|
return !1;
|
|
2331
2367
|
}
|
|
2332
|
-
function
|
|
2368
|
+
function Js(e, t) {
|
|
2333
2369
|
const s = e[t];
|
|
2334
2370
|
if (!s.respondsToUserMessageId)
|
|
2335
2371
|
return !1;
|
|
@@ -2337,29 +2373,29 @@ function Gs(e, t) {
|
|
|
2337
2373
|
const r = e[n];
|
|
2338
2374
|
if (r.role === "user")
|
|
2339
2375
|
return !1;
|
|
2340
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
2376
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || yt(r)))
|
|
2341
2377
|
return !0;
|
|
2342
2378
|
}
|
|
2343
2379
|
return !1;
|
|
2344
2380
|
}
|
|
2345
|
-
function
|
|
2381
|
+
function Ys(e, t) {
|
|
2346
2382
|
const s = e[t];
|
|
2347
2383
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2348
2384
|
if (e[n].role === "assistant" && G(s, e[n]))
|
|
2349
2385
|
return !0;
|
|
2350
2386
|
return !1;
|
|
2351
2387
|
}
|
|
2352
|
-
function
|
|
2388
|
+
function Vs(e, t) {
|
|
2353
2389
|
const s = e[t];
|
|
2354
2390
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2355
2391
|
if (e[n].role === "tool" && G(s, e[n]))
|
|
2356
2392
|
return !0;
|
|
2357
2393
|
return !1;
|
|
2358
2394
|
}
|
|
2359
|
-
function
|
|
2395
|
+
function Zs(e, t) {
|
|
2360
2396
|
const s = e[t];
|
|
2361
2397
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2362
|
-
if (
|
|
2398
|
+
if (yt(e[n]) && G(s, e[n]))
|
|
2363
2399
|
return !0;
|
|
2364
2400
|
return !1;
|
|
2365
2401
|
}
|
|
@@ -2369,15 +2405,15 @@ function G(e, t) {
|
|
|
2369
2405
|
function I(e, t) {
|
|
2370
2406
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
2371
2407
|
}
|
|
2372
|
-
function
|
|
2408
|
+
function Qs(e, t) {
|
|
2373
2409
|
try {
|
|
2374
|
-
const s = window.localStorage.getItem(`${
|
|
2410
|
+
const s = window.localStorage.getItem(`${jt}${e}`);
|
|
2375
2411
|
if (!s)
|
|
2376
2412
|
return null;
|
|
2377
2413
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
2378
2414
|
if (t !== void 0 && r !== t)
|
|
2379
2415
|
return null;
|
|
2380
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2416
|
+
const i = Array.isArray(n.messages) ? n.messages.map(hn).filter((o) => !!o) : [];
|
|
2381
2417
|
return {
|
|
2382
2418
|
sessionId: r,
|
|
2383
2419
|
messages: i
|
|
@@ -2386,33 +2422,33 @@ function Vs(e, t) {
|
|
|
2386
2422
|
return null;
|
|
2387
2423
|
}
|
|
2388
2424
|
}
|
|
2389
|
-
function
|
|
2425
|
+
function tn(e, t) {
|
|
2390
2426
|
try {
|
|
2391
2427
|
window.localStorage.setItem(
|
|
2392
|
-
`${
|
|
2428
|
+
`${jt}${e}`,
|
|
2393
2429
|
JSON.stringify({
|
|
2394
2430
|
sessionId: t.sessionId,
|
|
2395
|
-
messages: t.messages.slice(-
|
|
2431
|
+
messages: t.messages.slice(-ze).map(pn)
|
|
2396
2432
|
})
|
|
2397
2433
|
);
|
|
2398
2434
|
} catch {
|
|
2399
2435
|
return;
|
|
2400
2436
|
}
|
|
2401
2437
|
}
|
|
2402
|
-
function
|
|
2438
|
+
function en(e) {
|
|
2403
2439
|
try {
|
|
2404
2440
|
const t = window.localStorage.getItem(`${it}${e}`);
|
|
2405
2441
|
if (!t)
|
|
2406
2442
|
return [];
|
|
2407
2443
|
const s = JSON.parse(t);
|
|
2408
|
-
return Array.isArray(s) ? s.filter(
|
|
2444
|
+
return Array.isArray(s) ? s.filter(Tt) : [];
|
|
2409
2445
|
} catch {
|
|
2410
2446
|
return [];
|
|
2411
2447
|
}
|
|
2412
2448
|
}
|
|
2413
|
-
function
|
|
2449
|
+
function U(e, t) {
|
|
2414
2450
|
try {
|
|
2415
|
-
const s = t.filter(
|
|
2451
|
+
const s = t.filter(Tt);
|
|
2416
2452
|
if (s.length === 0) {
|
|
2417
2453
|
window.localStorage.removeItem(`${it}${e}`);
|
|
2418
2454
|
return;
|
|
@@ -2425,7 +2461,7 @@ function P(e, t) {
|
|
|
2425
2461
|
return;
|
|
2426
2462
|
}
|
|
2427
2463
|
}
|
|
2428
|
-
function
|
|
2464
|
+
function Jt(e, t) {
|
|
2429
2465
|
try {
|
|
2430
2466
|
const s = `${z}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
2431
2467
|
...o,
|
|
@@ -2441,28 +2477,28 @@ function Xt(e, t) {
|
|
|
2441
2477
|
} catch {
|
|
2442
2478
|
}
|
|
2443
2479
|
}
|
|
2444
|
-
function
|
|
2480
|
+
function sn(e, t) {
|
|
2445
2481
|
try {
|
|
2446
2482
|
if (window.sessionStorage.getItem(`${z}${e}`) === null)
|
|
2447
2483
|
return;
|
|
2448
2484
|
} catch {
|
|
2449
2485
|
return;
|
|
2450
2486
|
}
|
|
2451
|
-
|
|
2487
|
+
Jt(e, t);
|
|
2452
2488
|
}
|
|
2453
|
-
function
|
|
2489
|
+
function nn(e) {
|
|
2454
2490
|
try {
|
|
2455
2491
|
const t = `${z}${e}`, s = window.sessionStorage.getItem(t);
|
|
2456
2492
|
if (window.sessionStorage.removeItem(t), !s)
|
|
2457
2493
|
return [];
|
|
2458
2494
|
const n = JSON.parse(s);
|
|
2459
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2495
|
+
return Array.isArray(n) ? n.flatMap((r) => on(r) ? [{
|
|
2460
2496
|
...r.event,
|
|
2461
2497
|
page: S(),
|
|
2462
2498
|
rawOutput: {
|
|
2463
2499
|
pageContextRestarted: !0,
|
|
2464
2500
|
outcome: "unknown",
|
|
2465
|
-
message:
|
|
2501
|
+
message: rn(location.href),
|
|
2466
2502
|
currentUrl: location.href,
|
|
2467
2503
|
console: [],
|
|
2468
2504
|
metadata: {
|
|
@@ -2479,17 +2515,17 @@ function tn(e) {
|
|
|
2479
2515
|
return [];
|
|
2480
2516
|
}
|
|
2481
2517
|
}
|
|
2482
|
-
function
|
|
2518
|
+
function rn(e) {
|
|
2483
2519
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
2484
2520
|
Current URL: ${e}`;
|
|
2485
2521
|
}
|
|
2486
|
-
function
|
|
2522
|
+
function on(e) {
|
|
2487
2523
|
if (!e || typeof e != "object")
|
|
2488
2524
|
return !1;
|
|
2489
2525
|
const t = e, s = t.event;
|
|
2490
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
2526
|
+
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Tt(s) && s.type === "tool.result";
|
|
2491
2527
|
}
|
|
2492
|
-
function
|
|
2528
|
+
function an(e, t) {
|
|
2493
2529
|
const s = new Set(
|
|
2494
2530
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2495
2531
|
);
|
|
@@ -2498,26 +2534,26 @@ function nn(e, t) {
|
|
|
2498
2534
|
...t.filter((n) => !s.has(n.callId))
|
|
2499
2535
|
];
|
|
2500
2536
|
}
|
|
2501
|
-
function
|
|
2537
|
+
function cn(e) {
|
|
2502
2538
|
try {
|
|
2503
2539
|
window.sessionStorage.removeItem(`${z}${e}`);
|
|
2504
2540
|
} catch {
|
|
2505
2541
|
return;
|
|
2506
2542
|
}
|
|
2507
2543
|
}
|
|
2508
|
-
function
|
|
2544
|
+
function Tt(e) {
|
|
2509
2545
|
if (!e || typeof e != "object")
|
|
2510
2546
|
return !1;
|
|
2511
2547
|
const t = e;
|
|
2512
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
2548
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && vt(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? vt(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
|
|
2513
2549
|
}
|
|
2514
|
-
function
|
|
2550
|
+
function vt(e) {
|
|
2515
2551
|
if (!e || typeof e != "object")
|
|
2516
2552
|
return !1;
|
|
2517
2553
|
const t = e;
|
|
2518
2554
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
2519
2555
|
}
|
|
2520
|
-
function
|
|
2556
|
+
function Yt(e, t) {
|
|
2521
2557
|
if (!Array.isArray(e))
|
|
2522
2558
|
return;
|
|
2523
2559
|
const s = e.filter((r) => {
|
|
@@ -2525,24 +2561,24 @@ function Kt(e, t) {
|
|
|
2525
2561
|
return !1;
|
|
2526
2562
|
const i = r;
|
|
2527
2563
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2528
|
-
}), n = t ? s.map((r) =>
|
|
2564
|
+
}), n = t ? s.map((r) => Vt(r, t)) : s;
|
|
2529
2565
|
return n.length > 0 ? n : void 0;
|
|
2530
2566
|
}
|
|
2531
|
-
function
|
|
2567
|
+
function Vt(e, t) {
|
|
2532
2568
|
return e.fileUrl?.startsWith("/") ? {
|
|
2533
2569
|
...e,
|
|
2534
2570
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2535
2571
|
} : e;
|
|
2536
2572
|
}
|
|
2537
|
-
function
|
|
2538
|
-
if (
|
|
2573
|
+
function ln(e) {
|
|
2574
|
+
if (un(e))
|
|
2539
2575
|
return {
|
|
2540
2576
|
headers: {
|
|
2541
2577
|
"ngrok-skip-browser-warning": "true"
|
|
2542
2578
|
}
|
|
2543
2579
|
};
|
|
2544
2580
|
}
|
|
2545
|
-
function
|
|
2581
|
+
function un(e) {
|
|
2546
2582
|
try {
|
|
2547
2583
|
const t = new URL(e).hostname;
|
|
2548
2584
|
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
@@ -2550,14 +2586,14 @@ function an(e) {
|
|
|
2550
2586
|
return !1;
|
|
2551
2587
|
}
|
|
2552
2588
|
}
|
|
2553
|
-
function
|
|
2554
|
-
return e.type ||
|
|
2589
|
+
function Nt(e) {
|
|
2590
|
+
return e.type || dn(e.name) || "application/octet-stream";
|
|
2555
2591
|
}
|
|
2556
|
-
function
|
|
2592
|
+
function dn(e) {
|
|
2557
2593
|
const t = e.toLowerCase();
|
|
2558
2594
|
return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
|
|
2559
2595
|
}
|
|
2560
|
-
function
|
|
2596
|
+
function hn(e) {
|
|
2561
2597
|
if (!e || typeof e != "object")
|
|
2562
2598
|
return null;
|
|
2563
2599
|
const t = e;
|
|
@@ -2569,17 +2605,17 @@ function ln(e) {
|
|
|
2569
2605
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
2570
2606
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
2571
2607
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
2572
|
-
attachments:
|
|
2608
|
+
attachments: Yt(t.attachments)?.map(wt),
|
|
2573
2609
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2574
2610
|
};
|
|
2575
2611
|
}
|
|
2576
|
-
function
|
|
2612
|
+
function pn(e) {
|
|
2577
2613
|
return e.attachments?.length ? {
|
|
2578
2614
|
...e,
|
|
2579
|
-
attachments: e.attachments.map(
|
|
2615
|
+
attachments: e.attachments.map(wt)
|
|
2580
2616
|
} : e;
|
|
2581
2617
|
}
|
|
2582
|
-
function
|
|
2618
|
+
function wt(e) {
|
|
2583
2619
|
const {
|
|
2584
2620
|
dataUrl: t,
|
|
2585
2621
|
objectUrl: s,
|
|
@@ -2588,7 +2624,7 @@ function Tt(e) {
|
|
|
2588
2624
|
} = e;
|
|
2589
2625
|
return r;
|
|
2590
2626
|
}
|
|
2591
|
-
function
|
|
2627
|
+
function M(e) {
|
|
2592
2628
|
const t = e.respondsToUserMessageId;
|
|
2593
2629
|
return typeof t == "string" && t ? t : null;
|
|
2594
2630
|
}
|
|
@@ -2596,60 +2632,60 @@ function _(e) {
|
|
|
2596
2632
|
const t = e.runId;
|
|
2597
2633
|
return typeof t == "string" && t ? t : null;
|
|
2598
2634
|
}
|
|
2599
|
-
function
|
|
2635
|
+
function fn(e) {
|
|
2600
2636
|
const t = e?.timeoutMs;
|
|
2601
|
-
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <=
|
|
2637
|
+
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Qe);
|
|
2602
2638
|
}
|
|
2603
|
-
function
|
|
2639
|
+
function Zt(e) {
|
|
2604
2640
|
const t = {};
|
|
2605
2641
|
try {
|
|
2606
2642
|
new Headers(e).forEach((s, n) => {
|
|
2607
|
-
Object.keys(t).length <
|
|
2643
|
+
Object.keys(t).length < ft && (t[n] = It(n, s));
|
|
2608
2644
|
});
|
|
2609
2645
|
} catch {
|
|
2610
2646
|
return {};
|
|
2611
2647
|
}
|
|
2612
2648
|
return t;
|
|
2613
2649
|
}
|
|
2614
|
-
function
|
|
2615
|
-
return
|
|
2650
|
+
function It(e, t) {
|
|
2651
|
+
return re(e) ? X : E(j(t), We);
|
|
2616
2652
|
}
|
|
2617
|
-
function
|
|
2653
|
+
function gn(e, t) {
|
|
2618
2654
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2619
2655
|
}
|
|
2620
|
-
async function
|
|
2621
|
-
const r =
|
|
2656
|
+
async function mn(e, t, s, n) {
|
|
2657
|
+
const r = Zt(e.headers);
|
|
2622
2658
|
n({
|
|
2623
2659
|
...t,
|
|
2624
2660
|
responseStatus: e.status,
|
|
2625
2661
|
responseHeaders: r,
|
|
2626
|
-
responseBody: await
|
|
2662
|
+
responseBody: await yn(e),
|
|
2627
2663
|
durationMs: Date.now() - s
|
|
2628
2664
|
});
|
|
2629
2665
|
}
|
|
2630
|
-
async function
|
|
2631
|
-
if (!
|
|
2666
|
+
async function yn(e) {
|
|
2667
|
+
if (!Qt(e.headers))
|
|
2632
2668
|
return;
|
|
2633
2669
|
let t = null, s = null;
|
|
2634
2670
|
try {
|
|
2635
2671
|
if (t = e.clone().body?.getReader() ?? null, !t)
|
|
2636
2672
|
return;
|
|
2637
|
-
const n = new Promise((
|
|
2673
|
+
const n = new Promise((c) => {
|
|
2638
2674
|
s = window.setTimeout(() => {
|
|
2639
|
-
t?.cancel(),
|
|
2640
|
-
},
|
|
2675
|
+
t?.cancel(), c("timeout");
|
|
2676
|
+
}, je);
|
|
2641
2677
|
}), r = new TextDecoder();
|
|
2642
2678
|
let i = "", o = 0;
|
|
2643
2679
|
for (; ; ) {
|
|
2644
|
-
const
|
|
2645
|
-
if (
|
|
2680
|
+
const c = await Promise.race([t.read(), n]);
|
|
2681
|
+
if (c === "timeout")
|
|
2646
2682
|
return;
|
|
2647
|
-
const { done: u, value: l } =
|
|
2683
|
+
const { done: u, value: l } = c;
|
|
2648
2684
|
if (u)
|
|
2649
2685
|
return E(i + r.decode());
|
|
2650
|
-
const
|
|
2651
|
-
if (l.byteLength >
|
|
2652
|
-
return i += r.decode(l.subarray(0, Math.max(
|
|
2686
|
+
const a = pt - o;
|
|
2687
|
+
if (l.byteLength > a)
|
|
2688
|
+
return i += r.decode(l.subarray(0, Math.max(a, 0)), { stream: !0 }), t.cancel(), `${E(i)}... [truncated]`;
|
|
2653
2689
|
o += l.byteLength, i += r.decode(l, { stream: !0 });
|
|
2654
2690
|
}
|
|
2655
2691
|
} catch {
|
|
@@ -2659,26 +2695,26 @@ async function gn(e) {
|
|
|
2659
2695
|
s !== null && window.clearTimeout(s);
|
|
2660
2696
|
}
|
|
2661
2697
|
}
|
|
2662
|
-
function
|
|
2663
|
-
if (
|
|
2698
|
+
function Tn(e, t) {
|
|
2699
|
+
if (Qt(new Headers(t)))
|
|
2664
2700
|
try {
|
|
2665
2701
|
return e.responseType === "" || e.responseType === "text" ? E(e.responseText ?? "") : void 0;
|
|
2666
2702
|
} catch {
|
|
2667
2703
|
return;
|
|
2668
2704
|
}
|
|
2669
2705
|
}
|
|
2670
|
-
function
|
|
2706
|
+
function Ot(e) {
|
|
2671
2707
|
if (typeof e == "string")
|
|
2672
2708
|
return E(e);
|
|
2673
2709
|
}
|
|
2674
|
-
function
|
|
2710
|
+
function wn(e) {
|
|
2675
2711
|
return k({
|
|
2676
2712
|
...e,
|
|
2677
|
-
requestBody:
|
|
2678
|
-
responseBody:
|
|
2713
|
+
requestBody: Lt(e.requestBody),
|
|
2714
|
+
responseBody: Lt(e.responseBody)
|
|
2679
2715
|
});
|
|
2680
2716
|
}
|
|
2681
|
-
function
|
|
2717
|
+
function Lt(e) {
|
|
2682
2718
|
if (typeof e != "string")
|
|
2683
2719
|
return e;
|
|
2684
2720
|
const t = e.trim();
|
|
@@ -2690,14 +2726,14 @@ function Nt(e) {
|
|
|
2690
2726
|
return j(e);
|
|
2691
2727
|
}
|
|
2692
2728
|
}
|
|
2693
|
-
function
|
|
2729
|
+
function Qt(e) {
|
|
2694
2730
|
if (!e)
|
|
2695
2731
|
return !1;
|
|
2696
2732
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
2697
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
2733
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= pt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
2698
2734
|
}
|
|
2699
2735
|
function b(e, t = {}, s) {
|
|
2700
|
-
if (
|
|
2736
|
+
if (An(s))
|
|
2701
2737
|
return !0;
|
|
2702
2738
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
2703
2739
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -2707,12 +2743,12 @@ function b(e, t = {}, s) {
|
|
|
2707
2743
|
if (r.protocol !== "http:" && r.protocol !== "https:")
|
|
2708
2744
|
return !0;
|
|
2709
2745
|
const i = r.hostname.toLowerCase(), o = r.pathname.toLowerCase();
|
|
2710
|
-
return i === "pluno.ai" || i.endsWith(".pluno.ai") || o === "/api/product-agent" || o.startsWith("/api/product-agent/") || /(^|\/)(auth|oauth|login|logout)(\/|$)/.test(o) || /(^|\/)[^/]*token[^/]*(\/|$)/.test(o) || /(^|\/)(upload|uploads|attachments)(\/|$)/.test(o) || [...r.searchParams.keys()].some((
|
|
2746
|
+
return i === "pluno.ai" || i.endsWith(".pluno.ai") || o === "/api/product-agent" || o.startsWith("/api/product-agent/") || /(^|\/)(auth|oauth|login|logout)(\/|$)/.test(o) || /(^|\/)[^/]*token[^/]*(\/|$)/.test(o) || /(^|\/)(upload|uploads|attachments)(\/|$)/.test(o) || [...r.searchParams.keys()].some((c) => /^(x-amz-signature|x-goog-signature|signature|sig)$/i.test(c));
|
|
2711
2747
|
} catch {
|
|
2712
2748
|
return !0;
|
|
2713
2749
|
}
|
|
2714
2750
|
}
|
|
2715
|
-
function
|
|
2751
|
+
function In(e, t) {
|
|
2716
2752
|
if (b(e))
|
|
2717
2753
|
return !0;
|
|
2718
2754
|
try {
|
|
@@ -2722,23 +2758,23 @@ function yn(e, t) {
|
|
|
2722
2758
|
return !0;
|
|
2723
2759
|
}
|
|
2724
2760
|
}
|
|
2725
|
-
function
|
|
2761
|
+
function An(e) {
|
|
2726
2762
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
2727
2763
|
}
|
|
2728
|
-
function
|
|
2764
|
+
function Sn(e) {
|
|
2729
2765
|
const t = {};
|
|
2730
2766
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
2731
2767
|
const n = s.indexOf(":");
|
|
2732
2768
|
if (n <= 0)
|
|
2733
2769
|
continue;
|
|
2734
|
-
if (Object.keys(t).length >=
|
|
2770
|
+
if (Object.keys(t).length >= ft)
|
|
2735
2771
|
break;
|
|
2736
2772
|
const r = s.slice(0, n).trim();
|
|
2737
|
-
t[r] =
|
|
2773
|
+
t[r] = It(r, s.slice(n + 1).trim());
|
|
2738
2774
|
}
|
|
2739
2775
|
return t;
|
|
2740
2776
|
}
|
|
2741
|
-
function E(e, t =
|
|
2777
|
+
function E(e, t = pt) {
|
|
2742
2778
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
2743
2779
|
}
|
|
2744
2780
|
function tt(e) {
|
|
@@ -2752,31 +2788,31 @@ class F extends Error {
|
|
|
2752
2788
|
}
|
|
2753
2789
|
async function et(e, t) {
|
|
2754
2790
|
let s = null;
|
|
2755
|
-
for (let n = 0; n <
|
|
2791
|
+
for (let n = 0; n < Rt; n += 1)
|
|
2756
2792
|
try {
|
|
2757
2793
|
return await e();
|
|
2758
2794
|
} catch (r) {
|
|
2759
|
-
if (s = r, n >=
|
|
2795
|
+
if (s = r, n >= Rt - 1 || !En(r))
|
|
2760
2796
|
throw r;
|
|
2761
|
-
await
|
|
2797
|
+
await kn(n);
|
|
2762
2798
|
}
|
|
2763
2799
|
throw s instanceof Error ? s : new Error(t);
|
|
2764
2800
|
}
|
|
2765
|
-
function
|
|
2801
|
+
function kn(e) {
|
|
2766
2802
|
return new Promise((t) => {
|
|
2767
|
-
window.setTimeout(t,
|
|
2803
|
+
window.setTimeout(t, He[e] ?? 0);
|
|
2768
2804
|
});
|
|
2769
2805
|
}
|
|
2770
|
-
function
|
|
2771
|
-
return e instanceof F ?
|
|
2806
|
+
function En(e) {
|
|
2807
|
+
return e instanceof F ? Rn(e.status) : e instanceof TypeError;
|
|
2772
2808
|
}
|
|
2773
|
-
function
|
|
2809
|
+
function Rn(e) {
|
|
2774
2810
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
2775
2811
|
}
|
|
2776
|
-
function
|
|
2812
|
+
function _n(e) {
|
|
2777
2813
|
return e === 401 || e === 403;
|
|
2778
2814
|
}
|
|
2779
|
-
const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]",
|
|
2815
|
+
const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", Cn = "[REDACTED_SIGNED_URL]", bn = 20, Mn = /^(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, te = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ee = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, se = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ne = /\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, Pn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Un = /\bhttps?:\/\/[^\s"'<>]+/gi, Dn = /[),.;\]]+$/;
|
|
2780
2816
|
function k(e) {
|
|
2781
2817
|
return W(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2782
2818
|
}
|
|
@@ -2785,7 +2821,7 @@ function W(e, t, s) {
|
|
|
2785
2821
|
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : j(e);
|
|
2786
2822
|
if (e === null || typeof e != "object")
|
|
2787
2823
|
return e;
|
|
2788
|
-
if (t >=
|
|
2824
|
+
if (t >= bn)
|
|
2789
2825
|
return "[REDACTED_MAX_DEPTH]";
|
|
2790
2826
|
if (s.has(e))
|
|
2791
2827
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -2793,44 +2829,44 @@ function W(e, t, s) {
|
|
|
2793
2829
|
return e.map((r) => W(r, t + 1, s));
|
|
2794
2830
|
const n = {};
|
|
2795
2831
|
for (const [r, i] of Object.entries(e))
|
|
2796
|
-
|
|
2832
|
+
re(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? vn(i) : W(i, t + 1, s);
|
|
2797
2833
|
return n;
|
|
2798
2834
|
}
|
|
2799
|
-
function
|
|
2835
|
+
function re(e) {
|
|
2800
2836
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
2801
2837
|
return t.includes("authorization") || t.includes("cookie") || t.includes("password") || t.includes("passwd") || t === "pwd" || t.includes("secret") || t === "token" || t.endsWith("token") || t.includes("apikey") || t.includes("csrf") || t.includes("xsrf") || t === "jwt" || t === "session" || t === "signature" || t.includes("privatekey");
|
|
2802
2838
|
}
|
|
2803
|
-
function
|
|
2804
|
-
return typeof e == "string" ?
|
|
2839
|
+
function vn(e) {
|
|
2840
|
+
return typeof e == "string" ? ie(e) : W(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2805
2841
|
}
|
|
2806
|
-
function
|
|
2842
|
+
function ie(e) {
|
|
2807
2843
|
try {
|
|
2808
2844
|
const t = new URL(e, location.href);
|
|
2809
2845
|
for (const s of Array.from(t.searchParams.keys()))
|
|
2810
|
-
|
|
2846
|
+
Mn.test(s) && t.searchParams.set(s, R);
|
|
2811
2847
|
return t.username && (t.username = R), t.password && (t.password = R), t.toString();
|
|
2812
2848
|
} catch {
|
|
2813
|
-
return
|
|
2849
|
+
return Nn(e);
|
|
2814
2850
|
}
|
|
2815
2851
|
}
|
|
2816
2852
|
function j(e) {
|
|
2817
|
-
return e.replace(
|
|
2853
|
+
return e.replace(Pn, Cn).replace(Un, On).replace(te, `Bearer ${R}`).replace(ee, `Basic ${R}`).replace(se, R).replace(ne, (t, s) => `${s}: ${X}`);
|
|
2818
2854
|
}
|
|
2819
|
-
function
|
|
2820
|
-
return e.replace(
|
|
2855
|
+
function Nn(e) {
|
|
2856
|
+
return e.replace(te, `Bearer ${R}`).replace(ee, `Basic ${R}`).replace(se, R).replace(ne, (t, s) => `${s}: ${X}`);
|
|
2821
2857
|
}
|
|
2822
|
-
function
|
|
2823
|
-
const t = e.match(
|
|
2824
|
-
return `${
|
|
2858
|
+
function On(e) {
|
|
2859
|
+
const t = e.match(Dn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
2860
|
+
return `${ie(s)}${t}`;
|
|
2825
2861
|
}
|
|
2826
2862
|
export {
|
|
2827
|
-
|
|
2863
|
+
At as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
2828
2864
|
rt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2865
|
+
Ee as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
2866
|
+
ke as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
2867
|
+
Re as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
2868
|
+
$t as PlunoProductAgent,
|
|
2869
|
+
Xe as calculateReconnectDelay,
|
|
2870
|
+
$t as default,
|
|
2871
|
+
ps as getProductAgentOriginAccessErrorMessage
|
|
2836
2872
|
};
|