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