@pluno/product-agent-web 0.1.143 → 0.1.145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -0
- package/dist/product-agent-sdk.js +507 -466
- package/dist/product-agent-widget.js +1615 -1574
- 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 Ve = "pluno-product-agent-attachments";
|
|
2
|
+
const Ct = "files";
|
|
3
|
+
async function Ye(e) {
|
|
4
|
+
const t = await qt();
|
|
5
|
+
await ts(t, "readwrite", (s) => s.put(e));
|
|
6
|
+
}
|
|
7
|
+
async function Ze(e, t) {
|
|
8
|
+
const s = await qt();
|
|
9
|
+
await Bt(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await Ht(
|
|
11
11
|
n.get(e)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,28 +16,28 @@ async function Ve(e, t) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const t = await
|
|
21
|
-
await
|
|
19
|
+
async function Qe(e = 864e5) {
|
|
20
|
+
const t = await qt(), s = Date.now() - e;
|
|
21
|
+
await Bt(t, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await Ht(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function qt() {
|
|
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(Ve, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(Ct, { 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 ts(e, t, s) {
|
|
36
|
+
return await Bt(e, t, async (n) => await Ht(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Bt(e, t, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = e.transaction(
|
|
40
|
+
const i = e.transaction(Ct, t), o = i.objectStore(Ct);
|
|
41
41
|
let a, c = !1;
|
|
42
42
|
s(o).then((l) => {
|
|
43
43
|
a = l;
|
|
@@ -57,16 +57,16 @@ function qt(e, t, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Ht(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 es(e) {
|
|
66
66
|
return e !== null && (typeof e == "object" || typeof e == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const n = Reflect.get(e, "pluno"), r =
|
|
68
|
+
function Re(e, t, s) {
|
|
69
|
+
const n = Reflect.get(e, "pluno"), r = es(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,17 +80,17 @@ function Ae(e, t, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const ss = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function ns(e, t) {
|
|
85
85
|
return t ? e.replace(
|
|
86
|
-
|
|
86
|
+
ss,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
|
|
88
88
|
) : e;
|
|
89
89
|
}
|
|
90
|
-
const St = "pluno.productAgent.transportId",
|
|
90
|
+
const St = "pluno.productAgent.transportId", rs = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", is = 50, os = globalThis.setTimeout.bind(globalThis);
|
|
91
91
|
let W = null;
|
|
92
92
|
const et = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Map();
|
|
93
|
-
async function
|
|
93
|
+
async function as(e = be()) {
|
|
94
94
|
const t = e.randomUUID(), s = e.storage.getItem(St);
|
|
95
95
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
96
96
|
const o = e.channel.subscribe((c) => {
|
|
@@ -126,14 +126,14 @@ async function is(e = Ee()) {
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
-
async function
|
|
130
|
-
W || (W =
|
|
129
|
+
async function cs() {
|
|
130
|
+
W || (W = as(be()), W.then((n) => {
|
|
131
131
|
const r = (i) => {
|
|
132
132
|
i.persisted || (n.release(), W = null, et.clear(), window.removeEventListener("pagehide", r));
|
|
133
133
|
};
|
|
134
134
|
window.addEventListener("pagehide", r);
|
|
135
135
|
}));
|
|
136
|
-
const e = await W, t =
|
|
136
|
+
const e = await W, t = ls();
|
|
137
137
|
et.add(t);
|
|
138
138
|
let s = !1;
|
|
139
139
|
return {
|
|
@@ -144,21 +144,21 @@ async function os() {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function ls() {
|
|
148
148
|
let e = 0;
|
|
149
149
|
for (; et.has(e); )
|
|
150
150
|
e += 1;
|
|
151
151
|
return e;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function be() {
|
|
154
154
|
return {
|
|
155
|
-
storage:
|
|
156
|
-
channel:
|
|
155
|
+
storage: us(),
|
|
156
|
+
channel: ds(),
|
|
157
157
|
randomUUID: () => crypto.randomUUID(),
|
|
158
|
-
settle: () => new Promise((e) =>
|
|
158
|
+
settle: () => new Promise((e) => os(e, is))
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function us() {
|
|
162
162
|
return {
|
|
163
163
|
getItem: (e) => {
|
|
164
164
|
try {
|
|
@@ -176,9 +176,9 @@ function cs() {
|
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
|
-
function
|
|
179
|
+
function ds() {
|
|
180
180
|
if (typeof BroadcastChannel < "u") {
|
|
181
|
-
const e = new BroadcastChannel(
|
|
181
|
+
const e = new BroadcastChannel(rs);
|
|
182
182
|
return {
|
|
183
183
|
postMessage: (t) => e.postMessage(t),
|
|
184
184
|
subscribe: (t) => {
|
|
@@ -188,9 +188,9 @@ function ls() {
|
|
|
188
188
|
close: () => e.close()
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
return
|
|
191
|
+
return hs();
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function hs() {
|
|
194
194
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
195
195
|
if (s.key !== At || !s.newValue)
|
|
196
196
|
return;
|
|
@@ -211,18 +211,52 @@ function us() {
|
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
|
-
const
|
|
214
|
+
const ps = globalThis.fetch.bind(globalThis), Pt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', fs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', gs = ".pluno-pa-widget__panel", ms = ".pluno-pa-widget__timeline", ne = `${Pt}[data-pluno-sdk-preview-channel]`;
|
|
215
|
+
let ys = 0;
|
|
216
|
+
function re(e) {
|
|
217
|
+
const t = {};
|
|
218
|
+
for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
|
|
219
|
+
const o = e[i];
|
|
220
|
+
(typeof o == "string" || typeof o == "number" || typeof o == "boolean" || o === null) && (t[i] = o);
|
|
221
|
+
}
|
|
222
|
+
const s = e.content;
|
|
223
|
+
typeof s == "string" && (t.contentLength = s.length);
|
|
224
|
+
const n = e.delta;
|
|
225
|
+
typeof n == "string" && (t.deltaLength = n.length);
|
|
226
|
+
const r = e.attachments;
|
|
227
|
+
return Array.isArray(r) && (t.attachmentCount = r.length), t;
|
|
228
|
+
}
|
|
229
|
+
function Rt(e, t, s) {
|
|
230
|
+
if (typeof window > "u")
|
|
231
|
+
return;
|
|
232
|
+
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
233
|
+
if (!n)
|
|
234
|
+
return;
|
|
235
|
+
const r = {
|
|
236
|
+
schemaVersion: 1,
|
|
237
|
+
traceId: n,
|
|
238
|
+
source: "web_sdk",
|
|
239
|
+
category: e,
|
|
240
|
+
name: t,
|
|
241
|
+
sequence: ++ys,
|
|
242
|
+
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
243
|
+
monotonicMs: performance.now(),
|
|
244
|
+
data: s
|
|
245
|
+
};
|
|
246
|
+
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
247
|
+
}
|
|
248
|
+
const Is = "https://app.pluno.ai", Ts = "gpt-5.6-terra", ws = 2e4, Ss = 1e4, As = 1e4, Es = 1e4, Rs = 1e4, bs = 1e3, ie = 3e4, oe = 0.2, ae = 6e4, Ms = 15e3, V = 8, ks = 15e3, _s = 2e3, Cs = 1e3, Ps = 100, ce = 8e3, le = 3, Us = [300, 1e3], Ft = 64e3, bt = 4e3, Wt = 30, Ds = 2e3, Ns = 1e3, Me = "Image is too large for model vision input.", xs = 100, ke = "pluno.productAgent.state.", Ut = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Os = 100;
|
|
215
249
|
function Y(e, t = 0) {
|
|
216
250
|
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
217
251
|
return Math.max(t, s);
|
|
218
252
|
}
|
|
219
253
|
const st = /* @__PURE__ */ new Set();
|
|
220
254
|
let Z = null;
|
|
221
|
-
function
|
|
222
|
-
const s = Math.min(
|
|
223
|
-
return Math.min(
|
|
255
|
+
function vs(e, t = Math.random) {
|
|
256
|
+
const s = Math.min(ie, bs * 2 ** e), n = 1 - oe + t() * oe * 2;
|
|
257
|
+
return Math.min(ie, Math.round(s * n));
|
|
224
258
|
}
|
|
225
|
-
function
|
|
259
|
+
function Ls(e, t, s) {
|
|
226
260
|
return new Promise((n, r) => {
|
|
227
261
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
228
262
|
e.then(
|
|
@@ -235,13 +269,13 @@ function Ns(e, t, s) {
|
|
|
235
269
|
);
|
|
236
270
|
});
|
|
237
271
|
}
|
|
238
|
-
class
|
|
272
|
+
class _e {
|
|
239
273
|
constructor(t, s) {
|
|
240
274
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
241
275
|
...this.state,
|
|
242
|
-
starterPrompts:
|
|
276
|
+
starterPrompts: In(t.initialStarterPrompts)
|
|
243
277
|
};
|
|
244
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
278
|
+
const n = t.restorePersistedState === !1 ? null : or(t.clientId, t.expectedPersistedSessionId);
|
|
245
279
|
n && (this.state = {
|
|
246
280
|
...this.state,
|
|
247
281
|
...n,
|
|
@@ -254,9 +288,9 @@ class Me {
|
|
|
254
288
|
assistantDraftRunId: null,
|
|
255
289
|
isThinking: !1,
|
|
256
290
|
lastError: null
|
|
257
|
-
}), this.queuedClientEvents =
|
|
258
|
-
|
|
259
|
-
|
|
291
|
+
}), this.queuedClientEvents = pr(
|
|
292
|
+
cr(t.clientId),
|
|
293
|
+
ur(t.clientId)
|
|
260
294
|
), j(t.clientId, this.queuedClientEvents);
|
|
261
295
|
}
|
|
262
296
|
options;
|
|
@@ -328,15 +362,15 @@ class Me {
|
|
|
328
362
|
lastErrorSecuritySettingsUrl: null
|
|
329
363
|
};
|
|
330
364
|
static async init(t) {
|
|
331
|
-
const s = await
|
|
365
|
+
const s = await cs(), n = new _e({
|
|
332
366
|
...t,
|
|
333
|
-
backendUrl:
|
|
334
|
-
clientId: t.clientId ??
|
|
335
|
-
model: t.model ??
|
|
336
|
-
entrySurface:
|
|
367
|
+
backendUrl: sn(t.backendUrl ?? Is),
|
|
368
|
+
clientId: t.clientId ?? En(),
|
|
369
|
+
model: t.model ?? Ts,
|
|
370
|
+
entrySurface: nn(t.entrySurface)
|
|
337
371
|
}, s);
|
|
338
372
|
try {
|
|
339
|
-
|
|
373
|
+
Qe().catch((r) => {
|
|
340
374
|
S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
341
375
|
message: r instanceof Error ? r.message : String(r)
|
|
342
376
|
});
|
|
@@ -367,14 +401,14 @@ class Me {
|
|
|
367
401
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
368
402
|
);
|
|
369
403
|
try {
|
|
370
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
404
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ls(this.options.tokenProvider(), As, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
371
405
|
return;
|
|
372
406
|
if (!this.token && !this.options.webSocketFactory)
|
|
373
407
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
374
|
-
const s =
|
|
408
|
+
const s = an(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
375
409
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
376
410
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
377
|
-
},
|
|
411
|
+
}, Es), n.addEventListener("open", () => {
|
|
378
412
|
this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
|
|
379
413
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
380
414
|
isThinking: this.state.isThinking
|
|
@@ -386,9 +420,9 @@ class Me {
|
|
|
386
420
|
pageUrl: location.href
|
|
387
421
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
388
422
|
this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
389
|
-
},
|
|
423
|
+
}, Rs));
|
|
390
424
|
}), n.addEventListener("message", (r) => {
|
|
391
|
-
this.socket === n && this.handleServerEvent(
|
|
425
|
+
this.socket === n && this.handleServerEvent(yn(r.data));
|
|
392
426
|
}), n.addEventListener("close", (r) => {
|
|
393
427
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
394
428
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -421,7 +455,7 @@ class Me {
|
|
|
421
455
|
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;
|
|
422
456
|
}
|
|
423
457
|
destroy() {
|
|
424
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
458
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), fr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
425
459
|
for (const t of Object.values(this.listeners))
|
|
426
460
|
t?.clear();
|
|
427
461
|
}
|
|
@@ -437,7 +471,7 @@ class Me {
|
|
|
437
471
|
}
|
|
438
472
|
async sendMessage(t, s = {}) {
|
|
439
473
|
const n = t.trim(), r = s.attachments ?? [];
|
|
440
|
-
let i = r.map(
|
|
474
|
+
let i = r.map(Gt);
|
|
441
475
|
if (!n && i.length === 0)
|
|
442
476
|
return null;
|
|
443
477
|
const o = b(), a = s.clientMessageId ?? $(), c = {
|
|
@@ -491,14 +525,14 @@ class Me {
|
|
|
491
525
|
sessionId: this.state.sessionId ?? void 0,
|
|
492
526
|
clientMessageId: a,
|
|
493
527
|
initiatedBy: s.initiatedBy,
|
|
494
|
-
invocation:
|
|
528
|
+
invocation: rn(s.invocation ?? s.initiatedBy),
|
|
495
529
|
entrySurface: this.options.entrySurface,
|
|
496
530
|
content: n,
|
|
497
|
-
pageContent: d &&
|
|
531
|
+
pageContent: d && $t() || void 0,
|
|
498
532
|
attachments: i.length > 0 ? i : void 0,
|
|
499
533
|
page: o,
|
|
500
534
|
model: this.options.model,
|
|
501
|
-
metadata:
|
|
535
|
+
metadata: ue(this.options.metadata)
|
|
502
536
|
};
|
|
503
537
|
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = f, this.markThinkingProgress(), this.send(f), a;
|
|
504
538
|
}
|
|
@@ -510,12 +544,12 @@ class Me {
|
|
|
510
544
|
const s = $(), n = {
|
|
511
545
|
id: s,
|
|
512
546
|
name: t.name || "attachment",
|
|
513
|
-
mimeType:
|
|
547
|
+
mimeType: Se(t),
|
|
514
548
|
sizeBytes: t.size
|
|
515
549
|
};
|
|
516
550
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
517
551
|
const r = Date.now();
|
|
518
|
-
return
|
|
552
|
+
return Ye({
|
|
519
553
|
attachmentId: s,
|
|
520
554
|
name: n.name,
|
|
521
555
|
mimeType: n.mimeType,
|
|
@@ -544,7 +578,7 @@ class Me {
|
|
|
544
578
|
file: t,
|
|
545
579
|
attachment: s
|
|
546
580
|
}) {
|
|
547
|
-
const n = this.state.sessionId, r =
|
|
581
|
+
const n = this.state.sessionId, r = Se(t), i = {
|
|
548
582
|
sessionId: n ?? void 0,
|
|
549
583
|
attachmentId: s.id,
|
|
550
584
|
clientId: this.options.clientId,
|
|
@@ -554,7 +588,7 @@ class Me {
|
|
|
554
588
|
sizeBytes: t.size,
|
|
555
589
|
page: b(),
|
|
556
590
|
model: this.options.model,
|
|
557
|
-
metadata:
|
|
591
|
+
metadata: ue(this.options.metadata),
|
|
558
592
|
entrySurface: this.options.entrySurface
|
|
559
593
|
};
|
|
560
594
|
let o;
|
|
@@ -580,8 +614,8 @@ class Me {
|
|
|
580
614
|
}, "Failed to upload attachment"), o = c;
|
|
581
615
|
}
|
|
582
616
|
this.setState({ sessionId: o.sessionId });
|
|
583
|
-
const a =
|
|
584
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
617
|
+
const a = Be(o.attachment, this.options.backendUrl);
|
|
618
|
+
return this.updateAttachmentInState(s.id, a), s.id && Ze(s.id, {
|
|
585
619
|
sessionId: o.sessionId,
|
|
586
620
|
fileUrl: a.fileUrl,
|
|
587
621
|
sandboxPath: a.sandboxPath,
|
|
@@ -611,7 +645,7 @@ class Me {
|
|
|
611
645
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
612
646
|
if (n.ok)
|
|
613
647
|
return await n.json();
|
|
614
|
-
if (
|
|
648
|
+
if (Pr(n.status) && this.options.tokenProvider && !s) {
|
|
615
649
|
s = !0;
|
|
616
650
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
617
651
|
if (r.ok)
|
|
@@ -658,7 +692,7 @@ class Me {
|
|
|
658
692
|
const s = $(), n = new Promise((i, o) => {
|
|
659
693
|
const a = window.setTimeout(() => {
|
|
660
694
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
661
|
-
},
|
|
695
|
+
}, ce);
|
|
662
696
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
663
697
|
}), r = {
|
|
664
698
|
type: "sessions.list",
|
|
@@ -719,7 +753,7 @@ class Me {
|
|
|
719
753
|
return !1;
|
|
720
754
|
const s = this.socket;
|
|
721
755
|
try {
|
|
722
|
-
return s.send(JSON.stringify(t)), !0;
|
|
756
|
+
return s.send(JSON.stringify(t)), Rt("client_event", t.type, re(t)), !0;
|
|
723
757
|
} catch (n) {
|
|
724
758
|
return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
725
759
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -732,7 +766,7 @@ class Me {
|
|
|
732
766
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
733
767
|
return;
|
|
734
768
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
735
|
-
const t =
|
|
769
|
+
const t = cn();
|
|
736
770
|
this.sendNow(
|
|
737
771
|
M({
|
|
738
772
|
type: "starter_prompts.page_context",
|
|
@@ -743,13 +777,13 @@ class Me {
|
|
|
743
777
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
744
778
|
}
|
|
745
779
|
startStarterPromptUrlWatcher() {
|
|
746
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
780
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = ln(() => this.handleStarterPromptUrlChange()));
|
|
747
781
|
}
|
|
748
782
|
handleStarterPromptUrlChange() {
|
|
749
783
|
const t = location.href;
|
|
750
784
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
751
785
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
752
|
-
},
|
|
786
|
+
}, Os));
|
|
753
787
|
}
|
|
754
788
|
refreshStarterPromptsForCurrentUrl() {
|
|
755
789
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -778,7 +812,7 @@ class Me {
|
|
|
778
812
|
!this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
|
|
779
813
|
}
|
|
780
814
|
handleServerEvent(t) {
|
|
781
|
-
if (t.type === "run.steered") {
|
|
815
|
+
if (Rt("server_event", t.type, re(t)), t.type === "run.steered") {
|
|
782
816
|
this.handleRunSteered(t);
|
|
783
817
|
return;
|
|
784
818
|
}
|
|
@@ -790,20 +824,20 @@ class Me {
|
|
|
790
824
|
this.clearHeartbeatAckTimer();
|
|
791
825
|
return;
|
|
792
826
|
}
|
|
793
|
-
if (
|
|
827
|
+
if (Hs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
794
828
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
|
|
795
|
-
const s =
|
|
829
|
+
const s = Tn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
796
830
|
S("web-sdk.agent", "Received auth.ok appearance", {
|
|
797
831
|
hasAppearance: n,
|
|
798
832
|
rawAppearance: t.appearance,
|
|
799
833
|
normalizedAppearance: s
|
|
800
|
-
}), this.runtimeHelperJavascript =
|
|
801
|
-
const r =
|
|
802
|
-
user:
|
|
834
|
+
}), this.runtimeHelperJavascript = wn(t.runtimeHelpers)?.javascript ?? null;
|
|
835
|
+
const r = pe(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
836
|
+
user: Rn(t.user),
|
|
803
837
|
status: "connected",
|
|
804
838
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
805
839
|
};
|
|
806
|
-
(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 && !
|
|
840
|
+
(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 && !dn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
807
841
|
type: "page.upsert",
|
|
808
842
|
sessionId: this.state.sessionId,
|
|
809
843
|
page: b(),
|
|
@@ -813,19 +847,19 @@ class Me {
|
|
|
813
847
|
}
|
|
814
848
|
if (t.type === "starterPrompts.updated") {
|
|
815
849
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
816
|
-
starterPrompts:
|
|
850
|
+
starterPrompts: pe(t, "starterPrompts"),
|
|
817
851
|
starterPromptsLoading: !1
|
|
818
852
|
});
|
|
819
853
|
return;
|
|
820
854
|
}
|
|
821
855
|
if (t.type === "conversation.state") {
|
|
822
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
856
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Dn(
|
|
823
857
|
t.assistantDraft
|
|
824
858
|
), r = n !== void 0;
|
|
825
859
|
this.rememberUserMessageClientMessageIds(s);
|
|
826
|
-
const i =
|
|
860
|
+
const i = Kn(s);
|
|
827
861
|
if (i) {
|
|
828
|
-
const h =
|
|
862
|
+
const h = Jn(s, i);
|
|
829
863
|
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
830
864
|
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
831
865
|
h
|
|
@@ -833,22 +867,22 @@ class Me {
|
|
|
833
867
|
}
|
|
834
868
|
const o = s.filter((h) => {
|
|
835
869
|
const y = q(h);
|
|
836
|
-
return !
|
|
837
|
-
}), a =
|
|
870
|
+
return !me(y) && (!i || !Ot(y));
|
|
871
|
+
}), a = Hn(
|
|
838
872
|
this.state.messages,
|
|
839
|
-
|
|
840
|
-
), c =
|
|
841
|
-
(h) =>
|
|
873
|
+
bn(o, this.options.backendUrl)
|
|
874
|
+
), c = ge(a), l = !r && s.some(
|
|
875
|
+
(h) => Ie(
|
|
842
876
|
q(h),
|
|
843
877
|
this.state.assistantDraft,
|
|
844
878
|
this.state.assistantDraftItemId,
|
|
845
879
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
846
880
|
this.state.assistantDraftRunId
|
|
847
881
|
)
|
|
848
|
-
), u = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, I = c && (!u || l), m =
|
|
849
|
-
if (!c &&
|
|
882
|
+
), u = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, I = c && (!u || l), m = zn(a), d = I && m;
|
|
883
|
+
if (!c && Xn(this.state.messages, s))
|
|
850
884
|
return;
|
|
851
|
-
this.lastUserMessagePageUrl =
|
|
885
|
+
this.lastUserMessagePageUrl = Gn(s);
|
|
852
886
|
const f = I ? null : vt(s);
|
|
853
887
|
if (this.latestRecoverableClientMessageId = f, m && this.clearRetryTimers(), this.setState({
|
|
854
888
|
sessionId: E(t.session, "id") ?? this.state.sessionId,
|
|
@@ -890,7 +924,7 @@ class Me {
|
|
|
890
924
|
if (t.type === "sessions.page") {
|
|
891
925
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
892
926
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
893
|
-
sessions:
|
|
927
|
+
sessions: Mn(t.sessions),
|
|
894
928
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
895
929
|
}));
|
|
896
930
|
return;
|
|
@@ -910,9 +944,9 @@ class Me {
|
|
|
910
944
|
if (t.type === "session.item") {
|
|
911
945
|
this.rememberUserMessageClientMessageIds([t.item]);
|
|
912
946
|
const s = q(t.item);
|
|
913
|
-
if (
|
|
947
|
+
if (Ot(s)) {
|
|
914
948
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
915
|
-
const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ?
|
|
949
|
+
const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
916
950
|
if (r && a) {
|
|
917
951
|
this.retryAfterInterruptedRun(r, a);
|
|
918
952
|
return;
|
|
@@ -922,21 +956,21 @@ class Me {
|
|
|
922
956
|
return;
|
|
923
957
|
}
|
|
924
958
|
}
|
|
925
|
-
if (
|
|
959
|
+
if (me(s))
|
|
926
960
|
return;
|
|
927
|
-
const n =
|
|
961
|
+
const n = Ne(t.item, this.options.backendUrl);
|
|
928
962
|
if (n) {
|
|
929
963
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
930
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
964
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), x(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
931
965
|
const i = t.item.data;
|
|
932
|
-
|
|
933
|
-
const o =
|
|
966
|
+
Yn(i) && this.clearRunAckResyncRetryTimer();
|
|
967
|
+
const o = Dt(this.state.messages, n), a = ge(o), c = Ie(
|
|
934
968
|
i,
|
|
935
969
|
this.state.assistantDraft,
|
|
936
970
|
this.state.assistantDraftItemId,
|
|
937
971
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
938
972
|
this.state.assistantDraftRunId
|
|
939
|
-
), l = a && (!this.state.assistantDraft || c), u = l &&
|
|
973
|
+
), l = a && (!this.state.assistantDraft || c), u = l && x(n);
|
|
940
974
|
this.setState({
|
|
941
975
|
messages: o,
|
|
942
976
|
...c ? {
|
|
@@ -963,7 +997,7 @@ class Me {
|
|
|
963
997
|
this.clearRunAckResyncRetryTimer();
|
|
964
998
|
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((p) => p.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, u = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
|
|
965
999
|
this.setState({
|
|
966
|
-
messages:
|
|
1000
|
+
messages: Dt(this.state.messages, {
|
|
967
1001
|
id: o,
|
|
968
1002
|
role: "assistant",
|
|
969
1003
|
content: i,
|
|
@@ -993,7 +1027,7 @@ class Me {
|
|
|
993
1027
|
this.setState({
|
|
994
1028
|
sessionId: s,
|
|
995
1029
|
messages: this.state.messages.filter(
|
|
996
|
-
(c) => c.dataType !== "assistant_draft" || !
|
|
1030
|
+
(c) => c.dataType !== "assistant_draft" || !On(
|
|
997
1031
|
c,
|
|
998
1032
|
n,
|
|
999
1033
|
r
|
|
@@ -1014,9 +1048,9 @@ class Me {
|
|
|
1014
1048
|
if (s)
|
|
1015
1049
|
this.nonTranscriptToolCallIds.add(s);
|
|
1016
1050
|
else {
|
|
1017
|
-
const n =
|
|
1051
|
+
const n = qn(t);
|
|
1018
1052
|
if (n) {
|
|
1019
|
-
const r =
|
|
1053
|
+
const r = vn(
|
|
1020
1054
|
this.state.messages,
|
|
1021
1055
|
n
|
|
1022
1056
|
);
|
|
@@ -1060,7 +1094,7 @@ class Me {
|
|
|
1060
1094
|
return;
|
|
1061
1095
|
}
|
|
1062
1096
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1063
|
-
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c =
|
|
1097
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = on(a.message);
|
|
1064
1098
|
c && console.error(c), this.setState({
|
|
1065
1099
|
status: "error",
|
|
1066
1100
|
isThinking: !1,
|
|
@@ -1138,7 +1172,7 @@ class Me {
|
|
|
1138
1172
|
const r = new Promise((i, o) => {
|
|
1139
1173
|
const a = window.setTimeout(() => {
|
|
1140
1174
|
t.delete(s.requestId), o(new Error(n));
|
|
1141
|
-
},
|
|
1175
|
+
}, ce);
|
|
1142
1176
|
t.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1143
1177
|
});
|
|
1144
1178
|
if (!this.sendNow(s)) {
|
|
@@ -1161,7 +1195,7 @@ class Me {
|
|
|
1161
1195
|
t.clear();
|
|
1162
1196
|
}
|
|
1163
1197
|
markThinkingProgress() {
|
|
1164
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1198
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ae), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1165
1199
|
}
|
|
1166
1200
|
scheduleThinkingWatchdog(t) {
|
|
1167
1201
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1181,7 +1215,7 @@ class Me {
|
|
|
1181
1215
|
handleRunSteered(t) {
|
|
1182
1216
|
const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
|
|
1183
1217
|
!this.state.isThinking || !s || this.setState({
|
|
1184
|
-
messages:
|
|
1218
|
+
messages: Qn(
|
|
1185
1219
|
this.state.messages,
|
|
1186
1220
|
s
|
|
1187
1221
|
)
|
|
@@ -1190,7 +1224,7 @@ class Me {
|
|
|
1190
1224
|
scheduleRunAckWatchdog(t) {
|
|
1191
1225
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1192
1226
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1193
|
-
},
|
|
1227
|
+
}, ks);
|
|
1194
1228
|
}
|
|
1195
1229
|
recoverMissedRunAck(t) {
|
|
1196
1230
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1214,8 +1248,8 @@ class Me {
|
|
|
1214
1248
|
sessionId: this.state.sessionId,
|
|
1215
1249
|
clientMessageId: t,
|
|
1216
1250
|
automatic: !0
|
|
1217
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1218
|
-
}, Y(s,
|
|
1251
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ae)));
|
|
1252
|
+
}, Y(s, _s)));
|
|
1219
1253
|
}
|
|
1220
1254
|
clearRunAckResyncRetryTimer() {
|
|
1221
1255
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1254,7 +1288,7 @@ class Me {
|
|
|
1254
1288
|
sessionId: this.state.sessionId,
|
|
1255
1289
|
clientMessageId: t,
|
|
1256
1290
|
resyncAttempts: s + 1
|
|
1257
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1291
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ms);
|
|
1258
1292
|
return;
|
|
1259
1293
|
}
|
|
1260
1294
|
this.setState({
|
|
@@ -1289,7 +1323,7 @@ class Me {
|
|
|
1289
1323
|
if (!s || !n || !r)
|
|
1290
1324
|
return;
|
|
1291
1325
|
const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1292
|
-
if (!a && !c || !
|
|
1326
|
+
if (!a && !c || !Ir(o)) {
|
|
1293
1327
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1294
1328
|
type: "tool.result",
|
|
1295
1329
|
sessionId: s,
|
|
@@ -1321,7 +1355,7 @@ class Me {
|
|
|
1321
1355
|
});
|
|
1322
1356
|
return;
|
|
1323
1357
|
}
|
|
1324
|
-
const l =
|
|
1358
|
+
const l = $s(this.state.messages);
|
|
1325
1359
|
this.activeBrowserToolCalls.set(n, {
|
|
1326
1360
|
event: {
|
|
1327
1361
|
type: "tool.result",
|
|
@@ -1337,9 +1371,9 @@ class Me {
|
|
|
1337
1371
|
startedAtOrigin: location.origin
|
|
1338
1372
|
}), this.installSessionUserFilesApi(l);
|
|
1339
1373
|
let u = null, p;
|
|
1340
|
-
u = await this.executeRuntimeHelper(), p = await
|
|
1374
|
+
u = await this.executeRuntimeHelper(), p = await de(
|
|
1341
1375
|
o,
|
|
1342
|
-
|
|
1376
|
+
tn(t.runtimeContext, this.options.backendUrl)
|
|
1343
1377
|
).catch((I) => ({
|
|
1344
1378
|
ok: !1,
|
|
1345
1379
|
exception: {
|
|
@@ -1352,11 +1386,11 @@ class Me {
|
|
|
1352
1386
|
toolName: r,
|
|
1353
1387
|
summary: o.summary,
|
|
1354
1388
|
rawInput: M(o),
|
|
1355
|
-
rawOutput: M(
|
|
1356
|
-
}),
|
|
1389
|
+
rawOutput: M(Sn(p, u))
|
|
1390
|
+
}), lr(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1357
1391
|
}
|
|
1358
1392
|
setToolMessageLoading(t, s) {
|
|
1359
|
-
const n =
|
|
1393
|
+
const n = Ln(
|
|
1360
1394
|
this.state.messages,
|
|
1361
1395
|
t,
|
|
1362
1396
|
s
|
|
@@ -1367,33 +1401,33 @@ class Me {
|
|
|
1367
1401
|
if (this.pageLifecycleCleanup)
|
|
1368
1402
|
return;
|
|
1369
1403
|
const t = () => {
|
|
1370
|
-
|
|
1404
|
+
Le(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1371
1405
|
};
|
|
1372
1406
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1373
1407
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1374
1408
|
};
|
|
1375
1409
|
}
|
|
1376
1410
|
installSessionUserFilesApi(t) {
|
|
1377
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1411
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = js(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1378
1412
|
}
|
|
1379
1413
|
cleanupSessionUserFilesApi() {
|
|
1380
|
-
this.sessionUserFilesApiCleanup && (
|
|
1414
|
+
this.sessionUserFilesApiCleanup && (Zs(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1381
1415
|
}
|
|
1382
1416
|
async executeRuntimeHelper() {
|
|
1383
1417
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1384
1418
|
return null;
|
|
1385
|
-
const t = await
|
|
1419
|
+
const t = await de({
|
|
1386
1420
|
javascript: this.runtimeHelperJavascript
|
|
1387
1421
|
});
|
|
1388
|
-
return t.ok === !1 ?
|
|
1422
|
+
return t.ok === !1 ? An(t) : null;
|
|
1389
1423
|
}
|
|
1390
1424
|
enableNetworkCapture() {
|
|
1391
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1392
|
-
|
|
1425
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = qs((t) => {
|
|
1426
|
+
Rr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1393
1427
|
}));
|
|
1394
1428
|
}
|
|
1395
1429
|
enqueueNetworkEvent(t) {
|
|
1396
|
-
this.queuedNetworkEvents.length >=
|
|
1430
|
+
this.queuedNetworkEvents.length >= Ps || (this.queuedNetworkEvents.push(Er(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1397
1431
|
this.networkBatchTimer = null;
|
|
1398
1432
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1399
1433
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1402,12 +1436,12 @@ class Me {
|
|
|
1402
1436
|
page: b(),
|
|
1403
1437
|
events: s
|
|
1404
1438
|
});
|
|
1405
|
-
},
|
|
1439
|
+
}, Cs)));
|
|
1406
1440
|
}
|
|
1407
1441
|
scheduleReconnect() {
|
|
1408
1442
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1409
1443
|
return;
|
|
1410
|
-
const t =
|
|
1444
|
+
const t = vs(this.reconnectAttempts);
|
|
1411
1445
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1412
1446
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1413
1447
|
S("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1423,8 +1457,8 @@ class Me {
|
|
|
1423
1457
|
const t = this.socket;
|
|
1424
1458
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1425
1459
|
this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1426
|
-
},
|
|
1427
|
-
},
|
|
1460
|
+
}, Ss));
|
|
1461
|
+
}, ws);
|
|
1428
1462
|
}
|
|
1429
1463
|
stopHeartbeat() {
|
|
1430
1464
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1450,7 +1484,14 @@ class Me {
|
|
|
1450
1484
|
...t,
|
|
1451
1485
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1452
1486
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1453
|
-
},
|
|
1487
|
+
}, ar(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
|
|
1488
|
+
status: this.state.status,
|
|
1489
|
+
sessionId: this.state.sessionId,
|
|
1490
|
+
messageCount: this.state.messages.length,
|
|
1491
|
+
assistantDraftLength: this.state.assistantDraft.length,
|
|
1492
|
+
isThinking: this.state.isThinking,
|
|
1493
|
+
hasError: this.state.lastError !== null
|
|
1494
|
+
});
|
|
1454
1495
|
}
|
|
1455
1496
|
setReconnectingState() {
|
|
1456
1497
|
const t = this.state.lastError !== null && !this.state.isThinking && this.state.lastErrorCode !== "connection_failed";
|
|
@@ -1460,14 +1501,14 @@ class Me {
|
|
|
1460
1501
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1461
1502
|
}
|
|
1462
1503
|
}
|
|
1463
|
-
const
|
|
1464
|
-
function
|
|
1465
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1504
|
+
const Mt = /* @__PURE__ */ new WeakMap();
|
|
1505
|
+
function qs(e) {
|
|
1506
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Bs();
|
|
1466
1507
|
return t.subscribers.add(e), () => {
|
|
1467
1508
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1468
1509
|
};
|
|
1469
1510
|
}
|
|
1470
|
-
function
|
|
1511
|
+
function Bs() {
|
|
1471
1512
|
const e = /* @__PURE__ */ new Set(), t = (I) => {
|
|
1472
1513
|
e.forEach((m) => {
|
|
1473
1514
|
try {
|
|
@@ -1484,20 +1525,20 @@ function Os() {
|
|
|
1484
1525
|
throw y;
|
|
1485
1526
|
}
|
|
1486
1527
|
try {
|
|
1487
|
-
const y = m instanceof Request ? m : null, k =
|
|
1488
|
-
if (!
|
|
1528
|
+
const y = m instanceof Request ? m : null, k = Tr(m, y), T = He(d?.headers ?? y?.headers);
|
|
1529
|
+
if (!v(k, T, d?.body)) {
|
|
1489
1530
|
const H = {
|
|
1490
|
-
requestId:
|
|
1491
|
-
url: P(k,
|
|
1531
|
+
requestId: _t("fetch"),
|
|
1532
|
+
url: P(k, bt),
|
|
1492
1533
|
method: (d?.method ?? y?.method ?? "GET").toUpperCase(),
|
|
1493
1534
|
requestHeaders: T,
|
|
1494
|
-
requestBody:
|
|
1535
|
+
requestBody: Ae(d?.body),
|
|
1495
1536
|
resourceType: "fetch",
|
|
1496
1537
|
startedAt: new Date(f).toISOString()
|
|
1497
1538
|
};
|
|
1498
1539
|
h.then(
|
|
1499
1540
|
(_) => {
|
|
1500
|
-
|
|
1541
|
+
wr(_, H, f, t).catch(() => {
|
|
1501
1542
|
t({
|
|
1502
1543
|
...H,
|
|
1503
1544
|
responseStatus: _.status,
|
|
@@ -1519,27 +1560,27 @@ function Os() {
|
|
|
1519
1560
|
return h;
|
|
1520
1561
|
}, a = function(m, d, f, h, y) {
|
|
1521
1562
|
const k = n.call(this, m, d, f ?? !0, h ?? void 0, y ?? void 0), T = typeof d == "string" ? d : d.toString();
|
|
1522
|
-
return
|
|
1523
|
-
requestId:
|
|
1563
|
+
return Mt.set(this, {
|
|
1564
|
+
requestId: _t("xhr"),
|
|
1524
1565
|
method: String(m ?? "GET").toUpperCase(),
|
|
1525
|
-
url: P(T,
|
|
1566
|
+
url: P(T, bt),
|
|
1526
1567
|
requestHeaders: {},
|
|
1527
1568
|
startedAtMs: Date.now(),
|
|
1528
1569
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1529
|
-
excluded:
|
|
1570
|
+
excluded: v(T)
|
|
1530
1571
|
}), k;
|
|
1531
1572
|
}, c = function(m, d) {
|
|
1532
|
-
const f = r.call(this, m, d), h =
|
|
1533
|
-
return h && Object.keys(h.requestHeaders).length <
|
|
1573
|
+
const f = r.call(this, m, d), h = Mt.get(this);
|
|
1574
|
+
return h && Object.keys(h.requestHeaders).length < Wt && (h.requestHeaders[m] = Xt(m, d), h.excluded = h.excluded || v(h.url, h.requestHeaders)), f;
|
|
1534
1575
|
}, l = function(m) {
|
|
1535
1576
|
try {
|
|
1536
|
-
const d =
|
|
1537
|
-
d && (d.excluded = d.excluded ||
|
|
1577
|
+
const d = Mt.get(this);
|
|
1578
|
+
d && (d.excluded = d.excluded || v(d.url, d.requestHeaders, m), d.requestBody = Ae(m), d.excluded || this.addEventListener(
|
|
1538
1579
|
"loadend",
|
|
1539
1580
|
() => {
|
|
1540
1581
|
queueMicrotask(() => {
|
|
1541
1582
|
try {
|
|
1542
|
-
const f =
|
|
1583
|
+
const f = Mr(this.getAllResponseHeaders());
|
|
1543
1584
|
t({
|
|
1544
1585
|
requestId: d.requestId,
|
|
1545
1586
|
url: d.url,
|
|
@@ -1549,7 +1590,7 @@ function Os() {
|
|
|
1549
1590
|
resourceType: "xhr",
|
|
1550
1591
|
responseStatus: this.status,
|
|
1551
1592
|
responseHeaders: f,
|
|
1552
|
-
responseBody:
|
|
1593
|
+
responseBody: Ar(this, f),
|
|
1553
1594
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1554
1595
|
startedAt: d.startedAt,
|
|
1555
1596
|
durationMs: Date.now() - d.startedAtMs
|
|
@@ -1586,12 +1627,12 @@ function Os() {
|
|
|
1586
1627
|
u = new PerformanceObserver((I) => {
|
|
1587
1628
|
for (const m of I.getEntries()) {
|
|
1588
1629
|
const d = m;
|
|
1589
|
-
if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" ||
|
|
1630
|
+
if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || v(d.name))
|
|
1590
1631
|
continue;
|
|
1591
1632
|
const f = performance.timeOrigin + d.startTime;
|
|
1592
1633
|
t({
|
|
1593
|
-
requestId:
|
|
1594
|
-
url: P(d.name,
|
|
1634
|
+
requestId: _t("resource"),
|
|
1635
|
+
url: P(d.name, bt),
|
|
1595
1636
|
method: "GET",
|
|
1596
1637
|
resourceType: "resource",
|
|
1597
1638
|
responseStatus: d.responseStatus,
|
|
@@ -1641,15 +1682,15 @@ function S(e, t, s) {
|
|
|
1641
1682
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1642
1683
|
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 }));
|
|
1643
1684
|
}
|
|
1644
|
-
function
|
|
1685
|
+
function ue(e) {
|
|
1645
1686
|
const t = typeof e == "function" ? e() : e;
|
|
1646
1687
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1647
1688
|
}
|
|
1648
|
-
function
|
|
1689
|
+
function Hs(e) {
|
|
1649
1690
|
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";
|
|
1650
1691
|
}
|
|
1651
|
-
const
|
|
1652
|
-
function
|
|
1692
|
+
const Fs = 5e3, Ws = 12e4;
|
|
1693
|
+
function $s(e) {
|
|
1653
1694
|
const t = [];
|
|
1654
1695
|
for (const s of e)
|
|
1655
1696
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1660,30 +1701,30 @@ function Hs(e) {
|
|
|
1660
1701
|
});
|
|
1661
1702
|
return t;
|
|
1662
1703
|
}
|
|
1663
|
-
function
|
|
1704
|
+
function js(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1664
1705
|
const n = [
|
|
1665
|
-
|
|
1666
|
-
|
|
1706
|
+
Gs(),
|
|
1707
|
+
zs()
|
|
1667
1708
|
].filter((r) => typeof r == "function");
|
|
1668
1709
|
return () => {
|
|
1669
1710
|
for (const r of n.reverse())
|
|
1670
1711
|
r();
|
|
1671
1712
|
};
|
|
1672
1713
|
}
|
|
1673
|
-
function
|
|
1674
|
-
return
|
|
1714
|
+
function zs() {
|
|
1715
|
+
return Re(globalThis, "getPageSnapshot", async () => $t());
|
|
1675
1716
|
}
|
|
1676
|
-
function
|
|
1677
|
-
return
|
|
1678
|
-
inspectImage: async (t, s) => await
|
|
1717
|
+
function Gs() {
|
|
1718
|
+
return Re(globalThis, "pageImages", {
|
|
1719
|
+
inspectImage: async (t, s) => await Xs(t, s)
|
|
1679
1720
|
});
|
|
1680
1721
|
}
|
|
1681
|
-
async function
|
|
1682
|
-
const s =
|
|
1722
|
+
async function Xs(e, t = {}) {
|
|
1723
|
+
const s = Ys(t.name), n = await Ks(e);
|
|
1683
1724
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1684
1725
|
type: "pluno.pageImages.inspectImage",
|
|
1685
1726
|
imageAttached: !1,
|
|
1686
|
-
imageAttachmentError:
|
|
1727
|
+
imageAttachmentError: Me
|
|
1687
1728
|
} : {
|
|
1688
1729
|
type: "pluno.pageImages.inspectImage",
|
|
1689
1730
|
imageAttached: !0,
|
|
@@ -1697,15 +1738,15 @@ async function js(e, t = {}) {
|
|
|
1697
1738
|
imageAttachmentError: n.error
|
|
1698
1739
|
};
|
|
1699
1740
|
}
|
|
1700
|
-
async function
|
|
1701
|
-
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:
|
|
1741
|
+
async function Ks(e) {
|
|
1742
|
+
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: Me } : {
|
|
1702
1743
|
ok: !0,
|
|
1703
1744
|
mimeType: e.type,
|
|
1704
1745
|
sizeBytes: e.size,
|
|
1705
|
-
dataUrl: await
|
|
1706
|
-
} : { 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." } :
|
|
1746
|
+
dataUrl: await Qs(e)
|
|
1747
|
+
} : { 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." } : Js(e);
|
|
1707
1748
|
}
|
|
1708
|
-
function
|
|
1749
|
+
function Js(e) {
|
|
1709
1750
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1710
1751
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1711
1752
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1716,7 +1757,7 @@ function Gs(e) {
|
|
|
1716
1757
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1717
1758
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1718
1759
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1719
|
-
const o =
|
|
1760
|
+
const o = Vs(i);
|
|
1720
1761
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1721
1762
|
ok: !0,
|
|
1722
1763
|
mimeType: r,
|
|
@@ -1724,22 +1765,22 @@ function Gs(e) {
|
|
|
1724
1765
|
dataUrl: `data:${r};base64,${i}`
|
|
1725
1766
|
};
|
|
1726
1767
|
}
|
|
1727
|
-
function
|
|
1768
|
+
function Vs(e) {
|
|
1728
1769
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1729
1770
|
return null;
|
|
1730
1771
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1731
1772
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1732
1773
|
}
|
|
1733
|
-
function
|
|
1774
|
+
function Ys(e) {
|
|
1734
1775
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1735
1776
|
}
|
|
1736
|
-
function
|
|
1777
|
+
function Zs(e) {
|
|
1737
1778
|
try {
|
|
1738
1779
|
e();
|
|
1739
1780
|
} catch {
|
|
1740
1781
|
}
|
|
1741
1782
|
}
|
|
1742
|
-
function
|
|
1783
|
+
function Qs(e) {
|
|
1743
1784
|
return new Promise((t, s) => {
|
|
1744
1785
|
const n = new FileReader();
|
|
1745
1786
|
n.onload = () => {
|
|
@@ -1751,9 +1792,9 @@ function Vs(e) {
|
|
|
1751
1792
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1752
1793
|
});
|
|
1753
1794
|
}
|
|
1754
|
-
async function
|
|
1795
|
+
async function de(e, t) {
|
|
1755
1796
|
const s = Object.getPrototypeOf(async function() {
|
|
1756
|
-
}).constructor, n = e.timeoutMs ??
|
|
1797
|
+
}).constructor, n = e.timeoutMs ?? Fs, r = Date.now(), i = [];
|
|
1757
1798
|
let o;
|
|
1758
1799
|
const a = {
|
|
1759
1800
|
log: console.log,
|
|
@@ -1771,7 +1812,7 @@ async function le(e, t) {
|
|
|
1771
1812
|
o = window.setTimeout(() => p(l), n);
|
|
1772
1813
|
})
|
|
1773
1814
|
]);
|
|
1774
|
-
return u === l ?
|
|
1815
|
+
return u === l ? en(n) : {
|
|
1775
1816
|
ok: !0,
|
|
1776
1817
|
result: u,
|
|
1777
1818
|
console: i,
|
|
@@ -1800,7 +1841,7 @@ async function le(e, t) {
|
|
|
1800
1841
|
t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
1801
1842
|
}
|
|
1802
1843
|
}
|
|
1803
|
-
function
|
|
1844
|
+
function tn(e, t) {
|
|
1804
1845
|
if (!e || typeof e != "object")
|
|
1805
1846
|
return;
|
|
1806
1847
|
const s = e.sandboxFilesToken;
|
|
@@ -1810,7 +1851,7 @@ function Ys(e, t) {
|
|
|
1810
1851
|
const r = () => {
|
|
1811
1852
|
if (!n)
|
|
1812
1853
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
1813
|
-
}, i = async (a, c) => await
|
|
1854
|
+
}, i = async (a, c) => await ps(`${t.replace(/\/$/, "")}${a}`, c);
|
|
1814
1855
|
return {
|
|
1815
1856
|
value: Object.freeze({
|
|
1816
1857
|
upload: async (a) => {
|
|
@@ -1844,7 +1885,7 @@ function Ys(e, t) {
|
|
|
1844
1885
|
}
|
|
1845
1886
|
};
|
|
1846
1887
|
}
|
|
1847
|
-
function
|
|
1888
|
+
function en(e) {
|
|
1848
1889
|
return {
|
|
1849
1890
|
ok: !1,
|
|
1850
1891
|
exception: {
|
|
@@ -1858,10 +1899,10 @@ function Zs(e) {
|
|
|
1858
1899
|
}
|
|
1859
1900
|
};
|
|
1860
1901
|
}
|
|
1861
|
-
function
|
|
1902
|
+
function sn(e) {
|
|
1862
1903
|
return e.replace(/\/+$/, "");
|
|
1863
1904
|
}
|
|
1864
|
-
function
|
|
1905
|
+
function nn(e) {
|
|
1865
1906
|
const t = {
|
|
1866
1907
|
sidepanel: "extension_sidepanel",
|
|
1867
1908
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -1873,18 +1914,18 @@ function tn(e) {
|
|
|
1873
1914
|
};
|
|
1874
1915
|
return e && e in t ? t[e] : e ?? "embedded_custom_ui";
|
|
1875
1916
|
}
|
|
1876
|
-
function
|
|
1917
|
+
function rn(e) {
|
|
1877
1918
|
return e === "pluno" ? "scheduled_continuation" : e ?? "user";
|
|
1878
1919
|
}
|
|
1879
|
-
function
|
|
1920
|
+
function on(e, t = location.origin) {
|
|
1880
1921
|
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;
|
|
1881
1922
|
}
|
|
1882
|
-
function
|
|
1923
|
+
function an(e) {
|
|
1883
1924
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1884
1925
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1885
1926
|
}
|
|
1886
1927
|
function b() {
|
|
1887
|
-
const e =
|
|
1928
|
+
const e = De();
|
|
1888
1929
|
return {
|
|
1889
1930
|
url: location.href,
|
|
1890
1931
|
title: document.title,
|
|
@@ -1892,19 +1933,19 @@ function b() {
|
|
|
1892
1933
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1893
1934
|
};
|
|
1894
1935
|
}
|
|
1895
|
-
function
|
|
1936
|
+
function cn() {
|
|
1896
1937
|
return {
|
|
1897
1938
|
pageUrl: location.href,
|
|
1898
1939
|
pageTitle: document.title,
|
|
1899
|
-
htmlContent:
|
|
1940
|
+
htmlContent: $t()
|
|
1900
1941
|
};
|
|
1901
1942
|
}
|
|
1902
|
-
function
|
|
1903
|
-
return st.add(e), Z || (Z =
|
|
1943
|
+
function ln(e) {
|
|
1944
|
+
return st.add(e), Z || (Z = un()), () => {
|
|
1904
1945
|
st.delete(e), st.size === 0 && (Z?.(), Z = null);
|
|
1905
1946
|
};
|
|
1906
1947
|
}
|
|
1907
|
-
function
|
|
1948
|
+
function un() {
|
|
1908
1949
|
const e = () => {
|
|
1909
1950
|
for (const i of Array.from(st))
|
|
1910
1951
|
i();
|
|
@@ -1919,10 +1960,10 @@ function an() {
|
|
|
1919
1960
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
1920
1961
|
};
|
|
1921
1962
|
}
|
|
1922
|
-
function
|
|
1923
|
-
return
|
|
1963
|
+
function dn() {
|
|
1964
|
+
return De()?.surface === "browser_extension_sdk_preview";
|
|
1924
1965
|
}
|
|
1925
|
-
function
|
|
1966
|
+
function $t() {
|
|
1926
1967
|
if (!document.body)
|
|
1927
1968
|
return "";
|
|
1928
1969
|
const e = [], t = [], s = (f, h) => {
|
|
@@ -1931,16 +1972,16 @@ function Wt() {
|
|
|
1931
1972
|
};
|
|
1932
1973
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
1933
1974
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
1934
|
-
(f) =>
|
|
1975
|
+
(f) => Ce(f) && !f.parentElement?.closest(n)
|
|
1935
1976
|
);
|
|
1936
1977
|
for (const f of r.slice(0, 3))
|
|
1937
|
-
s("Active overlay",
|
|
1938
|
-
const i =
|
|
1939
|
-
s("Main page content", o), s("Additional visible page text",
|
|
1978
|
+
s("Active overlay", kt(z(f), t));
|
|
1979
|
+
const i = hn(), o = i ? kt(z(i), t) : "";
|
|
1980
|
+
s("Main page content", o), s("Additional visible page text", kt(z(document.body), t));
|
|
1940
1981
|
const a = e.map(([f, h]) => `${f}:
|
|
1941
1982
|
${h}`).join(`
|
|
1942
1983
|
|
|
1943
|
-
`).trim().slice(0, 12e3), c =
|
|
1984
|
+
`).trim().slice(0, 12e3), c = pn(r, i).trim(), l = `Simplified DOM outline:
|
|
1944
1985
|
`, u = `
|
|
1945
1986
|
|
|
1946
1987
|
Visible page text:
|
|
@@ -1958,20 +1999,20 @@ function B(e) {
|
|
|
1958
1999
|
|
|
1959
2000
|
`).trim();
|
|
1960
2001
|
}
|
|
1961
|
-
function
|
|
2002
|
+
function kt(e, t) {
|
|
1962
2003
|
let s = B(e);
|
|
1963
2004
|
for (const n of t)
|
|
1964
2005
|
s = s.replace(n, "");
|
|
1965
2006
|
return B(s);
|
|
1966
2007
|
}
|
|
1967
|
-
function
|
|
2008
|
+
function Ce(e) {
|
|
1968
2009
|
const t = window.getComputedStyle(e);
|
|
1969
2010
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
1970
2011
|
}
|
|
1971
|
-
function
|
|
1972
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2012
|
+
function hn() {
|
|
2013
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ce).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
|
|
1973
2014
|
}
|
|
1974
|
-
function
|
|
2015
|
+
function pn(e, t) {
|
|
1975
2016
|
const s = /* @__PURE__ */ new Set([
|
|
1976
2017
|
"main",
|
|
1977
2018
|
"nav",
|
|
@@ -2051,7 +2092,7 @@ function un(e, t) {
|
|
|
2051
2092
|
"data-test",
|
|
2052
2093
|
"data-qa",
|
|
2053
2094
|
"data-cy"
|
|
2054
|
-
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: p } =
|
|
2095
|
+
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: p } = fn(), I = new Set(e);
|
|
2055
2096
|
t && I.add(t);
|
|
2056
2097
|
let m = 0;
|
|
2057
2098
|
const d = (T) => {
|
|
@@ -2066,36 +2107,36 @@ function un(e, t) {
|
|
|
2066
2107
|
if (m >= 1e3 && !G || H.has(A) || i.has(R) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
|
|
2067
2108
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2068
2109
|
m += 1;
|
|
2069
|
-
const
|
|
2110
|
+
const Kt = d(A), X = Ue(A), Ke = a.has(Kt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(R) || R === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((g) => g instanceof HTMLElement), K = /* @__PURE__ */ new Map();
|
|
2070
2111
|
for (const g of pt) {
|
|
2071
2112
|
const w = f(g);
|
|
2072
2113
|
K.set(w, (K.get(w) ?? 0) + 1);
|
|
2073
2114
|
}
|
|
2074
|
-
const ft = /* @__PURE__ */ new Map(),
|
|
2115
|
+
const ft = /* @__PURE__ */ new Map(), Jt = /* @__PURE__ */ new Map();
|
|
2075
2116
|
for (const g of pt) {
|
|
2076
|
-
const w = f(g),
|
|
2077
|
-
|
|
2117
|
+
const w = f(g), N = Jt.get(w) ?? 0;
|
|
2118
|
+
Jt.set(w, N + 1), (K.get(w) ?? 0) > 8 && N >= 6 && !u.has(g) && ft.set(w, (ft.get(w) ?? 0) + 1);
|
|
2078
2119
|
}
|
|
2079
|
-
const
|
|
2120
|
+
const Vt = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Set(), gt = [], Zt = [];
|
|
2080
2121
|
for (const g of pt) {
|
|
2081
|
-
const w = f(g),
|
|
2082
|
-
if (
|
|
2083
|
-
|
|
2122
|
+
const w = f(g), N = K.get(w) ?? 0, ee = Vt.get(w) ?? 0;
|
|
2123
|
+
if (Vt.set(w, ee + 1), N > 8 && ee >= 6 && !u.has(g)) {
|
|
2124
|
+
Yt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Yt.add(w));
|
|
2084
2125
|
continue;
|
|
2085
2126
|
}
|
|
2086
|
-
const
|
|
2087
|
-
|
|
2127
|
+
const se = _(g, dt);
|
|
2128
|
+
Zt.push(se), gt.push(se.lines);
|
|
2088
2129
|
}
|
|
2089
2130
|
const mt = [];
|
|
2090
2131
|
if (A.shadowRoot)
|
|
2091
2132
|
for (const g of Array.from(A.shadowRoot.children))
|
|
2092
2133
|
g instanceof HTMLElement && mt.push(_(g, dt + 1));
|
|
2093
|
-
const J = [...
|
|
2134
|
+
const J = [...Zt, ...mt], yt = X.length > 0 || Ke || J.some((g) => g.hasUsefulContent), Qt = B(
|
|
2094
2135
|
[X, ...J.map((g) => g.textPreview)].filter(Boolean).join(" ")
|
|
2095
|
-
).slice(0, 180),
|
|
2136
|
+
).slice(0, 180), Je = A.hasAttribute("contenteditable") && (X.length > 0 || !A.querySelector("[contenteditable]")), te = l.some((g) => A.hasAttribute(g)) || !!Kt || Je, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(R) || te || G) && (yt || G) && (!r.has(R) || yt || te || G), Tt = It ? 1 : 0, F = [];
|
|
2096
2137
|
if (It) {
|
|
2097
|
-
const g = J.some((
|
|
2098
|
-
F.push(
|
|
2138
|
+
const g = J.some((N) => N.containsTextElement), w = n.has(R) && !g ? Qt : X;
|
|
2139
|
+
F.push(Pe(A, c, o, w.slice(0, 180)));
|
|
2099
2140
|
}
|
|
2100
2141
|
for (const g of gt)
|
|
2101
2142
|
F.push(...Q(g, Tt));
|
|
@@ -2105,15 +2146,15 @@ function un(e, t) {
|
|
|
2105
2146
|
wt.length > g.length && g.push("… shadow DOM omitted");
|
|
2106
2147
|
const w = R.includes("tooltip") || R.includes("popper") || R.includes("loader");
|
|
2107
2148
|
if (dt < 2 && !w) {
|
|
2108
|
-
const
|
|
2109
|
-
F.push(...Q([
|
|
2149
|
+
const N = It ? "#shadow-root" : `${R} #shadow-root`;
|
|
2150
|
+
F.push(...Q([N, ...Q(g, 1)], Tt));
|
|
2110
2151
|
} else
|
|
2111
2152
|
F.push(...Q(g, Tt));
|
|
2112
2153
|
}
|
|
2113
2154
|
return {
|
|
2114
2155
|
lines: F,
|
|
2115
2156
|
hasUsefulContent: yt,
|
|
2116
|
-
textPreview:
|
|
2157
|
+
textPreview: Qt,
|
|
2117
2158
|
containsTextElement: n.has(R) || J.some((g) => g.containsTextElement)
|
|
2118
2159
|
};
|
|
2119
2160
|
};
|
|
@@ -2121,7 +2162,7 @@ function un(e, t) {
|
|
|
2121
2162
|
`);
|
|
2122
2163
|
}, y = [], k = B(window.getSelection()?.toString() ?? "");
|
|
2123
2164
|
k && y.push(`--- selected text ---
|
|
2124
|
-
${JSON.stringify(k)}`), p.length > 0 && y.push(
|
|
2165
|
+
${JSON.stringify(k)}`), p.length > 0 && y.push(gn(p, s, c, o));
|
|
2125
2166
|
for (const T of e.slice(0, 3))
|
|
2126
2167
|
y.push(h(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2127
2168
|
if (t && y.push(h(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2132,11 +2173,11 @@ ${JSON.stringify(k)}`), p.length > 0 && y.push(hn(p, s, c, o));
|
|
|
2132
2173
|
|
|
2133
2174
|
`);
|
|
2134
2175
|
}
|
|
2135
|
-
function
|
|
2176
|
+
function Pe(e, t, s, n) {
|
|
2136
2177
|
const r = e.tagName.toLowerCase();
|
|
2137
2178
|
let i = r;
|
|
2138
2179
|
const o = e.getAttribute("id");
|
|
2139
|
-
o &&
|
|
2180
|
+
o && mn(o) && (i += `#${o}`);
|
|
2140
2181
|
for (const a of t) {
|
|
2141
2182
|
const c = e.getAttribute(a);
|
|
2142
2183
|
c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
|
|
@@ -2149,7 +2190,7 @@ function _e(e, t, s, n) {
|
|
|
2149
2190
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2150
2191
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2151
2192
|
}
|
|
2152
|
-
function
|
|
2193
|
+
function fn() {
|
|
2153
2194
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
|
|
2154
2195
|
if (!a)
|
|
2155
2196
|
return;
|
|
@@ -2170,7 +2211,7 @@ function dn() {
|
|
|
2170
2211
|
n = n.shadowRoot.activeElement;
|
|
2171
2212
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2172
2213
|
const r = window.getSelection();
|
|
2173
|
-
r && !r.isCollapsed && (s(
|
|
2214
|
+
r && !r.isCollapsed && (s(he(r.anchorNode), "selected text"), s(he(r.focusNode), "selected text"));
|
|
2174
2215
|
const i = [
|
|
2175
2216
|
["[aria-selected='true']", "selected"],
|
|
2176
2217
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2192,7 +2233,7 @@ function dn() {
|
|
|
2192
2233
|
priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
|
|
2193
2234
|
};
|
|
2194
2235
|
}
|
|
2195
|
-
function
|
|
2236
|
+
function gn(e, t, s, n) {
|
|
2196
2237
|
const r = ["--- active/current elements ---"];
|
|
2197
2238
|
for (const i of e) {
|
|
2198
2239
|
const o = [];
|
|
@@ -2203,18 +2244,18 @@ function hn(e, t, s, n) {
|
|
|
2203
2244
|
const p = a.getRootNode();
|
|
2204
2245
|
a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
|
|
2205
2246
|
}
|
|
2206
|
-
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((u, p) =>
|
|
2247
|
+
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((u, p) => Pe(
|
|
2207
2248
|
u,
|
|
2208
2249
|
s,
|
|
2209
2250
|
n,
|
|
2210
|
-
p === c.length - 1 ?
|
|
2251
|
+
p === c.length - 1 ? Ue(u).slice(0, 180) : ""
|
|
2211
2252
|
));
|
|
2212
2253
|
o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
|
|
2213
2254
|
}
|
|
2214
2255
|
return r.join(`
|
|
2215
2256
|
`);
|
|
2216
2257
|
}
|
|
2217
|
-
function
|
|
2258
|
+
function he(e) {
|
|
2218
2259
|
return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
|
|
2219
2260
|
}
|
|
2220
2261
|
function Q(e, t) {
|
|
@@ -2223,17 +2264,17 @@ function Q(e, t) {
|
|
|
2223
2264
|
const s = " ".repeat(t);
|
|
2224
2265
|
return e.map((n) => `${s}${n}`);
|
|
2225
2266
|
}
|
|
2226
|
-
function
|
|
2267
|
+
function Ue(e) {
|
|
2227
2268
|
return B(
|
|
2228
2269
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2229
2270
|
);
|
|
2230
2271
|
}
|
|
2231
|
-
function
|
|
2272
|
+
function mn(e) {
|
|
2232
2273
|
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);
|
|
2233
2274
|
}
|
|
2234
|
-
function
|
|
2235
|
-
const e = document.querySelector(
|
|
2236
|
-
if (!(e ?? document.querySelector(
|
|
2275
|
+
function De() {
|
|
2276
|
+
const e = document.querySelector(ne);
|
|
2277
|
+
if (!(e ?? document.querySelector(Pt)))
|
|
2237
2278
|
return;
|
|
2238
2279
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2239
2280
|
return {
|
|
@@ -2242,28 +2283,28 @@ function Pe() {
|
|
|
2242
2283
|
selectors: [
|
|
2243
2284
|
{
|
|
2244
2285
|
name: "widget_host",
|
|
2245
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2286
|
+
selector: s === "browser_extension_sdk_preview" ? ne : Pt,
|
|
2246
2287
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2247
2288
|
},
|
|
2248
2289
|
{
|
|
2249
2290
|
name: "widget_root",
|
|
2250
|
-
selector:
|
|
2291
|
+
selector: fs,
|
|
2251
2292
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2252
2293
|
},
|
|
2253
2294
|
{
|
|
2254
2295
|
name: "widget_panel",
|
|
2255
|
-
selector:
|
|
2296
|
+
selector: gs,
|
|
2256
2297
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2257
2298
|
},
|
|
2258
2299
|
{
|
|
2259
2300
|
name: "widget_timeline",
|
|
2260
|
-
selector:
|
|
2301
|
+
selector: ms,
|
|
2261
2302
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2262
2303
|
}
|
|
2263
2304
|
]
|
|
2264
2305
|
};
|
|
2265
2306
|
}
|
|
2266
|
-
function
|
|
2307
|
+
function yn(e) {
|
|
2267
2308
|
try {
|
|
2268
2309
|
const t = JSON.parse(e);
|
|
2269
2310
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2271,16 +2312,16 @@ function fn(e) {
|
|
|
2271
2312
|
return { type: "error", message: "Invalid server event" };
|
|
2272
2313
|
}
|
|
2273
2314
|
}
|
|
2274
|
-
function
|
|
2315
|
+
function pe(e, t) {
|
|
2275
2316
|
if (!e || typeof e != "object")
|
|
2276
2317
|
return [];
|
|
2277
2318
|
const s = e[t];
|
|
2278
2319
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2279
2320
|
}
|
|
2280
|
-
function
|
|
2321
|
+
function In(e) {
|
|
2281
2322
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2282
2323
|
}
|
|
2283
|
-
function
|
|
2324
|
+
function Tn(e) {
|
|
2284
2325
|
if (!e || typeof e != "object")
|
|
2285
2326
|
return null;
|
|
2286
2327
|
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;
|
|
@@ -2291,13 +2332,13 @@ function mn(e) {
|
|
|
2291
2332
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2292
2333
|
};
|
|
2293
2334
|
}
|
|
2294
|
-
function
|
|
2335
|
+
function wn(e) {
|
|
2295
2336
|
if (!e || typeof e != "object")
|
|
2296
2337
|
return null;
|
|
2297
2338
|
const t = e.javascript;
|
|
2298
2339
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2299
2340
|
}
|
|
2300
|
-
function
|
|
2341
|
+
function Sn(e, t) {
|
|
2301
2342
|
return t ? e && typeof e == "object" ? {
|
|
2302
2343
|
...e,
|
|
2303
2344
|
helperError: t
|
|
@@ -2307,13 +2348,13 @@ function In(e, t) {
|
|
|
2307
2348
|
helperError: t
|
|
2308
2349
|
} : e;
|
|
2309
2350
|
}
|
|
2310
|
-
function
|
|
2351
|
+
function An(e) {
|
|
2311
2352
|
if (!e || typeof e != "object")
|
|
2312
2353
|
return e;
|
|
2313
2354
|
const t = e;
|
|
2314
2355
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2315
2356
|
}
|
|
2316
|
-
function
|
|
2357
|
+
function En() {
|
|
2317
2358
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2318
2359
|
if (t)
|
|
2319
2360
|
return t;
|
|
@@ -2323,7 +2364,7 @@ function wn() {
|
|
|
2323
2364
|
function $() {
|
|
2324
2365
|
return crypto.randomUUID();
|
|
2325
2366
|
}
|
|
2326
|
-
function
|
|
2367
|
+
function Rn(e) {
|
|
2327
2368
|
if (!e || typeof e != "object")
|
|
2328
2369
|
return null;
|
|
2329
2370
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2334,12 +2375,12 @@ function Sn(e) {
|
|
|
2334
2375
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2335
2376
|
} : null;
|
|
2336
2377
|
}
|
|
2337
|
-
function
|
|
2338
|
-
return Array.isArray(e) ?
|
|
2339
|
-
e.map((s) =>
|
|
2378
|
+
function bn(e, t) {
|
|
2379
|
+
return Array.isArray(e) ? Lt(
|
|
2380
|
+
e.map((s) => Ne(s, t)).filter((s) => s !== null)
|
|
2340
2381
|
) : [];
|
|
2341
2382
|
}
|
|
2342
|
-
function
|
|
2383
|
+
function Mn(e) {
|
|
2343
2384
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2344
2385
|
if (!t || typeof t != "object")
|
|
2345
2386
|
return [];
|
|
@@ -2360,7 +2401,7 @@ function En(e) {
|
|
|
2360
2401
|
];
|
|
2361
2402
|
}) : [];
|
|
2362
2403
|
}
|
|
2363
|
-
function
|
|
2404
|
+
function Ne(e, t) {
|
|
2364
2405
|
if (!e || typeof e != "object")
|
|
2365
2406
|
return null;
|
|
2366
2407
|
const s = e, n = s.data;
|
|
@@ -2374,14 +2415,14 @@ function Ue(e, t) {
|
|
|
2374
2415
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2375
2416
|
role: i,
|
|
2376
2417
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2377
|
-
content:
|
|
2378
|
-
|
|
2418
|
+
content: ns(
|
|
2419
|
+
Nn(r.content),
|
|
2379
2420
|
t
|
|
2380
2421
|
),
|
|
2381
2422
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2382
|
-
respondsToUserMessageId:
|
|
2423
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2383
2424
|
...C(r) ? { runId: C(r) } : {},
|
|
2384
|
-
attachments:
|
|
2425
|
+
attachments: qe(r.attachments, t)
|
|
2385
2426
|
};
|
|
2386
2427
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2387
2428
|
value: r.id,
|
|
@@ -2392,37 +2433,37 @@ function Ue(e, t) {
|
|
|
2392
2433
|
}), o;
|
|
2393
2434
|
}
|
|
2394
2435
|
if (r.type === "function_call_output") {
|
|
2395
|
-
const i =
|
|
2436
|
+
const i = _n(r.output);
|
|
2396
2437
|
return i ? {
|
|
2397
2438
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2398
2439
|
role: "tool",
|
|
2399
2440
|
content: `Connect ${i.appName} to continue`,
|
|
2400
2441
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2401
|
-
respondsToUserMessageId:
|
|
2442
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2402
2443
|
...C(r) ? { runId: C(r) } : {},
|
|
2403
2444
|
dataType: "function_call_output",
|
|
2404
2445
|
toolName: "authenticate_pipedream_app",
|
|
2405
|
-
callId:
|
|
2446
|
+
callId: fe(r) ?? void 0,
|
|
2406
2447
|
integrationAuthRequest: i
|
|
2407
2448
|
} : null;
|
|
2408
2449
|
}
|
|
2409
2450
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2410
2451
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2411
2452
|
role: "tool",
|
|
2412
|
-
content: r.type === "mcp_call" ?
|
|
2453
|
+
content: r.type === "mcp_call" ? kn(r) : Pn(r),
|
|
2413
2454
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2414
|
-
respondsToUserMessageId:
|
|
2455
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2415
2456
|
...C(r) ? { runId: C(r) } : {},
|
|
2416
2457
|
dataType: String(r.type),
|
|
2417
2458
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2418
|
-
callId:
|
|
2459
|
+
callId: fe(r) ?? void 0,
|
|
2419
2460
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
2420
2461
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2421
2462
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2422
2463
|
role: "system",
|
|
2423
|
-
content:
|
|
2464
|
+
content: Cn(r),
|
|
2424
2465
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2425
|
-
respondsToUserMessageId:
|
|
2466
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2426
2467
|
...C(r) ? { runId: C(r) } : {},
|
|
2427
2468
|
dataType: String(r.type),
|
|
2428
2469
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -2431,11 +2472,11 @@ function Ue(e, t) {
|
|
|
2431
2472
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2432
2473
|
} : null;
|
|
2433
2474
|
}
|
|
2434
|
-
function
|
|
2475
|
+
function kn(e) {
|
|
2435
2476
|
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(" ");
|
|
2436
2477
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2437
2478
|
}
|
|
2438
|
-
function
|
|
2479
|
+
function _n(e) {
|
|
2439
2480
|
if (typeof e != "string")
|
|
2440
2481
|
return null;
|
|
2441
2482
|
try {
|
|
@@ -2452,10 +2493,10 @@ function bn(e) {
|
|
|
2452
2493
|
return null;
|
|
2453
2494
|
}
|
|
2454
2495
|
}
|
|
2455
|
-
function
|
|
2496
|
+
function Cn(e) {
|
|
2456
2497
|
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.";
|
|
2457
2498
|
}
|
|
2458
|
-
function
|
|
2499
|
+
function Pn(e) {
|
|
2459
2500
|
if (e.type === "web_search_call") {
|
|
2460
2501
|
const t = e.action;
|
|
2461
2502
|
if (t && typeof t == "object") {
|
|
@@ -2467,9 +2508,9 @@ function kn(e) {
|
|
|
2467
2508
|
}
|
|
2468
2509
|
return "🔎 Searching the web";
|
|
2469
2510
|
}
|
|
2470
|
-
return
|
|
2511
|
+
return Un(e);
|
|
2471
2512
|
}
|
|
2472
|
-
function
|
|
2513
|
+
function Un(e) {
|
|
2473
2514
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2474
2515
|
return L(e.summary);
|
|
2475
2516
|
if (typeof e.arguments == "string")
|
|
@@ -2486,7 +2527,7 @@ function L(e) {
|
|
|
2486
2527
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2487
2528
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2488
2529
|
}
|
|
2489
|
-
function
|
|
2530
|
+
function Dn(e) {
|
|
2490
2531
|
if (e == null)
|
|
2491
2532
|
return e;
|
|
2492
2533
|
if (typeof e != "object")
|
|
@@ -2501,11 +2542,11 @@ function Cn(e) {
|
|
|
2501
2542
|
runId: typeof t.runId == "string" ? t.runId : null
|
|
2502
2543
|
};
|
|
2503
2544
|
}
|
|
2504
|
-
function
|
|
2545
|
+
function fe(e) {
|
|
2505
2546
|
const t = e.callId ?? e.call_id;
|
|
2506
2547
|
return typeof t == "string" && t ? t : null;
|
|
2507
2548
|
}
|
|
2508
|
-
function
|
|
2549
|
+
function Nn(e) {
|
|
2509
2550
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2510
2551
|
if (!t || typeof t != "object")
|
|
2511
2552
|
return "";
|
|
@@ -2513,36 +2554,36 @@ function Pn(e) {
|
|
|
2513
2554
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2514
2555
|
}).filter(Boolean).join("") : "";
|
|
2515
2556
|
}
|
|
2516
|
-
function
|
|
2517
|
-
const s =
|
|
2518
|
-
|
|
2519
|
-
|
|
2557
|
+
function Dt(e, t) {
|
|
2558
|
+
const s = xe(e, t), n = Bn(
|
|
2559
|
+
xn(
|
|
2560
|
+
jn(e, t),
|
|
2520
2561
|
s
|
|
2521
2562
|
),
|
|
2522
2563
|
s
|
|
2523
2564
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2524
2565
|
if (r === -1)
|
|
2525
|
-
return
|
|
2566
|
+
return Lt(
|
|
2526
2567
|
[...n, s]
|
|
2527
2568
|
);
|
|
2528
2569
|
const i = [...n];
|
|
2529
|
-
return i[r] = s,
|
|
2570
|
+
return i[r] = s, Lt(i);
|
|
2530
2571
|
}
|
|
2531
|
-
function
|
|
2572
|
+
function xn(e, t) {
|
|
2532
2573
|
const s = t.assistantDraftItemId;
|
|
2533
2574
|
return s ? e.map(
|
|
2534
2575
|
(n) => n.dataType === "assistant_draft" && n.id === s ? t : n
|
|
2535
2576
|
) : e;
|
|
2536
2577
|
}
|
|
2537
|
-
function
|
|
2578
|
+
function On(e, t, s) {
|
|
2538
2579
|
return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
|
|
2539
2580
|
}
|
|
2540
|
-
function
|
|
2581
|
+
function vn(e, t) {
|
|
2541
2582
|
const s = e.findIndex(
|
|
2542
2583
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2543
2584
|
);
|
|
2544
2585
|
if (s === -1)
|
|
2545
|
-
return
|
|
2586
|
+
return Dt(e, t);
|
|
2546
2587
|
const n = [...e];
|
|
2547
2588
|
return n[s] = {
|
|
2548
2589
|
...n[s],
|
|
@@ -2554,12 +2595,12 @@ function xn(e, t) {
|
|
|
2554
2595
|
...n[s].runId ? {} : { runId: t.runId }
|
|
2555
2596
|
}, n;
|
|
2556
2597
|
}
|
|
2557
|
-
function
|
|
2598
|
+
function Ln(e, t, s) {
|
|
2558
2599
|
let n = !1;
|
|
2559
2600
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2560
2601
|
return n ? r : e;
|
|
2561
2602
|
}
|
|
2562
|
-
function
|
|
2603
|
+
function qn(e) {
|
|
2563
2604
|
if (e.hiddenFromTranscript === !0)
|
|
2564
2605
|
return null;
|
|
2565
2606
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
@@ -2578,7 +2619,7 @@ function vn(e) {
|
|
|
2578
2619
|
loading: !0
|
|
2579
2620
|
};
|
|
2580
2621
|
}
|
|
2581
|
-
function
|
|
2622
|
+
function Bn(e, t) {
|
|
2582
2623
|
if (t.id.startsWith("transient-activity:"))
|
|
2583
2624
|
return e;
|
|
2584
2625
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2586,10 +2627,10 @@ function On(e, t) {
|
|
|
2586
2627
|
(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)
|
|
2587
2628
|
);
|
|
2588
2629
|
}
|
|
2589
|
-
function
|
|
2590
|
-
const s =
|
|
2630
|
+
function Hn(e, t) {
|
|
2631
|
+
const s = Fn(
|
|
2591
2632
|
t.map(
|
|
2592
|
-
(c) =>
|
|
2633
|
+
(c) => xe(e, c)
|
|
2593
2634
|
)
|
|
2594
2635
|
), n = new Map(s.map((c) => [c.id, c])), r = new Map(
|
|
2595
2636
|
s.flatMap((c) => {
|
|
@@ -2604,8 +2645,8 @@ function Ln(e, t) {
|
|
|
2604
2645
|
), o = /* @__PURE__ */ new Set(), a = [];
|
|
2605
2646
|
for (const c of e) {
|
|
2606
2647
|
let l = n.get(c.id);
|
|
2607
|
-
if (
|
|
2608
|
-
const u =
|
|
2648
|
+
if (jt(c)) {
|
|
2649
|
+
const u = Nt(c);
|
|
2609
2650
|
if (l = u ? r.get(u) : void 0, !l) {
|
|
2610
2651
|
a.push(c);
|
|
2611
2652
|
continue;
|
|
@@ -2620,7 +2661,7 @@ function Ln(e, t) {
|
|
|
2620
2661
|
o.has(c) || a.push(c);
|
|
2621
2662
|
return a;
|
|
2622
2663
|
}
|
|
2623
|
-
function
|
|
2664
|
+
function Fn(e) {
|
|
2624
2665
|
const t = new Set(
|
|
2625
2666
|
e.flatMap(
|
|
2626
2667
|
(s) => s.callId && !s.id.startsWith("transient-activity:") ? [s.callId] : []
|
|
@@ -2630,46 +2671,46 @@ function qn(e) {
|
|
|
2630
2671
|
(s) => !(s.callId && s.id.startsWith("transient-activity:") && t.has(s.callId))
|
|
2631
2672
|
);
|
|
2632
2673
|
}
|
|
2633
|
-
function
|
|
2674
|
+
function xe(e, t) {
|
|
2634
2675
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2635
2676
|
return t;
|
|
2636
2677
|
const s = e.find(
|
|
2637
|
-
(r) => r.role === "user" && (r.id === t.id ||
|
|
2678
|
+
(r) => r.role === "user" && (r.id === t.id || jt(r) && Oe(r, t))
|
|
2638
2679
|
);
|
|
2639
2680
|
if (!s?.attachments?.length)
|
|
2640
2681
|
return t;
|
|
2641
2682
|
const n = t.attachments.map((r) => {
|
|
2642
|
-
const i =
|
|
2643
|
-
return i ?
|
|
2683
|
+
const i = Wn(s.attachments ?? [], r);
|
|
2684
|
+
return i ? $n(r, i) : r;
|
|
2644
2685
|
});
|
|
2645
2686
|
return { ...t, attachments: n };
|
|
2646
2687
|
}
|
|
2647
|
-
function
|
|
2688
|
+
function Wn(e, t) {
|
|
2648
2689
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2649
2690
|
}
|
|
2650
|
-
function
|
|
2691
|
+
function $n(e, t) {
|
|
2651
2692
|
const { previewUrl: s } = t;
|
|
2652
2693
|
return s ? { ...e, previewUrl: s } : e;
|
|
2653
2694
|
}
|
|
2654
|
-
function
|
|
2695
|
+
function jn(e, t) {
|
|
2655
2696
|
if (t.role !== "user")
|
|
2656
2697
|
return e;
|
|
2657
2698
|
const s = e.findIndex(
|
|
2658
|
-
(r) =>
|
|
2699
|
+
(r) => jt(r) && Oe(r, t)
|
|
2659
2700
|
);
|
|
2660
2701
|
if (s === -1)
|
|
2661
2702
|
return e;
|
|
2662
2703
|
const n = [...e];
|
|
2663
2704
|
return n.splice(s, 1), n;
|
|
2664
2705
|
}
|
|
2665
|
-
function
|
|
2666
|
-
const s =
|
|
2706
|
+
function Oe(e, t) {
|
|
2707
|
+
const s = Nt(e), n = Nt(t);
|
|
2667
2708
|
return s && n ? s === n : e.content === t.content;
|
|
2668
2709
|
}
|
|
2669
|
-
function
|
|
2710
|
+
function jt(e) {
|
|
2670
2711
|
return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
|
|
2671
2712
|
}
|
|
2672
|
-
function
|
|
2713
|
+
function Nt(e) {
|
|
2673
2714
|
const t = e.clientMessageId;
|
|
2674
2715
|
if (t)
|
|
2675
2716
|
return t;
|
|
@@ -2678,8 +2719,8 @@ function Dt(e) {
|
|
|
2678
2719
|
);
|
|
2679
2720
|
return n ? e.id.slice(n.length) : null;
|
|
2680
2721
|
}
|
|
2681
|
-
function
|
|
2682
|
-
const t =
|
|
2722
|
+
function ge(e) {
|
|
2723
|
+
const t = ve(e);
|
|
2683
2724
|
if (t === null)
|
|
2684
2725
|
return !1;
|
|
2685
2726
|
const s = e[t].id, n = e.some(
|
|
@@ -2689,7 +2730,7 @@ function pe(e) {
|
|
|
2689
2730
|
return n;
|
|
2690
2731
|
for (let r = e.length - 1; r > t; r -= 1) {
|
|
2691
2732
|
const i = e[r];
|
|
2692
|
-
if (
|
|
2733
|
+
if (x(i))
|
|
2693
2734
|
return !0;
|
|
2694
2735
|
if (i.role === "system") {
|
|
2695
2736
|
if (i.dataType === "run_error")
|
|
@@ -2700,23 +2741,23 @@ function pe(e) {
|
|
|
2700
2741
|
}
|
|
2701
2742
|
return !1;
|
|
2702
2743
|
}
|
|
2703
|
-
function
|
|
2704
|
-
const t =
|
|
2744
|
+
function zn(e) {
|
|
2745
|
+
const t = ve(e);
|
|
2705
2746
|
if (t === null)
|
|
2706
|
-
return e.some(
|
|
2747
|
+
return e.some(x);
|
|
2707
2748
|
const s = e[t].id;
|
|
2708
2749
|
return e.some((n) => n.respondsToUserMessageId === s) ? e.some(
|
|
2709
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
2710
|
-
) : e.slice(t + 1).some(
|
|
2750
|
+
(n) => n.respondsToUserMessageId === s && x(n)
|
|
2751
|
+
) : e.slice(t + 1).some(x);
|
|
2711
2752
|
}
|
|
2712
|
-
function
|
|
2753
|
+
function ve(e) {
|
|
2713
2754
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2714
2755
|
if (e[t].role === "user")
|
|
2715
2756
|
return t;
|
|
2716
2757
|
return null;
|
|
2717
2758
|
}
|
|
2718
2759
|
function xt(e) {
|
|
2719
|
-
return
|
|
2760
|
+
return x(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2720
2761
|
}
|
|
2721
2762
|
function at(e) {
|
|
2722
2763
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
@@ -2732,7 +2773,7 @@ function at(e) {
|
|
|
2732
2773
|
}
|
|
2733
2774
|
return null;
|
|
2734
2775
|
}
|
|
2735
|
-
function
|
|
2776
|
+
function Gn(e) {
|
|
2736
2777
|
const t = at(e);
|
|
2737
2778
|
if (t === null)
|
|
2738
2779
|
return null;
|
|
@@ -2748,13 +2789,13 @@ function q(e) {
|
|
|
2748
2789
|
const t = e.data;
|
|
2749
2790
|
return t && typeof t == "object" ? t : null;
|
|
2750
2791
|
}
|
|
2751
|
-
function
|
|
2792
|
+
function Ot(e) {
|
|
2752
2793
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2753
2794
|
}
|
|
2754
|
-
function
|
|
2795
|
+
function me(e) {
|
|
2755
2796
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2756
2797
|
}
|
|
2757
|
-
function
|
|
2798
|
+
function Xn(e, t) {
|
|
2758
2799
|
const s = at(t);
|
|
2759
2800
|
if (s === null)
|
|
2760
2801
|
return !1;
|
|
@@ -2779,7 +2820,7 @@ function vt(e) {
|
|
|
2779
2820
|
const r = n.clientMessageId;
|
|
2780
2821
|
return typeof r == "string" ? r : null;
|
|
2781
2822
|
}
|
|
2782
|
-
function
|
|
2823
|
+
function Kn(e) {
|
|
2783
2824
|
const t = at(e);
|
|
2784
2825
|
if (t === null)
|
|
2785
2826
|
return null;
|
|
@@ -2794,22 +2835,22 @@ function zn(e) {
|
|
|
2794
2835
|
if (i.type === "message" && i.role === "assistant")
|
|
2795
2836
|
return null;
|
|
2796
2837
|
if (i.type === "run_error")
|
|
2797
|
-
return i.retryable !== !0 ? null :
|
|
2838
|
+
return i.retryable !== !0 ? null : ye(e, i) ?? vt(e);
|
|
2798
2839
|
if (i.type === "run_status")
|
|
2799
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
2840
|
+
return i.status === "interrupted" && i.retryable === !0 ? ye(e, i) ?? vt(e) : null;
|
|
2800
2841
|
}
|
|
2801
2842
|
return null;
|
|
2802
2843
|
}
|
|
2803
|
-
function
|
|
2844
|
+
function ye(e, t) {
|
|
2804
2845
|
if (typeof t.clientMessageId == "string")
|
|
2805
2846
|
return t.clientMessageId;
|
|
2806
|
-
const s =
|
|
2847
|
+
const s = O(t);
|
|
2807
2848
|
if (!s)
|
|
2808
2849
|
return null;
|
|
2809
2850
|
const n = e.find((i) => E(i, "id") === s), r = q(n);
|
|
2810
2851
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2811
2852
|
}
|
|
2812
|
-
function
|
|
2853
|
+
function Jn(e, t) {
|
|
2813
2854
|
let s = 0;
|
|
2814
2855
|
for (const n of e) {
|
|
2815
2856
|
if (!n || typeof n != "object")
|
|
@@ -2822,56 +2863,56 @@ function Gn(e, t) {
|
|
|
2822
2863
|
}
|
|
2823
2864
|
return s;
|
|
2824
2865
|
}
|
|
2825
|
-
function
|
|
2826
|
-
if (!t || !
|
|
2866
|
+
function Ie(e, t, s, n, r) {
|
|
2867
|
+
if (!t || !Vn(e))
|
|
2827
2868
|
return !1;
|
|
2828
2869
|
const i = e;
|
|
2829
|
-
return !(
|
|
2870
|
+
return !(Ot(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && C(i) !== r));
|
|
2830
2871
|
}
|
|
2831
|
-
function
|
|
2872
|
+
function Vn(e) {
|
|
2832
2873
|
if (!e || typeof e != "object")
|
|
2833
2874
|
return !1;
|
|
2834
2875
|
const t = e;
|
|
2835
2876
|
return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted" || t.status === "failed");
|
|
2836
2877
|
}
|
|
2837
|
-
function
|
|
2878
|
+
function x(e) {
|
|
2838
2879
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
2839
2880
|
}
|
|
2840
|
-
function
|
|
2881
|
+
function Yn(e) {
|
|
2841
2882
|
if (!e || typeof e != "object")
|
|
2842
2883
|
return !1;
|
|
2843
2884
|
const t = e;
|
|
2844
2885
|
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";
|
|
2845
2886
|
}
|
|
2846
|
-
function
|
|
2847
|
-
return e.filter((t, s) => ct(t) ? !
|
|
2887
|
+
function Lt(e) {
|
|
2888
|
+
return e.filter((t, s) => ct(t) ? !ir(e, s) && !nr(e, s) && !rr(e, s) : Zn(t) ? t.retryable === !0 && sr(e, s) ? !1 : !er(e, s) : !0);
|
|
2848
2889
|
}
|
|
2849
|
-
function
|
|
2890
|
+
function Zn(e) {
|
|
2850
2891
|
return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
|
|
2851
2892
|
}
|
|
2852
2893
|
function ct(e) {
|
|
2853
2894
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
2854
2895
|
}
|
|
2855
|
-
function
|
|
2896
|
+
function Qn(e, t) {
|
|
2856
2897
|
const s = [...e].reverse().find(
|
|
2857
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t &&
|
|
2898
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && Te(n) && !tr(
|
|
2858
2899
|
e,
|
|
2859
2900
|
n.respondsToUserMessageId
|
|
2860
2901
|
)
|
|
2861
2902
|
)?.respondsToUserMessageId;
|
|
2862
2903
|
return s ? e.map(
|
|
2863
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
2904
|
+
(n) => n.respondsToUserMessageId === s && Te(n) ? { ...n, steered: !0 } : n
|
|
2864
2905
|
) : e;
|
|
2865
2906
|
}
|
|
2866
|
-
function
|
|
2907
|
+
function Te(e) {
|
|
2867
2908
|
return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
|
|
2868
2909
|
}
|
|
2869
|
-
function
|
|
2910
|
+
function tr(e, t) {
|
|
2870
2911
|
return e.some(
|
|
2871
|
-
(s) => s.respondsToUserMessageId === t && (
|
|
2912
|
+
(s) => s.respondsToUserMessageId === t && (x(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
2872
2913
|
);
|
|
2873
2914
|
}
|
|
2874
|
-
function
|
|
2915
|
+
function er(e, t) {
|
|
2875
2916
|
const s = e[t];
|
|
2876
2917
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2877
2918
|
const r = e[n];
|
|
@@ -2880,7 +2921,7 @@ function Zn(e, t) {
|
|
|
2880
2921
|
}
|
|
2881
2922
|
return !1;
|
|
2882
2923
|
}
|
|
2883
|
-
function
|
|
2924
|
+
function sr(e, t) {
|
|
2884
2925
|
const s = e[t];
|
|
2885
2926
|
if (!s.respondsToUserMessageId)
|
|
2886
2927
|
return !1;
|
|
@@ -2893,19 +2934,19 @@ function Qn(e, t) {
|
|
|
2893
2934
|
}
|
|
2894
2935
|
return !1;
|
|
2895
2936
|
}
|
|
2896
|
-
function
|
|
2937
|
+
function nr(e, t) {
|
|
2897
2938
|
const s = e[t];
|
|
2898
2939
|
return e.some(
|
|
2899
2940
|
(n, r) => r !== t && n.role === "assistant" && lt(s, n)
|
|
2900
2941
|
);
|
|
2901
2942
|
}
|
|
2902
|
-
function
|
|
2943
|
+
function rr(e, t) {
|
|
2903
2944
|
const s = e[t];
|
|
2904
2945
|
return e.some(
|
|
2905
2946
|
(n, r) => r !== t && n.role === "tool" && lt(s, n)
|
|
2906
2947
|
);
|
|
2907
2948
|
}
|
|
2908
|
-
function
|
|
2949
|
+
function ir(e, t) {
|
|
2909
2950
|
const s = e[t];
|
|
2910
2951
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2911
2952
|
if (ct(e[n]) && lt(s, e[n]))
|
|
@@ -2918,15 +2959,15 @@ function lt(e, t) {
|
|
|
2918
2959
|
function E(e, t) {
|
|
2919
2960
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
2920
2961
|
}
|
|
2921
|
-
function
|
|
2962
|
+
function or(e, t) {
|
|
2922
2963
|
try {
|
|
2923
|
-
const s = window.localStorage.getItem(`${
|
|
2964
|
+
const s = window.localStorage.getItem(`${ke}${e}`);
|
|
2924
2965
|
if (!s)
|
|
2925
2966
|
return null;
|
|
2926
2967
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
2927
2968
|
if (t !== void 0 && r !== t)
|
|
2928
2969
|
return null;
|
|
2929
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2970
|
+
const i = Array.isArray(n.messages) ? n.messages.map(mr).filter((o) => !!o) : [];
|
|
2930
2971
|
return {
|
|
2931
2972
|
sessionId: r,
|
|
2932
2973
|
messages: i
|
|
@@ -2935,46 +2976,46 @@ function nr(e, t) {
|
|
|
2935
2976
|
return null;
|
|
2936
2977
|
}
|
|
2937
2978
|
}
|
|
2938
|
-
function
|
|
2979
|
+
function ar(e, t) {
|
|
2939
2980
|
try {
|
|
2940
2981
|
window.localStorage.setItem(
|
|
2941
|
-
`${
|
|
2982
|
+
`${ke}${e}`,
|
|
2942
2983
|
JSON.stringify({
|
|
2943
2984
|
sessionId: t.sessionId,
|
|
2944
|
-
messages: t.messages.slice(-
|
|
2985
|
+
messages: t.messages.slice(-xs).map(yr)
|
|
2945
2986
|
})
|
|
2946
2987
|
);
|
|
2947
2988
|
} catch {
|
|
2948
2989
|
return;
|
|
2949
2990
|
}
|
|
2950
2991
|
}
|
|
2951
|
-
function
|
|
2992
|
+
function cr(e) {
|
|
2952
2993
|
try {
|
|
2953
|
-
const t = window.localStorage.getItem(`${
|
|
2994
|
+
const t = window.localStorage.getItem(`${Ut}${e}`);
|
|
2954
2995
|
if (!t)
|
|
2955
2996
|
return [];
|
|
2956
2997
|
const s = JSON.parse(t);
|
|
2957
|
-
return Array.isArray(s) ? s.filter(
|
|
2998
|
+
return Array.isArray(s) ? s.filter(zt) : [];
|
|
2958
2999
|
} catch {
|
|
2959
3000
|
return [];
|
|
2960
3001
|
}
|
|
2961
3002
|
}
|
|
2962
3003
|
function j(e, t) {
|
|
2963
3004
|
try {
|
|
2964
|
-
const s = t.filter(
|
|
3005
|
+
const s = t.filter(zt);
|
|
2965
3006
|
if (s.length === 0) {
|
|
2966
|
-
window.localStorage.removeItem(`${
|
|
3007
|
+
window.localStorage.removeItem(`${Ut}${e}`);
|
|
2967
3008
|
return;
|
|
2968
3009
|
}
|
|
2969
3010
|
window.localStorage.setItem(
|
|
2970
|
-
`${
|
|
3011
|
+
`${Ut}${e}`,
|
|
2971
3012
|
JSON.stringify(s.slice(-25))
|
|
2972
3013
|
);
|
|
2973
3014
|
} catch {
|
|
2974
3015
|
return;
|
|
2975
3016
|
}
|
|
2976
3017
|
}
|
|
2977
|
-
function
|
|
3018
|
+
function Le(e, t) {
|
|
2978
3019
|
try {
|
|
2979
3020
|
const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
2980
3021
|
...o,
|
|
@@ -2990,28 +3031,28 @@ function ve(e, t) {
|
|
|
2990
3031
|
} catch {
|
|
2991
3032
|
}
|
|
2992
3033
|
}
|
|
2993
|
-
function
|
|
3034
|
+
function lr(e, t) {
|
|
2994
3035
|
try {
|
|
2995
3036
|
if (window.sessionStorage.getItem(`${ot}${e}`) === null)
|
|
2996
3037
|
return;
|
|
2997
3038
|
} catch {
|
|
2998
3039
|
return;
|
|
2999
3040
|
}
|
|
3000
|
-
|
|
3041
|
+
Le(e, t);
|
|
3001
3042
|
}
|
|
3002
|
-
function
|
|
3043
|
+
function ur(e) {
|
|
3003
3044
|
try {
|
|
3004
3045
|
const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
|
|
3005
3046
|
if (window.sessionStorage.removeItem(t), !s)
|
|
3006
3047
|
return [];
|
|
3007
3048
|
const n = JSON.parse(s);
|
|
3008
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3049
|
+
return Array.isArray(n) ? n.flatMap((r) => hr(r) ? [{
|
|
3009
3050
|
...r.event,
|
|
3010
3051
|
page: b(),
|
|
3011
3052
|
rawOutput: {
|
|
3012
3053
|
pageContextRestarted: !0,
|
|
3013
3054
|
outcome: "unknown",
|
|
3014
|
-
message:
|
|
3055
|
+
message: dr(location.href),
|
|
3015
3056
|
currentUrl: location.href,
|
|
3016
3057
|
console: [],
|
|
3017
3058
|
metadata: {
|
|
@@ -3028,17 +3069,17 @@ function ar(e) {
|
|
|
3028
3069
|
return [];
|
|
3029
3070
|
}
|
|
3030
3071
|
}
|
|
3031
|
-
function
|
|
3072
|
+
function dr(e) {
|
|
3032
3073
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3033
3074
|
Current URL: ${e}`;
|
|
3034
3075
|
}
|
|
3035
|
-
function
|
|
3076
|
+
function hr(e) {
|
|
3036
3077
|
if (!e || typeof e != "object")
|
|
3037
3078
|
return !1;
|
|
3038
3079
|
const t = e, s = t.event;
|
|
3039
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
3080
|
+
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && zt(s) && s.type === "tool.result";
|
|
3040
3081
|
}
|
|
3041
|
-
function
|
|
3082
|
+
function pr(e, t) {
|
|
3042
3083
|
const s = new Set(
|
|
3043
3084
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3044
3085
|
);
|
|
@@ -3047,26 +3088,26 @@ function ur(e, t) {
|
|
|
3047
3088
|
...t.filter((n) => !s.has(n.callId))
|
|
3048
3089
|
];
|
|
3049
3090
|
}
|
|
3050
|
-
function
|
|
3091
|
+
function fr(e) {
|
|
3051
3092
|
try {
|
|
3052
3093
|
window.sessionStorage.removeItem(`${ot}${e}`);
|
|
3053
3094
|
} catch {
|
|
3054
3095
|
return;
|
|
3055
3096
|
}
|
|
3056
3097
|
}
|
|
3057
|
-
function
|
|
3098
|
+
function zt(e) {
|
|
3058
3099
|
if (!e || typeof e != "object")
|
|
3059
3100
|
return !1;
|
|
3060
3101
|
const t = e;
|
|
3061
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
3102
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && we(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? we(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;
|
|
3062
3103
|
}
|
|
3063
|
-
function
|
|
3104
|
+
function we(e) {
|
|
3064
3105
|
if (!e || typeof e != "object")
|
|
3065
3106
|
return !1;
|
|
3066
3107
|
const t = e;
|
|
3067
3108
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
3068
3109
|
}
|
|
3069
|
-
function
|
|
3110
|
+
function qe(e, t) {
|
|
3070
3111
|
if (!Array.isArray(e))
|
|
3071
3112
|
return;
|
|
3072
3113
|
const s = e.filter((r) => {
|
|
@@ -3074,23 +3115,23 @@ function Oe(e, t) {
|
|
|
3074
3115
|
return !1;
|
|
3075
3116
|
const i = r;
|
|
3076
3117
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3077
|
-
}), n = t ? s.map((r) =>
|
|
3118
|
+
}), n = t ? s.map((r) => Be(r, t)) : s;
|
|
3078
3119
|
return n.length > 0 ? n : void 0;
|
|
3079
3120
|
}
|
|
3080
|
-
function
|
|
3121
|
+
function Be(e, t) {
|
|
3081
3122
|
return e.fileUrl?.startsWith("/") ? {
|
|
3082
3123
|
...e,
|
|
3083
3124
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
3084
3125
|
} : e;
|
|
3085
3126
|
}
|
|
3086
|
-
function
|
|
3087
|
-
return e.type ||
|
|
3127
|
+
function Se(e) {
|
|
3128
|
+
return e.type || gr(e.name) || "application/octet-stream";
|
|
3088
3129
|
}
|
|
3089
|
-
function
|
|
3130
|
+
function gr(e) {
|
|
3090
3131
|
const t = e.toLowerCase();
|
|
3091
3132
|
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;
|
|
3092
3133
|
}
|
|
3093
|
-
function
|
|
3134
|
+
function mr(e) {
|
|
3094
3135
|
if (!e || typeof e != "object")
|
|
3095
3136
|
return null;
|
|
3096
3137
|
const t = e;
|
|
@@ -3103,17 +3144,17 @@ function pr(e) {
|
|
|
3103
3144
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
3104
3145
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
3105
3146
|
securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
|
|
3106
|
-
attachments:
|
|
3147
|
+
attachments: qe(t.attachments)?.map(Gt),
|
|
3107
3148
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
3108
3149
|
};
|
|
3109
3150
|
}
|
|
3110
|
-
function
|
|
3151
|
+
function yr(e) {
|
|
3111
3152
|
return e.attachments?.length ? {
|
|
3112
3153
|
...e,
|
|
3113
|
-
attachments: e.attachments.map(
|
|
3154
|
+
attachments: e.attachments.map(Gt)
|
|
3114
3155
|
} : e;
|
|
3115
3156
|
}
|
|
3116
|
-
function
|
|
3157
|
+
function Gt(e) {
|
|
3117
3158
|
const {
|
|
3118
3159
|
dataUrl: t,
|
|
3119
3160
|
objectUrl: s,
|
|
@@ -3122,7 +3163,7 @@ function zt(e) {
|
|
|
3122
3163
|
} = e;
|
|
3123
3164
|
return r;
|
|
3124
3165
|
}
|
|
3125
|
-
function
|
|
3166
|
+
function O(e) {
|
|
3126
3167
|
const t = e.respondsToUserMessageId;
|
|
3127
3168
|
return typeof t == "string" && t ? t : null;
|
|
3128
3169
|
}
|
|
@@ -3130,39 +3171,39 @@ function C(e) {
|
|
|
3130
3171
|
const t = e.runId;
|
|
3131
3172
|
return typeof t == "string" && t ? t : null;
|
|
3132
3173
|
}
|
|
3133
|
-
function
|
|
3174
|
+
function Ir(e) {
|
|
3134
3175
|
const t = e?.timeoutMs;
|
|
3135
|
-
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 <=
|
|
3176
|
+
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 <= Ws);
|
|
3136
3177
|
}
|
|
3137
|
-
function
|
|
3178
|
+
function He(e) {
|
|
3138
3179
|
const t = {};
|
|
3139
3180
|
try {
|
|
3140
3181
|
new Headers(e).forEach((s, n) => {
|
|
3141
|
-
Object.keys(t).length <
|
|
3182
|
+
Object.keys(t).length < Wt && (t[n] = Xt(n, s));
|
|
3142
3183
|
});
|
|
3143
3184
|
} catch {
|
|
3144
3185
|
return {};
|
|
3145
3186
|
}
|
|
3146
3187
|
return t;
|
|
3147
3188
|
}
|
|
3148
|
-
function
|
|
3149
|
-
return
|
|
3189
|
+
function Xt(e, t) {
|
|
3190
|
+
return Ge(e) ? ut : P(it(t), Ds);
|
|
3150
3191
|
}
|
|
3151
|
-
function
|
|
3192
|
+
function Tr(e, t) {
|
|
3152
3193
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
3153
3194
|
}
|
|
3154
|
-
async function
|
|
3155
|
-
const r =
|
|
3195
|
+
async function wr(e, t, s, n) {
|
|
3196
|
+
const r = He(e.headers);
|
|
3156
3197
|
n({
|
|
3157
3198
|
...t,
|
|
3158
3199
|
responseStatus: e.status,
|
|
3159
3200
|
responseHeaders: r,
|
|
3160
|
-
responseBody: await
|
|
3201
|
+
responseBody: await Sr(e),
|
|
3161
3202
|
durationMs: Date.now() - s
|
|
3162
3203
|
});
|
|
3163
3204
|
}
|
|
3164
|
-
async function
|
|
3165
|
-
if (!
|
|
3205
|
+
async function Sr(e) {
|
|
3206
|
+
if (!Fe(e.headers))
|
|
3166
3207
|
return;
|
|
3167
3208
|
let t = null, s = null;
|
|
3168
3209
|
try {
|
|
@@ -3171,7 +3212,7 @@ async function Ir(e) {
|
|
|
3171
3212
|
const n = new Promise((a) => {
|
|
3172
3213
|
s = window.setTimeout(() => {
|
|
3173
3214
|
t?.cancel(), a("timeout");
|
|
3174
|
-
},
|
|
3215
|
+
}, Ns);
|
|
3175
3216
|
}), r = new TextDecoder();
|
|
3176
3217
|
let i = "", o = 0;
|
|
3177
3218
|
for (; ; ) {
|
|
@@ -3181,7 +3222,7 @@ async function Ir(e) {
|
|
|
3181
3222
|
const { done: c, value: l } = a;
|
|
3182
3223
|
if (c)
|
|
3183
3224
|
return P(i + r.decode());
|
|
3184
|
-
const u =
|
|
3225
|
+
const u = Ft - o;
|
|
3185
3226
|
if (l.byteLength > u)
|
|
3186
3227
|
return i += r.decode(l.subarray(0, Math.max(u, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
|
|
3187
3228
|
o += l.byteLength, i += r.decode(l, { stream: !0 });
|
|
@@ -3193,26 +3234,26 @@ async function Ir(e) {
|
|
|
3193
3234
|
s !== null && window.clearTimeout(s);
|
|
3194
3235
|
}
|
|
3195
3236
|
}
|
|
3196
|
-
function
|
|
3197
|
-
if (
|
|
3237
|
+
function Ar(e, t) {
|
|
3238
|
+
if (Fe(new Headers(t)))
|
|
3198
3239
|
try {
|
|
3199
3240
|
return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
|
|
3200
3241
|
} catch {
|
|
3201
3242
|
return;
|
|
3202
3243
|
}
|
|
3203
3244
|
}
|
|
3204
|
-
function
|
|
3245
|
+
function Ae(e) {
|
|
3205
3246
|
if (typeof e == "string")
|
|
3206
3247
|
return P(e);
|
|
3207
3248
|
}
|
|
3208
|
-
function
|
|
3249
|
+
function Er(e) {
|
|
3209
3250
|
return M({
|
|
3210
3251
|
...e,
|
|
3211
|
-
requestBody:
|
|
3212
|
-
responseBody:
|
|
3252
|
+
requestBody: Ee(e.requestBody),
|
|
3253
|
+
responseBody: Ee(e.responseBody)
|
|
3213
3254
|
});
|
|
3214
3255
|
}
|
|
3215
|
-
function
|
|
3256
|
+
function Ee(e) {
|
|
3216
3257
|
if (typeof e != "string")
|
|
3217
3258
|
return e;
|
|
3218
3259
|
const t = e.trim();
|
|
@@ -3224,14 +3265,14 @@ function Se(e) {
|
|
|
3224
3265
|
return it(e);
|
|
3225
3266
|
}
|
|
3226
3267
|
}
|
|
3227
|
-
function
|
|
3268
|
+
function Fe(e) {
|
|
3228
3269
|
if (!e)
|
|
3229
3270
|
return !1;
|
|
3230
3271
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3231
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3272
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= Ft && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3232
3273
|
}
|
|
3233
|
-
function
|
|
3234
|
-
if (
|
|
3274
|
+
function v(e, t = {}, s) {
|
|
3275
|
+
if (br(s))
|
|
3235
3276
|
return !0;
|
|
3236
3277
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3237
3278
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3246,8 +3287,8 @@ function O(e, t = {}, s) {
|
|
|
3246
3287
|
return !0;
|
|
3247
3288
|
}
|
|
3248
3289
|
}
|
|
3249
|
-
function
|
|
3250
|
-
if (
|
|
3290
|
+
function Rr(e, t) {
|
|
3291
|
+
if (v(e))
|
|
3251
3292
|
return !0;
|
|
3252
3293
|
try {
|
|
3253
3294
|
const s = new URL(e, location.href), n = new URL(t);
|
|
@@ -3256,26 +3297,26 @@ function Sr(e, t) {
|
|
|
3256
3297
|
return !0;
|
|
3257
3298
|
}
|
|
3258
3299
|
}
|
|
3259
|
-
function
|
|
3300
|
+
function br(e) {
|
|
3260
3301
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3261
3302
|
}
|
|
3262
|
-
function
|
|
3303
|
+
function Mr(e) {
|
|
3263
3304
|
const t = {};
|
|
3264
3305
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3265
3306
|
const n = s.indexOf(":");
|
|
3266
3307
|
if (n <= 0)
|
|
3267
3308
|
continue;
|
|
3268
|
-
if (Object.keys(t).length >=
|
|
3309
|
+
if (Object.keys(t).length >= Wt)
|
|
3269
3310
|
break;
|
|
3270
3311
|
const r = s.slice(0, n).trim();
|
|
3271
|
-
t[r] =
|
|
3312
|
+
t[r] = Xt(r, s.slice(n + 1).trim());
|
|
3272
3313
|
}
|
|
3273
3314
|
return t;
|
|
3274
3315
|
}
|
|
3275
|
-
function P(e, t =
|
|
3316
|
+
function P(e, t = Ft) {
|
|
3276
3317
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
3277
3318
|
}
|
|
3278
|
-
function
|
|
3319
|
+
function _t(e) {
|
|
3279
3320
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3280
3321
|
}
|
|
3281
3322
|
class nt extends Error {
|
|
@@ -3286,31 +3327,31 @@ class nt extends Error {
|
|
|
3286
3327
|
}
|
|
3287
3328
|
async function tt(e, t) {
|
|
3288
3329
|
let s = null;
|
|
3289
|
-
for (let n = 0; n <
|
|
3330
|
+
for (let n = 0; n < le; n += 1)
|
|
3290
3331
|
try {
|
|
3291
3332
|
return await e();
|
|
3292
3333
|
} catch (r) {
|
|
3293
|
-
if (s = r, n >=
|
|
3334
|
+
if (s = r, n >= le - 1 || !_r(r))
|
|
3294
3335
|
throw r;
|
|
3295
|
-
await
|
|
3336
|
+
await kr(n);
|
|
3296
3337
|
}
|
|
3297
3338
|
throw s instanceof Error ? s : new Error(t);
|
|
3298
3339
|
}
|
|
3299
|
-
function
|
|
3340
|
+
function kr(e) {
|
|
3300
3341
|
return new Promise((t) => {
|
|
3301
|
-
window.setTimeout(t,
|
|
3342
|
+
window.setTimeout(t, Us[e] ?? 0);
|
|
3302
3343
|
});
|
|
3303
3344
|
}
|
|
3304
|
-
function
|
|
3305
|
-
return e instanceof nt ?
|
|
3345
|
+
function _r(e) {
|
|
3346
|
+
return e instanceof nt ? Cr(e.status) : e instanceof TypeError;
|
|
3306
3347
|
}
|
|
3307
|
-
function
|
|
3348
|
+
function Cr(e) {
|
|
3308
3349
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3309
3350
|
}
|
|
3310
|
-
function
|
|
3351
|
+
function Pr(e) {
|
|
3311
3352
|
return e === 401 || e === 403;
|
|
3312
3353
|
}
|
|
3313
|
-
const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]",
|
|
3354
|
+
const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", Ur = "[REDACTED_SIGNED_URL]", Dr = 20, Nr = /^(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, We = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, $e = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, je = /\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, xr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Or = /\bhttps?:\/\/[^\s"'<>]+/gi, vr = /[),.;\]]+$/;
|
|
3314
3355
|
function M(e) {
|
|
3315
3356
|
return rt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3316
3357
|
}
|
|
@@ -3319,7 +3360,7 @@ function rt(e, t, s) {
|
|
|
3319
3360
|
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
|
|
3320
3361
|
if (e === null || typeof e != "object")
|
|
3321
3362
|
return e;
|
|
3322
|
-
if (t >=
|
|
3363
|
+
if (t >= Dr)
|
|
3323
3364
|
return "[REDACTED_MAX_DEPTH]";
|
|
3324
3365
|
if (s.has(e))
|
|
3325
3366
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -3327,44 +3368,44 @@ function rt(e, t, s) {
|
|
|
3327
3368
|
return e.map((r) => rt(r, t + 1, s));
|
|
3328
3369
|
const n = {};
|
|
3329
3370
|
for (const [r, i] of Object.entries(e))
|
|
3330
|
-
r === "pageContent" ? n[r] = i :
|
|
3371
|
+
r === "pageContent" ? n[r] = i : Ge(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Lr(i) : rt(i, t + 1, s);
|
|
3331
3372
|
return n;
|
|
3332
3373
|
}
|
|
3333
|
-
function
|
|
3374
|
+
function Ge(e) {
|
|
3334
3375
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3335
3376
|
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");
|
|
3336
3377
|
}
|
|
3337
|
-
function
|
|
3338
|
-
return typeof e == "string" ?
|
|
3378
|
+
function Lr(e) {
|
|
3379
|
+
return typeof e == "string" ? Xe(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3339
3380
|
}
|
|
3340
|
-
function
|
|
3381
|
+
function Xe(e) {
|
|
3341
3382
|
try {
|
|
3342
3383
|
const t = new URL(e, location.href);
|
|
3343
3384
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3344
|
-
|
|
3385
|
+
Nr.test(s) && t.searchParams.set(s, U);
|
|
3345
3386
|
return t.username && (t.username = U), t.password && (t.password = U), t.toString();
|
|
3346
3387
|
} catch {
|
|
3347
|
-
return
|
|
3388
|
+
return qr(e);
|
|
3348
3389
|
}
|
|
3349
3390
|
}
|
|
3350
3391
|
function it(e) {
|
|
3351
|
-
return e.replace(
|
|
3392
|
+
return e.replace(xr, Ur).replace(Or, Br).replace(We, `Bearer ${U}`).replace($e, `Basic ${U}`).replace(je, U).replace(ze, (t, s) => `${s}: ${ut}`);
|
|
3352
3393
|
}
|
|
3353
|
-
function
|
|
3354
|
-
return e.replace(
|
|
3394
|
+
function qr(e) {
|
|
3395
|
+
return e.replace(We, `Bearer ${U}`).replace($e, `Basic ${U}`).replace(je, U).replace(ze, (t, s) => `${s}: ${ut}`);
|
|
3355
3396
|
}
|
|
3356
|
-
function
|
|
3357
|
-
const t = e.match(
|
|
3358
|
-
return `${
|
|
3397
|
+
function Br(e) {
|
|
3398
|
+
const t = e.match(vr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3399
|
+
return `${Xe(s)}${t}`;
|
|
3359
3400
|
}
|
|
3360
3401
|
export {
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3402
|
+
ne as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3403
|
+
Pt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3404
|
+
gs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3405
|
+
fs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3406
|
+
ms as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3407
|
+
_e as PlunoProductAgent,
|
|
3408
|
+
vs as calculateReconnectDelay,
|
|
3409
|
+
_e as default,
|
|
3410
|
+
on as getProductAgentOriginAccessErrorMessage
|
|
3370
3411
|
};
|