@pluno/product-agent-web 0.1.122 → 0.1.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/product-agent-sdk.js +708 -661
- package/dist/product-agent-widget.js +850 -800
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
1
|
+
const Ve = "pluno-product-agent-attachments";
|
|
2
|
+
const Mt = "files";
|
|
3
|
+
async function Se(e) {
|
|
4
4
|
const t = await it();
|
|
5
|
-
await
|
|
5
|
+
await ke(t, "readwrite", (s) => s.put(e));
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
8
|
-
const t = await it(), s = await
|
|
7
|
+
async function Ye(e) {
|
|
8
|
+
const t = await it(), s = await ke(
|
|
9
9
|
t,
|
|
10
10
|
"readonly",
|
|
11
11
|
(r) => r.get(e)
|
|
@@ -13,12 +13,12 @@ async function Ve(e) {
|
|
|
13
13
|
if (!s)
|
|
14
14
|
return null;
|
|
15
15
|
const n = Date.now();
|
|
16
|
-
return await
|
|
16
|
+
return await Ee(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
|
|
17
17
|
}
|
|
18
|
-
async function
|
|
18
|
+
async function Ee(e, t) {
|
|
19
19
|
const s = await it();
|
|
20
|
-
await
|
|
21
|
-
const r = await
|
|
20
|
+
await Lt(s, "readwrite", async (n) => {
|
|
21
|
+
const r = await xt(
|
|
22
22
|
n.get(e)
|
|
23
23
|
);
|
|
24
24
|
r && n.put({
|
|
@@ -27,38 +27,38 @@ async function Se(e, t) {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
30
|
+
async function Ze(e = 864e5) {
|
|
31
31
|
const t = await it(), s = Date.now() - e;
|
|
32
|
-
await
|
|
32
|
+
await Lt(t, "readwrite", async (n) => {
|
|
33
33
|
const r = n.index("lastUsedAt");
|
|
34
|
-
(await
|
|
34
|
+
(await xt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
function it() {
|
|
38
38
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
39
|
-
const s = indexedDB.open(
|
|
39
|
+
const s = indexedDB.open(Ve, 1);
|
|
40
40
|
s.onupgradeneeded = () => {
|
|
41
|
-
const r = s.result.createObjectStore(
|
|
41
|
+
const r = s.result.createObjectStore(Mt, { keyPath: "attachmentId" });
|
|
42
42
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
43
43
|
}, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
async function
|
|
47
|
-
return await
|
|
46
|
+
async function ke(e, t, s) {
|
|
47
|
+
return await Lt(e, t, async (n) => await xt(s(n)));
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function Lt(e, t, s) {
|
|
50
50
|
return new Promise((n, r) => {
|
|
51
|
-
const i = e.transaction(
|
|
51
|
+
const i = e.transaction(Mt, t), o = i.objectStore(Mt);
|
|
52
52
|
let a, u = !1;
|
|
53
|
-
s(o).then((
|
|
54
|
-
a =
|
|
55
|
-
}).catch((
|
|
53
|
+
s(o).then((c) => {
|
|
54
|
+
a = c;
|
|
55
|
+
}).catch((c) => {
|
|
56
56
|
u = !0;
|
|
57
57
|
try {
|
|
58
58
|
i.abort();
|
|
59
59
|
} catch {
|
|
60
60
|
}
|
|
61
|
-
r(
|
|
61
|
+
r(c);
|
|
62
62
|
}), i.oncomplete = () => {
|
|
63
63
|
u || n(a);
|
|
64
64
|
}, i.onerror = () => {
|
|
@@ -68,16 +68,16 @@ function vt(e, t, s) {
|
|
|
68
68
|
};
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function xt(e) {
|
|
72
72
|
return new Promise((t, s) => {
|
|
73
73
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function Qe(e) {
|
|
77
77
|
return e !== null && (typeof e == "object" || typeof e == "function");
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
const n = Reflect.get(e, "pluno"), r =
|
|
79
|
+
function Bt(e, t, s) {
|
|
80
|
+
const n = Reflect.get(e, "pluno"), r = Qe(n) ? n : {};
|
|
81
81
|
if (r !== n && !Reflect.set(e, "pluno", r))
|
|
82
82
|
return null;
|
|
83
83
|
const i = Object.getOwnPropertyDescriptor(r, t);
|
|
@@ -91,11 +91,11 @@ function xt(e, t, s) {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
const
|
|
94
|
+
const wt = "pluno.productAgent.transportId", ts = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", es = 50, ss = globalThis.setTimeout.bind(globalThis);
|
|
95
95
|
let F = null;
|
|
96
|
-
const tt = /* @__PURE__ */ new Set();
|
|
97
|
-
async function
|
|
98
|
-
const t = e.randomUUID(), s = e.storage.getItem(
|
|
96
|
+
const tt = /* @__PURE__ */ new Set(), St = /* @__PURE__ */ new Map();
|
|
97
|
+
async function ns(e = be()) {
|
|
98
|
+
const t = e.randomUUID(), s = e.storage.getItem(wt);
|
|
99
99
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
100
100
|
const o = e.channel.subscribe((u) => {
|
|
101
101
|
if (!(u.senderId === t || u.transportId !== n)) {
|
|
@@ -113,14 +113,14 @@ async function ss(e = ke()) {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
if (!s)
|
|
116
|
-
e.storage.setItem(
|
|
116
|
+
e.storage.setItem(wt, n), r = !0;
|
|
117
117
|
else
|
|
118
118
|
for (; ; ) {
|
|
119
119
|
if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
|
|
120
120
|
r = !0;
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
123
|
-
n = e.randomUUID(), e.storage.setItem(
|
|
123
|
+
n = e.randomUUID(), e.storage.setItem(wt, n);
|
|
124
124
|
}
|
|
125
125
|
let a = !1;
|
|
126
126
|
return {
|
|
@@ -130,14 +130,14 @@ async function ss(e = ke()) {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
async function
|
|
134
|
-
F || (F =
|
|
133
|
+
async function rs() {
|
|
134
|
+
F || (F = ns(be()), F.then((n) => {
|
|
135
135
|
const r = (i) => {
|
|
136
136
|
i.persisted || (n.release(), F = null, tt.clear(), window.removeEventListener("pagehide", r));
|
|
137
137
|
};
|
|
138
138
|
window.addEventListener("pagehide", r);
|
|
139
139
|
}));
|
|
140
|
-
const e = await F, t =
|
|
140
|
+
const e = await F, t = is();
|
|
141
141
|
tt.add(t);
|
|
142
142
|
let s = !1;
|
|
143
143
|
return {
|
|
@@ -148,23 +148,41 @@ async function ns() {
|
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function is() {
|
|
152
152
|
let e = 0;
|
|
153
153
|
for (; tt.has(e); )
|
|
154
154
|
e += 1;
|
|
155
155
|
return e;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function be() {
|
|
158
158
|
return {
|
|
159
|
-
storage:
|
|
160
|
-
channel:
|
|
159
|
+
storage: os(),
|
|
160
|
+
channel: as(),
|
|
161
161
|
randomUUID: () => crypto.randomUUID(),
|
|
162
|
-
settle: () => new Promise((e) =>
|
|
162
|
+
settle: () => new Promise((e) => ss(e, es))
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function os() {
|
|
166
|
+
return {
|
|
167
|
+
getItem: (e) => {
|
|
168
|
+
try {
|
|
169
|
+
return window.sessionStorage?.getItem(e) ?? St.get(e) ?? null;
|
|
170
|
+
} catch {
|
|
171
|
+
return St.get(e) ?? null;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
setItem: (e, t) => {
|
|
175
|
+
St.set(e, t);
|
|
176
|
+
try {
|
|
177
|
+
window.sessionStorage?.setItem(e, t);
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function as() {
|
|
166
184
|
if (typeof BroadcastChannel < "u") {
|
|
167
|
-
const e = new BroadcastChannel(
|
|
185
|
+
const e = new BroadcastChannel(ts);
|
|
168
186
|
return {
|
|
169
187
|
postMessage: (t) => e.postMessage(t),
|
|
170
188
|
subscribe: (t) => {
|
|
@@ -174,9 +192,9 @@ function is() {
|
|
|
174
192
|
close: () => e.close()
|
|
175
193
|
};
|
|
176
194
|
}
|
|
177
|
-
return
|
|
195
|
+
return cs();
|
|
178
196
|
}
|
|
179
|
-
function
|
|
197
|
+
function cs() {
|
|
180
198
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
181
199
|
if (s.key !== At || !s.newValue)
|
|
182
200
|
return;
|
|
@@ -197,18 +215,18 @@ function os() {
|
|
|
197
215
|
}
|
|
198
216
|
};
|
|
199
217
|
}
|
|
200
|
-
const
|
|
218
|
+
const Ct = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ls = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', us = ".pluno-pa-widget__panel", ds = ".pluno-pa-widget__timeline", ne = `${Ct}[data-pluno-sdk-preview-channel]`, hs = "https://app.pluno.ai", ps = "gpt-5.6-terra", fs = 2e4, gs = 1e4, ms = 1e4, ys = 1e4, Ts = 1e4, Is = 1e3, re = 3e4, ie = 0.2, oe = 6e4, ws = 15e3, K = 8, As = 15e3, Ss = 2e3, Es = 1e3, ks = 100, bs = 8e3, Rs = 15e3, ae = 3, _s = [300, 1e3], qt = 64e3, Et = 4e3, Ht = 30, Ms = 2e3, Cs = 1e3, Ps = 200 * 1024 * 1024, Ft = "Image is too large for model vision input.", Us = 100, Re = "pluno.productAgent.state.", Pt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Ds = 100;
|
|
201
219
|
function V(e, t = 0) {
|
|
202
220
|
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
203
221
|
return Math.max(t, s);
|
|
204
222
|
}
|
|
205
223
|
const et = /* @__PURE__ */ new Set();
|
|
206
224
|
let Y = null;
|
|
207
|
-
function
|
|
208
|
-
const s = Math.min(
|
|
209
|
-
return Math.min(
|
|
225
|
+
function Ns(e, t = Math.random) {
|
|
226
|
+
const s = Math.min(re, Is * 2 ** e), n = 1 - ie + t() * ie * 2;
|
|
227
|
+
return Math.min(re, Math.round(s * n));
|
|
210
228
|
}
|
|
211
|
-
function
|
|
229
|
+
function Os(e, t, s) {
|
|
212
230
|
return new Promise((n, r) => {
|
|
213
231
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
214
232
|
e.then(
|
|
@@ -221,13 +239,13 @@ function Ds(e, t, s) {
|
|
|
221
239
|
);
|
|
222
240
|
});
|
|
223
241
|
}
|
|
224
|
-
class
|
|
242
|
+
class _e {
|
|
225
243
|
constructor(t, s) {
|
|
226
244
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
227
245
|
...this.state,
|
|
228
|
-
starterPrompts:
|
|
246
|
+
starterPrompts: pn(t.initialStarterPrompts)
|
|
229
247
|
};
|
|
230
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
248
|
+
const n = t.restorePersistedState === !1 ? null : Yn(t.clientId, t.expectedPersistedSessionId);
|
|
231
249
|
n && (this.state = {
|
|
232
250
|
...this.state,
|
|
233
251
|
...n,
|
|
@@ -240,9 +258,9 @@ class Re {
|
|
|
240
258
|
assistantDraftRunId: null,
|
|
241
259
|
isThinking: !1,
|
|
242
260
|
lastError: null
|
|
243
|
-
}), this.queuedClientEvents =
|
|
244
|
-
|
|
245
|
-
|
|
261
|
+
}), this.queuedClientEvents = rr(
|
|
262
|
+
Qn(t.clientId),
|
|
263
|
+
er(t.clientId)
|
|
246
264
|
), W(t.clientId, this.queuedClientEvents);
|
|
247
265
|
}
|
|
248
266
|
options;
|
|
@@ -308,15 +326,15 @@ class Re {
|
|
|
308
326
|
lastErrorSecuritySettingsUrl: null
|
|
309
327
|
};
|
|
310
328
|
static async init(t) {
|
|
311
|
-
const s = await
|
|
329
|
+
const s = await rs(), n = new _e({
|
|
312
330
|
...t,
|
|
313
|
-
backendUrl:
|
|
314
|
-
clientId: t.clientId ??
|
|
315
|
-
model: t.model ??
|
|
331
|
+
backendUrl: Qs(t.backendUrl ?? hs),
|
|
332
|
+
clientId: t.clientId ?? Tn(),
|
|
333
|
+
model: t.model ?? ps
|
|
316
334
|
}, s);
|
|
317
335
|
try {
|
|
318
|
-
|
|
319
|
-
|
|
336
|
+
Ze().catch((r) => {
|
|
337
|
+
I("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
320
338
|
message: r instanceof Error ? r.message : String(r)
|
|
321
339
|
});
|
|
322
340
|
}), t.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), t.autoConnect !== !1 && await n.connect();
|
|
@@ -347,15 +365,15 @@ class Re {
|
|
|
347
365
|
lastError: null
|
|
348
366
|
});
|
|
349
367
|
try {
|
|
350
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
368
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await Os(this.options.tokenProvider(), ms, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
351
369
|
return;
|
|
352
370
|
if (!this.token && !this.options.webSocketFactory)
|
|
353
371
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
354
|
-
const s =
|
|
372
|
+
const s = en(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
355
373
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
356
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (
|
|
357
|
-
},
|
|
358
|
-
this.socket !== n || (this.clearSocketConnectTimer(),
|
|
374
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (I("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
375
|
+
}, ys), n.addEventListener("open", () => {
|
|
376
|
+
this.socket !== n || (this.clearSocketConnectTimer(), I("web-sdk.agent", "Pluno socket opened", {
|
|
359
377
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
360
378
|
isThinking: this.state.isThinking
|
|
361
379
|
}), !(this.token ? this.sendNow({
|
|
@@ -365,12 +383,12 @@ class Re {
|
|
|
365
383
|
transportId: this.transportIdentity.transportId,
|
|
366
384
|
pageUrl: location.href
|
|
367
385
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
368
|
-
this.socket === n && (
|
|
369
|
-
},
|
|
386
|
+
this.socket === n && (I("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
387
|
+
}, Ts));
|
|
370
388
|
}), n.addEventListener("message", (r) => {
|
|
371
|
-
this.socket === n && this.handleServerEvent(
|
|
389
|
+
this.socket === n && this.handleServerEvent(hn(r.data));
|
|
372
390
|
}), n.addEventListener("close", (r) => {
|
|
373
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (
|
|
391
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (I("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
374
392
|
code: typeof r?.code == "number" ? r.code : null,
|
|
375
393
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
376
394
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -378,7 +396,7 @@ class Re {
|
|
|
378
396
|
isThinking: this.state.isThinking
|
|
379
397
|
}), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
|
|
380
398
|
}), n.addEventListener("error", () => {
|
|
381
|
-
this.socket !== n || this.state.status === "closed" || (
|
|
399
|
+
this.socket !== n || this.state.status === "closed" || (I("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
382
400
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
383
401
|
isThinking: this.state.isThinking
|
|
384
402
|
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
@@ -401,12 +419,12 @@ class Re {
|
|
|
401
419
|
this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
|
|
402
420
|
}
|
|
403
421
|
destroy() {
|
|
404
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
422
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), ir(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
405
423
|
for (const t of Object.values(this.listeners))
|
|
406
424
|
t?.clear();
|
|
407
425
|
}
|
|
408
426
|
sendMessage(t, s = {}) {
|
|
409
|
-
const n = t.trim(), r = s.attachments ?? [], i = r.map(
|
|
427
|
+
const n = t.trim(), r = s.attachments ?? [], i = r.map(Gt);
|
|
410
428
|
if (!n && i.length === 0)
|
|
411
429
|
return null;
|
|
412
430
|
const o = R(), a = s.clientMessageId ?? Q();
|
|
@@ -417,9 +435,9 @@ class Re {
|
|
|
417
435
|
content: n,
|
|
418
436
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
419
437
|
...r.length > 0 ? { attachments: r } : {}
|
|
420
|
-
},
|
|
438
|
+
}, c = this.state.messages.some((f) => f.id === u.id || f.clientMessageId === a);
|
|
421
439
|
this.setState({
|
|
422
|
-
messages:
|
|
440
|
+
messages: c ? this.state.messages : [...this.state.messages, u],
|
|
423
441
|
...this.state.isThinking ? {} : {
|
|
424
442
|
assistantDraft: "",
|
|
425
443
|
assistantDraftItemId: null,
|
|
@@ -429,20 +447,20 @@ class Re {
|
|
|
429
447
|
},
|
|
430
448
|
isThinking: !0,
|
|
431
449
|
lastError: null
|
|
432
|
-
}),
|
|
433
|
-
const
|
|
450
|
+
}), c || this.emit("message", u);
|
|
451
|
+
const l = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, h = {
|
|
434
452
|
type: "chat.user_message",
|
|
435
453
|
sessionId: this.state.sessionId ?? void 0,
|
|
436
454
|
clientMessageId: a,
|
|
437
455
|
initiatedBy: s.initiatedBy,
|
|
438
456
|
content: n,
|
|
439
|
-
pageContent:
|
|
457
|
+
pageContent: l && Wt() || void 0,
|
|
440
458
|
attachments: i.length > 0 ? i : void 0,
|
|
441
459
|
page: o,
|
|
442
460
|
model: this.options.model,
|
|
443
|
-
metadata:
|
|
461
|
+
metadata: ce(this.options.metadata)
|
|
444
462
|
};
|
|
445
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent =
|
|
463
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = h, this.markThinkingProgress(), this.send(h), this.startBackgroundAttachmentUploads(a, i), a;
|
|
446
464
|
}
|
|
447
465
|
retryLastMessage() {
|
|
448
466
|
const t = this.state.sessionId, s = this.retryableClientMessageId;
|
|
@@ -452,12 +470,12 @@ class Re {
|
|
|
452
470
|
const s = Q(), n = {
|
|
453
471
|
id: s,
|
|
454
472
|
name: t.name || "attachment",
|
|
455
|
-
mimeType:
|
|
473
|
+
mimeType: Ie(t),
|
|
456
474
|
sizeBytes: t.size
|
|
457
475
|
};
|
|
458
476
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
459
477
|
const r = Date.now();
|
|
460
|
-
return
|
|
478
|
+
return Se({
|
|
461
479
|
attachmentId: s,
|
|
462
480
|
name: n.name,
|
|
463
481
|
mimeType: n.mimeType,
|
|
@@ -468,7 +486,7 @@ class Re {
|
|
|
468
486
|
createdAt: r,
|
|
469
487
|
lastUsedAt: r
|
|
470
488
|
}).catch((i) => {
|
|
471
|
-
|
|
489
|
+
I("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
472
490
|
attachmentId: s,
|
|
473
491
|
name: n.name,
|
|
474
492
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -497,7 +515,7 @@ class Re {
|
|
|
497
515
|
waitForSession: !0,
|
|
498
516
|
notifyCompletion: !0
|
|
499
517
|
}).catch((i) => {
|
|
500
|
-
|
|
518
|
+
I("web-sdk.agent", "Attachment background upload failed", {
|
|
501
519
|
attachmentId: n.id,
|
|
502
520
|
name: n.name,
|
|
503
521
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -512,7 +530,7 @@ class Re {
|
|
|
512
530
|
waitForSession: r,
|
|
513
531
|
notifyCompletion: i
|
|
514
532
|
}) {
|
|
515
|
-
const o = r ? await this.waitForSessionId() : this.state.sessionId, a =
|
|
533
|
+
const o = r ? await this.waitForSessionId() : this.state.sessionId, a = Ie(t), u = {
|
|
516
534
|
sessionId: o ?? void 0,
|
|
517
535
|
attachmentId: s.id,
|
|
518
536
|
clientId: this.options.clientId,
|
|
@@ -522,45 +540,45 @@ class Re {
|
|
|
522
540
|
sizeBytes: t.size,
|
|
523
541
|
page: R(),
|
|
524
542
|
model: this.options.model,
|
|
525
|
-
metadata:
|
|
526
|
-
},
|
|
543
|
+
metadata: ce(this.options.metadata)
|
|
544
|
+
}, c = this.options.prepareAttachmentUpload ? await _t(
|
|
527
545
|
() => this.options.prepareAttachmentUpload(u),
|
|
528
546
|
"Failed to prepare attachment upload"
|
|
529
547
|
) : await this.prepareEmbedAttachmentUpload(u);
|
|
530
|
-
await
|
|
531
|
-
const
|
|
532
|
-
method:
|
|
533
|
-
headers:
|
|
548
|
+
await _t(async () => {
|
|
549
|
+
const h = await fetch(c.uploadUrl, {
|
|
550
|
+
method: c.uploadMethod,
|
|
551
|
+
headers: c.uploadHeaders,
|
|
534
552
|
body: t
|
|
535
553
|
});
|
|
536
|
-
if (!
|
|
537
|
-
throw new st("Failed to upload attachment",
|
|
538
|
-
return
|
|
539
|
-
}, "Failed to upload attachment"), this.setState({ sessionId:
|
|
540
|
-
const
|
|
541
|
-
return this.updateAttachmentInState(s.id,
|
|
542
|
-
sessionId:
|
|
543
|
-
fileUrl:
|
|
544
|
-
gcsPath:
|
|
554
|
+
if (!h.ok)
|
|
555
|
+
throw new st("Failed to upload attachment", h.status);
|
|
556
|
+
return h;
|
|
557
|
+
}, "Failed to upload attachment"), this.setState({ sessionId: c.sessionId });
|
|
558
|
+
const l = qe(c.attachment, this.options.backendUrl);
|
|
559
|
+
return this.updateAttachmentInState(s.id, l), s.id && Ee(s.id, {
|
|
560
|
+
sessionId: c.sessionId,
|
|
561
|
+
fileUrl: l.fileUrl,
|
|
562
|
+
gcsPath: l.gcsPath,
|
|
545
563
|
lastUsedAt: Date.now()
|
|
546
|
-
}).catch((
|
|
547
|
-
|
|
564
|
+
}).catch((h) => {
|
|
565
|
+
I("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
548
566
|
attachmentId: s.id,
|
|
549
|
-
name:
|
|
550
|
-
message:
|
|
567
|
+
name: l.name,
|
|
568
|
+
message: h instanceof Error ? h.message : String(h)
|
|
551
569
|
});
|
|
552
|
-
}), i &&
|
|
570
|
+
}), i && l.gcsPath && this.send({
|
|
553
571
|
type: "attachment.upload_completed",
|
|
554
|
-
sessionId:
|
|
572
|
+
sessionId: c.sessionId,
|
|
555
573
|
clientMessageId: n,
|
|
556
|
-
attachment:
|
|
557
|
-
}),
|
|
574
|
+
attachment: l
|
|
575
|
+
}), l;
|
|
558
576
|
}
|
|
559
577
|
waitForSessionId() {
|
|
560
578
|
return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
|
|
561
579
|
const n = window.setTimeout(() => {
|
|
562
580
|
r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
|
|
563
|
-
},
|
|
581
|
+
}, Rs), r = this.on("state", (i) => {
|
|
564
582
|
i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
|
|
565
583
|
});
|
|
566
584
|
});
|
|
@@ -578,11 +596,11 @@ class Re {
|
|
|
578
596
|
}
|
|
579
597
|
async prepareEmbedAttachmentUpload(t) {
|
|
580
598
|
let s = !1;
|
|
581
|
-
return await
|
|
599
|
+
return await _t(async () => {
|
|
582
600
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
583
601
|
if (n.ok)
|
|
584
602
|
return await n.json();
|
|
585
|
-
if (
|
|
603
|
+
if (Er(n.status) && this.options.tokenProvider && !s) {
|
|
586
604
|
s = !0;
|
|
587
605
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
588
606
|
if (r.ok)
|
|
@@ -629,7 +647,7 @@ class Re {
|
|
|
629
647
|
const s = Q(), n = new Promise((i, o) => {
|
|
630
648
|
const a = window.setTimeout(() => {
|
|
631
649
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
632
|
-
},
|
|
650
|
+
}, bs);
|
|
633
651
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
634
652
|
}), r = {
|
|
635
653
|
type: "sessions.list",
|
|
@@ -677,7 +695,7 @@ class Re {
|
|
|
677
695
|
try {
|
|
678
696
|
return s.send(JSON.stringify(t)), !0;
|
|
679
697
|
} catch (n) {
|
|
680
|
-
return
|
|
698
|
+
return I("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
681
699
|
message: n instanceof Error ? n.message : String(n),
|
|
682
700
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
683
701
|
isThinking: this.state.isThinking
|
|
@@ -688,7 +706,7 @@ class Re {
|
|
|
688
706
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
689
707
|
return;
|
|
690
708
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
691
|
-
const t =
|
|
709
|
+
const t = sn();
|
|
692
710
|
this.sendNow(
|
|
693
711
|
_({
|
|
694
712
|
type: "starter_prompts.page_context",
|
|
@@ -699,13 +717,13 @@ class Re {
|
|
|
699
717
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
700
718
|
}
|
|
701
719
|
startStarterPromptUrlWatcher() {
|
|
702
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
720
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = nn(() => this.handleStarterPromptUrlChange()));
|
|
703
721
|
}
|
|
704
722
|
handleStarterPromptUrlChange() {
|
|
705
723
|
const t = location.href;
|
|
706
724
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
707
725
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
708
|
-
},
|
|
726
|
+
}, Ds));
|
|
709
727
|
}
|
|
710
728
|
refreshStarterPromptsForCurrentUrl() {
|
|
711
729
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -739,19 +757,19 @@ class Re {
|
|
|
739
757
|
this.clearHeartbeatAckTimer();
|
|
740
758
|
return;
|
|
741
759
|
}
|
|
742
|
-
if (
|
|
760
|
+
if (xs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
743
761
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
|
|
744
|
-
const s =
|
|
745
|
-
|
|
762
|
+
const s = fn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
763
|
+
I("web-sdk.agent", "Received auth.ok appearance", {
|
|
746
764
|
hasAppearance: n,
|
|
747
765
|
rawAppearance: t.appearance,
|
|
748
766
|
normalizedAppearance: s
|
|
749
|
-
}), this.runtimeHelperJavascript =
|
|
750
|
-
const r =
|
|
751
|
-
user:
|
|
767
|
+
}), this.runtimeHelperJavascript = gn(t.runtimeHelpers)?.javascript ?? null;
|
|
768
|
+
const r = de(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
769
|
+
user: In(t.user),
|
|
752
770
|
status: "connected"
|
|
753
771
|
};
|
|
754
|
-
(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 && !
|
|
772
|
+
(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 && !on() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
755
773
|
type: "page.upsert",
|
|
756
774
|
sessionId: this.state.sessionId,
|
|
757
775
|
page: R(),
|
|
@@ -761,67 +779,78 @@ class Re {
|
|
|
761
779
|
}
|
|
762
780
|
if (t.type === "starterPrompts.updated") {
|
|
763
781
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
764
|
-
starterPrompts:
|
|
782
|
+
starterPrompts: de(t, "starterPrompts"),
|
|
765
783
|
starterPromptsLoading: !1
|
|
766
784
|
});
|
|
767
785
|
return;
|
|
768
786
|
}
|
|
769
787
|
if (t.type === "conversation.state") {
|
|
770
|
-
const s = Array.isArray(t.items) ? t.items : []
|
|
788
|
+
const s = Array.isArray(t.items) ? t.items : [], n = _n(
|
|
789
|
+
t.assistantDraft
|
|
790
|
+
), r = n !== void 0;
|
|
771
791
|
this.rememberUserMessageClientMessageIds(s);
|
|
772
|
-
const
|
|
773
|
-
if (
|
|
774
|
-
const
|
|
775
|
-
this.retryAttemptsByClientMessageId[
|
|
776
|
-
this.retryAttemptsByClientMessageId[
|
|
777
|
-
|
|
792
|
+
const i = Fn(s);
|
|
793
|
+
if (i) {
|
|
794
|
+
const d = Wn(s, i);
|
|
795
|
+
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
796
|
+
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
797
|
+
d
|
|
778
798
|
);
|
|
779
799
|
}
|
|
780
|
-
const
|
|
781
|
-
const
|
|
782
|
-
return !
|
|
783
|
-
}),
|
|
800
|
+
const o = s.filter((d) => {
|
|
801
|
+
const g = x(d);
|
|
802
|
+
return !ge(g) && (!i || !Dt(g));
|
|
803
|
+
}), a = Nn(
|
|
784
804
|
this.state.messages,
|
|
785
|
-
|
|
786
|
-
),
|
|
787
|
-
(
|
|
788
|
-
x(
|
|
805
|
+
wn(o, this.options.backendUrl)
|
|
806
|
+
), u = fe(a), c = !r && s.some(
|
|
807
|
+
(d) => ye(
|
|
808
|
+
x(d),
|
|
789
809
|
this.state.assistantDraft,
|
|
790
810
|
this.state.assistantDraftItemId,
|
|
791
811
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
792
812
|
this.state.assistantDraftRunId
|
|
793
813
|
)
|
|
794
|
-
),
|
|
795
|
-
if (!
|
|
814
|
+
), l = r ? n?.content ?? "" : this.state.assistantDraft, h = !!n?.content, f = u && (!l || c);
|
|
815
|
+
if (!u && Hn(this.state.messages, s))
|
|
796
816
|
return;
|
|
797
|
-
this.lastUserMessagePageUrl =
|
|
798
|
-
const
|
|
799
|
-
if (this.latestRecoverableClientMessageId =
|
|
817
|
+
this.lastUserMessagePageUrl = qn(s);
|
|
818
|
+
const p = f ? null : Nt(s);
|
|
819
|
+
if (this.latestRecoverableClientMessageId = p, xn(a) && this.clearRetryTimers(), this.setState({
|
|
800
820
|
sessionId: E(t.session, "id") ?? this.state.sessionId,
|
|
801
|
-
messages:
|
|
802
|
-
...
|
|
821
|
+
messages: a,
|
|
822
|
+
...r ? {
|
|
823
|
+
assistantDraft: n?.content ?? "",
|
|
824
|
+
assistantDraftItemId: n?.itemId ?? null,
|
|
825
|
+
assistantDraftPhase: n?.phase ?? null,
|
|
826
|
+
assistantDraftRespondsToUserMessageId: n?.respondsToUserMessageId ?? null,
|
|
827
|
+
assistantDraftRunId: n?.runId ?? null
|
|
828
|
+
} : c ? {
|
|
803
829
|
assistantDraft: "",
|
|
804
830
|
assistantDraftItemId: null,
|
|
805
831
|
assistantDraftPhase: null,
|
|
806
832
|
assistantDraftRespondsToUserMessageId: null,
|
|
807
833
|
assistantDraftRunId: null
|
|
808
834
|
} : {},
|
|
809
|
-
...
|
|
835
|
+
...h ? {
|
|
836
|
+
isThinking: !0,
|
|
837
|
+
lastError: null
|
|
838
|
+
} : f ? {
|
|
810
839
|
isThinking: !1
|
|
811
|
-
} :
|
|
840
|
+
} : p ? {
|
|
812
841
|
isThinking: !0,
|
|
813
842
|
lastError: null
|
|
814
843
|
} : {}
|
|
815
|
-
}),
|
|
816
|
-
const
|
|
817
|
-
|
|
844
|
+
}), f ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (h || p) && (p && (this.activeClientMessageId = p), this.markThinkingProgress()), i) {
|
|
845
|
+
const d = E(t.session, "id") ?? this.state.sessionId;
|
|
846
|
+
d && this.retryAfterInterruptedRun(d, i);
|
|
818
847
|
}
|
|
819
848
|
return;
|
|
820
849
|
}
|
|
821
850
|
if (t.type === "sessions.page") {
|
|
822
851
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
823
852
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
824
|
-
sessions:
|
|
853
|
+
sessions: An(t.sessions),
|
|
825
854
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
826
855
|
}));
|
|
827
856
|
return;
|
|
@@ -833,7 +862,7 @@ class Re {
|
|
|
833
862
|
if (t.type === "session.item") {
|
|
834
863
|
this.rememberUserMessageClientMessageIds([t.item]);
|
|
835
864
|
const s = x(t.item);
|
|
836
|
-
if (
|
|
865
|
+
if (Dt(s)) {
|
|
837
866
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
838
867
|
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);
|
|
839
868
|
if (r && a) {
|
|
@@ -845,14 +874,14 @@ class Re {
|
|
|
845
874
|
return;
|
|
846
875
|
}
|
|
847
876
|
}
|
|
848
|
-
if (
|
|
877
|
+
if (ge(s))
|
|
849
878
|
return;
|
|
850
|
-
const n =
|
|
879
|
+
const n = De(t.item, this.options.backendUrl);
|
|
851
880
|
if (n) {
|
|
852
881
|
j(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
853
882
|
const r = t.item.data;
|
|
854
|
-
|
|
855
|
-
const i =
|
|
883
|
+
jn(r) && this.clearRunAckResyncRetryTimer();
|
|
884
|
+
const i = Ne(this.state.messages, n), o = fe(i), a = ye(
|
|
856
885
|
r,
|
|
857
886
|
this.state.assistantDraft,
|
|
858
887
|
this.state.assistantDraftItemId,
|
|
@@ -904,9 +933,9 @@ class Re {
|
|
|
904
933
|
}
|
|
905
934
|
if (t.type === "tool.call") {
|
|
906
935
|
this.clearRunAckResyncRetryTimer();
|
|
907
|
-
const s =
|
|
936
|
+
const s = Un(t);
|
|
908
937
|
if (s) {
|
|
909
|
-
const n =
|
|
938
|
+
const n = Cn(
|
|
910
939
|
this.state.messages,
|
|
911
940
|
s
|
|
912
941
|
);
|
|
@@ -935,7 +964,7 @@ class Re {
|
|
|
935
964
|
return;
|
|
936
965
|
}
|
|
937
966
|
o && r && i && (this.retryableClientMessageId = i);
|
|
938
|
-
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u =
|
|
967
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = tn(a.message);
|
|
939
968
|
u && console.error(u), this.setState({
|
|
940
969
|
status: "error",
|
|
941
970
|
isThinking: !1,
|
|
@@ -1010,7 +1039,7 @@ class Re {
|
|
|
1010
1039
|
this.pendingSessionHistoryRequests.clear();
|
|
1011
1040
|
}
|
|
1012
1041
|
markThinkingProgress() {
|
|
1013
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1042
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(oe), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1014
1043
|
}
|
|
1015
1044
|
scheduleThinkingWatchdog(t) {
|
|
1016
1045
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1030,10 +1059,10 @@ class Re {
|
|
|
1030
1059
|
scheduleRunAckWatchdog(t) {
|
|
1031
1060
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1032
1061
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1033
|
-
},
|
|
1062
|
+
}, As);
|
|
1034
1063
|
}
|
|
1035
1064
|
recoverMissedRunAck(t) {
|
|
1036
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (
|
|
1065
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (I("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
1037
1066
|
sessionId: this.state.sessionId,
|
|
1038
1067
|
clientMessageId: t
|
|
1039
1068
|
}), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
|
|
@@ -1046,7 +1075,7 @@ class Re {
|
|
|
1046
1075
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1047
1076
|
isThinking: !0,
|
|
1048
1077
|
lastError: null
|
|
1049
|
-
}),
|
|
1078
|
+
}), I("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
1050
1079
|
sessionId: this.state.sessionId,
|
|
1051
1080
|
clientMessageId: t
|
|
1052
1081
|
}), this.state.sessionId ? this.send({
|
|
@@ -1054,8 +1083,8 @@ class Re {
|
|
|
1054
1083
|
sessionId: this.state.sessionId,
|
|
1055
1084
|
clientMessageId: t,
|
|
1056
1085
|
automatic: !0
|
|
1057
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1058
|
-
}, V(s,
|
|
1086
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(oe)));
|
|
1087
|
+
}, V(s, Ss)));
|
|
1059
1088
|
}
|
|
1060
1089
|
clearRunAckResyncRetryTimer() {
|
|
1061
1090
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1068,7 +1097,7 @@ class Re {
|
|
|
1068
1097
|
return;
|
|
1069
1098
|
const t = this.activeClientMessageId;
|
|
1070
1099
|
if (!t) {
|
|
1071
|
-
|
|
1100
|
+
I("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
1072
1101
|
sessionId: this.state.sessionId
|
|
1073
1102
|
}), this.setState({
|
|
1074
1103
|
isThinking: !1,
|
|
@@ -1079,7 +1108,7 @@ class Re {
|
|
|
1079
1108
|
}
|
|
1080
1109
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1081
1110
|
if (n >= K) {
|
|
1082
|
-
|
|
1111
|
+
I("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1083
1112
|
sessionId: this.state.sessionId,
|
|
1084
1113
|
clientMessageId: t
|
|
1085
1114
|
}), this.retryableClientMessageId = t, this.setState({
|
|
@@ -1090,18 +1119,18 @@ class Re {
|
|
|
1090
1119
|
return;
|
|
1091
1120
|
}
|
|
1092
1121
|
if (s < 1) {
|
|
1093
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1,
|
|
1122
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, I("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
1094
1123
|
sessionId: this.state.sessionId,
|
|
1095
1124
|
clientMessageId: t,
|
|
1096
1125
|
resyncAttempts: s + 1
|
|
1097
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1126
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(ws);
|
|
1098
1127
|
return;
|
|
1099
1128
|
}
|
|
1100
1129
|
this.setState({
|
|
1101
1130
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1102
1131
|
isThinking: !0,
|
|
1103
1132
|
lastError: null
|
|
1104
|
-
}),
|
|
1133
|
+
}), I("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
1105
1134
|
sessionId: this.state.sessionId,
|
|
1106
1135
|
clientMessageId: t,
|
|
1107
1136
|
retryAttempts: n + 1
|
|
@@ -1129,7 +1158,7 @@ class Re {
|
|
|
1129
1158
|
if (!s || !n || !r)
|
|
1130
1159
|
return;
|
|
1131
1160
|
const a = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1132
|
-
if (r !== "execute_code" && !a || !
|
|
1161
|
+
if (r !== "execute_code" && !a || !dr(o)) {
|
|
1133
1162
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1134
1163
|
type: "tool.result",
|
|
1135
1164
|
sessionId: s,
|
|
@@ -1145,7 +1174,7 @@ class Re {
|
|
|
1145
1174
|
});
|
|
1146
1175
|
return;
|
|
1147
1176
|
}
|
|
1148
|
-
const u =
|
|
1177
|
+
const u = Hs(this.state.messages);
|
|
1149
1178
|
this.activeBrowserToolCalls.set(n, {
|
|
1150
1179
|
event: {
|
|
1151
1180
|
type: "tool.result",
|
|
@@ -1160,11 +1189,11 @@ class Re {
|
|
|
1160
1189
|
startedAtUrl: location.href,
|
|
1161
1190
|
startedAtOrigin: location.origin
|
|
1162
1191
|
}), this.installSessionUserFilesApi(u);
|
|
1163
|
-
let
|
|
1164
|
-
|
|
1192
|
+
let c = null, l;
|
|
1193
|
+
c = await this.executeRuntimeHelper(), l = await le(o).catch((h) => ({
|
|
1165
1194
|
ok: !1,
|
|
1166
1195
|
exception: {
|
|
1167
|
-
message:
|
|
1196
|
+
message: h instanceof Error ? h.message : String(h)
|
|
1168
1197
|
}
|
|
1169
1198
|
})), this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
1170
1199
|
type: "tool.result",
|
|
@@ -1173,11 +1202,11 @@ class Re {
|
|
|
1173
1202
|
toolName: r,
|
|
1174
1203
|
summary: o.summary,
|
|
1175
1204
|
rawInput: _(o),
|
|
1176
|
-
rawOutput: _(
|
|
1177
|
-
}),
|
|
1205
|
+
rawOutput: _(mn(l, c))
|
|
1206
|
+
}), tr(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1178
1207
|
}
|
|
1179
1208
|
setToolMessageLoading(t, s) {
|
|
1180
|
-
const n =
|
|
1209
|
+
const n = Pn(
|
|
1181
1210
|
this.state.messages,
|
|
1182
1211
|
t,
|
|
1183
1212
|
s
|
|
@@ -1188,33 +1217,33 @@ class Re {
|
|
|
1188
1217
|
if (this.pageLifecycleCleanup)
|
|
1189
1218
|
return;
|
|
1190
1219
|
const t = () => {
|
|
1191
|
-
|
|
1220
|
+
xe(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1192
1221
|
};
|
|
1193
1222
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1194
1223
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1195
1224
|
};
|
|
1196
1225
|
}
|
|
1197
1226
|
installSessionUserFilesApi(t) {
|
|
1198
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1227
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Fs(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1199
1228
|
}
|
|
1200
1229
|
cleanupSessionUserFilesApi() {
|
|
1201
|
-
this.sessionUserFilesApiCleanup && (
|
|
1230
|
+
this.sessionUserFilesApiCleanup && (Vs(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1202
1231
|
}
|
|
1203
1232
|
async executeRuntimeHelper() {
|
|
1204
1233
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1205
1234
|
return null;
|
|
1206
|
-
const t = await
|
|
1235
|
+
const t = await le({
|
|
1207
1236
|
javascript: this.runtimeHelperJavascript
|
|
1208
1237
|
});
|
|
1209
|
-
return t.ok === !1 ?
|
|
1238
|
+
return t.ok === !1 ? yn(t) : null;
|
|
1210
1239
|
}
|
|
1211
1240
|
enableNetworkCapture() {
|
|
1212
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1213
|
-
|
|
1241
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = vs((t) => {
|
|
1242
|
+
yr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1214
1243
|
}));
|
|
1215
1244
|
}
|
|
1216
1245
|
enqueueNetworkEvent(t) {
|
|
1217
|
-
this.queuedNetworkEvents.length >=
|
|
1246
|
+
this.queuedNetworkEvents.length >= ks || (this.queuedNetworkEvents.push(mr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1218
1247
|
this.networkBatchTimer = null;
|
|
1219
1248
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1220
1249
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1223,15 +1252,15 @@ class Re {
|
|
|
1223
1252
|
page: R(),
|
|
1224
1253
|
events: s
|
|
1225
1254
|
});
|
|
1226
|
-
},
|
|
1255
|
+
}, Es)));
|
|
1227
1256
|
}
|
|
1228
1257
|
scheduleReconnect() {
|
|
1229
1258
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1230
1259
|
return;
|
|
1231
|
-
const t =
|
|
1260
|
+
const t = Ns(this.reconnectAttempts);
|
|
1232
1261
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1233
1262
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1234
|
-
|
|
1263
|
+
I("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
1235
1264
|
message: s instanceof Error ? s.message : String(s),
|
|
1236
1265
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1237
1266
|
isThinking: this.state.isThinking
|
|
@@ -1243,9 +1272,9 @@ class Re {
|
|
|
1243
1272
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
1244
1273
|
const t = this.socket;
|
|
1245
1274
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1246
|
-
this.socket === t && (
|
|
1247
|
-
},
|
|
1248
|
-
},
|
|
1275
|
+
this.socket === t && (I("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1276
|
+
}, gs));
|
|
1277
|
+
}, fs);
|
|
1249
1278
|
}
|
|
1250
1279
|
stopHeartbeat() {
|
|
1251
1280
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1271,50 +1300,50 @@ class Re {
|
|
|
1271
1300
|
...t,
|
|
1272
1301
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1273
1302
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1274
|
-
},
|
|
1303
|
+
}, Zn(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
1275
1304
|
}
|
|
1276
1305
|
emit(t, s) {
|
|
1277
1306
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1278
1307
|
}
|
|
1279
1308
|
}
|
|
1280
|
-
const
|
|
1281
|
-
function
|
|
1282
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1309
|
+
const kt = /* @__PURE__ */ new WeakMap();
|
|
1310
|
+
function vs(e) {
|
|
1311
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Ls();
|
|
1283
1312
|
return t.subscribers.add(e), () => {
|
|
1284
1313
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1285
1314
|
};
|
|
1286
1315
|
}
|
|
1287
|
-
function
|
|
1288
|
-
const e = /* @__PURE__ */ new Set(), t = (
|
|
1316
|
+
function Ls() {
|
|
1317
|
+
const e = /* @__PURE__ */ new Set(), t = (f) => {
|
|
1289
1318
|
e.forEach((p) => {
|
|
1290
1319
|
try {
|
|
1291
|
-
p(
|
|
1320
|
+
p(f);
|
|
1292
1321
|
} catch {
|
|
1293
1322
|
}
|
|
1294
1323
|
});
|
|
1295
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p,
|
|
1324
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p, d) {
|
|
1296
1325
|
const g = Date.now();
|
|
1297
1326
|
let T;
|
|
1298
1327
|
try {
|
|
1299
|
-
T = s.call(this, p,
|
|
1328
|
+
T = s.call(this, p, d);
|
|
1300
1329
|
} catch (y) {
|
|
1301
1330
|
throw y;
|
|
1302
1331
|
}
|
|
1303
1332
|
try {
|
|
1304
|
-
const y = p instanceof Request ? p : null, N =
|
|
1305
|
-
if (!v(N,
|
|
1333
|
+
const y = p instanceof Request ? p : null, N = hr(p, y), w = He(d?.headers ?? y?.headers);
|
|
1334
|
+
if (!v(N, w, d?.body)) {
|
|
1306
1335
|
const q = {
|
|
1307
|
-
requestId:
|
|
1308
|
-
url: C(N,
|
|
1309
|
-
method: (
|
|
1310
|
-
requestHeaders:
|
|
1311
|
-
requestBody: we(
|
|
1336
|
+
requestId: Rt("fetch"),
|
|
1337
|
+
url: C(N, Et),
|
|
1338
|
+
method: (d?.method ?? y?.method ?? "GET").toUpperCase(),
|
|
1339
|
+
requestHeaders: w,
|
|
1340
|
+
requestBody: we(d?.body),
|
|
1312
1341
|
resourceType: "fetch",
|
|
1313
1342
|
startedAt: new Date(g).toISOString()
|
|
1314
1343
|
};
|
|
1315
1344
|
T.then(
|
|
1316
1345
|
(b) => {
|
|
1317
|
-
|
|
1346
|
+
pr(b, q, g, t).catch(() => {
|
|
1318
1347
|
t({
|
|
1319
1348
|
...q,
|
|
1320
1349
|
responseStatus: b.status,
|
|
@@ -1334,42 +1363,42 @@ function Os() {
|
|
|
1334
1363
|
} catch {
|
|
1335
1364
|
}
|
|
1336
1365
|
return T;
|
|
1337
|
-
}, a = function(p,
|
|
1338
|
-
const N = n.call(this, p,
|
|
1339
|
-
return
|
|
1340
|
-
requestId:
|
|
1366
|
+
}, a = function(p, d, g, T, y) {
|
|
1367
|
+
const N = n.call(this, p, d, g ?? !0, T ?? void 0, y ?? void 0), w = typeof d == "string" ? d : d.toString();
|
|
1368
|
+
return kt.set(this, {
|
|
1369
|
+
requestId: Rt("xhr"),
|
|
1341
1370
|
method: String(p ?? "GET").toUpperCase(),
|
|
1342
|
-
url: C(
|
|
1371
|
+
url: C(w, Et),
|
|
1343
1372
|
requestHeaders: {},
|
|
1344
1373
|
startedAtMs: Date.now(),
|
|
1345
1374
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1346
|
-
excluded: v(
|
|
1375
|
+
excluded: v(w)
|
|
1347
1376
|
}), N;
|
|
1348
|
-
}, u = function(p,
|
|
1349
|
-
const g = r.call(this, p,
|
|
1350
|
-
return T && Object.keys(T.requestHeaders).length <
|
|
1351
|
-
},
|
|
1377
|
+
}, u = function(p, d) {
|
|
1378
|
+
const g = r.call(this, p, d), T = kt.get(this);
|
|
1379
|
+
return T && Object.keys(T.requestHeaders).length < Ht && (T.requestHeaders[p] = Xt(p, d), T.excluded = T.excluded || v(T.url, T.requestHeaders)), g;
|
|
1380
|
+
}, c = function(p) {
|
|
1352
1381
|
try {
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1382
|
+
const d = kt.get(this);
|
|
1383
|
+
d && (d.excluded = d.excluded || v(d.url, d.requestHeaders, p), d.requestBody = we(p), d.excluded || this.addEventListener(
|
|
1355
1384
|
"loadend",
|
|
1356
1385
|
() => {
|
|
1357
1386
|
queueMicrotask(() => {
|
|
1358
1387
|
try {
|
|
1359
|
-
const g =
|
|
1388
|
+
const g = Ir(this.getAllResponseHeaders());
|
|
1360
1389
|
t({
|
|
1361
|
-
requestId:
|
|
1362
|
-
url:
|
|
1363
|
-
method:
|
|
1364
|
-
requestHeaders:
|
|
1365
|
-
requestBody:
|
|
1390
|
+
requestId: d.requestId,
|
|
1391
|
+
url: d.url,
|
|
1392
|
+
method: d.method,
|
|
1393
|
+
requestHeaders: d.requestHeaders,
|
|
1394
|
+
requestBody: d.requestBody,
|
|
1366
1395
|
resourceType: "xhr",
|
|
1367
1396
|
responseStatus: this.status,
|
|
1368
1397
|
responseHeaders: g,
|
|
1369
|
-
responseBody:
|
|
1398
|
+
responseBody: gr(this, g),
|
|
1370
1399
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1371
|
-
startedAt:
|
|
1372
|
-
durationMs: Date.now() -
|
|
1400
|
+
startedAt: d.startedAt,
|
|
1401
|
+
durationMs: Date.now() - d.startedAtMs
|
|
1373
1402
|
});
|
|
1374
1403
|
} catch {
|
|
1375
1404
|
return;
|
|
@@ -1395,38 +1424,38 @@ function Os() {
|
|
|
1395
1424
|
} catch {
|
|
1396
1425
|
}
|
|
1397
1426
|
try {
|
|
1398
|
-
XMLHttpRequest.prototype.send =
|
|
1427
|
+
XMLHttpRequest.prototype.send = c;
|
|
1399
1428
|
} catch {
|
|
1400
1429
|
}
|
|
1401
|
-
let
|
|
1430
|
+
let l = null;
|
|
1402
1431
|
if (typeof PerformanceObserver < "u") {
|
|
1403
|
-
|
|
1404
|
-
for (const p of
|
|
1405
|
-
const
|
|
1406
|
-
if (
|
|
1432
|
+
l = new PerformanceObserver((f) => {
|
|
1433
|
+
for (const p of f.getEntries()) {
|
|
1434
|
+
const d = p;
|
|
1435
|
+
if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || v(d.name))
|
|
1407
1436
|
continue;
|
|
1408
|
-
const g = performance.timeOrigin +
|
|
1437
|
+
const g = performance.timeOrigin + d.startTime;
|
|
1409
1438
|
t({
|
|
1410
|
-
requestId:
|
|
1411
|
-
url: C(
|
|
1439
|
+
requestId: Rt("resource"),
|
|
1440
|
+
url: C(d.name, Et),
|
|
1412
1441
|
method: "GET",
|
|
1413
1442
|
resourceType: "resource",
|
|
1414
|
-
responseStatus:
|
|
1443
|
+
responseStatus: d.responseStatus,
|
|
1415
1444
|
startedAt: new Date(g).toISOString(),
|
|
1416
|
-
durationMs:
|
|
1445
|
+
durationMs: d.duration
|
|
1417
1446
|
});
|
|
1418
1447
|
}
|
|
1419
1448
|
});
|
|
1420
1449
|
try {
|
|
1421
|
-
|
|
1450
|
+
l.observe({ type: "resource", buffered: !0 });
|
|
1422
1451
|
} catch {
|
|
1423
|
-
|
|
1452
|
+
l.disconnect(), l = null;
|
|
1424
1453
|
}
|
|
1425
1454
|
}
|
|
1426
|
-
const
|
|
1455
|
+
const h = {
|
|
1427
1456
|
subscribers: e,
|
|
1428
1457
|
destroy: () => {
|
|
1429
|
-
|
|
1458
|
+
l?.disconnect();
|
|
1430
1459
|
try {
|
|
1431
1460
|
window.fetch === o && (window.fetch = s);
|
|
1432
1461
|
} catch {
|
|
@@ -1440,14 +1469,14 @@ function Os() {
|
|
|
1440
1469
|
} catch {
|
|
1441
1470
|
}
|
|
1442
1471
|
try {
|
|
1443
|
-
XMLHttpRequest.prototype.send ===
|
|
1472
|
+
XMLHttpRequest.prototype.send === c && (XMLHttpRequest.prototype.send = i);
|
|
1444
1473
|
} catch {
|
|
1445
1474
|
}
|
|
1446
1475
|
}
|
|
1447
1476
|
};
|
|
1448
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
1477
|
+
return window.__plunoProductAgentNetworkCapture = h, h;
|
|
1449
1478
|
}
|
|
1450
|
-
function
|
|
1479
|
+
function I(e, t, s) {
|
|
1451
1480
|
if (typeof window > "u")
|
|
1452
1481
|
return;
|
|
1453
1482
|
const n = window, r = {
|
|
@@ -1458,15 +1487,15 @@ function w(e, t, s) {
|
|
|
1458
1487
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1459
1488
|
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 }));
|
|
1460
1489
|
}
|
|
1461
|
-
function
|
|
1490
|
+
function ce(e) {
|
|
1462
1491
|
const t = typeof e == "function" ? e() : e;
|
|
1463
1492
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1464
1493
|
}
|
|
1465
|
-
function
|
|
1494
|
+
function xs(e) {
|
|
1466
1495
|
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";
|
|
1467
1496
|
}
|
|
1468
|
-
const
|
|
1469
|
-
function
|
|
1497
|
+
const Bs = 5e3, qs = 12e4;
|
|
1498
|
+
function Hs(e) {
|
|
1470
1499
|
const t = [];
|
|
1471
1500
|
for (const s of e)
|
|
1472
1501
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1477,122 +1506,122 @@ function Bs(e) {
|
|
|
1477
1506
|
});
|
|
1478
1507
|
return t;
|
|
1479
1508
|
}
|
|
1480
|
-
function
|
|
1509
|
+
function Fs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1481
1510
|
const n = [
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1511
|
+
$s(e, t, s),
|
|
1512
|
+
js(),
|
|
1513
|
+
Ws()
|
|
1485
1514
|
].filter((r) => typeof r == "function");
|
|
1486
1515
|
return () => {
|
|
1487
1516
|
for (const r of n.reverse())
|
|
1488
1517
|
r();
|
|
1489
1518
|
};
|
|
1490
1519
|
}
|
|
1491
|
-
function
|
|
1492
|
-
return
|
|
1493
|
-
}
|
|
1494
|
-
function
|
|
1495
|
-
const n = new Map(e.map((
|
|
1496
|
-
id:
|
|
1497
|
-
name:
|
|
1498
|
-
mimeType:
|
|
1499
|
-
sizeBytes:
|
|
1500
|
-
type:
|
|
1501
|
-
size:
|
|
1502
|
-
}), i = (
|
|
1503
|
-
const
|
|
1504
|
-
if (!
|
|
1505
|
-
throw new Error(`Unknown Pluno user file: ${
|
|
1506
|
-
return
|
|
1507
|
-
}, o = async (
|
|
1508
|
-
const
|
|
1509
|
-
if (
|
|
1510
|
-
return
|
|
1511
|
-
const
|
|
1512
|
-
if (
|
|
1513
|
-
return
|
|
1514
|
-
const p = await
|
|
1515
|
-
attachmentId:
|
|
1516
|
-
name:
|
|
1520
|
+
function Ws() {
|
|
1521
|
+
return Bt(globalThis, "getPageSnapshot", async () => Wt());
|
|
1522
|
+
}
|
|
1523
|
+
function $s(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1524
|
+
const n = new Map(e.map((c) => [c.id, c])), r = (c) => ({
|
|
1525
|
+
id: c.id,
|
|
1526
|
+
name: c.name,
|
|
1527
|
+
mimeType: c.mimeType,
|
|
1528
|
+
sizeBytes: c.sizeBytes,
|
|
1529
|
+
type: c.mimeType,
|
|
1530
|
+
size: c.sizeBytes
|
|
1531
|
+
}), i = (c) => {
|
|
1532
|
+
const l = n.get(c);
|
|
1533
|
+
if (!l)
|
|
1534
|
+
throw new Error(`Unknown Pluno user file: ${c}`);
|
|
1535
|
+
return l;
|
|
1536
|
+
}, o = async (c) => {
|
|
1537
|
+
const l = i(c), h = t.get(l.id);
|
|
1538
|
+
if (h)
|
|
1539
|
+
return h;
|
|
1540
|
+
const f = s.get(l.id);
|
|
1541
|
+
if (f)
|
|
1542
|
+
return f;
|
|
1543
|
+
const p = await Ye(l.id).then((y) => y?.blob ?? null).catch((y) => (I("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
|
|
1544
|
+
attachmentId: l.id,
|
|
1545
|
+
name: l.name,
|
|
1517
1546
|
message: y instanceof Error ? y.message : String(y)
|
|
1518
1547
|
}), null));
|
|
1519
1548
|
if (p)
|
|
1520
|
-
return s.set(
|
|
1521
|
-
if (!
|
|
1522
|
-
throw new Error(`Pluno user file is missing content: ${
|
|
1523
|
-
const
|
|
1524
|
-
if (!
|
|
1525
|
-
throw new Error(`Failed to load Pluno user file: ${
|
|
1526
|
-
const g = await
|
|
1527
|
-
s.set(
|
|
1549
|
+
return s.set(l.id, p), p;
|
|
1550
|
+
if (!l.fileUrl)
|
|
1551
|
+
throw new Error(`Pluno user file is missing content: ${c}`);
|
|
1552
|
+
const d = await fetch(l.fileUrl, or(l.fileUrl));
|
|
1553
|
+
if (!d.ok)
|
|
1554
|
+
throw new Error(`Failed to load Pluno user file: ${c}`);
|
|
1555
|
+
const g = await d.blob();
|
|
1556
|
+
s.set(l.id, g);
|
|
1528
1557
|
const T = Date.now();
|
|
1529
|
-
return
|
|
1530
|
-
attachmentId:
|
|
1531
|
-
name:
|
|
1532
|
-
mimeType:
|
|
1533
|
-
sizeBytes:
|
|
1558
|
+
return Se({
|
|
1559
|
+
attachmentId: l.id,
|
|
1560
|
+
name: l.name,
|
|
1561
|
+
mimeType: l.mimeType,
|
|
1562
|
+
sizeBytes: l.sizeBytes,
|
|
1534
1563
|
blob: g,
|
|
1535
|
-
fileUrl:
|
|
1536
|
-
gcsPath:
|
|
1564
|
+
fileUrl: l.fileUrl,
|
|
1565
|
+
gcsPath: l.gcsPath,
|
|
1537
1566
|
createdAt: T,
|
|
1538
1567
|
lastUsedAt: T
|
|
1539
1568
|
}).catch((y) => {
|
|
1540
|
-
|
|
1541
|
-
attachmentId:
|
|
1542
|
-
name:
|
|
1569
|
+
I("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
|
|
1570
|
+
attachmentId: l.id,
|
|
1571
|
+
name: l.name,
|
|
1543
1572
|
message: y instanceof Error ? y.message : String(y)
|
|
1544
1573
|
});
|
|
1545
1574
|
}), g;
|
|
1546
1575
|
};
|
|
1547
|
-
return
|
|
1576
|
+
return Bt(globalThis, "userFiles", {
|
|
1548
1577
|
list: () => e.map(r),
|
|
1549
|
-
get: (
|
|
1550
|
-
const
|
|
1551
|
-
return
|
|
1578
|
+
get: (c) => {
|
|
1579
|
+
const l = n.get(c);
|
|
1580
|
+
return l ? r(l) : null;
|
|
1552
1581
|
},
|
|
1553
|
-
inspectImage: async (
|
|
1554
|
-
const
|
|
1555
|
-
if (!
|
|
1556
|
-
throw new Error(`Pluno user file is not an image: ${
|
|
1557
|
-
const p =
|
|
1558
|
-
return
|
|
1582
|
+
inspectImage: async (c) => {
|
|
1583
|
+
const l = i(c), h = await o(c), f = l.mimeType.startsWith("image/") ? l.mimeType : h.type || l.mimeType;
|
|
1584
|
+
if (!f.startsWith("image/"))
|
|
1585
|
+
throw new Error(`Pluno user file is not an image: ${c}`);
|
|
1586
|
+
const p = h.type === f ? h : new Blob([h], { type: f });
|
|
1587
|
+
return Ys(f, p.size) > Ps ? {
|
|
1559
1588
|
type: "pluno.userFiles.inspectImage",
|
|
1560
|
-
id:
|
|
1561
|
-
name:
|
|
1562
|
-
mimeType:
|
|
1563
|
-
sizeBytes:
|
|
1589
|
+
id: l.id,
|
|
1590
|
+
name: l.name,
|
|
1591
|
+
mimeType: f,
|
|
1592
|
+
sizeBytes: l.sizeBytes,
|
|
1564
1593
|
imageAttached: !1,
|
|
1565
|
-
imageAttachmentError:
|
|
1594
|
+
imageAttachmentError: Ft
|
|
1566
1595
|
} : {
|
|
1567
1596
|
type: "pluno.userFiles.inspectImage",
|
|
1568
|
-
id:
|
|
1569
|
-
name:
|
|
1570
|
-
mimeType:
|
|
1571
|
-
sizeBytes:
|
|
1597
|
+
id: l.id,
|
|
1598
|
+
name: l.name,
|
|
1599
|
+
mimeType: f,
|
|
1600
|
+
sizeBytes: l.sizeBytes,
|
|
1572
1601
|
imageAttached: !0,
|
|
1573
|
-
dataUrl: await
|
|
1602
|
+
dataUrl: await Ut(p)
|
|
1574
1603
|
};
|
|
1575
1604
|
},
|
|
1576
|
-
getDataUrl: async (
|
|
1605
|
+
getDataUrl: async (c) => (i(c), await Ut(await o(c))),
|
|
1577
1606
|
getBlob: o,
|
|
1578
|
-
getArrayBuffer: async (
|
|
1579
|
-
getFile: async (
|
|
1580
|
-
const
|
|
1581
|
-
return new File([await o(
|
|
1607
|
+
getArrayBuffer: async (c) => await (await o(c)).arrayBuffer(),
|
|
1608
|
+
getFile: async (c) => {
|
|
1609
|
+
const l = i(c);
|
|
1610
|
+
return new File([await o(c)], l.name, { type: l.mimeType });
|
|
1582
1611
|
}
|
|
1583
1612
|
});
|
|
1584
1613
|
}
|
|
1585
|
-
function
|
|
1586
|
-
return
|
|
1587
|
-
inspectImage: async (t, s) => await
|
|
1614
|
+
function js() {
|
|
1615
|
+
return Bt(globalThis, "pageImages", {
|
|
1616
|
+
inspectImage: async (t, s) => await zs(t, s)
|
|
1588
1617
|
});
|
|
1589
1618
|
}
|
|
1590
|
-
async function
|
|
1591
|
-
const s =
|
|
1619
|
+
async function zs(e, t = {}) {
|
|
1620
|
+
const s = Ks(t.name), n = await Gs(e);
|
|
1592
1621
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1593
1622
|
type: "pluno.pageImages.inspectImage",
|
|
1594
1623
|
imageAttached: !1,
|
|
1595
|
-
imageAttachmentError:
|
|
1624
|
+
imageAttachmentError: Ft
|
|
1596
1625
|
} : {
|
|
1597
1626
|
type: "pluno.pageImages.inspectImage",
|
|
1598
1627
|
imageAttached: !0,
|
|
@@ -1606,15 +1635,15 @@ async function $s(e, t = {}) {
|
|
|
1606
1635
|
imageAttachmentError: n.error
|
|
1607
1636
|
};
|
|
1608
1637
|
}
|
|
1609
|
-
async function
|
|
1610
|
-
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:
|
|
1638
|
+
async function Gs(e) {
|
|
1639
|
+
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: Ft } : {
|
|
1611
1640
|
ok: !0,
|
|
1612
1641
|
mimeType: e.type,
|
|
1613
1642
|
sizeBytes: e.size,
|
|
1614
|
-
dataUrl: await
|
|
1615
|
-
} : { 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." } :
|
|
1643
|
+
dataUrl: await Ut(e)
|
|
1644
|
+
} : { 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." } : Xs(e);
|
|
1616
1645
|
}
|
|
1617
|
-
function
|
|
1646
|
+
function Xs(e) {
|
|
1618
1647
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1619
1648
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1620
1649
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1625,7 +1654,7 @@ function zs(e) {
|
|
|
1625
1654
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1626
1655
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1627
1656
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1628
|
-
const o =
|
|
1657
|
+
const o = Js(i);
|
|
1629
1658
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1630
1659
|
ok: !0,
|
|
1631
1660
|
mimeType: r,
|
|
@@ -1633,22 +1662,22 @@ function zs(e) {
|
|
|
1633
1662
|
dataUrl: `data:${r};base64,${i}`
|
|
1634
1663
|
};
|
|
1635
1664
|
}
|
|
1636
|
-
function
|
|
1665
|
+
function Js(e) {
|
|
1637
1666
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1638
1667
|
return null;
|
|
1639
1668
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1640
1669
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1641
1670
|
}
|
|
1642
|
-
function
|
|
1671
|
+
function Ks(e) {
|
|
1643
1672
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1644
1673
|
}
|
|
1645
|
-
function
|
|
1674
|
+
function Vs(e) {
|
|
1646
1675
|
try {
|
|
1647
1676
|
e();
|
|
1648
1677
|
} catch {
|
|
1649
1678
|
}
|
|
1650
1679
|
}
|
|
1651
|
-
function
|
|
1680
|
+
function Ut(e) {
|
|
1652
1681
|
return new Promise((t, s) => {
|
|
1653
1682
|
const n = new FileReader();
|
|
1654
1683
|
n.onload = () => {
|
|
@@ -1660,32 +1689,32 @@ function Pt(e) {
|
|
|
1660
1689
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1661
1690
|
});
|
|
1662
1691
|
}
|
|
1663
|
-
function
|
|
1692
|
+
function Ys(e, t) {
|
|
1664
1693
|
return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
|
|
1665
1694
|
}
|
|
1666
|
-
async function
|
|
1695
|
+
async function le(e) {
|
|
1667
1696
|
const t = Object.getPrototypeOf(async function() {
|
|
1668
|
-
}).constructor, s = e.timeoutMs ??
|
|
1697
|
+
}).constructor, s = e.timeoutMs ?? Bs, n = Date.now(), r = [];
|
|
1669
1698
|
let i;
|
|
1670
1699
|
const o = {
|
|
1671
1700
|
log: console.log,
|
|
1672
1701
|
info: console.info,
|
|
1673
1702
|
warn: console.warn,
|
|
1674
1703
|
error: console.error
|
|
1675
|
-
}, a = (u) => (...
|
|
1676
|
-
r.push({ level: u, args:
|
|
1704
|
+
}, a = (u) => (...c) => {
|
|
1705
|
+
r.push({ level: u, args: c }), o[u](...c);
|
|
1677
1706
|
};
|
|
1678
1707
|
console.log = a("log"), console.info = a("info"), console.warn = a("warn"), console.error = a("error");
|
|
1679
1708
|
try {
|
|
1680
|
-
const u = /* @__PURE__ */ Symbol("execute_code_timeout"),
|
|
1709
|
+
const u = /* @__PURE__ */ Symbol("execute_code_timeout"), c = await Promise.race([
|
|
1681
1710
|
new t(e.javascript)(),
|
|
1682
|
-
new Promise((
|
|
1683
|
-
i = window.setTimeout(() =>
|
|
1711
|
+
new Promise((l) => {
|
|
1712
|
+
i = window.setTimeout(() => l(u), s);
|
|
1684
1713
|
})
|
|
1685
1714
|
]);
|
|
1686
|
-
return
|
|
1715
|
+
return c === u ? Zs(s) : {
|
|
1687
1716
|
ok: !0,
|
|
1688
|
-
result:
|
|
1717
|
+
result: c,
|
|
1689
1718
|
console: r,
|
|
1690
1719
|
metadata: {
|
|
1691
1720
|
durationMs: Date.now() - n,
|
|
@@ -1712,7 +1741,7 @@ async function ce(e) {
|
|
|
1712
1741
|
i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
|
|
1713
1742
|
}
|
|
1714
1743
|
}
|
|
1715
|
-
function
|
|
1744
|
+
function Zs(e) {
|
|
1716
1745
|
return {
|
|
1717
1746
|
ok: !1,
|
|
1718
1747
|
exception: {
|
|
@@ -1726,18 +1755,18 @@ function Vs(e) {
|
|
|
1726
1755
|
}
|
|
1727
1756
|
};
|
|
1728
1757
|
}
|
|
1729
|
-
function
|
|
1758
|
+
function Qs(e) {
|
|
1730
1759
|
return e.replace(/\/+$/, "");
|
|
1731
1760
|
}
|
|
1732
|
-
function
|
|
1761
|
+
function tn(e, t = location.origin) {
|
|
1733
1762
|
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;
|
|
1734
1763
|
}
|
|
1735
|
-
function
|
|
1764
|
+
function en(e) {
|
|
1736
1765
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1737
1766
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1738
1767
|
}
|
|
1739
1768
|
function R() {
|
|
1740
|
-
const e =
|
|
1769
|
+
const e = Ue();
|
|
1741
1770
|
return {
|
|
1742
1771
|
url: location.href,
|
|
1743
1772
|
title: document.title,
|
|
@@ -1745,19 +1774,19 @@ function R() {
|
|
|
1745
1774
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1746
1775
|
};
|
|
1747
1776
|
}
|
|
1748
|
-
function
|
|
1777
|
+
function sn() {
|
|
1749
1778
|
return {
|
|
1750
1779
|
pageUrl: location.href,
|
|
1751
1780
|
pageTitle: document.title,
|
|
1752
|
-
htmlContent:
|
|
1781
|
+
htmlContent: Wt()
|
|
1753
1782
|
};
|
|
1754
1783
|
}
|
|
1755
|
-
function
|
|
1756
|
-
return et.add(e), Y || (Y =
|
|
1784
|
+
function nn(e) {
|
|
1785
|
+
return et.add(e), Y || (Y = rn()), () => {
|
|
1757
1786
|
et.delete(e), et.size === 0 && (Y?.(), Y = null);
|
|
1758
1787
|
};
|
|
1759
1788
|
}
|
|
1760
|
-
function
|
|
1789
|
+
function rn() {
|
|
1761
1790
|
const e = () => {
|
|
1762
1791
|
for (const i of Array.from(et))
|
|
1763
1792
|
i();
|
|
@@ -1772,10 +1801,10 @@ function sn() {
|
|
|
1772
1801
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
1773
1802
|
};
|
|
1774
1803
|
}
|
|
1775
|
-
function
|
|
1776
|
-
return
|
|
1804
|
+
function on() {
|
|
1805
|
+
return Ue()?.surface === "browser_extension_sdk_preview";
|
|
1777
1806
|
}
|
|
1778
|
-
function
|
|
1807
|
+
function Wt() {
|
|
1779
1808
|
if (!document.body)
|
|
1780
1809
|
return "";
|
|
1781
1810
|
const e = [], t = [], s = (g, T) => {
|
|
@@ -1784,21 +1813,21 @@ function Ft() {
|
|
|
1784
1813
|
};
|
|
1785
1814
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
1786
1815
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
1787
|
-
(g) =>
|
|
1816
|
+
(g) => Me(g) && !g.parentElement?.closest(n)
|
|
1788
1817
|
);
|
|
1789
1818
|
for (const g of r.slice(0, 3))
|
|
1790
|
-
s("Active overlay",
|
|
1791
|
-
const i =
|
|
1792
|
-
s("Main page content", o), s("Additional visible page text",
|
|
1819
|
+
s("Active overlay", bt($(g), t));
|
|
1820
|
+
const i = an(), o = i ? bt($(i), t) : "";
|
|
1821
|
+
s("Main page content", o), s("Additional visible page text", bt($(document.body), t));
|
|
1793
1822
|
const a = e.map(([g, T]) => `${g}:
|
|
1794
1823
|
${T}`).join(`
|
|
1795
1824
|
|
|
1796
|
-
`).trim().slice(0, 12e3), u =
|
|
1797
|
-
`,
|
|
1825
|
+
`).trim().slice(0, 12e3), u = cn(r, i).trim(), c = `Simplified DOM outline:
|
|
1826
|
+
`, l = `
|
|
1798
1827
|
|
|
1799
1828
|
Visible page text:
|
|
1800
|
-
`,
|
|
1801
|
-
return `${
|
|
1829
|
+
`, h = 12e3 - c.length - l.length, f = Math.min(a.length, 7900), p = u.slice(0, h - f), d = a.slice(0, h - p.length);
|
|
1830
|
+
return `${c}${p}${l}${d}`;
|
|
1802
1831
|
}
|
|
1803
1832
|
function $(e) {
|
|
1804
1833
|
return e.innerText ?? e.textContent ?? "";
|
|
@@ -1811,20 +1840,20 @@ function B(e) {
|
|
|
1811
1840
|
|
|
1812
1841
|
`).trim();
|
|
1813
1842
|
}
|
|
1814
|
-
function
|
|
1843
|
+
function bt(e, t) {
|
|
1815
1844
|
let s = B(e);
|
|
1816
1845
|
for (const n of t)
|
|
1817
1846
|
s = s.replace(n, "");
|
|
1818
1847
|
return B(s);
|
|
1819
1848
|
}
|
|
1820
|
-
function
|
|
1849
|
+
function Me(e) {
|
|
1821
1850
|
const t = window.getComputedStyle(e);
|
|
1822
1851
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
1823
1852
|
}
|
|
1824
|
-
function
|
|
1825
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
1853
|
+
function an() {
|
|
1854
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Me).sort((e, t) => $(t).length - $(e).length)[0] ?? null;
|
|
1826
1855
|
}
|
|
1827
|
-
function
|
|
1856
|
+
function cn(e, t) {
|
|
1828
1857
|
const s = /* @__PURE__ */ new Set([
|
|
1829
1858
|
"main",
|
|
1830
1859
|
"nav",
|
|
@@ -1904,92 +1933,92 @@ function on(e, t) {
|
|
|
1904
1933
|
"data-test",
|
|
1905
1934
|
"data-qa",
|
|
1906
1935
|
"data-cy"
|
|
1907
|
-
],
|
|
1908
|
-
t &&
|
|
1936
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: l, priorityTargets: h } = ln(), f = new Set(e);
|
|
1937
|
+
t && f.add(t);
|
|
1909
1938
|
let p = 0;
|
|
1910
|
-
const
|
|
1911
|
-
const U =
|
|
1939
|
+
const d = (w) => {
|
|
1940
|
+
const U = w.getAttribute("role");
|
|
1912
1941
|
return U && !o.has(U) ? U : "";
|
|
1913
|
-
}, g = (
|
|
1914
|
-
const U =
|
|
1915
|
-
return `${
|
|
1916
|
-
}, T = (
|
|
1942
|
+
}, g = (w) => {
|
|
1943
|
+
const U = w.getAttribute("data-testid") || w.getAttribute("data-test") || w.getAttribute("data-qa") || w.getAttribute("data-cy") || "";
|
|
1944
|
+
return `${w.tagName.toLowerCase()}|${d(w)}|${U}`;
|
|
1945
|
+
}, T = (w, U, q) => {
|
|
1917
1946
|
const b = (S, ut) => {
|
|
1918
|
-
const k = S.tagName.toLowerCase(), dt = window.getComputedStyle(S), z =
|
|
1947
|
+
const k = S.tagName.toLowerCase(), dt = window.getComputedStyle(S), z = l.has(S);
|
|
1919
1948
|
if (p >= 1e3 && !z || q.has(S) || i.has(k) || S.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || dt.display === "none" || dt.visibility === "hidden")
|
|
1920
1949
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
1921
1950
|
p += 1;
|
|
1922
|
-
const
|
|
1923
|
-
for (const
|
|
1924
|
-
const A = g(
|
|
1951
|
+
const Jt = d(S), G = Pe(S), Je = a.has(Jt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(k) || k === "a" && S.hasAttribute("href"), ht = Array.from(S.children).filter((m) => m instanceof HTMLElement), X = /* @__PURE__ */ new Map();
|
|
1952
|
+
for (const m of ht) {
|
|
1953
|
+
const A = g(m);
|
|
1925
1954
|
X.set(A, (X.get(A) ?? 0) + 1);
|
|
1926
1955
|
}
|
|
1927
|
-
const pt = /* @__PURE__ */ new Map(),
|
|
1928
|
-
for (const
|
|
1929
|
-
const A = g(
|
|
1930
|
-
|
|
1956
|
+
const pt = /* @__PURE__ */ new Map(), Kt = /* @__PURE__ */ new Map();
|
|
1957
|
+
for (const m of ht) {
|
|
1958
|
+
const A = g(m), D = Kt.get(A) ?? 0;
|
|
1959
|
+
Kt.set(A, D + 1), (X.get(A) ?? 0) > 8 && D >= 6 && !l.has(m) && pt.set(A, (pt.get(A) ?? 0) + 1);
|
|
1931
1960
|
}
|
|
1932
|
-
const
|
|
1933
|
-
for (const
|
|
1934
|
-
const A = g(
|
|
1935
|
-
if (
|
|
1936
|
-
|
|
1961
|
+
const Vt = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Set(), ft = [], Zt = [];
|
|
1962
|
+
for (const m of ht) {
|
|
1963
|
+
const A = g(m), D = X.get(A) ?? 0, ee = Vt.get(A) ?? 0;
|
|
1964
|
+
if (Vt.set(A, ee + 1), D > 8 && ee >= 6 && !l.has(m)) {
|
|
1965
|
+
Yt.has(A) || (ft.push([`… ${pt.get(A) ?? 0} similar siblings omitted`]), Yt.add(A));
|
|
1937
1966
|
continue;
|
|
1938
1967
|
}
|
|
1939
|
-
const
|
|
1940
|
-
|
|
1968
|
+
const se = b(m, ut);
|
|
1969
|
+
Zt.push(se), ft.push(se.lines);
|
|
1941
1970
|
}
|
|
1942
1971
|
const gt = [];
|
|
1943
1972
|
if (S.shadowRoot)
|
|
1944
|
-
for (const
|
|
1945
|
-
|
|
1946
|
-
const J = [...
|
|
1947
|
-
[G, ...J.map((
|
|
1948
|
-
).slice(0, 180),
|
|
1973
|
+
for (const m of Array.from(S.shadowRoot.children))
|
|
1974
|
+
m instanceof HTMLElement && gt.push(b(m, ut + 1));
|
|
1975
|
+
const J = [...Zt, ...gt], mt = G.length > 0 || Je || J.some((m) => m.hasUsefulContent), Qt = B(
|
|
1976
|
+
[G, ...J.map((m) => m.textPreview)].filter(Boolean).join(" ")
|
|
1977
|
+
).slice(0, 180), Ke = S.hasAttribute("contenteditable") && (G.length > 0 || !S.querySelector("[contenteditable]")), te = c.some((m) => S.hasAttribute(m)) || !!Jt || Ke, yt = (S.getClientRects().length > 0 || dt.display === "contents") && (s.has(k) || te || z) && (mt || z) && (!r.has(k) || mt || te || z), Tt = yt ? 1 : 0, H = [];
|
|
1949
1978
|
if (yt) {
|
|
1950
|
-
const
|
|
1951
|
-
H.push(
|
|
1979
|
+
const m = J.some((D) => D.containsTextElement), A = n.has(k) && !m ? Qt : G;
|
|
1980
|
+
H.push(Ce(S, u, o, A.slice(0, 180)));
|
|
1952
1981
|
}
|
|
1953
|
-
for (const
|
|
1954
|
-
H.push(...Z(
|
|
1955
|
-
const
|
|
1956
|
-
if (
|
|
1957
|
-
const
|
|
1958
|
-
|
|
1982
|
+
for (const m of ft)
|
|
1983
|
+
H.push(...Z(m, Tt));
|
|
1984
|
+
const It = gt.flatMap((m) => m.lines);
|
|
1985
|
+
if (It.length > 0) {
|
|
1986
|
+
const m = It.slice(0, 20);
|
|
1987
|
+
It.length > m.length && m.push("… shadow DOM omitted");
|
|
1959
1988
|
const A = k.includes("tooltip") || k.includes("popper") || k.includes("loader");
|
|
1960
1989
|
if (ut < 2 && !A) {
|
|
1961
1990
|
const D = yt ? "#shadow-root" : `${k} #shadow-root`;
|
|
1962
|
-
H.push(...Z([D, ...Z(
|
|
1991
|
+
H.push(...Z([D, ...Z(m, 1)], Tt));
|
|
1963
1992
|
} else
|
|
1964
|
-
H.push(...Z(
|
|
1993
|
+
H.push(...Z(m, Tt));
|
|
1965
1994
|
}
|
|
1966
1995
|
return {
|
|
1967
1996
|
lines: H,
|
|
1968
1997
|
hasUsefulContent: mt,
|
|
1969
|
-
textPreview:
|
|
1970
|
-
containsTextElement: n.has(k) || J.some((
|
|
1998
|
+
textPreview: Qt,
|
|
1999
|
+
containsTextElement: n.has(k) || J.some((m) => m.containsTextElement)
|
|
1971
2000
|
};
|
|
1972
2001
|
};
|
|
1973
|
-
return [`--- ${U} ---`, ...b(
|
|
2002
|
+
return [`--- ${U} ---`, ...b(w, 0).lines].join(`
|
|
1974
2003
|
`);
|
|
1975
2004
|
}, y = [], N = B(window.getSelection()?.toString() ?? "");
|
|
1976
2005
|
N && y.push(`--- selected text ---
|
|
1977
|
-
${JSON.stringify(N)}`),
|
|
1978
|
-
for (const
|
|
1979
|
-
y.push(T(
|
|
2006
|
+
${JSON.stringify(N)}`), h.length > 0 && y.push(un(h, s, u, o));
|
|
2007
|
+
for (const w of e.slice(0, 3))
|
|
2008
|
+
y.push(T(w, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
1980
2009
|
if (t && y.push(T(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
1981
|
-
const
|
|
1982
|
-
y.push(T(document.body,
|
|
2010
|
+
const w = t || e.length ? "other visible DOM" : "visible DOM";
|
|
2011
|
+
y.push(T(document.body, w, f));
|
|
1983
2012
|
}
|
|
1984
2013
|
return y.join(`
|
|
1985
2014
|
|
|
1986
2015
|
`);
|
|
1987
2016
|
}
|
|
1988
|
-
function
|
|
2017
|
+
function Ce(e, t, s, n) {
|
|
1989
2018
|
const r = e.tagName.toLowerCase();
|
|
1990
2019
|
let i = r;
|
|
1991
2020
|
const o = e.getAttribute("id");
|
|
1992
|
-
o &&
|
|
2021
|
+
o && dn(o) && (i += `#${o}`);
|
|
1993
2022
|
for (const a of t) {
|
|
1994
2023
|
const u = e.getAttribute(a);
|
|
1995
2024
|
u && u.length <= 160 && (a !== "role" || !s.has(u)) && (i += `[${a}=${JSON.stringify(u)}]`);
|
|
@@ -2002,20 +2031,20 @@ function Me(e, t, s, n) {
|
|
|
2002
2031
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2003
2032
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2004
2033
|
}
|
|
2005
|
-
function
|
|
2034
|
+
function ln() {
|
|
2006
2035
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, u) => {
|
|
2007
2036
|
if (!a)
|
|
2008
2037
|
return;
|
|
2009
|
-
const
|
|
2010
|
-
if (
|
|
2038
|
+
const c = window.getComputedStyle(a);
|
|
2039
|
+
if (c.display === "none" || c.visibility === "hidden")
|
|
2011
2040
|
return;
|
|
2012
|
-
const
|
|
2013
|
-
|
|
2014
|
-
let
|
|
2015
|
-
for (;
|
|
2016
|
-
e.add(
|
|
2017
|
-
const
|
|
2018
|
-
|
|
2041
|
+
const l = t.get(a) ?? /* @__PURE__ */ new Set();
|
|
2042
|
+
l.add(u), t.set(a, l);
|
|
2043
|
+
let h = a;
|
|
2044
|
+
for (; h; ) {
|
|
2045
|
+
e.add(h);
|
|
2046
|
+
const f = h.getRootNode();
|
|
2047
|
+
h = h.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
|
|
2019
2048
|
}
|
|
2020
2049
|
};
|
|
2021
2050
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -2023,7 +2052,7 @@ function an() {
|
|
|
2023
2052
|
n = n.shadowRoot.activeElement;
|
|
2024
2053
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2025
2054
|
const r = window.getSelection();
|
|
2026
|
-
r && !r.isCollapsed && (s(
|
|
2055
|
+
r && !r.isCollapsed && (s(ue(r.anchorNode), "selected text"), s(ue(r.focusNode), "selected text"));
|
|
2027
2056
|
const i = [
|
|
2028
2057
|
["[aria-selected='true']", "selected"],
|
|
2029
2058
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2034,40 +2063,40 @@ function an() {
|
|
|
2034
2063
|
], o = [document];
|
|
2035
2064
|
for (let a = 0; a < o.length; a += 1) {
|
|
2036
2065
|
const u = o[a];
|
|
2037
|
-
for (const [
|
|
2038
|
-
for (const
|
|
2039
|
-
s(
|
|
2040
|
-
for (const
|
|
2041
|
-
|
|
2066
|
+
for (const [c, l] of i)
|
|
2067
|
+
for (const h of Array.from(u.querySelectorAll(c)))
|
|
2068
|
+
s(h, l);
|
|
2069
|
+
for (const c of Array.from(u.querySelectorAll("*")))
|
|
2070
|
+
c.shadowRoot && o.push(c.shadowRoot);
|
|
2042
2071
|
}
|
|
2043
2072
|
return {
|
|
2044
2073
|
priorityElements: e,
|
|
2045
2074
|
priorityTargets: Array.from(t, ([a, u]) => ({ element: a, labels: Array.from(u) }))
|
|
2046
2075
|
};
|
|
2047
2076
|
}
|
|
2048
|
-
function
|
|
2077
|
+
function un(e, t, s, n) {
|
|
2049
2078
|
const r = ["--- active/current elements ---"];
|
|
2050
2079
|
for (const i of e) {
|
|
2051
2080
|
const o = [];
|
|
2052
2081
|
let a = i.element;
|
|
2053
2082
|
for (; a; ) {
|
|
2054
|
-
const
|
|
2055
|
-
(a === i.element || t.has(
|
|
2056
|
-
const
|
|
2057
|
-
a = a.parentElement ?? (
|
|
2083
|
+
const l = a.tagName.toLowerCase();
|
|
2084
|
+
(a === i.element || t.has(l) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
2085
|
+
const h = a.getRootNode();
|
|
2086
|
+
a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
|
|
2058
2087
|
}
|
|
2059
|
-
const u = o.length > 6 ? [o[0], ...o.slice(-5)] : o,
|
|
2060
|
-
|
|
2088
|
+
const u = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = u.map((l, h) => Ce(
|
|
2089
|
+
l,
|
|
2061
2090
|
s,
|
|
2062
2091
|
n,
|
|
2063
|
-
|
|
2092
|
+
h === u.length - 1 ? Pe(l).slice(0, 180) : ""
|
|
2064
2093
|
));
|
|
2065
|
-
o.length > u.length &&
|
|
2094
|
+
o.length > u.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
2066
2095
|
}
|
|
2067
2096
|
return r.join(`
|
|
2068
2097
|
`);
|
|
2069
2098
|
}
|
|
2070
|
-
function
|
|
2099
|
+
function ue(e) {
|
|
2071
2100
|
return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
|
|
2072
2101
|
}
|
|
2073
2102
|
function Z(e, t) {
|
|
@@ -2076,17 +2105,17 @@ function Z(e, t) {
|
|
|
2076
2105
|
const s = " ".repeat(t);
|
|
2077
2106
|
return e.map((n) => `${s}${n}`);
|
|
2078
2107
|
}
|
|
2079
|
-
function
|
|
2108
|
+
function Pe(e) {
|
|
2080
2109
|
return B(
|
|
2081
2110
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2082
2111
|
);
|
|
2083
2112
|
}
|
|
2084
|
-
function
|
|
2113
|
+
function dn(e) {
|
|
2085
2114
|
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);
|
|
2086
2115
|
}
|
|
2087
|
-
function
|
|
2088
|
-
const e = document.querySelector(
|
|
2089
|
-
if (!(e ?? document.querySelector(
|
|
2116
|
+
function Ue() {
|
|
2117
|
+
const e = document.querySelector(ne);
|
|
2118
|
+
if (!(e ?? document.querySelector(Ct)))
|
|
2090
2119
|
return;
|
|
2091
2120
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2092
2121
|
return {
|
|
@@ -2095,28 +2124,28 @@ function Pe() {
|
|
|
2095
2124
|
selectors: [
|
|
2096
2125
|
{
|
|
2097
2126
|
name: "widget_host",
|
|
2098
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2127
|
+
selector: s === "browser_extension_sdk_preview" ? ne : Ct,
|
|
2099
2128
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2100
2129
|
},
|
|
2101
2130
|
{
|
|
2102
2131
|
name: "widget_root",
|
|
2103
|
-
selector:
|
|
2132
|
+
selector: ls,
|
|
2104
2133
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2105
2134
|
},
|
|
2106
2135
|
{
|
|
2107
2136
|
name: "widget_panel",
|
|
2108
|
-
selector:
|
|
2137
|
+
selector: us,
|
|
2109
2138
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2110
2139
|
},
|
|
2111
2140
|
{
|
|
2112
2141
|
name: "widget_timeline",
|
|
2113
|
-
selector:
|
|
2142
|
+
selector: ds,
|
|
2114
2143
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2115
2144
|
}
|
|
2116
2145
|
]
|
|
2117
2146
|
};
|
|
2118
2147
|
}
|
|
2119
|
-
function
|
|
2148
|
+
function hn(e) {
|
|
2120
2149
|
try {
|
|
2121
2150
|
const t = JSON.parse(e);
|
|
2122
2151
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2124,16 +2153,16 @@ function un(e) {
|
|
|
2124
2153
|
return { type: "error", message: "Invalid server event" };
|
|
2125
2154
|
}
|
|
2126
2155
|
}
|
|
2127
|
-
function
|
|
2156
|
+
function de(e, t) {
|
|
2128
2157
|
if (!e || typeof e != "object")
|
|
2129
2158
|
return [];
|
|
2130
2159
|
const s = e[t];
|
|
2131
2160
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2132
2161
|
}
|
|
2133
|
-
function
|
|
2162
|
+
function pn(e) {
|
|
2134
2163
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2135
2164
|
}
|
|
2136
|
-
function
|
|
2165
|
+
function fn(e) {
|
|
2137
2166
|
if (!e || typeof e != "object")
|
|
2138
2167
|
return null;
|
|
2139
2168
|
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;
|
|
@@ -2144,13 +2173,13 @@ function hn(e) {
|
|
|
2144
2173
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2145
2174
|
};
|
|
2146
2175
|
}
|
|
2147
|
-
function
|
|
2176
|
+
function gn(e) {
|
|
2148
2177
|
if (!e || typeof e != "object")
|
|
2149
2178
|
return null;
|
|
2150
2179
|
const t = e.javascript;
|
|
2151
2180
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2152
2181
|
}
|
|
2153
|
-
function
|
|
2182
|
+
function mn(e, t) {
|
|
2154
2183
|
return t ? e && typeof e == "object" ? {
|
|
2155
2184
|
...e,
|
|
2156
2185
|
helperError: t
|
|
@@ -2160,13 +2189,13 @@ function fn(e, t) {
|
|
|
2160
2189
|
helperError: t
|
|
2161
2190
|
} : e;
|
|
2162
2191
|
}
|
|
2163
|
-
function
|
|
2192
|
+
function yn(e) {
|
|
2164
2193
|
if (!e || typeof e != "object")
|
|
2165
2194
|
return e;
|
|
2166
2195
|
const t = e;
|
|
2167
2196
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2168
2197
|
}
|
|
2169
|
-
function
|
|
2198
|
+
function Tn() {
|
|
2170
2199
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2171
2200
|
if (t)
|
|
2172
2201
|
return t;
|
|
@@ -2176,7 +2205,7 @@ function mn() {
|
|
|
2176
2205
|
function Q() {
|
|
2177
2206
|
return crypto.randomUUID();
|
|
2178
2207
|
}
|
|
2179
|
-
function
|
|
2208
|
+
function In(e) {
|
|
2180
2209
|
if (!e || typeof e != "object")
|
|
2181
2210
|
return null;
|
|
2182
2211
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2187,14 +2216,14 @@ function yn(e) {
|
|
|
2187
2216
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2188
2217
|
} : null;
|
|
2189
2218
|
}
|
|
2190
|
-
function
|
|
2191
|
-
return Array.isArray(e) ?
|
|
2192
|
-
|
|
2193
|
-
e.map((s) =>
|
|
2219
|
+
function wn(e, t) {
|
|
2220
|
+
return Array.isArray(e) ? Ot(
|
|
2221
|
+
vt(
|
|
2222
|
+
e.map((s) => De(s, t)).filter((s) => s !== null)
|
|
2194
2223
|
)
|
|
2195
2224
|
) : [];
|
|
2196
2225
|
}
|
|
2197
|
-
function
|
|
2226
|
+
function An(e) {
|
|
2198
2227
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2199
2228
|
if (!t || typeof t != "object")
|
|
2200
2229
|
return [];
|
|
@@ -2213,7 +2242,7 @@ function wn(e) {
|
|
|
2213
2242
|
];
|
|
2214
2243
|
}) : [];
|
|
2215
2244
|
}
|
|
2216
|
-
function
|
|
2245
|
+
function De(e, t) {
|
|
2217
2246
|
if (!e || typeof e != "object")
|
|
2218
2247
|
return null;
|
|
2219
2248
|
const s = e, n = s.data;
|
|
@@ -2229,19 +2258,22 @@ function Ue(e, t) {
|
|
|
2229
2258
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2230
2259
|
role: i,
|
|
2231
2260
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2232
|
-
content:
|
|
2261
|
+
content: Mn(r.content),
|
|
2233
2262
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2234
2263
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2235
2264
|
...M(r) ? { runId: M(r) } : {},
|
|
2236
|
-
attachments:
|
|
2265
|
+
attachments: Be(r.attachments, t)
|
|
2237
2266
|
};
|
|
2238
|
-
return typeof r.
|
|
2267
|
+
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2268
|
+
value: r.id,
|
|
2269
|
+
enumerable: !1
|
|
2270
|
+
}), typeof r.clientMessageId == "string" && Object.defineProperty(o, "clientMessageId", {
|
|
2239
2271
|
value: r.clientMessageId,
|
|
2240
2272
|
enumerable: !1
|
|
2241
2273
|
}), o;
|
|
2242
2274
|
}
|
|
2243
2275
|
if (r.type === "function_call_output") {
|
|
2244
|
-
const i =
|
|
2276
|
+
const i = En(r.output);
|
|
2245
2277
|
return i ? {
|
|
2246
2278
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2247
2279
|
role: "tool",
|
|
@@ -2251,25 +2283,25 @@ function Ue(e, t) {
|
|
|
2251
2283
|
...M(r) ? { runId: M(r) } : {},
|
|
2252
2284
|
dataType: "function_call_output",
|
|
2253
2285
|
toolName: "authenticate_pipedream_app",
|
|
2254
|
-
callId:
|
|
2286
|
+
callId: he(r) ?? void 0,
|
|
2255
2287
|
integrationAuthRequest: i
|
|
2256
2288
|
} : null;
|
|
2257
2289
|
}
|
|
2258
2290
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2259
2291
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2260
2292
|
role: "tool",
|
|
2261
|
-
content: r.type === "mcp_call" ?
|
|
2293
|
+
content: r.type === "mcp_call" ? Sn(r) : bn(r),
|
|
2262
2294
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2263
2295
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2264
2296
|
...M(r) ? { runId: M(r) } : {},
|
|
2265
2297
|
dataType: String(r.type),
|
|
2266
2298
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2267
|
-
callId:
|
|
2299
|
+
callId: he(r) ?? void 0,
|
|
2268
2300
|
loading: r.localExecutionStatus === "running"
|
|
2269
2301
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2270
2302
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2271
2303
|
role: "system",
|
|
2272
|
-
content:
|
|
2304
|
+
content: kn(r),
|
|
2273
2305
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2274
2306
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2275
2307
|
...M(r) ? { runId: M(r) } : {},
|
|
@@ -2279,11 +2311,11 @@ function Ue(e, t) {
|
|
|
2279
2311
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2280
2312
|
} : null;
|
|
2281
2313
|
}
|
|
2282
|
-
function
|
|
2314
|
+
function Sn(e) {
|
|
2283
2315
|
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(" ");
|
|
2284
2316
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2285
2317
|
}
|
|
2286
|
-
function
|
|
2318
|
+
function En(e) {
|
|
2287
2319
|
if (typeof e != "string")
|
|
2288
2320
|
return null;
|
|
2289
2321
|
try {
|
|
@@ -2300,10 +2332,10 @@ function An(e) {
|
|
|
2300
2332
|
return null;
|
|
2301
2333
|
}
|
|
2302
2334
|
}
|
|
2303
|
-
function
|
|
2335
|
+
function kn(e) {
|
|
2304
2336
|
return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
|
|
2305
2337
|
}
|
|
2306
|
-
function
|
|
2338
|
+
function bn(e) {
|
|
2307
2339
|
if (e.type === "web_search_call") {
|
|
2308
2340
|
const t = e.action;
|
|
2309
2341
|
if (t && typeof t == "object") {
|
|
@@ -2315,9 +2347,9 @@ function En(e) {
|
|
|
2315
2347
|
}
|
|
2316
2348
|
return "🔎 Searching the web";
|
|
2317
2349
|
}
|
|
2318
|
-
return
|
|
2350
|
+
return Rn(e);
|
|
2319
2351
|
}
|
|
2320
|
-
function
|
|
2352
|
+
function Rn(e) {
|
|
2321
2353
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2322
2354
|
return L(e.summary);
|
|
2323
2355
|
if (typeof e.arguments == "string")
|
|
@@ -2334,11 +2366,26 @@ function L(e) {
|
|
|
2334
2366
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2335
2367
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2336
2368
|
}
|
|
2337
|
-
function
|
|
2369
|
+
function _n(e) {
|
|
2370
|
+
if (e == null)
|
|
2371
|
+
return e;
|
|
2372
|
+
if (typeof e != "object")
|
|
2373
|
+
return;
|
|
2374
|
+
const t = e;
|
|
2375
|
+
if (typeof t.content == "string")
|
|
2376
|
+
return {
|
|
2377
|
+
content: t.content,
|
|
2378
|
+
itemId: typeof t.itemId == "string" ? t.itemId : null,
|
|
2379
|
+
phase: t.phase === "commentary" || t.phase === "final_answer" ? t.phase : null,
|
|
2380
|
+
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null,
|
|
2381
|
+
runId: typeof t.runId == "string" ? t.runId : null
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
function he(e) {
|
|
2338
2385
|
const t = e.callId ?? e.call_id;
|
|
2339
2386
|
return typeof t == "string" && t ? t : null;
|
|
2340
2387
|
}
|
|
2341
|
-
function
|
|
2388
|
+
function Mn(e) {
|
|
2342
2389
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2343
2390
|
if (!t || typeof t != "object")
|
|
2344
2391
|
return "";
|
|
@@ -2346,24 +2393,24 @@ function bn(e) {
|
|
|
2346
2393
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2347
2394
|
}).filter(Boolean).join("") : "";
|
|
2348
2395
|
}
|
|
2349
|
-
function
|
|
2350
|
-
const s =
|
|
2351
|
-
|
|
2396
|
+
function Ne(e, t) {
|
|
2397
|
+
const s = Oe(e, t), n = Dn(
|
|
2398
|
+
Ln(e, t),
|
|
2352
2399
|
s
|
|
2353
2400
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2354
2401
|
if (r === -1)
|
|
2355
|
-
return
|
|
2356
|
-
|
|
2402
|
+
return Ot(
|
|
2403
|
+
vt([...n, s])
|
|
2357
2404
|
);
|
|
2358
2405
|
const i = [...n];
|
|
2359
|
-
return i[r] = s,
|
|
2406
|
+
return i[r] = s, Ot(vt(i));
|
|
2360
2407
|
}
|
|
2361
|
-
function
|
|
2408
|
+
function Cn(e, t) {
|
|
2362
2409
|
const s = e.findIndex(
|
|
2363
2410
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2364
2411
|
);
|
|
2365
2412
|
if (s === -1)
|
|
2366
|
-
return
|
|
2413
|
+
return Ne(e, t);
|
|
2367
2414
|
const n = [...e];
|
|
2368
2415
|
return n[s] = {
|
|
2369
2416
|
...n[s],
|
|
@@ -2371,12 +2418,12 @@ function Rn(e, t) {
|
|
|
2371
2418
|
loading: !0
|
|
2372
2419
|
}, n;
|
|
2373
2420
|
}
|
|
2374
|
-
function
|
|
2421
|
+
function Pn(e, t, s) {
|
|
2375
2422
|
let n = !1;
|
|
2376
2423
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2377
2424
|
return n ? r : e;
|
|
2378
2425
|
}
|
|
2379
|
-
function
|
|
2426
|
+
function Un(e) {
|
|
2380
2427
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
2381
2428
|
return !t || !s ? null : {
|
|
2382
2429
|
id: `transient-activity:${t}`,
|
|
@@ -2393,7 +2440,7 @@ function Mn(e) {
|
|
|
2393
2440
|
loading: !0
|
|
2394
2441
|
};
|
|
2395
2442
|
}
|
|
2396
|
-
function
|
|
2443
|
+
function Dn(e, t) {
|
|
2397
2444
|
if (t.id.startsWith("transient-activity:"))
|
|
2398
2445
|
return e;
|
|
2399
2446
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2401,52 +2448,52 @@ function Cn(e, t) {
|
|
|
2401
2448
|
(n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId === t.runId && n.respondsToUserMessageId === t.respondsToUserMessageId)
|
|
2402
2449
|
);
|
|
2403
2450
|
}
|
|
2404
|
-
function
|
|
2451
|
+
function Nn(e, t) {
|
|
2405
2452
|
const s = t.map(
|
|
2406
|
-
(n) =>
|
|
2453
|
+
(n) => Oe(e, n)
|
|
2407
2454
|
);
|
|
2408
|
-
return t.length > 0 ? s : e.filter(
|
|
2455
|
+
return t.length > 0 ? s : e.filter($t);
|
|
2409
2456
|
}
|
|
2410
|
-
function
|
|
2457
|
+
function Oe(e, t) {
|
|
2411
2458
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2412
2459
|
return t;
|
|
2413
2460
|
const s = e.find(
|
|
2414
|
-
(r) => r.role === "user" && (r.id === t.id ||
|
|
2461
|
+
(r) => r.role === "user" && (r.id === t.id || $t(r) && ve(r, t))
|
|
2415
2462
|
);
|
|
2416
2463
|
if (!s?.attachments?.length)
|
|
2417
2464
|
return t;
|
|
2418
2465
|
const n = t.attachments.map((r) => {
|
|
2419
|
-
const i =
|
|
2420
|
-
return i ?
|
|
2466
|
+
const i = On(s.attachments ?? [], r);
|
|
2467
|
+
return i ? vn(r, i) : r;
|
|
2421
2468
|
});
|
|
2422
2469
|
return { ...t, attachments: n };
|
|
2423
2470
|
}
|
|
2424
|
-
function
|
|
2471
|
+
function On(e, t) {
|
|
2425
2472
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2426
2473
|
}
|
|
2427
|
-
function
|
|
2474
|
+
function vn(e, t) {
|
|
2428
2475
|
const { previewUrl: s } = t;
|
|
2429
2476
|
return s ? { ...e, previewUrl: s } : e;
|
|
2430
2477
|
}
|
|
2431
|
-
function
|
|
2478
|
+
function Ln(e, t) {
|
|
2432
2479
|
if (t.role !== "user")
|
|
2433
2480
|
return e;
|
|
2434
2481
|
const s = e.findIndex(
|
|
2435
|
-
(r) =>
|
|
2482
|
+
(r) => $t(r) && ve(r, t)
|
|
2436
2483
|
);
|
|
2437
2484
|
if (s === -1)
|
|
2438
2485
|
return e;
|
|
2439
2486
|
const n = [...e];
|
|
2440
2487
|
return n.splice(s, 1), n;
|
|
2441
2488
|
}
|
|
2442
|
-
function
|
|
2443
|
-
const s =
|
|
2489
|
+
function ve(e, t) {
|
|
2490
|
+
const s = pe(e), n = pe(t);
|
|
2444
2491
|
return s && n ? s === n : e.content === t.content;
|
|
2445
2492
|
}
|
|
2446
|
-
function
|
|
2493
|
+
function $t(e) {
|
|
2447
2494
|
return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
|
|
2448
2495
|
}
|
|
2449
|
-
function
|
|
2496
|
+
function pe(e) {
|
|
2450
2497
|
const t = e.clientMessageId;
|
|
2451
2498
|
if (t)
|
|
2452
2499
|
return t;
|
|
@@ -2455,8 +2502,8 @@ function he(e) {
|
|
|
2455
2502
|
);
|
|
2456
2503
|
return n ? e.id.slice(n.length) : null;
|
|
2457
2504
|
}
|
|
2458
|
-
function
|
|
2459
|
-
const t =
|
|
2505
|
+
function fe(e) {
|
|
2506
|
+
const t = Le(e);
|
|
2460
2507
|
if (t === null)
|
|
2461
2508
|
return !1;
|
|
2462
2509
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
@@ -2472,17 +2519,17 @@ function pe(e) {
|
|
|
2472
2519
|
}
|
|
2473
2520
|
return !1;
|
|
2474
2521
|
}
|
|
2475
|
-
function
|
|
2476
|
-
const t =
|
|
2522
|
+
function xn(e) {
|
|
2523
|
+
const t = Le(e);
|
|
2477
2524
|
return t === null ? e.some(j) : e.slice(t + 1).some(j);
|
|
2478
2525
|
}
|
|
2479
|
-
function
|
|
2526
|
+
function Le(e) {
|
|
2480
2527
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2481
2528
|
if (e[t].role === "user")
|
|
2482
2529
|
return t;
|
|
2483
2530
|
return null;
|
|
2484
2531
|
}
|
|
2485
|
-
function
|
|
2532
|
+
function Bn(e) {
|
|
2486
2533
|
return j(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2487
2534
|
}
|
|
2488
2535
|
function at(e) {
|
|
@@ -2499,7 +2546,7 @@ function at(e) {
|
|
|
2499
2546
|
}
|
|
2500
2547
|
return null;
|
|
2501
2548
|
}
|
|
2502
|
-
function
|
|
2549
|
+
function qn(e) {
|
|
2503
2550
|
const t = at(e);
|
|
2504
2551
|
if (t === null)
|
|
2505
2552
|
return null;
|
|
@@ -2515,13 +2562,13 @@ function x(e) {
|
|
|
2515
2562
|
const t = e.data;
|
|
2516
2563
|
return t && typeof t == "object" ? t : null;
|
|
2517
2564
|
}
|
|
2518
|
-
function
|
|
2565
|
+
function Dt(e) {
|
|
2519
2566
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2520
2567
|
}
|
|
2521
|
-
function
|
|
2568
|
+
function ge(e) {
|
|
2522
2569
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2523
2570
|
}
|
|
2524
|
-
function
|
|
2571
|
+
function Hn(e, t) {
|
|
2525
2572
|
const s = at(t);
|
|
2526
2573
|
if (s === null)
|
|
2527
2574
|
return !1;
|
|
@@ -2529,9 +2576,9 @@ function xn(e, t) {
|
|
|
2529
2576
|
if (typeof r != "string" || !r)
|
|
2530
2577
|
return !1;
|
|
2531
2578
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2532
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
2579
|
+
return i === -1 ? !1 : e.slice(i + 1).some(Bn);
|
|
2533
2580
|
}
|
|
2534
|
-
function
|
|
2581
|
+
function Nt(e) {
|
|
2535
2582
|
const t = at(e);
|
|
2536
2583
|
if (t === null)
|
|
2537
2584
|
return null;
|
|
@@ -2544,7 +2591,7 @@ function Dt(e) {
|
|
|
2544
2591
|
const r = n.clientMessageId;
|
|
2545
2592
|
return typeof r == "string" ? r : null;
|
|
2546
2593
|
}
|
|
2547
|
-
function
|
|
2594
|
+
function Fn(e) {
|
|
2548
2595
|
const t = at(e);
|
|
2549
2596
|
if (t === null)
|
|
2550
2597
|
return null;
|
|
@@ -2559,13 +2606,13 @@ function Bn(e) {
|
|
|
2559
2606
|
if (i.type === "message" && i.role === "assistant")
|
|
2560
2607
|
return null;
|
|
2561
2608
|
if (i.type === "run_error")
|
|
2562
|
-
return i.retryable !== !0 ? null :
|
|
2609
|
+
return i.retryable !== !0 ? null : me(e, i) ?? Nt(e);
|
|
2563
2610
|
if (i.type === "run_status")
|
|
2564
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
2611
|
+
return i.status === "interrupted" && i.retryable === !0 ? me(e, i) ?? Nt(e) : null;
|
|
2565
2612
|
}
|
|
2566
2613
|
return null;
|
|
2567
2614
|
}
|
|
2568
|
-
function
|
|
2615
|
+
function me(e, t) {
|
|
2569
2616
|
if (typeof t.clientMessageId == "string")
|
|
2570
2617
|
return t.clientMessageId;
|
|
2571
2618
|
const s = O(t);
|
|
@@ -2574,7 +2621,7 @@ function ge(e, t) {
|
|
|
2574
2621
|
const n = e.find((i) => E(i, "id") === s), r = x(n);
|
|
2575
2622
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2576
2623
|
}
|
|
2577
|
-
function
|
|
2624
|
+
function Wn(e, t) {
|
|
2578
2625
|
let s = 0;
|
|
2579
2626
|
for (const n of e) {
|
|
2580
2627
|
if (!n || typeof n != "object")
|
|
@@ -2587,13 +2634,13 @@ function qn(e, t) {
|
|
|
2587
2634
|
}
|
|
2588
2635
|
return s;
|
|
2589
2636
|
}
|
|
2590
|
-
function
|
|
2591
|
-
if (!t ||
|
|
2637
|
+
function ye(e, t, s, n, r) {
|
|
2638
|
+
if (!t || !$n(e))
|
|
2592
2639
|
return !1;
|
|
2593
2640
|
const i = e;
|
|
2594
|
-
return !(
|
|
2641
|
+
return !(Dt(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && O(i) !== n || r !== null && M(i) !== r);
|
|
2595
2642
|
}
|
|
2596
|
-
function
|
|
2643
|
+
function $n(e) {
|
|
2597
2644
|
if (!e || typeof e != "object")
|
|
2598
2645
|
return !1;
|
|
2599
2646
|
const t = e;
|
|
@@ -2602,22 +2649,22 @@ function Hn(e) {
|
|
|
2602
2649
|
function j(e) {
|
|
2603
2650
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
2604
2651
|
}
|
|
2605
|
-
function
|
|
2652
|
+
function jn(e) {
|
|
2606
2653
|
if (!e || typeof e != "object")
|
|
2607
2654
|
return !1;
|
|
2608
2655
|
const t = e;
|
|
2609
2656
|
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";
|
|
2610
2657
|
}
|
|
2611
|
-
function
|
|
2612
|
-
return e.filter((t, s) =>
|
|
2658
|
+
function Ot(e) {
|
|
2659
|
+
return e.filter((t, s) => jt(t) ? !Vn(e, s) && !Jn(e, s) && !Kn(e, s) : zn(t) ? t.retryable === !0 && Xn(e, s) ? !1 : !Gn(e, s) : !0);
|
|
2613
2660
|
}
|
|
2614
|
-
function
|
|
2661
|
+
function zn(e) {
|
|
2615
2662
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
2616
2663
|
}
|
|
2617
|
-
function
|
|
2664
|
+
function jt(e) {
|
|
2618
2665
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
2619
2666
|
}
|
|
2620
|
-
function
|
|
2667
|
+
function vt(e) {
|
|
2621
2668
|
const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
2622
2669
|
for (const i of e) {
|
|
2623
2670
|
if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
|
|
@@ -2633,7 +2680,7 @@ function Ot(e) {
|
|
|
2633
2680
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
2634
2681
|
return r;
|
|
2635
2682
|
}
|
|
2636
|
-
function
|
|
2683
|
+
function Gn(e, t) {
|
|
2637
2684
|
const s = e[t];
|
|
2638
2685
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2639
2686
|
const r = e[n];
|
|
@@ -2644,7 +2691,7 @@ function $n(e, t) {
|
|
|
2644
2691
|
}
|
|
2645
2692
|
return !1;
|
|
2646
2693
|
}
|
|
2647
|
-
function
|
|
2694
|
+
function Xn(e, t) {
|
|
2648
2695
|
const s = e[t];
|
|
2649
2696
|
if (!s.respondsToUserMessageId)
|
|
2650
2697
|
return !1;
|
|
@@ -2652,29 +2699,29 @@ function jn(e, t) {
|
|
|
2652
2699
|
const r = e[n];
|
|
2653
2700
|
if (r.role === "user")
|
|
2654
2701
|
return !1;
|
|
2655
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
2702
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || jt(r)))
|
|
2656
2703
|
return !0;
|
|
2657
2704
|
}
|
|
2658
2705
|
return !1;
|
|
2659
2706
|
}
|
|
2660
|
-
function
|
|
2707
|
+
function Jn(e, t) {
|
|
2661
2708
|
const s = e[t];
|
|
2662
2709
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2663
2710
|
if (e[n].role === "assistant" && ct(s, e[n]))
|
|
2664
2711
|
return !0;
|
|
2665
2712
|
return !1;
|
|
2666
2713
|
}
|
|
2667
|
-
function
|
|
2714
|
+
function Kn(e, t) {
|
|
2668
2715
|
const s = e[t];
|
|
2669
2716
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2670
2717
|
if (e[n].role === "tool" && ct(s, e[n]))
|
|
2671
2718
|
return !0;
|
|
2672
2719
|
return !1;
|
|
2673
2720
|
}
|
|
2674
|
-
function
|
|
2721
|
+
function Vn(e, t) {
|
|
2675
2722
|
const s = e[t];
|
|
2676
2723
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2677
|
-
if (
|
|
2724
|
+
if (jt(e[n]) && ct(s, e[n]))
|
|
2678
2725
|
return !0;
|
|
2679
2726
|
return !1;
|
|
2680
2727
|
}
|
|
@@ -2684,15 +2731,15 @@ function ct(e, t) {
|
|
|
2684
2731
|
function E(e, t) {
|
|
2685
2732
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
2686
2733
|
}
|
|
2687
|
-
function
|
|
2734
|
+
function Yn(e, t) {
|
|
2688
2735
|
try {
|
|
2689
|
-
const s = window.localStorage.getItem(`${
|
|
2736
|
+
const s = window.localStorage.getItem(`${Re}${e}`);
|
|
2690
2737
|
if (!s)
|
|
2691
2738
|
return null;
|
|
2692
2739
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
2693
2740
|
if (t !== void 0 && r !== t)
|
|
2694
2741
|
return null;
|
|
2695
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2742
|
+
const i = Array.isArray(n.messages) ? n.messages.map(lr).filter((o) => !!o) : [];
|
|
2696
2743
|
return {
|
|
2697
2744
|
sessionId: r,
|
|
2698
2745
|
messages: i
|
|
@@ -2701,46 +2748,46 @@ function Jn(e, t) {
|
|
|
2701
2748
|
return null;
|
|
2702
2749
|
}
|
|
2703
2750
|
}
|
|
2704
|
-
function
|
|
2751
|
+
function Zn(e, t) {
|
|
2705
2752
|
try {
|
|
2706
2753
|
window.localStorage.setItem(
|
|
2707
|
-
`${
|
|
2754
|
+
`${Re}${e}`,
|
|
2708
2755
|
JSON.stringify({
|
|
2709
2756
|
sessionId: t.sessionId,
|
|
2710
|
-
messages: t.messages.slice(-
|
|
2757
|
+
messages: t.messages.slice(-Us).map(ur)
|
|
2711
2758
|
})
|
|
2712
2759
|
);
|
|
2713
2760
|
} catch {
|
|
2714
2761
|
return;
|
|
2715
2762
|
}
|
|
2716
2763
|
}
|
|
2717
|
-
function
|
|
2764
|
+
function Qn(e) {
|
|
2718
2765
|
try {
|
|
2719
|
-
const t = window.localStorage.getItem(`${
|
|
2766
|
+
const t = window.localStorage.getItem(`${Pt}${e}`);
|
|
2720
2767
|
if (!t)
|
|
2721
2768
|
return [];
|
|
2722
2769
|
const s = JSON.parse(t);
|
|
2723
|
-
return Array.isArray(s) ? s.filter(
|
|
2770
|
+
return Array.isArray(s) ? s.filter(zt) : [];
|
|
2724
2771
|
} catch {
|
|
2725
2772
|
return [];
|
|
2726
2773
|
}
|
|
2727
2774
|
}
|
|
2728
2775
|
function W(e, t) {
|
|
2729
2776
|
try {
|
|
2730
|
-
const s = t.filter(
|
|
2777
|
+
const s = t.filter(zt);
|
|
2731
2778
|
if (s.length === 0) {
|
|
2732
|
-
window.localStorage.removeItem(`${
|
|
2779
|
+
window.localStorage.removeItem(`${Pt}${e}`);
|
|
2733
2780
|
return;
|
|
2734
2781
|
}
|
|
2735
2782
|
window.localStorage.setItem(
|
|
2736
|
-
`${
|
|
2783
|
+
`${Pt}${e}`,
|
|
2737
2784
|
JSON.stringify(s.slice(-25))
|
|
2738
2785
|
);
|
|
2739
2786
|
} catch {
|
|
2740
2787
|
return;
|
|
2741
2788
|
}
|
|
2742
2789
|
}
|
|
2743
|
-
function
|
|
2790
|
+
function xe(e, t) {
|
|
2744
2791
|
try {
|
|
2745
2792
|
const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
2746
2793
|
...o,
|
|
@@ -2756,28 +2803,28 @@ function Le(e, t) {
|
|
|
2756
2803
|
} catch {
|
|
2757
2804
|
}
|
|
2758
2805
|
}
|
|
2759
|
-
function
|
|
2806
|
+
function tr(e, t) {
|
|
2760
2807
|
try {
|
|
2761
2808
|
if (window.sessionStorage.getItem(`${ot}${e}`) === null)
|
|
2762
2809
|
return;
|
|
2763
2810
|
} catch {
|
|
2764
2811
|
return;
|
|
2765
2812
|
}
|
|
2766
|
-
|
|
2813
|
+
xe(e, t);
|
|
2767
2814
|
}
|
|
2768
|
-
function
|
|
2815
|
+
function er(e) {
|
|
2769
2816
|
try {
|
|
2770
2817
|
const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
|
|
2771
2818
|
if (window.sessionStorage.removeItem(t), !s)
|
|
2772
2819
|
return [];
|
|
2773
2820
|
const n = JSON.parse(s);
|
|
2774
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2821
|
+
return Array.isArray(n) ? n.flatMap((r) => nr(r) ? [{
|
|
2775
2822
|
...r.event,
|
|
2776
2823
|
page: R(),
|
|
2777
2824
|
rawOutput: {
|
|
2778
2825
|
pageContextRestarted: !0,
|
|
2779
2826
|
outcome: "unknown",
|
|
2780
|
-
message:
|
|
2827
|
+
message: sr(location.href),
|
|
2781
2828
|
currentUrl: location.href,
|
|
2782
2829
|
console: [],
|
|
2783
2830
|
metadata: {
|
|
@@ -2794,17 +2841,17 @@ function Zn(e) {
|
|
|
2794
2841
|
return [];
|
|
2795
2842
|
}
|
|
2796
2843
|
}
|
|
2797
|
-
function
|
|
2844
|
+
function sr(e) {
|
|
2798
2845
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
2799
2846
|
Current URL: ${e}`;
|
|
2800
2847
|
}
|
|
2801
|
-
function
|
|
2848
|
+
function nr(e) {
|
|
2802
2849
|
if (!e || typeof e != "object")
|
|
2803
2850
|
return !1;
|
|
2804
2851
|
const t = e, s = t.event;
|
|
2805
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
2852
|
+
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";
|
|
2806
2853
|
}
|
|
2807
|
-
function
|
|
2854
|
+
function rr(e, t) {
|
|
2808
2855
|
const s = new Set(
|
|
2809
2856
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2810
2857
|
);
|
|
@@ -2813,26 +2860,26 @@ function er(e, t) {
|
|
|
2813
2860
|
...t.filter((n) => !s.has(n.callId))
|
|
2814
2861
|
];
|
|
2815
2862
|
}
|
|
2816
|
-
function
|
|
2863
|
+
function ir(e) {
|
|
2817
2864
|
try {
|
|
2818
2865
|
window.sessionStorage.removeItem(`${ot}${e}`);
|
|
2819
2866
|
} catch {
|
|
2820
2867
|
return;
|
|
2821
2868
|
}
|
|
2822
2869
|
}
|
|
2823
|
-
function
|
|
2870
|
+
function zt(e) {
|
|
2824
2871
|
if (!e || typeof e != "object")
|
|
2825
2872
|
return !1;
|
|
2826
2873
|
const t = e;
|
|
2827
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
2874
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && Te(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Te(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;
|
|
2828
2875
|
}
|
|
2829
|
-
function
|
|
2876
|
+
function Te(e) {
|
|
2830
2877
|
if (!e || typeof e != "object")
|
|
2831
2878
|
return !1;
|
|
2832
2879
|
const t = e;
|
|
2833
2880
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
2834
2881
|
}
|
|
2835
|
-
function
|
|
2882
|
+
function Be(e, t) {
|
|
2836
2883
|
if (!Array.isArray(e))
|
|
2837
2884
|
return;
|
|
2838
2885
|
const s = e.filter((r) => {
|
|
@@ -2840,24 +2887,24 @@ function xe(e, t) {
|
|
|
2840
2887
|
return !1;
|
|
2841
2888
|
const i = r;
|
|
2842
2889
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2843
|
-
}), n = t ? s.map((r) =>
|
|
2890
|
+
}), n = t ? s.map((r) => qe(r, t)) : s;
|
|
2844
2891
|
return n.length > 0 ? n : void 0;
|
|
2845
2892
|
}
|
|
2846
|
-
function
|
|
2893
|
+
function qe(e, t) {
|
|
2847
2894
|
return e.fileUrl?.startsWith("/") ? {
|
|
2848
2895
|
...e,
|
|
2849
2896
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2850
2897
|
} : e;
|
|
2851
2898
|
}
|
|
2852
|
-
function
|
|
2853
|
-
if (
|
|
2899
|
+
function or(e) {
|
|
2900
|
+
if (ar(e))
|
|
2854
2901
|
return {
|
|
2855
2902
|
headers: {
|
|
2856
2903
|
"ngrok-skip-browser-warning": "true"
|
|
2857
2904
|
}
|
|
2858
2905
|
};
|
|
2859
2906
|
}
|
|
2860
|
-
function
|
|
2907
|
+
function ar(e) {
|
|
2861
2908
|
try {
|
|
2862
2909
|
const t = new URL(e).hostname;
|
|
2863
2910
|
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
@@ -2865,14 +2912,14 @@ function rr(e) {
|
|
|
2865
2912
|
return !1;
|
|
2866
2913
|
}
|
|
2867
2914
|
}
|
|
2868
|
-
function
|
|
2869
|
-
return e.type ||
|
|
2915
|
+
function Ie(e) {
|
|
2916
|
+
return e.type || cr(e.name) || "application/octet-stream";
|
|
2870
2917
|
}
|
|
2871
|
-
function
|
|
2918
|
+
function cr(e) {
|
|
2872
2919
|
const t = e.toLowerCase();
|
|
2873
2920
|
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;
|
|
2874
2921
|
}
|
|
2875
|
-
function
|
|
2922
|
+
function lr(e) {
|
|
2876
2923
|
if (!e || typeof e != "object")
|
|
2877
2924
|
return null;
|
|
2878
2925
|
const t = e;
|
|
@@ -2885,17 +2932,17 @@ function or(e) {
|
|
|
2885
2932
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
2886
2933
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
2887
2934
|
securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
|
|
2888
|
-
attachments:
|
|
2935
|
+
attachments: Be(t.attachments)?.map(Gt),
|
|
2889
2936
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2890
2937
|
};
|
|
2891
2938
|
}
|
|
2892
|
-
function
|
|
2939
|
+
function ur(e) {
|
|
2893
2940
|
return e.attachments?.length ? {
|
|
2894
2941
|
...e,
|
|
2895
|
-
attachments: e.attachments.map(
|
|
2942
|
+
attachments: e.attachments.map(Gt)
|
|
2896
2943
|
} : e;
|
|
2897
2944
|
}
|
|
2898
|
-
function
|
|
2945
|
+
function Gt(e) {
|
|
2899
2946
|
const {
|
|
2900
2947
|
dataUrl: t,
|
|
2901
2948
|
objectUrl: s,
|
|
@@ -2912,39 +2959,39 @@ function M(e) {
|
|
|
2912
2959
|
const t = e.runId;
|
|
2913
2960
|
return typeof t == "string" && t ? t : null;
|
|
2914
2961
|
}
|
|
2915
|
-
function
|
|
2962
|
+
function dr(e) {
|
|
2916
2963
|
const t = e?.timeoutMs;
|
|
2917
|
-
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 <=
|
|
2964
|
+
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 <= qs);
|
|
2918
2965
|
}
|
|
2919
|
-
function
|
|
2966
|
+
function He(e) {
|
|
2920
2967
|
const t = {};
|
|
2921
2968
|
try {
|
|
2922
2969
|
new Headers(e).forEach((s, n) => {
|
|
2923
|
-
Object.keys(t).length <
|
|
2970
|
+
Object.keys(t).length < Ht && (t[n] = Xt(n, s));
|
|
2924
2971
|
});
|
|
2925
2972
|
} catch {
|
|
2926
2973
|
return {};
|
|
2927
2974
|
}
|
|
2928
2975
|
return t;
|
|
2929
2976
|
}
|
|
2930
|
-
function
|
|
2931
|
-
return
|
|
2977
|
+
function Xt(e, t) {
|
|
2978
|
+
return Ge(e) ? lt : C(rt(t), Ms);
|
|
2932
2979
|
}
|
|
2933
|
-
function
|
|
2980
|
+
function hr(e, t) {
|
|
2934
2981
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2935
2982
|
}
|
|
2936
|
-
async function
|
|
2937
|
-
const r =
|
|
2983
|
+
async function pr(e, t, s, n) {
|
|
2984
|
+
const r = He(e.headers);
|
|
2938
2985
|
n({
|
|
2939
2986
|
...t,
|
|
2940
2987
|
responseStatus: e.status,
|
|
2941
2988
|
responseHeaders: r,
|
|
2942
|
-
responseBody: await
|
|
2989
|
+
responseBody: await fr(e),
|
|
2943
2990
|
durationMs: Date.now() - s
|
|
2944
2991
|
});
|
|
2945
2992
|
}
|
|
2946
|
-
async function
|
|
2947
|
-
if (!
|
|
2993
|
+
async function fr(e) {
|
|
2994
|
+
if (!Fe(e.headers))
|
|
2948
2995
|
return;
|
|
2949
2996
|
let t = null, s = null;
|
|
2950
2997
|
try {
|
|
@@ -2953,20 +3000,20 @@ async function dr(e) {
|
|
|
2953
3000
|
const n = new Promise((a) => {
|
|
2954
3001
|
s = window.setTimeout(() => {
|
|
2955
3002
|
t?.cancel(), a("timeout");
|
|
2956
|
-
},
|
|
3003
|
+
}, Cs);
|
|
2957
3004
|
}), r = new TextDecoder();
|
|
2958
3005
|
let i = "", o = 0;
|
|
2959
3006
|
for (; ; ) {
|
|
2960
3007
|
const a = await Promise.race([t.read(), n]);
|
|
2961
3008
|
if (a === "timeout")
|
|
2962
3009
|
return;
|
|
2963
|
-
const { done: u, value:
|
|
3010
|
+
const { done: u, value: c } = a;
|
|
2964
3011
|
if (u)
|
|
2965
3012
|
return C(i + r.decode());
|
|
2966
|
-
const
|
|
2967
|
-
if (
|
|
2968
|
-
return i += r.decode(
|
|
2969
|
-
o +=
|
|
3013
|
+
const l = qt - o;
|
|
3014
|
+
if (c.byteLength > l)
|
|
3015
|
+
return i += r.decode(c.subarray(0, Math.max(l, 0)), { stream: !0 }), t.cancel(), `${C(i)}... [truncated]`;
|
|
3016
|
+
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
2970
3017
|
}
|
|
2971
3018
|
} catch {
|
|
2972
3019
|
t?.cancel();
|
|
@@ -2975,8 +3022,8 @@ async function dr(e) {
|
|
|
2975
3022
|
s !== null && window.clearTimeout(s);
|
|
2976
3023
|
}
|
|
2977
3024
|
}
|
|
2978
|
-
function
|
|
2979
|
-
if (
|
|
3025
|
+
function gr(e, t) {
|
|
3026
|
+
if (Fe(new Headers(t)))
|
|
2980
3027
|
try {
|
|
2981
3028
|
return e.responseType === "" || e.responseType === "text" ? C(e.responseText ?? "") : void 0;
|
|
2982
3029
|
} catch {
|
|
@@ -2987,14 +3034,14 @@ function we(e) {
|
|
|
2987
3034
|
if (typeof e == "string")
|
|
2988
3035
|
return C(e);
|
|
2989
3036
|
}
|
|
2990
|
-
function
|
|
3037
|
+
function mr(e) {
|
|
2991
3038
|
return _({
|
|
2992
3039
|
...e,
|
|
2993
|
-
requestBody:
|
|
2994
|
-
responseBody:
|
|
3040
|
+
requestBody: Ae(e.requestBody),
|
|
3041
|
+
responseBody: Ae(e.responseBody)
|
|
2995
3042
|
});
|
|
2996
3043
|
}
|
|
2997
|
-
function
|
|
3044
|
+
function Ae(e) {
|
|
2998
3045
|
if (typeof e != "string")
|
|
2999
3046
|
return e;
|
|
3000
3047
|
const t = e.trim();
|
|
@@ -3006,14 +3053,14 @@ function Ie(e) {
|
|
|
3006
3053
|
return rt(e);
|
|
3007
3054
|
}
|
|
3008
3055
|
}
|
|
3009
|
-
function
|
|
3056
|
+
function Fe(e) {
|
|
3010
3057
|
if (!e)
|
|
3011
3058
|
return !1;
|
|
3012
3059
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3013
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3060
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= qt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3014
3061
|
}
|
|
3015
3062
|
function v(e, t = {}, s) {
|
|
3016
|
-
if (
|
|
3063
|
+
if (Tr(s))
|
|
3017
3064
|
return !0;
|
|
3018
3065
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3019
3066
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3028,7 +3075,7 @@ function v(e, t = {}, s) {
|
|
|
3028
3075
|
return !0;
|
|
3029
3076
|
}
|
|
3030
3077
|
}
|
|
3031
|
-
function
|
|
3078
|
+
function yr(e, t) {
|
|
3032
3079
|
if (v(e))
|
|
3033
3080
|
return !0;
|
|
3034
3081
|
try {
|
|
@@ -3038,26 +3085,26 @@ function fr(e, t) {
|
|
|
3038
3085
|
return !0;
|
|
3039
3086
|
}
|
|
3040
3087
|
}
|
|
3041
|
-
function
|
|
3088
|
+
function Tr(e) {
|
|
3042
3089
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3043
3090
|
}
|
|
3044
|
-
function
|
|
3091
|
+
function Ir(e) {
|
|
3045
3092
|
const t = {};
|
|
3046
3093
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3047
3094
|
const n = s.indexOf(":");
|
|
3048
3095
|
if (n <= 0)
|
|
3049
3096
|
continue;
|
|
3050
|
-
if (Object.keys(t).length >=
|
|
3097
|
+
if (Object.keys(t).length >= Ht)
|
|
3051
3098
|
break;
|
|
3052
3099
|
const r = s.slice(0, n).trim();
|
|
3053
|
-
t[r] =
|
|
3100
|
+
t[r] = Xt(r, s.slice(n + 1).trim());
|
|
3054
3101
|
}
|
|
3055
3102
|
return t;
|
|
3056
3103
|
}
|
|
3057
|
-
function C(e, t =
|
|
3104
|
+
function C(e, t = qt) {
|
|
3058
3105
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
3059
3106
|
}
|
|
3060
|
-
function
|
|
3107
|
+
function Rt(e) {
|
|
3061
3108
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3062
3109
|
}
|
|
3063
3110
|
class st extends Error {
|
|
@@ -3066,33 +3113,33 @@ class st extends Error {
|
|
|
3066
3113
|
}
|
|
3067
3114
|
status;
|
|
3068
3115
|
}
|
|
3069
|
-
async function
|
|
3116
|
+
async function _t(e, t) {
|
|
3070
3117
|
let s = null;
|
|
3071
|
-
for (let n = 0; n <
|
|
3118
|
+
for (let n = 0; n < ae; n += 1)
|
|
3072
3119
|
try {
|
|
3073
3120
|
return await e();
|
|
3074
3121
|
} catch (r) {
|
|
3075
|
-
if (s = r, n >=
|
|
3122
|
+
if (s = r, n >= ae - 1 || !Ar(r))
|
|
3076
3123
|
throw r;
|
|
3077
|
-
await
|
|
3124
|
+
await wr(n);
|
|
3078
3125
|
}
|
|
3079
3126
|
throw s instanceof Error ? s : new Error(t);
|
|
3080
3127
|
}
|
|
3081
|
-
function
|
|
3128
|
+
function wr(e) {
|
|
3082
3129
|
return new Promise((t) => {
|
|
3083
|
-
window.setTimeout(t,
|
|
3130
|
+
window.setTimeout(t, _s[e] ?? 0);
|
|
3084
3131
|
});
|
|
3085
3132
|
}
|
|
3086
|
-
function
|
|
3087
|
-
return e instanceof st ?
|
|
3133
|
+
function Ar(e) {
|
|
3134
|
+
return e instanceof st ? Sr(e.status) : e instanceof TypeError;
|
|
3088
3135
|
}
|
|
3089
|
-
function
|
|
3136
|
+
function Sr(e) {
|
|
3090
3137
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3091
3138
|
}
|
|
3092
|
-
function
|
|
3139
|
+
function Er(e) {
|
|
3093
3140
|
return e === 401 || e === 403;
|
|
3094
3141
|
}
|
|
3095
|
-
const lt = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]",
|
|
3142
|
+
const lt = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", kr = "[REDACTED_SIGNED_URL]", br = 20, Rr = /^(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, _r = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Mr = /\bhttps?:\/\/[^\s"'<>]+/gi, Cr = /[),.;\]]+$/;
|
|
3096
3143
|
function _(e) {
|
|
3097
3144
|
return nt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3098
3145
|
}
|
|
@@ -3101,7 +3148,7 @@ function nt(e, t, s) {
|
|
|
3101
3148
|
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : rt(e);
|
|
3102
3149
|
if (e === null || typeof e != "object")
|
|
3103
3150
|
return e;
|
|
3104
|
-
if (t >=
|
|
3151
|
+
if (t >= br)
|
|
3105
3152
|
return "[REDACTED_MAX_DEPTH]";
|
|
3106
3153
|
if (s.has(e))
|
|
3107
3154
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -3109,44 +3156,44 @@ function nt(e, t, s) {
|
|
|
3109
3156
|
return e.map((r) => nt(r, t + 1, s));
|
|
3110
3157
|
const n = {};
|
|
3111
3158
|
for (const [r, i] of Object.entries(e))
|
|
3112
|
-
r === "pageContent" ? n[r] = i :
|
|
3159
|
+
r === "pageContent" ? n[r] = i : Ge(r) ? n[r] = lt : n[r] = r.toLowerCase() === "url" ? Pr(i) : nt(i, t + 1, s);
|
|
3113
3160
|
return n;
|
|
3114
3161
|
}
|
|
3115
|
-
function
|
|
3162
|
+
function Ge(e) {
|
|
3116
3163
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3117
3164
|
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");
|
|
3118
3165
|
}
|
|
3119
|
-
function
|
|
3120
|
-
return typeof e == "string" ?
|
|
3166
|
+
function Pr(e) {
|
|
3167
|
+
return typeof e == "string" ? Xe(e) : nt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3121
3168
|
}
|
|
3122
|
-
function
|
|
3169
|
+
function Xe(e) {
|
|
3123
3170
|
try {
|
|
3124
3171
|
const t = new URL(e, location.href);
|
|
3125
3172
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3126
|
-
|
|
3173
|
+
Rr.test(s) && t.searchParams.set(s, P);
|
|
3127
3174
|
return t.username && (t.username = P), t.password && (t.password = P), t.toString();
|
|
3128
3175
|
} catch {
|
|
3129
|
-
return
|
|
3176
|
+
return Ur(e);
|
|
3130
3177
|
}
|
|
3131
3178
|
}
|
|
3132
3179
|
function rt(e) {
|
|
3133
|
-
return e.replace(
|
|
3180
|
+
return e.replace(_r, kr).replace(Mr, Dr).replace(We, `Bearer ${P}`).replace($e, `Basic ${P}`).replace(je, P).replace(ze, (t, s) => `${s}: ${lt}`);
|
|
3134
3181
|
}
|
|
3135
|
-
function
|
|
3136
|
-
return e.replace(
|
|
3182
|
+
function Ur(e) {
|
|
3183
|
+
return e.replace(We, `Bearer ${P}`).replace($e, `Basic ${P}`).replace(je, P).replace(ze, (t, s) => `${s}: ${lt}`);
|
|
3137
3184
|
}
|
|
3138
|
-
function
|
|
3139
|
-
const t = e.match(
|
|
3140
|
-
return `${
|
|
3185
|
+
function Dr(e) {
|
|
3186
|
+
const t = e.match(Cr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3187
|
+
return `${Xe(s)}${t}`;
|
|
3141
3188
|
}
|
|
3142
3189
|
export {
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3190
|
+
ne as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3191
|
+
Ct as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3192
|
+
us as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3193
|
+
ls as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3194
|
+
ds as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3195
|
+
_e as PlunoProductAgent,
|
|
3196
|
+
Ns as calculateReconnectDelay,
|
|
3197
|
+
_e as default,
|
|
3198
|
+
tn as getProductAgentOriginAccessErrorMessage
|
|
3152
3199
|
};
|