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