@pluno/product-agent-web 0.1.81 → 0.1.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/product-agent-sdk.js +438 -471
- package/dist/scheduledChatContinuations.d.ts +3 -11
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const t = await
|
|
1
|
+
const ee = "pluno-product-agent-attachments";
|
|
2
|
+
const et = "files";
|
|
3
|
+
async function Ut(e) {
|
|
4
|
+
const t = await W();
|
|
5
5
|
await vt(t, "readwrite", (s) => s.put(e));
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
8
|
-
const t = await
|
|
7
|
+
async function se(e) {
|
|
8
|
+
const t = await W(), s = await vt(
|
|
9
9
|
t,
|
|
10
10
|
"readonly",
|
|
11
11
|
(r) => r.get(e)
|
|
@@ -13,12 +13,12 @@ async function ne(e) {
|
|
|
13
13
|
if (!s)
|
|
14
14
|
return null;
|
|
15
15
|
const n = Date.now();
|
|
16
|
-
return await
|
|
16
|
+
return await Dt(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
|
|
17
17
|
}
|
|
18
|
-
async function
|
|
19
|
-
const s = await
|
|
20
|
-
await
|
|
21
|
-
const r = await
|
|
18
|
+
async function Dt(e, t) {
|
|
19
|
+
const s = await W();
|
|
20
|
+
await lt(s, "readwrite", async (n) => {
|
|
21
|
+
const r = await ut(
|
|
22
22
|
n.get(e)
|
|
23
23
|
);
|
|
24
24
|
r && n.put({
|
|
@@ -27,28 +27,28 @@ async function Nt(e, t) {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
const t = await
|
|
32
|
-
await
|
|
30
|
+
async function ne(e = 864e5) {
|
|
31
|
+
const t = await W(), s = Date.now() - e;
|
|
32
|
+
await lt(t, "readwrite", async (n) => {
|
|
33
33
|
const r = n.index("lastUsedAt");
|
|
34
|
-
(await
|
|
34
|
+
(await ut(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function W() {
|
|
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(ee, 1);
|
|
40
40
|
s.onupgradeneeded = () => {
|
|
41
|
-
const r = s.result.createObjectStore(
|
|
41
|
+
const r = s.result.createObjectStore(et, { 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
46
|
async function vt(e, t, s) {
|
|
47
|
-
return await
|
|
47
|
+
return await lt(e, t, async (n) => await ut(s(n)));
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function lt(e, t, s) {
|
|
50
50
|
return new Promise((n, r) => {
|
|
51
|
-
const i = e.transaction(
|
|
51
|
+
const i = e.transaction(et, t), o = i.objectStore(et);
|
|
52
52
|
let a, u = !1;
|
|
53
53
|
s(o).then((l) => {
|
|
54
54
|
a = l;
|
|
@@ -68,16 +68,16 @@ function ct(e, t, s) {
|
|
|
68
68
|
};
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function ut(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 re(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 Nt(e, t, s) {
|
|
80
|
+
const n = Reflect.get(e, "pluno"), r = re(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,82 +91,56 @@ function Ot(e, t, s) {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
const
|
|
95
|
-
function
|
|
96
|
-
return `const plunoScheduledContinuation = Object.freeze(${JSON.stringify({
|
|
97
|
-
defaultTaskId: `scheduled-${t}`,
|
|
98
|
-
resultKey: Lt,
|
|
99
|
-
expiresAfterDueMs: ut
|
|
100
|
-
})});
|
|
101
|
-
${e}`;
|
|
102
|
-
}
|
|
103
|
-
async function le(e, {
|
|
104
|
-
clientId: t,
|
|
105
|
-
sessionId: s,
|
|
106
|
-
callId: n
|
|
107
|
-
}, r) {
|
|
108
|
-
try {
|
|
109
|
-
const i = ue(e, {
|
|
110
|
-
clientId: t,
|
|
111
|
-
sessionId: s,
|
|
112
|
-
callId: n
|
|
113
|
-
});
|
|
114
|
-
if (!i)
|
|
115
|
-
return e;
|
|
116
|
-
if (!await r(i))
|
|
117
|
-
throw new Error("Scheduled continuations are unavailable in this runtime.");
|
|
118
|
-
return Tt(e, {
|
|
119
|
-
ok: !0,
|
|
120
|
-
id: i.id,
|
|
121
|
-
dueAt: i.dueAt
|
|
122
|
-
});
|
|
123
|
-
} catch (i) {
|
|
124
|
-
return Tt(e, {
|
|
125
|
-
ok: !1,
|
|
126
|
-
error: i instanceof Error ? i.message : String(i)
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function ue(e, {
|
|
94
|
+
const x = "pluno.productAgent.scheduledChatContinuation.", st = "pluno:scheduled-chat-continuation-changed", Ot = 10080 * 6e4, ie = 5e3, oe = 15e3;
|
|
95
|
+
function ae(e, {
|
|
131
96
|
clientId: t,
|
|
132
97
|
sessionId: s,
|
|
133
98
|
callId: n
|
|
134
99
|
}) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (r.ok !== !0 || !r.result || typeof r.result != "object")
|
|
139
|
-
return null;
|
|
140
|
-
const i = r.result[Lt];
|
|
141
|
-
if (i === void 0)
|
|
142
|
-
return null;
|
|
143
|
-
if (!i || typeof i != "object")
|
|
144
|
-
throw new Error("Scheduled continuation instruction must be an object.");
|
|
145
|
-
const o = i, a = `scheduled-${n}`;
|
|
146
|
-
if ((o.id ?? a) !== a)
|
|
147
|
-
throw new Error("Scheduled continuation id must use plunoScheduledContinuation.defaultTaskId.");
|
|
148
|
-
if (typeof o.prompt != "string" || o.prompt.trim().length === 0)
|
|
149
|
-
throw new Error("Scheduled continuation prompt must be a non-empty string.");
|
|
150
|
-
if (typeof o.dueAt != "number" || !Number.isFinite(o.dueAt))
|
|
151
|
-
throw new Error("Scheduled continuation dueAt must be a finite Unix time in milliseconds.");
|
|
152
|
-
return {
|
|
153
|
-
id: a,
|
|
100
|
+
return `const plunoScheduledContinuation = Object.freeze(${JSON.stringify({
|
|
101
|
+
storageKeyPrefix: x,
|
|
102
|
+
changedEvent: st,
|
|
154
103
|
clientId: t,
|
|
155
104
|
sessionId: s,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
105
|
+
defaultTaskId: `scheduled-${n}`,
|
|
106
|
+
expiresAfterDueMs: Ot
|
|
107
|
+
})});
|
|
108
|
+
const scheduleQuery = (query, delaySeconds) => {
|
|
109
|
+
if (typeof query !== "string" || query.trim().length === 0) {
|
|
110
|
+
throw new Error("scheduleQuery query must be a non-empty string.");
|
|
111
|
+
}
|
|
112
|
+
if (typeof delaySeconds !== "number" || !Number.isFinite(delaySeconds) || delaySeconds < 0) {
|
|
113
|
+
throw new Error("scheduleQuery delaySeconds must be a non-negative finite number.");
|
|
114
|
+
}
|
|
115
|
+
const dueAt = Date.now() + delaySeconds * 1000;
|
|
116
|
+
const task = {
|
|
117
|
+
id: plunoScheduledContinuation.defaultTaskId,
|
|
118
|
+
clientId: plunoScheduledContinuation.clientId,
|
|
119
|
+
sessionId: plunoScheduledContinuation.sessionId,
|
|
120
|
+
prompt: query.trim(),
|
|
121
|
+
dueAt,
|
|
122
|
+
expiresAt: dueAt + plunoScheduledContinuation.expiresAfterDueMs,
|
|
159
123
|
};
|
|
124
|
+
window.localStorage.setItem(
|
|
125
|
+
plunoScheduledContinuation.storageKeyPrefix + task.id,
|
|
126
|
+
JSON.stringify(task),
|
|
127
|
+
);
|
|
128
|
+
window.dispatchEvent(new CustomEvent(plunoScheduledContinuation.changedEvent, {
|
|
129
|
+
detail: { taskId: task.id },
|
|
130
|
+
}));
|
|
131
|
+
return Object.freeze({ id: task.id, dueAt: task.dueAt });
|
|
132
|
+
};
|
|
133
|
+
${e}`;
|
|
160
134
|
}
|
|
161
|
-
function
|
|
162
|
-
const t = e.storage === void 0 ?
|
|
135
|
+
function ce(e) {
|
|
136
|
+
const t = e.storage === void 0 ? le() : e.storage;
|
|
163
137
|
let s = null, n = !1, r = !1, i = !1, o = t !== null;
|
|
164
138
|
const a = /* @__PURE__ */ new Map(), u = () => {
|
|
165
139
|
s !== null && (clearTimeout(s), s = null);
|
|
166
140
|
}, l = () => {
|
|
167
141
|
u(), !(i || !o) && (s = setTimeout(() => {
|
|
168
142
|
s = null, h();
|
|
169
|
-
},
|
|
143
|
+
}, ie));
|
|
170
144
|
}, c = () => {
|
|
171
145
|
o = !1, u();
|
|
172
146
|
}, h = async () => {
|
|
@@ -196,7 +170,7 @@ function de(e) {
|
|
|
196
170
|
e.onTasksChanged?.(m);
|
|
197
171
|
for (const g of m)
|
|
198
172
|
if (!(g.clientId !== e.clientId || g.dueAt > f || a.has(g.id) || !await e.canDeliver(g))) {
|
|
199
|
-
a.set(g.id, f +
|
|
173
|
+
a.set(g.id, f + oe);
|
|
200
174
|
try {
|
|
201
175
|
await e.deliver(g);
|
|
202
176
|
} catch {
|
|
@@ -242,9 +216,9 @@ function U(e) {
|
|
|
242
216
|
if (!e || typeof e != "object")
|
|
243
217
|
return !1;
|
|
244
218
|
const t = e;
|
|
245
|
-
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 + Ot;
|
|
246
220
|
}
|
|
247
|
-
function
|
|
221
|
+
function le() {
|
|
248
222
|
let e;
|
|
249
223
|
try {
|
|
250
224
|
e = window.localStorage, e.length;
|
|
@@ -256,13 +230,13 @@ function he() {
|
|
|
256
230
|
const t = [];
|
|
257
231
|
for (let s = 0; s < e.length; s += 1) {
|
|
258
232
|
const n = e.key(s);
|
|
259
|
-
if (!n?.startsWith(
|
|
233
|
+
if (!n?.startsWith(x))
|
|
260
234
|
continue;
|
|
261
235
|
const r = e.getItem(n);
|
|
262
236
|
if (r)
|
|
263
237
|
try {
|
|
264
238
|
const i = JSON.parse(r);
|
|
265
|
-
U(i) && n ===
|
|
239
|
+
U(i) && n === X(i.id) ? t.push(i) : (e.removeItem(n), s -= 1);
|
|
266
240
|
} catch {
|
|
267
241
|
e.removeItem(n), s -= 1;
|
|
268
242
|
}
|
|
@@ -270,34 +244,29 @@ function he() {
|
|
|
270
244
|
return t;
|
|
271
245
|
},
|
|
272
246
|
async set(t) {
|
|
273
|
-
e.setItem(
|
|
247
|
+
e.setItem(X(t.id), JSON.stringify(t));
|
|
274
248
|
},
|
|
275
249
|
async remove(t) {
|
|
276
|
-
e.removeItem(
|
|
250
|
+
e.removeItem(X(t));
|
|
277
251
|
},
|
|
278
252
|
subscribe(t) {
|
|
279
|
-
const s = (
|
|
280
|
-
|
|
253
|
+
const s = (r) => {
|
|
254
|
+
r.key?.startsWith(x) && t();
|
|
255
|
+
}, n = () => t();
|
|
256
|
+
return window.addEventListener("storage", s), window.addEventListener(st, n), () => {
|
|
257
|
+
window.removeEventListener("storage", s), window.removeEventListener(st, n);
|
|
281
258
|
};
|
|
282
|
-
return window.addEventListener("storage", s), () => window.removeEventListener("storage", s);
|
|
283
259
|
}
|
|
284
260
|
};
|
|
285
261
|
}
|
|
286
|
-
function
|
|
287
|
-
return {
|
|
288
|
-
...e && typeof e == "object" ? e : { result: e },
|
|
289
|
-
...t.ok === !1 ? { ok: !1 } : {},
|
|
290
|
-
scheduledContinuation: t
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
function G(e) {
|
|
294
|
-
return `${et}${e}`;
|
|
262
|
+
function X(e) {
|
|
263
|
+
return `${x}${e}`;
|
|
295
264
|
}
|
|
296
|
-
const
|
|
265
|
+
const K = "pluno.productAgent.transportId", ue = "pluno.productAgent.transportIdentity", J = "pluno.productAgent.transportIdentity.event", de = 50, he = globalThis.setTimeout.bind(globalThis);
|
|
297
266
|
let M = null;
|
|
298
267
|
const L = /* @__PURE__ */ new Set();
|
|
299
|
-
async function
|
|
300
|
-
const t = e.randomUUID(), s = e.storage.getItem(
|
|
268
|
+
async function pe(e = Lt()) {
|
|
269
|
+
const t = e.randomUUID(), s = e.storage.getItem(K);
|
|
301
270
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
302
271
|
const o = e.channel.subscribe((u) => {
|
|
303
272
|
if (!(u.senderId === t || u.transportId !== n)) {
|
|
@@ -315,14 +284,14 @@ async function me(e = Bt()) {
|
|
|
315
284
|
}
|
|
316
285
|
});
|
|
317
286
|
if (!s)
|
|
318
|
-
e.storage.setItem(
|
|
287
|
+
e.storage.setItem(K, n), r = !0;
|
|
319
288
|
else
|
|
320
289
|
for (; ; ) {
|
|
321
290
|
if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
|
|
322
291
|
r = !0;
|
|
323
292
|
break;
|
|
324
293
|
}
|
|
325
|
-
n = e.randomUUID(), e.storage.setItem(
|
|
294
|
+
n = e.randomUUID(), e.storage.setItem(K, n);
|
|
326
295
|
}
|
|
327
296
|
let a = !1;
|
|
328
297
|
return {
|
|
@@ -332,14 +301,14 @@ async function me(e = Bt()) {
|
|
|
332
301
|
}
|
|
333
302
|
};
|
|
334
303
|
}
|
|
335
|
-
async function
|
|
336
|
-
M || (M =
|
|
304
|
+
async function fe() {
|
|
305
|
+
M || (M = pe(Lt()), M.then((n) => {
|
|
337
306
|
const r = (i) => {
|
|
338
307
|
i.persisted || (n.release(), M = null, L.clear(), window.removeEventListener("pagehide", r));
|
|
339
308
|
};
|
|
340
309
|
window.addEventListener("pagehide", r);
|
|
341
310
|
}));
|
|
342
|
-
const e = await M, t =
|
|
311
|
+
const e = await M, t = ge();
|
|
343
312
|
L.add(t);
|
|
344
313
|
let s = !1;
|
|
345
314
|
return {
|
|
@@ -350,23 +319,23 @@ async function ye() {
|
|
|
350
319
|
}
|
|
351
320
|
};
|
|
352
321
|
}
|
|
353
|
-
function
|
|
322
|
+
function ge() {
|
|
354
323
|
let e = 0;
|
|
355
324
|
for (; L.has(e); )
|
|
356
325
|
e += 1;
|
|
357
326
|
return e;
|
|
358
327
|
}
|
|
359
|
-
function
|
|
328
|
+
function Lt() {
|
|
360
329
|
return {
|
|
361
330
|
storage: window.sessionStorage,
|
|
362
|
-
channel:
|
|
331
|
+
channel: me(),
|
|
363
332
|
randomUUID: () => crypto.randomUUID(),
|
|
364
|
-
settle: () => new Promise((e) =>
|
|
333
|
+
settle: () => new Promise((e) => he(e, de))
|
|
365
334
|
};
|
|
366
335
|
}
|
|
367
|
-
function
|
|
336
|
+
function me() {
|
|
368
337
|
if (typeof BroadcastChannel < "u") {
|
|
369
|
-
const e = new BroadcastChannel(
|
|
338
|
+
const e = new BroadcastChannel(ue);
|
|
370
339
|
return {
|
|
371
340
|
postMessage: (t) => e.postMessage(t),
|
|
372
341
|
subscribe: (t) => {
|
|
@@ -376,11 +345,11 @@ function we() {
|
|
|
376
345
|
close: () => e.close()
|
|
377
346
|
};
|
|
378
347
|
}
|
|
379
|
-
return
|
|
348
|
+
return ye();
|
|
380
349
|
}
|
|
381
|
-
function
|
|
350
|
+
function ye() {
|
|
382
351
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
383
|
-
if (s.key !==
|
|
352
|
+
if (s.key !== J || !s.newValue)
|
|
384
353
|
return;
|
|
385
354
|
const n = JSON.parse(s.newValue);
|
|
386
355
|
for (const r of e)
|
|
@@ -389,9 +358,9 @@ function Ie() {
|
|
|
389
358
|
return window.addEventListener("storage", t), {
|
|
390
359
|
postMessage: (s) => {
|
|
391
360
|
window.localStorage.setItem(
|
|
392
|
-
|
|
361
|
+
J,
|
|
393
362
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
394
|
-
), window.localStorage.removeItem(
|
|
363
|
+
), window.localStorage.removeItem(J);
|
|
395
364
|
},
|
|
396
365
|
subscribe: (s) => (e.add(s), () => e.delete(s)),
|
|
397
366
|
close: () => {
|
|
@@ -399,17 +368,17 @@ function Ie() {
|
|
|
399
368
|
}
|
|
400
369
|
};
|
|
401
370
|
}
|
|
402
|
-
const
|
|
403
|
-
function
|
|
404
|
-
return Math.max(t,
|
|
371
|
+
const nt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Te = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', we = ".pluno-pa-widget__panel", Ie = ".pluno-pa-widget__timeline", Tt = `${nt}[data-pluno-sdk-preview-channel]`, Ae = "https://app.pluno.ai", Se = "gpt-5.6-sol", ke = 2e4, Ee = 1e4, Re = 1e4, Ce = 1e4, _e = 1e4, be = 1e3, wt = 3e4, It = 0.2, At = 6e4, Me = 15e3, D = 3, Pe = 2e3, Ue = 15e3, De = 1e3, ve = 100, Ne = 8e3, Oe = 15e3, St = 3, Le = [300, 1e3], dt = 64e3, V = 4e3, ht = 30, Be = 2e3, qe = 1e3, xe = 200 * 1024 * 1024, pt = "Image is too large for model vision input.", He = 100, Bt = "pluno.productAgent.state.", rt = "pluno.productAgent.pendingEvents.", j = "pluno.productAgent.activeToolCalls.", Fe = 100;
|
|
372
|
+
function v(e, t = 0) {
|
|
373
|
+
return Math.max(t, Pe * 4 ** e);
|
|
405
374
|
}
|
|
406
375
|
const B = /* @__PURE__ */ new Set();
|
|
407
|
-
let
|
|
408
|
-
function
|
|
409
|
-
const s = Math.min(
|
|
410
|
-
return Math.min(
|
|
376
|
+
let N = null;
|
|
377
|
+
function We(e, t = Math.random) {
|
|
378
|
+
const s = Math.min(wt, be * 2 ** e), n = 1 - It + t() * It * 2;
|
|
379
|
+
return Math.min(wt, Math.round(s * n));
|
|
411
380
|
}
|
|
412
|
-
function
|
|
381
|
+
function je(e, t, s) {
|
|
413
382
|
return new Promise((n, r) => {
|
|
414
383
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
415
384
|
e.then(
|
|
@@ -426,9 +395,9 @@ class qt {
|
|
|
426
395
|
constructor(t, s) {
|
|
427
396
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
428
397
|
...this.state,
|
|
429
|
-
starterPrompts:
|
|
398
|
+
starterPrompts: ms(t.initialStarterPrompts)
|
|
430
399
|
};
|
|
431
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
400
|
+
const n = t.restorePersistedState === !1 ? null : Gs(t.clientId, t.expectedPersistedSessionId);
|
|
432
401
|
n && (this.state = {
|
|
433
402
|
...this.state,
|
|
434
403
|
...n,
|
|
@@ -439,14 +408,17 @@ class qt {
|
|
|
439
408
|
assistantDraftRunId: null,
|
|
440
409
|
isThinking: !1,
|
|
441
410
|
lastError: null
|
|
442
|
-
}), this.queuedClientEvents =
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
), P(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler =
|
|
411
|
+
}), this.queuedClientEvents = Qs(
|
|
412
|
+
Ks(t.clientId),
|
|
413
|
+
Vs(t.clientId)
|
|
414
|
+
), P(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = ce({
|
|
446
415
|
clientId: t.clientId,
|
|
447
416
|
canDeliver: (r) => r.sessionId === this.state.sessionId,
|
|
448
417
|
deliver: async (r) => {
|
|
449
|
-
if (!this.sendMessage(r.prompt, {
|
|
418
|
+
if (!this.sendMessage(r.prompt, {
|
|
419
|
+
clientMessageId: r.id,
|
|
420
|
+
initiatedBy: "pluno"
|
|
421
|
+
}))
|
|
450
422
|
throw new Error("Scheduled continuation could not be sent.");
|
|
451
423
|
}
|
|
452
424
|
});
|
|
@@ -507,14 +479,14 @@ class qt {
|
|
|
507
479
|
lastErrorCode: null
|
|
508
480
|
};
|
|
509
481
|
static async init(t) {
|
|
510
|
-
const s = await
|
|
482
|
+
const s = await fe(), n = new qt({
|
|
511
483
|
...t,
|
|
512
|
-
backendUrl:
|
|
513
|
-
clientId: t.clientId ??
|
|
514
|
-
model: t.model ??
|
|
484
|
+
backendUrl: as(t.backendUrl ?? Ae),
|
|
485
|
+
clientId: t.clientId ?? As(),
|
|
486
|
+
model: t.model ?? Se
|
|
515
487
|
}, s);
|
|
516
488
|
try {
|
|
517
|
-
|
|
489
|
+
ne().catch((r) => {
|
|
518
490
|
y("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
519
491
|
message: r instanceof Error ? r.message : String(r)
|
|
520
492
|
});
|
|
@@ -546,14 +518,14 @@ class qt {
|
|
|
546
518
|
lastError: null
|
|
547
519
|
});
|
|
548
520
|
try {
|
|
549
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
521
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await je(this.options.tokenProvider(), Re, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
550
522
|
return;
|
|
551
523
|
if (!this.token && !this.options.webSocketFactory)
|
|
552
524
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
553
|
-
const s =
|
|
525
|
+
const s = ls(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
554
526
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
555
527
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (y("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
556
|
-
},
|
|
528
|
+
}, Ce), n.addEventListener("open", () => {
|
|
557
529
|
this.socket !== n || (this.clearSocketConnectTimer(), y("web-sdk.agent", "Pluno socket opened", {
|
|
558
530
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
559
531
|
isThinking: this.state.isThinking
|
|
@@ -565,9 +537,9 @@ class qt {
|
|
|
565
537
|
pageUrl: location.href
|
|
566
538
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
567
539
|
this.socket === n && (y("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
568
|
-
},
|
|
540
|
+
}, _e));
|
|
569
541
|
}), n.addEventListener("message", (r) => {
|
|
570
|
-
this.socket === n && this.handleServerEvent(
|
|
542
|
+
this.socket === n && this.handleServerEvent(gs(r.data));
|
|
571
543
|
}), n.addEventListener("close", (r) => {
|
|
572
544
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (y("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
573
545
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -600,7 +572,7 @@ class qt {
|
|
|
600
572
|
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;
|
|
601
573
|
}
|
|
602
574
|
destroy() {
|
|
603
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(),
|
|
575
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), tn(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
604
576
|
for (const t of Object.values(this.listeners))
|
|
605
577
|
t?.clear();
|
|
606
578
|
}
|
|
@@ -631,11 +603,12 @@ class qt {
|
|
|
631
603
|
type: "chat.user_message",
|
|
632
604
|
sessionId: this.state.sessionId ?? void 0,
|
|
633
605
|
clientMessageId: a,
|
|
606
|
+
initiatedBy: s.initiatedBy,
|
|
634
607
|
content: n,
|
|
635
608
|
attachments: i.length > 0 ? i : void 0,
|
|
636
609
|
page: o,
|
|
637
610
|
model: this.options.model,
|
|
638
|
-
metadata:
|
|
611
|
+
metadata: kt(this.options.metadata)
|
|
639
612
|
};
|
|
640
613
|
return this.activeClientMessageId = a, this.activeUserMessageEvent = c, this.markThinkingProgress(), this.send(c), this.startBackgroundAttachmentUploads(a, i), a;
|
|
641
614
|
}
|
|
@@ -647,12 +620,12 @@ class qt {
|
|
|
647
620
|
const s = O(), n = {
|
|
648
621
|
id: s,
|
|
649
622
|
name: t.name || "attachment",
|
|
650
|
-
mimeType:
|
|
623
|
+
mimeType: bt(t),
|
|
651
624
|
sizeBytes: t.size
|
|
652
625
|
};
|
|
653
626
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
654
627
|
const r = Date.now();
|
|
655
|
-
return
|
|
628
|
+
return Ut({
|
|
656
629
|
attachmentId: s,
|
|
657
630
|
name: n.name,
|
|
658
631
|
mimeType: n.mimeType,
|
|
@@ -707,7 +680,7 @@ class qt {
|
|
|
707
680
|
waitForSession: r,
|
|
708
681
|
notifyCompletion: i
|
|
709
682
|
}) {
|
|
710
|
-
const o = r ? await this.waitForSessionId() : this.state.sessionId, a =
|
|
683
|
+
const o = r ? await this.waitForSessionId() : this.state.sessionId, a = bt(t), u = {
|
|
711
684
|
sessionId: o ?? void 0,
|
|
712
685
|
attachmentId: s.id,
|
|
713
686
|
clientId: this.options.clientId,
|
|
@@ -717,23 +690,23 @@ class qt {
|
|
|
717
690
|
sizeBytes: t.size,
|
|
718
691
|
page: A(),
|
|
719
692
|
model: this.options.model,
|
|
720
|
-
metadata:
|
|
721
|
-
}, l = this.options.prepareAttachmentUpload ? await
|
|
693
|
+
metadata: kt(this.options.metadata)
|
|
694
|
+
}, l = this.options.prepareAttachmentUpload ? await tt(
|
|
722
695
|
() => this.options.prepareAttachmentUpload(u),
|
|
723
696
|
"Failed to prepare attachment upload"
|
|
724
697
|
) : await this.prepareEmbedAttachmentUpload(u);
|
|
725
|
-
await
|
|
698
|
+
await tt(async () => {
|
|
726
699
|
const h = await fetch(l.uploadUrl, {
|
|
727
700
|
method: l.uploadMethod,
|
|
728
701
|
headers: l.uploadHeaders,
|
|
729
702
|
body: t
|
|
730
703
|
});
|
|
731
704
|
if (!h.ok)
|
|
732
|
-
throw new
|
|
705
|
+
throw new q("Failed to upload attachment", h.status);
|
|
733
706
|
return h;
|
|
734
707
|
}, "Failed to upload attachment"), this.setState({ sessionId: l.sessionId });
|
|
735
|
-
const c =
|
|
736
|
-
return this.updateAttachmentInState(s.id, c), s.id &&
|
|
708
|
+
const c = Gt(l.attachment, this.options.backendUrl);
|
|
709
|
+
return this.updateAttachmentInState(s.id, c), s.id && Dt(s.id, {
|
|
737
710
|
sessionId: l.sessionId,
|
|
738
711
|
fileUrl: c.fileUrl,
|
|
739
712
|
gcsPath: c.gcsPath,
|
|
@@ -755,7 +728,7 @@ class qt {
|
|
|
755
728
|
return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
|
|
756
729
|
const n = window.setTimeout(() => {
|
|
757
730
|
r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
|
|
758
|
-
},
|
|
731
|
+
}, Oe), r = this.on("state", (i) => {
|
|
759
732
|
i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
|
|
760
733
|
});
|
|
761
734
|
});
|
|
@@ -773,18 +746,18 @@ class qt {
|
|
|
773
746
|
}
|
|
774
747
|
async prepareEmbedAttachmentUpload(t) {
|
|
775
748
|
let s = !1;
|
|
776
|
-
return await
|
|
749
|
+
return await tt(async () => {
|
|
777
750
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
778
751
|
if (n.ok)
|
|
779
752
|
return await n.json();
|
|
780
|
-
if (
|
|
753
|
+
if (wn(n.status) && this.options.tokenProvider && !s) {
|
|
781
754
|
s = !0;
|
|
782
755
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
783
756
|
if (r.ok)
|
|
784
757
|
return await r.json();
|
|
785
|
-
throw new
|
|
758
|
+
throw new q("Failed to prepare attachment upload", r.status);
|
|
786
759
|
}
|
|
787
|
-
throw new
|
|
760
|
+
throw new q("Failed to prepare attachment upload", n.status);
|
|
788
761
|
}, "Failed to prepare attachment upload");
|
|
789
762
|
}
|
|
790
763
|
async fetchEmbedAttachmentUpload(t) {
|
|
@@ -822,7 +795,7 @@ class qt {
|
|
|
822
795
|
const s = O(), n = new Promise((i, o) => {
|
|
823
796
|
const a = window.setTimeout(() => {
|
|
824
797
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
825
|
-
},
|
|
798
|
+
}, Ne);
|
|
826
799
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
827
800
|
}), r = {
|
|
828
801
|
type: "sessions.list",
|
|
@@ -879,7 +852,7 @@ class qt {
|
|
|
879
852
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
880
853
|
return;
|
|
881
854
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
882
|
-
const t =
|
|
855
|
+
const t = us();
|
|
883
856
|
this.sendNow(
|
|
884
857
|
S({
|
|
885
858
|
type: "starter_prompts.page_context",
|
|
@@ -890,13 +863,13 @@ class qt {
|
|
|
890
863
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
891
864
|
}
|
|
892
865
|
startStarterPromptUrlWatcher() {
|
|
893
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
866
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = ds(() => this.handleStarterPromptUrlChange()));
|
|
894
867
|
}
|
|
895
868
|
handleStarterPromptUrlChange() {
|
|
896
869
|
const t = location.href;
|
|
897
870
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
898
871
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
899
|
-
},
|
|
872
|
+
}, Fe));
|
|
900
873
|
}
|
|
901
874
|
refreshStarterPromptsForCurrentUrl() {
|
|
902
875
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -930,19 +903,19 @@ class qt {
|
|
|
930
903
|
this.clearHeartbeatAckTimer();
|
|
931
904
|
return;
|
|
932
905
|
}
|
|
933
|
-
if (
|
|
906
|
+
if (Ge(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
934
907
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
|
|
935
|
-
const s =
|
|
908
|
+
const s = ys(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
936
909
|
y("web-sdk.agent", "Received auth.ok appearance", {
|
|
937
910
|
hasAppearance: n,
|
|
938
911
|
rawAppearance: t.appearance,
|
|
939
912
|
normalizedAppearance: s
|
|
940
|
-
}), this.runtimeHelperJavascript =
|
|
941
|
-
const r =
|
|
942
|
-
user:
|
|
913
|
+
}), this.runtimeHelperJavascript = Ts(t.runtimeHelpers)?.javascript ?? null;
|
|
914
|
+
const r = Rt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
915
|
+
user: Ss(t.user),
|
|
943
916
|
status: "connected"
|
|
944
917
|
};
|
|
945
|
-
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !
|
|
918
|
+
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !ps() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
946
919
|
type: "page.upsert",
|
|
947
920
|
sessionId: this.state.sessionId,
|
|
948
921
|
page: A(),
|
|
@@ -952,28 +925,28 @@ class qt {
|
|
|
952
925
|
}
|
|
953
926
|
if (t.type === "starterPrompts.updated") {
|
|
954
927
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
955
|
-
starterPrompts:
|
|
928
|
+
starterPrompts: Rt(t, "starterPrompts"),
|
|
956
929
|
starterPromptsLoading: !1
|
|
957
930
|
});
|
|
958
931
|
return;
|
|
959
932
|
}
|
|
960
933
|
if (t.type === "conversation.state") {
|
|
961
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
934
|
+
const s = Array.isArray(t.items) ? t.items : [], n = qs(s);
|
|
962
935
|
if (n) {
|
|
963
|
-
const a =
|
|
936
|
+
const a = xs(s, n);
|
|
964
937
|
this.retryAttemptsByClientMessageId[n] = Math.max(
|
|
965
938
|
this.retryAttemptsByClientMessageId[n] ?? 0,
|
|
966
939
|
a
|
|
967
940
|
);
|
|
968
941
|
}
|
|
969
|
-
const r =
|
|
942
|
+
const r = Us(
|
|
970
943
|
this.state.messages,
|
|
971
|
-
|
|
972
|
-
), i =
|
|
973
|
-
if (!i &&
|
|
944
|
+
ks(s, this.options.backendUrl)
|
|
945
|
+
), i = Ct(r);
|
|
946
|
+
if (!i && Bs(this.state.messages, s))
|
|
974
947
|
return;
|
|
975
|
-
const o = i ? null :
|
|
976
|
-
if (this.latestRecoverableClientMessageId = o,
|
|
948
|
+
const o = i ? null : ot(s);
|
|
949
|
+
if (this.latestRecoverableClientMessageId = o, Os(r) && this.clearRetryTimers(), this.setState({
|
|
977
950
|
sessionId: k(t.session, "id") ?? this.state.sessionId,
|
|
978
951
|
messages: r,
|
|
979
952
|
...i ? { assistantDraft: "", assistantDraftRespondsToUserMessageId: null, assistantDraftRunId: null, isThinking: !1 } : o ? {
|
|
@@ -992,7 +965,7 @@ class qt {
|
|
|
992
965
|
if (t.type === "sessions.page") {
|
|
993
966
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
994
967
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
995
|
-
sessions:
|
|
968
|
+
sessions: Es(t.sessions),
|
|
996
969
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
997
970
|
}));
|
|
998
971
|
return;
|
|
@@ -1002,12 +975,12 @@ class qt {
|
|
|
1002
975
|
return;
|
|
1003
976
|
}
|
|
1004
977
|
if (t.type === "session.item") {
|
|
1005
|
-
const s =
|
|
978
|
+
const s = Ht(t.item, this.options.backendUrl);
|
|
1006
979
|
if (s) {
|
|
1007
980
|
s.role === "assistant" && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1008
981
|
const n = t.item.data;
|
|
1009
|
-
|
|
1010
|
-
const r =
|
|
982
|
+
Hs(n) && this.clearRunAckResyncRetryTimer();
|
|
983
|
+
const r = Ps(this.state.messages, s), i = Ct(r);
|
|
1011
984
|
this.setState({
|
|
1012
985
|
messages: r,
|
|
1013
986
|
assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
|
|
@@ -1055,7 +1028,7 @@ class qt {
|
|
|
1055
1028
|
if (this.retryAfterRetryableError(t))
|
|
1056
1029
|
return;
|
|
1057
1030
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1058
|
-
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u =
|
|
1031
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = cs(a.message);
|
|
1059
1032
|
u && console.error(u), this.setState({
|
|
1060
1033
|
status: "error",
|
|
1061
1034
|
isThinking: !1,
|
|
@@ -1081,7 +1054,7 @@ class qt {
|
|
|
1081
1054
|
if (i >= D)
|
|
1082
1055
|
return !1;
|
|
1083
1056
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1084
|
-
const o =
|
|
1057
|
+
const o = v(
|
|
1085
1058
|
i,
|
|
1086
1059
|
typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
|
|
1087
1060
|
);
|
|
@@ -1108,7 +1081,7 @@ class qt {
|
|
|
1108
1081
|
}
|
|
1109
1082
|
this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "reconnecting", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
|
|
1110
1083
|
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 });
|
|
1111
|
-
},
|
|
1084
|
+
}, v(n));
|
|
1112
1085
|
}
|
|
1113
1086
|
clearRetryTimers() {
|
|
1114
1087
|
for (const t of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1121,7 +1094,7 @@ class qt {
|
|
|
1121
1094
|
this.pendingSessionHistoryRequests.clear();
|
|
1122
1095
|
}
|
|
1123
1096
|
markThinkingProgress() {
|
|
1124
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1097
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(At), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1125
1098
|
}
|
|
1126
1099
|
scheduleThinkingWatchdog(t) {
|
|
1127
1100
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1138,7 +1111,7 @@ class qt {
|
|
|
1138
1111
|
scheduleRunAckWatchdog(t) {
|
|
1139
1112
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1140
1113
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1141
|
-
},
|
|
1114
|
+
}, Ue);
|
|
1142
1115
|
}
|
|
1143
1116
|
recoverMissedRunAck(t) {
|
|
1144
1117
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (y("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1162,8 +1135,8 @@ class qt {
|
|
|
1162
1135
|
sessionId: this.state.sessionId,
|
|
1163
1136
|
clientMessageId: t,
|
|
1164
1137
|
automatic: !0
|
|
1165
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1166
|
-
},
|
|
1138
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(At)));
|
|
1139
|
+
}, v(s)));
|
|
1167
1140
|
}
|
|
1168
1141
|
clearRunAckResyncRetryTimer() {
|
|
1169
1142
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1202,7 +1175,7 @@ class qt {
|
|
|
1202
1175
|
sessionId: this.state.sessionId,
|
|
1203
1176
|
clientMessageId: t,
|
|
1204
1177
|
resyncAttempts: s + 1
|
|
1205
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1178
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Me);
|
|
1206
1179
|
return;
|
|
1207
1180
|
}
|
|
1208
1181
|
this.setState({
|
|
@@ -1220,7 +1193,7 @@ class qt {
|
|
|
1220
1193
|
clientMessageId: t,
|
|
1221
1194
|
automatic: !0
|
|
1222
1195
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1223
|
-
},
|
|
1196
|
+
}, v(n)));
|
|
1224
1197
|
}
|
|
1225
1198
|
resyncThinkingSession() {
|
|
1226
1199
|
this.state.sessionId ? this.send({
|
|
@@ -1234,7 +1207,7 @@ class qt {
|
|
|
1234
1207
|
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;
|
|
1235
1208
|
if (!s || !n || !r)
|
|
1236
1209
|
return;
|
|
1237
|
-
if (r !== "execute_code" || !
|
|
1210
|
+
if (r !== "execute_code" || !an(o)) {
|
|
1238
1211
|
this.send({
|
|
1239
1212
|
type: "tool.result",
|
|
1240
1213
|
sessionId: s,
|
|
@@ -1250,7 +1223,7 @@ class qt {
|
|
|
1250
1223
|
});
|
|
1251
1224
|
return;
|
|
1252
1225
|
}
|
|
1253
|
-
const a =
|
|
1226
|
+
const a = Je(this.state.messages);
|
|
1254
1227
|
this.activeBrowserToolCalls.set(n, {
|
|
1255
1228
|
event: {
|
|
1256
1229
|
type: "tool.result",
|
|
@@ -1266,9 +1239,11 @@ class qt {
|
|
|
1266
1239
|
startedAtOrigin: location.origin
|
|
1267
1240
|
}), this.installSessionUserFilesApi(a);
|
|
1268
1241
|
let u = null, l;
|
|
1269
|
-
u = await this.executeRuntimeHelper(), l = await
|
|
1242
|
+
u = await this.executeRuntimeHelper(), l = await Et({
|
|
1270
1243
|
...o,
|
|
1271
|
-
javascript:
|
|
1244
|
+
javascript: ae(o.javascript, {
|
|
1245
|
+
clientId: this.options.clientId,
|
|
1246
|
+
sessionId: s,
|
|
1272
1247
|
callId: n
|
|
1273
1248
|
})
|
|
1274
1249
|
}).catch((c) => ({
|
|
@@ -1276,55 +1251,47 @@ class qt {
|
|
|
1276
1251
|
exception: {
|
|
1277
1252
|
message: c instanceof Error ? c.message : String(c)
|
|
1278
1253
|
}
|
|
1279
|
-
})),
|
|
1280
|
-
l,
|
|
1281
|
-
{
|
|
1282
|
-
clientId: this.options.clientId,
|
|
1283
|
-
sessionId: s,
|
|
1284
|
-
callId: n
|
|
1285
|
-
},
|
|
1286
|
-
(c) => this.scheduledChatContinuationScheduler.scheduleTask(c)
|
|
1287
|
-
), this.activeBrowserToolCalls.delete(n), this.send({
|
|
1254
|
+
})), this.activeBrowserToolCalls.delete(n), this.send({
|
|
1288
1255
|
type: "tool.result",
|
|
1289
1256
|
sessionId: s,
|
|
1290
1257
|
callId: n,
|
|
1291
1258
|
toolName: r,
|
|
1292
1259
|
summary: o.summary,
|
|
1293
1260
|
rawInput: S(o),
|
|
1294
|
-
rawOutput: S(
|
|
1295
|
-
}),
|
|
1261
|
+
rawOutput: S(ws(l, u))
|
|
1262
|
+
}), Js(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1296
1263
|
}
|
|
1297
1264
|
startPageLifecycleRecovery() {
|
|
1298
1265
|
if (this.pageLifecycleCleanup)
|
|
1299
1266
|
return;
|
|
1300
1267
|
const t = () => {
|
|
1301
|
-
|
|
1268
|
+
$t(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1302
1269
|
};
|
|
1303
1270
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1304
1271
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1305
1272
|
};
|
|
1306
1273
|
}
|
|
1307
1274
|
installSessionUserFilesApi(t) {
|
|
1308
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1275
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Ve(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1309
1276
|
}
|
|
1310
1277
|
cleanupSessionUserFilesApi() {
|
|
1311
|
-
this.sessionUserFilesApiCleanup && (
|
|
1278
|
+
this.sessionUserFilesApiCleanup && (rs(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1312
1279
|
}
|
|
1313
1280
|
async executeRuntimeHelper() {
|
|
1314
1281
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1315
1282
|
return null;
|
|
1316
|
-
const t = await
|
|
1283
|
+
const t = await Et({
|
|
1317
1284
|
javascript: this.runtimeHelperJavascript
|
|
1318
1285
|
});
|
|
1319
|
-
return t.ok === !1 ?
|
|
1286
|
+
return t.ok === !1 ? Is(t) : null;
|
|
1320
1287
|
}
|
|
1321
1288
|
enableNetworkCapture() {
|
|
1322
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1323
|
-
|
|
1289
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = $e((t) => {
|
|
1290
|
+
pn(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1324
1291
|
}));
|
|
1325
1292
|
}
|
|
1326
1293
|
enqueueNetworkEvent(t) {
|
|
1327
|
-
this.queuedNetworkEvents.length >=
|
|
1294
|
+
this.queuedNetworkEvents.length >= ve || (this.queuedNetworkEvents.push(hn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1328
1295
|
this.networkBatchTimer = null;
|
|
1329
1296
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1330
1297
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1333,12 +1300,12 @@ class qt {
|
|
|
1333
1300
|
page: A(),
|
|
1334
1301
|
events: s
|
|
1335
1302
|
});
|
|
1336
|
-
},
|
|
1303
|
+
}, De)));
|
|
1337
1304
|
}
|
|
1338
1305
|
scheduleReconnect() {
|
|
1339
1306
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1340
1307
|
return;
|
|
1341
|
-
const t =
|
|
1308
|
+
const t = We(this.reconnectAttempts);
|
|
1342
1309
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1343
1310
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1344
1311
|
y("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1354,8 +1321,8 @@ class qt {
|
|
|
1354
1321
|
const t = this.socket;
|
|
1355
1322
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1356
1323
|
this.socket === t && (y("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1357
|
-
},
|
|
1358
|
-
},
|
|
1324
|
+
}, Ee));
|
|
1325
|
+
}, ke);
|
|
1359
1326
|
}
|
|
1360
1327
|
stopHeartbeat() {
|
|
1361
1328
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1380,20 +1347,20 @@ class qt {
|
|
|
1380
1347
|
...this.state,
|
|
1381
1348
|
...t,
|
|
1382
1349
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
|
|
1383
|
-
},
|
|
1350
|
+
}, Xs(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
1384
1351
|
}
|
|
1385
1352
|
emit(t, s) {
|
|
1386
1353
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1387
1354
|
}
|
|
1388
1355
|
}
|
|
1389
1356
|
const Y = /* @__PURE__ */ new WeakMap();
|
|
1390
|
-
function
|
|
1391
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1357
|
+
function $e(e) {
|
|
1358
|
+
const t = window.__plunoProductAgentNetworkCapture ?? ze();
|
|
1392
1359
|
return t.subscribers.add(e), () => {
|
|
1393
1360
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1394
1361
|
};
|
|
1395
1362
|
}
|
|
1396
|
-
function
|
|
1363
|
+
function ze() {
|
|
1397
1364
|
const e = /* @__PURE__ */ new Set(), t = (T) => {
|
|
1398
1365
|
e.forEach((p) => {
|
|
1399
1366
|
try {
|
|
@@ -1410,22 +1377,22 @@ function Ke() {
|
|
|
1410
1377
|
throw m;
|
|
1411
1378
|
}
|
|
1412
1379
|
try {
|
|
1413
|
-
const m = p instanceof Request ? p : null, g =
|
|
1380
|
+
const m = p instanceof Request ? p : null, g = cn(p, m), I = Xt(d?.headers ?? m?.headers);
|
|
1414
1381
|
if (!b(g, I, d?.body)) {
|
|
1415
|
-
const
|
|
1416
|
-
requestId:
|
|
1417
|
-
url: E(g,
|
|
1382
|
+
const G = {
|
|
1383
|
+
requestId: Q("fetch"),
|
|
1384
|
+
url: E(g, V),
|
|
1418
1385
|
method: (d?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
1419
1386
|
requestHeaders: I,
|
|
1420
|
-
requestBody:
|
|
1387
|
+
requestBody: Mt(d?.body),
|
|
1421
1388
|
resourceType: "fetch",
|
|
1422
1389
|
startedAt: new Date(f).toISOString()
|
|
1423
1390
|
};
|
|
1424
1391
|
w.then(
|
|
1425
1392
|
(C) => {
|
|
1426
|
-
|
|
1393
|
+
ln(C, G, f, t).catch(() => {
|
|
1427
1394
|
t({
|
|
1428
|
-
...
|
|
1395
|
+
...G,
|
|
1429
1396
|
responseStatus: C.status,
|
|
1430
1397
|
durationMs: Date.now() - f
|
|
1431
1398
|
});
|
|
@@ -1433,7 +1400,7 @@ function Ke() {
|
|
|
1433
1400
|
},
|
|
1434
1401
|
(C) => {
|
|
1435
1402
|
t({
|
|
1436
|
-
...
|
|
1403
|
+
...G,
|
|
1437
1404
|
errorText: E(C instanceof Error ? C.message : String(C)),
|
|
1438
1405
|
durationMs: Date.now() - f
|
|
1439
1406
|
});
|
|
@@ -1446,9 +1413,9 @@ function Ke() {
|
|
|
1446
1413
|
}, a = function(p, d, f, w, m) {
|
|
1447
1414
|
const g = n.call(this, p, d, f ?? !0, w ?? void 0, m ?? void 0), I = typeof d == "string" ? d : d.toString();
|
|
1448
1415
|
return Y.set(this, {
|
|
1449
|
-
requestId:
|
|
1416
|
+
requestId: Q("xhr"),
|
|
1450
1417
|
method: String(p ?? "GET").toUpperCase(),
|
|
1451
|
-
url: E(I,
|
|
1418
|
+
url: E(I, V),
|
|
1452
1419
|
requestHeaders: {},
|
|
1453
1420
|
startedAtMs: Date.now(),
|
|
1454
1421
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1460,12 +1427,12 @@ function Ke() {
|
|
|
1460
1427
|
}, l = function(p) {
|
|
1461
1428
|
try {
|
|
1462
1429
|
const d = Y.get(this);
|
|
1463
|
-
d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody =
|
|
1430
|
+
d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = Mt(p), d.excluded || this.addEventListener(
|
|
1464
1431
|
"loadend",
|
|
1465
1432
|
() => {
|
|
1466
1433
|
queueMicrotask(() => {
|
|
1467
1434
|
try {
|
|
1468
|
-
const f =
|
|
1435
|
+
const f = gn(this.getAllResponseHeaders());
|
|
1469
1436
|
t({
|
|
1470
1437
|
requestId: d.requestId,
|
|
1471
1438
|
url: d.url,
|
|
@@ -1475,7 +1442,7 @@ function Ke() {
|
|
|
1475
1442
|
resourceType: "xhr",
|
|
1476
1443
|
responseStatus: this.status,
|
|
1477
1444
|
responseHeaders: f,
|
|
1478
|
-
responseBody:
|
|
1445
|
+
responseBody: dn(this, f),
|
|
1479
1446
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1480
1447
|
startedAt: d.startedAt,
|
|
1481
1448
|
durationMs: Date.now() - d.startedAtMs
|
|
@@ -1516,8 +1483,8 @@ function Ke() {
|
|
|
1516
1483
|
continue;
|
|
1517
1484
|
const f = performance.timeOrigin + d.startTime;
|
|
1518
1485
|
t({
|
|
1519
|
-
requestId:
|
|
1520
|
-
url: E(d.name,
|
|
1486
|
+
requestId: Q("resource"),
|
|
1487
|
+
url: E(d.name, V),
|
|
1521
1488
|
method: "GET",
|
|
1522
1489
|
resourceType: "resource",
|
|
1523
1490
|
responseStatus: d.responseStatus,
|
|
@@ -1567,15 +1534,15 @@ function y(e, t, s) {
|
|
|
1567
1534
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1568
1535
|
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 }));
|
|
1569
1536
|
}
|
|
1570
|
-
function
|
|
1537
|
+
function kt(e) {
|
|
1571
1538
|
const t = typeof e == "function" ? e() : e;
|
|
1572
1539
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1573
1540
|
}
|
|
1574
|
-
function
|
|
1541
|
+
function Ge(e) {
|
|
1575
1542
|
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";
|
|
1576
1543
|
}
|
|
1577
|
-
const
|
|
1578
|
-
function
|
|
1544
|
+
const Xe = 5e3, Ke = 12e4;
|
|
1545
|
+
function Je(e) {
|
|
1579
1546
|
const t = [];
|
|
1580
1547
|
for (const s of e)
|
|
1581
1548
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1586,17 +1553,17 @@ function Ze(e) {
|
|
|
1586
1553
|
});
|
|
1587
1554
|
return t;
|
|
1588
1555
|
}
|
|
1589
|
-
function
|
|
1556
|
+
function Ve(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1590
1557
|
const n = [
|
|
1591
|
-
|
|
1592
|
-
|
|
1558
|
+
Ye(e, t, s),
|
|
1559
|
+
Ze()
|
|
1593
1560
|
].filter((r) => typeof r == "function");
|
|
1594
1561
|
return () => {
|
|
1595
1562
|
for (const r of n.reverse())
|
|
1596
1563
|
r();
|
|
1597
1564
|
};
|
|
1598
1565
|
}
|
|
1599
|
-
function
|
|
1566
|
+
function Ye(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1600
1567
|
const n = new Map(e.map((l) => [l.id, l])), r = (l) => ({
|
|
1601
1568
|
id: l.id,
|
|
1602
1569
|
name: l.name,
|
|
@@ -1616,7 +1583,7 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1616
1583
|
const T = s.get(c.id);
|
|
1617
1584
|
if (T)
|
|
1618
1585
|
return T;
|
|
1619
|
-
const p = await
|
|
1586
|
+
const p = await se(c.id).then((m) => m?.blob ?? null).catch((m) => (y("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
|
|
1620
1587
|
attachmentId: c.id,
|
|
1621
1588
|
name: c.name,
|
|
1622
1589
|
message: m instanceof Error ? m.message : String(m)
|
|
@@ -1625,13 +1592,13 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1625
1592
|
return s.set(c.id, p), p;
|
|
1626
1593
|
if (!c.fileUrl)
|
|
1627
1594
|
throw new Error(`Pluno user file is missing content: ${l}`);
|
|
1628
|
-
const d = await fetch(c.fileUrl,
|
|
1595
|
+
const d = await fetch(c.fileUrl, en(c.fileUrl));
|
|
1629
1596
|
if (!d.ok)
|
|
1630
1597
|
throw new Error(`Failed to load Pluno user file: ${l}`);
|
|
1631
1598
|
const f = await d.blob();
|
|
1632
1599
|
s.set(c.id, f);
|
|
1633
1600
|
const w = Date.now();
|
|
1634
|
-
return
|
|
1601
|
+
return Ut({
|
|
1635
1602
|
attachmentId: c.id,
|
|
1636
1603
|
name: c.name,
|
|
1637
1604
|
mimeType: c.mimeType,
|
|
@@ -1649,7 +1616,7 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1649
1616
|
});
|
|
1650
1617
|
}), f;
|
|
1651
1618
|
};
|
|
1652
|
-
return
|
|
1619
|
+
return Nt(globalThis, "userFiles", {
|
|
1653
1620
|
list: () => e.map(r),
|
|
1654
1621
|
get: (l) => {
|
|
1655
1622
|
const c = n.get(l);
|
|
@@ -1660,7 +1627,7 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1660
1627
|
if (!T.startsWith("image/"))
|
|
1661
1628
|
throw new Error(`Pluno user file is not an image: ${l}`);
|
|
1662
1629
|
const p = h.type === T ? h : new Blob([h], { type: T });
|
|
1663
|
-
return
|
|
1630
|
+
return is(T, p.size) > xe ? {
|
|
1664
1631
|
type: "pluno.userFiles.inspectImage",
|
|
1665
1632
|
id: c.id,
|
|
1666
1633
|
name: c.name,
|
|
@@ -1675,10 +1642,10 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1675
1642
|
mimeType: T,
|
|
1676
1643
|
sizeBytes: c.sizeBytes,
|
|
1677
1644
|
imageAttached: !0,
|
|
1678
|
-
dataUrl: await
|
|
1645
|
+
dataUrl: await it(p)
|
|
1679
1646
|
};
|
|
1680
1647
|
},
|
|
1681
|
-
getDataUrl: async (l) => (i(l), await
|
|
1648
|
+
getDataUrl: async (l) => (i(l), await it(await o(l))),
|
|
1682
1649
|
getBlob: o,
|
|
1683
1650
|
getArrayBuffer: async (l) => await (await o(l)).arrayBuffer(),
|
|
1684
1651
|
getFile: async (l) => {
|
|
@@ -1687,13 +1654,13 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1687
1654
|
}
|
|
1688
1655
|
});
|
|
1689
1656
|
}
|
|
1690
|
-
function
|
|
1691
|
-
return
|
|
1692
|
-
inspectImage: async (t, s) => await
|
|
1657
|
+
function Ze() {
|
|
1658
|
+
return Nt(globalThis, "pageImages", {
|
|
1659
|
+
inspectImage: async (t, s) => await Qe(t, s)
|
|
1693
1660
|
});
|
|
1694
1661
|
}
|
|
1695
|
-
async function
|
|
1696
|
-
const s =
|
|
1662
|
+
async function Qe(e, t = {}) {
|
|
1663
|
+
const s = ns(t.name), n = await ts(e);
|
|
1697
1664
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1698
1665
|
type: "pluno.pageImages.inspectImage",
|
|
1699
1666
|
imageAttached: !1,
|
|
@@ -1711,15 +1678,15 @@ async function ss(e, t = {}) {
|
|
|
1711
1678
|
imageAttachmentError: n.error
|
|
1712
1679
|
};
|
|
1713
1680
|
}
|
|
1714
|
-
async function
|
|
1681
|
+
async function ts(e) {
|
|
1715
1682
|
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: pt } : {
|
|
1716
1683
|
ok: !0,
|
|
1717
1684
|
mimeType: e.type,
|
|
1718
1685
|
sizeBytes: e.size,
|
|
1719
|
-
dataUrl: await
|
|
1720
|
-
} : { 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." } :
|
|
1686
|
+
dataUrl: await it(e)
|
|
1687
|
+
} : { 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." } : es(e);
|
|
1721
1688
|
}
|
|
1722
|
-
function
|
|
1689
|
+
function es(e) {
|
|
1723
1690
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1724
1691
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1725
1692
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1730,7 +1697,7 @@ function rs(e) {
|
|
|
1730
1697
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1731
1698
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1732
1699
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1733
|
-
const o =
|
|
1700
|
+
const o = ss(i);
|
|
1734
1701
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1735
1702
|
ok: !0,
|
|
1736
1703
|
mimeType: r,
|
|
@@ -1738,22 +1705,22 @@ function rs(e) {
|
|
|
1738
1705
|
dataUrl: `data:${r};base64,${i}`
|
|
1739
1706
|
};
|
|
1740
1707
|
}
|
|
1741
|
-
function
|
|
1708
|
+
function ss(e) {
|
|
1742
1709
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1743
1710
|
return null;
|
|
1744
1711
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1745
1712
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1746
1713
|
}
|
|
1747
|
-
function
|
|
1714
|
+
function ns(e) {
|
|
1748
1715
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1749
1716
|
}
|
|
1750
|
-
function
|
|
1717
|
+
function rs(e) {
|
|
1751
1718
|
try {
|
|
1752
1719
|
e();
|
|
1753
1720
|
} catch {
|
|
1754
1721
|
}
|
|
1755
1722
|
}
|
|
1756
|
-
function
|
|
1723
|
+
function it(e) {
|
|
1757
1724
|
return new Promise((t, s) => {
|
|
1758
1725
|
const n = new FileReader();
|
|
1759
1726
|
n.onload = () => {
|
|
@@ -1765,12 +1732,12 @@ function rt(e) {
|
|
|
1765
1732
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1766
1733
|
});
|
|
1767
1734
|
}
|
|
1768
|
-
function
|
|
1735
|
+
function is(e, t) {
|
|
1769
1736
|
return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
|
|
1770
1737
|
}
|
|
1771
|
-
async function
|
|
1738
|
+
async function Et(e) {
|
|
1772
1739
|
const t = Object.getPrototypeOf(async function() {
|
|
1773
|
-
}).constructor, s = e.timeoutMs ??
|
|
1740
|
+
}).constructor, s = e.timeoutMs ?? Xe, n = Date.now(), r = [];
|
|
1774
1741
|
let i;
|
|
1775
1742
|
const o = {
|
|
1776
1743
|
log: console.log,
|
|
@@ -1788,7 +1755,7 @@ async function Rt(e) {
|
|
|
1788
1755
|
i = window.setTimeout(() => c(u), s);
|
|
1789
1756
|
})
|
|
1790
1757
|
]);
|
|
1791
|
-
return l === u ?
|
|
1758
|
+
return l === u ? os(s) : {
|
|
1792
1759
|
ok: !0,
|
|
1793
1760
|
result: l,
|
|
1794
1761
|
console: r,
|
|
@@ -1817,7 +1784,7 @@ async function Rt(e) {
|
|
|
1817
1784
|
i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
|
|
1818
1785
|
}
|
|
1819
1786
|
}
|
|
1820
|
-
function
|
|
1787
|
+
function os(e) {
|
|
1821
1788
|
return {
|
|
1822
1789
|
ok: !1,
|
|
1823
1790
|
exception: {
|
|
@@ -1831,18 +1798,18 @@ function ls(e) {
|
|
|
1831
1798
|
}
|
|
1832
1799
|
};
|
|
1833
1800
|
}
|
|
1834
|
-
function
|
|
1801
|
+
function as(e) {
|
|
1835
1802
|
return e.replace(/\/+$/, "");
|
|
1836
1803
|
}
|
|
1837
|
-
function
|
|
1804
|
+
function cs(e, t = location.origin) {
|
|
1838
1805
|
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;
|
|
1839
1806
|
}
|
|
1840
|
-
function
|
|
1807
|
+
function ls(e) {
|
|
1841
1808
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1842
1809
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1843
1810
|
}
|
|
1844
1811
|
function A() {
|
|
1845
|
-
const e =
|
|
1812
|
+
const e = xt();
|
|
1846
1813
|
return {
|
|
1847
1814
|
url: location.href,
|
|
1848
1815
|
title: document.title,
|
|
@@ -1850,19 +1817,19 @@ function A() {
|
|
|
1850
1817
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1851
1818
|
};
|
|
1852
1819
|
}
|
|
1853
|
-
function
|
|
1820
|
+
function us() {
|
|
1854
1821
|
return {
|
|
1855
1822
|
pageUrl: location.href,
|
|
1856
1823
|
pageTitle: document.title,
|
|
1857
|
-
htmlContent:
|
|
1824
|
+
htmlContent: fs()
|
|
1858
1825
|
};
|
|
1859
1826
|
}
|
|
1860
|
-
function
|
|
1861
|
-
return B.add(e),
|
|
1862
|
-
B.delete(e), B.size === 0 && (
|
|
1827
|
+
function ds(e) {
|
|
1828
|
+
return B.add(e), N || (N = hs()), () => {
|
|
1829
|
+
B.delete(e), B.size === 0 && (N?.(), N = null);
|
|
1863
1830
|
};
|
|
1864
1831
|
}
|
|
1865
|
-
function
|
|
1832
|
+
function hs() {
|
|
1866
1833
|
const e = () => {
|
|
1867
1834
|
for (const i of Array.from(B))
|
|
1868
1835
|
i();
|
|
@@ -1877,10 +1844,10 @@ function gs() {
|
|
|
1877
1844
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
1878
1845
|
};
|
|
1879
1846
|
}
|
|
1880
|
-
function
|
|
1881
|
-
return
|
|
1847
|
+
function ps() {
|
|
1848
|
+
return xt()?.surface === "browser_extension_sdk_preview";
|
|
1882
1849
|
}
|
|
1883
|
-
function
|
|
1850
|
+
function fs() {
|
|
1884
1851
|
const e = document.body?.cloneNode(!0);
|
|
1885
1852
|
return e instanceof HTMLElement ? (e.querySelectorAll(
|
|
1886
1853
|
[
|
|
@@ -1904,9 +1871,9 @@ function ys() {
|
|
|
1904
1871
|
s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
|
|
1905
1872
|
}), 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) ?? "") : "";
|
|
1906
1873
|
}
|
|
1907
|
-
function
|
|
1908
|
-
const e = document.querySelector(
|
|
1909
|
-
if (!(e ?? document.querySelector(
|
|
1874
|
+
function xt() {
|
|
1875
|
+
const e = document.querySelector(Tt);
|
|
1876
|
+
if (!(e ?? document.querySelector(nt)))
|
|
1910
1877
|
return;
|
|
1911
1878
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
1912
1879
|
return {
|
|
@@ -1915,28 +1882,28 @@ function Ht() {
|
|
|
1915
1882
|
selectors: [
|
|
1916
1883
|
{
|
|
1917
1884
|
name: "widget_host",
|
|
1918
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
1885
|
+
selector: s === "browser_extension_sdk_preview" ? Tt : nt,
|
|
1919
1886
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
1920
1887
|
},
|
|
1921
1888
|
{
|
|
1922
1889
|
name: "widget_root",
|
|
1923
|
-
selector:
|
|
1890
|
+
selector: Te,
|
|
1924
1891
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
1925
1892
|
},
|
|
1926
1893
|
{
|
|
1927
1894
|
name: "widget_panel",
|
|
1928
|
-
selector:
|
|
1895
|
+
selector: we,
|
|
1929
1896
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
1930
1897
|
},
|
|
1931
1898
|
{
|
|
1932
1899
|
name: "widget_timeline",
|
|
1933
|
-
selector:
|
|
1900
|
+
selector: Ie,
|
|
1934
1901
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
1935
1902
|
}
|
|
1936
1903
|
]
|
|
1937
1904
|
};
|
|
1938
1905
|
}
|
|
1939
|
-
function
|
|
1906
|
+
function gs(e) {
|
|
1940
1907
|
try {
|
|
1941
1908
|
const t = JSON.parse(e);
|
|
1942
1909
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -1944,16 +1911,16 @@ function Ts(e) {
|
|
|
1944
1911
|
return { type: "error", message: "Invalid server event" };
|
|
1945
1912
|
}
|
|
1946
1913
|
}
|
|
1947
|
-
function
|
|
1914
|
+
function Rt(e, t) {
|
|
1948
1915
|
if (!e || typeof e != "object")
|
|
1949
1916
|
return [];
|
|
1950
1917
|
const s = e[t];
|
|
1951
1918
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
1952
1919
|
}
|
|
1953
|
-
function
|
|
1920
|
+
function ms(e) {
|
|
1954
1921
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
1955
1922
|
}
|
|
1956
|
-
function
|
|
1923
|
+
function ys(e) {
|
|
1957
1924
|
if (!e || typeof e != "object")
|
|
1958
1925
|
return null;
|
|
1959
1926
|
const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -1964,13 +1931,13 @@ function Is(e) {
|
|
|
1964
1931
|
...a !== null ? { scribbleStyle: a } : {}
|
|
1965
1932
|
};
|
|
1966
1933
|
}
|
|
1967
|
-
function
|
|
1934
|
+
function Ts(e) {
|
|
1968
1935
|
if (!e || typeof e != "object")
|
|
1969
1936
|
return null;
|
|
1970
1937
|
const t = e.javascript;
|
|
1971
1938
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
1972
1939
|
}
|
|
1973
|
-
function
|
|
1940
|
+
function ws(e, t) {
|
|
1974
1941
|
return t ? e && typeof e == "object" ? {
|
|
1975
1942
|
...e,
|
|
1976
1943
|
helperError: t
|
|
@@ -1980,13 +1947,13 @@ function Ss(e, t) {
|
|
|
1980
1947
|
helperError: t
|
|
1981
1948
|
} : e;
|
|
1982
1949
|
}
|
|
1983
|
-
function
|
|
1950
|
+
function Is(e) {
|
|
1984
1951
|
if (!e || typeof e != "object")
|
|
1985
1952
|
return e;
|
|
1986
1953
|
const t = e;
|
|
1987
1954
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
1988
1955
|
}
|
|
1989
|
-
function
|
|
1956
|
+
function As() {
|
|
1990
1957
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
1991
1958
|
if (t)
|
|
1992
1959
|
return t;
|
|
@@ -1996,7 +1963,7 @@ function Es() {
|
|
|
1996
1963
|
function O() {
|
|
1997
1964
|
return crypto.randomUUID();
|
|
1998
1965
|
}
|
|
1999
|
-
function
|
|
1966
|
+
function Ss(e) {
|
|
2000
1967
|
if (!e || typeof e != "object")
|
|
2001
1968
|
return null;
|
|
2002
1969
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2007,14 +1974,14 @@ function Rs(e) {
|
|
|
2007
1974
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2008
1975
|
} : null;
|
|
2009
1976
|
}
|
|
2010
|
-
function
|
|
2011
|
-
return Array.isArray(e) ?
|
|
2012
|
-
|
|
2013
|
-
e.map((s) =>
|
|
1977
|
+
function ks(e, t) {
|
|
1978
|
+
return Array.isArray(e) ? at(
|
|
1979
|
+
ct(
|
|
1980
|
+
e.map((s) => Ht(s, t)).filter((s) => s !== null)
|
|
2014
1981
|
)
|
|
2015
1982
|
) : [];
|
|
2016
1983
|
}
|
|
2017
|
-
function
|
|
1984
|
+
function Es(e) {
|
|
2018
1985
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2019
1986
|
if (!t || typeof t != "object")
|
|
2020
1987
|
return [];
|
|
@@ -2032,7 +1999,7 @@ function _s(e) {
|
|
|
2032
1999
|
];
|
|
2033
2000
|
}) : [];
|
|
2034
2001
|
}
|
|
2035
|
-
function
|
|
2002
|
+
function Ht(e, t) {
|
|
2036
2003
|
if (!e || typeof e != "object")
|
|
2037
2004
|
return null;
|
|
2038
2005
|
const s = e, n = s.data;
|
|
@@ -2044,39 +2011,39 @@ function Ft(e, t) {
|
|
|
2044
2011
|
return {
|
|
2045
2012
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2046
2013
|
role: i,
|
|
2047
|
-
content:
|
|
2014
|
+
content: Ms(r.content),
|
|
2048
2015
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2049
|
-
respondsToUserMessageId:
|
|
2016
|
+
respondsToUserMessageId: Z(r) ?? void 0,
|
|
2050
2017
|
..._(r) ? { runId: _(r) } : {},
|
|
2051
|
-
attachments:
|
|
2018
|
+
attachments: zt(r.attachments, t)
|
|
2052
2019
|
};
|
|
2053
2020
|
}
|
|
2054
2021
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" ? {
|
|
2055
2022
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2056
2023
|
role: "tool",
|
|
2057
|
-
content:
|
|
2024
|
+
content: Cs(r),
|
|
2058
2025
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2059
|
-
respondsToUserMessageId:
|
|
2026
|
+
respondsToUserMessageId: Z(r) ?? void 0,
|
|
2060
2027
|
..._(r) ? { runId: _(r) } : {},
|
|
2061
2028
|
dataType: String(r.type),
|
|
2062
2029
|
toolName: typeof r.name == "string" ? r.name : void 0,
|
|
2063
|
-
callId:
|
|
2030
|
+
callId: bs(r) ?? void 0,
|
|
2064
2031
|
loading: r.localExecutionStatus === "running"
|
|
2065
2032
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2066
2033
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2067
2034
|
role: "system",
|
|
2068
|
-
content:
|
|
2035
|
+
content: Rs(r),
|
|
2069
2036
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2070
|
-
respondsToUserMessageId:
|
|
2037
|
+
respondsToUserMessageId: Z(r) ?? void 0,
|
|
2071
2038
|
..._(r) ? { runId: _(r) } : {},
|
|
2072
2039
|
dataType: String(r.type),
|
|
2073
2040
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying")
|
|
2074
2041
|
} : null;
|
|
2075
2042
|
}
|
|
2076
|
-
function
|
|
2043
|
+
function Rs(e) {
|
|
2077
2044
|
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.";
|
|
2078
2045
|
}
|
|
2079
|
-
function
|
|
2046
|
+
function Cs(e) {
|
|
2080
2047
|
if (e.type === "web_search_call") {
|
|
2081
2048
|
const t = e.action;
|
|
2082
2049
|
if (t && typeof t == "object") {
|
|
@@ -2088,9 +2055,9 @@ function Ms(e) {
|
|
|
2088
2055
|
}
|
|
2089
2056
|
return "Searching the web";
|
|
2090
2057
|
}
|
|
2091
|
-
return
|
|
2058
|
+
return _s(e);
|
|
2092
2059
|
}
|
|
2093
|
-
function
|
|
2060
|
+
function _s(e) {
|
|
2094
2061
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2095
2062
|
return e.summary;
|
|
2096
2063
|
if (typeof e.arguments == "string")
|
|
@@ -2103,11 +2070,11 @@ function Ps(e) {
|
|
|
2103
2070
|
}
|
|
2104
2071
|
return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
|
|
2105
2072
|
}
|
|
2106
|
-
function
|
|
2073
|
+
function bs(e) {
|
|
2107
2074
|
const t = e.callId ?? e.call_id;
|
|
2108
2075
|
return typeof t == "string" && t ? t : null;
|
|
2109
2076
|
}
|
|
2110
|
-
function
|
|
2077
|
+
function Ms(e) {
|
|
2111
2078
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2112
2079
|
if (!t || typeof t != "object")
|
|
2113
2080
|
return "";
|
|
@@ -2115,24 +2082,24 @@ function Ds(e) {
|
|
|
2115
2082
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2116
2083
|
}).filter(Boolean).join("") : "";
|
|
2117
2084
|
}
|
|
2118
|
-
function
|
|
2119
|
-
const s =
|
|
2085
|
+
function Ps(e, t) {
|
|
2086
|
+
const s = Ft(e, t), n = Ns(e, t), r = n.findIndex((o) => o.id === s.id);
|
|
2120
2087
|
if (r === -1)
|
|
2121
|
-
return
|
|
2122
|
-
|
|
2088
|
+
return at(
|
|
2089
|
+
ct([...n, s])
|
|
2123
2090
|
);
|
|
2124
2091
|
const i = [...n];
|
|
2125
|
-
return i[r] = s,
|
|
2092
|
+
return i[r] = s, at(ct(i));
|
|
2126
2093
|
}
|
|
2127
|
-
function
|
|
2094
|
+
function Us(e, t) {
|
|
2128
2095
|
const s = t.map(
|
|
2129
|
-
(n) =>
|
|
2096
|
+
(n) => Ft(e, n)
|
|
2130
2097
|
);
|
|
2131
2098
|
return t.length > 0 ? s : e.filter(
|
|
2132
2099
|
(n) => n.role === "user" && n.id.startsWith("local-")
|
|
2133
2100
|
);
|
|
2134
2101
|
}
|
|
2135
|
-
function
|
|
2102
|
+
function Ft(e, t) {
|
|
2136
2103
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2137
2104
|
return t;
|
|
2138
2105
|
const s = e.find(
|
|
@@ -2141,19 +2108,19 @@ function Wt(e, t) {
|
|
|
2141
2108
|
if (!s?.attachments?.length)
|
|
2142
2109
|
return t;
|
|
2143
2110
|
const n = t.attachments.map((r) => {
|
|
2144
|
-
const i =
|
|
2145
|
-
return i ?
|
|
2111
|
+
const i = Ds(s.attachments ?? [], r);
|
|
2112
|
+
return i ? vs(r, i) : r;
|
|
2146
2113
|
});
|
|
2147
2114
|
return { ...t, attachments: n };
|
|
2148
2115
|
}
|
|
2149
|
-
function
|
|
2116
|
+
function Ds(e, t) {
|
|
2150
2117
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2151
2118
|
}
|
|
2152
|
-
function
|
|
2119
|
+
function vs(e, t) {
|
|
2153
2120
|
const { previewUrl: s } = t;
|
|
2154
2121
|
return s ? { ...e, previewUrl: s } : e;
|
|
2155
2122
|
}
|
|
2156
|
-
function
|
|
2123
|
+
function Ns(e, t) {
|
|
2157
2124
|
if (t.role !== "user")
|
|
2158
2125
|
return e;
|
|
2159
2126
|
const s = e.findIndex(
|
|
@@ -2164,8 +2131,8 @@ function Bs(e, t) {
|
|
|
2164
2131
|
const n = [...e];
|
|
2165
2132
|
return n.splice(s, 1), n;
|
|
2166
2133
|
}
|
|
2167
|
-
function
|
|
2168
|
-
const t =
|
|
2134
|
+
function Ct(e) {
|
|
2135
|
+
const t = Wt(e);
|
|
2169
2136
|
if (t === null)
|
|
2170
2137
|
return !1;
|
|
2171
2138
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
@@ -2181,17 +2148,17 @@ function _t(e) {
|
|
|
2181
2148
|
}
|
|
2182
2149
|
return !1;
|
|
2183
2150
|
}
|
|
2184
|
-
function
|
|
2185
|
-
const t =
|
|
2151
|
+
function Os(e) {
|
|
2152
|
+
const t = Wt(e);
|
|
2186
2153
|
return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
|
|
2187
2154
|
}
|
|
2188
|
-
function
|
|
2155
|
+
function Wt(e) {
|
|
2189
2156
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2190
2157
|
if (e[t].role === "user")
|
|
2191
2158
|
return t;
|
|
2192
2159
|
return null;
|
|
2193
2160
|
}
|
|
2194
|
-
function
|
|
2161
|
+
function Ls(e) {
|
|
2195
2162
|
return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2196
2163
|
}
|
|
2197
2164
|
function ft(e) {
|
|
@@ -2208,7 +2175,7 @@ function ft(e) {
|
|
|
2208
2175
|
}
|
|
2209
2176
|
return null;
|
|
2210
2177
|
}
|
|
2211
|
-
function
|
|
2178
|
+
function Bs(e, t) {
|
|
2212
2179
|
const s = ft(t);
|
|
2213
2180
|
if (s === null)
|
|
2214
2181
|
return !1;
|
|
@@ -2216,9 +2183,9 @@ function Hs(e, t) {
|
|
|
2216
2183
|
if (typeof r != "string" || !r)
|
|
2217
2184
|
return !1;
|
|
2218
2185
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2219
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
2186
|
+
return i === -1 ? !1 : e.slice(i + 1).some(Ls);
|
|
2220
2187
|
}
|
|
2221
|
-
function
|
|
2188
|
+
function ot(e) {
|
|
2222
2189
|
const t = ft(e);
|
|
2223
2190
|
if (t === null)
|
|
2224
2191
|
return null;
|
|
@@ -2231,7 +2198,7 @@ function it(e) {
|
|
|
2231
2198
|
const r = n.clientMessageId;
|
|
2232
2199
|
return typeof r == "string" ? r : null;
|
|
2233
2200
|
}
|
|
2234
|
-
function
|
|
2201
|
+
function qs(e) {
|
|
2235
2202
|
const t = ft(e);
|
|
2236
2203
|
if (t === null)
|
|
2237
2204
|
return null;
|
|
@@ -2246,13 +2213,13 @@ function Fs(e) {
|
|
|
2246
2213
|
if (i.type === "message" && i.role === "assistant")
|
|
2247
2214
|
return null;
|
|
2248
2215
|
if (i.type === "run_error")
|
|
2249
|
-
return i.retryable !== !0 ? null : typeof i.clientMessageId == "string" ? i.clientMessageId :
|
|
2216
|
+
return i.retryable !== !0 ? null : typeof i.clientMessageId == "string" ? i.clientMessageId : ot(e);
|
|
2250
2217
|
if (i.type === "run_status")
|
|
2251
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
2218
|
+
return i.status === "interrupted" && i.retryable === !0 ? ot(e) : null;
|
|
2252
2219
|
}
|
|
2253
2220
|
return null;
|
|
2254
2221
|
}
|
|
2255
|
-
function
|
|
2222
|
+
function xs(e, t) {
|
|
2256
2223
|
let s = 0;
|
|
2257
2224
|
for (const n of e) {
|
|
2258
2225
|
if (!n || typeof n != "object")
|
|
@@ -2265,22 +2232,22 @@ function Ws(e, t) {
|
|
|
2265
2232
|
}
|
|
2266
2233
|
return s;
|
|
2267
2234
|
}
|
|
2268
|
-
function
|
|
2235
|
+
function Hs(e) {
|
|
2269
2236
|
if (!e || typeof e != "object")
|
|
2270
2237
|
return !1;
|
|
2271
2238
|
const t = e;
|
|
2272
2239
|
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";
|
|
2273
2240
|
}
|
|
2274
|
-
function
|
|
2275
|
-
return e.filter((t, s) =>
|
|
2241
|
+
function at(e) {
|
|
2242
|
+
return e.filter((t, s) => jt(t) ? !zs(e, s) && !js(e, s) && !$s(e, s) : Fs(t) ? !Ws(e, s) : !0);
|
|
2276
2243
|
}
|
|
2277
|
-
function
|
|
2244
|
+
function Fs(e) {
|
|
2278
2245
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
2279
2246
|
}
|
|
2280
|
-
function
|
|
2247
|
+
function jt(e) {
|
|
2281
2248
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
2282
2249
|
}
|
|
2283
|
-
function
|
|
2250
|
+
function ct(e) {
|
|
2284
2251
|
const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
2285
2252
|
for (const i of e) {
|
|
2286
2253
|
if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
|
|
@@ -2296,53 +2263,53 @@ function at(e) {
|
|
|
2296
2263
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
2297
2264
|
return r;
|
|
2298
2265
|
}
|
|
2299
|
-
function
|
|
2266
|
+
function Ws(e, t) {
|
|
2300
2267
|
const s = e[t];
|
|
2301
2268
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2302
2269
|
const r = e[n];
|
|
2303
2270
|
if (r.role === "user")
|
|
2304
2271
|
return !1;
|
|
2305
|
-
if (r.role === "assistant" &&
|
|
2272
|
+
if (r.role === "assistant" && $(s, r))
|
|
2306
2273
|
return !0;
|
|
2307
2274
|
}
|
|
2308
2275
|
return !1;
|
|
2309
2276
|
}
|
|
2310
|
-
function
|
|
2277
|
+
function js(e, t) {
|
|
2311
2278
|
const s = e[t];
|
|
2312
2279
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2313
|
-
if (e[n].role === "assistant" &&
|
|
2280
|
+
if (e[n].role === "assistant" && $(s, e[n]))
|
|
2314
2281
|
return !0;
|
|
2315
2282
|
return !1;
|
|
2316
2283
|
}
|
|
2317
|
-
function
|
|
2284
|
+
function $s(e, t) {
|
|
2318
2285
|
const s = e[t];
|
|
2319
2286
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2320
|
-
if (e[n].role === "tool" &&
|
|
2287
|
+
if (e[n].role === "tool" && $(s, e[n]))
|
|
2321
2288
|
return !0;
|
|
2322
2289
|
return !1;
|
|
2323
2290
|
}
|
|
2324
|
-
function
|
|
2291
|
+
function zs(e, t) {
|
|
2325
2292
|
const s = e[t];
|
|
2326
2293
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2327
|
-
if (
|
|
2294
|
+
if (jt(e[n]) && $(s, e[n]))
|
|
2328
2295
|
return !0;
|
|
2329
2296
|
return !1;
|
|
2330
2297
|
}
|
|
2331
|
-
function
|
|
2298
|
+
function $(e, t) {
|
|
2332
2299
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
2333
2300
|
}
|
|
2334
2301
|
function k(e, t) {
|
|
2335
2302
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
2336
2303
|
}
|
|
2337
|
-
function
|
|
2304
|
+
function Gs(e, t) {
|
|
2338
2305
|
try {
|
|
2339
|
-
const s = window.localStorage.getItem(`${
|
|
2306
|
+
const s = window.localStorage.getItem(`${Bt}${e}`);
|
|
2340
2307
|
if (!s)
|
|
2341
2308
|
return null;
|
|
2342
2309
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
2343
2310
|
if (t !== void 0 && r !== t)
|
|
2344
2311
|
return null;
|
|
2345
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2312
|
+
const i = Array.isArray(n.messages) ? n.messages.map(rn).filter((o) => !!o) : [];
|
|
2346
2313
|
return {
|
|
2347
2314
|
sessionId: r,
|
|
2348
2315
|
messages: i
|
|
@@ -2351,22 +2318,22 @@ function Js(e, t) {
|
|
|
2351
2318
|
return null;
|
|
2352
2319
|
}
|
|
2353
2320
|
}
|
|
2354
|
-
function
|
|
2321
|
+
function Xs(e, t) {
|
|
2355
2322
|
try {
|
|
2356
2323
|
window.localStorage.setItem(
|
|
2357
|
-
`${
|
|
2324
|
+
`${Bt}${e}`,
|
|
2358
2325
|
JSON.stringify({
|
|
2359
2326
|
sessionId: t.sessionId,
|
|
2360
|
-
messages: t.messages.slice(-
|
|
2327
|
+
messages: t.messages.slice(-He).map(on)
|
|
2361
2328
|
})
|
|
2362
2329
|
);
|
|
2363
2330
|
} catch {
|
|
2364
2331
|
return;
|
|
2365
2332
|
}
|
|
2366
2333
|
}
|
|
2367
|
-
function
|
|
2334
|
+
function Ks(e) {
|
|
2368
2335
|
try {
|
|
2369
|
-
const t = window.localStorage.getItem(`${
|
|
2336
|
+
const t = window.localStorage.getItem(`${rt}${e}`);
|
|
2370
2337
|
if (!t)
|
|
2371
2338
|
return [];
|
|
2372
2339
|
const s = JSON.parse(t);
|
|
@@ -2379,20 +2346,20 @@ function P(e, t) {
|
|
|
2379
2346
|
try {
|
|
2380
2347
|
const s = t.filter(gt);
|
|
2381
2348
|
if (s.length === 0) {
|
|
2382
|
-
window.localStorage.removeItem(`${
|
|
2349
|
+
window.localStorage.removeItem(`${rt}${e}`);
|
|
2383
2350
|
return;
|
|
2384
2351
|
}
|
|
2385
2352
|
window.localStorage.setItem(
|
|
2386
|
-
`${
|
|
2353
|
+
`${rt}${e}`,
|
|
2387
2354
|
JSON.stringify(s.slice(-25))
|
|
2388
2355
|
);
|
|
2389
2356
|
} catch {
|
|
2390
2357
|
return;
|
|
2391
2358
|
}
|
|
2392
2359
|
}
|
|
2393
|
-
function
|
|
2360
|
+
function $t(e, t) {
|
|
2394
2361
|
try {
|
|
2395
|
-
const s = `${
|
|
2362
|
+
const s = `${j}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
2396
2363
|
...o,
|
|
2397
2364
|
storedAt: Date.now(),
|
|
2398
2365
|
unloadUrl: n,
|
|
@@ -2406,28 +2373,28 @@ function zt(e, t) {
|
|
|
2406
2373
|
} catch {
|
|
2407
2374
|
}
|
|
2408
2375
|
}
|
|
2409
|
-
function
|
|
2376
|
+
function Js(e, t) {
|
|
2410
2377
|
try {
|
|
2411
|
-
if (window.sessionStorage.getItem(`${
|
|
2378
|
+
if (window.sessionStorage.getItem(`${j}${e}`) === null)
|
|
2412
2379
|
return;
|
|
2413
2380
|
} catch {
|
|
2414
2381
|
return;
|
|
2415
2382
|
}
|
|
2416
|
-
|
|
2383
|
+
$t(e, t);
|
|
2417
2384
|
}
|
|
2418
|
-
function
|
|
2385
|
+
function Vs(e) {
|
|
2419
2386
|
try {
|
|
2420
|
-
const t = `${
|
|
2387
|
+
const t = `${j}${e}`, s = window.sessionStorage.getItem(t);
|
|
2421
2388
|
if (window.sessionStorage.removeItem(t), !s)
|
|
2422
2389
|
return [];
|
|
2423
2390
|
const n = JSON.parse(s);
|
|
2424
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2391
|
+
return Array.isArray(n) ? n.flatMap((r) => Zs(r) ? [{
|
|
2425
2392
|
...r.event,
|
|
2426
2393
|
page: A(),
|
|
2427
2394
|
rawOutput: {
|
|
2428
2395
|
pageContextRestarted: !0,
|
|
2429
2396
|
outcome: "unknown",
|
|
2430
|
-
message:
|
|
2397
|
+
message: Ys(location.href),
|
|
2431
2398
|
currentUrl: location.href,
|
|
2432
2399
|
console: [],
|
|
2433
2400
|
metadata: {
|
|
@@ -2444,17 +2411,17 @@ function Qs(e) {
|
|
|
2444
2411
|
return [];
|
|
2445
2412
|
}
|
|
2446
2413
|
}
|
|
2447
|
-
function
|
|
2414
|
+
function Ys(e) {
|
|
2448
2415
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
2449
2416
|
Current URL: ${e}`;
|
|
2450
2417
|
}
|
|
2451
|
-
function
|
|
2418
|
+
function Zs(e) {
|
|
2452
2419
|
if (!e || typeof e != "object")
|
|
2453
2420
|
return !1;
|
|
2454
2421
|
const t = e, s = t.event;
|
|
2455
2422
|
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && gt(s) && s.type === "tool.result";
|
|
2456
2423
|
}
|
|
2457
|
-
function
|
|
2424
|
+
function Qs(e, t) {
|
|
2458
2425
|
const s = new Set(
|
|
2459
2426
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2460
2427
|
);
|
|
@@ -2463,9 +2430,9 @@ function sn(e, t) {
|
|
|
2463
2430
|
...t.filter((n) => !s.has(n.callId))
|
|
2464
2431
|
];
|
|
2465
2432
|
}
|
|
2466
|
-
function
|
|
2433
|
+
function tn(e) {
|
|
2467
2434
|
try {
|
|
2468
|
-
window.sessionStorage.removeItem(`${
|
|
2435
|
+
window.sessionStorage.removeItem(`${j}${e}`);
|
|
2469
2436
|
} catch {
|
|
2470
2437
|
return;
|
|
2471
2438
|
}
|
|
@@ -2474,15 +2441,15 @@ function gt(e) {
|
|
|
2474
2441
|
if (!e || typeof e != "object")
|
|
2475
2442
|
return !1;
|
|
2476
2443
|
const t = e;
|
|
2477
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
2444
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && _t(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? _t(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" : !1;
|
|
2478
2445
|
}
|
|
2479
|
-
function
|
|
2446
|
+
function _t(e) {
|
|
2480
2447
|
if (!e || typeof e != "object")
|
|
2481
2448
|
return !1;
|
|
2482
2449
|
const t = e;
|
|
2483
2450
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
2484
2451
|
}
|
|
2485
|
-
function
|
|
2452
|
+
function zt(e, t) {
|
|
2486
2453
|
if (!Array.isArray(e))
|
|
2487
2454
|
return;
|
|
2488
2455
|
const s = e.filter((r) => {
|
|
@@ -2490,24 +2457,24 @@ function Gt(e, t) {
|
|
|
2490
2457
|
return !1;
|
|
2491
2458
|
const i = r;
|
|
2492
2459
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2493
|
-
}), n = t ? s.map((r) =>
|
|
2460
|
+
}), n = t ? s.map((r) => Gt(r, t)) : s;
|
|
2494
2461
|
return n.length > 0 ? n : void 0;
|
|
2495
2462
|
}
|
|
2496
|
-
function
|
|
2463
|
+
function Gt(e, t) {
|
|
2497
2464
|
return e.fileUrl?.startsWith("/") ? {
|
|
2498
2465
|
...e,
|
|
2499
2466
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2500
2467
|
} : e;
|
|
2501
2468
|
}
|
|
2502
|
-
function
|
|
2503
|
-
if (
|
|
2469
|
+
function en(e) {
|
|
2470
|
+
if (sn(e))
|
|
2504
2471
|
return {
|
|
2505
2472
|
headers: {
|
|
2506
2473
|
"ngrok-skip-browser-warning": "true"
|
|
2507
2474
|
}
|
|
2508
2475
|
};
|
|
2509
2476
|
}
|
|
2510
|
-
function
|
|
2477
|
+
function sn(e) {
|
|
2511
2478
|
try {
|
|
2512
2479
|
const t = new URL(e).hostname;
|
|
2513
2480
|
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
@@ -2515,14 +2482,14 @@ function on(e) {
|
|
|
2515
2482
|
return !1;
|
|
2516
2483
|
}
|
|
2517
2484
|
}
|
|
2518
|
-
function
|
|
2519
|
-
return e.type ||
|
|
2485
|
+
function bt(e) {
|
|
2486
|
+
return e.type || nn(e.name) || "application/octet-stream";
|
|
2520
2487
|
}
|
|
2521
|
-
function
|
|
2488
|
+
function nn(e) {
|
|
2522
2489
|
const t = e.toLowerCase();
|
|
2523
2490
|
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;
|
|
2524
2491
|
}
|
|
2525
|
-
function
|
|
2492
|
+
function rn(e) {
|
|
2526
2493
|
if (!e || typeof e != "object")
|
|
2527
2494
|
return null;
|
|
2528
2495
|
const t = e;
|
|
@@ -2534,11 +2501,11 @@ function cn(e) {
|
|
|
2534
2501
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
2535
2502
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
2536
2503
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
2537
|
-
attachments:
|
|
2504
|
+
attachments: zt(t.attachments)?.map(mt),
|
|
2538
2505
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2539
2506
|
};
|
|
2540
2507
|
}
|
|
2541
|
-
function
|
|
2508
|
+
function on(e) {
|
|
2542
2509
|
return e.attachments?.length ? {
|
|
2543
2510
|
...e,
|
|
2544
2511
|
attachments: e.attachments.map(mt)
|
|
@@ -2553,7 +2520,7 @@ function mt(e) {
|
|
|
2553
2520
|
} = e;
|
|
2554
2521
|
return r;
|
|
2555
2522
|
}
|
|
2556
|
-
function
|
|
2523
|
+
function Z(e) {
|
|
2557
2524
|
const t = e.respondsToUserMessageId;
|
|
2558
2525
|
return typeof t == "string" && t ? t : null;
|
|
2559
2526
|
}
|
|
@@ -2561,11 +2528,11 @@ function _(e) {
|
|
|
2561
2528
|
const t = e.runId;
|
|
2562
2529
|
return typeof t == "string" && t ? t : null;
|
|
2563
2530
|
}
|
|
2564
|
-
function
|
|
2531
|
+
function an(e) {
|
|
2565
2532
|
const t = e?.timeoutMs;
|
|
2566
|
-
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 <=
|
|
2533
|
+
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 <= Ke);
|
|
2567
2534
|
}
|
|
2568
|
-
function
|
|
2535
|
+
function Xt(e) {
|
|
2569
2536
|
const t = {};
|
|
2570
2537
|
try {
|
|
2571
2538
|
new Headers(e).forEach((s, n) => {
|
|
@@ -2577,23 +2544,23 @@ function Kt(e) {
|
|
|
2577
2544
|
return t;
|
|
2578
2545
|
}
|
|
2579
2546
|
function yt(e, t) {
|
|
2580
|
-
return
|
|
2547
|
+
return Qt(e) ? z : E(F(t), Be);
|
|
2581
2548
|
}
|
|
2582
|
-
function
|
|
2549
|
+
function cn(e, t) {
|
|
2583
2550
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2584
2551
|
}
|
|
2585
|
-
async function
|
|
2586
|
-
const r =
|
|
2552
|
+
async function ln(e, t, s, n) {
|
|
2553
|
+
const r = Xt(e.headers);
|
|
2587
2554
|
n({
|
|
2588
2555
|
...t,
|
|
2589
2556
|
responseStatus: e.status,
|
|
2590
2557
|
responseHeaders: r,
|
|
2591
|
-
responseBody: await
|
|
2558
|
+
responseBody: await un(e),
|
|
2592
2559
|
durationMs: Date.now() - s
|
|
2593
2560
|
});
|
|
2594
2561
|
}
|
|
2595
|
-
async function
|
|
2596
|
-
if (!
|
|
2562
|
+
async function un(e) {
|
|
2563
|
+
if (!Kt(e.headers))
|
|
2597
2564
|
return;
|
|
2598
2565
|
let t = null, s = null;
|
|
2599
2566
|
try {
|
|
@@ -2602,7 +2569,7 @@ async function pn(e) {
|
|
|
2602
2569
|
const n = new Promise((a) => {
|
|
2603
2570
|
s = window.setTimeout(() => {
|
|
2604
2571
|
t?.cancel(), a("timeout");
|
|
2605
|
-
},
|
|
2572
|
+
}, qe);
|
|
2606
2573
|
}), r = new TextDecoder();
|
|
2607
2574
|
let i = "", o = 0;
|
|
2608
2575
|
for (; ; ) {
|
|
@@ -2624,45 +2591,45 @@ async function pn(e) {
|
|
|
2624
2591
|
s !== null && window.clearTimeout(s);
|
|
2625
2592
|
}
|
|
2626
2593
|
}
|
|
2627
|
-
function
|
|
2628
|
-
if (
|
|
2594
|
+
function dn(e, t) {
|
|
2595
|
+
if (Kt(new Headers(t)))
|
|
2629
2596
|
try {
|
|
2630
2597
|
return e.responseType === "" || e.responseType === "text" ? E(e.responseText ?? "") : void 0;
|
|
2631
2598
|
} catch {
|
|
2632
2599
|
return;
|
|
2633
2600
|
}
|
|
2634
2601
|
}
|
|
2635
|
-
function
|
|
2602
|
+
function Mt(e) {
|
|
2636
2603
|
if (typeof e == "string")
|
|
2637
2604
|
return E(e);
|
|
2638
2605
|
}
|
|
2639
|
-
function
|
|
2606
|
+
function hn(e) {
|
|
2640
2607
|
return S({
|
|
2641
2608
|
...e,
|
|
2642
|
-
requestBody:
|
|
2643
|
-
responseBody:
|
|
2609
|
+
requestBody: Pt(e.requestBody),
|
|
2610
|
+
responseBody: Pt(e.responseBody)
|
|
2644
2611
|
});
|
|
2645
2612
|
}
|
|
2646
|
-
function
|
|
2613
|
+
function Pt(e) {
|
|
2647
2614
|
if (typeof e != "string")
|
|
2648
2615
|
return e;
|
|
2649
2616
|
const t = e.trim();
|
|
2650
2617
|
if (!t.startsWith("{") && !t.startsWith("["))
|
|
2651
|
-
return
|
|
2618
|
+
return F(e);
|
|
2652
2619
|
try {
|
|
2653
2620
|
return JSON.stringify(S(JSON.parse(e)));
|
|
2654
2621
|
} catch {
|
|
2655
|
-
return
|
|
2622
|
+
return F(e);
|
|
2656
2623
|
}
|
|
2657
2624
|
}
|
|
2658
|
-
function
|
|
2625
|
+
function Kt(e) {
|
|
2659
2626
|
if (!e)
|
|
2660
2627
|
return !1;
|
|
2661
2628
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
2662
2629
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= dt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
2663
2630
|
}
|
|
2664
2631
|
function b(e, t = {}, s) {
|
|
2665
|
-
if (
|
|
2632
|
+
if (fn(s))
|
|
2666
2633
|
return !0;
|
|
2667
2634
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
2668
2635
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -2677,7 +2644,7 @@ function b(e, t = {}, s) {
|
|
|
2677
2644
|
return !0;
|
|
2678
2645
|
}
|
|
2679
2646
|
}
|
|
2680
|
-
function
|
|
2647
|
+
function pn(e, t) {
|
|
2681
2648
|
if (b(e))
|
|
2682
2649
|
return !0;
|
|
2683
2650
|
try {
|
|
@@ -2687,10 +2654,10 @@ function mn(e, t) {
|
|
|
2687
2654
|
return !0;
|
|
2688
2655
|
}
|
|
2689
2656
|
}
|
|
2690
|
-
function
|
|
2657
|
+
function fn(e) {
|
|
2691
2658
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
2692
2659
|
}
|
|
2693
|
-
function
|
|
2660
|
+
function gn(e) {
|
|
2694
2661
|
const t = {};
|
|
2695
2662
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
2696
2663
|
const n = s.indexOf(":");
|
|
@@ -2706,96 +2673,96 @@ function Tn(e) {
|
|
|
2706
2673
|
function E(e, t = dt) {
|
|
2707
2674
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
2708
2675
|
}
|
|
2709
|
-
function
|
|
2676
|
+
function Q(e) {
|
|
2710
2677
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2711
2678
|
}
|
|
2712
|
-
class
|
|
2679
|
+
class q extends Error {
|
|
2713
2680
|
constructor(t, s) {
|
|
2714
2681
|
super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
2715
2682
|
}
|
|
2716
2683
|
status;
|
|
2717
2684
|
}
|
|
2718
|
-
async function
|
|
2685
|
+
async function tt(e, t) {
|
|
2719
2686
|
let s = null;
|
|
2720
|
-
for (let n = 0; n <
|
|
2687
|
+
for (let n = 0; n < St; n += 1)
|
|
2721
2688
|
try {
|
|
2722
2689
|
return await e();
|
|
2723
2690
|
} catch (r) {
|
|
2724
|
-
if (s = r, n >=
|
|
2691
|
+
if (s = r, n >= St - 1 || !yn(r))
|
|
2725
2692
|
throw r;
|
|
2726
|
-
await
|
|
2693
|
+
await mn(n);
|
|
2727
2694
|
}
|
|
2728
2695
|
throw s instanceof Error ? s : new Error(t);
|
|
2729
2696
|
}
|
|
2730
|
-
function
|
|
2697
|
+
function mn(e) {
|
|
2731
2698
|
return new Promise((t) => {
|
|
2732
|
-
window.setTimeout(t,
|
|
2699
|
+
window.setTimeout(t, Le[e] ?? 0);
|
|
2733
2700
|
});
|
|
2734
2701
|
}
|
|
2735
|
-
function
|
|
2736
|
-
return e instanceof
|
|
2702
|
+
function yn(e) {
|
|
2703
|
+
return e instanceof q ? Tn(e.status) : e instanceof TypeError;
|
|
2737
2704
|
}
|
|
2738
|
-
function
|
|
2705
|
+
function Tn(e) {
|
|
2739
2706
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
2740
2707
|
}
|
|
2741
|
-
function
|
|
2708
|
+
function wn(e) {
|
|
2742
2709
|
return e === 401 || e === 403;
|
|
2743
2710
|
}
|
|
2744
|
-
const
|
|
2711
|
+
const z = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", In = "[REDACTED_SIGNED_URL]", An = 20, Sn = /^(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, Jt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Vt = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Yt = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Zt = /\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, kn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, En = /\bhttps?:\/\/[^\s"'<>]+/gi, Rn = /[),.;\]]+$/;
|
|
2745
2712
|
function S(e) {
|
|
2746
|
-
return
|
|
2713
|
+
return H(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2747
2714
|
}
|
|
2748
|
-
function
|
|
2715
|
+
function H(e, t, s) {
|
|
2749
2716
|
if (typeof e == "string")
|
|
2750
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
2717
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : F(e);
|
|
2751
2718
|
if (e === null || typeof e != "object")
|
|
2752
2719
|
return e;
|
|
2753
|
-
if (t >=
|
|
2720
|
+
if (t >= An)
|
|
2754
2721
|
return "[REDACTED_MAX_DEPTH]";
|
|
2755
2722
|
if (s.has(e))
|
|
2756
2723
|
return "[REDACTED_CIRCULAR]";
|
|
2757
2724
|
if (s.add(e), Array.isArray(e))
|
|
2758
|
-
return e.map((r) =>
|
|
2725
|
+
return e.map((r) => H(r, t + 1, s));
|
|
2759
2726
|
const n = {};
|
|
2760
2727
|
for (const [r, i] of Object.entries(e))
|
|
2761
|
-
|
|
2728
|
+
Qt(r) ? n[r] = z : n[r] = r.toLowerCase() === "url" ? Cn(i) : H(i, t + 1, s);
|
|
2762
2729
|
return n;
|
|
2763
2730
|
}
|
|
2764
|
-
function
|
|
2731
|
+
function Qt(e) {
|
|
2765
2732
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
2766
2733
|
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");
|
|
2767
2734
|
}
|
|
2768
|
-
function
|
|
2769
|
-
return typeof e == "string" ?
|
|
2735
|
+
function Cn(e) {
|
|
2736
|
+
return typeof e == "string" ? te(e) : H(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2770
2737
|
}
|
|
2771
|
-
function
|
|
2738
|
+
function te(e) {
|
|
2772
2739
|
try {
|
|
2773
2740
|
const t = new URL(e, location.href);
|
|
2774
2741
|
for (const s of Array.from(t.searchParams.keys()))
|
|
2775
|
-
|
|
2742
|
+
Sn.test(s) && t.searchParams.set(s, R);
|
|
2776
2743
|
return t.username && (t.username = R), t.password && (t.password = R), t.toString();
|
|
2777
2744
|
} catch {
|
|
2778
|
-
return
|
|
2745
|
+
return _n(e);
|
|
2779
2746
|
}
|
|
2780
2747
|
}
|
|
2781
|
-
function
|
|
2782
|
-
return e.replace(
|
|
2748
|
+
function F(e) {
|
|
2749
|
+
return e.replace(kn, In).replace(En, bn).replace(Jt, `Bearer ${R}`).replace(Vt, `Basic ${R}`).replace(Yt, R).replace(Zt, (t, s) => `${s}: ${z}`);
|
|
2783
2750
|
}
|
|
2784
|
-
function
|
|
2785
|
-
return e.replace(
|
|
2751
|
+
function _n(e) {
|
|
2752
|
+
return e.replace(Jt, `Bearer ${R}`).replace(Vt, `Basic ${R}`).replace(Yt, R).replace(Zt, (t, s) => `${s}: ${z}`);
|
|
2786
2753
|
}
|
|
2787
|
-
function
|
|
2788
|
-
const t = e.match(
|
|
2789
|
-
return `${
|
|
2754
|
+
function bn(e) {
|
|
2755
|
+
const t = e.match(Rn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
2756
|
+
return `${te(s)}${t}`;
|
|
2790
2757
|
}
|
|
2791
2758
|
export {
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2759
|
+
Tt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
2760
|
+
nt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
2761
|
+
we as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
2762
|
+
Te as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
2763
|
+
Ie as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
2797
2764
|
qt as PlunoProductAgent,
|
|
2798
|
-
|
|
2765
|
+
We as calculateReconnectDelay,
|
|
2799
2766
|
qt as default,
|
|
2800
|
-
|
|
2767
|
+
cs as getProductAgentOriginAccessErrorMessage
|
|
2801
2768
|
};
|