@pluno/product-agent-web 0.1.112 → 0.1.114
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 +0 -1
- package/dist/product-agent-sdk.js +673 -861
- package/dist/product-agent-widget.js +573 -568
- package/package.json +1 -1
- package/dist/scheduledChatContinuations.d.ts +0 -39
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const t = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const t = await
|
|
1
|
+
const ce = "pluno-product-agent-attachments";
|
|
2
|
+
const et = "files";
|
|
3
|
+
async function xt(e) {
|
|
4
|
+
const t = await $();
|
|
5
|
+
await Ht(t, "readwrite", (s) => s.put(e));
|
|
6
|
+
}
|
|
7
|
+
async function le(e) {
|
|
8
|
+
const t = await $(), s = await Ht(
|
|
9
9
|
t,
|
|
10
10
|
"readonly",
|
|
11
11
|
(r) => r.get(e)
|
|
@@ -13,12 +13,12 @@ async function fe(e) {
|
|
|
13
13
|
if (!s)
|
|
14
14
|
return null;
|
|
15
15
|
const n = Date.now();
|
|
16
|
-
return await
|
|
16
|
+
return await Ft(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
|
|
17
17
|
}
|
|
18
|
-
async function
|
|
19
|
-
const s = await
|
|
20
|
-
await
|
|
21
|
-
const r = await
|
|
18
|
+
async function Ft(e, t) {
|
|
19
|
+
const s = await $();
|
|
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,40 +27,40 @@ async function $t(e, t) {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
const t = await
|
|
32
|
-
await
|
|
30
|
+
async function ue(e = 864e5) {
|
|
31
|
+
const t = await $(), 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 $() {
|
|
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(ce, 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 Ht(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
|
|
53
|
-
s(o).then((
|
|
54
|
-
|
|
55
|
-
}).catch((
|
|
51
|
+
const i = e.transaction(et, t), o = i.objectStore(et);
|
|
52
|
+
let l, u = !1;
|
|
53
|
+
s(o).then((c) => {
|
|
54
|
+
l = c;
|
|
55
|
+
}).catch((c) => {
|
|
56
56
|
u = !0;
|
|
57
57
|
try {
|
|
58
58
|
i.abort();
|
|
59
59
|
} catch {
|
|
60
60
|
}
|
|
61
|
-
r(
|
|
61
|
+
r(c);
|
|
62
62
|
}), i.oncomplete = () => {
|
|
63
|
-
u || n(
|
|
63
|
+
u || n(l);
|
|
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 pt(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 de(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 Wt(e, t, s) {
|
|
80
|
+
const n = Reflect.get(e, "pluno"), r = de(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,182 +91,11 @@ function Gt(e, t, s) {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
const
|
|
95
|
-
function Te(e, {
|
|
96
|
-
clientId: t,
|
|
97
|
-
sessionId: s,
|
|
98
|
-
callId: n
|
|
99
|
-
}) {
|
|
100
|
-
return `const plunoScheduledContinuation = Object.freeze(${JSON.stringify({
|
|
101
|
-
storageKeyPrefix: j,
|
|
102
|
-
changedEvent: it,
|
|
103
|
-
clientId: t,
|
|
104
|
-
sessionId: s,
|
|
105
|
-
defaultTaskId: `scheduled-${n}`,
|
|
106
|
-
expiresAfterDueMs: Xt
|
|
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,
|
|
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}`;
|
|
134
|
-
}
|
|
135
|
-
function we(e) {
|
|
136
|
-
const t = e.storage === void 0 ? Ae() : e.storage;
|
|
137
|
-
let s = null, n = !1, r = !1, i = !1, o = t !== null;
|
|
138
|
-
const c = /* @__PURE__ */ new Map(), u = () => {
|
|
139
|
-
s !== null && (clearTimeout(s), s = null);
|
|
140
|
-
}, l = () => {
|
|
141
|
-
u(), !(i || !o) && (s = setTimeout(() => {
|
|
142
|
-
s = null, h();
|
|
143
|
-
}, ye));
|
|
144
|
-
}, a = () => {
|
|
145
|
-
o = !1, u();
|
|
146
|
-
}, h = async () => {
|
|
147
|
-
if (!(i || !o || !t)) {
|
|
148
|
-
if (n) {
|
|
149
|
-
r = !0;
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
n = !0;
|
|
153
|
-
try {
|
|
154
|
-
const f = Date.now();
|
|
155
|
-
for (const [g, A] of c)
|
|
156
|
-
A <= f && c.delete(g);
|
|
157
|
-
const T = await t.list(), m = [];
|
|
158
|
-
for (const g of T) {
|
|
159
|
-
if (!N(g)) {
|
|
160
|
-
const A = g && typeof g == "object" ? g.id : null;
|
|
161
|
-
typeof A == "string" && await t.remove(A);
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
if (g.expiresAt <= f) {
|
|
165
|
-
await t.remove(g.id), c.delete(g.id);
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
m.push(g);
|
|
169
|
-
}
|
|
170
|
-
e.onTasksChanged?.(m);
|
|
171
|
-
for (const g of m)
|
|
172
|
-
if (!(g.clientId !== e.clientId || g.dueAt > f || c.has(g.id) || !await e.canDeliver(g))) {
|
|
173
|
-
c.set(g.id, f + Ie);
|
|
174
|
-
try {
|
|
175
|
-
await e.deliver(g);
|
|
176
|
-
} catch {
|
|
177
|
-
c.delete(g.id);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
} catch {
|
|
181
|
-
a();
|
|
182
|
-
} finally {
|
|
183
|
-
n = !1, r ? (r = !1, h()) : l();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}, I = async (f) => {
|
|
187
|
-
if (i || !o || !t || !N(f))
|
|
188
|
-
return !1;
|
|
189
|
-
try {
|
|
190
|
-
return await t.set(f), e.onTasksChanged?.((await t.list()).filter(N)), await h(), !0;
|
|
191
|
-
} catch {
|
|
192
|
-
return a(), !1;
|
|
193
|
-
}
|
|
194
|
-
}, p = async (f) => {
|
|
195
|
-
if (c.delete(f), i || !o || !t)
|
|
196
|
-
return !1;
|
|
197
|
-
try {
|
|
198
|
-
return await t.remove(f), e.onTasksChanged?.((await t.list()).filter(N)), !0;
|
|
199
|
-
} catch {
|
|
200
|
-
return a(), !1;
|
|
201
|
-
}
|
|
202
|
-
}, d = t?.subscribe?.(() => {
|
|
203
|
-
h();
|
|
204
|
-
}) ?? null;
|
|
205
|
-
return o && h(), {
|
|
206
|
-
processDueTasks: h,
|
|
207
|
-
scheduleTask: I,
|
|
208
|
-
acknowledgeTask: p,
|
|
209
|
-
isAvailable: () => o,
|
|
210
|
-
destroy() {
|
|
211
|
-
i = !0, u(), d?.(), c.clear();
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function N(e) {
|
|
216
|
-
if (!e || typeof e != "object")
|
|
217
|
-
return !1;
|
|
218
|
-
const t = e;
|
|
219
|
-
return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt + Xt;
|
|
220
|
-
}
|
|
221
|
-
function Ae() {
|
|
222
|
-
let e;
|
|
223
|
-
try {
|
|
224
|
-
e = window.localStorage, e.length;
|
|
225
|
-
} catch {
|
|
226
|
-
return null;
|
|
227
|
-
}
|
|
228
|
-
return {
|
|
229
|
-
async list() {
|
|
230
|
-
const t = [];
|
|
231
|
-
for (let s = 0; s < e.length; s += 1) {
|
|
232
|
-
const n = e.key(s);
|
|
233
|
-
if (!n?.startsWith(j))
|
|
234
|
-
continue;
|
|
235
|
-
const r = e.getItem(n);
|
|
236
|
-
if (r)
|
|
237
|
-
try {
|
|
238
|
-
const i = JSON.parse(r);
|
|
239
|
-
N(i) && n === V(i.id) ? t.push(i) : (e.removeItem(n), s -= 1);
|
|
240
|
-
} catch {
|
|
241
|
-
e.removeItem(n), s -= 1;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return t;
|
|
245
|
-
},
|
|
246
|
-
async set(t) {
|
|
247
|
-
e.setItem(V(t.id), JSON.stringify(t));
|
|
248
|
-
},
|
|
249
|
-
async remove(t) {
|
|
250
|
-
e.removeItem(V(t));
|
|
251
|
-
},
|
|
252
|
-
subscribe(t) {
|
|
253
|
-
const s = (r) => {
|
|
254
|
-
r.key?.startsWith(j) && t();
|
|
255
|
-
}, n = () => t();
|
|
256
|
-
return window.addEventListener("storage", s), window.addEventListener(it, n), () => {
|
|
257
|
-
window.removeEventListener("storage", s), window.removeEventListener(it, n);
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
function V(e) {
|
|
263
|
-
return `${j}${e}`;
|
|
264
|
-
}
|
|
265
|
-
const Z = "pluno.productAgent.transportId", Se = "pluno.productAgent.transportIdentity", Q = "pluno.productAgent.transportIdentity.event", ke = 50, Ee = globalThis.setTimeout.bind(globalThis);
|
|
94
|
+
const J = "pluno.productAgent.transportId", he = "pluno.productAgent.transportIdentity", V = "pluno.productAgent.transportIdentity.event", pe = 50, fe = globalThis.setTimeout.bind(globalThis);
|
|
266
95
|
let P = null;
|
|
267
|
-
const
|
|
268
|
-
async function
|
|
269
|
-
const t = e.randomUUID(), s = e.storage.getItem(
|
|
96
|
+
const x = /* @__PURE__ */ new Set();
|
|
97
|
+
async function ge(e = jt()) {
|
|
98
|
+
const t = e.randomUUID(), s = e.storage.getItem(J);
|
|
270
99
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
271
100
|
const o = e.channel.subscribe((u) => {
|
|
272
101
|
if (!(u.senderId === t || u.transportId !== n)) {
|
|
@@ -284,58 +113,58 @@ async function _e(e = Kt()) {
|
|
|
284
113
|
}
|
|
285
114
|
});
|
|
286
115
|
if (!s)
|
|
287
|
-
e.storage.setItem(
|
|
116
|
+
e.storage.setItem(J, n), r = !0;
|
|
288
117
|
else
|
|
289
118
|
for (; ; ) {
|
|
290
119
|
if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
|
|
291
120
|
r = !0;
|
|
292
121
|
break;
|
|
293
122
|
}
|
|
294
|
-
n = e.randomUUID(), e.storage.setItem(
|
|
123
|
+
n = e.randomUUID(), e.storage.setItem(J, n);
|
|
295
124
|
}
|
|
296
|
-
let
|
|
125
|
+
let l = !1;
|
|
297
126
|
return {
|
|
298
127
|
transportId: n,
|
|
299
128
|
release: () => {
|
|
300
|
-
|
|
129
|
+
l || (l = !0, o(), e.channel.close());
|
|
301
130
|
}
|
|
302
131
|
};
|
|
303
132
|
}
|
|
304
|
-
async function
|
|
305
|
-
P || (P =
|
|
133
|
+
async function me() {
|
|
134
|
+
P || (P = ge(jt()), P.then((n) => {
|
|
306
135
|
const r = (i) => {
|
|
307
|
-
i.persisted || (n.release(), P = null,
|
|
136
|
+
i.persisted || (n.release(), P = null, x.clear(), window.removeEventListener("pagehide", r));
|
|
308
137
|
};
|
|
309
138
|
window.addEventListener("pagehide", r);
|
|
310
139
|
}));
|
|
311
|
-
const e = await P, t =
|
|
312
|
-
|
|
140
|
+
const e = await P, t = ye();
|
|
141
|
+
x.add(t);
|
|
313
142
|
let s = !1;
|
|
314
143
|
return {
|
|
315
144
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
316
145
|
transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
|
|
317
146
|
release: () => {
|
|
318
|
-
s || (s = !0,
|
|
147
|
+
s || (s = !0, x.delete(t));
|
|
319
148
|
}
|
|
320
149
|
};
|
|
321
150
|
}
|
|
322
|
-
function
|
|
151
|
+
function ye() {
|
|
323
152
|
let e = 0;
|
|
324
|
-
for (;
|
|
153
|
+
for (; x.has(e); )
|
|
325
154
|
e += 1;
|
|
326
155
|
return e;
|
|
327
156
|
}
|
|
328
|
-
function
|
|
157
|
+
function jt() {
|
|
329
158
|
return {
|
|
330
159
|
storage: window.sessionStorage,
|
|
331
|
-
channel:
|
|
160
|
+
channel: Ie(),
|
|
332
161
|
randomUUID: () => crypto.randomUUID(),
|
|
333
|
-
settle: () => new Promise((e) =>
|
|
162
|
+
settle: () => new Promise((e) => fe(e, pe))
|
|
334
163
|
};
|
|
335
164
|
}
|
|
336
|
-
function
|
|
165
|
+
function Ie() {
|
|
337
166
|
if (typeof BroadcastChannel < "u") {
|
|
338
|
-
const e = new BroadcastChannel(
|
|
167
|
+
const e = new BroadcastChannel(he);
|
|
339
168
|
return {
|
|
340
169
|
postMessage: (t) => e.postMessage(t),
|
|
341
170
|
subscribe: (t) => {
|
|
@@ -345,11 +174,11 @@ function be() {
|
|
|
345
174
|
close: () => e.close()
|
|
346
175
|
};
|
|
347
176
|
}
|
|
348
|
-
return
|
|
177
|
+
return Te();
|
|
349
178
|
}
|
|
350
|
-
function
|
|
179
|
+
function Te() {
|
|
351
180
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
352
|
-
if (s.key !==
|
|
181
|
+
if (s.key !== V || !s.newValue)
|
|
353
182
|
return;
|
|
354
183
|
const n = JSON.parse(s.newValue);
|
|
355
184
|
for (const r of e)
|
|
@@ -358,9 +187,9 @@ function Me() {
|
|
|
358
187
|
return window.addEventListener("storage", t), {
|
|
359
188
|
postMessage: (s) => {
|
|
360
189
|
window.localStorage.setItem(
|
|
361
|
-
|
|
190
|
+
V,
|
|
362
191
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
363
|
-
), window.localStorage.removeItem(
|
|
192
|
+
), window.localStorage.removeItem(V);
|
|
364
193
|
},
|
|
365
194
|
subscribe: (s) => (e.add(s), () => e.delete(s)),
|
|
366
195
|
close: () => {
|
|
@@ -368,18 +197,18 @@ function Me() {
|
|
|
368
197
|
}
|
|
369
198
|
};
|
|
370
199
|
}
|
|
371
|
-
const
|
|
372
|
-
function
|
|
200
|
+
const st = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', we = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ae = ".pluno-pa-widget__panel", Se = ".pluno-pa-widget__timeline", wt = `${st}[data-pluno-sdk-preview-channel]`, ke = "https://app.pluno.ai", Ee = "gpt-5.6-terra", Re = 2e4, _e = 1e4, be = 1e4, Me = 1e4, Ce = 1e4, Pe = 1e3, At = 3e4, St = 0.2, kt = 6e4, Ue = 15e3, B = 8, De = 15e3, Ne = 2e3, Oe = 1e3, Be = 100, Le = 8e3, ve = 15e3, Et = 3, qe = [300, 1e3], dt = 64e3, Y = 4e3, ht = 30, xe = 2e3, Fe = 1e3, He = 200 * 1024 * 1024, pt = "Image is too large for model vision input.", We = 100, $t = "pluno.productAgent.state.", nt = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", je = 100;
|
|
201
|
+
function L(e, t = 0) {
|
|
373
202
|
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
374
203
|
return Math.max(t, s);
|
|
375
204
|
}
|
|
376
|
-
const
|
|
377
|
-
let
|
|
378
|
-
function
|
|
379
|
-
const s = Math.min(
|
|
380
|
-
return Math.min(
|
|
205
|
+
const F = /* @__PURE__ */ new Set();
|
|
206
|
+
let v = null;
|
|
207
|
+
function $e(e, t = Math.random) {
|
|
208
|
+
const s = Math.min(At, Pe * 2 ** e), n = 1 - St + t() * St * 2;
|
|
209
|
+
return Math.min(At, Math.round(s * n));
|
|
381
210
|
}
|
|
382
|
-
function
|
|
211
|
+
function ze(e, t, s) {
|
|
383
212
|
return new Promise((n, r) => {
|
|
384
213
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
385
214
|
e.then(
|
|
@@ -392,13 +221,13 @@ function es(e, t, s) {
|
|
|
392
221
|
);
|
|
393
222
|
});
|
|
394
223
|
}
|
|
395
|
-
class
|
|
224
|
+
class zt {
|
|
396
225
|
constructor(t, s) {
|
|
397
226
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
398
227
|
...this.state,
|
|
399
|
-
starterPrompts:
|
|
228
|
+
starterPrompts: Is(t.initialStarterPrompts)
|
|
400
229
|
};
|
|
401
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
230
|
+
const n = t.restorePersistedState === !1 ? null : Zs(t.clientId, t.expectedPersistedSessionId);
|
|
402
231
|
n && (this.state = {
|
|
403
232
|
...this.state,
|
|
404
233
|
...n,
|
|
@@ -411,20 +240,10 @@ class Yt {
|
|
|
411
240
|
assistantDraftRunId: null,
|
|
412
241
|
isThinking: !1,
|
|
413
242
|
lastError: null
|
|
414
|
-
}), this.queuedClientEvents =
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
),
|
|
418
|
-
clientId: t.clientId,
|
|
419
|
-
canDeliver: (r) => r.sessionId === this.state.sessionId,
|
|
420
|
-
deliver: async (r) => {
|
|
421
|
-
if (!this.sendMessage(r.prompt, {
|
|
422
|
-
clientMessageId: r.id,
|
|
423
|
-
initiatedBy: "pluno"
|
|
424
|
-
}))
|
|
425
|
-
throw new Error("Scheduled continuation could not be sent.");
|
|
426
|
-
}
|
|
427
|
-
});
|
|
243
|
+
}), this.queuedClientEvents = on(
|
|
244
|
+
tn(t.clientId),
|
|
245
|
+
sn(t.clientId)
|
|
246
|
+
), U(t.clientId, this.queuedClientEvents);
|
|
428
247
|
}
|
|
429
248
|
options;
|
|
430
249
|
listeners = {};
|
|
@@ -463,7 +282,6 @@ class Yt {
|
|
|
463
282
|
attachmentBlobCache = /* @__PURE__ */ new Map();
|
|
464
283
|
sessionUserFilesApiCleanup = null;
|
|
465
284
|
activeBrowserToolCalls = /* @__PURE__ */ new Map();
|
|
466
|
-
scheduledChatContinuationScheduler;
|
|
467
285
|
pageLifecycleCleanup = null;
|
|
468
286
|
transientStarterPromptsRequestInFlight = !1;
|
|
469
287
|
transientStarterPromptsRequestAttempted = !1;
|
|
@@ -489,15 +307,15 @@ class Yt {
|
|
|
489
307
|
lastErrorSecuritySettingsUrl: null
|
|
490
308
|
};
|
|
491
309
|
static async init(t) {
|
|
492
|
-
const s = await
|
|
310
|
+
const s = await me(), n = new zt({
|
|
493
311
|
...t,
|
|
494
|
-
backendUrl:
|
|
495
|
-
clientId: t.clientId ??
|
|
496
|
-
model: t.model ??
|
|
312
|
+
backendUrl: ls(t.backendUrl ?? ke),
|
|
313
|
+
clientId: t.clientId ?? ks(),
|
|
314
|
+
model: t.model ?? Ee
|
|
497
315
|
}, s);
|
|
498
316
|
try {
|
|
499
|
-
|
|
500
|
-
|
|
317
|
+
ue().catch((r) => {
|
|
318
|
+
f("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
501
319
|
message: r instanceof Error ? r.message : String(r)
|
|
502
320
|
});
|
|
503
321
|
}), t.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), t.autoConnect !== !1 && await n.connect();
|
|
@@ -528,15 +346,15 @@ class Yt {
|
|
|
528
346
|
lastError: null
|
|
529
347
|
});
|
|
530
348
|
try {
|
|
531
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
349
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await ze(this.options.tokenProvider(), be, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
532
350
|
return;
|
|
533
351
|
if (!this.token && !this.options.webSocketFactory)
|
|
534
352
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
535
|
-
const s =
|
|
353
|
+
const s = ds(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
536
354
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
537
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (
|
|
538
|
-
},
|
|
539
|
-
this.socket !== n || (this.clearSocketConnectTimer(),
|
|
355
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (f("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
356
|
+
}, Me), n.addEventListener("open", () => {
|
|
357
|
+
this.socket !== n || (this.clearSocketConnectTimer(), f("web-sdk.agent", "Pluno socket opened", {
|
|
540
358
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
541
359
|
isThinking: this.state.isThinking
|
|
542
360
|
}), !(this.token ? this.sendNow({
|
|
@@ -546,12 +364,12 @@ class Yt {
|
|
|
546
364
|
transportId: this.transportIdentity.transportId,
|
|
547
365
|
pageUrl: location.href
|
|
548
366
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
549
|
-
this.socket === n && (
|
|
550
|
-
},
|
|
367
|
+
this.socket === n && (f("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
368
|
+
}, Ce));
|
|
551
369
|
}), n.addEventListener("message", (r) => {
|
|
552
|
-
this.socket === n && this.handleServerEvent(
|
|
370
|
+
this.socket === n && this.handleServerEvent(ys(r.data));
|
|
553
371
|
}), n.addEventListener("close", (r) => {
|
|
554
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (
|
|
372
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (f("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
555
373
|
code: typeof r?.code == "number" ? r.code : null,
|
|
556
374
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
557
375
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -559,7 +377,7 @@ class Yt {
|
|
|
559
377
|
isThinking: this.state.isThinking
|
|
560
378
|
}), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
|
|
561
379
|
}), n.addEventListener("error", () => {
|
|
562
|
-
this.socket !== n || this.state.status === "closed" || (
|
|
380
|
+
this.socket !== n || this.state.status === "closed" || (f("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
563
381
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
564
382
|
isThinking: this.state.isThinking
|
|
565
383
|
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
@@ -582,25 +400,25 @@ class Yt {
|
|
|
582
400
|
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;
|
|
583
401
|
}
|
|
584
402
|
destroy() {
|
|
585
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
403
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), an(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
586
404
|
for (const t of Object.values(this.listeners))
|
|
587
405
|
t?.clear();
|
|
588
406
|
}
|
|
589
407
|
sendMessage(t, s = {}) {
|
|
590
|
-
const n = t.trim(), r = s.attachments ?? [], i = r.map(
|
|
408
|
+
const n = t.trim(), r = s.attachments ?? [], i = r.map(It);
|
|
591
409
|
if (!n && i.length === 0)
|
|
592
410
|
return null;
|
|
593
|
-
const o =
|
|
411
|
+
const o = w(), l = s.clientMessageId ?? q();
|
|
594
412
|
this.retryableClientMessageId = null;
|
|
595
413
|
const u = {
|
|
596
|
-
id: `local-${
|
|
414
|
+
id: `local-${l}`,
|
|
597
415
|
role: "user",
|
|
598
416
|
content: n,
|
|
599
417
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
600
418
|
...r.length > 0 ? { attachments: r } : {}
|
|
601
|
-
},
|
|
419
|
+
}, c = this.state.messages.some((h) => h.id === u.id || h.clientMessageId === l);
|
|
602
420
|
this.setState({
|
|
603
|
-
messages:
|
|
421
|
+
messages: c ? this.state.messages : [...this.state.messages, u],
|
|
604
422
|
...this.state.isThinking ? {} : {
|
|
605
423
|
assistantDraft: "",
|
|
606
424
|
assistantDraftItemId: null,
|
|
@@ -610,45 +428,45 @@ class Yt {
|
|
|
610
428
|
},
|
|
611
429
|
isThinking: !0,
|
|
612
430
|
lastError: null
|
|
613
|
-
}),
|
|
431
|
+
}), c || this.emit("message", u);
|
|
614
432
|
const a = {
|
|
615
433
|
type: "chat.user_message",
|
|
616
434
|
sessionId: this.state.sessionId ?? void 0,
|
|
617
|
-
clientMessageId:
|
|
435
|
+
clientMessageId: l,
|
|
618
436
|
initiatedBy: s.initiatedBy,
|
|
619
437
|
content: n,
|
|
620
438
|
attachments: i.length > 0 ? i : void 0,
|
|
621
439
|
page: o,
|
|
622
440
|
model: this.options.model,
|
|
623
|
-
metadata:
|
|
441
|
+
metadata: Rt(this.options.metadata)
|
|
624
442
|
};
|
|
625
|
-
return this.activeClientMessageId =
|
|
443
|
+
return this.activeClientMessageId = l, this.activeUserMessageEvent = a, this.markThinkingProgress(), this.send(a), this.startBackgroundAttachmentUploads(l, i), l;
|
|
626
444
|
}
|
|
627
445
|
retryLastMessage() {
|
|
628
446
|
const t = this.state.sessionId, s = this.retryableClientMessageId;
|
|
629
447
|
return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
|
|
630
448
|
}
|
|
631
449
|
createLocalAttachment(t) {
|
|
632
|
-
const s =
|
|
450
|
+
const s = q(), n = {
|
|
633
451
|
id: s,
|
|
634
452
|
name: t.name || "attachment",
|
|
635
|
-
mimeType:
|
|
453
|
+
mimeType: Lt(t),
|
|
636
454
|
sizeBytes: t.size
|
|
637
455
|
};
|
|
638
456
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
639
457
|
const r = Date.now();
|
|
640
|
-
return
|
|
458
|
+
return xt({
|
|
641
459
|
attachmentId: s,
|
|
642
460
|
name: n.name,
|
|
643
461
|
mimeType: n.mimeType,
|
|
644
462
|
sizeBytes: n.sizeBytes,
|
|
645
463
|
blob: t,
|
|
646
|
-
origin:
|
|
464
|
+
origin: w().origin,
|
|
647
465
|
sessionId: this.state.sessionId ?? void 0,
|
|
648
466
|
createdAt: r,
|
|
649
467
|
lastUsedAt: r
|
|
650
468
|
}).catch((i) => {
|
|
651
|
-
|
|
469
|
+
f("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
652
470
|
attachmentId: s,
|
|
653
471
|
name: n.name,
|
|
654
472
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -660,7 +478,7 @@ class Yt {
|
|
|
660
478
|
return await this.uploadAttachmentForMessage({
|
|
661
479
|
file: t,
|
|
662
480
|
attachment: s,
|
|
663
|
-
clientMessageId:
|
|
481
|
+
clientMessageId: q(),
|
|
664
482
|
waitForSession: !1,
|
|
665
483
|
notifyCompletion: !1
|
|
666
484
|
});
|
|
@@ -677,7 +495,7 @@ class Yt {
|
|
|
677
495
|
waitForSession: !0,
|
|
678
496
|
notifyCompletion: !0
|
|
679
497
|
}).catch((i) => {
|
|
680
|
-
|
|
498
|
+
f("web-sdk.agent", "Attachment background upload failed", {
|
|
681
499
|
attachmentId: n.id,
|
|
682
500
|
name: n.name,
|
|
683
501
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -692,46 +510,46 @@ class Yt {
|
|
|
692
510
|
waitForSession: r,
|
|
693
511
|
notifyCompletion: i
|
|
694
512
|
}) {
|
|
695
|
-
const o = r ? await this.waitForSessionId() : this.state.sessionId,
|
|
513
|
+
const o = r ? await this.waitForSessionId() : this.state.sessionId, l = Lt(t), u = {
|
|
696
514
|
sessionId: o ?? void 0,
|
|
697
515
|
attachmentId: s.id,
|
|
698
516
|
clientId: this.options.clientId,
|
|
699
517
|
transportId: this.transportIdentity.transportId,
|
|
700
518
|
name: t.name || "attachment",
|
|
701
|
-
mimeType:
|
|
519
|
+
mimeType: l,
|
|
702
520
|
sizeBytes: t.size,
|
|
703
|
-
page:
|
|
521
|
+
page: w(),
|
|
704
522
|
model: this.options.model,
|
|
705
|
-
metadata:
|
|
706
|
-
},
|
|
523
|
+
metadata: Rt(this.options.metadata)
|
|
524
|
+
}, c = this.options.prepareAttachmentUpload ? await tt(
|
|
707
525
|
() => this.options.prepareAttachmentUpload(u),
|
|
708
526
|
"Failed to prepare attachment upload"
|
|
709
527
|
) : await this.prepareEmbedAttachmentUpload(u);
|
|
710
|
-
await
|
|
711
|
-
const h = await fetch(
|
|
712
|
-
method:
|
|
713
|
-
headers:
|
|
528
|
+
await tt(async () => {
|
|
529
|
+
const h = await fetch(c.uploadUrl, {
|
|
530
|
+
method: c.uploadMethod,
|
|
531
|
+
headers: c.uploadHeaders,
|
|
714
532
|
body: t
|
|
715
533
|
});
|
|
716
534
|
if (!h.ok)
|
|
717
|
-
throw new
|
|
535
|
+
throw new H("Failed to upload attachment", h.status);
|
|
718
536
|
return h;
|
|
719
|
-
}, "Failed to upload attachment"), this.setState({ sessionId:
|
|
720
|
-
const a =
|
|
721
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
722
|
-
sessionId:
|
|
537
|
+
}, "Failed to upload attachment"), this.setState({ sessionId: c.sessionId });
|
|
538
|
+
const a = Qt(c.attachment, this.options.backendUrl);
|
|
539
|
+
return this.updateAttachmentInState(s.id, a), s.id && Ft(s.id, {
|
|
540
|
+
sessionId: c.sessionId,
|
|
723
541
|
fileUrl: a.fileUrl,
|
|
724
542
|
gcsPath: a.gcsPath,
|
|
725
543
|
lastUsedAt: Date.now()
|
|
726
544
|
}).catch((h) => {
|
|
727
|
-
|
|
545
|
+
f("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
728
546
|
attachmentId: s.id,
|
|
729
547
|
name: a.name,
|
|
730
548
|
message: h instanceof Error ? h.message : String(h)
|
|
731
549
|
});
|
|
732
550
|
}), i && a.gcsPath && this.send({
|
|
733
551
|
type: "attachment.upload_completed",
|
|
734
|
-
sessionId:
|
|
552
|
+
sessionId: c.sessionId,
|
|
735
553
|
clientMessageId: n,
|
|
736
554
|
attachment: a
|
|
737
555
|
}), a;
|
|
@@ -740,7 +558,7 @@ class Yt {
|
|
|
740
558
|
return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
|
|
741
559
|
const n = window.setTimeout(() => {
|
|
742
560
|
r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
|
|
743
|
-
},
|
|
561
|
+
}, ve), r = this.on("state", (i) => {
|
|
744
562
|
i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
|
|
745
563
|
});
|
|
746
564
|
});
|
|
@@ -758,18 +576,18 @@ class Yt {
|
|
|
758
576
|
}
|
|
759
577
|
async prepareEmbedAttachmentUpload(t) {
|
|
760
578
|
let s = !1;
|
|
761
|
-
return await
|
|
579
|
+
return await tt(async () => {
|
|
762
580
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
763
581
|
if (n.ok)
|
|
764
582
|
return await n.json();
|
|
765
|
-
if (
|
|
583
|
+
if (Rn(n.status) && this.options.tokenProvider && !s) {
|
|
766
584
|
s = !0;
|
|
767
585
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
768
586
|
if (r.ok)
|
|
769
587
|
return await r.json();
|
|
770
|
-
throw new
|
|
588
|
+
throw new H("Failed to prepare attachment upload", r.status);
|
|
771
589
|
}
|
|
772
|
-
throw new
|
|
590
|
+
throw new H("Failed to prepare attachment upload", n.status);
|
|
773
591
|
}, "Failed to prepare attachment upload");
|
|
774
592
|
}
|
|
775
593
|
async fetchEmbedAttachmentUpload(t) {
|
|
@@ -791,7 +609,7 @@ class Yt {
|
|
|
791
609
|
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, s && this.send({
|
|
792
610
|
type: "session.reset",
|
|
793
611
|
sessionId: this.state.sessionId ?? void 0,
|
|
794
|
-
page:
|
|
612
|
+
page: w()
|
|
795
613
|
}), this.setState({
|
|
796
614
|
sessionId: null,
|
|
797
615
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -806,15 +624,15 @@ class Yt {
|
|
|
806
624
|
});
|
|
807
625
|
}
|
|
808
626
|
listSessions(t = {}) {
|
|
809
|
-
const s =
|
|
810
|
-
const
|
|
627
|
+
const s = q(), n = new Promise((i, o) => {
|
|
628
|
+
const l = window.setTimeout(() => {
|
|
811
629
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
812
|
-
},
|
|
813
|
-
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout:
|
|
630
|
+
}, Le);
|
|
631
|
+
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: l });
|
|
814
632
|
}), r = {
|
|
815
633
|
type: "sessions.list",
|
|
816
634
|
requestId: s,
|
|
817
|
-
page:
|
|
635
|
+
page: w(),
|
|
818
636
|
...t.cursor ? { cursor: t.cursor } : {},
|
|
819
637
|
...t.limit ? { limit: t.limit } : {}
|
|
820
638
|
};
|
|
@@ -838,11 +656,11 @@ class Yt {
|
|
|
838
656
|
}), this.send({
|
|
839
657
|
type: "session.load",
|
|
840
658
|
sessionId: t,
|
|
841
|
-
page:
|
|
659
|
+
page: w()
|
|
842
660
|
});
|
|
843
661
|
}
|
|
844
662
|
send(t) {
|
|
845
|
-
this.sendNow(
|
|
663
|
+
this.sendNow(A(t)) || (this.queuedClientEvents.push(t), U(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
846
664
|
}
|
|
847
665
|
async getUploadToken() {
|
|
848
666
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -857,7 +675,7 @@ class Yt {
|
|
|
857
675
|
try {
|
|
858
676
|
return s.send(JSON.stringify(t)), !0;
|
|
859
677
|
} catch (n) {
|
|
860
|
-
return
|
|
678
|
+
return f("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
861
679
|
message: n instanceof Error ? n.message : String(n),
|
|
862
680
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
863
681
|
isThinking: this.state.isThinking
|
|
@@ -868,9 +686,9 @@ class Yt {
|
|
|
868
686
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
869
687
|
return;
|
|
870
688
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
871
|
-
const t =
|
|
689
|
+
const t = hs();
|
|
872
690
|
this.sendNow(
|
|
873
|
-
|
|
691
|
+
A({
|
|
874
692
|
type: "starter_prompts.page_context",
|
|
875
693
|
pageUrl: t.pageUrl,
|
|
876
694
|
pageTitle: t.pageTitle,
|
|
@@ -879,13 +697,13 @@ class Yt {
|
|
|
879
697
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
880
698
|
}
|
|
881
699
|
startStarterPromptUrlWatcher() {
|
|
882
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
700
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = ps(() => this.handleStarterPromptUrlChange()));
|
|
883
701
|
}
|
|
884
702
|
handleStarterPromptUrlChange() {
|
|
885
703
|
const t = location.href;
|
|
886
704
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
887
705
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
888
|
-
},
|
|
706
|
+
}, je));
|
|
889
707
|
}
|
|
890
708
|
refreshStarterPromptsForCurrentUrl() {
|
|
891
709
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -900,14 +718,14 @@ class Yt {
|
|
|
900
718
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
901
719
|
return;
|
|
902
720
|
const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
903
|
-
|
|
721
|
+
U(this.options.clientId, this.queuedClientEvents);
|
|
904
722
|
for (let s = 0; s < t.length; s += 1) {
|
|
905
723
|
const n = t[s];
|
|
906
|
-
if (!this.sendNow(
|
|
907
|
-
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)),
|
|
724
|
+
if (!this.sendNow(A(n))) {
|
|
725
|
+
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), U(this.options.clientId, this.queuedClientEvents);
|
|
908
726
|
return;
|
|
909
727
|
}
|
|
910
|
-
|
|
728
|
+
U(this.options.clientId, this.queuedClientEvents);
|
|
911
729
|
}
|
|
912
730
|
}
|
|
913
731
|
handleServerEvent(t) {
|
|
@@ -919,29 +737,29 @@ class Yt {
|
|
|
919
737
|
this.clearHeartbeatAckTimer();
|
|
920
738
|
return;
|
|
921
739
|
}
|
|
922
|
-
if (
|
|
740
|
+
if (Ke(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
923
741
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
|
|
924
|
-
const s =
|
|
925
|
-
|
|
742
|
+
const s = Ts(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
743
|
+
f("web-sdk.agent", "Received auth.ok appearance", {
|
|
926
744
|
hasAppearance: n,
|
|
927
745
|
rawAppearance: t.appearance,
|
|
928
746
|
normalizedAppearance: s
|
|
929
|
-
}), this.runtimeHelperJavascript =
|
|
930
|
-
const r =
|
|
931
|
-
user:
|
|
747
|
+
}), this.runtimeHelperJavascript = ws(t.runtimeHelpers)?.javascript ?? null;
|
|
748
|
+
const r = bt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, l = {
|
|
749
|
+
user: Es(t.user),
|
|
932
750
|
status: "connected"
|
|
933
751
|
};
|
|
934
|
-
(i || this.state.starterPrompts.length === 0) && (
|
|
752
|
+
(i || this.state.starterPrompts.length === 0) && (l.starterPrompts = r, l.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (l.appearance = s), this.setState(l), i && r.length === 0 && !o && !gs() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
935
753
|
type: "page.upsert",
|
|
936
754
|
sessionId: this.state.sessionId,
|
|
937
|
-
page:
|
|
755
|
+
page: w(),
|
|
938
756
|
model: this.options.model
|
|
939
757
|
});
|
|
940
758
|
return;
|
|
941
759
|
}
|
|
942
760
|
if (t.type === "starterPrompts.updated") {
|
|
943
761
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
944
|
-
starterPrompts:
|
|
762
|
+
starterPrompts: bt(t, "starterPrompts"),
|
|
945
763
|
starterPromptsLoading: !1
|
|
946
764
|
});
|
|
947
765
|
return;
|
|
@@ -949,36 +767,36 @@ class Yt {
|
|
|
949
767
|
if (t.type === "conversation.state") {
|
|
950
768
|
const s = Array.isArray(t.items) ? t.items : [];
|
|
951
769
|
this.rememberUserMessageClientMessageIds(s);
|
|
952
|
-
const n =
|
|
770
|
+
const n = Ws(s);
|
|
953
771
|
if (n) {
|
|
954
|
-
const a =
|
|
772
|
+
const a = js(s, n);
|
|
955
773
|
this.retryAttemptsByClientMessageId[n] = Math.max(
|
|
956
774
|
this.retryAttemptsByClientMessageId[n] ?? 0,
|
|
957
775
|
a
|
|
958
776
|
);
|
|
959
777
|
}
|
|
960
778
|
const r = s.filter((a) => {
|
|
961
|
-
const h =
|
|
962
|
-
return !
|
|
963
|
-
}), i =
|
|
779
|
+
const h = D(a);
|
|
780
|
+
return !Dt(h) && (!n || !it(h));
|
|
781
|
+
}), i = Bs(
|
|
964
782
|
this.state.messages,
|
|
965
|
-
|
|
966
|
-
), o =
|
|
967
|
-
(a) =>
|
|
968
|
-
|
|
783
|
+
Rs(r, this.options.backendUrl)
|
|
784
|
+
), o = Ut(i), l = s.some(
|
|
785
|
+
(a) => Ot(
|
|
786
|
+
D(a),
|
|
969
787
|
this.state.assistantDraft,
|
|
970
788
|
this.state.assistantDraftItemId,
|
|
971
789
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
972
790
|
this.state.assistantDraftRunId
|
|
973
791
|
)
|
|
974
|
-
), u = o && (!this.state.assistantDraft ||
|
|
975
|
-
if (!o &&
|
|
792
|
+
), u = o && (!this.state.assistantDraft || l);
|
|
793
|
+
if (!o && Hs(this.state.messages, s))
|
|
976
794
|
return;
|
|
977
|
-
const
|
|
978
|
-
if (this.latestRecoverableClientMessageId =
|
|
979
|
-
sessionId:
|
|
795
|
+
const c = u ? null : ot(s);
|
|
796
|
+
if (this.latestRecoverableClientMessageId = c, xs(i) && this.clearRetryTimers(), this.setState({
|
|
797
|
+
sessionId: T(t.session, "id") ?? this.state.sessionId,
|
|
980
798
|
messages: i,
|
|
981
|
-
...
|
|
799
|
+
...l ? {
|
|
982
800
|
assistantDraft: "",
|
|
983
801
|
assistantDraftItemId: null,
|
|
984
802
|
assistantDraftPhase: null,
|
|
@@ -987,12 +805,12 @@ class Yt {
|
|
|
987
805
|
} : {},
|
|
988
806
|
...u ? {
|
|
989
807
|
isThinking: !1
|
|
990
|
-
} :
|
|
808
|
+
} : c ? {
|
|
991
809
|
isThinking: !0,
|
|
992
810
|
lastError: null
|
|
993
811
|
} : {}
|
|
994
|
-
}), u ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) :
|
|
995
|
-
const a =
|
|
812
|
+
}), u ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : c && (this.activeClientMessageId = c, this.markThinkingProgress()), n) {
|
|
813
|
+
const a = T(t.session, "id") ?? this.state.sessionId;
|
|
996
814
|
a && this.retryAfterInterruptedRun(a, n);
|
|
997
815
|
}
|
|
998
816
|
return;
|
|
@@ -1000,23 +818,23 @@ class Yt {
|
|
|
1000
818
|
if (t.type === "sessions.page") {
|
|
1001
819
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1002
820
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1003
|
-
sessions:
|
|
821
|
+
sessions: _s(t.sessions),
|
|
1004
822
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
1005
823
|
}));
|
|
1006
824
|
return;
|
|
1007
825
|
}
|
|
1008
826
|
if (t.type === "session.updated") {
|
|
1009
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
827
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: T(t.session, "id") ?? this.state.sessionId });
|
|
1010
828
|
return;
|
|
1011
829
|
}
|
|
1012
830
|
if (t.type === "session.item") {
|
|
1013
831
|
this.rememberUserMessageClientMessageIds([t.item]);
|
|
1014
|
-
const s =
|
|
1015
|
-
if (
|
|
832
|
+
const s = D(t.item);
|
|
833
|
+
if (it(s)) {
|
|
1016
834
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1017
|
-
const r =
|
|
1018
|
-
if (r &&
|
|
1019
|
-
this.retryAfterInterruptedRun(r,
|
|
835
|
+
const r = T(t.item, "sessionId") ?? this.state.sessionId, i = s ? R(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, l = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
836
|
+
if (r && l) {
|
|
837
|
+
this.retryAfterInterruptedRun(r, l);
|
|
1020
838
|
return;
|
|
1021
839
|
}
|
|
1022
840
|
if (r && i) {
|
|
@@ -1024,23 +842,23 @@ class Yt {
|
|
|
1024
842
|
return;
|
|
1025
843
|
}
|
|
1026
844
|
}
|
|
1027
|
-
if (
|
|
845
|
+
if (Dt(s))
|
|
1028
846
|
return;
|
|
1029
|
-
const n =
|
|
847
|
+
const n = Xt(t.item, this.options.backendUrl);
|
|
1030
848
|
if (n) {
|
|
1031
|
-
|
|
849
|
+
N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1032
850
|
const r = t.item.data;
|
|
1033
|
-
|
|
1034
|
-
const i =
|
|
851
|
+
zs(r) && this.clearRunAckResyncRetryTimer();
|
|
852
|
+
const i = Ct(this.state.messages, n), o = Ut(i), l = Ot(
|
|
1035
853
|
r,
|
|
1036
854
|
this.state.assistantDraft,
|
|
1037
855
|
this.state.assistantDraftItemId,
|
|
1038
856
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1039
857
|
this.state.assistantDraftRunId
|
|
1040
|
-
), u = o && (!this.state.assistantDraft ||
|
|
858
|
+
), u = o && (!this.state.assistantDraft || l);
|
|
1041
859
|
this.setState({
|
|
1042
860
|
messages: i,
|
|
1043
|
-
...
|
|
861
|
+
...l ? {
|
|
1044
862
|
assistantDraft: "",
|
|
1045
863
|
assistantDraftItemId: null,
|
|
1046
864
|
assistantDraftPhase: null,
|
|
@@ -1083,9 +901,9 @@ class Yt {
|
|
|
1083
901
|
}
|
|
1084
902
|
if (t.type === "tool.call") {
|
|
1085
903
|
this.clearRunAckResyncRetryTimer();
|
|
1086
|
-
const s =
|
|
904
|
+
const s = Ns(t);
|
|
1087
905
|
s && (this.setState({
|
|
1088
|
-
messages:
|
|
906
|
+
messages: Ct(this.state.messages, s),
|
|
1089
907
|
isThinking: !0
|
|
1090
908
|
}), this.emit("message", s)), this.executeToolCall(t);
|
|
1091
909
|
return;
|
|
@@ -1102,14 +920,14 @@ class Yt {
|
|
|
1102
920
|
return;
|
|
1103
921
|
}
|
|
1104
922
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1105
|
-
const
|
|
923
|
+
const l = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = us(l.message);
|
|
1106
924
|
u && console.error(u), this.setState({
|
|
1107
925
|
status: "error",
|
|
1108
926
|
isThinking: !1,
|
|
1109
|
-
lastError:
|
|
927
|
+
lastError: l.message,
|
|
1110
928
|
lastErrorCode: typeof t.code == "string" ? t.code : null,
|
|
1111
929
|
lastErrorSecuritySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : null
|
|
1112
|
-
}), this.clearThinkingWatchdog(), this.emit("error",
|
|
930
|
+
}), this.clearThinkingWatchdog(), this.emit("error", l);
|
|
1113
931
|
}
|
|
1114
932
|
}
|
|
1115
933
|
retryAfterRetryableError(t) {
|
|
@@ -1118,20 +936,20 @@ class Yt {
|
|
|
1118
936
|
return !1;
|
|
1119
937
|
if (t.code === "run_still_active") {
|
|
1120
938
|
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) {
|
|
1121
|
-
const
|
|
939
|
+
const l = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
|
|
1122
940
|
this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
|
|
1123
941
|
delete this.retryTimersByClientMessageId[n], this.resyncThinkingSession(), this.markThinkingProgress();
|
|
1124
|
-
},
|
|
942
|
+
}, l);
|
|
1125
943
|
}
|
|
1126
944
|
return !0;
|
|
1127
945
|
}
|
|
1128
946
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1129
947
|
return !0;
|
|
1130
948
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1131
|
-
if (i >=
|
|
949
|
+
if (i >= B)
|
|
1132
950
|
return !1;
|
|
1133
951
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1134
|
-
const o =
|
|
952
|
+
const o = L(
|
|
1135
953
|
i,
|
|
1136
954
|
typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
|
|
1137
955
|
);
|
|
@@ -1148,7 +966,7 @@ class Yt {
|
|
|
1148
966
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1149
967
|
return;
|
|
1150
968
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1151
|
-
if (n >=
|
|
969
|
+
if (n >= B) {
|
|
1152
970
|
this.retryableClientMessageId = s, this.setState({
|
|
1153
971
|
isThinking: !1,
|
|
1154
972
|
lastError: "Pluno could not finish this message. Try it again.",
|
|
@@ -1158,7 +976,7 @@ class Yt {
|
|
|
1158
976
|
}
|
|
1159
977
|
this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
|
|
1160
978
|
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 });
|
|
1161
|
-
},
|
|
979
|
+
}, L(n));
|
|
1162
980
|
}
|
|
1163
981
|
clearRetryTimers() {
|
|
1164
982
|
for (const t of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1167,7 +985,7 @@ class Yt {
|
|
|
1167
985
|
}
|
|
1168
986
|
rememberUserMessageClientMessageIds(t) {
|
|
1169
987
|
for (const s of t) {
|
|
1170
|
-
const n =
|
|
988
|
+
const n = T(s, "id"), r = D(s);
|
|
1171
989
|
n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
|
|
1172
990
|
}
|
|
1173
991
|
}
|
|
@@ -1177,7 +995,7 @@ class Yt {
|
|
|
1177
995
|
this.pendingSessionHistoryRequests.clear();
|
|
1178
996
|
}
|
|
1179
997
|
markThinkingProgress() {
|
|
1180
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
998
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(kt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1181
999
|
}
|
|
1182
1000
|
scheduleThinkingWatchdog(t) {
|
|
1183
1001
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1189,18 +1007,18 @@ class Yt {
|
|
|
1189
1007
|
}
|
|
1190
1008
|
handleRunAck(t) {
|
|
1191
1009
|
const s = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
|
|
1192
|
-
s &&
|
|
1010
|
+
s && this.emit("ack", {
|
|
1193
1011
|
clientMessageId: s,
|
|
1194
1012
|
sessionId: typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId
|
|
1195
|
-
})
|
|
1013
|
+
}), !(!this.state.isThinking || !s || s !== this.activeClientMessageId) && (this.clearRunAckResyncRetryTimer(), this.scheduleRunAckWatchdog(s));
|
|
1196
1014
|
}
|
|
1197
1015
|
scheduleRunAckWatchdog(t) {
|
|
1198
1016
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1199
1017
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1200
|
-
},
|
|
1018
|
+
}, De);
|
|
1201
1019
|
}
|
|
1202
1020
|
recoverMissedRunAck(t) {
|
|
1203
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (
|
|
1021
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (f("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
1204
1022
|
sessionId: this.state.sessionId,
|
|
1205
1023
|
clientMessageId: t
|
|
1206
1024
|
}), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
|
|
@@ -1208,12 +1026,12 @@ class Yt {
|
|
|
1208
1026
|
scheduleRunAckResyncRetry(t) {
|
|
1209
1027
|
this.clearRunAckResyncRetryTimer();
|
|
1210
1028
|
const s = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1211
|
-
s >=
|
|
1029
|
+
s >= B || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1212
1030
|
this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
|
|
1213
1031
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1214
1032
|
isThinking: !0,
|
|
1215
1033
|
lastError: null
|
|
1216
|
-
}),
|
|
1034
|
+
}), f("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
1217
1035
|
sessionId: this.state.sessionId,
|
|
1218
1036
|
clientMessageId: t
|
|
1219
1037
|
}), this.state.sessionId ? this.send({
|
|
@@ -1221,8 +1039,8 @@ class Yt {
|
|
|
1221
1039
|
sessionId: this.state.sessionId,
|
|
1222
1040
|
clientMessageId: t,
|
|
1223
1041
|
automatic: !0
|
|
1224
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1225
|
-
},
|
|
1042
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(kt)));
|
|
1043
|
+
}, L(s, Ne)));
|
|
1226
1044
|
}
|
|
1227
1045
|
clearRunAckResyncRetryTimer() {
|
|
1228
1046
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1235,7 +1053,7 @@ class Yt {
|
|
|
1235
1053
|
return;
|
|
1236
1054
|
const t = this.activeClientMessageId;
|
|
1237
1055
|
if (!t) {
|
|
1238
|
-
|
|
1056
|
+
f("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
1239
1057
|
sessionId: this.state.sessionId
|
|
1240
1058
|
}), this.setState({
|
|
1241
1059
|
isThinking: !1,
|
|
@@ -1245,8 +1063,8 @@ class Yt {
|
|
|
1245
1063
|
return;
|
|
1246
1064
|
}
|
|
1247
1065
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1248
|
-
if (n >=
|
|
1249
|
-
|
|
1066
|
+
if (n >= B) {
|
|
1067
|
+
f("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1250
1068
|
sessionId: this.state.sessionId,
|
|
1251
1069
|
clientMessageId: t
|
|
1252
1070
|
}), this.retryableClientMessageId = t, this.setState({
|
|
@@ -1257,18 +1075,18 @@ class Yt {
|
|
|
1257
1075
|
return;
|
|
1258
1076
|
}
|
|
1259
1077
|
if (s < 1) {
|
|
1260
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1,
|
|
1078
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, f("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
1261
1079
|
sessionId: this.state.sessionId,
|
|
1262
1080
|
clientMessageId: t,
|
|
1263
1081
|
resyncAttempts: s + 1
|
|
1264
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1082
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ue);
|
|
1265
1083
|
return;
|
|
1266
1084
|
}
|
|
1267
1085
|
this.setState({
|
|
1268
1086
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1269
1087
|
isThinking: !0,
|
|
1270
1088
|
lastError: null
|
|
1271
|
-
}),
|
|
1089
|
+
}), f("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
1272
1090
|
sessionId: this.state.sessionId,
|
|
1273
1091
|
clientMessageId: t,
|
|
1274
1092
|
retryAttempts: n + 1
|
|
@@ -1279,31 +1097,32 @@ class Yt {
|
|
|
1279
1097
|
clientMessageId: t,
|
|
1280
1098
|
automatic: !0
|
|
1281
1099
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1282
|
-
},
|
|
1100
|
+
}, L(n)));
|
|
1283
1101
|
}
|
|
1284
1102
|
resyncThinkingSession() {
|
|
1285
1103
|
this.state.sessionId ? this.send({
|
|
1286
1104
|
type: "page.upsert",
|
|
1287
1105
|
sessionId: this.state.sessionId,
|
|
1288
|
-
page:
|
|
1106
|
+
page: w(),
|
|
1289
1107
|
model: this.options.model
|
|
1290
1108
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
|
|
1291
1109
|
}
|
|
1292
1110
|
async executeToolCall(t) {
|
|
1293
|
-
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 =
|
|
1111
|
+
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 = M(
|
|
1294
1112
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
1295
1113
|
), o = t.rawInput;
|
|
1296
1114
|
if (!s || !n || !r)
|
|
1297
1115
|
return;
|
|
1298
|
-
|
|
1116
|
+
const l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1117
|
+
if (r !== "execute_code" && !l || !pn(o)) {
|
|
1299
1118
|
this.send({
|
|
1300
1119
|
type: "tool.result",
|
|
1301
1120
|
sessionId: s,
|
|
1302
1121
|
callId: n,
|
|
1303
1122
|
toolName: r,
|
|
1304
1123
|
summary: i,
|
|
1305
|
-
rawInput:
|
|
1306
|
-
rawOutput:
|
|
1124
|
+
rawInput: A(o),
|
|
1125
|
+
rawOutput: A({
|
|
1307
1126
|
ok: !1,
|
|
1308
1127
|
toolName: r,
|
|
1309
1128
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -1311,7 +1130,7 @@ class Yt {
|
|
|
1311
1130
|
});
|
|
1312
1131
|
return;
|
|
1313
1132
|
}
|
|
1314
|
-
const
|
|
1133
|
+
const u = Ye(this.state.messages);
|
|
1315
1134
|
this.activeBrowserToolCalls.set(n, {
|
|
1316
1135
|
event: {
|
|
1317
1136
|
type: "tool.result",
|
|
@@ -1319,25 +1138,18 @@ class Yt {
|
|
|
1319
1138
|
callId: n,
|
|
1320
1139
|
toolName: r,
|
|
1321
1140
|
summary: i,
|
|
1322
|
-
rawInput:
|
|
1141
|
+
rawInput: A(o),
|
|
1323
1142
|
rawOutput: null
|
|
1324
1143
|
},
|
|
1325
1144
|
startedAtMs: Date.now(),
|
|
1326
1145
|
startedAtUrl: location.href,
|
|
1327
1146
|
startedAtOrigin: location.origin
|
|
1328
|
-
}), this.installSessionUserFilesApi(
|
|
1329
|
-
let
|
|
1330
|
-
|
|
1331
|
-
...o,
|
|
1332
|
-
javascript: Te(o.javascript, {
|
|
1333
|
-
clientId: this.options.clientId,
|
|
1334
|
-
sessionId: s,
|
|
1335
|
-
callId: n
|
|
1336
|
-
})
|
|
1337
|
-
}).catch((a) => ({
|
|
1147
|
+
}), this.installSessionUserFilesApi(u);
|
|
1148
|
+
let c = null, a;
|
|
1149
|
+
c = await this.executeRuntimeHelper(), a = await _t(o).catch((h) => ({
|
|
1338
1150
|
ok: !1,
|
|
1339
1151
|
exception: {
|
|
1340
|
-
message:
|
|
1152
|
+
message: h instanceof Error ? h.message : String(h)
|
|
1341
1153
|
}
|
|
1342
1154
|
})), this.activeBrowserToolCalls.delete(n), this.send({
|
|
1343
1155
|
type: "tool.result",
|
|
@@ -1345,58 +1157,58 @@ class Yt {
|
|
|
1345
1157
|
callId: n,
|
|
1346
1158
|
toolName: r,
|
|
1347
1159
|
summary: o.summary,
|
|
1348
|
-
rawInput:
|
|
1349
|
-
rawOutput:
|
|
1350
|
-
}),
|
|
1160
|
+
rawInput: A(o),
|
|
1161
|
+
rawOutput: A(As(a, c))
|
|
1162
|
+
}), en(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1351
1163
|
}
|
|
1352
1164
|
startPageLifecycleRecovery() {
|
|
1353
1165
|
if (this.pageLifecycleCleanup)
|
|
1354
1166
|
return;
|
|
1355
1167
|
const t = () => {
|
|
1356
|
-
|
|
1168
|
+
Yt(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1357
1169
|
};
|
|
1358
1170
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1359
1171
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1360
1172
|
};
|
|
1361
1173
|
}
|
|
1362
1174
|
installSessionUserFilesApi(t) {
|
|
1363
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1175
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Ze(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1364
1176
|
}
|
|
1365
1177
|
cleanupSessionUserFilesApi() {
|
|
1366
|
-
this.sessionUserFilesApiCleanup && (
|
|
1178
|
+
this.sessionUserFilesApiCleanup && (os(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1367
1179
|
}
|
|
1368
1180
|
async executeRuntimeHelper() {
|
|
1369
1181
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1370
1182
|
return null;
|
|
1371
|
-
const t = await
|
|
1183
|
+
const t = await _t({
|
|
1372
1184
|
javascript: this.runtimeHelperJavascript
|
|
1373
1185
|
});
|
|
1374
|
-
return t.ok === !1 ?
|
|
1186
|
+
return t.ok === !1 ? Ss(t) : null;
|
|
1375
1187
|
}
|
|
1376
1188
|
enableNetworkCapture() {
|
|
1377
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1378
|
-
|
|
1189
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = Ge((t) => {
|
|
1190
|
+
Tn(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1379
1191
|
}));
|
|
1380
1192
|
}
|
|
1381
1193
|
enqueueNetworkEvent(t) {
|
|
1382
|
-
this.queuedNetworkEvents.length >=
|
|
1194
|
+
this.queuedNetworkEvents.length >= Be || (this.queuedNetworkEvents.push(In(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1383
1195
|
this.networkBatchTimer = null;
|
|
1384
1196
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1385
1197
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
1386
1198
|
type: "network.batch",
|
|
1387
1199
|
sessionId: this.state.sessionId ?? void 0,
|
|
1388
|
-
page:
|
|
1200
|
+
page: w(),
|
|
1389
1201
|
events: s
|
|
1390
1202
|
});
|
|
1391
|
-
},
|
|
1203
|
+
}, Oe)));
|
|
1392
1204
|
}
|
|
1393
1205
|
scheduleReconnect() {
|
|
1394
1206
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1395
1207
|
return;
|
|
1396
|
-
const t =
|
|
1208
|
+
const t = $e(this.reconnectAttempts);
|
|
1397
1209
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1398
1210
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1399
|
-
|
|
1211
|
+
f("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
1400
1212
|
message: s instanceof Error ? s.message : String(s),
|
|
1401
1213
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1402
1214
|
isThinking: this.state.isThinking
|
|
@@ -1408,9 +1220,9 @@ class Yt {
|
|
|
1408
1220
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
1409
1221
|
const t = this.socket;
|
|
1410
1222
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1411
|
-
this.socket === t && (
|
|
1412
|
-
},
|
|
1413
|
-
},
|
|
1223
|
+
this.socket === t && (f("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1224
|
+
}, _e));
|
|
1225
|
+
}, Re);
|
|
1414
1226
|
}
|
|
1415
1227
|
stopHeartbeat() {
|
|
1416
1228
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1436,92 +1248,92 @@ class Yt {
|
|
|
1436
1248
|
...t,
|
|
1437
1249
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1438
1250
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1439
|
-
},
|
|
1251
|
+
}, Qs(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
1440
1252
|
}
|
|
1441
1253
|
emit(t, s) {
|
|
1442
1254
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1443
1255
|
}
|
|
1444
1256
|
}
|
|
1445
|
-
const
|
|
1446
|
-
function
|
|
1447
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1257
|
+
const Z = /* @__PURE__ */ new WeakMap();
|
|
1258
|
+
function Ge(e) {
|
|
1259
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Xe();
|
|
1448
1260
|
return t.subscribers.add(e), () => {
|
|
1449
1261
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1450
1262
|
};
|
|
1451
1263
|
}
|
|
1452
|
-
function
|
|
1453
|
-
const e = /* @__PURE__ */ new Set(), t = (
|
|
1264
|
+
function Xe() {
|
|
1265
|
+
const e = /* @__PURE__ */ new Set(), t = (g) => {
|
|
1454
1266
|
e.forEach((p) => {
|
|
1455
1267
|
try {
|
|
1456
|
-
p(
|
|
1268
|
+
p(g);
|
|
1457
1269
|
} catch {
|
|
1458
1270
|
}
|
|
1459
1271
|
});
|
|
1460
1272
|
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p, d) {
|
|
1461
|
-
const
|
|
1462
|
-
let
|
|
1273
|
+
const m = Date.now();
|
|
1274
|
+
let I;
|
|
1463
1275
|
try {
|
|
1464
|
-
|
|
1465
|
-
} catch (
|
|
1466
|
-
throw
|
|
1276
|
+
I = s.call(this, p, d);
|
|
1277
|
+
} catch (y) {
|
|
1278
|
+
throw y;
|
|
1467
1279
|
}
|
|
1468
1280
|
try {
|
|
1469
|
-
const
|
|
1470
|
-
if (!
|
|
1471
|
-
const
|
|
1472
|
-
requestId:
|
|
1473
|
-
url:
|
|
1474
|
-
method: (d?.method ??
|
|
1475
|
-
requestHeaders:
|
|
1476
|
-
requestBody:
|
|
1281
|
+
const y = p instanceof Request ? p : null, O = fn(p, y), C = te(d?.headers ?? y?.headers);
|
|
1282
|
+
if (!b(O, C, d?.body)) {
|
|
1283
|
+
const K = {
|
|
1284
|
+
requestId: Q("fetch"),
|
|
1285
|
+
url: k(O, Y),
|
|
1286
|
+
method: (d?.method ?? y?.method ?? "GET").toUpperCase(),
|
|
1287
|
+
requestHeaders: C,
|
|
1288
|
+
requestBody: vt(d?.body),
|
|
1477
1289
|
resourceType: "fetch",
|
|
1478
|
-
startedAt: new Date(
|
|
1290
|
+
startedAt: new Date(m).toISOString()
|
|
1479
1291
|
};
|
|
1480
|
-
|
|
1481
|
-
(
|
|
1482
|
-
|
|
1292
|
+
I.then(
|
|
1293
|
+
(_) => {
|
|
1294
|
+
gn(_, K, m, t).catch(() => {
|
|
1483
1295
|
t({
|
|
1484
|
-
...
|
|
1485
|
-
responseStatus:
|
|
1486
|
-
durationMs: Date.now() -
|
|
1296
|
+
...K,
|
|
1297
|
+
responseStatus: _.status,
|
|
1298
|
+
durationMs: Date.now() - m
|
|
1487
1299
|
});
|
|
1488
1300
|
});
|
|
1489
1301
|
},
|
|
1490
|
-
(
|
|
1302
|
+
(_) => {
|
|
1491
1303
|
t({
|
|
1492
|
-
...
|
|
1493
|
-
errorText: _
|
|
1494
|
-
durationMs: Date.now() -
|
|
1304
|
+
...K,
|
|
1305
|
+
errorText: k(_ instanceof Error ? _.message : String(_)),
|
|
1306
|
+
durationMs: Date.now() - m
|
|
1495
1307
|
});
|
|
1496
1308
|
}
|
|
1497
1309
|
);
|
|
1498
1310
|
}
|
|
1499
1311
|
} catch {
|
|
1500
1312
|
}
|
|
1501
|
-
return
|
|
1502
|
-
},
|
|
1503
|
-
const
|
|
1504
|
-
return
|
|
1505
|
-
requestId:
|
|
1313
|
+
return I;
|
|
1314
|
+
}, l = function(p, d, m, I, y) {
|
|
1315
|
+
const O = n.call(this, p, d, m ?? !0, I ?? void 0, y ?? void 0), C = typeof d == "string" ? d : d.toString();
|
|
1316
|
+
return Z.set(this, {
|
|
1317
|
+
requestId: Q("xhr"),
|
|
1506
1318
|
method: String(p ?? "GET").toUpperCase(),
|
|
1507
|
-
url:
|
|
1319
|
+
url: k(C, Y),
|
|
1508
1320
|
requestHeaders: {},
|
|
1509
1321
|
startedAtMs: Date.now(),
|
|
1510
1322
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1511
|
-
excluded:
|
|
1512
|
-
}),
|
|
1323
|
+
excluded: b(C)
|
|
1324
|
+
}), O;
|
|
1513
1325
|
}, u = function(p, d) {
|
|
1514
|
-
const
|
|
1515
|
-
return
|
|
1516
|
-
},
|
|
1326
|
+
const m = r.call(this, p, d), I = Z.get(this);
|
|
1327
|
+
return I && Object.keys(I.requestHeaders).length < ht && (I.requestHeaders[p] = Tt(p, d), I.excluded = I.excluded || b(I.url, I.requestHeaders)), m;
|
|
1328
|
+
}, c = function(p) {
|
|
1517
1329
|
try {
|
|
1518
|
-
const d =
|
|
1519
|
-
d && (d.excluded = d.excluded ||
|
|
1330
|
+
const d = Z.get(this);
|
|
1331
|
+
d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = vt(p), d.excluded || this.addEventListener(
|
|
1520
1332
|
"loadend",
|
|
1521
1333
|
() => {
|
|
1522
1334
|
queueMicrotask(() => {
|
|
1523
1335
|
try {
|
|
1524
|
-
const
|
|
1336
|
+
const m = An(this.getAllResponseHeaders());
|
|
1525
1337
|
t({
|
|
1526
1338
|
requestId: d.requestId,
|
|
1527
1339
|
url: d.url,
|
|
@@ -1530,8 +1342,8 @@ function ns() {
|
|
|
1530
1342
|
requestBody: d.requestBody,
|
|
1531
1343
|
resourceType: "xhr",
|
|
1532
1344
|
responseStatus: this.status,
|
|
1533
|
-
responseHeaders:
|
|
1534
|
-
responseBody:
|
|
1345
|
+
responseHeaders: m,
|
|
1346
|
+
responseBody: yn(this, m),
|
|
1535
1347
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1536
1348
|
startedAt: d.startedAt,
|
|
1537
1349
|
durationMs: Date.now() - d.startedAtMs
|
|
@@ -1552,7 +1364,7 @@ function ns() {
|
|
|
1552
1364
|
} catch {
|
|
1553
1365
|
}
|
|
1554
1366
|
try {
|
|
1555
|
-
XMLHttpRequest.prototype.open =
|
|
1367
|
+
XMLHttpRequest.prototype.open = l;
|
|
1556
1368
|
} catch {
|
|
1557
1369
|
}
|
|
1558
1370
|
try {
|
|
@@ -1560,24 +1372,24 @@ function ns() {
|
|
|
1560
1372
|
} catch {
|
|
1561
1373
|
}
|
|
1562
1374
|
try {
|
|
1563
|
-
XMLHttpRequest.prototype.send =
|
|
1375
|
+
XMLHttpRequest.prototype.send = c;
|
|
1564
1376
|
} catch {
|
|
1565
1377
|
}
|
|
1566
1378
|
let a = null;
|
|
1567
1379
|
if (typeof PerformanceObserver < "u") {
|
|
1568
|
-
a = new PerformanceObserver((
|
|
1569
|
-
for (const p of
|
|
1380
|
+
a = new PerformanceObserver((g) => {
|
|
1381
|
+
for (const p of g.getEntries()) {
|
|
1570
1382
|
const d = p;
|
|
1571
|
-
if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" ||
|
|
1383
|
+
if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || b(d.name))
|
|
1572
1384
|
continue;
|
|
1573
|
-
const
|
|
1385
|
+
const m = performance.timeOrigin + d.startTime;
|
|
1574
1386
|
t({
|
|
1575
|
-
requestId:
|
|
1576
|
-
url:
|
|
1387
|
+
requestId: Q("resource"),
|
|
1388
|
+
url: k(d.name, Y),
|
|
1577
1389
|
method: "GET",
|
|
1578
1390
|
resourceType: "resource",
|
|
1579
1391
|
responseStatus: d.responseStatus,
|
|
1580
|
-
startedAt: new Date(
|
|
1392
|
+
startedAt: new Date(m).toISOString(),
|
|
1581
1393
|
durationMs: d.duration
|
|
1582
1394
|
});
|
|
1583
1395
|
}
|
|
@@ -1597,7 +1409,7 @@ function ns() {
|
|
|
1597
1409
|
} catch {
|
|
1598
1410
|
}
|
|
1599
1411
|
try {
|
|
1600
|
-
XMLHttpRequest.prototype.open ===
|
|
1412
|
+
XMLHttpRequest.prototype.open === l && (XMLHttpRequest.prototype.open = n);
|
|
1601
1413
|
} catch {
|
|
1602
1414
|
}
|
|
1603
1415
|
try {
|
|
@@ -1605,14 +1417,14 @@ function ns() {
|
|
|
1605
1417
|
} catch {
|
|
1606
1418
|
}
|
|
1607
1419
|
try {
|
|
1608
|
-
XMLHttpRequest.prototype.send ===
|
|
1420
|
+
XMLHttpRequest.prototype.send === c && (XMLHttpRequest.prototype.send = i);
|
|
1609
1421
|
} catch {
|
|
1610
1422
|
}
|
|
1611
1423
|
}
|
|
1612
1424
|
};
|
|
1613
1425
|
return window.__plunoProductAgentNetworkCapture = h, h;
|
|
1614
1426
|
}
|
|
1615
|
-
function
|
|
1427
|
+
function f(e, t, s) {
|
|
1616
1428
|
if (typeof window > "u")
|
|
1617
1429
|
return;
|
|
1618
1430
|
const n = window, r = {
|
|
@@ -1623,15 +1435,15 @@ function y(e, t, s) {
|
|
|
1623
1435
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1624
1436
|
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 }));
|
|
1625
1437
|
}
|
|
1626
|
-
function
|
|
1438
|
+
function Rt(e) {
|
|
1627
1439
|
const t = typeof e == "function" ? e() : e;
|
|
1628
1440
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1629
1441
|
}
|
|
1630
|
-
function
|
|
1442
|
+
function Ke(e) {
|
|
1631
1443
|
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";
|
|
1632
1444
|
}
|
|
1633
|
-
const
|
|
1634
|
-
function
|
|
1445
|
+
const Je = 5e3, Ve = 12e4;
|
|
1446
|
+
function Ye(e) {
|
|
1635
1447
|
const t = [];
|
|
1636
1448
|
for (const s of e)
|
|
1637
1449
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1642,118 +1454,118 @@ function as(e) {
|
|
|
1642
1454
|
});
|
|
1643
1455
|
return t;
|
|
1644
1456
|
}
|
|
1645
|
-
function
|
|
1457
|
+
function Ze(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1646
1458
|
const n = [
|
|
1647
|
-
|
|
1648
|
-
|
|
1459
|
+
Qe(e, t, s),
|
|
1460
|
+
ts()
|
|
1649
1461
|
].filter((r) => typeof r == "function");
|
|
1650
1462
|
return () => {
|
|
1651
1463
|
for (const r of n.reverse())
|
|
1652
1464
|
r();
|
|
1653
1465
|
};
|
|
1654
1466
|
}
|
|
1655
|
-
function
|
|
1656
|
-
const n = new Map(e.map((
|
|
1657
|
-
id:
|
|
1658
|
-
name:
|
|
1659
|
-
mimeType:
|
|
1660
|
-
sizeBytes:
|
|
1661
|
-
type:
|
|
1662
|
-
size:
|
|
1663
|
-
}), i = (
|
|
1664
|
-
const a = n.get(
|
|
1467
|
+
function Qe(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1468
|
+
const n = new Map(e.map((c) => [c.id, c])), r = (c) => ({
|
|
1469
|
+
id: c.id,
|
|
1470
|
+
name: c.name,
|
|
1471
|
+
mimeType: c.mimeType,
|
|
1472
|
+
sizeBytes: c.sizeBytes,
|
|
1473
|
+
type: c.mimeType,
|
|
1474
|
+
size: c.sizeBytes
|
|
1475
|
+
}), i = (c) => {
|
|
1476
|
+
const a = n.get(c);
|
|
1665
1477
|
if (!a)
|
|
1666
|
-
throw new Error(`Unknown Pluno user file: ${
|
|
1478
|
+
throw new Error(`Unknown Pluno user file: ${c}`);
|
|
1667
1479
|
return a;
|
|
1668
|
-
}, o = async (
|
|
1669
|
-
const a = i(
|
|
1480
|
+
}, o = async (c) => {
|
|
1481
|
+
const a = i(c), h = t.get(a.id);
|
|
1670
1482
|
if (h)
|
|
1671
1483
|
return h;
|
|
1672
|
-
const
|
|
1673
|
-
if (
|
|
1674
|
-
return
|
|
1675
|
-
const p = await
|
|
1484
|
+
const g = s.get(a.id);
|
|
1485
|
+
if (g)
|
|
1486
|
+
return g;
|
|
1487
|
+
const p = await le(a.id).then((y) => y?.blob ?? null).catch((y) => (f("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
|
|
1676
1488
|
attachmentId: a.id,
|
|
1677
1489
|
name: a.name,
|
|
1678
|
-
message:
|
|
1490
|
+
message: y instanceof Error ? y.message : String(y)
|
|
1679
1491
|
}), null));
|
|
1680
1492
|
if (p)
|
|
1681
1493
|
return s.set(a.id, p), p;
|
|
1682
1494
|
if (!a.fileUrl)
|
|
1683
|
-
throw new Error(`Pluno user file is missing content: ${
|
|
1684
|
-
const d = await fetch(a.fileUrl,
|
|
1495
|
+
throw new Error(`Pluno user file is missing content: ${c}`);
|
|
1496
|
+
const d = await fetch(a.fileUrl, cn(a.fileUrl));
|
|
1685
1497
|
if (!d.ok)
|
|
1686
|
-
throw new Error(`Failed to load Pluno user file: ${
|
|
1687
|
-
const
|
|
1688
|
-
s.set(a.id,
|
|
1689
|
-
const
|
|
1690
|
-
return
|
|
1498
|
+
throw new Error(`Failed to load Pluno user file: ${c}`);
|
|
1499
|
+
const m = await d.blob();
|
|
1500
|
+
s.set(a.id, m);
|
|
1501
|
+
const I = Date.now();
|
|
1502
|
+
return xt({
|
|
1691
1503
|
attachmentId: a.id,
|
|
1692
1504
|
name: a.name,
|
|
1693
1505
|
mimeType: a.mimeType,
|
|
1694
1506
|
sizeBytes: a.sizeBytes,
|
|
1695
|
-
blob:
|
|
1507
|
+
blob: m,
|
|
1696
1508
|
fileUrl: a.fileUrl,
|
|
1697
1509
|
gcsPath: a.gcsPath,
|
|
1698
|
-
createdAt:
|
|
1699
|
-
lastUsedAt:
|
|
1700
|
-
}).catch((
|
|
1701
|
-
|
|
1510
|
+
createdAt: I,
|
|
1511
|
+
lastUsedAt: I
|
|
1512
|
+
}).catch((y) => {
|
|
1513
|
+
f("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
|
|
1702
1514
|
attachmentId: a.id,
|
|
1703
1515
|
name: a.name,
|
|
1704
|
-
message:
|
|
1516
|
+
message: y instanceof Error ? y.message : String(y)
|
|
1705
1517
|
});
|
|
1706
|
-
}),
|
|
1518
|
+
}), m;
|
|
1707
1519
|
};
|
|
1708
|
-
return
|
|
1520
|
+
return Wt(globalThis, "userFiles", {
|
|
1709
1521
|
list: () => e.map(r),
|
|
1710
|
-
get: (
|
|
1711
|
-
const a = n.get(
|
|
1522
|
+
get: (c) => {
|
|
1523
|
+
const a = n.get(c);
|
|
1712
1524
|
return a ? r(a) : null;
|
|
1713
1525
|
},
|
|
1714
|
-
inspectImage: async (
|
|
1715
|
-
const a = i(
|
|
1716
|
-
if (!
|
|
1717
|
-
throw new Error(`Pluno user file is not an image: ${
|
|
1718
|
-
const p = h.type ===
|
|
1719
|
-
return
|
|
1526
|
+
inspectImage: async (c) => {
|
|
1527
|
+
const a = i(c), h = await o(c), g = a.mimeType.startsWith("image/") ? a.mimeType : h.type || a.mimeType;
|
|
1528
|
+
if (!g.startsWith("image/"))
|
|
1529
|
+
throw new Error(`Pluno user file is not an image: ${c}`);
|
|
1530
|
+
const p = h.type === g ? h : new Blob([h], { type: g });
|
|
1531
|
+
return as(g, p.size) > He ? {
|
|
1720
1532
|
type: "pluno.userFiles.inspectImage",
|
|
1721
1533
|
id: a.id,
|
|
1722
1534
|
name: a.name,
|
|
1723
|
-
mimeType:
|
|
1535
|
+
mimeType: g,
|
|
1724
1536
|
sizeBytes: a.sizeBytes,
|
|
1725
1537
|
imageAttached: !1,
|
|
1726
|
-
imageAttachmentError:
|
|
1538
|
+
imageAttachmentError: pt
|
|
1727
1539
|
} : {
|
|
1728
1540
|
type: "pluno.userFiles.inspectImage",
|
|
1729
1541
|
id: a.id,
|
|
1730
1542
|
name: a.name,
|
|
1731
|
-
mimeType:
|
|
1543
|
+
mimeType: g,
|
|
1732
1544
|
sizeBytes: a.sizeBytes,
|
|
1733
1545
|
imageAttached: !0,
|
|
1734
|
-
dataUrl: await
|
|
1546
|
+
dataUrl: await rt(p)
|
|
1735
1547
|
};
|
|
1736
1548
|
},
|
|
1737
|
-
getDataUrl: async (
|
|
1549
|
+
getDataUrl: async (c) => (i(c), await rt(await o(c))),
|
|
1738
1550
|
getBlob: o,
|
|
1739
|
-
getArrayBuffer: async (
|
|
1740
|
-
getFile: async (
|
|
1741
|
-
const a = i(
|
|
1742
|
-
return new File([await o(
|
|
1551
|
+
getArrayBuffer: async (c) => await (await o(c)).arrayBuffer(),
|
|
1552
|
+
getFile: async (c) => {
|
|
1553
|
+
const a = i(c);
|
|
1554
|
+
return new File([await o(c)], a.name, { type: a.mimeType });
|
|
1743
1555
|
}
|
|
1744
1556
|
});
|
|
1745
1557
|
}
|
|
1746
|
-
function
|
|
1747
|
-
return
|
|
1748
|
-
inspectImage: async (t, s) => await
|
|
1558
|
+
function ts() {
|
|
1559
|
+
return Wt(globalThis, "pageImages", {
|
|
1560
|
+
inspectImage: async (t, s) => await es(t, s)
|
|
1749
1561
|
});
|
|
1750
1562
|
}
|
|
1751
|
-
async function
|
|
1752
|
-
const s =
|
|
1563
|
+
async function es(e, t = {}) {
|
|
1564
|
+
const s = is(t.name), n = await ss(e);
|
|
1753
1565
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1754
1566
|
type: "pluno.pageImages.inspectImage",
|
|
1755
1567
|
imageAttached: !1,
|
|
1756
|
-
imageAttachmentError:
|
|
1568
|
+
imageAttachmentError: pt
|
|
1757
1569
|
} : {
|
|
1758
1570
|
type: "pluno.pageImages.inspectImage",
|
|
1759
1571
|
imageAttached: !0,
|
|
@@ -1767,26 +1579,26 @@ async function ds(e, t = {}) {
|
|
|
1767
1579
|
imageAttachmentError: n.error
|
|
1768
1580
|
};
|
|
1769
1581
|
}
|
|
1770
|
-
async function
|
|
1771
|
-
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:
|
|
1582
|
+
async function ss(e) {
|
|
1583
|
+
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 } : {
|
|
1772
1584
|
ok: !0,
|
|
1773
1585
|
mimeType: e.type,
|
|
1774
1586
|
sizeBytes: e.size,
|
|
1775
|
-
dataUrl: await
|
|
1776
|
-
} : { 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." } :
|
|
1587
|
+
dataUrl: await rt(e)
|
|
1588
|
+
} : { 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." } : ns(e);
|
|
1777
1589
|
}
|
|
1778
|
-
function
|
|
1590
|
+
function ns(e) {
|
|
1779
1591
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1780
1592
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1781
|
-
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((
|
|
1593
|
+
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((l) => l.trim()).filter(Boolean), r = n[0] ?? "";
|
|
1782
1594
|
if (!r.startsWith("image/"))
|
|
1783
1595
|
return { ok: !1, error: "Page image MIME type must be image/*." };
|
|
1784
|
-
if (!n.slice(1).some((
|
|
1596
|
+
if (!n.slice(1).some((l) => l.toLowerCase() === "base64"))
|
|
1785
1597
|
return { ok: !1, error: "Page image data URL must be base64 encoded." };
|
|
1786
1598
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1787
1599
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1788
1600
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1789
|
-
const o =
|
|
1601
|
+
const o = rs(i);
|
|
1790
1602
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1791
1603
|
ok: !0,
|
|
1792
1604
|
mimeType: r,
|
|
@@ -1794,22 +1606,22 @@ function ps(e) {
|
|
|
1794
1606
|
dataUrl: `data:${r};base64,${i}`
|
|
1795
1607
|
};
|
|
1796
1608
|
}
|
|
1797
|
-
function
|
|
1609
|
+
function rs(e) {
|
|
1798
1610
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1799
1611
|
return null;
|
|
1800
1612
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1801
1613
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1802
1614
|
}
|
|
1803
|
-
function
|
|
1615
|
+
function is(e) {
|
|
1804
1616
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1805
1617
|
}
|
|
1806
|
-
function
|
|
1618
|
+
function os(e) {
|
|
1807
1619
|
try {
|
|
1808
1620
|
e();
|
|
1809
1621
|
} catch {
|
|
1810
1622
|
}
|
|
1811
1623
|
}
|
|
1812
|
-
function
|
|
1624
|
+
function rt(e) {
|
|
1813
1625
|
return new Promise((t, s) => {
|
|
1814
1626
|
const n = new FileReader();
|
|
1815
1627
|
n.onload = () => {
|
|
@@ -1821,32 +1633,32 @@ function ct(e) {
|
|
|
1821
1633
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1822
1634
|
});
|
|
1823
1635
|
}
|
|
1824
|
-
function
|
|
1636
|
+
function as(e, t) {
|
|
1825
1637
|
return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
|
|
1826
1638
|
}
|
|
1827
|
-
async function
|
|
1639
|
+
async function _t(e) {
|
|
1828
1640
|
const t = Object.getPrototypeOf(async function() {
|
|
1829
|
-
}).constructor, s = e.timeoutMs ??
|
|
1641
|
+
}).constructor, s = e.timeoutMs ?? Je, n = Date.now(), r = [];
|
|
1830
1642
|
let i;
|
|
1831
1643
|
const o = {
|
|
1832
1644
|
log: console.log,
|
|
1833
1645
|
info: console.info,
|
|
1834
1646
|
warn: console.warn,
|
|
1835
1647
|
error: console.error
|
|
1836
|
-
},
|
|
1837
|
-
r.push({ level: u, args:
|
|
1648
|
+
}, l = (u) => (...c) => {
|
|
1649
|
+
r.push({ level: u, args: c }), o[u](...c);
|
|
1838
1650
|
};
|
|
1839
|
-
console.log =
|
|
1651
|
+
console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error");
|
|
1840
1652
|
try {
|
|
1841
|
-
const u = /* @__PURE__ */ Symbol("execute_code_timeout"),
|
|
1653
|
+
const u = /* @__PURE__ */ Symbol("execute_code_timeout"), c = await Promise.race([
|
|
1842
1654
|
new t(e.javascript)(),
|
|
1843
1655
|
new Promise((a) => {
|
|
1844
1656
|
i = window.setTimeout(() => a(u), s);
|
|
1845
1657
|
})
|
|
1846
1658
|
]);
|
|
1847
|
-
return
|
|
1659
|
+
return c === u ? cs(s) : {
|
|
1848
1660
|
ok: !0,
|
|
1849
|
-
result:
|
|
1661
|
+
result: c,
|
|
1850
1662
|
console: r,
|
|
1851
1663
|
metadata: {
|
|
1852
1664
|
durationMs: Date.now() - n,
|
|
@@ -1873,7 +1685,7 @@ async function Ut(e) {
|
|
|
1873
1685
|
i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
|
|
1874
1686
|
}
|
|
1875
1687
|
}
|
|
1876
|
-
function
|
|
1688
|
+
function cs(e) {
|
|
1877
1689
|
return {
|
|
1878
1690
|
ok: !1,
|
|
1879
1691
|
exception: {
|
|
@@ -1887,18 +1699,18 @@ function Is(e) {
|
|
|
1887
1699
|
}
|
|
1888
1700
|
};
|
|
1889
1701
|
}
|
|
1890
|
-
function
|
|
1702
|
+
function ls(e) {
|
|
1891
1703
|
return e.replace(/\/+$/, "");
|
|
1892
1704
|
}
|
|
1893
|
-
function
|
|
1705
|
+
function us(e, t = location.origin) {
|
|
1894
1706
|
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;
|
|
1895
1707
|
}
|
|
1896
|
-
function
|
|
1708
|
+
function ds(e) {
|
|
1897
1709
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1898
1710
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1899
1711
|
}
|
|
1900
|
-
function
|
|
1901
|
-
const e =
|
|
1712
|
+
function w() {
|
|
1713
|
+
const e = Gt();
|
|
1902
1714
|
return {
|
|
1903
1715
|
url: location.href,
|
|
1904
1716
|
title: document.title,
|
|
@@ -1906,21 +1718,21 @@ function S() {
|
|
|
1906
1718
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1907
1719
|
};
|
|
1908
1720
|
}
|
|
1909
|
-
function
|
|
1721
|
+
function hs() {
|
|
1910
1722
|
return {
|
|
1911
1723
|
pageUrl: location.href,
|
|
1912
1724
|
pageTitle: document.title,
|
|
1913
|
-
htmlContent:
|
|
1725
|
+
htmlContent: ms()
|
|
1914
1726
|
};
|
|
1915
1727
|
}
|
|
1916
|
-
function
|
|
1917
|
-
return
|
|
1918
|
-
|
|
1728
|
+
function ps(e) {
|
|
1729
|
+
return F.add(e), v || (v = fs()), () => {
|
|
1730
|
+
F.delete(e), F.size === 0 && (v?.(), v = null);
|
|
1919
1731
|
};
|
|
1920
1732
|
}
|
|
1921
|
-
function
|
|
1733
|
+
function fs() {
|
|
1922
1734
|
const e = () => {
|
|
1923
|
-
for (const i of Array.from(
|
|
1735
|
+
for (const i of Array.from(F))
|
|
1924
1736
|
i();
|
|
1925
1737
|
}, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
1926
1738
|
const o = t(...i);
|
|
@@ -1933,10 +1745,10 @@ function Es() {
|
|
|
1933
1745
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
1934
1746
|
};
|
|
1935
1747
|
}
|
|
1936
|
-
function
|
|
1937
|
-
return
|
|
1748
|
+
function gs() {
|
|
1749
|
+
return Gt()?.surface === "browser_extension_sdk_preview";
|
|
1938
1750
|
}
|
|
1939
|
-
function
|
|
1751
|
+
function ms() {
|
|
1940
1752
|
const e = document.body?.cloneNode(!0);
|
|
1941
1753
|
return e instanceof HTMLElement ? (e.querySelectorAll(
|
|
1942
1754
|
[
|
|
@@ -1960,9 +1772,9 @@ function Rs() {
|
|
|
1960
1772
|
s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
|
|
1961
1773
|
}), 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) ?? "") : "";
|
|
1962
1774
|
}
|
|
1963
|
-
function
|
|
1964
|
-
const e = document.querySelector(
|
|
1965
|
-
if (!(e ?? document.querySelector(
|
|
1775
|
+
function Gt() {
|
|
1776
|
+
const e = document.querySelector(wt);
|
|
1777
|
+
if (!(e ?? document.querySelector(st)))
|
|
1966
1778
|
return;
|
|
1967
1779
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
1968
1780
|
return {
|
|
@@ -1971,28 +1783,28 @@ function Vt() {
|
|
|
1971
1783
|
selectors: [
|
|
1972
1784
|
{
|
|
1973
1785
|
name: "widget_host",
|
|
1974
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
1786
|
+
selector: s === "browser_extension_sdk_preview" ? wt : st,
|
|
1975
1787
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
1976
1788
|
},
|
|
1977
1789
|
{
|
|
1978
1790
|
name: "widget_root",
|
|
1979
|
-
selector:
|
|
1791
|
+
selector: we,
|
|
1980
1792
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
1981
1793
|
},
|
|
1982
1794
|
{
|
|
1983
1795
|
name: "widget_panel",
|
|
1984
|
-
selector:
|
|
1796
|
+
selector: Ae,
|
|
1985
1797
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
1986
1798
|
},
|
|
1987
1799
|
{
|
|
1988
1800
|
name: "widget_timeline",
|
|
1989
|
-
selector:
|
|
1801
|
+
selector: Se,
|
|
1990
1802
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
1991
1803
|
}
|
|
1992
1804
|
]
|
|
1993
1805
|
};
|
|
1994
1806
|
}
|
|
1995
|
-
function
|
|
1807
|
+
function ys(e) {
|
|
1996
1808
|
try {
|
|
1997
1809
|
const t = JSON.parse(e);
|
|
1998
1810
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2000,33 +1812,33 @@ function Cs(e) {
|
|
|
2000
1812
|
return { type: "error", message: "Invalid server event" };
|
|
2001
1813
|
}
|
|
2002
1814
|
}
|
|
2003
|
-
function
|
|
1815
|
+
function bt(e, t) {
|
|
2004
1816
|
if (!e || typeof e != "object")
|
|
2005
1817
|
return [];
|
|
2006
1818
|
const s = e[t];
|
|
2007
1819
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2008
1820
|
}
|
|
2009
|
-
function
|
|
1821
|
+
function Is(e) {
|
|
2010
1822
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2011
1823
|
}
|
|
2012
|
-
function
|
|
1824
|
+
function Ts(e) {
|
|
2013
1825
|
if (!e || typeof e != "object")
|
|
2014
1826
|
return null;
|
|
2015
|
-
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,
|
|
2016
|
-
return !r && !i && !o &&
|
|
1827
|
+
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, l = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
1828
|
+
return !r && !i && !o && l === null ? null : {
|
|
2017
1829
|
...r ? { accentColor: r } : {},
|
|
2018
1830
|
...i ? { colorScheme: i } : {},
|
|
2019
1831
|
...o ? { fontFamily: o } : {},
|
|
2020
|
-
...
|
|
1832
|
+
...l !== null ? { scribbleStyle: l } : {}
|
|
2021
1833
|
};
|
|
2022
1834
|
}
|
|
2023
|
-
function
|
|
1835
|
+
function ws(e) {
|
|
2024
1836
|
if (!e || typeof e != "object")
|
|
2025
1837
|
return null;
|
|
2026
1838
|
const t = e.javascript;
|
|
2027
1839
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2028
1840
|
}
|
|
2029
|
-
function
|
|
1841
|
+
function As(e, t) {
|
|
2030
1842
|
return t ? e && typeof e == "object" ? {
|
|
2031
1843
|
...e,
|
|
2032
1844
|
helperError: t
|
|
@@ -2036,23 +1848,23 @@ function Ps(e, t) {
|
|
|
2036
1848
|
helperError: t
|
|
2037
1849
|
} : e;
|
|
2038
1850
|
}
|
|
2039
|
-
function
|
|
1851
|
+
function Ss(e) {
|
|
2040
1852
|
if (!e || typeof e != "object")
|
|
2041
1853
|
return e;
|
|
2042
1854
|
const t = e;
|
|
2043
1855
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2044
1856
|
}
|
|
2045
|
-
function
|
|
1857
|
+
function ks() {
|
|
2046
1858
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2047
1859
|
if (t)
|
|
2048
1860
|
return t;
|
|
2049
1861
|
const s = crypto.randomUUID();
|
|
2050
1862
|
return window.localStorage.setItem(e, s), s;
|
|
2051
1863
|
}
|
|
2052
|
-
function
|
|
1864
|
+
function q() {
|
|
2053
1865
|
return crypto.randomUUID();
|
|
2054
1866
|
}
|
|
2055
|
-
function
|
|
1867
|
+
function Es(e) {
|
|
2056
1868
|
if (!e || typeof e != "object")
|
|
2057
1869
|
return null;
|
|
2058
1870
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2063,23 +1875,23 @@ function Os(e) {
|
|
|
2063
1875
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2064
1876
|
} : null;
|
|
2065
1877
|
}
|
|
2066
|
-
function
|
|
2067
|
-
return Array.isArray(e) ?
|
|
2068
|
-
|
|
2069
|
-
e.map((s) =>
|
|
1878
|
+
function Rs(e, t) {
|
|
1879
|
+
return Array.isArray(e) ? at(
|
|
1880
|
+
ct(
|
|
1881
|
+
e.map((s) => Xt(s, t)).filter((s) => s !== null)
|
|
2070
1882
|
)
|
|
2071
1883
|
) : [];
|
|
2072
1884
|
}
|
|
2073
|
-
function
|
|
1885
|
+
function _s(e) {
|
|
2074
1886
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2075
1887
|
if (!t || typeof t != "object")
|
|
2076
1888
|
return [];
|
|
2077
|
-
const s = t, n =
|
|
1889
|
+
const s = t, n = T(s, "id"), r = T(s, "createdAt"), i = T(s, "updatedAt"), o = T(s, "lastActiveAt");
|
|
2078
1890
|
return !n || !r || !i || !o ? [] : [
|
|
2079
1891
|
{
|
|
2080
1892
|
id: n,
|
|
2081
|
-
title:
|
|
2082
|
-
firstUserMessage:
|
|
1893
|
+
title: T(s, "title"),
|
|
1894
|
+
firstUserMessage: T(s, "firstUserMessage"),
|
|
2083
1895
|
currentPage: s.currentPage ?? null,
|
|
2084
1896
|
createdAt: r,
|
|
2085
1897
|
updatedAt: i,
|
|
@@ -2089,7 +1901,7 @@ function Ls(e) {
|
|
|
2089
1901
|
];
|
|
2090
1902
|
}) : [];
|
|
2091
1903
|
}
|
|
2092
|
-
function
|
|
1904
|
+
function Xt(e, t) {
|
|
2093
1905
|
if (!e || typeof e != "object")
|
|
2094
1906
|
return null;
|
|
2095
1907
|
const s = e, n = s.data;
|
|
@@ -2105,11 +1917,11 @@ function Zt(e, t) {
|
|
|
2105
1917
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2106
1918
|
role: i,
|
|
2107
1919
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2108
|
-
content:
|
|
1920
|
+
content: Ds(r.content),
|
|
2109
1921
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2110
|
-
respondsToUserMessageId:
|
|
2111
|
-
...
|
|
2112
|
-
attachments:
|
|
1922
|
+
respondsToUserMessageId: R(r) ?? void 0,
|
|
1923
|
+
...S(r) ? { runId: S(r) } : {},
|
|
1924
|
+
attachments: Zt(r.attachments, t)
|
|
2113
1925
|
};
|
|
2114
1926
|
return typeof r.clientMessageId == "string" && Object.defineProperty(o, "clientMessageId", {
|
|
2115
1927
|
value: r.clientMessageId,
|
|
@@ -2117,49 +1929,49 @@ function Zt(e, t) {
|
|
|
2117
1929
|
}), o;
|
|
2118
1930
|
}
|
|
2119
1931
|
if (r.type === "function_call_output") {
|
|
2120
|
-
const i =
|
|
1932
|
+
const i = Ms(r.output);
|
|
2121
1933
|
return i ? {
|
|
2122
1934
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2123
1935
|
role: "tool",
|
|
2124
1936
|
content: `Connect ${i.appName} to continue`,
|
|
2125
1937
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2126
|
-
respondsToUserMessageId:
|
|
2127
|
-
...
|
|
1938
|
+
respondsToUserMessageId: R(r) ?? void 0,
|
|
1939
|
+
...S(r) ? { runId: S(r) } : {},
|
|
2128
1940
|
dataType: "function_call_output",
|
|
2129
1941
|
toolName: "authenticate_pipedream_app",
|
|
2130
|
-
callId:
|
|
1942
|
+
callId: Mt(r) ?? void 0,
|
|
2131
1943
|
integrationAuthRequest: i
|
|
2132
1944
|
} : null;
|
|
2133
1945
|
}
|
|
2134
1946
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2135
1947
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2136
1948
|
role: "tool",
|
|
2137
|
-
content: r.type === "mcp_call" ?
|
|
1949
|
+
content: r.type === "mcp_call" ? bs(r) : Ps(r),
|
|
2138
1950
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2139
|
-
respondsToUserMessageId:
|
|
2140
|
-
...
|
|
1951
|
+
respondsToUserMessageId: R(r) ?? void 0,
|
|
1952
|
+
...S(r) ? { runId: S(r) } : {},
|
|
2141
1953
|
dataType: String(r.type),
|
|
2142
1954
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2143
|
-
callId:
|
|
1955
|
+
callId: Mt(r) ?? void 0,
|
|
2144
1956
|
loading: r.localExecutionStatus === "running"
|
|
2145
1957
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2146
1958
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2147
1959
|
role: "system",
|
|
2148
|
-
content:
|
|
1960
|
+
content: Cs(r),
|
|
2149
1961
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2150
|
-
respondsToUserMessageId:
|
|
2151
|
-
...
|
|
1962
|
+
respondsToUserMessageId: R(r) ?? void 0,
|
|
1963
|
+
...S(r) ? { runId: S(r) } : {},
|
|
2152
1964
|
dataType: String(r.type),
|
|
2153
1965
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
2154
1966
|
...typeof r.retryable == "boolean" ? { retryable: r.retryable } : {},
|
|
2155
1967
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2156
1968
|
} : null;
|
|
2157
1969
|
}
|
|
2158
|
-
function
|
|
1970
|
+
function bs(e) {
|
|
2159
1971
|
const s = (typeof e.server_label == "string" ? e.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
2160
1972
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2161
1973
|
}
|
|
2162
|
-
function
|
|
1974
|
+
function Ms(e) {
|
|
2163
1975
|
if (typeof e != "string")
|
|
2164
1976
|
return null;
|
|
2165
1977
|
try {
|
|
@@ -2176,10 +1988,10 @@ function qs(e) {
|
|
|
2176
1988
|
return null;
|
|
2177
1989
|
}
|
|
2178
1990
|
}
|
|
2179
|
-
function
|
|
1991
|
+
function Cs(e) {
|
|
2180
1992
|
return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : 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." : "Pluno run status changed.";
|
|
2181
1993
|
}
|
|
2182
|
-
function
|
|
1994
|
+
function Ps(e) {
|
|
2183
1995
|
if (e.type === "web_search_call") {
|
|
2184
1996
|
const t = e.action;
|
|
2185
1997
|
if (t && typeof t == "object") {
|
|
@@ -2191,30 +2003,30 @@ function Fs(e) {
|
|
|
2191
2003
|
}
|
|
2192
2004
|
return "🔎 Searching the web";
|
|
2193
2005
|
}
|
|
2194
|
-
return
|
|
2006
|
+
return Us(e);
|
|
2195
2007
|
}
|
|
2196
|
-
function
|
|
2008
|
+
function Us(e) {
|
|
2197
2009
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2198
|
-
return
|
|
2010
|
+
return M(e.summary);
|
|
2199
2011
|
if (typeof e.arguments == "string")
|
|
2200
2012
|
try {
|
|
2201
2013
|
const t = JSON.parse(e.arguments);
|
|
2202
2014
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
2203
|
-
return
|
|
2015
|
+
return M(t.summary);
|
|
2204
2016
|
} catch {
|
|
2205
|
-
return typeof e.name == "string" && e.name.trim().length > 0 ?
|
|
2017
|
+
return typeof e.name == "string" && e.name.trim().length > 0 ? M(e.name) : "🛠️ Run tool";
|
|
2206
2018
|
}
|
|
2207
|
-
return typeof e.name == "string" && e.name.trim().length > 0 ?
|
|
2019
|
+
return typeof e.name == "string" && e.name.trim().length > 0 ? M(e.name) : "🛠️ Run tool";
|
|
2208
2020
|
}
|
|
2209
|
-
function
|
|
2021
|
+
function M(e) {
|
|
2210
2022
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2211
2023
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2212
2024
|
}
|
|
2213
|
-
function
|
|
2025
|
+
function Mt(e) {
|
|
2214
2026
|
const t = e.callId ?? e.call_id;
|
|
2215
2027
|
return typeof t == "string" && t ? t : null;
|
|
2216
2028
|
}
|
|
2217
|
-
function
|
|
2029
|
+
function Ds(e) {
|
|
2218
2030
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2219
2031
|
if (!t || typeof t != "object")
|
|
2220
2032
|
return "";
|
|
@@ -2222,24 +2034,24 @@ function Ws(e) {
|
|
|
2222
2034
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2223
2035
|
}).filter(Boolean).join("") : "";
|
|
2224
2036
|
}
|
|
2225
|
-
function
|
|
2226
|
-
const s =
|
|
2227
|
-
|
|
2037
|
+
function Ct(e, t) {
|
|
2038
|
+
const s = Kt(e, t), n = Os(
|
|
2039
|
+
qs(e, t),
|
|
2228
2040
|
s
|
|
2229
2041
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2230
2042
|
if (r === -1)
|
|
2231
|
-
return
|
|
2232
|
-
|
|
2043
|
+
return at(
|
|
2044
|
+
ct([...n, s])
|
|
2233
2045
|
);
|
|
2234
2046
|
const i = [...n];
|
|
2235
|
-
return i[r] = s,
|
|
2047
|
+
return i[r] = s, at(ct(i));
|
|
2236
2048
|
}
|
|
2237
|
-
function
|
|
2049
|
+
function Ns(e) {
|
|
2238
2050
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
2239
2051
|
return !t || !s ? null : {
|
|
2240
2052
|
id: `transient-activity:${t}`,
|
|
2241
2053
|
role: "tool",
|
|
2242
|
-
content:
|
|
2054
|
+
content: M(
|
|
2243
2055
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
2244
2056
|
),
|
|
2245
2057
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2251,7 +2063,7 @@ function js(e) {
|
|
|
2251
2063
|
loading: !0
|
|
2252
2064
|
};
|
|
2253
2065
|
}
|
|
2254
|
-
function
|
|
2066
|
+
function Os(e, t) {
|
|
2255
2067
|
if (t.id.startsWith("transient-activity:"))
|
|
2256
2068
|
return e;
|
|
2257
2069
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2259,52 +2071,52 @@ function $s(e, t) {
|
|
|
2259
2071
|
(n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId === t.runId && n.respondsToUserMessageId === t.respondsToUserMessageId)
|
|
2260
2072
|
);
|
|
2261
2073
|
}
|
|
2262
|
-
function
|
|
2074
|
+
function Bs(e, t) {
|
|
2263
2075
|
const s = t.map(
|
|
2264
|
-
(n) =>
|
|
2076
|
+
(n) => Kt(e, n)
|
|
2265
2077
|
);
|
|
2266
|
-
return t.length > 0 ? s : e.filter(
|
|
2078
|
+
return t.length > 0 ? s : e.filter(ft);
|
|
2267
2079
|
}
|
|
2268
|
-
function
|
|
2080
|
+
function Kt(e, t) {
|
|
2269
2081
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2270
2082
|
return t;
|
|
2271
2083
|
const s = e.find(
|
|
2272
|
-
(r) => r.role === "user" && (r.id === t.id ||
|
|
2084
|
+
(r) => r.role === "user" && (r.id === t.id || ft(r) && Jt(r, t))
|
|
2273
2085
|
);
|
|
2274
2086
|
if (!s?.attachments?.length)
|
|
2275
2087
|
return t;
|
|
2276
2088
|
const n = t.attachments.map((r) => {
|
|
2277
|
-
const i =
|
|
2278
|
-
return i ?
|
|
2089
|
+
const i = Ls(s.attachments ?? [], r);
|
|
2090
|
+
return i ? vs(r, i) : r;
|
|
2279
2091
|
});
|
|
2280
2092
|
return { ...t, attachments: n };
|
|
2281
2093
|
}
|
|
2282
|
-
function
|
|
2094
|
+
function Ls(e, t) {
|
|
2283
2095
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2284
2096
|
}
|
|
2285
|
-
function
|
|
2097
|
+
function vs(e, t) {
|
|
2286
2098
|
const { previewUrl: s } = t;
|
|
2287
2099
|
return s ? { ...e, previewUrl: s } : e;
|
|
2288
2100
|
}
|
|
2289
|
-
function
|
|
2101
|
+
function qs(e, t) {
|
|
2290
2102
|
if (t.role !== "user")
|
|
2291
2103
|
return e;
|
|
2292
2104
|
const s = e.findIndex(
|
|
2293
|
-
(r) =>
|
|
2105
|
+
(r) => ft(r) && Jt(r, t)
|
|
2294
2106
|
);
|
|
2295
2107
|
if (s === -1)
|
|
2296
2108
|
return e;
|
|
2297
2109
|
const n = [...e];
|
|
2298
2110
|
return n.splice(s, 1), n;
|
|
2299
2111
|
}
|
|
2300
|
-
function
|
|
2301
|
-
const s =
|
|
2112
|
+
function Jt(e, t) {
|
|
2113
|
+
const s = Pt(e), n = Pt(t);
|
|
2302
2114
|
return s && n ? s === n : e.content === t.content;
|
|
2303
2115
|
}
|
|
2304
|
-
function
|
|
2116
|
+
function ft(e) {
|
|
2305
2117
|
return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
|
|
2306
2118
|
}
|
|
2307
|
-
function
|
|
2119
|
+
function Pt(e) {
|
|
2308
2120
|
const t = e.clientMessageId;
|
|
2309
2121
|
if (t)
|
|
2310
2122
|
return t;
|
|
@@ -2313,13 +2125,13 @@ function Ot(e) {
|
|
|
2313
2125
|
);
|
|
2314
2126
|
return n ? e.id.slice(n.length) : null;
|
|
2315
2127
|
}
|
|
2316
|
-
function
|
|
2317
|
-
const t =
|
|
2128
|
+
function Ut(e) {
|
|
2129
|
+
const t = Vt(e);
|
|
2318
2130
|
if (t === null)
|
|
2319
2131
|
return !1;
|
|
2320
2132
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
2321
2133
|
const n = e[s];
|
|
2322
|
-
if (
|
|
2134
|
+
if (N(n))
|
|
2323
2135
|
return !0;
|
|
2324
2136
|
if (n.role === "system") {
|
|
2325
2137
|
if (n.dataType === "run_error")
|
|
@@ -2330,20 +2142,20 @@ function vt(e) {
|
|
|
2330
2142
|
}
|
|
2331
2143
|
return !1;
|
|
2332
2144
|
}
|
|
2333
|
-
function
|
|
2334
|
-
const t =
|
|
2335
|
-
return t === null ? e.some(
|
|
2145
|
+
function xs(e) {
|
|
2146
|
+
const t = Vt(e);
|
|
2147
|
+
return t === null ? e.some(N) : e.slice(t + 1).some(N);
|
|
2336
2148
|
}
|
|
2337
|
-
function
|
|
2149
|
+
function Vt(e) {
|
|
2338
2150
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2339
2151
|
if (e[t].role === "user")
|
|
2340
2152
|
return t;
|
|
2341
2153
|
return null;
|
|
2342
2154
|
}
|
|
2343
|
-
function
|
|
2344
|
-
return
|
|
2155
|
+
function Fs(e) {
|
|
2156
|
+
return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2345
2157
|
}
|
|
2346
|
-
function
|
|
2158
|
+
function gt(e) {
|
|
2347
2159
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
2348
2160
|
const s = e[t];
|
|
2349
2161
|
if (!s || typeof s != "object")
|
|
@@ -2357,30 +2169,30 @@ function Tt(e) {
|
|
|
2357
2169
|
}
|
|
2358
2170
|
return null;
|
|
2359
2171
|
}
|
|
2360
|
-
function
|
|
2172
|
+
function D(e) {
|
|
2361
2173
|
if (!e || typeof e != "object")
|
|
2362
2174
|
return null;
|
|
2363
2175
|
const t = e.data;
|
|
2364
2176
|
return t && typeof t == "object" ? t : null;
|
|
2365
2177
|
}
|
|
2366
|
-
function
|
|
2178
|
+
function it(e) {
|
|
2367
2179
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2368
2180
|
}
|
|
2369
|
-
function
|
|
2181
|
+
function Dt(e) {
|
|
2370
2182
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2371
2183
|
}
|
|
2372
|
-
function
|
|
2373
|
-
const s =
|
|
2184
|
+
function Hs(e, t) {
|
|
2185
|
+
const s = gt(t);
|
|
2374
2186
|
if (s === null)
|
|
2375
2187
|
return !1;
|
|
2376
2188
|
const n = t[s], r = n && typeof n == "object" ? n.id : null;
|
|
2377
2189
|
if (typeof r != "string" || !r)
|
|
2378
2190
|
return !1;
|
|
2379
2191
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2380
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
2192
|
+
return i === -1 ? !1 : e.slice(i + 1).some(Fs);
|
|
2381
2193
|
}
|
|
2382
|
-
function
|
|
2383
|
-
const t =
|
|
2194
|
+
function ot(e) {
|
|
2195
|
+
const t = gt(e);
|
|
2384
2196
|
if (t === null)
|
|
2385
2197
|
return null;
|
|
2386
2198
|
const s = e[t];
|
|
@@ -2392,8 +2204,8 @@ function ut(e) {
|
|
|
2392
2204
|
const r = n.clientMessageId;
|
|
2393
2205
|
return typeof r == "string" ? r : null;
|
|
2394
2206
|
}
|
|
2395
|
-
function
|
|
2396
|
-
const t =
|
|
2207
|
+
function Ws(e) {
|
|
2208
|
+
const t = gt(e);
|
|
2397
2209
|
if (t === null)
|
|
2398
2210
|
return null;
|
|
2399
2211
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
@@ -2407,22 +2219,22 @@ function Zs(e) {
|
|
|
2407
2219
|
if (i.type === "message" && i.role === "assistant")
|
|
2408
2220
|
return null;
|
|
2409
2221
|
if (i.type === "run_error")
|
|
2410
|
-
return i.retryable !== !0 ? null :
|
|
2222
|
+
return i.retryable !== !0 ? null : Nt(e, i) ?? ot(e);
|
|
2411
2223
|
if (i.type === "run_status")
|
|
2412
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
2224
|
+
return i.status === "interrupted" && i.retryable === !0 ? Nt(e, i) ?? ot(e) : null;
|
|
2413
2225
|
}
|
|
2414
2226
|
return null;
|
|
2415
2227
|
}
|
|
2416
|
-
function
|
|
2228
|
+
function Nt(e, t) {
|
|
2417
2229
|
if (typeof t.clientMessageId == "string")
|
|
2418
2230
|
return t.clientMessageId;
|
|
2419
|
-
const s =
|
|
2231
|
+
const s = R(t);
|
|
2420
2232
|
if (!s)
|
|
2421
2233
|
return null;
|
|
2422
|
-
const n = e.find((i) =>
|
|
2234
|
+
const n = e.find((i) => T(i, "id") === s), r = D(n);
|
|
2423
2235
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2424
2236
|
}
|
|
2425
|
-
function
|
|
2237
|
+
function js(e, t) {
|
|
2426
2238
|
let s = 0;
|
|
2427
2239
|
for (const n of e) {
|
|
2428
2240
|
if (!n || typeof n != "object")
|
|
@@ -2435,37 +2247,37 @@ function Qs(e, t) {
|
|
|
2435
2247
|
}
|
|
2436
2248
|
return s;
|
|
2437
2249
|
}
|
|
2438
|
-
function
|
|
2439
|
-
if (!t ||
|
|
2250
|
+
function Ot(e, t, s, n, r) {
|
|
2251
|
+
if (!t || !$s(e))
|
|
2440
2252
|
return !1;
|
|
2441
2253
|
const i = e;
|
|
2442
|
-
return !(
|
|
2254
|
+
return !(it(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && R(i) !== n || r !== null && S(i) !== r);
|
|
2443
2255
|
}
|
|
2444
|
-
function
|
|
2256
|
+
function $s(e) {
|
|
2445
2257
|
if (!e || typeof e != "object")
|
|
2446
2258
|
return !1;
|
|
2447
2259
|
const t = e;
|
|
2448
2260
|
return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted");
|
|
2449
2261
|
}
|
|
2450
|
-
function
|
|
2262
|
+
function N(e) {
|
|
2451
2263
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
2452
2264
|
}
|
|
2453
|
-
function
|
|
2265
|
+
function zs(e) {
|
|
2454
2266
|
if (!e || typeof e != "object")
|
|
2455
2267
|
return !1;
|
|
2456
2268
|
const t = e;
|
|
2457
2269
|
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";
|
|
2458
2270
|
}
|
|
2459
|
-
function
|
|
2460
|
-
return e.filter((t, s) =>
|
|
2271
|
+
function at(e) {
|
|
2272
|
+
return e.filter((t, s) => mt(t) ? !Ys(e, s) && !Js(e, s) && !Vs(e, s) : Gs(t) ? t.retryable === !0 && Ks(e, s) ? !1 : !Xs(e, s) : !0);
|
|
2461
2273
|
}
|
|
2462
|
-
function
|
|
2274
|
+
function Gs(e) {
|
|
2463
2275
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
2464
2276
|
}
|
|
2465
|
-
function
|
|
2277
|
+
function mt(e) {
|
|
2466
2278
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
2467
2279
|
}
|
|
2468
|
-
function
|
|
2280
|
+
function ct(e) {
|
|
2469
2281
|
const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
2470
2282
|
for (const i of e) {
|
|
2471
2283
|
if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
|
|
@@ -2481,18 +2293,18 @@ function ht(e) {
|
|
|
2481
2293
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
2482
2294
|
return r;
|
|
2483
2295
|
}
|
|
2484
|
-
function
|
|
2296
|
+
function Xs(e, t) {
|
|
2485
2297
|
const s = e[t];
|
|
2486
2298
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2487
2299
|
const r = e[n];
|
|
2488
2300
|
if (r.role === "user")
|
|
2489
2301
|
return !1;
|
|
2490
|
-
if (r.role === "assistant" &&
|
|
2302
|
+
if (r.role === "assistant" && G(s, r))
|
|
2491
2303
|
return !0;
|
|
2492
2304
|
}
|
|
2493
2305
|
return !1;
|
|
2494
2306
|
}
|
|
2495
|
-
function
|
|
2307
|
+
function Ks(e, t) {
|
|
2496
2308
|
const s = e[t];
|
|
2497
2309
|
if (!s.respondsToUserMessageId)
|
|
2498
2310
|
return !1;
|
|
@@ -2500,47 +2312,47 @@ function rn(e, t) {
|
|
|
2500
2312
|
const r = e[n];
|
|
2501
2313
|
if (r.role === "user")
|
|
2502
2314
|
return !1;
|
|
2503
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
2315
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || mt(r)))
|
|
2504
2316
|
return !0;
|
|
2505
2317
|
}
|
|
2506
2318
|
return !1;
|
|
2507
2319
|
}
|
|
2508
|
-
function
|
|
2320
|
+
function Js(e, t) {
|
|
2509
2321
|
const s = e[t];
|
|
2510
2322
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2511
|
-
if (e[n].role === "assistant" &&
|
|
2323
|
+
if (e[n].role === "assistant" && G(s, e[n]))
|
|
2512
2324
|
return !0;
|
|
2513
2325
|
return !1;
|
|
2514
2326
|
}
|
|
2515
|
-
function
|
|
2327
|
+
function Vs(e, t) {
|
|
2516
2328
|
const s = e[t];
|
|
2517
2329
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2518
|
-
if (e[n].role === "tool" &&
|
|
2330
|
+
if (e[n].role === "tool" && G(s, e[n]))
|
|
2519
2331
|
return !0;
|
|
2520
2332
|
return !1;
|
|
2521
2333
|
}
|
|
2522
|
-
function
|
|
2334
|
+
function Ys(e, t) {
|
|
2523
2335
|
const s = e[t];
|
|
2524
2336
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2525
|
-
if (
|
|
2337
|
+
if (mt(e[n]) && G(s, e[n]))
|
|
2526
2338
|
return !0;
|
|
2527
2339
|
return !1;
|
|
2528
2340
|
}
|
|
2529
|
-
function
|
|
2341
|
+
function G(e, t) {
|
|
2530
2342
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
2531
2343
|
}
|
|
2532
|
-
function
|
|
2344
|
+
function T(e, t) {
|
|
2533
2345
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
2534
2346
|
}
|
|
2535
|
-
function
|
|
2347
|
+
function Zs(e, t) {
|
|
2536
2348
|
try {
|
|
2537
|
-
const s = window.localStorage.getItem(`${
|
|
2349
|
+
const s = window.localStorage.getItem(`${$t}${e}`);
|
|
2538
2350
|
if (!s)
|
|
2539
2351
|
return null;
|
|
2540
2352
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
2541
2353
|
if (t !== void 0 && r !== t)
|
|
2542
2354
|
return null;
|
|
2543
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2355
|
+
const i = Array.isArray(n.messages) ? n.messages.map(dn).filter((o) => !!o) : [];
|
|
2544
2356
|
return {
|
|
2545
2357
|
sessionId: r,
|
|
2546
2358
|
messages: i
|
|
@@ -2549,48 +2361,48 @@ function ln(e, t) {
|
|
|
2549
2361
|
return null;
|
|
2550
2362
|
}
|
|
2551
2363
|
}
|
|
2552
|
-
function
|
|
2364
|
+
function Qs(e, t) {
|
|
2553
2365
|
try {
|
|
2554
2366
|
window.localStorage.setItem(
|
|
2555
|
-
`${
|
|
2367
|
+
`${$t}${e}`,
|
|
2556
2368
|
JSON.stringify({
|
|
2557
2369
|
sessionId: t.sessionId,
|
|
2558
|
-
messages: t.messages.slice(-
|
|
2370
|
+
messages: t.messages.slice(-We).map(hn)
|
|
2559
2371
|
})
|
|
2560
2372
|
);
|
|
2561
2373
|
} catch {
|
|
2562
2374
|
return;
|
|
2563
2375
|
}
|
|
2564
2376
|
}
|
|
2565
|
-
function
|
|
2377
|
+
function tn(e) {
|
|
2566
2378
|
try {
|
|
2567
|
-
const t = window.localStorage.getItem(`${
|
|
2379
|
+
const t = window.localStorage.getItem(`${nt}${e}`);
|
|
2568
2380
|
if (!t)
|
|
2569
2381
|
return [];
|
|
2570
2382
|
const s = JSON.parse(t);
|
|
2571
|
-
return Array.isArray(s) ? s.filter(
|
|
2383
|
+
return Array.isArray(s) ? s.filter(yt) : [];
|
|
2572
2384
|
} catch {
|
|
2573
2385
|
return [];
|
|
2574
2386
|
}
|
|
2575
2387
|
}
|
|
2576
|
-
function
|
|
2388
|
+
function U(e, t) {
|
|
2577
2389
|
try {
|
|
2578
|
-
const s = t.filter(
|
|
2390
|
+
const s = t.filter(yt);
|
|
2579
2391
|
if (s.length === 0) {
|
|
2580
|
-
window.localStorage.removeItem(`${
|
|
2392
|
+
window.localStorage.removeItem(`${nt}${e}`);
|
|
2581
2393
|
return;
|
|
2582
2394
|
}
|
|
2583
2395
|
window.localStorage.setItem(
|
|
2584
|
-
`${
|
|
2396
|
+
`${nt}${e}`,
|
|
2585
2397
|
JSON.stringify(s.slice(-25))
|
|
2586
2398
|
);
|
|
2587
2399
|
} catch {
|
|
2588
2400
|
return;
|
|
2589
2401
|
}
|
|
2590
2402
|
}
|
|
2591
|
-
function
|
|
2403
|
+
function Yt(e, t) {
|
|
2592
2404
|
try {
|
|
2593
|
-
const s = `${
|
|
2405
|
+
const s = `${z}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
2594
2406
|
...o,
|
|
2595
2407
|
storedAt: Date.now(),
|
|
2596
2408
|
unloadUrl: n,
|
|
@@ -2604,28 +2416,28 @@ function se(e, t) {
|
|
|
2604
2416
|
} catch {
|
|
2605
2417
|
}
|
|
2606
2418
|
}
|
|
2607
|
-
function
|
|
2419
|
+
function en(e, t) {
|
|
2608
2420
|
try {
|
|
2609
|
-
if (window.sessionStorage.getItem(`${
|
|
2421
|
+
if (window.sessionStorage.getItem(`${z}${e}`) === null)
|
|
2610
2422
|
return;
|
|
2611
2423
|
} catch {
|
|
2612
2424
|
return;
|
|
2613
2425
|
}
|
|
2614
|
-
|
|
2426
|
+
Yt(e, t);
|
|
2615
2427
|
}
|
|
2616
|
-
function
|
|
2428
|
+
function sn(e) {
|
|
2617
2429
|
try {
|
|
2618
|
-
const t = `${
|
|
2430
|
+
const t = `${z}${e}`, s = window.sessionStorage.getItem(t);
|
|
2619
2431
|
if (window.sessionStorage.removeItem(t), !s)
|
|
2620
2432
|
return [];
|
|
2621
2433
|
const n = JSON.parse(s);
|
|
2622
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2434
|
+
return Array.isArray(n) ? n.flatMap((r) => rn(r) ? [{
|
|
2623
2435
|
...r.event,
|
|
2624
|
-
page:
|
|
2436
|
+
page: w(),
|
|
2625
2437
|
rawOutput: {
|
|
2626
2438
|
pageContextRestarted: !0,
|
|
2627
2439
|
outcome: "unknown",
|
|
2628
|
-
message:
|
|
2440
|
+
message: nn(location.href),
|
|
2629
2441
|
currentUrl: location.href,
|
|
2630
2442
|
console: [],
|
|
2631
2443
|
metadata: {
|
|
@@ -2642,17 +2454,17 @@ function pn(e) {
|
|
|
2642
2454
|
return [];
|
|
2643
2455
|
}
|
|
2644
2456
|
}
|
|
2645
|
-
function
|
|
2457
|
+
function nn(e) {
|
|
2646
2458
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
2647
2459
|
Current URL: ${e}`;
|
|
2648
2460
|
}
|
|
2649
|
-
function
|
|
2461
|
+
function rn(e) {
|
|
2650
2462
|
if (!e || typeof e != "object")
|
|
2651
2463
|
return !1;
|
|
2652
2464
|
const t = e, s = t.event;
|
|
2653
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
2465
|
+
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && yt(s) && s.type === "tool.result";
|
|
2654
2466
|
}
|
|
2655
|
-
function
|
|
2467
|
+
function on(e, t) {
|
|
2656
2468
|
const s = new Set(
|
|
2657
2469
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2658
2470
|
);
|
|
@@ -2661,26 +2473,26 @@ function mn(e, t) {
|
|
|
2661
2473
|
...t.filter((n) => !s.has(n.callId))
|
|
2662
2474
|
];
|
|
2663
2475
|
}
|
|
2664
|
-
function
|
|
2476
|
+
function an(e) {
|
|
2665
2477
|
try {
|
|
2666
|
-
window.sessionStorage.removeItem(`${
|
|
2478
|
+
window.sessionStorage.removeItem(`${z}${e}`);
|
|
2667
2479
|
} catch {
|
|
2668
2480
|
return;
|
|
2669
2481
|
}
|
|
2670
2482
|
}
|
|
2671
|
-
function
|
|
2483
|
+
function yt(e) {
|
|
2672
2484
|
if (!e || typeof e != "object")
|
|
2673
2485
|
return !1;
|
|
2674
2486
|
const t = e;
|
|
2675
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
2487
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && Bt(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Bt(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
|
|
2676
2488
|
}
|
|
2677
|
-
function
|
|
2489
|
+
function Bt(e) {
|
|
2678
2490
|
if (!e || typeof e != "object")
|
|
2679
2491
|
return !1;
|
|
2680
2492
|
const t = e;
|
|
2681
2493
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
2682
2494
|
}
|
|
2683
|
-
function
|
|
2495
|
+
function Zt(e, t) {
|
|
2684
2496
|
if (!Array.isArray(e))
|
|
2685
2497
|
return;
|
|
2686
2498
|
const s = e.filter((r) => {
|
|
@@ -2688,24 +2500,24 @@ function ne(e, t) {
|
|
|
2688
2500
|
return !1;
|
|
2689
2501
|
const i = r;
|
|
2690
2502
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2691
|
-
}), n = t ? s.map((r) =>
|
|
2503
|
+
}), n = t ? s.map((r) => Qt(r, t)) : s;
|
|
2692
2504
|
return n.length > 0 ? n : void 0;
|
|
2693
2505
|
}
|
|
2694
|
-
function
|
|
2506
|
+
function Qt(e, t) {
|
|
2695
2507
|
return e.fileUrl?.startsWith("/") ? {
|
|
2696
2508
|
...e,
|
|
2697
2509
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2698
2510
|
} : e;
|
|
2699
2511
|
}
|
|
2700
|
-
function
|
|
2701
|
-
if (
|
|
2512
|
+
function cn(e) {
|
|
2513
|
+
if (ln(e))
|
|
2702
2514
|
return {
|
|
2703
2515
|
headers: {
|
|
2704
2516
|
"ngrok-skip-browser-warning": "true"
|
|
2705
2517
|
}
|
|
2706
2518
|
};
|
|
2707
2519
|
}
|
|
2708
|
-
function
|
|
2520
|
+
function ln(e) {
|
|
2709
2521
|
try {
|
|
2710
2522
|
const t = new URL(e).hostname;
|
|
2711
2523
|
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
@@ -2713,14 +2525,14 @@ function Tn(e) {
|
|
|
2713
2525
|
return !1;
|
|
2714
2526
|
}
|
|
2715
2527
|
}
|
|
2716
|
-
function
|
|
2717
|
-
return e.type ||
|
|
2528
|
+
function Lt(e) {
|
|
2529
|
+
return e.type || un(e.name) || "application/octet-stream";
|
|
2718
2530
|
}
|
|
2719
|
-
function
|
|
2531
|
+
function un(e) {
|
|
2720
2532
|
const t = e.toLowerCase();
|
|
2721
2533
|
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;
|
|
2722
2534
|
}
|
|
2723
|
-
function
|
|
2535
|
+
function dn(e) {
|
|
2724
2536
|
if (!e || typeof e != "object")
|
|
2725
2537
|
return null;
|
|
2726
2538
|
const t = e;
|
|
@@ -2733,17 +2545,17 @@ function An(e) {
|
|
|
2733
2545
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
2734
2546
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
2735
2547
|
securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
|
|
2736
|
-
attachments:
|
|
2548
|
+
attachments: Zt(t.attachments)?.map(It),
|
|
2737
2549
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2738
2550
|
};
|
|
2739
2551
|
}
|
|
2740
|
-
function
|
|
2552
|
+
function hn(e) {
|
|
2741
2553
|
return e.attachments?.length ? {
|
|
2742
2554
|
...e,
|
|
2743
|
-
attachments: e.attachments.map(
|
|
2555
|
+
attachments: e.attachments.map(It)
|
|
2744
2556
|
} : e;
|
|
2745
2557
|
}
|
|
2746
|
-
function
|
|
2558
|
+
function It(e) {
|
|
2747
2559
|
const {
|
|
2748
2560
|
dataUrl: t,
|
|
2749
2561
|
objectUrl: s,
|
|
@@ -2752,69 +2564,69 @@ function St(e) {
|
|
|
2752
2564
|
} = e;
|
|
2753
2565
|
return r;
|
|
2754
2566
|
}
|
|
2755
|
-
function
|
|
2567
|
+
function R(e) {
|
|
2756
2568
|
const t = e.respondsToUserMessageId;
|
|
2757
2569
|
return typeof t == "string" && t ? t : null;
|
|
2758
2570
|
}
|
|
2759
|
-
function
|
|
2571
|
+
function S(e) {
|
|
2760
2572
|
const t = e.runId;
|
|
2761
2573
|
return typeof t == "string" && t ? t : null;
|
|
2762
2574
|
}
|
|
2763
|
-
function
|
|
2575
|
+
function pn(e) {
|
|
2764
2576
|
const t = e?.timeoutMs;
|
|
2765
|
-
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 <=
|
|
2577
|
+
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 <= Ve);
|
|
2766
2578
|
}
|
|
2767
|
-
function
|
|
2579
|
+
function te(e) {
|
|
2768
2580
|
const t = {};
|
|
2769
2581
|
try {
|
|
2770
2582
|
new Headers(e).forEach((s, n) => {
|
|
2771
|
-
Object.keys(t).length <
|
|
2583
|
+
Object.keys(t).length < ht && (t[n] = Tt(n, s));
|
|
2772
2584
|
});
|
|
2773
2585
|
} catch {
|
|
2774
2586
|
return {};
|
|
2775
2587
|
}
|
|
2776
2588
|
return t;
|
|
2777
2589
|
}
|
|
2778
|
-
function
|
|
2779
|
-
return
|
|
2590
|
+
function Tt(e, t) {
|
|
2591
|
+
return oe(e) ? X : k(j(t), xe);
|
|
2780
2592
|
}
|
|
2781
|
-
function
|
|
2593
|
+
function fn(e, t) {
|
|
2782
2594
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2783
2595
|
}
|
|
2784
|
-
async function
|
|
2785
|
-
const r =
|
|
2596
|
+
async function gn(e, t, s, n) {
|
|
2597
|
+
const r = te(e.headers);
|
|
2786
2598
|
n({
|
|
2787
2599
|
...t,
|
|
2788
2600
|
responseStatus: e.status,
|
|
2789
2601
|
responseHeaders: r,
|
|
2790
|
-
responseBody: await
|
|
2602
|
+
responseBody: await mn(e),
|
|
2791
2603
|
durationMs: Date.now() - s
|
|
2792
2604
|
});
|
|
2793
2605
|
}
|
|
2794
|
-
async function
|
|
2795
|
-
if (!
|
|
2606
|
+
async function mn(e) {
|
|
2607
|
+
if (!ee(e.headers))
|
|
2796
2608
|
return;
|
|
2797
2609
|
let t = null, s = null;
|
|
2798
2610
|
try {
|
|
2799
2611
|
if (t = e.clone().body?.getReader() ?? null, !t)
|
|
2800
2612
|
return;
|
|
2801
|
-
const n = new Promise((
|
|
2613
|
+
const n = new Promise((l) => {
|
|
2802
2614
|
s = window.setTimeout(() => {
|
|
2803
|
-
t?.cancel(),
|
|
2804
|
-
},
|
|
2615
|
+
t?.cancel(), l("timeout");
|
|
2616
|
+
}, Fe);
|
|
2805
2617
|
}), r = new TextDecoder();
|
|
2806
2618
|
let i = "", o = 0;
|
|
2807
2619
|
for (; ; ) {
|
|
2808
|
-
const
|
|
2809
|
-
if (
|
|
2620
|
+
const l = await Promise.race([t.read(), n]);
|
|
2621
|
+
if (l === "timeout")
|
|
2810
2622
|
return;
|
|
2811
|
-
const { done: u, value:
|
|
2623
|
+
const { done: u, value: c } = l;
|
|
2812
2624
|
if (u)
|
|
2813
|
-
return
|
|
2814
|
-
const a =
|
|
2815
|
-
if (
|
|
2816
|
-
return i += r.decode(
|
|
2817
|
-
o +=
|
|
2625
|
+
return k(i + r.decode());
|
|
2626
|
+
const a = dt - o;
|
|
2627
|
+
if (c.byteLength > a)
|
|
2628
|
+
return i += r.decode(c.subarray(0, Math.max(a, 0)), { stream: !0 }), t.cancel(), `${k(i)}... [truncated]`;
|
|
2629
|
+
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
2818
2630
|
}
|
|
2819
2631
|
} catch {
|
|
2820
2632
|
t?.cancel();
|
|
@@ -2823,45 +2635,45 @@ async function Rn(e) {
|
|
|
2823
2635
|
s !== null && window.clearTimeout(s);
|
|
2824
2636
|
}
|
|
2825
2637
|
}
|
|
2826
|
-
function
|
|
2827
|
-
if (
|
|
2638
|
+
function yn(e, t) {
|
|
2639
|
+
if (ee(new Headers(t)))
|
|
2828
2640
|
try {
|
|
2829
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
2641
|
+
return e.responseType === "" || e.responseType === "text" ? k(e.responseText ?? "") : void 0;
|
|
2830
2642
|
} catch {
|
|
2831
2643
|
return;
|
|
2832
2644
|
}
|
|
2833
2645
|
}
|
|
2834
|
-
function
|
|
2646
|
+
function vt(e) {
|
|
2835
2647
|
if (typeof e == "string")
|
|
2836
|
-
return
|
|
2648
|
+
return k(e);
|
|
2837
2649
|
}
|
|
2838
|
-
function
|
|
2839
|
-
return
|
|
2650
|
+
function In(e) {
|
|
2651
|
+
return A({
|
|
2840
2652
|
...e,
|
|
2841
|
-
requestBody:
|
|
2842
|
-
responseBody:
|
|
2653
|
+
requestBody: qt(e.requestBody),
|
|
2654
|
+
responseBody: qt(e.responseBody)
|
|
2843
2655
|
});
|
|
2844
2656
|
}
|
|
2845
|
-
function
|
|
2657
|
+
function qt(e) {
|
|
2846
2658
|
if (typeof e != "string")
|
|
2847
2659
|
return e;
|
|
2848
2660
|
const t = e.trim();
|
|
2849
2661
|
if (!t.startsWith("{") && !t.startsWith("["))
|
|
2850
|
-
return
|
|
2662
|
+
return j(e);
|
|
2851
2663
|
try {
|
|
2852
|
-
return JSON.stringify(
|
|
2664
|
+
return JSON.stringify(A(JSON.parse(e)));
|
|
2853
2665
|
} catch {
|
|
2854
|
-
return
|
|
2666
|
+
return j(e);
|
|
2855
2667
|
}
|
|
2856
2668
|
}
|
|
2857
|
-
function
|
|
2669
|
+
function ee(e) {
|
|
2858
2670
|
if (!e)
|
|
2859
2671
|
return !1;
|
|
2860
2672
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
2861
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
2673
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= dt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
2862
2674
|
}
|
|
2863
|
-
function
|
|
2864
|
-
if (
|
|
2675
|
+
function b(e, t = {}, s) {
|
|
2676
|
+
if (wn(s))
|
|
2865
2677
|
return !0;
|
|
2866
2678
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
2867
2679
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -2871,13 +2683,13 @@ function M(e, t = {}, s) {
|
|
|
2871
2683
|
if (r.protocol !== "http:" && r.protocol !== "https:")
|
|
2872
2684
|
return !0;
|
|
2873
2685
|
const i = r.hostname.toLowerCase(), o = r.pathname.toLowerCase();
|
|
2874
|
-
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((
|
|
2686
|
+
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((l) => /^(x-amz-signature|x-goog-signature|signature|sig)$/i.test(l));
|
|
2875
2687
|
} catch {
|
|
2876
2688
|
return !0;
|
|
2877
2689
|
}
|
|
2878
2690
|
}
|
|
2879
|
-
function
|
|
2880
|
-
if (
|
|
2691
|
+
function Tn(e, t) {
|
|
2692
|
+
if (b(e))
|
|
2881
2693
|
return !0;
|
|
2882
2694
|
try {
|
|
2883
2695
|
const s = new URL(e, location.href), n = new URL(t);
|
|
@@ -2886,115 +2698,115 @@ function Mn(e, t) {
|
|
|
2886
2698
|
return !0;
|
|
2887
2699
|
}
|
|
2888
2700
|
}
|
|
2889
|
-
function
|
|
2701
|
+
function wn(e) {
|
|
2890
2702
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
2891
2703
|
}
|
|
2892
|
-
function
|
|
2704
|
+
function An(e) {
|
|
2893
2705
|
const t = {};
|
|
2894
2706
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
2895
2707
|
const n = s.indexOf(":");
|
|
2896
2708
|
if (n <= 0)
|
|
2897
2709
|
continue;
|
|
2898
|
-
if (Object.keys(t).length >=
|
|
2710
|
+
if (Object.keys(t).length >= ht)
|
|
2899
2711
|
break;
|
|
2900
2712
|
const r = s.slice(0, n).trim();
|
|
2901
|
-
t[r] =
|
|
2713
|
+
t[r] = Tt(r, s.slice(n + 1).trim());
|
|
2902
2714
|
}
|
|
2903
2715
|
return t;
|
|
2904
2716
|
}
|
|
2905
|
-
function
|
|
2717
|
+
function k(e, t = dt) {
|
|
2906
2718
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
2907
2719
|
}
|
|
2908
|
-
function
|
|
2720
|
+
function Q(e) {
|
|
2909
2721
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2910
2722
|
}
|
|
2911
|
-
class
|
|
2723
|
+
class H extends Error {
|
|
2912
2724
|
constructor(t, s) {
|
|
2913
2725
|
super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
2914
2726
|
}
|
|
2915
2727
|
status;
|
|
2916
2728
|
}
|
|
2917
|
-
async function
|
|
2729
|
+
async function tt(e, t) {
|
|
2918
2730
|
let s = null;
|
|
2919
|
-
for (let n = 0; n <
|
|
2731
|
+
for (let n = 0; n < Et; n += 1)
|
|
2920
2732
|
try {
|
|
2921
2733
|
return await e();
|
|
2922
2734
|
} catch (r) {
|
|
2923
|
-
if (s = r, n >=
|
|
2735
|
+
if (s = r, n >= Et - 1 || !kn(r))
|
|
2924
2736
|
throw r;
|
|
2925
|
-
await
|
|
2737
|
+
await Sn(n);
|
|
2926
2738
|
}
|
|
2927
2739
|
throw s instanceof Error ? s : new Error(t);
|
|
2928
2740
|
}
|
|
2929
|
-
function
|
|
2741
|
+
function Sn(e) {
|
|
2930
2742
|
return new Promise((t) => {
|
|
2931
|
-
window.setTimeout(t,
|
|
2743
|
+
window.setTimeout(t, qe[e] ?? 0);
|
|
2932
2744
|
});
|
|
2933
2745
|
}
|
|
2934
|
-
function
|
|
2935
|
-
return e instanceof
|
|
2746
|
+
function kn(e) {
|
|
2747
|
+
return e instanceof H ? En(e.status) : e instanceof TypeError;
|
|
2936
2748
|
}
|
|
2937
|
-
function
|
|
2749
|
+
function En(e) {
|
|
2938
2750
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
2939
2751
|
}
|
|
2940
|
-
function
|
|
2752
|
+
function Rn(e) {
|
|
2941
2753
|
return e === 401 || e === 403;
|
|
2942
2754
|
}
|
|
2943
|
-
const
|
|
2944
|
-
function
|
|
2945
|
-
return
|
|
2755
|
+
const X = "[REDACTED_SECRET]", E = "[REDACTED_TOKEN]", _n = "[REDACTED_SIGNED_URL]", bn = 20, Mn = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, se = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ne = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, re = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ie = /\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, Cn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Pn = /\bhttps?:\/\/[^\s"'<>]+/gi, Un = /[),.;\]]+$/;
|
|
2756
|
+
function A(e) {
|
|
2757
|
+
return W(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2946
2758
|
}
|
|
2947
|
-
function
|
|
2759
|
+
function W(e, t, s) {
|
|
2948
2760
|
if (typeof e == "string")
|
|
2949
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
2761
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : j(e);
|
|
2950
2762
|
if (e === null || typeof e != "object")
|
|
2951
2763
|
return e;
|
|
2952
|
-
if (t >=
|
|
2764
|
+
if (t >= bn)
|
|
2953
2765
|
return "[REDACTED_MAX_DEPTH]";
|
|
2954
2766
|
if (s.has(e))
|
|
2955
2767
|
return "[REDACTED_CIRCULAR]";
|
|
2956
2768
|
if (s.add(e), Array.isArray(e))
|
|
2957
|
-
return e.map((r) =>
|
|
2769
|
+
return e.map((r) => W(r, t + 1, s));
|
|
2958
2770
|
const n = {};
|
|
2959
2771
|
for (const [r, i] of Object.entries(e))
|
|
2960
|
-
|
|
2772
|
+
oe(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? Dn(i) : W(i, t + 1, s);
|
|
2961
2773
|
return n;
|
|
2962
2774
|
}
|
|
2963
|
-
function
|
|
2775
|
+
function oe(e) {
|
|
2964
2776
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
2965
2777
|
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");
|
|
2966
2778
|
}
|
|
2967
|
-
function
|
|
2968
|
-
return typeof e == "string" ?
|
|
2779
|
+
function Dn(e) {
|
|
2780
|
+
return typeof e == "string" ? ae(e) : W(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2969
2781
|
}
|
|
2970
|
-
function
|
|
2782
|
+
function ae(e) {
|
|
2971
2783
|
try {
|
|
2972
2784
|
const t = new URL(e, location.href);
|
|
2973
2785
|
for (const s of Array.from(t.searchParams.keys()))
|
|
2974
|
-
|
|
2975
|
-
return t.username && (t.username =
|
|
2786
|
+
Mn.test(s) && t.searchParams.set(s, E);
|
|
2787
|
+
return t.username && (t.username = E), t.password && (t.password = E), t.toString();
|
|
2976
2788
|
} catch {
|
|
2977
|
-
return
|
|
2789
|
+
return Nn(e);
|
|
2978
2790
|
}
|
|
2979
2791
|
}
|
|
2980
|
-
function
|
|
2981
|
-
return e.replace(
|
|
2792
|
+
function j(e) {
|
|
2793
|
+
return e.replace(Cn, _n).replace(Pn, On).replace(se, `Bearer ${E}`).replace(ne, `Basic ${E}`).replace(re, E).replace(ie, (t, s) => `${s}: ${X}`);
|
|
2982
2794
|
}
|
|
2983
|
-
function
|
|
2984
|
-
return e.replace(
|
|
2795
|
+
function Nn(e) {
|
|
2796
|
+
return e.replace(se, `Bearer ${E}`).replace(ne, `Basic ${E}`).replace(re, E).replace(ie, (t, s) => `${s}: ${X}`);
|
|
2985
2797
|
}
|
|
2986
|
-
function
|
|
2987
|
-
const t = e.match(
|
|
2988
|
-
return `${
|
|
2798
|
+
function On(e) {
|
|
2799
|
+
const t = e.match(Un)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
2800
|
+
return `${ae(s)}${t}`;
|
|
2989
2801
|
}
|
|
2990
2802
|
export {
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
2803
|
+
wt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
2804
|
+
st as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
2805
|
+
Ae as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
2806
|
+
we as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
2807
|
+
Se as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
2808
|
+
zt as PlunoProductAgent,
|
|
2809
|
+
$e as calculateReconnectDelay,
|
|
2810
|
+
zt as default,
|
|
2811
|
+
us as getProductAgentOriginAccessErrorMessage
|
|
3000
2812
|
};
|