@pluno/product-agent-web 0.1.153 → 0.1.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/product-agent-sdk.js +674 -599
- package/dist/product-agent-widget.js +1825 -1746
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const t = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
1
|
+
const ns = "pluno-product-agent-attachments";
|
|
2
|
+
const vt = "files";
|
|
3
|
+
async function rs(e) {
|
|
4
|
+
const t = await $t();
|
|
5
|
+
await as(t, "readwrite", (s) => s.put(e));
|
|
6
|
+
}
|
|
7
|
+
async function is(e, t) {
|
|
8
|
+
const s = await $t();
|
|
9
|
+
await jt(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await zt(
|
|
11
11
|
n.get(e)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,28 +16,28 @@ async function ns(e, t) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const t = await
|
|
21
|
-
await
|
|
19
|
+
async function os(e = 864e5) {
|
|
20
|
+
const t = await $t(), s = Date.now() - e;
|
|
21
|
+
await jt(t, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await zt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function $t() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
28
|
-
const s = indexedDB.open(
|
|
28
|
+
const s = indexedDB.open(ns, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(vt, { keyPath: "attachmentId" });
|
|
31
31
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
32
32
|
}, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
return await
|
|
35
|
+
async function as(e, t, s) {
|
|
36
|
+
return await jt(e, t, async (n) => await zt(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function jt(e, t, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = e.transaction(
|
|
40
|
+
const i = e.transaction(vt, t), o = i.objectStore(vt);
|
|
41
41
|
let a, c = !1;
|
|
42
42
|
s(o).then((l) => {
|
|
43
43
|
a = l;
|
|
@@ -57,16 +57,16 @@ function $t(e, t, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function zt(e) {
|
|
61
61
|
return new Promise((t, s) => {
|
|
62
62
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function cs(e) {
|
|
66
66
|
return e !== null && (typeof e == "object" || typeof e == "function");
|
|
67
67
|
}
|
|
68
68
|
function be(e, t, s) {
|
|
69
|
-
const n = Reflect.get(e, "pluno"), r =
|
|
69
|
+
const n = Reflect.get(e, "pluno"), r = cs(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(e, "pluno", r))
|
|
71
71
|
return null;
|
|
72
72
|
const i = Object.getOwnPropertyDescriptor(r, t);
|
|
@@ -80,14 +80,14 @@ function be(e, t, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const ls = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function us(e, t) {
|
|
85
85
|
return t ? e.replace(
|
|
86
|
-
|
|
86
|
+
ls,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
|
|
88
88
|
) : e;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function ds(e, t, s) {
|
|
91
91
|
const n = t.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
92
92
|
n.flatMap(
|
|
93
93
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
@@ -125,17 +125,17 @@ function ls(e, t, s) {
|
|
|
125
125
|
I.has(u) || m.push(u);
|
|
126
126
|
return m;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function hs(e, t, s, n) {
|
|
129
129
|
return e.filter((r) => {
|
|
130
130
|
const i = n(r);
|
|
131
131
|
return !i.isActivity || !i.isTransient ? !0 : t !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== t : s === null || i.runId !== s;
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
const
|
|
134
|
+
const Et = "pluno.productAgent.transportId", ps = "pluno.productAgent.transportIdentity", Rt = "pluno.productAgent.transportIdentity.event", fs = 50, gs = globalThis.setTimeout.bind(globalThis);
|
|
135
135
|
let $ = null;
|
|
136
|
-
const
|
|
137
|
-
async function
|
|
138
|
-
const t = e.randomUUID(), s = e.storage.getItem(
|
|
136
|
+
const it = /* @__PURE__ */ new Set(), Mt = /* @__PURE__ */ new Map();
|
|
137
|
+
async function ms(e = ke()) {
|
|
138
|
+
const t = e.randomUUID(), s = e.storage.getItem(Et);
|
|
139
139
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
140
140
|
const o = e.channel.subscribe((c) => {
|
|
141
141
|
if (!(c.senderId === t || c.transportId !== n)) {
|
|
@@ -153,14 +153,14 @@ async function fs(e = Me()) {
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
if (!s)
|
|
156
|
-
e.storage.setItem(
|
|
156
|
+
e.storage.setItem(Et, n), r = !0;
|
|
157
157
|
else
|
|
158
158
|
for (; ; ) {
|
|
159
159
|
if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
|
|
160
160
|
r = !0;
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
|
-
n = e.randomUUID(), e.storage.setItem(
|
|
163
|
+
n = e.randomUUID(), e.storage.setItem(Et, n);
|
|
164
164
|
}
|
|
165
165
|
let a = !1;
|
|
166
166
|
return {
|
|
@@ -170,49 +170,49 @@ async function fs(e = Me()) {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
174
|
-
$ || ($ =
|
|
173
|
+
async function ys() {
|
|
174
|
+
$ || ($ = ms(ke()), $.then((n) => {
|
|
175
175
|
const r = (i) => {
|
|
176
|
-
i.persisted || (n.release(), $ = null,
|
|
176
|
+
i.persisted || (n.release(), $ = null, it.clear(), window.removeEventListener("pagehide", r));
|
|
177
177
|
};
|
|
178
178
|
window.addEventListener("pagehide", r);
|
|
179
179
|
}));
|
|
180
|
-
const e = await $, t =
|
|
181
|
-
|
|
180
|
+
const e = await $, t = Is();
|
|
181
|
+
it.add(t);
|
|
182
182
|
let s = !1;
|
|
183
183
|
return {
|
|
184
184
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
185
185
|
transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
|
|
186
186
|
release: () => {
|
|
187
|
-
s || (s = !0,
|
|
187
|
+
s || (s = !0, it.delete(t));
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function Is() {
|
|
192
192
|
let e = 0;
|
|
193
|
-
for (;
|
|
193
|
+
for (; it.has(e); )
|
|
194
194
|
e += 1;
|
|
195
195
|
return e;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function ke() {
|
|
198
198
|
return {
|
|
199
|
-
storage:
|
|
200
|
-
channel:
|
|
199
|
+
storage: Ts(),
|
|
200
|
+
channel: ws(),
|
|
201
201
|
randomUUID: () => crypto.randomUUID(),
|
|
202
|
-
settle: () => new Promise((e) =>
|
|
202
|
+
settle: () => new Promise((e) => gs(e, fs))
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function Ts() {
|
|
206
206
|
return {
|
|
207
207
|
getItem: (e) => {
|
|
208
208
|
try {
|
|
209
|
-
return window.sessionStorage?.getItem(e) ??
|
|
209
|
+
return window.sessionStorage?.getItem(e) ?? Mt.get(e) ?? null;
|
|
210
210
|
} catch {
|
|
211
|
-
return
|
|
211
|
+
return Mt.get(e) ?? null;
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
setItem: (e, t) => {
|
|
215
|
-
|
|
215
|
+
Mt.set(e, t);
|
|
216
216
|
try {
|
|
217
217
|
window.sessionStorage?.setItem(e, t);
|
|
218
218
|
} catch {
|
|
@@ -220,9 +220,9 @@ function ys() {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function ws() {
|
|
224
224
|
if (typeof BroadcastChannel < "u") {
|
|
225
|
-
const e = new BroadcastChannel(
|
|
225
|
+
const e = new BroadcastChannel(ps);
|
|
226
226
|
return {
|
|
227
227
|
postMessage: (t) => e.postMessage(t),
|
|
228
228
|
subscribe: (t) => {
|
|
@@ -232,11 +232,11 @@ function Is() {
|
|
|
232
232
|
close: () => e.close()
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
-
return
|
|
235
|
+
return Ss();
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function Ss() {
|
|
238
238
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
239
|
-
if (s.key !==
|
|
239
|
+
if (s.key !== Rt || !s.newValue)
|
|
240
240
|
return;
|
|
241
241
|
const n = JSON.parse(s.newValue);
|
|
242
242
|
for (const r of e)
|
|
@@ -245,9 +245,9 @@ function Ts() {
|
|
|
245
245
|
return window.addEventListener("storage", t), {
|
|
246
246
|
postMessage: (s) => {
|
|
247
247
|
window.localStorage.setItem(
|
|
248
|
-
|
|
248
|
+
Rt,
|
|
249
249
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
250
|
-
), window.localStorage.removeItem(
|
|
250
|
+
), window.localStorage.removeItem(Rt);
|
|
251
251
|
},
|
|
252
252
|
subscribe: (s) => (e.add(s), () => e.delete(s)),
|
|
253
253
|
close: () => {
|
|
@@ -255,8 +255,8 @@ function Ts() {
|
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
-
const
|
|
259
|
-
function
|
|
258
|
+
const _e = "schedule_follow_up";
|
|
259
|
+
function As(e) {
|
|
260
260
|
let t = e;
|
|
261
261
|
if (typeof t == "string")
|
|
262
262
|
try {
|
|
@@ -267,11 +267,11 @@ function ws(e) {
|
|
|
267
267
|
if (!t || typeof t != "object")
|
|
268
268
|
return null;
|
|
269
269
|
const s = t;
|
|
270
|
-
return s.ok !== !0 || s.toolName !==
|
|
270
|
+
return s.ok !== !0 || s.toolName !== _e || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
let
|
|
274
|
-
function
|
|
272
|
+
const Es = globalThis.fetch.bind(globalThis), Nt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Rs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ms = ".pluno-pa-widget__panel", bs = ".pluno-pa-widget__timeline", ce = `${Nt}[data-pluno-sdk-preview-channel]`;
|
|
273
|
+
let ks = 0;
|
|
274
|
+
function le(e) {
|
|
275
275
|
const t = {};
|
|
276
276
|
for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
|
|
277
277
|
const o = e[i];
|
|
@@ -284,7 +284,7 @@ function ae(e) {
|
|
|
284
284
|
const r = e.attachments;
|
|
285
285
|
return Array.isArray(r) && (t.attachmentCount = r.length), t;
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function bt(e, t, s) {
|
|
288
288
|
if (typeof window > "u")
|
|
289
289
|
return;
|
|
290
290
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -296,31 +296,31 @@ function Rt(e, t, s) {
|
|
|
296
296
|
source: "web_sdk",
|
|
297
297
|
category: e,
|
|
298
298
|
name: t,
|
|
299
|
-
sequence: ++
|
|
299
|
+
sequence: ++ks,
|
|
300
300
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
301
301
|
monotonicMs: performance.now(),
|
|
302
302
|
data: s
|
|
303
303
|
};
|
|
304
304
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
305
305
|
}
|
|
306
|
-
const
|
|
306
|
+
const _s = "https://app.pluno.ai", Cs = "gpt-5.6-terra", Ps = 2e4, Us = 1e4, Ds = 1e4, vs = 1e4, Ns = 1e4, Os = 1e3, ue = 3e4, de = 0.2, he = 6e4, xs = 15e3, Q = 8, Ls = "Pluno could not finish this message. Try it again.", Bs = "Browser connection was interrupted.", qs = 15e3, Hs = 2e3, Ws = 1e3, Fs = 100, pe = 8e3, fe = 3, $s = [300, 1e3], Ce = 50 * 1024 * 1024, js = /* @__PURE__ */ new Set([
|
|
307
307
|
".jpeg:image/jpeg",
|
|
308
308
|
".jpg:image/jpeg",
|
|
309
309
|
".pdf:application/pdf",
|
|
310
310
|
".png:image/png",
|
|
311
311
|
".webp:image/webp"
|
|
312
|
-
]),
|
|
313
|
-
function
|
|
312
|
+
]), ni = ".pdf,.png,.jpg,.jpeg,.webp", Kt = 64e3, kt = 4e3, Gt = 30, zs = 2e3, Ks = 1e3, Pe = "Image is too large for model vision input.", Gs = 100, Ue = "pluno.productAgent.state.", Ot = "pluno.productAgent.pendingEvents.", ut = "pluno.productAgent.activeToolCalls.", Xs = 100;
|
|
313
|
+
function tt(e, t = 0) {
|
|
314
314
|
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
315
315
|
return Math.max(t, s);
|
|
316
316
|
}
|
|
317
|
-
const
|
|
318
|
-
let
|
|
319
|
-
function
|
|
320
|
-
const s = Math.min(
|
|
321
|
-
return Math.min(
|
|
317
|
+
const ot = /* @__PURE__ */ new Set();
|
|
318
|
+
let et = null;
|
|
319
|
+
function Js(e, t = Math.random) {
|
|
320
|
+
const s = Math.min(ue, Os * 2 ** e), n = 1 - de + t() * de * 2;
|
|
321
|
+
return Math.min(ue, Math.round(s * n));
|
|
322
322
|
}
|
|
323
|
-
function
|
|
323
|
+
function Vs(e, t, s) {
|
|
324
324
|
return new Promise((n, r) => {
|
|
325
325
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
326
326
|
e.then(
|
|
@@ -333,13 +333,13 @@ function Xs(e, t, s) {
|
|
|
333
333
|
);
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
|
-
class
|
|
336
|
+
class De {
|
|
337
337
|
constructor(t, s) {
|
|
338
338
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
339
339
|
...this.state,
|
|
340
|
-
starterPrompts:
|
|
340
|
+
starterPrompts: Un(t.initialStarterPrompts)
|
|
341
341
|
};
|
|
342
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
342
|
+
const n = t.restorePersistedState === !1 ? null : Sr(t.clientId, t.expectedPersistedSessionId);
|
|
343
343
|
n && (this.state = {
|
|
344
344
|
...this.state,
|
|
345
345
|
...n,
|
|
@@ -352,10 +352,10 @@ class Ue {
|
|
|
352
352
|
assistantDraftRunId: null,
|
|
353
353
|
isThinking: !1,
|
|
354
354
|
lastError: null
|
|
355
|
-
}), this.queuedClientEvents =
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
),
|
|
355
|
+
}), this.queuedClientEvents = _r(
|
|
356
|
+
Er(t.clientId),
|
|
357
|
+
Mr(t.clientId)
|
|
358
|
+
), z(t.clientId, this.queuedClientEvents);
|
|
359
359
|
}
|
|
360
360
|
options;
|
|
361
361
|
listeners = {};
|
|
@@ -429,15 +429,15 @@ class Ue {
|
|
|
429
429
|
lastErrorSecuritySettingsUrl: null
|
|
430
430
|
};
|
|
431
431
|
static async init(t) {
|
|
432
|
-
const s = await
|
|
432
|
+
const s = await ys(), n = new De({
|
|
433
433
|
...t,
|
|
434
|
-
backendUrl:
|
|
435
|
-
clientId: t.clientId ??
|
|
436
|
-
model: t.model ??
|
|
437
|
-
entrySurface:
|
|
434
|
+
backendUrl: mn(t.backendUrl ?? _s),
|
|
435
|
+
clientId: t.clientId ?? xn(),
|
|
436
|
+
model: t.model ?? Cs,
|
|
437
|
+
entrySurface: yn(t.entrySurface)
|
|
438
438
|
}, s);
|
|
439
439
|
try {
|
|
440
|
-
|
|
440
|
+
os().catch((r) => {
|
|
441
441
|
S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
442
442
|
message: r instanceof Error ? r.message : String(r)
|
|
443
443
|
});
|
|
@@ -468,14 +468,14 @@ class Ue {
|
|
|
468
468
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
469
469
|
);
|
|
470
470
|
try {
|
|
471
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
471
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await Vs(this.options.tokenProvider(), Ds, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
472
472
|
return;
|
|
473
473
|
if (!this.token && !this.options.webSocketFactory)
|
|
474
474
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
475
|
-
const s =
|
|
475
|
+
const s = wn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
476
476
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
477
477
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
478
|
-
},
|
|
478
|
+
}, vs), n.addEventListener("open", () => {
|
|
479
479
|
this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
|
|
480
480
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
481
481
|
isThinking: this.state.isThinking
|
|
@@ -487,9 +487,9 @@ class Ue {
|
|
|
487
487
|
pageUrl: location.href
|
|
488
488
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
489
489
|
this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
490
|
-
},
|
|
490
|
+
}, Ns));
|
|
491
491
|
}), n.addEventListener("message", (r) => {
|
|
492
|
-
this.socket === n && this.handleServerEvent(
|
|
492
|
+
this.socket === n && this.handleServerEvent(Pn(r.data));
|
|
493
493
|
}), n.addEventListener("close", (r) => {
|
|
494
494
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
495
495
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -522,7 +522,7 @@ class Ue {
|
|
|
522
522
|
this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWarmupEvent = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
523
523
|
}
|
|
524
524
|
destroy() {
|
|
525
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
525
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Cr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
526
526
|
for (const t of Object.values(this.listeners))
|
|
527
527
|
t?.clear();
|
|
528
528
|
}
|
|
@@ -532,21 +532,21 @@ class Ue {
|
|
|
532
532
|
reason: t,
|
|
533
533
|
entrySurface: this.options.entrySurface,
|
|
534
534
|
sessionId: this.state.sessionId ?? void 0,
|
|
535
|
-
page:
|
|
535
|
+
page: b()
|
|
536
536
|
};
|
|
537
537
|
this.sendNow(s) || (this.pendingWarmupEvent = s);
|
|
538
538
|
}
|
|
539
539
|
async sendMessage(t, s = {}) {
|
|
540
540
|
const n = t.trim(), r = s.attachments ?? [];
|
|
541
|
-
if (!this.options.persistAttachmentUpload && (r.forEach(
|
|
541
|
+
if (!this.options.persistAttachmentUpload && (r.forEach(Ke), r.reduce(
|
|
542
542
|
(g, A) => g + A.sizeBytes,
|
|
543
543
|
0
|
|
544
|
-
) >
|
|
544
|
+
) > Ce))
|
|
545
545
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
546
|
-
let i = r.map(
|
|
546
|
+
let i = r.map(Yt);
|
|
547
547
|
if (!n && i.length === 0)
|
|
548
548
|
return null;
|
|
549
|
-
const o =
|
|
549
|
+
const o = b(), a = s.clientMessageId ?? j(), c = {
|
|
550
550
|
id: `local-${a}`,
|
|
551
551
|
role: "user",
|
|
552
552
|
content: n,
|
|
@@ -597,14 +597,14 @@ class Ue {
|
|
|
597
597
|
sessionId: this.state.sessionId ?? void 0,
|
|
598
598
|
clientMessageId: a,
|
|
599
599
|
initiatedBy: s.initiatedBy,
|
|
600
|
-
invocation:
|
|
600
|
+
invocation: In(s.invocation ?? s.initiatedBy),
|
|
601
601
|
entrySurface: this.options.entrySurface,
|
|
602
602
|
content: n,
|
|
603
|
-
pageContent: u &&
|
|
603
|
+
pageContent: u && Xt() || void 0,
|
|
604
604
|
attachments: i.length > 0 ? i : void 0,
|
|
605
605
|
page: o,
|
|
606
606
|
model: this.options.model,
|
|
607
|
-
metadata:
|
|
607
|
+
metadata: ge(this.options.metadata)
|
|
608
608
|
};
|
|
609
609
|
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.browserConnectionInterruptedClientMessageIds.delete(a), this.markThinkingProgress(), this.send(d), a;
|
|
610
610
|
}
|
|
@@ -613,22 +613,22 @@ class Ue {
|
|
|
613
613
|
return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(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);
|
|
614
614
|
}
|
|
615
615
|
createLocalAttachment(t) {
|
|
616
|
-
this.options.persistAttachmentUpload ||
|
|
616
|
+
this.options.persistAttachmentUpload || Pr(t);
|
|
617
617
|
const s = j(), n = {
|
|
618
618
|
id: s,
|
|
619
619
|
name: t.name || "attachment",
|
|
620
|
-
mimeType:
|
|
620
|
+
mimeType: Ft(t),
|
|
621
621
|
sizeBytes: t.size
|
|
622
622
|
};
|
|
623
623
|
this.attachmentFiles.set(s, t);
|
|
624
624
|
const r = Date.now();
|
|
625
|
-
return
|
|
625
|
+
return rs({
|
|
626
626
|
attachmentId: s,
|
|
627
627
|
name: n.name,
|
|
628
628
|
mimeType: n.mimeType,
|
|
629
629
|
sizeBytes: n.sizeBytes,
|
|
630
630
|
blob: t,
|
|
631
|
-
origin:
|
|
631
|
+
origin: b().origin,
|
|
632
632
|
sessionId: this.state.sessionId ?? void 0,
|
|
633
633
|
createdAt: r,
|
|
634
634
|
lastUsedAt: r
|
|
@@ -651,7 +651,7 @@ class Ue {
|
|
|
651
651
|
file: t,
|
|
652
652
|
attachment: s
|
|
653
653
|
}) {
|
|
654
|
-
const n = this.state.sessionId, r =
|
|
654
|
+
const n = this.state.sessionId, r = Ft(t), i = {
|
|
655
655
|
sessionId: n ?? void 0,
|
|
656
656
|
attachmentId: s.id,
|
|
657
657
|
clientId: this.options.clientId,
|
|
@@ -659,36 +659,36 @@ class Ue {
|
|
|
659
659
|
name: t.name || "attachment",
|
|
660
660
|
mimeType: r,
|
|
661
661
|
sizeBytes: t.size,
|
|
662
|
-
page:
|
|
662
|
+
page: b(),
|
|
663
663
|
model: this.options.model,
|
|
664
|
-
metadata:
|
|
664
|
+
metadata: ge(this.options.metadata),
|
|
665
665
|
entrySurface: this.options.entrySurface
|
|
666
666
|
};
|
|
667
667
|
let o;
|
|
668
668
|
if (this.options.persistAttachmentUpload)
|
|
669
|
-
o = await
|
|
669
|
+
o = await rt(
|
|
670
670
|
() => this.options.persistAttachmentUpload(i, t),
|
|
671
671
|
"Failed to upload attachment"
|
|
672
672
|
);
|
|
673
673
|
else {
|
|
674
|
-
const c = this.options.prepareAttachmentUpload ? await
|
|
674
|
+
const c = this.options.prepareAttachmentUpload ? await rt(
|
|
675
675
|
() => this.options.prepareAttachmentUpload(i),
|
|
676
676
|
"Failed to prepare attachment upload"
|
|
677
677
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
678
|
-
await
|
|
678
|
+
await rt(async () => {
|
|
679
679
|
const l = await fetch(new URL(c.uploadUrl, this.options.backendUrl), {
|
|
680
680
|
method: c.uploadMethod,
|
|
681
681
|
headers: c.uploadHeaders,
|
|
682
682
|
body: t
|
|
683
683
|
});
|
|
684
684
|
if (!l.ok)
|
|
685
|
-
throw new
|
|
685
|
+
throw new at("Failed to upload attachment", l.status);
|
|
686
686
|
return l;
|
|
687
687
|
}, "Failed to upload attachment"), o = c;
|
|
688
688
|
}
|
|
689
689
|
this.setState({ sessionId: o.sessionId });
|
|
690
|
-
const a =
|
|
691
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
690
|
+
const a = ze(o.attachment, this.options.backendUrl);
|
|
691
|
+
return this.updateAttachmentInState(s.id, a), s.id && is(s.id, {
|
|
692
692
|
sessionId: o.sessionId,
|
|
693
693
|
fileUrl: a.fileUrl,
|
|
694
694
|
sandboxPath: a.sandboxPath,
|
|
@@ -715,18 +715,18 @@ class Ue {
|
|
|
715
715
|
}
|
|
716
716
|
async prepareEmbedAttachmentUpload(t) {
|
|
717
717
|
let s = !1;
|
|
718
|
-
return await
|
|
718
|
+
return await rt(async () => {
|
|
719
719
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
720
720
|
if (n.ok)
|
|
721
721
|
return await n.json();
|
|
722
|
-
if (
|
|
722
|
+
if (Gr(n.status) && this.options.tokenProvider && !s) {
|
|
723
723
|
s = !0;
|
|
724
724
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
725
725
|
if (r.ok)
|
|
726
726
|
return await r.json();
|
|
727
|
-
throw new
|
|
727
|
+
throw new at("Failed to prepare attachment upload", r.status);
|
|
728
728
|
}
|
|
729
|
-
throw new
|
|
729
|
+
throw new at("Failed to prepare attachment upload", n.status);
|
|
730
730
|
}, "Failed to prepare attachment upload");
|
|
731
731
|
}
|
|
732
732
|
async fetchEmbedAttachmentUpload(t) {
|
|
@@ -741,14 +741,30 @@ class Ue {
|
|
|
741
741
|
});
|
|
742
742
|
}
|
|
743
743
|
stop() {
|
|
744
|
-
|
|
744
|
+
if (!this.state.sessionId)
|
|
745
|
+
return;
|
|
746
|
+
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
747
|
+
const t = hr(
|
|
748
|
+
this.state.messages,
|
|
749
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
750
|
+
this.state.assistantDraftRunId,
|
|
751
|
+
this.activeClientMessageId
|
|
752
|
+
);
|
|
753
|
+
this.setState({
|
|
754
|
+
messages: nt(
|
|
755
|
+
this.state.messages,
|
|
756
|
+
t.clientMessageId,
|
|
757
|
+
t.runId
|
|
758
|
+
),
|
|
759
|
+
isThinking: !1
|
|
760
|
+
}), this.clearThinkingWatchdog();
|
|
745
761
|
}
|
|
746
762
|
startNewSession(t = {}) {
|
|
747
763
|
const s = t.notifyTransport !== !1;
|
|
748
764
|
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
|
|
749
765
|
type: "session.reset",
|
|
750
766
|
sessionId: this.state.sessionId ?? void 0,
|
|
751
|
-
page:
|
|
767
|
+
page: b()
|
|
752
768
|
}), this.setState({
|
|
753
769
|
sessionId: null,
|
|
754
770
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -766,12 +782,12 @@ class Ue {
|
|
|
766
782
|
const s = j(), n = new Promise((i, o) => {
|
|
767
783
|
const a = window.setTimeout(() => {
|
|
768
784
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
769
|
-
},
|
|
785
|
+
}, pe);
|
|
770
786
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
771
787
|
}), r = {
|
|
772
788
|
type: "sessions.list",
|
|
773
789
|
requestId: s,
|
|
774
|
-
page:
|
|
790
|
+
page: b(),
|
|
775
791
|
...t.cursor ? { cursor: t.cursor } : {},
|
|
776
792
|
...t.limit ? { limit: t.limit } : {},
|
|
777
793
|
...typeof t.pinned == "boolean" ? { pinned: t.pinned } : {}
|
|
@@ -810,11 +826,11 @@ class Ue {
|
|
|
810
826
|
}), this.send({
|
|
811
827
|
type: "session.load",
|
|
812
828
|
sessionId: t,
|
|
813
|
-
page:
|
|
829
|
+
page: b()
|
|
814
830
|
});
|
|
815
831
|
}
|
|
816
832
|
send(t) {
|
|
817
|
-
this.sendNow(_(t)) || (this.queuedClientEvents.push(t),
|
|
833
|
+
this.sendNow(_(t)) || (this.queuedClientEvents.push(t), z(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
818
834
|
}
|
|
819
835
|
async getUploadToken() {
|
|
820
836
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -827,7 +843,7 @@ class Ue {
|
|
|
827
843
|
return !1;
|
|
828
844
|
const s = this.socket;
|
|
829
845
|
try {
|
|
830
|
-
return s.send(JSON.stringify(t)),
|
|
846
|
+
return s.send(JSON.stringify(t)), bt("client_event", t.type, le(t)), !0;
|
|
831
847
|
} catch (n) {
|
|
832
848
|
return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
833
849
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -840,7 +856,7 @@ class Ue {
|
|
|
840
856
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
841
857
|
return;
|
|
842
858
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
843
|
-
const t =
|
|
859
|
+
const t = Sn();
|
|
844
860
|
this.sendNow(
|
|
845
861
|
_({
|
|
846
862
|
type: "starter_prompts.page_context",
|
|
@@ -851,13 +867,13 @@ class Ue {
|
|
|
851
867
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
852
868
|
}
|
|
853
869
|
startStarterPromptUrlWatcher() {
|
|
854
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
870
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = An(() => this.handleStarterPromptUrlChange()));
|
|
855
871
|
}
|
|
856
872
|
handleStarterPromptUrlChange() {
|
|
857
873
|
const t = location.href;
|
|
858
874
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
859
875
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
860
|
-
},
|
|
876
|
+
}, Xs));
|
|
861
877
|
}
|
|
862
878
|
refreshStarterPromptsForCurrentUrl() {
|
|
863
879
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -872,27 +888,27 @@ class Ue {
|
|
|
872
888
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
873
889
|
return;
|
|
874
890
|
const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
875
|
-
|
|
891
|
+
z(this.options.clientId, this.queuedClientEvents);
|
|
876
892
|
for (let s = 0; s < t.length; s += 1) {
|
|
877
893
|
const n = t[s];
|
|
878
894
|
if (!this.sendNow(_(n))) {
|
|
879
|
-
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)),
|
|
895
|
+
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), z(this.options.clientId, this.queuedClientEvents);
|
|
880
896
|
return;
|
|
881
897
|
}
|
|
882
|
-
|
|
898
|
+
z(this.options.clientId, this.queuedClientEvents);
|
|
883
899
|
}
|
|
884
900
|
}
|
|
885
901
|
flushPendingWarmupEvent() {
|
|
886
902
|
!this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
|
|
887
903
|
}
|
|
888
904
|
handleServerEvent(t) {
|
|
889
|
-
if (
|
|
890
|
-
const s =
|
|
905
|
+
if (bt("server_event", t.type, le(t)), t.type === "run.ack") {
|
|
906
|
+
const s = Ct(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
|
|
891
907
|
s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && n === this.activeClientMessageId && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(t);
|
|
892
908
|
return;
|
|
893
909
|
}
|
|
894
910
|
if (t.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
895
|
-
const s =
|
|
911
|
+
const s = Ct(t);
|
|
896
912
|
if (s) {
|
|
897
913
|
this.deferredSessionUpdatedSessionIds.add(s);
|
|
898
914
|
return;
|
|
@@ -907,42 +923,42 @@ class Ue {
|
|
|
907
923
|
this.clearHeartbeatAckTimer();
|
|
908
924
|
return;
|
|
909
925
|
}
|
|
910
|
-
if (
|
|
926
|
+
if (Qs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
911
927
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
|
|
912
|
-
const s =
|
|
928
|
+
const s = Dn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
913
929
|
S("web-sdk.agent", "Received auth.ok appearance", {
|
|
914
930
|
hasAppearance: n,
|
|
915
931
|
rawAppearance: t.appearance,
|
|
916
932
|
normalizedAppearance: s
|
|
917
|
-
}), this.runtimeHelperJavascript =
|
|
918
|
-
const r =
|
|
919
|
-
user:
|
|
933
|
+
}), this.runtimeHelperJavascript = vn(t.runtimeHelpers)?.javascript ?? null;
|
|
934
|
+
const r = Ie(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
935
|
+
user: Ln(t.user),
|
|
920
936
|
status: "connected",
|
|
921
937
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
922
938
|
};
|
|
923
|
-
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !
|
|
939
|
+
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !Rn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
924
940
|
type: "page.upsert",
|
|
925
941
|
sessionId: this.state.sessionId,
|
|
926
|
-
page:
|
|
942
|
+
page: b(),
|
|
927
943
|
model: this.options.model
|
|
928
944
|
});
|
|
929
945
|
return;
|
|
930
946
|
}
|
|
931
947
|
if (t.type === "starterPrompts.updated") {
|
|
932
948
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
933
|
-
starterPrompts:
|
|
949
|
+
starterPrompts: Ie(t, "starterPrompts"),
|
|
934
950
|
starterPromptsLoading: !1
|
|
935
951
|
});
|
|
936
952
|
return;
|
|
937
953
|
}
|
|
938
954
|
if (t.type === "conversation.state") {
|
|
939
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
955
|
+
const s = Array.isArray(t.items) ? t.items : [], n = zn(
|
|
940
956
|
t.assistantDraft
|
|
941
957
|
), r = n !== void 0;
|
|
942
958
|
this.rememberUserMessageClientMessageIds(s);
|
|
943
|
-
const i =
|
|
959
|
+
const i = ar(s);
|
|
944
960
|
if (i) {
|
|
945
|
-
const p =
|
|
961
|
+
const p = cr(s, i);
|
|
946
962
|
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
947
963
|
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
948
964
|
p
|
|
@@ -950,23 +966,23 @@ class Ue {
|
|
|
950
966
|
}
|
|
951
967
|
const o = s.filter((p) => {
|
|
952
968
|
const g = B(p);
|
|
953
|
-
return
|
|
954
|
-
}), a =
|
|
969
|
+
return we(g) ? !1 : !g || !i || !Bt(g) ? !0 : Ht(s, g) !== i;
|
|
970
|
+
}), a = tr(
|
|
955
971
|
this.state.messages,
|
|
956
|
-
|
|
957
|
-
), c =
|
|
958
|
-
(p) =>
|
|
972
|
+
Bn(o, this.options.backendUrl)
|
|
973
|
+
), c = Te(a), l = !r && s.some(
|
|
974
|
+
(p) => Se(
|
|
959
975
|
B(p),
|
|
960
976
|
this.state.assistantDraft,
|
|
961
977
|
this.state.assistantDraftItemId,
|
|
962
978
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
963
979
|
this.state.assistantDraftRunId
|
|
964
980
|
)
|
|
965
|
-
), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), m =
|
|
966
|
-
if (!c &&
|
|
981
|
+
), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), m = rr(a), u = I && m;
|
|
982
|
+
if (!c && or(this.state.messages, s))
|
|
967
983
|
return;
|
|
968
|
-
this.lastUserMessagePageUrl =
|
|
969
|
-
const d = I ? null :
|
|
984
|
+
this.lastUserMessagePageUrl = ir(s);
|
|
985
|
+
const d = I ? null : qt(s);
|
|
970
986
|
if (this.latestRecoverableClientMessageId = d, m && this.clearRetryTimers(), this.setState({
|
|
971
987
|
sessionId: R(t.session, "id") ?? this.state.sessionId,
|
|
972
988
|
messages: a,
|
|
@@ -1007,7 +1023,7 @@ class Ue {
|
|
|
1007
1023
|
if (t.type === "sessions.page") {
|
|
1008
1024
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1009
1025
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1010
|
-
sessions:
|
|
1026
|
+
sessions: qn(t.sessions),
|
|
1011
1027
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
1012
1028
|
}));
|
|
1013
1029
|
return;
|
|
@@ -1027,9 +1043,9 @@ class Ue {
|
|
|
1027
1043
|
if (t.type === "session.item") {
|
|
1028
1044
|
this.rememberUserMessageClientMessageIds([t.item]);
|
|
1029
1045
|
const s = B(t.item);
|
|
1030
|
-
if (
|
|
1046
|
+
if (Bt(s)) {
|
|
1031
1047
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1032
|
-
const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ?
|
|
1048
|
+
const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1033
1049
|
if (r && a) {
|
|
1034
1050
|
this.retryAfterInterruptedRun(r, a);
|
|
1035
1051
|
return;
|
|
@@ -1039,15 +1055,15 @@ class Ue {
|
|
|
1039
1055
|
return;
|
|
1040
1056
|
}
|
|
1041
1057
|
}
|
|
1042
|
-
if (
|
|
1058
|
+
if (we(s))
|
|
1043
1059
|
return;
|
|
1044
|
-
const n =
|
|
1060
|
+
const n = Le(t.item, this.options.backendUrl);
|
|
1045
1061
|
if (n) {
|
|
1046
1062
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1047
1063
|
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), O(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1048
1064
|
const i = t.item.data;
|
|
1049
|
-
|
|
1050
|
-
const o =
|
|
1065
|
+
ur(i) && this.clearRunAckResyncRetryTimer();
|
|
1066
|
+
const o = xt(this.state.messages, n), a = Te(o), c = Se(
|
|
1051
1067
|
i,
|
|
1052
1068
|
this.state.assistantDraft,
|
|
1053
1069
|
this.state.assistantDraftItemId,
|
|
@@ -1080,7 +1096,7 @@ class Ue {
|
|
|
1080
1096
|
this.clearRunAckResyncRetryTimer();
|
|
1081
1097
|
const s = typeof t.delta == "string" ? t.delta : "", n = typeof t.itemId == "string" ? t.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((f) => f.id === o), c = t.phase === "commentary" || t.phase === "final_answer" ? t.phase : r ? null : this.state.assistantDraftPhase, l = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
|
|
1082
1098
|
this.setState({
|
|
1083
|
-
messages:
|
|
1099
|
+
messages: xt(this.state.messages, {
|
|
1084
1100
|
id: o,
|
|
1085
1101
|
role: "assistant",
|
|
1086
1102
|
content: i,
|
|
@@ -1106,9 +1122,9 @@ class Ue {
|
|
|
1106
1122
|
const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null, r = typeof t.runId == "string" ? t.runId : null;
|
|
1107
1123
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1108
1124
|
return;
|
|
1109
|
-
const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c =
|
|
1125
|
+
const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = hs(
|
|
1110
1126
|
this.state.messages.filter(
|
|
1111
|
-
(l) => l.dataType !== "assistant_draft" || !
|
|
1127
|
+
(l) => l.dataType !== "assistant_draft" || !Xn(
|
|
1112
1128
|
l,
|
|
1113
1129
|
n,
|
|
1114
1130
|
r
|
|
@@ -1116,11 +1132,11 @@ class Ue {
|
|
|
1116
1132
|
),
|
|
1117
1133
|
n,
|
|
1118
1134
|
r,
|
|
1119
|
-
|
|
1135
|
+
Be
|
|
1120
1136
|
);
|
|
1121
1137
|
this.setState({
|
|
1122
1138
|
sessionId: s,
|
|
1123
|
-
messages:
|
|
1139
|
+
messages: Jn(
|
|
1124
1140
|
c,
|
|
1125
1141
|
typeof t.responseId == "string" ? t.responseId : null,
|
|
1126
1142
|
n,
|
|
@@ -1141,9 +1157,9 @@ class Ue {
|
|
|
1141
1157
|
if (s)
|
|
1142
1158
|
this.nonTranscriptToolCallIds.add(s);
|
|
1143
1159
|
else {
|
|
1144
|
-
const n =
|
|
1160
|
+
const n = Zn(t);
|
|
1145
1161
|
if (n) {
|
|
1146
|
-
const r =
|
|
1162
|
+
const r = Vn(
|
|
1147
1163
|
this.state.messages,
|
|
1148
1164
|
n
|
|
1149
1165
|
);
|
|
@@ -1187,8 +1203,13 @@ class Ue {
|
|
|
1187
1203
|
return;
|
|
1188
1204
|
}
|
|
1189
1205
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1190
|
-
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c =
|
|
1206
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = Tn(a.message);
|
|
1191
1207
|
c && console.error(c), this.setState({
|
|
1208
|
+
messages: nt(
|
|
1209
|
+
this.state.messages,
|
|
1210
|
+
i ?? this.activeClientMessageId,
|
|
1211
|
+
typeof t.runId == "string" ? t.runId : null
|
|
1212
|
+
),
|
|
1192
1213
|
status: "error",
|
|
1193
1214
|
isThinking: !1,
|
|
1194
1215
|
lastError: a.message,
|
|
@@ -1199,9 +1220,9 @@ class Ue {
|
|
|
1199
1220
|
}
|
|
1200
1221
|
}
|
|
1201
1222
|
shouldIgnoreBackgroundSessionEvent(t) {
|
|
1202
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1223
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !tn(t))
|
|
1203
1224
|
return !1;
|
|
1204
|
-
const s =
|
|
1225
|
+
const s = Ct(t);
|
|
1205
1226
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1206
1227
|
}
|
|
1207
1228
|
rememberCurrentRunAsBackground() {
|
|
@@ -1223,10 +1244,10 @@ class Ue {
|
|
|
1223
1244
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1224
1245
|
return !0;
|
|
1225
1246
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1226
|
-
if (i >=
|
|
1247
|
+
if (i >= Q)
|
|
1227
1248
|
return !1;
|
|
1228
1249
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1229
|
-
const o =
|
|
1250
|
+
const o = tt(
|
|
1230
1251
|
i,
|
|
1231
1252
|
typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
|
|
1232
1253
|
);
|
|
@@ -1243,8 +1264,13 @@ class Ue {
|
|
|
1243
1264
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1244
1265
|
return;
|
|
1245
1266
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1246
|
-
if (n >=
|
|
1267
|
+
if (n >= Q) {
|
|
1247
1268
|
this.retryableClientMessageId = s, this.setState({
|
|
1269
|
+
messages: nt(
|
|
1270
|
+
this.state.messages,
|
|
1271
|
+
s,
|
|
1272
|
+
null
|
|
1273
|
+
),
|
|
1248
1274
|
isThinking: !1,
|
|
1249
1275
|
lastError: this.getRunRecoveryExhaustedErrorMessage(s),
|
|
1250
1276
|
lastErrorCode: "run_recovery_exhausted"
|
|
@@ -1253,7 +1279,7 @@ class Ue {
|
|
|
1253
1279
|
}
|
|
1254
1280
|
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(() => {
|
|
1255
1281
|
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 });
|
|
1256
|
-
},
|
|
1282
|
+
}, tt(n));
|
|
1257
1283
|
}
|
|
1258
1284
|
clearRetryTimers() {
|
|
1259
1285
|
for (const t of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1275,7 +1301,7 @@ class Ue {
|
|
|
1275
1301
|
const r = new Promise((i, o) => {
|
|
1276
1302
|
const a = window.setTimeout(() => {
|
|
1277
1303
|
t.delete(s.requestId), o(new Error(n));
|
|
1278
|
-
},
|
|
1304
|
+
}, pe);
|
|
1279
1305
|
t.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1280
1306
|
});
|
|
1281
1307
|
if (!this.sendNow(s)) {
|
|
@@ -1298,7 +1324,7 @@ class Ue {
|
|
|
1298
1324
|
t.clear();
|
|
1299
1325
|
}
|
|
1300
1326
|
markThinkingProgress() {
|
|
1301
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1327
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(he), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1302
1328
|
}
|
|
1303
1329
|
scheduleThinkingWatchdog(t) {
|
|
1304
1330
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1318,7 +1344,7 @@ class Ue {
|
|
|
1318
1344
|
handleRunSteered(t) {
|
|
1319
1345
|
const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
|
|
1320
1346
|
!this.state.isThinking || !s || this.setState({
|
|
1321
|
-
messages:
|
|
1347
|
+
messages: fr(
|
|
1322
1348
|
this.state.messages,
|
|
1323
1349
|
s
|
|
1324
1350
|
)
|
|
@@ -1327,7 +1353,7 @@ class Ue {
|
|
|
1327
1353
|
scheduleRunAckWatchdog(t) {
|
|
1328
1354
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1329
1355
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1330
|
-
},
|
|
1356
|
+
}, qs);
|
|
1331
1357
|
}
|
|
1332
1358
|
recoverMissedRunAck(t) {
|
|
1333
1359
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1338,7 +1364,7 @@ class Ue {
|
|
|
1338
1364
|
scheduleRunAckResyncRetry(t) {
|
|
1339
1365
|
this.clearRunAckResyncRetryTimer();
|
|
1340
1366
|
const s = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1341
|
-
s >=
|
|
1367
|
+
s >= Q || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1342
1368
|
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({
|
|
1343
1369
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1344
1370
|
isThinking: !0,
|
|
@@ -1351,8 +1377,8 @@ class Ue {
|
|
|
1351
1377
|
sessionId: this.state.sessionId,
|
|
1352
1378
|
clientMessageId: t,
|
|
1353
1379
|
automatic: !0
|
|
1354
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1355
|
-
},
|
|
1380
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(he)));
|
|
1381
|
+
}, tt(s, Hs)));
|
|
1356
1382
|
}
|
|
1357
1383
|
clearRunAckResyncRetryTimer() {
|
|
1358
1384
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1375,11 +1401,16 @@ class Ue {
|
|
|
1375
1401
|
return;
|
|
1376
1402
|
}
|
|
1377
1403
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1378
|
-
if (n >=
|
|
1404
|
+
if (n >= Q) {
|
|
1379
1405
|
S("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1380
1406
|
sessionId: this.state.sessionId,
|
|
1381
1407
|
clientMessageId: t
|
|
1382
1408
|
}), this.retryableClientMessageId = t, this.setState({
|
|
1409
|
+
messages: nt(
|
|
1410
|
+
this.state.messages,
|
|
1411
|
+
t,
|
|
1412
|
+
null
|
|
1413
|
+
),
|
|
1383
1414
|
isThinking: !1,
|
|
1384
1415
|
lastError: this.getRunRecoveryExhaustedErrorMessage(t),
|
|
1385
1416
|
lastErrorCode: "run_recovery_exhausted"
|
|
@@ -1391,7 +1422,7 @@ class Ue {
|
|
|
1391
1422
|
sessionId: this.state.sessionId,
|
|
1392
1423
|
clientMessageId: t,
|
|
1393
1424
|
resyncAttempts: s + 1
|
|
1394
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1425
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(xs);
|
|
1395
1426
|
return;
|
|
1396
1427
|
}
|
|
1397
1428
|
this.setState({
|
|
@@ -1409,13 +1440,13 @@ class Ue {
|
|
|
1409
1440
|
clientMessageId: t,
|
|
1410
1441
|
automatic: !0
|
|
1411
1442
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1412
|
-
},
|
|
1443
|
+
}, tt(n)));
|
|
1413
1444
|
}
|
|
1414
1445
|
resyncThinkingSession() {
|
|
1415
1446
|
this.state.sessionId ? this.send({
|
|
1416
1447
|
type: "page.upsert",
|
|
1417
1448
|
sessionId: this.state.sessionId,
|
|
1418
|
-
page:
|
|
1449
|
+
page: b(),
|
|
1419
1450
|
model: this.options.model
|
|
1420
1451
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1421
1452
|
}
|
|
@@ -1426,7 +1457,7 @@ class Ue {
|
|
|
1426
1457
|
if (!s || !n || !r)
|
|
1427
1458
|
return;
|
|
1428
1459
|
const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1429
|
-
if (!a && !c || !
|
|
1460
|
+
if (!a && !c || !Or(o)) {
|
|
1430
1461
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1431
1462
|
type: "tool.result",
|
|
1432
1463
|
sessionId: s,
|
|
@@ -1473,9 +1504,9 @@ class Ue {
|
|
|
1473
1504
|
startedAtOrigin: location.origin
|
|
1474
1505
|
}), this.installSessionBrowserApis();
|
|
1475
1506
|
let l = null, h;
|
|
1476
|
-
l = await this.executeRuntimeHelper(), h = await
|
|
1507
|
+
l = await this.executeRuntimeHelper(), h = await me(
|
|
1477
1508
|
o,
|
|
1478
|
-
|
|
1509
|
+
fn(t.runtimeContext, this.options.backendUrl)
|
|
1479
1510
|
).catch((f) => ({
|
|
1480
1511
|
ok: !1,
|
|
1481
1512
|
exception: {
|
|
@@ -1488,11 +1519,11 @@ class Ue {
|
|
|
1488
1519
|
toolName: r,
|
|
1489
1520
|
summary: o.summary,
|
|
1490
1521
|
rawInput: _(o),
|
|
1491
|
-
rawOutput: _(
|
|
1492
|
-
}),
|
|
1522
|
+
rawOutput: _(Nn(h, l))
|
|
1523
|
+
}), Rr(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1493
1524
|
}
|
|
1494
1525
|
setToolMessageLoading(t, s) {
|
|
1495
|
-
const n =
|
|
1526
|
+
const n = Yn(
|
|
1496
1527
|
this.state.messages,
|
|
1497
1528
|
t,
|
|
1498
1529
|
s
|
|
@@ -1503,47 +1534,47 @@ class Ue {
|
|
|
1503
1534
|
if (this.pageLifecycleCleanup)
|
|
1504
1535
|
return;
|
|
1505
1536
|
const t = () => {
|
|
1506
|
-
|
|
1537
|
+
$e(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1507
1538
|
};
|
|
1508
1539
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1509
1540
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1510
1541
|
};
|
|
1511
1542
|
}
|
|
1512
1543
|
installSessionBrowserApis() {
|
|
1513
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
1544
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = nn();
|
|
1514
1545
|
}
|
|
1515
1546
|
cleanupSessionBrowserApis() {
|
|
1516
|
-
this.sessionBrowserApisCleanup && (
|
|
1547
|
+
this.sessionBrowserApisCleanup && (hn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
1517
1548
|
}
|
|
1518
1549
|
async executeRuntimeHelper() {
|
|
1519
1550
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1520
1551
|
return null;
|
|
1521
|
-
const t = await
|
|
1552
|
+
const t = await me({
|
|
1522
1553
|
javascript: this.runtimeHelperJavascript
|
|
1523
1554
|
});
|
|
1524
|
-
return t.ok === !1 ?
|
|
1555
|
+
return t.ok === !1 ? On(t) : null;
|
|
1525
1556
|
}
|
|
1526
1557
|
enableNetworkCapture() {
|
|
1527
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1528
|
-
|
|
1558
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = Ys((t) => {
|
|
1559
|
+
Wr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1529
1560
|
}));
|
|
1530
1561
|
}
|
|
1531
1562
|
enqueueNetworkEvent(t) {
|
|
1532
|
-
this.queuedNetworkEvents.length >=
|
|
1563
|
+
this.queuedNetworkEvents.length >= Fs || (this.queuedNetworkEvents.push(Hr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1533
1564
|
this.networkBatchTimer = null;
|
|
1534
1565
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1535
1566
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
1536
1567
|
type: "network.batch",
|
|
1537
1568
|
sessionId: this.state.sessionId ?? void 0,
|
|
1538
|
-
page:
|
|
1569
|
+
page: b(),
|
|
1539
1570
|
events: s
|
|
1540
1571
|
});
|
|
1541
|
-
},
|
|
1572
|
+
}, Ws)));
|
|
1542
1573
|
}
|
|
1543
1574
|
scheduleReconnect() {
|
|
1544
1575
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1545
1576
|
return;
|
|
1546
|
-
const t =
|
|
1577
|
+
const t = Js(this.reconnectAttempts);
|
|
1547
1578
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1548
1579
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1549
1580
|
S("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1559,8 +1590,8 @@ class Ue {
|
|
|
1559
1590
|
const t = this.socket;
|
|
1560
1591
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1561
1592
|
this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1562
|
-
},
|
|
1563
|
-
},
|
|
1593
|
+
}, Us));
|
|
1594
|
+
}, Ps);
|
|
1564
1595
|
}
|
|
1565
1596
|
stopHeartbeat() {
|
|
1566
1597
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1586,7 +1617,7 @@ class Ue {
|
|
|
1586
1617
|
...t,
|
|
1587
1618
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1588
1619
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1589
|
-
},
|
|
1620
|
+
}, Ar(this.options.clientId, this.state), this.emit("state", this.getState()), bt("state", this.state.status, {
|
|
1590
1621
|
status: this.state.status,
|
|
1591
1622
|
sessionId: this.state.sessionId,
|
|
1592
1623
|
messageCount: this.state.messages.length,
|
|
@@ -1603,20 +1634,20 @@ class Ue {
|
|
|
1603
1634
|
this.state.isThinking && this.activeClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId);
|
|
1604
1635
|
}
|
|
1605
1636
|
getRunRecoveryExhaustedErrorMessage(t) {
|
|
1606
|
-
return t && this.browserConnectionInterruptedClientMessageIds.has(t) ?
|
|
1637
|
+
return t && this.browserConnectionInterruptedClientMessageIds.has(t) ? Bs : Ls;
|
|
1607
1638
|
}
|
|
1608
1639
|
emit(t, s) {
|
|
1609
1640
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1610
1641
|
}
|
|
1611
1642
|
}
|
|
1612
|
-
const
|
|
1613
|
-
function
|
|
1614
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1643
|
+
const _t = /* @__PURE__ */ new WeakMap();
|
|
1644
|
+
function Ys(e) {
|
|
1645
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Zs();
|
|
1615
1646
|
return t.subscribers.add(e), () => {
|
|
1616
1647
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1617
1648
|
};
|
|
1618
1649
|
}
|
|
1619
|
-
function
|
|
1650
|
+
function Zs() {
|
|
1620
1651
|
const e = /* @__PURE__ */ new Set(), t = (I) => {
|
|
1621
1652
|
e.forEach((m) => {
|
|
1622
1653
|
try {
|
|
@@ -1633,22 +1664,22 @@ function Vs() {
|
|
|
1633
1664
|
throw g;
|
|
1634
1665
|
}
|
|
1635
1666
|
try {
|
|
1636
|
-
const g = m instanceof Request ? m : null, A =
|
|
1667
|
+
const g = m instanceof Request ? m : null, A = xr(m, g), T = Ge(u?.headers ?? g?.headers);
|
|
1637
1668
|
if (!x(A, T, u?.body)) {
|
|
1638
|
-
const
|
|
1639
|
-
requestId:
|
|
1640
|
-
url: P(A,
|
|
1669
|
+
const W = {
|
|
1670
|
+
requestId: Dt("fetch"),
|
|
1671
|
+
url: P(A, kt),
|
|
1641
1672
|
method: (u?.method ?? g?.method ?? "GET").toUpperCase(),
|
|
1642
1673
|
requestHeaders: T,
|
|
1643
|
-
requestBody:
|
|
1674
|
+
requestBody: Re(u?.body),
|
|
1644
1675
|
resourceType: "fetch",
|
|
1645
1676
|
startedAt: new Date(d).toISOString()
|
|
1646
1677
|
};
|
|
1647
1678
|
p.then(
|
|
1648
1679
|
(C) => {
|
|
1649
|
-
|
|
1680
|
+
Lr(C, W, d, t).catch(() => {
|
|
1650
1681
|
t({
|
|
1651
|
-
...
|
|
1682
|
+
...W,
|
|
1652
1683
|
responseStatus: C.status,
|
|
1653
1684
|
durationMs: Date.now() - d
|
|
1654
1685
|
});
|
|
@@ -1656,7 +1687,7 @@ function Vs() {
|
|
|
1656
1687
|
},
|
|
1657
1688
|
(C) => {
|
|
1658
1689
|
t({
|
|
1659
|
-
...
|
|
1690
|
+
...W,
|
|
1660
1691
|
errorText: P(C instanceof Error ? C.message : String(C)),
|
|
1661
1692
|
durationMs: Date.now() - d
|
|
1662
1693
|
});
|
|
@@ -1668,27 +1699,27 @@ function Vs() {
|
|
|
1668
1699
|
return p;
|
|
1669
1700
|
}, a = function(m, u, d, p, g) {
|
|
1670
1701
|
const A = n.call(this, m, u, d ?? !0, p ?? void 0, g ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
1671
|
-
return
|
|
1672
|
-
requestId:
|
|
1702
|
+
return _t.set(this, {
|
|
1703
|
+
requestId: Dt("xhr"),
|
|
1673
1704
|
method: String(m ?? "GET").toUpperCase(),
|
|
1674
|
-
url: P(T,
|
|
1705
|
+
url: P(T, kt),
|
|
1675
1706
|
requestHeaders: {},
|
|
1676
1707
|
startedAtMs: Date.now(),
|
|
1677
1708
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1678
1709
|
excluded: x(T)
|
|
1679
1710
|
}), A;
|
|
1680
1711
|
}, c = function(m, u) {
|
|
1681
|
-
const d = r.call(this, m, u), p =
|
|
1682
|
-
return p && Object.keys(p.requestHeaders).length <
|
|
1712
|
+
const d = r.call(this, m, u), p = _t.get(this);
|
|
1713
|
+
return p && Object.keys(p.requestHeaders).length < Gt && (p.requestHeaders[m] = Zt(m, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
|
|
1683
1714
|
}, l = function(m) {
|
|
1684
1715
|
try {
|
|
1685
|
-
const u =
|
|
1686
|
-
u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, m), u.requestBody =
|
|
1716
|
+
const u = _t.get(this);
|
|
1717
|
+
u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, m), u.requestBody = Re(m), u.excluded || this.addEventListener(
|
|
1687
1718
|
"loadend",
|
|
1688
1719
|
() => {
|
|
1689
1720
|
queueMicrotask(() => {
|
|
1690
1721
|
try {
|
|
1691
|
-
const d =
|
|
1722
|
+
const d = $r(this.getAllResponseHeaders());
|
|
1692
1723
|
t({
|
|
1693
1724
|
requestId: u.requestId,
|
|
1694
1725
|
url: u.url,
|
|
@@ -1698,7 +1729,7 @@ function Vs() {
|
|
|
1698
1729
|
resourceType: "xhr",
|
|
1699
1730
|
responseStatus: this.status,
|
|
1700
1731
|
responseHeaders: d,
|
|
1701
|
-
responseBody:
|
|
1732
|
+
responseBody: qr(this, d),
|
|
1702
1733
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1703
1734
|
startedAt: u.startedAt,
|
|
1704
1735
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -1739,8 +1770,8 @@ function Vs() {
|
|
|
1739
1770
|
continue;
|
|
1740
1771
|
const d = performance.timeOrigin + u.startTime;
|
|
1741
1772
|
t({
|
|
1742
|
-
requestId:
|
|
1743
|
-
url: P(u.name,
|
|
1773
|
+
requestId: Dt("resource"),
|
|
1774
|
+
url: P(u.name, kt),
|
|
1744
1775
|
method: "GET",
|
|
1745
1776
|
resourceType: "resource",
|
|
1746
1777
|
responseStatus: u.responseStatus,
|
|
@@ -1790,17 +1821,17 @@ function S(e, t, s) {
|
|
|
1790
1821
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1791
1822
|
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 }));
|
|
1792
1823
|
}
|
|
1793
|
-
function
|
|
1824
|
+
function ge(e) {
|
|
1794
1825
|
const t = typeof e == "function" ? e() : e;
|
|
1795
1826
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1796
1827
|
}
|
|
1797
|
-
function
|
|
1828
|
+
function Qs(e) {
|
|
1798
1829
|
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";
|
|
1799
1830
|
}
|
|
1800
|
-
function
|
|
1831
|
+
function tn(e) {
|
|
1801
1832
|
return e.type === "run.steered" || e.type === "run.ack" || 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" || e.type === "tool.status" || e.type === "error" && typeof e.requestId != "string";
|
|
1802
1833
|
}
|
|
1803
|
-
function
|
|
1834
|
+
function Ct(e) {
|
|
1804
1835
|
if (typeof e.sessionId == "string")
|
|
1805
1836
|
return e.sessionId;
|
|
1806
1837
|
if (e.session && typeof e.session == "object") {
|
|
@@ -1815,31 +1846,31 @@ function kt(e) {
|
|
|
1815
1846
|
}
|
|
1816
1847
|
return null;
|
|
1817
1848
|
}
|
|
1818
|
-
const
|
|
1819
|
-
function
|
|
1849
|
+
const en = 5e3, sn = 12e4;
|
|
1850
|
+
function nn() {
|
|
1820
1851
|
const e = [
|
|
1821
|
-
|
|
1822
|
-
|
|
1852
|
+
on(),
|
|
1853
|
+
rn()
|
|
1823
1854
|
].filter((t) => typeof t == "function");
|
|
1824
1855
|
return () => {
|
|
1825
1856
|
for (const t of e.reverse())
|
|
1826
1857
|
t();
|
|
1827
1858
|
};
|
|
1828
1859
|
}
|
|
1829
|
-
function
|
|
1830
|
-
return be(globalThis, "getPageSnapshot", async () =>
|
|
1860
|
+
function rn() {
|
|
1861
|
+
return be(globalThis, "getPageSnapshot", async () => Xt());
|
|
1831
1862
|
}
|
|
1832
|
-
function
|
|
1863
|
+
function on() {
|
|
1833
1864
|
return be(globalThis, "pageImages", {
|
|
1834
|
-
inspectImage: async (t, s) => await
|
|
1865
|
+
inspectImage: async (t, s) => await an(t, s)
|
|
1835
1866
|
});
|
|
1836
1867
|
}
|
|
1837
|
-
async function
|
|
1838
|
-
const s =
|
|
1868
|
+
async function an(e, t = {}) {
|
|
1869
|
+
const s = dn(t.name), n = await cn(e);
|
|
1839
1870
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1840
1871
|
type: "pluno.pageImages.inspectImage",
|
|
1841
1872
|
imageAttached: !1,
|
|
1842
|
-
imageAttachmentError:
|
|
1873
|
+
imageAttachmentError: Pe
|
|
1843
1874
|
} : {
|
|
1844
1875
|
type: "pluno.pageImages.inspectImage",
|
|
1845
1876
|
imageAttached: !0,
|
|
@@ -1853,15 +1884,15 @@ async function rn(e, t = {}) {
|
|
|
1853
1884
|
imageAttachmentError: n.error
|
|
1854
1885
|
};
|
|
1855
1886
|
}
|
|
1856
|
-
async function
|
|
1857
|
-
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:
|
|
1887
|
+
async function cn(e) {
|
|
1888
|
+
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: Pe } : {
|
|
1858
1889
|
ok: !0,
|
|
1859
1890
|
mimeType: e.type,
|
|
1860
1891
|
sizeBytes: e.size,
|
|
1861
|
-
dataUrl: await
|
|
1862
|
-
} : { 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." } :
|
|
1892
|
+
dataUrl: await pn(e)
|
|
1893
|
+
} : { 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." } : ln(e);
|
|
1863
1894
|
}
|
|
1864
|
-
function
|
|
1895
|
+
function ln(e) {
|
|
1865
1896
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1866
1897
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1867
1898
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1872,7 +1903,7 @@ function an(e) {
|
|
|
1872
1903
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1873
1904
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1874
1905
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1875
|
-
const o =
|
|
1906
|
+
const o = un(i);
|
|
1876
1907
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1877
1908
|
ok: !0,
|
|
1878
1909
|
mimeType: r,
|
|
@@ -1880,22 +1911,22 @@ function an(e) {
|
|
|
1880
1911
|
dataUrl: `data:${r};base64,${i}`
|
|
1881
1912
|
};
|
|
1882
1913
|
}
|
|
1883
|
-
function
|
|
1914
|
+
function un(e) {
|
|
1884
1915
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1885
1916
|
return null;
|
|
1886
1917
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1887
1918
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1888
1919
|
}
|
|
1889
|
-
function
|
|
1920
|
+
function dn(e) {
|
|
1890
1921
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1891
1922
|
}
|
|
1892
|
-
function
|
|
1923
|
+
function hn(e) {
|
|
1893
1924
|
try {
|
|
1894
1925
|
e();
|
|
1895
1926
|
} catch {
|
|
1896
1927
|
}
|
|
1897
1928
|
}
|
|
1898
|
-
function
|
|
1929
|
+
function pn(e) {
|
|
1899
1930
|
return new Promise((t, s) => {
|
|
1900
1931
|
const n = new FileReader();
|
|
1901
1932
|
n.onload = () => {
|
|
@@ -1907,9 +1938,9 @@ function dn(e) {
|
|
|
1907
1938
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(e);
|
|
1908
1939
|
});
|
|
1909
1940
|
}
|
|
1910
|
-
async function
|
|
1941
|
+
async function me(e, t) {
|
|
1911
1942
|
const s = Object.getPrototypeOf(async function() {
|
|
1912
|
-
}).constructor, n = e.timeoutMs ??
|
|
1943
|
+
}).constructor, n = e.timeoutMs ?? en, r = Date.now(), i = [];
|
|
1913
1944
|
let o;
|
|
1914
1945
|
const a = {
|
|
1915
1946
|
log: console.log,
|
|
@@ -1927,7 +1958,7 @@ async function fe(e, t) {
|
|
|
1927
1958
|
o = window.setTimeout(() => f(l), n);
|
|
1928
1959
|
})
|
|
1929
1960
|
]);
|
|
1930
|
-
return h === l ?
|
|
1961
|
+
return h === l ? gn(n) : {
|
|
1931
1962
|
ok: !0,
|
|
1932
1963
|
result: h,
|
|
1933
1964
|
console: i,
|
|
@@ -1956,7 +1987,7 @@ async function fe(e, t) {
|
|
|
1956
1987
|
t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
1957
1988
|
}
|
|
1958
1989
|
}
|
|
1959
|
-
function
|
|
1990
|
+
function fn(e, t) {
|
|
1960
1991
|
if (!e || typeof e != "object")
|
|
1961
1992
|
return;
|
|
1962
1993
|
const s = e.sandboxFilesToken;
|
|
@@ -1966,7 +1997,7 @@ function hn(e, t) {
|
|
|
1966
1997
|
const r = () => {
|
|
1967
1998
|
if (!n)
|
|
1968
1999
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
1969
|
-
}, i = async (a, c) => await
|
|
2000
|
+
}, i = async (a, c) => await Es(`${t.replace(/\/$/, "")}${a}`, c);
|
|
1970
2001
|
return {
|
|
1971
2002
|
value: Object.freeze({
|
|
1972
2003
|
upload: async (a) => {
|
|
@@ -2000,7 +2031,7 @@ function hn(e, t) {
|
|
|
2000
2031
|
}
|
|
2001
2032
|
};
|
|
2002
2033
|
}
|
|
2003
|
-
function
|
|
2034
|
+
function gn(e) {
|
|
2004
2035
|
return {
|
|
2005
2036
|
ok: !1,
|
|
2006
2037
|
exception: {
|
|
@@ -2014,10 +2045,10 @@ function pn(e) {
|
|
|
2014
2045
|
}
|
|
2015
2046
|
};
|
|
2016
2047
|
}
|
|
2017
|
-
function
|
|
2048
|
+
function mn(e) {
|
|
2018
2049
|
return e.replace(/\/+$/, "");
|
|
2019
2050
|
}
|
|
2020
|
-
function
|
|
2051
|
+
function yn(e) {
|
|
2021
2052
|
const t = {
|
|
2022
2053
|
sidepanel: "extension_sidepanel",
|
|
2023
2054
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2029,18 +2060,18 @@ function gn(e) {
|
|
|
2029
2060
|
};
|
|
2030
2061
|
return e && e in t ? t[e] : e ?? "embedded_custom_ui";
|
|
2031
2062
|
}
|
|
2032
|
-
function
|
|
2063
|
+
function In(e) {
|
|
2033
2064
|
return e === "pluno" ? "scheduled_continuation" : e ?? "user";
|
|
2034
2065
|
}
|
|
2035
|
-
function
|
|
2066
|
+
function Tn(e, t = location.origin) {
|
|
2036
2067
|
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;
|
|
2037
2068
|
}
|
|
2038
|
-
function
|
|
2069
|
+
function wn(e) {
|
|
2039
2070
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
2040
2071
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
2041
2072
|
}
|
|
2042
|
-
function
|
|
2043
|
-
const e =
|
|
2073
|
+
function b() {
|
|
2074
|
+
const e = xe();
|
|
2044
2075
|
return {
|
|
2045
2076
|
url: location.href,
|
|
2046
2077
|
title: document.title,
|
|
@@ -2048,21 +2079,21 @@ function M() {
|
|
|
2048
2079
|
...e ? { plunoProductAgentUi: e } : {}
|
|
2049
2080
|
};
|
|
2050
2081
|
}
|
|
2051
|
-
function
|
|
2082
|
+
function Sn() {
|
|
2052
2083
|
return {
|
|
2053
2084
|
pageUrl: location.href,
|
|
2054
2085
|
pageTitle: document.title,
|
|
2055
|
-
htmlContent:
|
|
2086
|
+
htmlContent: Xt()
|
|
2056
2087
|
};
|
|
2057
2088
|
}
|
|
2058
|
-
function
|
|
2059
|
-
return
|
|
2060
|
-
|
|
2089
|
+
function An(e) {
|
|
2090
|
+
return ot.add(e), et || (et = En()), () => {
|
|
2091
|
+
ot.delete(e), ot.size === 0 && (et?.(), et = null);
|
|
2061
2092
|
};
|
|
2062
2093
|
}
|
|
2063
|
-
function
|
|
2094
|
+
function En() {
|
|
2064
2095
|
const e = () => {
|
|
2065
|
-
for (const i of Array.from(
|
|
2096
|
+
for (const i of Array.from(ot))
|
|
2066
2097
|
i();
|
|
2067
2098
|
}, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2068
2099
|
const o = t(...i);
|
|
@@ -2075,10 +2106,10 @@ function Sn() {
|
|
|
2075
2106
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
2076
2107
|
};
|
|
2077
2108
|
}
|
|
2078
|
-
function
|
|
2079
|
-
return
|
|
2109
|
+
function Rn() {
|
|
2110
|
+
return xe()?.surface === "browser_extension_sdk_preview";
|
|
2080
2111
|
}
|
|
2081
|
-
function
|
|
2112
|
+
function Xt() {
|
|
2082
2113
|
if (!document.body)
|
|
2083
2114
|
return "";
|
|
2084
2115
|
const e = [], t = [], s = (d, p) => {
|
|
@@ -2087,23 +2118,23 @@ function Kt() {
|
|
|
2087
2118
|
};
|
|
2088
2119
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2089
2120
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2090
|
-
(d) =>
|
|
2121
|
+
(d) => ve(d) && !d.parentElement?.closest(n)
|
|
2091
2122
|
);
|
|
2092
2123
|
for (const d of r.slice(0, 3))
|
|
2093
|
-
s("Active overlay",
|
|
2094
|
-
const i =
|
|
2095
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2124
|
+
s("Active overlay", Pt(K(d), t));
|
|
2125
|
+
const i = Mn(), o = i ? Pt(K(i), t) : "";
|
|
2126
|
+
s("Main page content", o), s("Additional visible page text", Pt(K(document.body), t));
|
|
2096
2127
|
const a = e.map(([d, p]) => `${d}:
|
|
2097
2128
|
${p}`).join(`
|
|
2098
2129
|
|
|
2099
|
-
`).trim().slice(0, 12e3), c =
|
|
2130
|
+
`).trim().slice(0, 12e3), c = bn(r, i).trim(), l = `Simplified DOM outline:
|
|
2100
2131
|
`, h = `
|
|
2101
2132
|
|
|
2102
2133
|
Visible page text:
|
|
2103
2134
|
`, f = 12e3 - l.length - h.length, I = Math.min(a.length, 7900), m = c.slice(0, f - I), u = a.slice(0, f - m.length);
|
|
2104
2135
|
return `${l}${m}${h}${u}`;
|
|
2105
2136
|
}
|
|
2106
|
-
function
|
|
2137
|
+
function K(e) {
|
|
2107
2138
|
return e.innerText ?? e.textContent ?? "";
|
|
2108
2139
|
}
|
|
2109
2140
|
function q(e) {
|
|
@@ -2114,20 +2145,20 @@ function q(e) {
|
|
|
2114
2145
|
|
|
2115
2146
|
`).trim();
|
|
2116
2147
|
}
|
|
2117
|
-
function
|
|
2148
|
+
function Pt(e, t) {
|
|
2118
2149
|
let s = q(e);
|
|
2119
2150
|
for (const n of t)
|
|
2120
2151
|
s = s.replace(n, "");
|
|
2121
2152
|
return q(s);
|
|
2122
2153
|
}
|
|
2123
|
-
function
|
|
2154
|
+
function ve(e) {
|
|
2124
2155
|
const t = window.getComputedStyle(e);
|
|
2125
2156
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
2126
2157
|
}
|
|
2127
|
-
function
|
|
2128
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2158
|
+
function Mn() {
|
|
2159
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(ve).sort((e, t) => K(t).length - K(e).length)[0] ?? null;
|
|
2129
2160
|
}
|
|
2130
|
-
function
|
|
2161
|
+
function bn(e, t) {
|
|
2131
2162
|
const s = /* @__PURE__ */ new Set([
|
|
2132
2163
|
"main",
|
|
2133
2164
|
"nav",
|
|
@@ -2207,7 +2238,7 @@ function Rn(e, t) {
|
|
|
2207
2238
|
"data-test",
|
|
2208
2239
|
"data-qa",
|
|
2209
2240
|
"data-cy"
|
|
2210
|
-
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } =
|
|
2241
|
+
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = kn(), I = new Set(e);
|
|
2211
2242
|
t && I.add(t);
|
|
2212
2243
|
let m = 0;
|
|
2213
2244
|
const u = (T) => {
|
|
@@ -2216,68 +2247,68 @@ function Rn(e, t) {
|
|
|
2216
2247
|
}, d = (T) => {
|
|
2217
2248
|
const D = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
|
|
2218
2249
|
return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
|
|
2219
|
-
}, p = (T, D,
|
|
2220
|
-
const C = (E,
|
|
2221
|
-
const
|
|
2222
|
-
if (m >= 1e3 && !
|
|
2250
|
+
}, p = (T, D, W) => {
|
|
2251
|
+
const C = (E, pt) => {
|
|
2252
|
+
const M = E.tagName.toLowerCase(), ft = window.getComputedStyle(E), J = h.has(E);
|
|
2253
|
+
if (m >= 1e3 && !J || W.has(E) || i.has(M) || E.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ft.display === "none" || ft.visibility === "hidden")
|
|
2223
2254
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2224
2255
|
m += 1;
|
|
2225
|
-
const
|
|
2226
|
-
for (const y of
|
|
2256
|
+
const Qt = u(E), V = Oe(E), es = a.has(Qt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(M) || M === "a" && E.hasAttribute("href"), gt = Array.from(E.children).filter((y) => y instanceof HTMLElement), Y = /* @__PURE__ */ new Map();
|
|
2257
|
+
for (const y of gt) {
|
|
2227
2258
|
const w = d(y);
|
|
2228
|
-
|
|
2259
|
+
Y.set(w, (Y.get(w) ?? 0) + 1);
|
|
2229
2260
|
}
|
|
2230
|
-
const
|
|
2231
|
-
for (const y of
|
|
2232
|
-
const w = d(y),
|
|
2233
|
-
|
|
2261
|
+
const mt = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Map();
|
|
2262
|
+
for (const y of gt) {
|
|
2263
|
+
const w = d(y), v = te.get(w) ?? 0;
|
|
2264
|
+
te.set(w, v + 1), (Y.get(w) ?? 0) > 8 && v >= 6 && !h.has(y) && mt.set(w, (mt.get(w) ?? 0) + 1);
|
|
2234
2265
|
}
|
|
2235
|
-
const
|
|
2236
|
-
for (const y of
|
|
2237
|
-
const w = d(y),
|
|
2238
|
-
if (
|
|
2239
|
-
|
|
2266
|
+
const ee = /* @__PURE__ */ new Map(), se = /* @__PURE__ */ new Set(), yt = [], ne = [];
|
|
2267
|
+
for (const y of gt) {
|
|
2268
|
+
const w = d(y), v = Y.get(w) ?? 0, oe = ee.get(w) ?? 0;
|
|
2269
|
+
if (ee.set(w, oe + 1), v > 8 && oe >= 6 && !h.has(y)) {
|
|
2270
|
+
se.has(w) || (yt.push([`… ${mt.get(w) ?? 0} similar siblings omitted`]), se.add(w));
|
|
2240
2271
|
continue;
|
|
2241
2272
|
}
|
|
2242
|
-
const
|
|
2243
|
-
|
|
2273
|
+
const ae = C(y, pt);
|
|
2274
|
+
ne.push(ae), yt.push(ae.lines);
|
|
2244
2275
|
}
|
|
2245
|
-
const
|
|
2276
|
+
const It = [];
|
|
2246
2277
|
if (E.shadowRoot)
|
|
2247
2278
|
for (const y of Array.from(E.shadowRoot.children))
|
|
2248
|
-
y instanceof HTMLElement &&
|
|
2249
|
-
const
|
|
2250
|
-
[
|
|
2251
|
-
).slice(0, 180),
|
|
2252
|
-
if (
|
|
2253
|
-
const y =
|
|
2254
|
-
|
|
2279
|
+
y instanceof HTMLElement && It.push(C(y, pt + 1));
|
|
2280
|
+
const Z = [...ne, ...It], Tt = V.length > 0 || es || Z.some((y) => y.hasUsefulContent), re = q(
|
|
2281
|
+
[V, ...Z.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2282
|
+
).slice(0, 180), ss = E.hasAttribute("contenteditable") && (V.length > 0 || !E.querySelector("[contenteditable]")), ie = l.some((y) => E.hasAttribute(y)) || !!Qt || ss, wt = (E.getClientRects().length > 0 || ft.display === "contents") && (s.has(M) || ie || J) && (Tt || J) && (!r.has(M) || Tt || ie || J), St = wt ? 1 : 0, F = [];
|
|
2283
|
+
if (wt) {
|
|
2284
|
+
const y = Z.some((v) => v.containsTextElement), w = n.has(M) && !y ? re : V;
|
|
2285
|
+
F.push(Ne(E, c, o, w.slice(0, 180)));
|
|
2255
2286
|
}
|
|
2256
|
-
for (const y of
|
|
2257
|
-
|
|
2258
|
-
const
|
|
2259
|
-
if (
|
|
2260
|
-
const y =
|
|
2261
|
-
|
|
2262
|
-
const w =
|
|
2263
|
-
if (
|
|
2264
|
-
const
|
|
2265
|
-
|
|
2287
|
+
for (const y of yt)
|
|
2288
|
+
F.push(...st(y, St));
|
|
2289
|
+
const At = It.flatMap((y) => y.lines);
|
|
2290
|
+
if (At.length > 0) {
|
|
2291
|
+
const y = At.slice(0, 20);
|
|
2292
|
+
At.length > y.length && y.push("… shadow DOM omitted");
|
|
2293
|
+
const w = M.includes("tooltip") || M.includes("popper") || M.includes("loader");
|
|
2294
|
+
if (pt < 2 && !w) {
|
|
2295
|
+
const v = wt ? "#shadow-root" : `${M} #shadow-root`;
|
|
2296
|
+
F.push(...st([v, ...st(y, 1)], St));
|
|
2266
2297
|
} else
|
|
2267
|
-
|
|
2298
|
+
F.push(...st(y, St));
|
|
2268
2299
|
}
|
|
2269
2300
|
return {
|
|
2270
|
-
lines:
|
|
2271
|
-
hasUsefulContent:
|
|
2272
|
-
textPreview:
|
|
2273
|
-
containsTextElement: n.has(
|
|
2301
|
+
lines: F,
|
|
2302
|
+
hasUsefulContent: Tt,
|
|
2303
|
+
textPreview: re,
|
|
2304
|
+
containsTextElement: n.has(M) || Z.some((y) => y.containsTextElement)
|
|
2274
2305
|
};
|
|
2275
2306
|
};
|
|
2276
2307
|
return [`--- ${D} ---`, ...C(T, 0).lines].join(`
|
|
2277
2308
|
`);
|
|
2278
2309
|
}, g = [], A = q(window.getSelection()?.toString() ?? "");
|
|
2279
2310
|
A && g.push(`--- selected text ---
|
|
2280
|
-
${JSON.stringify(A)}`), f.length > 0 && g.push(
|
|
2311
|
+
${JSON.stringify(A)}`), f.length > 0 && g.push(_n(f, s, c, o));
|
|
2281
2312
|
for (const T of e.slice(0, 3))
|
|
2282
2313
|
g.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2283
2314
|
if (t && g.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2292,7 +2323,7 @@ function Ne(e, t, s, n) {
|
|
|
2292
2323
|
const r = e.tagName.toLowerCase();
|
|
2293
2324
|
let i = r;
|
|
2294
2325
|
const o = e.getAttribute("id");
|
|
2295
|
-
o &&
|
|
2326
|
+
o && Cn(o) && (i += `#${o}`);
|
|
2296
2327
|
for (const a of t) {
|
|
2297
2328
|
const c = e.getAttribute(a);
|
|
2298
2329
|
c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
|
|
@@ -2305,7 +2336,7 @@ function Ne(e, t, s, n) {
|
|
|
2305
2336
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2306
2337
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2307
2338
|
}
|
|
2308
|
-
function
|
|
2339
|
+
function kn() {
|
|
2309
2340
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
|
|
2310
2341
|
if (!a)
|
|
2311
2342
|
return;
|
|
@@ -2326,7 +2357,7 @@ function bn() {
|
|
|
2326
2357
|
n = n.shadowRoot.activeElement;
|
|
2327
2358
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2328
2359
|
const r = window.getSelection();
|
|
2329
|
-
r && !r.isCollapsed && (s(
|
|
2360
|
+
r && !r.isCollapsed && (s(ye(r.anchorNode), "selected text"), s(ye(r.focusNode), "selected text"));
|
|
2330
2361
|
const i = [
|
|
2331
2362
|
["[aria-selected='true']", "selected"],
|
|
2332
2363
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2348,7 +2379,7 @@ function bn() {
|
|
|
2348
2379
|
priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
|
|
2349
2380
|
};
|
|
2350
2381
|
}
|
|
2351
|
-
function
|
|
2382
|
+
function _n(e, t, s, n) {
|
|
2352
2383
|
const r = ["--- active/current elements ---"];
|
|
2353
2384
|
for (const i of e) {
|
|
2354
2385
|
const o = [];
|
|
@@ -2363,33 +2394,33 @@ function Mn(e, t, s, n) {
|
|
|
2363
2394
|
h,
|
|
2364
2395
|
s,
|
|
2365
2396
|
n,
|
|
2366
|
-
f === c.length - 1 ?
|
|
2397
|
+
f === c.length - 1 ? Oe(h).slice(0, 180) : ""
|
|
2367
2398
|
));
|
|
2368
2399
|
o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
|
|
2369
2400
|
}
|
|
2370
2401
|
return r.join(`
|
|
2371
2402
|
`);
|
|
2372
2403
|
}
|
|
2373
|
-
function
|
|
2404
|
+
function ye(e) {
|
|
2374
2405
|
return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
|
|
2375
2406
|
}
|
|
2376
|
-
function
|
|
2407
|
+
function st(e, t) {
|
|
2377
2408
|
if (t === 0)
|
|
2378
2409
|
return e;
|
|
2379
2410
|
const s = " ".repeat(t);
|
|
2380
2411
|
return e.map((n) => `${s}${n}`);
|
|
2381
2412
|
}
|
|
2382
|
-
function
|
|
2413
|
+
function Oe(e) {
|
|
2383
2414
|
return q(
|
|
2384
2415
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2385
2416
|
);
|
|
2386
2417
|
}
|
|
2387
|
-
function
|
|
2418
|
+
function Cn(e) {
|
|
2388
2419
|
return e.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(e) && !/[a-f0-9]{12,}/i.test(e) && !/:r[0-9a-z]+:/i.test(e);
|
|
2389
2420
|
}
|
|
2390
|
-
function
|
|
2391
|
-
const e = document.querySelector(
|
|
2392
|
-
if (!(e ?? document.querySelector(
|
|
2421
|
+
function xe() {
|
|
2422
|
+
const e = document.querySelector(ce);
|
|
2423
|
+
if (!(e ?? document.querySelector(Nt)))
|
|
2393
2424
|
return;
|
|
2394
2425
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2395
2426
|
return {
|
|
@@ -2398,28 +2429,28 @@ function Oe() {
|
|
|
2398
2429
|
selectors: [
|
|
2399
2430
|
{
|
|
2400
2431
|
name: "widget_host",
|
|
2401
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2432
|
+
selector: s === "browser_extension_sdk_preview" ? ce : Nt,
|
|
2402
2433
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2403
2434
|
},
|
|
2404
2435
|
{
|
|
2405
2436
|
name: "widget_root",
|
|
2406
|
-
selector:
|
|
2437
|
+
selector: Rs,
|
|
2407
2438
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2408
2439
|
},
|
|
2409
2440
|
{
|
|
2410
2441
|
name: "widget_panel",
|
|
2411
|
-
selector:
|
|
2442
|
+
selector: Ms,
|
|
2412
2443
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2413
2444
|
},
|
|
2414
2445
|
{
|
|
2415
2446
|
name: "widget_timeline",
|
|
2416
|
-
selector:
|
|
2447
|
+
selector: bs,
|
|
2417
2448
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2418
2449
|
}
|
|
2419
2450
|
]
|
|
2420
2451
|
};
|
|
2421
2452
|
}
|
|
2422
|
-
function
|
|
2453
|
+
function Pn(e) {
|
|
2423
2454
|
try {
|
|
2424
2455
|
const t = JSON.parse(e);
|
|
2425
2456
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2427,16 +2458,16 @@ function _n(e) {
|
|
|
2427
2458
|
return { type: "error", message: "Invalid server event" };
|
|
2428
2459
|
}
|
|
2429
2460
|
}
|
|
2430
|
-
function
|
|
2461
|
+
function Ie(e, t) {
|
|
2431
2462
|
if (!e || typeof e != "object")
|
|
2432
2463
|
return [];
|
|
2433
2464
|
const s = e[t];
|
|
2434
2465
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2435
2466
|
}
|
|
2436
|
-
function
|
|
2467
|
+
function Un(e) {
|
|
2437
2468
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2438
2469
|
}
|
|
2439
|
-
function
|
|
2470
|
+
function Dn(e) {
|
|
2440
2471
|
if (!e || typeof e != "object")
|
|
2441
2472
|
return null;
|
|
2442
2473
|
const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -2447,13 +2478,13 @@ function Pn(e) {
|
|
|
2447
2478
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2448
2479
|
};
|
|
2449
2480
|
}
|
|
2450
|
-
function
|
|
2481
|
+
function vn(e) {
|
|
2451
2482
|
if (!e || typeof e != "object")
|
|
2452
2483
|
return null;
|
|
2453
2484
|
const t = e.javascript;
|
|
2454
2485
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2455
2486
|
}
|
|
2456
|
-
function
|
|
2487
|
+
function Nn(e, t) {
|
|
2457
2488
|
return t ? e && typeof e == "object" ? {
|
|
2458
2489
|
...e,
|
|
2459
2490
|
helperError: t
|
|
@@ -2463,13 +2494,13 @@ function Dn(e, t) {
|
|
|
2463
2494
|
helperError: t
|
|
2464
2495
|
} : e;
|
|
2465
2496
|
}
|
|
2466
|
-
function
|
|
2497
|
+
function On(e) {
|
|
2467
2498
|
if (!e || typeof e != "object")
|
|
2468
2499
|
return e;
|
|
2469
2500
|
const t = e;
|
|
2470
2501
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2471
2502
|
}
|
|
2472
|
-
function
|
|
2503
|
+
function xn() {
|
|
2473
2504
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2474
2505
|
if (t)
|
|
2475
2506
|
return t;
|
|
@@ -2479,7 +2510,7 @@ function vn() {
|
|
|
2479
2510
|
function j() {
|
|
2480
2511
|
return crypto.randomUUID();
|
|
2481
2512
|
}
|
|
2482
|
-
function
|
|
2513
|
+
function Ln(e) {
|
|
2483
2514
|
if (!e || typeof e != "object")
|
|
2484
2515
|
return null;
|
|
2485
2516
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2490,12 +2521,12 @@ function On(e) {
|
|
|
2490
2521
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2491
2522
|
} : null;
|
|
2492
2523
|
}
|
|
2493
|
-
function
|
|
2494
|
-
return Array.isArray(e) ?
|
|
2495
|
-
e.map((s) =>
|
|
2524
|
+
function Bn(e, t) {
|
|
2525
|
+
return Array.isArray(e) ? Wt(
|
|
2526
|
+
e.map((s) => Le(s, t)).filter((s) => s !== null)
|
|
2496
2527
|
) : [];
|
|
2497
2528
|
}
|
|
2498
|
-
function
|
|
2529
|
+
function qn(e) {
|
|
2499
2530
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2500
2531
|
if (!t || typeof t != "object")
|
|
2501
2532
|
return [];
|
|
@@ -2516,7 +2547,7 @@ function Ln(e) {
|
|
|
2516
2547
|
];
|
|
2517
2548
|
}) : [];
|
|
2518
2549
|
}
|
|
2519
|
-
function
|
|
2550
|
+
function Le(e, t) {
|
|
2520
2551
|
if (!e || typeof e != "object")
|
|
2521
2552
|
return null;
|
|
2522
2553
|
const s = e, n = s.data;
|
|
@@ -2530,14 +2561,14 @@ function xe(e, t) {
|
|
|
2530
2561
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2531
2562
|
role: i,
|
|
2532
2563
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2533
|
-
content:
|
|
2534
|
-
|
|
2564
|
+
content: us(
|
|
2565
|
+
Kn(r.content),
|
|
2535
2566
|
t
|
|
2536
2567
|
),
|
|
2537
2568
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2538
|
-
respondsToUserMessageId:
|
|
2569
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
2539
2570
|
...k(r) ? { runId: k(r) } : {},
|
|
2540
|
-
attachments:
|
|
2571
|
+
attachments: je(r.attachments, t)
|
|
2541
2572
|
};
|
|
2542
2573
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2543
2574
|
value: r.id,
|
|
@@ -2548,51 +2579,51 @@ function xe(e, t) {
|
|
|
2548
2579
|
}), o;
|
|
2549
2580
|
}
|
|
2550
2581
|
if (r.type === "function_call_output") {
|
|
2551
|
-
const i =
|
|
2582
|
+
const i = As(r.output);
|
|
2552
2583
|
if (i)
|
|
2553
2584
|
return {
|
|
2554
2585
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2555
2586
|
role: "tool",
|
|
2556
2587
|
content: "",
|
|
2557
2588
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2558
|
-
respondsToUserMessageId:
|
|
2589
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
2559
2590
|
...k(r) ? { runId: k(r) } : {},
|
|
2560
2591
|
dataType: "scheduled_check_in",
|
|
2561
|
-
toolName:
|
|
2562
|
-
callId:
|
|
2592
|
+
toolName: _e,
|
|
2593
|
+
callId: Ut(r) ?? void 0,
|
|
2563
2594
|
scheduledCheckInAt: i
|
|
2564
2595
|
};
|
|
2565
|
-
const o =
|
|
2596
|
+
const o = Wn(r.output);
|
|
2566
2597
|
return o ? {
|
|
2567
2598
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2568
2599
|
role: "tool",
|
|
2569
2600
|
content: `Connect ${o.appName} to continue`,
|
|
2570
2601
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2571
|
-
respondsToUserMessageId:
|
|
2602
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
2572
2603
|
...k(r) ? { runId: k(r) } : {},
|
|
2573
2604
|
dataType: "function_call_output",
|
|
2574
2605
|
toolName: "authenticate_pipedream_app",
|
|
2575
|
-
callId:
|
|
2606
|
+
callId: Ut(r) ?? void 0,
|
|
2576
2607
|
integrationAuthRequest: o
|
|
2577
2608
|
} : null;
|
|
2578
2609
|
}
|
|
2579
2610
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2580
2611
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2581
2612
|
role: "tool",
|
|
2582
|
-
content: r.type === "mcp_call" ?
|
|
2613
|
+
content: r.type === "mcp_call" ? Hn(r) : $n(r),
|
|
2583
2614
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2584
|
-
respondsToUserMessageId:
|
|
2615
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
2585
2616
|
...k(r) ? { runId: k(r) } : {},
|
|
2586
2617
|
dataType: String(r.type),
|
|
2587
2618
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2588
|
-
callId:
|
|
2619
|
+
callId: Ut(r) ?? void 0,
|
|
2589
2620
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
2590
2621
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2591
2622
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2592
2623
|
role: "system",
|
|
2593
|
-
content:
|
|
2624
|
+
content: Fn(r),
|
|
2594
2625
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2595
|
-
respondsToUserMessageId:
|
|
2626
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
2596
2627
|
...k(r) ? { runId: k(r) } : {},
|
|
2597
2628
|
dataType: String(r.type),
|
|
2598
2629
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -2601,11 +2632,11 @@ function xe(e, t) {
|
|
|
2601
2632
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2602
2633
|
} : null;
|
|
2603
2634
|
}
|
|
2604
|
-
function
|
|
2635
|
+
function Hn(e) {
|
|
2605
2636
|
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(" ");
|
|
2606
2637
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2607
2638
|
}
|
|
2608
|
-
function
|
|
2639
|
+
function Wn(e) {
|
|
2609
2640
|
if (typeof e != "string")
|
|
2610
2641
|
return null;
|
|
2611
2642
|
try {
|
|
@@ -2622,10 +2653,10 @@ function qn(e) {
|
|
|
2622
2653
|
return null;
|
|
2623
2654
|
}
|
|
2624
2655
|
}
|
|
2625
|
-
function
|
|
2656
|
+
function Fn(e) {
|
|
2626
2657
|
return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : e.type === "run_status" && e.status === "steered" ? "Steered" : 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.";
|
|
2627
2658
|
}
|
|
2628
|
-
function
|
|
2659
|
+
function $n(e) {
|
|
2629
2660
|
if (e.type === "web_search_call") {
|
|
2630
2661
|
const t = e.action;
|
|
2631
2662
|
if (t && typeof t == "object") {
|
|
@@ -2637,9 +2668,9 @@ function Wn(e) {
|
|
|
2637
2668
|
}
|
|
2638
2669
|
return "🔎 Searching the web";
|
|
2639
2670
|
}
|
|
2640
|
-
return
|
|
2671
|
+
return jn(e);
|
|
2641
2672
|
}
|
|
2642
|
-
function
|
|
2673
|
+
function jn(e) {
|
|
2643
2674
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2644
2675
|
return L(e.summary);
|
|
2645
2676
|
if (typeof e.arguments == "string")
|
|
@@ -2656,7 +2687,7 @@ function L(e) {
|
|
|
2656
2687
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2657
2688
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2658
2689
|
}
|
|
2659
|
-
function
|
|
2690
|
+
function zn(e) {
|
|
2660
2691
|
if (e == null)
|
|
2661
2692
|
return e;
|
|
2662
2693
|
if (typeof e != "object")
|
|
@@ -2671,11 +2702,11 @@ function jn(e) {
|
|
|
2671
2702
|
runId: typeof t.runId == "string" ? t.runId : null
|
|
2672
2703
|
};
|
|
2673
2704
|
}
|
|
2674
|
-
function
|
|
2705
|
+
function Ut(e) {
|
|
2675
2706
|
const t = e.callId ?? e.call_id;
|
|
2676
2707
|
return typeof t == "string" && t ? t : null;
|
|
2677
2708
|
}
|
|
2678
|
-
function
|
|
2709
|
+
function Kn(e) {
|
|
2679
2710
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2680
2711
|
if (!t || typeof t != "object")
|
|
2681
2712
|
return "";
|
|
@@ -2683,31 +2714,31 @@ function Fn(e) {
|
|
|
2683
2714
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2684
2715
|
}).filter(Boolean).join("") : "";
|
|
2685
2716
|
}
|
|
2686
|
-
function
|
|
2687
|
-
const s =
|
|
2688
|
-
|
|
2689
|
-
|
|
2717
|
+
function xt(e, t) {
|
|
2718
|
+
const s = qe(e, t), n = Qn(
|
|
2719
|
+
Gn(
|
|
2720
|
+
nr(e, t),
|
|
2690
2721
|
s
|
|
2691
2722
|
),
|
|
2692
2723
|
s
|
|
2693
2724
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2694
2725
|
if (r === -1)
|
|
2695
|
-
return
|
|
2726
|
+
return Wt(
|
|
2696
2727
|
[...n, s]
|
|
2697
2728
|
);
|
|
2698
2729
|
const i = [...n];
|
|
2699
|
-
return i[r] = s,
|
|
2730
|
+
return i[r] = s, Wt(i);
|
|
2700
2731
|
}
|
|
2701
|
-
function
|
|
2732
|
+
function Gn(e, t) {
|
|
2702
2733
|
const s = t.assistantDraftItemId;
|
|
2703
2734
|
return s ? e.map(
|
|
2704
2735
|
(n) => n.dataType === "assistant_draft" && n.id === s ? t : n
|
|
2705
2736
|
) : e;
|
|
2706
2737
|
}
|
|
2707
|
-
function
|
|
2738
|
+
function Xn(e, t, s) {
|
|
2708
2739
|
return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
|
|
2709
2740
|
}
|
|
2710
|
-
function
|
|
2741
|
+
function Jn(e, t, s, n) {
|
|
2711
2742
|
if (s === null) return e;
|
|
2712
2743
|
let r = -1;
|
|
2713
2744
|
for (let o = e.length - 1; o >= 0; o -= 1) {
|
|
@@ -2724,12 +2755,12 @@ function Gn(e, t, s, n) {
|
|
|
2724
2755
|
respondsToUserMessageId: s
|
|
2725
2756
|
}, i;
|
|
2726
2757
|
}
|
|
2727
|
-
function
|
|
2758
|
+
function Vn(e, t) {
|
|
2728
2759
|
const s = e.findIndex(
|
|
2729
2760
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2730
2761
|
);
|
|
2731
2762
|
if (s === -1)
|
|
2732
|
-
return
|
|
2763
|
+
return xt(e, t);
|
|
2733
2764
|
const n = [...e];
|
|
2734
2765
|
return n[s] = {
|
|
2735
2766
|
...n[s],
|
|
@@ -2741,12 +2772,12 @@ function Xn(e, t) {
|
|
|
2741
2772
|
...n[s].runId ? {} : { runId: t.runId }
|
|
2742
2773
|
}, n;
|
|
2743
2774
|
}
|
|
2744
|
-
function
|
|
2775
|
+
function Yn(e, t, s) {
|
|
2745
2776
|
let n = !1;
|
|
2746
2777
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2747
2778
|
return n ? r : e;
|
|
2748
2779
|
}
|
|
2749
|
-
function
|
|
2780
|
+
function Zn(e) {
|
|
2750
2781
|
if (e.hiddenFromTranscript === !0)
|
|
2751
2782
|
return null;
|
|
2752
2783
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
@@ -2765,7 +2796,7 @@ function Vn(e) {
|
|
|
2765
2796
|
loading: !0
|
|
2766
2797
|
};
|
|
2767
2798
|
}
|
|
2768
|
-
function
|
|
2799
|
+
function Qn(e, t) {
|
|
2769
2800
|
if (t.id.startsWith("transient-activity:"))
|
|
2770
2801
|
return e;
|
|
2771
2802
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2773,17 +2804,17 @@ function Yn(e, t) {
|
|
|
2773
2804
|
(n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId && n.runId === t.runId)
|
|
2774
2805
|
);
|
|
2775
2806
|
}
|
|
2776
|
-
function
|
|
2777
|
-
return
|
|
2807
|
+
function tr(e, t) {
|
|
2808
|
+
return ds(
|
|
2778
2809
|
e,
|
|
2779
2810
|
t.map(
|
|
2780
|
-
(s) =>
|
|
2811
|
+
(s) => qe(e, s)
|
|
2781
2812
|
),
|
|
2782
|
-
|
|
2813
|
+
Be
|
|
2783
2814
|
);
|
|
2784
2815
|
}
|
|
2785
|
-
function
|
|
2786
|
-
const t =
|
|
2816
|
+
function Be(e) {
|
|
2817
|
+
const t = G(e) ?? void 0, s = e.assistantDraftItemId, n = [
|
|
2787
2818
|
...e.callId ? [`call:${e.callId}`] : [],
|
|
2788
2819
|
...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
|
|
2789
2820
|
];
|
|
@@ -2794,52 +2825,52 @@ function Le(e) {
|
|
|
2794
2825
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
2795
2826
|
...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
|
|
2796
2827
|
...e.runId ? { runId: e.runId } : {},
|
|
2797
|
-
isOptimistic:
|
|
2828
|
+
isOptimistic: Jt(e),
|
|
2798
2829
|
isAssistantDraft: e.dataType === "assistant_draft",
|
|
2799
2830
|
isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
|
|
2800
2831
|
isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
|
|
2801
2832
|
};
|
|
2802
2833
|
}
|
|
2803
|
-
function
|
|
2834
|
+
function qe(e, t) {
|
|
2804
2835
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2805
2836
|
return t;
|
|
2806
2837
|
const s = e.find(
|
|
2807
|
-
(r) => r.role === "user" && (r.id === t.id ||
|
|
2838
|
+
(r) => r.role === "user" && (r.id === t.id || Jt(r) && He(r, t))
|
|
2808
2839
|
);
|
|
2809
2840
|
if (!s?.attachments?.length)
|
|
2810
2841
|
return t;
|
|
2811
2842
|
const n = t.attachments.map((r) => {
|
|
2812
|
-
const i =
|
|
2813
|
-
return i ?
|
|
2843
|
+
const i = er(s.attachments ?? [], r);
|
|
2844
|
+
return i ? sr(r, i) : r;
|
|
2814
2845
|
});
|
|
2815
2846
|
return { ...t, attachments: n };
|
|
2816
2847
|
}
|
|
2817
|
-
function
|
|
2848
|
+
function er(e, t) {
|
|
2818
2849
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2819
2850
|
}
|
|
2820
|
-
function
|
|
2851
|
+
function sr(e, t) {
|
|
2821
2852
|
const { previewUrl: s } = t;
|
|
2822
2853
|
return s ? { ...e, previewUrl: s } : e;
|
|
2823
2854
|
}
|
|
2824
|
-
function
|
|
2855
|
+
function nr(e, t) {
|
|
2825
2856
|
if (t.role !== "user")
|
|
2826
2857
|
return e;
|
|
2827
2858
|
const s = e.findIndex(
|
|
2828
|
-
(r) =>
|
|
2859
|
+
(r) => Jt(r) && He(r, t)
|
|
2829
2860
|
);
|
|
2830
2861
|
if (s === -1)
|
|
2831
2862
|
return e;
|
|
2832
2863
|
const n = [...e];
|
|
2833
2864
|
return n.splice(s, 1), n;
|
|
2834
2865
|
}
|
|
2835
|
-
function
|
|
2836
|
-
const s =
|
|
2866
|
+
function He(e, t) {
|
|
2867
|
+
const s = G(e), n = G(t);
|
|
2837
2868
|
return s && n ? s === n : e.content === t.content;
|
|
2838
2869
|
}
|
|
2839
|
-
function
|
|
2870
|
+
function Jt(e) {
|
|
2840
2871
|
return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
|
|
2841
2872
|
}
|
|
2842
|
-
function
|
|
2873
|
+
function G(e) {
|
|
2843
2874
|
const t = e.clientMessageId;
|
|
2844
2875
|
if (t)
|
|
2845
2876
|
return t;
|
|
@@ -2848,12 +2879,12 @@ function Ot(e) {
|
|
|
2848
2879
|
);
|
|
2849
2880
|
return n ? e.id.slice(n.length) : null;
|
|
2850
2881
|
}
|
|
2851
|
-
function
|
|
2852
|
-
const t =
|
|
2882
|
+
function Te(e) {
|
|
2883
|
+
const t = We(e);
|
|
2853
2884
|
if (t === null)
|
|
2854
2885
|
return !1;
|
|
2855
2886
|
const s = e[t].id, n = e.some(
|
|
2856
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
2887
|
+
(r) => r.respondsToUserMessageId === s && Lt(r)
|
|
2857
2888
|
);
|
|
2858
2889
|
if (e.some((r) => r.respondsToUserMessageId === s))
|
|
2859
2890
|
return n;
|
|
@@ -2870,8 +2901,8 @@ function ye(e) {
|
|
|
2870
2901
|
}
|
|
2871
2902
|
return !1;
|
|
2872
2903
|
}
|
|
2873
|
-
function
|
|
2874
|
-
const t =
|
|
2904
|
+
function rr(e) {
|
|
2905
|
+
const t = We(e);
|
|
2875
2906
|
if (t === null)
|
|
2876
2907
|
return e.some(O);
|
|
2877
2908
|
const s = e[t].id;
|
|
@@ -2879,16 +2910,16 @@ function sr(e) {
|
|
|
2879
2910
|
(n) => n.respondsToUserMessageId === s && O(n)
|
|
2880
2911
|
) : e.slice(t + 1).some(O);
|
|
2881
2912
|
}
|
|
2882
|
-
function
|
|
2913
|
+
function We(e) {
|
|
2883
2914
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2884
2915
|
if (e[t].role === "user")
|
|
2885
2916
|
return t;
|
|
2886
2917
|
return null;
|
|
2887
2918
|
}
|
|
2888
|
-
function
|
|
2919
|
+
function Lt(e) {
|
|
2889
2920
|
return O(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2890
2921
|
}
|
|
2891
|
-
function
|
|
2922
|
+
function dt(e) {
|
|
2892
2923
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
2893
2924
|
const s = e[t];
|
|
2894
2925
|
if (!s || typeof s != "object")
|
|
@@ -2902,8 +2933,8 @@ function at(e) {
|
|
|
2902
2933
|
}
|
|
2903
2934
|
return null;
|
|
2904
2935
|
}
|
|
2905
|
-
function
|
|
2906
|
-
const t =
|
|
2936
|
+
function ir(e) {
|
|
2937
|
+
const t = dt(e);
|
|
2907
2938
|
if (t === null)
|
|
2908
2939
|
return null;
|
|
2909
2940
|
const n = B(e[t])?.page;
|
|
@@ -2918,14 +2949,14 @@ function B(e) {
|
|
|
2918
2949
|
const t = e.data;
|
|
2919
2950
|
return t && typeof t == "object" ? t : null;
|
|
2920
2951
|
}
|
|
2921
|
-
function
|
|
2952
|
+
function Bt(e) {
|
|
2922
2953
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2923
2954
|
}
|
|
2924
|
-
function
|
|
2955
|
+
function we(e) {
|
|
2925
2956
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2926
2957
|
}
|
|
2927
|
-
function
|
|
2928
|
-
const s =
|
|
2958
|
+
function or(e, t) {
|
|
2959
|
+
const s = dt(t);
|
|
2929
2960
|
if (s === null)
|
|
2930
2961
|
return !1;
|
|
2931
2962
|
const n = t[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -2933,11 +2964,11 @@ function rr(e, t) {
|
|
|
2933
2964
|
return !1;
|
|
2934
2965
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2935
2966
|
return i === -1 ? !1 : e.some((o) => o.respondsToUserMessageId === r) ? e.some(
|
|
2936
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
2937
|
-
) : e.slice(i + 1).some(
|
|
2967
|
+
(o) => o.respondsToUserMessageId === r && Lt(o)
|
|
2968
|
+
) : e.slice(i + 1).some(Lt);
|
|
2938
2969
|
}
|
|
2939
|
-
function
|
|
2940
|
-
const t =
|
|
2970
|
+
function qt(e) {
|
|
2971
|
+
const t = dt(e);
|
|
2941
2972
|
if (t === null)
|
|
2942
2973
|
return null;
|
|
2943
2974
|
const s = e[t];
|
|
@@ -2949,8 +2980,8 @@ function Bt(e) {
|
|
|
2949
2980
|
const r = n.clientMessageId;
|
|
2950
2981
|
return typeof r == "string" ? r : null;
|
|
2951
2982
|
}
|
|
2952
|
-
function
|
|
2953
|
-
const t =
|
|
2983
|
+
function ar(e) {
|
|
2984
|
+
const t = dt(e);
|
|
2954
2985
|
if (t === null)
|
|
2955
2986
|
return null;
|
|
2956
2987
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
@@ -2964,22 +2995,22 @@ function ir(e) {
|
|
|
2964
2995
|
if (i.type === "message" && i.role === "assistant")
|
|
2965
2996
|
return null;
|
|
2966
2997
|
if (i.type === "run_error")
|
|
2967
|
-
return i.retryable !== !0 ? null :
|
|
2998
|
+
return i.retryable !== !0 ? null : Ht(e, i) ?? qt(e);
|
|
2968
2999
|
if (i.type === "run_status")
|
|
2969
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3000
|
+
return i.status === "interrupted" && i.retryable === !0 ? Ht(e, i) ?? qt(e) : null;
|
|
2970
3001
|
}
|
|
2971
3002
|
return null;
|
|
2972
3003
|
}
|
|
2973
|
-
function
|
|
3004
|
+
function Ht(e, t) {
|
|
2974
3005
|
if (typeof t.clientMessageId == "string")
|
|
2975
3006
|
return t.clientMessageId;
|
|
2976
|
-
const s =
|
|
3007
|
+
const s = N(t);
|
|
2977
3008
|
if (!s)
|
|
2978
3009
|
return null;
|
|
2979
3010
|
const n = e.find((i) => R(i, "id") === s), r = B(n);
|
|
2980
3011
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2981
3012
|
}
|
|
2982
|
-
function
|
|
3013
|
+
function cr(e, t) {
|
|
2983
3014
|
let s = 0;
|
|
2984
3015
|
for (const n of e) {
|
|
2985
3016
|
if (!n || typeof n != "object")
|
|
@@ -2992,13 +3023,13 @@ function or(e, t) {
|
|
|
2992
3023
|
}
|
|
2993
3024
|
return s;
|
|
2994
3025
|
}
|
|
2995
|
-
function
|
|
2996
|
-
if (!t || !
|
|
3026
|
+
function Se(e, t, s, n, r) {
|
|
3027
|
+
if (!t || !lr(e))
|
|
2997
3028
|
return !1;
|
|
2998
3029
|
const i = e;
|
|
2999
|
-
return !(
|
|
3030
|
+
return !(Bt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? N(i) !== n : r !== null && k(i) !== r));
|
|
3000
3031
|
}
|
|
3001
|
-
function
|
|
3032
|
+
function lr(e) {
|
|
3002
3033
|
if (!e || typeof e != "object")
|
|
3003
3034
|
return !1;
|
|
3004
3035
|
const t = e;
|
|
@@ -3007,50 +3038,91 @@ function ar(e) {
|
|
|
3007
3038
|
function O(e) {
|
|
3008
3039
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
3009
3040
|
}
|
|
3010
|
-
function
|
|
3041
|
+
function ur(e) {
|
|
3011
3042
|
if (!e || typeof e != "object")
|
|
3012
3043
|
return !1;
|
|
3013
3044
|
const t = e;
|
|
3014
3045
|
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";
|
|
3015
3046
|
}
|
|
3016
|
-
function
|
|
3017
|
-
return e.filter((t, s) =>
|
|
3047
|
+
function Wt(e) {
|
|
3048
|
+
return e.filter((t, s) => H(t) ? !wr(e, s) && !Fe(e, s) && !Ir(e, s) && !Tr(e, s) : dr(t) ? t.retryable === !0 && yr(e, s) ? !1 : !mr(e, s) : !0);
|
|
3018
3049
|
}
|
|
3019
|
-
function
|
|
3050
|
+
function dr(e) {
|
|
3020
3051
|
return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
|
|
3021
3052
|
}
|
|
3022
|
-
function
|
|
3053
|
+
function H(e) {
|
|
3023
3054
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
3024
3055
|
}
|
|
3025
|
-
function
|
|
3056
|
+
function hr(e, t, s, n) {
|
|
3057
|
+
const r = e.findIndex(
|
|
3058
|
+
(c, l) => H(c) && !Fe(e, l)
|
|
3059
|
+
), i = r === -1 ? null : e[r], o = t ?? i?.respondsToUserMessageId ?? null, a = o ? e.find(
|
|
3060
|
+
(c) => c.role === "user" && c.id === o
|
|
3061
|
+
) : null;
|
|
3062
|
+
return {
|
|
3063
|
+
clientMessageId: a ? G(a) : o ? null : n,
|
|
3064
|
+
runId: s ?? i?.runId ?? null
|
|
3065
|
+
};
|
|
3066
|
+
}
|
|
3067
|
+
function nt(e, t, s) {
|
|
3068
|
+
const n = new Set(
|
|
3069
|
+
e.filter(
|
|
3070
|
+
(r) => r.role === "user" && t !== null && G(r) === t
|
|
3071
|
+
).map((r) => r.id)
|
|
3072
|
+
);
|
|
3073
|
+
return e.filter(
|
|
3074
|
+
(r) => !H(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3075
|
+
);
|
|
3076
|
+
}
|
|
3077
|
+
function Fe(e, t) {
|
|
3078
|
+
return e.some(
|
|
3079
|
+
(s, n) => n !== t && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && pr(
|
|
3080
|
+
e,
|
|
3081
|
+
t,
|
|
3082
|
+
n
|
|
3083
|
+
)
|
|
3084
|
+
);
|
|
3085
|
+
}
|
|
3086
|
+
function pr(e, t, s) {
|
|
3087
|
+
const n = e[t], r = e[s];
|
|
3088
|
+
if (X(n, r))
|
|
3089
|
+
return !0;
|
|
3090
|
+
if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
|
|
3091
|
+
return !1;
|
|
3092
|
+
for (let i = s - 1; i >= 0; i -= 1)
|
|
3093
|
+
if (e[i].role === "user")
|
|
3094
|
+
return e[i].id === n.respondsToUserMessageId;
|
|
3095
|
+
return !1;
|
|
3096
|
+
}
|
|
3097
|
+
function fr(e, t) {
|
|
3026
3098
|
const s = [...e].reverse().find(
|
|
3027
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t &&
|
|
3099
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && Ae(n) && !gr(
|
|
3028
3100
|
e,
|
|
3029
3101
|
n.respondsToUserMessageId
|
|
3030
3102
|
)
|
|
3031
3103
|
)?.respondsToUserMessageId;
|
|
3032
3104
|
return s ? e.map(
|
|
3033
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3105
|
+
(n) => n.respondsToUserMessageId === s && Ae(n) ? { ...n, steered: !0 } : n
|
|
3034
3106
|
) : e;
|
|
3035
3107
|
}
|
|
3036
|
-
function
|
|
3037
|
-
return e.role === "tool" ||
|
|
3108
|
+
function Ae(e) {
|
|
3109
|
+
return e.role === "tool" || H(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
|
|
3038
3110
|
}
|
|
3039
|
-
function
|
|
3111
|
+
function gr(e, t) {
|
|
3040
3112
|
return e.some(
|
|
3041
3113
|
(s) => s.respondsToUserMessageId === t && (O(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3042
3114
|
);
|
|
3043
3115
|
}
|
|
3044
|
-
function
|
|
3116
|
+
function mr(e, t) {
|
|
3045
3117
|
const s = e[t];
|
|
3046
3118
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
3047
3119
|
const r = e[n];
|
|
3048
|
-
if (r.role === "assistant" &&
|
|
3120
|
+
if (r.role === "assistant" && X(s, r))
|
|
3049
3121
|
return !0;
|
|
3050
3122
|
}
|
|
3051
3123
|
return !1;
|
|
3052
3124
|
}
|
|
3053
|
-
function
|
|
3125
|
+
function yr(e, t) {
|
|
3054
3126
|
const s = e[t];
|
|
3055
3127
|
if (!s.respondsToUserMessageId)
|
|
3056
3128
|
return !1;
|
|
@@ -3058,45 +3130,45 @@ function pr(e, t) {
|
|
|
3058
3130
|
const r = e[n];
|
|
3059
3131
|
if (r.role === "user")
|
|
3060
3132
|
return !1;
|
|
3061
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3133
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || H(r)))
|
|
3062
3134
|
return !0;
|
|
3063
3135
|
}
|
|
3064
3136
|
return !1;
|
|
3065
3137
|
}
|
|
3066
|
-
function
|
|
3138
|
+
function Ir(e, t) {
|
|
3067
3139
|
const s = e[t];
|
|
3068
3140
|
return e.some(
|
|
3069
|
-
(n, r) => r !== t && n.role === "assistant" &&
|
|
3141
|
+
(n, r) => r !== t && n.role === "assistant" && X(s, n)
|
|
3070
3142
|
);
|
|
3071
3143
|
}
|
|
3072
|
-
function
|
|
3144
|
+
function Tr(e, t) {
|
|
3073
3145
|
const s = e[t];
|
|
3074
3146
|
return e.some(
|
|
3075
|
-
(n, r) => r !== t && n.role === "tool" &&
|
|
3147
|
+
(n, r) => r !== t && n.role === "tool" && X(s, n)
|
|
3076
3148
|
);
|
|
3077
3149
|
}
|
|
3078
|
-
function
|
|
3150
|
+
function wr(e, t) {
|
|
3079
3151
|
const s = e[t];
|
|
3080
3152
|
for (let n = t + 1; n < e.length; n += 1)
|
|
3081
|
-
if (
|
|
3153
|
+
if (H(e[n]) && X(s, e[n]))
|
|
3082
3154
|
return !0;
|
|
3083
3155
|
return !1;
|
|
3084
3156
|
}
|
|
3085
|
-
function
|
|
3157
|
+
function X(e, t) {
|
|
3086
3158
|
return !!(e.respondsToUserMessageId && e.respondsToUserMessageId === t.respondsToUserMessageId);
|
|
3087
3159
|
}
|
|
3088
3160
|
function R(e, t) {
|
|
3089
3161
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
3090
3162
|
}
|
|
3091
|
-
function
|
|
3163
|
+
function Sr(e, t) {
|
|
3092
3164
|
try {
|
|
3093
|
-
const s = window.localStorage.getItem(`${
|
|
3165
|
+
const s = window.localStorage.getItem(`${Ue}${e}`);
|
|
3094
3166
|
if (!s)
|
|
3095
3167
|
return null;
|
|
3096
3168
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3097
3169
|
if (t !== void 0 && r !== t)
|
|
3098
3170
|
return null;
|
|
3099
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3171
|
+
const i = Array.isArray(n.messages) ? n.messages.map(vr).filter((o) => !!o) : [];
|
|
3100
3172
|
return {
|
|
3101
3173
|
sessionId: r,
|
|
3102
3174
|
messages: i
|
|
@@ -3105,48 +3177,48 @@ function yr(e, t) {
|
|
|
3105
3177
|
return null;
|
|
3106
3178
|
}
|
|
3107
3179
|
}
|
|
3108
|
-
function
|
|
3180
|
+
function Ar(e, t) {
|
|
3109
3181
|
try {
|
|
3110
3182
|
window.localStorage.setItem(
|
|
3111
|
-
`${
|
|
3183
|
+
`${Ue}${e}`,
|
|
3112
3184
|
JSON.stringify({
|
|
3113
3185
|
sessionId: t.sessionId,
|
|
3114
|
-
messages: t.messages.slice(-
|
|
3186
|
+
messages: t.messages.slice(-Gs).map(Nr)
|
|
3115
3187
|
})
|
|
3116
3188
|
);
|
|
3117
3189
|
} catch {
|
|
3118
3190
|
return;
|
|
3119
3191
|
}
|
|
3120
3192
|
}
|
|
3121
|
-
function
|
|
3193
|
+
function Er(e) {
|
|
3122
3194
|
try {
|
|
3123
|
-
const t = window.localStorage.getItem(`${
|
|
3195
|
+
const t = window.localStorage.getItem(`${Ot}${e}`);
|
|
3124
3196
|
if (!t)
|
|
3125
3197
|
return [];
|
|
3126
3198
|
const s = JSON.parse(t);
|
|
3127
|
-
return Array.isArray(s) ? s.filter(
|
|
3199
|
+
return Array.isArray(s) ? s.filter(Vt) : [];
|
|
3128
3200
|
} catch {
|
|
3129
3201
|
return [];
|
|
3130
3202
|
}
|
|
3131
3203
|
}
|
|
3132
|
-
function
|
|
3204
|
+
function z(e, t) {
|
|
3133
3205
|
try {
|
|
3134
|
-
const s = t.filter(
|
|
3206
|
+
const s = t.filter(Vt);
|
|
3135
3207
|
if (s.length === 0) {
|
|
3136
|
-
window.localStorage.removeItem(`${
|
|
3208
|
+
window.localStorage.removeItem(`${Ot}${e}`);
|
|
3137
3209
|
return;
|
|
3138
3210
|
}
|
|
3139
3211
|
window.localStorage.setItem(
|
|
3140
|
-
`${
|
|
3212
|
+
`${Ot}${e}`,
|
|
3141
3213
|
JSON.stringify(s.slice(-25))
|
|
3142
3214
|
);
|
|
3143
3215
|
} catch {
|
|
3144
3216
|
return;
|
|
3145
3217
|
}
|
|
3146
3218
|
}
|
|
3147
|
-
function
|
|
3219
|
+
function $e(e, t) {
|
|
3148
3220
|
try {
|
|
3149
|
-
const s = `${
|
|
3221
|
+
const s = `${ut}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
3150
3222
|
...o,
|
|
3151
3223
|
storedAt: Date.now(),
|
|
3152
3224
|
unloadUrl: n,
|
|
@@ -3160,28 +3232,28 @@ function We(e, t) {
|
|
|
3160
3232
|
} catch {
|
|
3161
3233
|
}
|
|
3162
3234
|
}
|
|
3163
|
-
function
|
|
3235
|
+
function Rr(e, t) {
|
|
3164
3236
|
try {
|
|
3165
|
-
if (window.sessionStorage.getItem(`${
|
|
3237
|
+
if (window.sessionStorage.getItem(`${ut}${e}`) === null)
|
|
3166
3238
|
return;
|
|
3167
3239
|
} catch {
|
|
3168
3240
|
return;
|
|
3169
3241
|
}
|
|
3170
|
-
|
|
3242
|
+
$e(e, t);
|
|
3171
3243
|
}
|
|
3172
|
-
function
|
|
3244
|
+
function Mr(e) {
|
|
3173
3245
|
try {
|
|
3174
|
-
const t = `${
|
|
3246
|
+
const t = `${ut}${e}`, s = window.sessionStorage.getItem(t);
|
|
3175
3247
|
if (window.sessionStorage.removeItem(t), !s)
|
|
3176
3248
|
return [];
|
|
3177
3249
|
const n = JSON.parse(s);
|
|
3178
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3250
|
+
return Array.isArray(n) ? n.flatMap((r) => kr(r) ? [{
|
|
3179
3251
|
...r.event,
|
|
3180
|
-
page:
|
|
3252
|
+
page: b(),
|
|
3181
3253
|
rawOutput: {
|
|
3182
3254
|
pageContextRestarted: !0,
|
|
3183
3255
|
outcome: "unknown",
|
|
3184
|
-
message:
|
|
3256
|
+
message: br(location.href),
|
|
3185
3257
|
currentUrl: location.href,
|
|
3186
3258
|
console: [],
|
|
3187
3259
|
metadata: {
|
|
@@ -3198,17 +3270,17 @@ function Sr(e) {
|
|
|
3198
3270
|
return [];
|
|
3199
3271
|
}
|
|
3200
3272
|
}
|
|
3201
|
-
function
|
|
3273
|
+
function br(e) {
|
|
3202
3274
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3203
3275
|
Current URL: ${e}`;
|
|
3204
3276
|
}
|
|
3205
|
-
function
|
|
3277
|
+
function kr(e) {
|
|
3206
3278
|
if (!e || typeof e != "object")
|
|
3207
3279
|
return !1;
|
|
3208
3280
|
const t = e, s = t.event;
|
|
3209
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
3281
|
+
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Vt(s) && s.type === "tool.result";
|
|
3210
3282
|
}
|
|
3211
|
-
function
|
|
3283
|
+
function _r(e, t) {
|
|
3212
3284
|
const s = new Set(
|
|
3213
3285
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3214
3286
|
);
|
|
@@ -3217,26 +3289,26 @@ function Rr(e, t) {
|
|
|
3217
3289
|
...t.filter((n) => !s.has(n.callId))
|
|
3218
3290
|
];
|
|
3219
3291
|
}
|
|
3220
|
-
function
|
|
3292
|
+
function Cr(e) {
|
|
3221
3293
|
try {
|
|
3222
|
-
window.sessionStorage.removeItem(`${
|
|
3294
|
+
window.sessionStorage.removeItem(`${ut}${e}`);
|
|
3223
3295
|
} catch {
|
|
3224
3296
|
return;
|
|
3225
3297
|
}
|
|
3226
3298
|
}
|
|
3227
|
-
function
|
|
3299
|
+
function Vt(e) {
|
|
3228
3300
|
if (!e || typeof e != "object")
|
|
3229
3301
|
return !1;
|
|
3230
3302
|
const t = e;
|
|
3231
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
3303
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && Ee(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Ee(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;
|
|
3232
3304
|
}
|
|
3233
|
-
function
|
|
3305
|
+
function Ee(e) {
|
|
3234
3306
|
if (!e || typeof e != "object")
|
|
3235
3307
|
return !1;
|
|
3236
3308
|
const t = e;
|
|
3237
3309
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
3238
3310
|
}
|
|
3239
|
-
function
|
|
3311
|
+
function je(e, t) {
|
|
3240
3312
|
if (!Array.isArray(e))
|
|
3241
3313
|
return;
|
|
3242
3314
|
const s = e.filter((r) => {
|
|
@@ -3244,47 +3316,50 @@ function $e(e, t) {
|
|
|
3244
3316
|
return !1;
|
|
3245
3317
|
const i = r;
|
|
3246
3318
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3247
|
-
}), n = t ? s.map((r) =>
|
|
3319
|
+
}), n = t ? s.map((r) => ze(r, t)) : s;
|
|
3248
3320
|
return n.length > 0 ? n : void 0;
|
|
3249
3321
|
}
|
|
3250
|
-
function
|
|
3322
|
+
function ze(e, t) {
|
|
3251
3323
|
return e.fileUrl?.startsWith("/") ? {
|
|
3252
3324
|
...e,
|
|
3253
3325
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
3254
3326
|
} : e;
|
|
3255
3327
|
}
|
|
3256
|
-
function
|
|
3257
|
-
return e.type ||
|
|
3328
|
+
function Ft(e) {
|
|
3329
|
+
return e.type || Dr(e.name) || "application/octet-stream";
|
|
3258
3330
|
}
|
|
3259
|
-
function
|
|
3260
|
-
|
|
3331
|
+
function Pr(e) {
|
|
3332
|
+
Ke({
|
|
3261
3333
|
name: e.name,
|
|
3262
|
-
mimeType:
|
|
3334
|
+
mimeType: Ft(e),
|
|
3263
3335
|
sizeBytes: e.size
|
|
3264
3336
|
});
|
|
3265
3337
|
}
|
|
3266
|
-
function
|
|
3267
|
-
const t =
|
|
3268
|
-
if (
|
|
3338
|
+
function Ke(e) {
|
|
3339
|
+
const t = Ur(e.name), s = e.mimeType.trim().toLowerCase();
|
|
3340
|
+
if (!js.has(`${t}:${s}`))
|
|
3269
3341
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
3270
|
-
if (e.sizeBytes <= 0 || e.sizeBytes >=
|
|
3342
|
+
if (e.sizeBytes <= 0 || e.sizeBytes >= Ce)
|
|
3271
3343
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
3272
3344
|
}
|
|
3273
|
-
function
|
|
3345
|
+
function Ur(e) {
|
|
3274
3346
|
const t = e.trim().toLowerCase(), s = t.lastIndexOf(".");
|
|
3275
3347
|
return s >= 0 ? t.slice(s) : "";
|
|
3276
3348
|
}
|
|
3277
|
-
function
|
|
3349
|
+
function Dr(e) {
|
|
3278
3350
|
const t = e.toLowerCase();
|
|
3279
3351
|
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;
|
|
3280
3352
|
}
|
|
3281
|
-
function
|
|
3353
|
+
function vr(e) {
|
|
3282
3354
|
if (!e || typeof e != "object")
|
|
3283
3355
|
return null;
|
|
3284
3356
|
const t = e;
|
|
3285
3357
|
return typeof t.id != "string" || typeof t.content != "string" || typeof t.createdAt != "string" || !["user", "assistant", "tool", "system"].includes(String(t.role)) ? null : {
|
|
3286
3358
|
id: t.id,
|
|
3287
3359
|
role: t.role,
|
|
3360
|
+
// Commentary can be persisted while an embedded agent navigates the host page mid-run. Keep its phase so the
|
|
3361
|
+
// restored draft stays in activity history instead of flashing as a completed assistant answer after navigation.
|
|
3362
|
+
...t.phase === "commentary" || t.phase === "final_answer" ? { phase: t.phase } : {},
|
|
3288
3363
|
content: t.content,
|
|
3289
3364
|
createdAt: t.createdAt,
|
|
3290
3365
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
@@ -3292,17 +3367,17 @@ function Cr(e) {
|
|
|
3292
3367
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
3293
3368
|
scheduledCheckInAt: typeof t.scheduledCheckInAt == "string" ? t.scheduledCheckInAt : void 0,
|
|
3294
3369
|
securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
|
|
3295
|
-
attachments:
|
|
3370
|
+
attachments: je(t.attachments)?.map(Yt),
|
|
3296
3371
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
3297
3372
|
};
|
|
3298
3373
|
}
|
|
3299
|
-
function
|
|
3374
|
+
function Nr(e) {
|
|
3300
3375
|
return e.attachments?.length ? {
|
|
3301
3376
|
...e,
|
|
3302
|
-
attachments: e.attachments.map(
|
|
3377
|
+
attachments: e.attachments.map(Yt)
|
|
3303
3378
|
} : e;
|
|
3304
3379
|
}
|
|
3305
|
-
function
|
|
3380
|
+
function Yt(e) {
|
|
3306
3381
|
const {
|
|
3307
3382
|
dataUrl: t,
|
|
3308
3383
|
objectUrl: s,
|
|
@@ -3311,7 +3386,7 @@ function Jt(e) {
|
|
|
3311
3386
|
} = e;
|
|
3312
3387
|
return r;
|
|
3313
3388
|
}
|
|
3314
|
-
function
|
|
3389
|
+
function N(e) {
|
|
3315
3390
|
const t = e.respondsToUserMessageId;
|
|
3316
3391
|
return typeof t == "string" && t ? t : null;
|
|
3317
3392
|
}
|
|
@@ -3319,39 +3394,39 @@ function k(e) {
|
|
|
3319
3394
|
const t = e.runId;
|
|
3320
3395
|
return typeof t == "string" && t ? t : null;
|
|
3321
3396
|
}
|
|
3322
|
-
function
|
|
3397
|
+
function Or(e) {
|
|
3323
3398
|
const t = e?.timeoutMs;
|
|
3324
|
-
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 <=
|
|
3399
|
+
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 <= sn);
|
|
3325
3400
|
}
|
|
3326
|
-
function
|
|
3401
|
+
function Ge(e) {
|
|
3327
3402
|
const t = {};
|
|
3328
3403
|
try {
|
|
3329
3404
|
new Headers(e).forEach((s, n) => {
|
|
3330
|
-
Object.keys(t).length <
|
|
3405
|
+
Object.keys(t).length < Gt && (t[n] = Zt(n, s));
|
|
3331
3406
|
});
|
|
3332
3407
|
} catch {
|
|
3333
3408
|
return {};
|
|
3334
3409
|
}
|
|
3335
3410
|
return t;
|
|
3336
3411
|
}
|
|
3337
|
-
function
|
|
3338
|
-
return
|
|
3412
|
+
function Zt(e, t) {
|
|
3413
|
+
return Qe(e) ? ht : P(lt(t), zs);
|
|
3339
3414
|
}
|
|
3340
|
-
function
|
|
3415
|
+
function xr(e, t) {
|
|
3341
3416
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
3342
3417
|
}
|
|
3343
|
-
async function
|
|
3344
|
-
const r =
|
|
3418
|
+
async function Lr(e, t, s, n) {
|
|
3419
|
+
const r = Ge(e.headers);
|
|
3345
3420
|
n({
|
|
3346
3421
|
...t,
|
|
3347
3422
|
responseStatus: e.status,
|
|
3348
3423
|
responseHeaders: r,
|
|
3349
|
-
responseBody: await
|
|
3424
|
+
responseBody: await Br(e),
|
|
3350
3425
|
durationMs: Date.now() - s
|
|
3351
3426
|
});
|
|
3352
3427
|
}
|
|
3353
|
-
async function
|
|
3354
|
-
if (!
|
|
3428
|
+
async function Br(e) {
|
|
3429
|
+
if (!Xe(e.headers))
|
|
3355
3430
|
return;
|
|
3356
3431
|
let t = null, s = null;
|
|
3357
3432
|
try {
|
|
@@ -3360,7 +3435,7 @@ async function vr(e) {
|
|
|
3360
3435
|
const n = new Promise((a) => {
|
|
3361
3436
|
s = window.setTimeout(() => {
|
|
3362
3437
|
t?.cancel(), a("timeout");
|
|
3363
|
-
},
|
|
3438
|
+
}, Ks);
|
|
3364
3439
|
}), r = new TextDecoder();
|
|
3365
3440
|
let i = "", o = 0;
|
|
3366
3441
|
for (; ; ) {
|
|
@@ -3370,7 +3445,7 @@ async function vr(e) {
|
|
|
3370
3445
|
const { done: c, value: l } = a;
|
|
3371
3446
|
if (c)
|
|
3372
3447
|
return P(i + r.decode());
|
|
3373
|
-
const h =
|
|
3448
|
+
const h = Kt - o;
|
|
3374
3449
|
if (l.byteLength > h)
|
|
3375
3450
|
return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
|
|
3376
3451
|
o += l.byteLength, i += r.decode(l, { stream: !0 });
|
|
@@ -3382,45 +3457,45 @@ async function vr(e) {
|
|
|
3382
3457
|
s !== null && window.clearTimeout(s);
|
|
3383
3458
|
}
|
|
3384
3459
|
}
|
|
3385
|
-
function
|
|
3386
|
-
if (
|
|
3460
|
+
function qr(e, t) {
|
|
3461
|
+
if (Xe(new Headers(t)))
|
|
3387
3462
|
try {
|
|
3388
3463
|
return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
|
|
3389
3464
|
} catch {
|
|
3390
3465
|
return;
|
|
3391
3466
|
}
|
|
3392
3467
|
}
|
|
3393
|
-
function
|
|
3468
|
+
function Re(e) {
|
|
3394
3469
|
if (typeof e == "string")
|
|
3395
3470
|
return P(e);
|
|
3396
3471
|
}
|
|
3397
|
-
function
|
|
3472
|
+
function Hr(e) {
|
|
3398
3473
|
return _({
|
|
3399
3474
|
...e,
|
|
3400
|
-
requestBody:
|
|
3401
|
-
responseBody:
|
|
3475
|
+
requestBody: Me(e.requestBody),
|
|
3476
|
+
responseBody: Me(e.responseBody)
|
|
3402
3477
|
});
|
|
3403
3478
|
}
|
|
3404
|
-
function
|
|
3479
|
+
function Me(e) {
|
|
3405
3480
|
if (typeof e != "string")
|
|
3406
3481
|
return e;
|
|
3407
3482
|
const t = e.trim();
|
|
3408
3483
|
if (!t.startsWith("{") && !t.startsWith("["))
|
|
3409
|
-
return
|
|
3484
|
+
return lt(e);
|
|
3410
3485
|
try {
|
|
3411
3486
|
return JSON.stringify(_(JSON.parse(e)));
|
|
3412
3487
|
} catch {
|
|
3413
|
-
return
|
|
3488
|
+
return lt(e);
|
|
3414
3489
|
}
|
|
3415
3490
|
}
|
|
3416
|
-
function
|
|
3491
|
+
function Xe(e) {
|
|
3417
3492
|
if (!e)
|
|
3418
3493
|
return !1;
|
|
3419
3494
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3420
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3495
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= Kt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3421
3496
|
}
|
|
3422
3497
|
function x(e, t = {}, s) {
|
|
3423
|
-
if (
|
|
3498
|
+
if (Fr(s))
|
|
3424
3499
|
return !0;
|
|
3425
3500
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3426
3501
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3435,7 +3510,7 @@ function x(e, t = {}, s) {
|
|
|
3435
3510
|
return !0;
|
|
3436
3511
|
}
|
|
3437
3512
|
}
|
|
3438
|
-
function
|
|
3513
|
+
function Wr(e, t) {
|
|
3439
3514
|
if (x(e))
|
|
3440
3515
|
return !0;
|
|
3441
3516
|
try {
|
|
@@ -3445,117 +3520,117 @@ function Lr(e, t) {
|
|
|
3445
3520
|
return !0;
|
|
3446
3521
|
}
|
|
3447
3522
|
}
|
|
3448
|
-
function
|
|
3523
|
+
function Fr(e) {
|
|
3449
3524
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3450
3525
|
}
|
|
3451
|
-
function
|
|
3526
|
+
function $r(e) {
|
|
3452
3527
|
const t = {};
|
|
3453
3528
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3454
3529
|
const n = s.indexOf(":");
|
|
3455
3530
|
if (n <= 0)
|
|
3456
3531
|
continue;
|
|
3457
|
-
if (Object.keys(t).length >=
|
|
3532
|
+
if (Object.keys(t).length >= Gt)
|
|
3458
3533
|
break;
|
|
3459
3534
|
const r = s.slice(0, n).trim();
|
|
3460
|
-
t[r] =
|
|
3535
|
+
t[r] = Zt(r, s.slice(n + 1).trim());
|
|
3461
3536
|
}
|
|
3462
3537
|
return t;
|
|
3463
3538
|
}
|
|
3464
|
-
function P(e, t =
|
|
3539
|
+
function P(e, t = Kt) {
|
|
3465
3540
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
3466
3541
|
}
|
|
3467
|
-
function
|
|
3542
|
+
function Dt(e) {
|
|
3468
3543
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3469
3544
|
}
|
|
3470
|
-
class
|
|
3545
|
+
class at extends Error {
|
|
3471
3546
|
constructor(t, s) {
|
|
3472
3547
|
super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
3473
3548
|
}
|
|
3474
3549
|
status;
|
|
3475
3550
|
}
|
|
3476
|
-
async function
|
|
3551
|
+
async function rt(e, t) {
|
|
3477
3552
|
let s = null;
|
|
3478
|
-
for (let n = 0; n <
|
|
3553
|
+
for (let n = 0; n < fe; n += 1)
|
|
3479
3554
|
try {
|
|
3480
3555
|
return await e();
|
|
3481
3556
|
} catch (r) {
|
|
3482
|
-
if (s = r, n >=
|
|
3557
|
+
if (s = r, n >= fe - 1 || !zr(r))
|
|
3483
3558
|
throw r;
|
|
3484
|
-
await
|
|
3559
|
+
await jr(n);
|
|
3485
3560
|
}
|
|
3486
3561
|
throw s instanceof Error ? s : new Error(t);
|
|
3487
3562
|
}
|
|
3488
|
-
function
|
|
3563
|
+
function jr(e) {
|
|
3489
3564
|
return new Promise((t) => {
|
|
3490
|
-
window.setTimeout(t,
|
|
3565
|
+
window.setTimeout(t, $s[e] ?? 0);
|
|
3491
3566
|
});
|
|
3492
3567
|
}
|
|
3493
|
-
function
|
|
3494
|
-
return e instanceof
|
|
3568
|
+
function zr(e) {
|
|
3569
|
+
return e instanceof at ? Kr(e.status) : e instanceof TypeError;
|
|
3495
3570
|
}
|
|
3496
|
-
function
|
|
3571
|
+
function Kr(e) {
|
|
3497
3572
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3498
3573
|
}
|
|
3499
|
-
function
|
|
3574
|
+
function Gr(e) {
|
|
3500
3575
|
return e === 401 || e === 403;
|
|
3501
3576
|
}
|
|
3502
|
-
const
|
|
3577
|
+
const ht = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", Xr = "[REDACTED_SIGNED_URL]", Jr = 20, Vr = /^(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, Je = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Ve = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ye = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ze = /\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, Yr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Zr = /\bhttps?:\/\/[^\s"'<>]+/gi, Qr = /[),.;\]]+$/;
|
|
3503
3578
|
function _(e) {
|
|
3504
|
-
return
|
|
3579
|
+
return ct(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3505
3580
|
}
|
|
3506
|
-
function
|
|
3581
|
+
function ct(e, t, s) {
|
|
3507
3582
|
if (typeof e == "string")
|
|
3508
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
3583
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : lt(e);
|
|
3509
3584
|
if (e === null || typeof e != "object")
|
|
3510
3585
|
return e;
|
|
3511
|
-
if (t >=
|
|
3586
|
+
if (t >= Jr)
|
|
3512
3587
|
return "[REDACTED_MAX_DEPTH]";
|
|
3513
3588
|
if (s.has(e))
|
|
3514
3589
|
return "[REDACTED_CIRCULAR]";
|
|
3515
3590
|
if (s.add(e), Array.isArray(e))
|
|
3516
|
-
return e.map((r) =>
|
|
3591
|
+
return e.map((r) => ct(r, t + 1, s));
|
|
3517
3592
|
const n = {};
|
|
3518
3593
|
for (const [r, i] of Object.entries(e))
|
|
3519
|
-
r === "pageContent" ? n[r] = i :
|
|
3594
|
+
r === "pageContent" ? n[r] = i : Qe(r) ? n[r] = ht : n[r] = r.toLowerCase() === "url" ? ti(i) : ct(i, t + 1, s);
|
|
3520
3595
|
return n;
|
|
3521
3596
|
}
|
|
3522
|
-
function
|
|
3597
|
+
function Qe(e) {
|
|
3523
3598
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3524
3599
|
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");
|
|
3525
3600
|
}
|
|
3526
|
-
function
|
|
3527
|
-
return typeof e == "string" ?
|
|
3601
|
+
function ti(e) {
|
|
3602
|
+
return typeof e == "string" ? ts(e) : ct(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3528
3603
|
}
|
|
3529
|
-
function
|
|
3604
|
+
function ts(e) {
|
|
3530
3605
|
try {
|
|
3531
3606
|
const t = new URL(e, location.href);
|
|
3532
3607
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3533
|
-
|
|
3608
|
+
Vr.test(s) && t.searchParams.set(s, U);
|
|
3534
3609
|
return t.username && (t.username = U), t.password && (t.password = U), t.toString();
|
|
3535
3610
|
} catch {
|
|
3536
|
-
return
|
|
3611
|
+
return ei(e);
|
|
3537
3612
|
}
|
|
3538
3613
|
}
|
|
3539
|
-
function
|
|
3540
|
-
return e.replace(
|
|
3614
|
+
function lt(e) {
|
|
3615
|
+
return e.replace(Yr, Xr).replace(Zr, si).replace(Je, `Bearer ${U}`).replace(Ve, `Basic ${U}`).replace(Ye, U).replace(Ze, (t, s) => `${s}: ${ht}`);
|
|
3541
3616
|
}
|
|
3542
|
-
function
|
|
3543
|
-
return e.replace(
|
|
3617
|
+
function ei(e) {
|
|
3618
|
+
return e.replace(Je, `Bearer ${U}`).replace(Ve, `Basic ${U}`).replace(Ye, U).replace(Ze, (t, s) => `${s}: ${ht}`);
|
|
3544
3619
|
}
|
|
3545
|
-
function
|
|
3546
|
-
const t = e.match(
|
|
3547
|
-
return `${
|
|
3620
|
+
function si(e) {
|
|
3621
|
+
const t = e.match(Qr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3622
|
+
return `${ts(s)}${t}`;
|
|
3548
3623
|
}
|
|
3549
3624
|
export {
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3625
|
+
ce as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3626
|
+
Nt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3627
|
+
Ms as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3628
|
+
Rs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3629
|
+
bs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3630
|
+
ni as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
3631
|
+
De as PlunoProductAgent,
|
|
3632
|
+
Js as calculateReconnectDelay,
|
|
3633
|
+
De as default,
|
|
3634
|
+
Tn as getProductAgentOriginAccessErrorMessage,
|
|
3635
|
+
Pr as validateProductAgentProviderInputFile
|
|
3561
3636
|
};
|