@pluno/product-agent-web 0.1.132 → 0.1.133
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/markdown.d.ts +2 -0
- package/dist/product-agent-sdk.js +390 -380
- package/dist/product-agent-widget.js +5746 -2565
- package/package.json +2 -2
|
@@ -4,10 +4,10 @@ async function Xe(e) {
|
|
|
4
4
|
const t = await vt();
|
|
5
5
|
await Ve(t, "readwrite", (s) => s.put(e));
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
7
|
+
async function Ke(e, t) {
|
|
8
8
|
const s = await vt();
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
9
|
+
await Nt(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await Ot(
|
|
11
11
|
n.get(e)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,11 +16,11 @@ async function Je(e, t) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
19
|
+
async function Je(e = 864e5) {
|
|
20
20
|
const t = await vt(), s = Date.now() - e;
|
|
21
|
-
await
|
|
21
|
+
await Nt(t, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await Ot(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
function vt() {
|
|
@@ -33,9 +33,9 @@ function vt() {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
async function Ve(e, t, s) {
|
|
36
|
-
return await
|
|
36
|
+
return await Nt(e, t, async (n) => await Ot(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Nt(e, t, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
40
|
const i = e.transaction(_t, t), o = i.objectStore(_t);
|
|
41
41
|
let a, c = !1;
|
|
@@ -57,7 +57,7 @@ function Ot(e, t, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Ot(e) {
|
|
61
61
|
return new Promise((t, s) => {
|
|
62
62
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
@@ -65,7 +65,7 @@ function Nt(e) {
|
|
|
65
65
|
function Ye(e) {
|
|
66
66
|
return e !== null && (typeof e == "object" || typeof e == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Ie(e, t, s) {
|
|
69
69
|
const n = Reflect.get(e, "pluno"), r = Ye(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(e, "pluno", r))
|
|
71
71
|
return null;
|
|
@@ -80,11 +80,18 @@ function Te(e, t, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const Ze = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function Qe(e, t) {
|
|
85
|
+
return t ? e.replace(
|
|
86
|
+
Ze,
|
|
87
|
+
(s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
|
|
88
|
+
) : e;
|
|
89
|
+
}
|
|
90
|
+
const Tt = "pluno.productAgent.transportId", ts = "pluno.productAgent.transportIdentity", It = "pluno.productAgent.transportIdentity.event", es = 50, ss = globalThis.setTimeout.bind(globalThis);
|
|
84
91
|
let $ = null;
|
|
85
92
|
const Q = /* @__PURE__ */ new Set(), wt = /* @__PURE__ */ new Map();
|
|
86
|
-
async function
|
|
87
|
-
const t = e.randomUUID(), s = e.storage.getItem(
|
|
93
|
+
async function ns(e = we()) {
|
|
94
|
+
const t = e.randomUUID(), s = e.storage.getItem(Tt);
|
|
88
95
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
89
96
|
const o = e.channel.subscribe((c) => {
|
|
90
97
|
if (!(c.senderId === t || c.transportId !== n)) {
|
|
@@ -102,14 +109,14 @@ async function es(e = we()) {
|
|
|
102
109
|
}
|
|
103
110
|
});
|
|
104
111
|
if (!s)
|
|
105
|
-
e.storage.setItem(
|
|
112
|
+
e.storage.setItem(Tt, n), r = !0;
|
|
106
113
|
else
|
|
107
114
|
for (; ; ) {
|
|
108
115
|
if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
|
|
109
116
|
r = !0;
|
|
110
117
|
break;
|
|
111
118
|
}
|
|
112
|
-
n = e.randomUUID(), e.storage.setItem(
|
|
119
|
+
n = e.randomUUID(), e.storage.setItem(Tt, n);
|
|
113
120
|
}
|
|
114
121
|
let a = !1;
|
|
115
122
|
return {
|
|
@@ -119,14 +126,14 @@ async function es(e = we()) {
|
|
|
119
126
|
}
|
|
120
127
|
};
|
|
121
128
|
}
|
|
122
|
-
async function
|
|
123
|
-
$ || ($ =
|
|
129
|
+
async function rs() {
|
|
130
|
+
$ || ($ = ns(we()), $.then((n) => {
|
|
124
131
|
const r = (i) => {
|
|
125
132
|
i.persisted || (n.release(), $ = null, Q.clear(), window.removeEventListener("pagehide", r));
|
|
126
133
|
};
|
|
127
134
|
window.addEventListener("pagehide", r);
|
|
128
135
|
}));
|
|
129
|
-
const e = await $, t =
|
|
136
|
+
const e = await $, t = is();
|
|
130
137
|
Q.add(t);
|
|
131
138
|
let s = !1;
|
|
132
139
|
return {
|
|
@@ -137,7 +144,7 @@ async function ss() {
|
|
|
137
144
|
}
|
|
138
145
|
};
|
|
139
146
|
}
|
|
140
|
-
function
|
|
147
|
+
function is() {
|
|
141
148
|
let e = 0;
|
|
142
149
|
for (; Q.has(e); )
|
|
143
150
|
e += 1;
|
|
@@ -145,13 +152,13 @@ function ns() {
|
|
|
145
152
|
}
|
|
146
153
|
function we() {
|
|
147
154
|
return {
|
|
148
|
-
storage:
|
|
149
|
-
channel:
|
|
155
|
+
storage: os(),
|
|
156
|
+
channel: as(),
|
|
150
157
|
randomUUID: () => crypto.randomUUID(),
|
|
151
|
-
settle: () => new Promise((e) =>
|
|
158
|
+
settle: () => new Promise((e) => ss(e, es))
|
|
152
159
|
};
|
|
153
160
|
}
|
|
154
|
-
function
|
|
161
|
+
function os() {
|
|
155
162
|
return {
|
|
156
163
|
getItem: (e) => {
|
|
157
164
|
try {
|
|
@@ -169,9 +176,9 @@ function rs() {
|
|
|
169
176
|
}
|
|
170
177
|
};
|
|
171
178
|
}
|
|
172
|
-
function
|
|
179
|
+
function as() {
|
|
173
180
|
if (typeof BroadcastChannel < "u") {
|
|
174
|
-
const e = new BroadcastChannel(
|
|
181
|
+
const e = new BroadcastChannel(ts);
|
|
175
182
|
return {
|
|
176
183
|
postMessage: (t) => e.postMessage(t),
|
|
177
184
|
subscribe: (t) => {
|
|
@@ -181,11 +188,11 @@ function is() {
|
|
|
181
188
|
close: () => e.close()
|
|
182
189
|
};
|
|
183
190
|
}
|
|
184
|
-
return
|
|
191
|
+
return cs();
|
|
185
192
|
}
|
|
186
|
-
function
|
|
193
|
+
function cs() {
|
|
187
194
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
188
|
-
if (s.key !==
|
|
195
|
+
if (s.key !== It || !s.newValue)
|
|
189
196
|
return;
|
|
190
197
|
const n = JSON.parse(s.newValue);
|
|
191
198
|
for (const r of e)
|
|
@@ -194,9 +201,9 @@ function os() {
|
|
|
194
201
|
return window.addEventListener("storage", t), {
|
|
195
202
|
postMessage: (s) => {
|
|
196
203
|
window.localStorage.setItem(
|
|
197
|
-
|
|
204
|
+
It,
|
|
198
205
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
199
|
-
), window.localStorage.removeItem(
|
|
206
|
+
), window.localStorage.removeItem(It);
|
|
200
207
|
},
|
|
201
208
|
subscribe: (s) => (e.add(s), () => e.delete(s)),
|
|
202
209
|
close: () => {
|
|
@@ -204,18 +211,18 @@ function os() {
|
|
|
204
211
|
}
|
|
205
212
|
};
|
|
206
213
|
}
|
|
207
|
-
const
|
|
214
|
+
const ls = globalThis.fetch.bind(globalThis), Mt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', us = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ds = ".pluno-pa-widget__panel", hs = ".pluno-pa-widget__timeline", te = `${Mt}[data-pluno-sdk-preview-channel]`, ps = "https://app.pluno.ai", fs = "gpt-5.6-terra", gs = 2e4, ms = 1e4, ys = 1e4, Ts = 1e4, Is = 1e4, ws = 1e3, ee = 3e4, se = 0.2, ne = 6e4, As = 15e3, J = 8, Ss = 15e3, Es = 2e3, bs = 1e3, ks = 100, Rs = 8e3, re = 3, _s = [300, 1e3], Lt = 64e3, At = 4e3, Bt = 30, Ms = 2e3, Cs = 1e3, Ae = "Image is too large for model vision input.", Ps = 100, Se = "pluno.productAgent.state.", Ct = "pluno.productAgent.pendingEvents.", rt = "pluno.productAgent.activeToolCalls.", Us = 100;
|
|
208
215
|
function V(e, t = 0) {
|
|
209
216
|
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
210
217
|
return Math.max(t, s);
|
|
211
218
|
}
|
|
212
219
|
const tt = /* @__PURE__ */ new Set();
|
|
213
220
|
let Y = null;
|
|
214
|
-
function
|
|
215
|
-
const s = Math.min(ee,
|
|
221
|
+
function Ds(e, t = Math.random) {
|
|
222
|
+
const s = Math.min(ee, ws * 2 ** e), n = 1 - se + t() * se * 2;
|
|
216
223
|
return Math.min(ee, Math.round(s * n));
|
|
217
224
|
}
|
|
218
|
-
function
|
|
225
|
+
function xs(e, t, s) {
|
|
219
226
|
return new Promise((n, r) => {
|
|
220
227
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
221
228
|
e.then(
|
|
@@ -228,13 +235,13 @@ function Us(e, t, s) {
|
|
|
228
235
|
);
|
|
229
236
|
});
|
|
230
237
|
}
|
|
231
|
-
class
|
|
238
|
+
class Ee {
|
|
232
239
|
constructor(t, s) {
|
|
233
240
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
234
241
|
...this.state,
|
|
235
|
-
starterPrompts:
|
|
242
|
+
starterPrompts: fn(t.initialStarterPrompts)
|
|
236
243
|
};
|
|
237
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
244
|
+
const n = t.restorePersistedState === !1 ? null : Zn(t.clientId, t.expectedPersistedSessionId);
|
|
238
245
|
n && (this.state = {
|
|
239
246
|
...this.state,
|
|
240
247
|
...n,
|
|
@@ -247,9 +254,9 @@ class be {
|
|
|
247
254
|
assistantDraftRunId: null,
|
|
248
255
|
isThinking: !1,
|
|
249
256
|
lastError: null
|
|
250
|
-
}), this.queuedClientEvents =
|
|
251
|
-
|
|
252
|
-
|
|
257
|
+
}), this.queuedClientEvents = ir(
|
|
258
|
+
tr(t.clientId),
|
|
259
|
+
sr(t.clientId)
|
|
253
260
|
), W(t.clientId, this.queuedClientEvents);
|
|
254
261
|
}
|
|
255
262
|
options;
|
|
@@ -317,16 +324,16 @@ class be {
|
|
|
317
324
|
lastErrorSecuritySettingsUrl: null
|
|
318
325
|
};
|
|
319
326
|
static async init(t) {
|
|
320
|
-
const s = await
|
|
327
|
+
const s = await rs(), n = new Ee({
|
|
321
328
|
...t,
|
|
322
|
-
backendUrl:
|
|
323
|
-
clientId: t.clientId ??
|
|
324
|
-
model: t.model ??
|
|
325
|
-
entrySurface:
|
|
329
|
+
backendUrl: Zs(t.backendUrl ?? ps),
|
|
330
|
+
clientId: t.clientId ?? In(),
|
|
331
|
+
model: t.model ?? fs,
|
|
332
|
+
entrySurface: Qs(t.entrySurface)
|
|
326
333
|
}, s);
|
|
327
334
|
try {
|
|
328
|
-
|
|
329
|
-
|
|
335
|
+
Je().catch((r) => {
|
|
336
|
+
A("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
330
337
|
message: r instanceof Error ? r.message : String(r)
|
|
331
338
|
});
|
|
332
339
|
}), t.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), t.autoConnect !== !1 && await n.connect();
|
|
@@ -357,15 +364,15 @@ class be {
|
|
|
357
364
|
lastError: null
|
|
358
365
|
});
|
|
359
366
|
try {
|
|
360
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
367
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await xs(this.options.tokenProvider(), ys, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
361
368
|
return;
|
|
362
369
|
if (!this.token && !this.options.webSocketFactory)
|
|
363
370
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
364
|
-
const s =
|
|
371
|
+
const s = sn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
365
372
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
366
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (
|
|
367
|
-
},
|
|
368
|
-
this.socket !== n || (this.clearSocketConnectTimer(),
|
|
373
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (A("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
374
|
+
}, Ts), n.addEventListener("open", () => {
|
|
375
|
+
this.socket !== n || (this.clearSocketConnectTimer(), A("web-sdk.agent", "Pluno socket opened", {
|
|
369
376
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
370
377
|
isThinking: this.state.isThinking
|
|
371
378
|
}), !(this.token ? this.sendNow({
|
|
@@ -375,12 +382,12 @@ class be {
|
|
|
375
382
|
transportId: this.transportIdentity.transportId,
|
|
376
383
|
pageUrl: location.href
|
|
377
384
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
378
|
-
this.socket === n && (
|
|
379
|
-
},
|
|
385
|
+
this.socket === n && (A("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
386
|
+
}, Is));
|
|
380
387
|
}), n.addEventListener("message", (r) => {
|
|
381
|
-
this.socket === n && this.handleServerEvent(
|
|
388
|
+
this.socket === n && this.handleServerEvent(pn(r.data));
|
|
382
389
|
}), n.addEventListener("close", (r) => {
|
|
383
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (
|
|
390
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (A("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
384
391
|
code: typeof r?.code == "number" ? r.code : null,
|
|
385
392
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
386
393
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -388,7 +395,7 @@ class be {
|
|
|
388
395
|
isThinking: this.state.isThinking
|
|
389
396
|
}), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
|
|
390
397
|
}), n.addEventListener("error", () => {
|
|
391
|
-
this.socket !== n || this.state.status === "closed" || (
|
|
398
|
+
this.socket !== n || this.state.status === "closed" || (A("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
392
399
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
393
400
|
isThinking: this.state.isThinking
|
|
394
401
|
}), 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());
|
|
@@ -411,7 +418,7 @@ class be {
|
|
|
411
418
|
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;
|
|
412
419
|
}
|
|
413
420
|
destroy() {
|
|
414
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
421
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), or(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
415
422
|
for (const t of Object.values(this.listeners))
|
|
416
423
|
t?.clear();
|
|
417
424
|
}
|
|
@@ -420,7 +427,7 @@ class be {
|
|
|
420
427
|
let i = r.map(Wt);
|
|
421
428
|
if (!n && i.length === 0)
|
|
422
429
|
return null;
|
|
423
|
-
const o = _(), a = s.clientMessageId ??
|
|
430
|
+
const o = _(), a = s.clientMessageId ?? bt(), c = {
|
|
424
431
|
id: `local-${a}`,
|
|
425
432
|
role: "user",
|
|
426
433
|
content: n,
|
|
@@ -471,7 +478,7 @@ class be {
|
|
|
471
478
|
sessionId: this.state.sessionId ?? void 0,
|
|
472
479
|
clientMessageId: a,
|
|
473
480
|
initiatedBy: s.initiatedBy,
|
|
474
|
-
invocation:
|
|
481
|
+
invocation: tn(s.invocation ?? s.initiatedBy),
|
|
475
482
|
entrySurface: this.options.entrySurface,
|
|
476
483
|
content: n,
|
|
477
484
|
pageContent: y && qt() || void 0,
|
|
@@ -487,7 +494,7 @@ class be {
|
|
|
487
494
|
return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
|
|
488
495
|
}
|
|
489
496
|
createLocalAttachment(t) {
|
|
490
|
-
const s =
|
|
497
|
+
const s = bt(), n = {
|
|
491
498
|
id: s,
|
|
492
499
|
name: t.name || "attachment",
|
|
493
500
|
mimeType: me(t),
|
|
@@ -506,7 +513,7 @@ class be {
|
|
|
506
513
|
createdAt: r,
|
|
507
514
|
lastUsedAt: r
|
|
508
515
|
}).catch((i) => {
|
|
509
|
-
|
|
516
|
+
A("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
510
517
|
attachmentId: s,
|
|
511
518
|
name: n.name,
|
|
512
519
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -550,14 +557,14 @@ class be {
|
|
|
550
557
|
throw new et("Failed to upload attachment", c.status);
|
|
551
558
|
return c;
|
|
552
559
|
}, "Failed to upload attachment"), this.setState({ sessionId: o.sessionId });
|
|
553
|
-
const a =
|
|
554
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
560
|
+
const a = Ne(o.attachment, this.options.backendUrl);
|
|
561
|
+
return this.updateAttachmentInState(s.id, a), s.id && Ke(s.id, {
|
|
555
562
|
sessionId: o.sessionId,
|
|
556
563
|
fileUrl: a.fileUrl,
|
|
557
564
|
sandboxPath: a.sandboxPath,
|
|
558
565
|
lastUsedAt: Date.now()
|
|
559
566
|
}).catch((c) => {
|
|
560
|
-
|
|
567
|
+
A("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
561
568
|
attachmentId: s.id,
|
|
562
569
|
name: a.name,
|
|
563
570
|
message: c instanceof Error ? c.message : String(c)
|
|
@@ -581,7 +588,7 @@ class be {
|
|
|
581
588
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
582
589
|
if (n.ok)
|
|
583
590
|
return await n.json();
|
|
584
|
-
if (
|
|
591
|
+
if (Sr(n.status) && this.options.tokenProvider && !s) {
|
|
585
592
|
s = !0;
|
|
586
593
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
587
594
|
if (r.ok)
|
|
@@ -625,10 +632,10 @@ class be {
|
|
|
625
632
|
});
|
|
626
633
|
}
|
|
627
634
|
listSessions(t = {}) {
|
|
628
|
-
const s =
|
|
635
|
+
const s = bt(), n = new Promise((i, o) => {
|
|
629
636
|
const a = window.setTimeout(() => {
|
|
630
637
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
631
|
-
},
|
|
638
|
+
}, Rs);
|
|
632
639
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
633
640
|
}), r = {
|
|
634
641
|
type: "sessions.list",
|
|
@@ -676,7 +683,7 @@ class be {
|
|
|
676
683
|
try {
|
|
677
684
|
return s.send(JSON.stringify(t)), !0;
|
|
678
685
|
} catch (n) {
|
|
679
|
-
return
|
|
686
|
+
return A("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
680
687
|
message: n instanceof Error ? n.message : String(n),
|
|
681
688
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
682
689
|
isThinking: this.state.isThinking
|
|
@@ -687,7 +694,7 @@ class be {
|
|
|
687
694
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
688
695
|
return;
|
|
689
696
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
690
|
-
const t =
|
|
697
|
+
const t = nn();
|
|
691
698
|
this.sendNow(
|
|
692
699
|
k({
|
|
693
700
|
type: "starter_prompts.page_context",
|
|
@@ -698,13 +705,13 @@ class be {
|
|
|
698
705
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
699
706
|
}
|
|
700
707
|
startStarterPromptUrlWatcher() {
|
|
701
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
708
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = rn(() => this.handleStarterPromptUrlChange()));
|
|
702
709
|
}
|
|
703
710
|
handleStarterPromptUrlChange() {
|
|
704
711
|
const t = location.href;
|
|
705
712
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
706
713
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
707
|
-
},
|
|
714
|
+
}, Us));
|
|
708
715
|
}
|
|
709
716
|
refreshStarterPromptsForCurrentUrl() {
|
|
710
717
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -738,19 +745,19 @@ class be {
|
|
|
738
745
|
this.clearHeartbeatAckTimer();
|
|
739
746
|
return;
|
|
740
747
|
}
|
|
741
|
-
if (
|
|
748
|
+
if (Os(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
742
749
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
|
|
743
|
-
const s =
|
|
744
|
-
|
|
750
|
+
const s = gn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
751
|
+
A("web-sdk.agent", "Received auth.ok appearance", {
|
|
745
752
|
hasAppearance: n,
|
|
746
753
|
rawAppearance: t.appearance,
|
|
747
754
|
normalizedAppearance: s
|
|
748
|
-
}), this.runtimeHelperJavascript =
|
|
755
|
+
}), this.runtimeHelperJavascript = mn(t.runtimeHelpers)?.javascript ?? null;
|
|
749
756
|
const r = ce(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
750
|
-
user:
|
|
757
|
+
user: wn(t.user),
|
|
751
758
|
status: "connected"
|
|
752
759
|
};
|
|
753
|
-
(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 && !
|
|
760
|
+
(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 && !an() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
754
761
|
type: "page.upsert",
|
|
755
762
|
sessionId: this.state.sessionId,
|
|
756
763
|
page: _(),
|
|
@@ -766,24 +773,24 @@ class be {
|
|
|
766
773
|
return;
|
|
767
774
|
}
|
|
768
775
|
if (t.type === "conversation.state") {
|
|
769
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
776
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Mn(
|
|
770
777
|
t.assistantDraft
|
|
771
778
|
), r = n !== void 0;
|
|
772
779
|
this.rememberUserMessageClientMessageIds(s);
|
|
773
|
-
const i =
|
|
780
|
+
const i = $n(s);
|
|
774
781
|
if (i) {
|
|
775
|
-
const f =
|
|
782
|
+
const f = Wn(s, i);
|
|
776
783
|
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
777
784
|
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
778
785
|
f
|
|
779
786
|
);
|
|
780
787
|
}
|
|
781
788
|
const o = s.filter((f) => {
|
|
782
|
-
const
|
|
783
|
-
return !he(
|
|
784
|
-
}), a =
|
|
789
|
+
const T = L(f);
|
|
790
|
+
return !he(T) && (!i || !Pt(T));
|
|
791
|
+
}), a = vn(
|
|
785
792
|
this.state.messages,
|
|
786
|
-
|
|
793
|
+
An(o, this.options.backendUrl)
|
|
787
794
|
), c = de(a), l = !r && s.some(
|
|
788
795
|
(f) => fe(
|
|
789
796
|
L(f),
|
|
@@ -792,13 +799,13 @@ class be {
|
|
|
792
799
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
793
800
|
this.state.assistantDraftRunId
|
|
794
801
|
)
|
|
795
|
-
), d = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, y = c && (!d || l), m =
|
|
796
|
-
if (!c &&
|
|
802
|
+
), d = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, y = c && (!d || l), m = Bn(a), u = y && m;
|
|
803
|
+
if (!c && Fn(this.state.messages, s))
|
|
797
804
|
return;
|
|
798
|
-
this.lastUserMessagePageUrl =
|
|
805
|
+
this.lastUserMessagePageUrl = Hn(s);
|
|
799
806
|
const h = y ? null : Ut(s);
|
|
800
807
|
if (this.latestRecoverableClientMessageId = h, m && this.clearRetryTimers(), this.setState({
|
|
801
|
-
sessionId:
|
|
808
|
+
sessionId: E(t.session, "id") ?? this.state.sessionId,
|
|
802
809
|
messages: a,
|
|
803
810
|
...r ? {
|
|
804
811
|
assistantDraft: n?.content ?? "",
|
|
@@ -829,7 +836,7 @@ class be {
|
|
|
829
836
|
lastError: null
|
|
830
837
|
} : {}
|
|
831
838
|
}), y ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (p || h) && (h && (this.activeClientMessageId = h), this.markThinkingProgress()), i) {
|
|
832
|
-
const f =
|
|
839
|
+
const f = E(t.session, "id") ?? this.state.sessionId;
|
|
833
840
|
f && this.retryAfterInterruptedRun(f, i);
|
|
834
841
|
}
|
|
835
842
|
return;
|
|
@@ -837,13 +844,13 @@ class be {
|
|
|
837
844
|
if (t.type === "sessions.page") {
|
|
838
845
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
839
846
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
840
|
-
sessions:
|
|
847
|
+
sessions: Sn(t.sessions),
|
|
841
848
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
842
849
|
}));
|
|
843
850
|
return;
|
|
844
851
|
}
|
|
845
852
|
if (t.type === "session.updated") {
|
|
846
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
853
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: E(t.session, "id") ?? this.state.sessionId });
|
|
847
854
|
return;
|
|
848
855
|
}
|
|
849
856
|
if (t.type === "session.item") {
|
|
@@ -851,7 +858,7 @@ class be {
|
|
|
851
858
|
const s = L(t.item);
|
|
852
859
|
if (Pt(s)) {
|
|
853
860
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
854
|
-
const r =
|
|
861
|
+
const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? v(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
855
862
|
if (r && a) {
|
|
856
863
|
this.retryAfterInterruptedRun(r, a);
|
|
857
864
|
return;
|
|
@@ -868,7 +875,7 @@ class be {
|
|
|
868
875
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
869
876
|
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), q(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
870
877
|
const i = t.item.data;
|
|
871
|
-
|
|
878
|
+
zn(i) && this.clearRunAckResyncRetryTimer();
|
|
872
879
|
const o = Ce(this.state.messages, n), a = de(o), c = fe(
|
|
873
880
|
i,
|
|
874
881
|
this.state.assistantDraft,
|
|
@@ -929,9 +936,9 @@ class be {
|
|
|
929
936
|
}
|
|
930
937
|
if (t.type === "tool.call") {
|
|
931
938
|
this.clearRunAckResyncRetryTimer();
|
|
932
|
-
const s =
|
|
939
|
+
const s = Dn(t);
|
|
933
940
|
if (s) {
|
|
934
|
-
const n =
|
|
941
|
+
const n = Pn(
|
|
935
942
|
this.state.messages,
|
|
936
943
|
s
|
|
937
944
|
);
|
|
@@ -972,7 +979,7 @@ class be {
|
|
|
972
979
|
return;
|
|
973
980
|
}
|
|
974
981
|
o && r && i && (this.retryableClientMessageId = i);
|
|
975
|
-
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c =
|
|
982
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = en(a.message);
|
|
976
983
|
c && console.error(c), this.setState({
|
|
977
984
|
status: "error",
|
|
978
985
|
isThinking: !1,
|
|
@@ -998,7 +1005,7 @@ class be {
|
|
|
998
1005
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
999
1006
|
return !0;
|
|
1000
1007
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1001
|
-
if (i >=
|
|
1008
|
+
if (i >= J)
|
|
1002
1009
|
return !1;
|
|
1003
1010
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1004
1011
|
const o = V(
|
|
@@ -1018,7 +1025,7 @@ class be {
|
|
|
1018
1025
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1019
1026
|
return;
|
|
1020
1027
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1021
|
-
if (n >=
|
|
1028
|
+
if (n >= J) {
|
|
1022
1029
|
this.retryableClientMessageId = s, this.setState({
|
|
1023
1030
|
isThinking: !1,
|
|
1024
1031
|
lastError: "Pluno could not finish this message. Try it again.",
|
|
@@ -1037,7 +1044,7 @@ class be {
|
|
|
1037
1044
|
}
|
|
1038
1045
|
rememberUserMessageClientMessageIds(t) {
|
|
1039
1046
|
for (const s of t) {
|
|
1040
|
-
const n =
|
|
1047
|
+
const n = E(s, "id"), r = L(s);
|
|
1041
1048
|
n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
|
|
1042
1049
|
}
|
|
1043
1050
|
}
|
|
@@ -1067,10 +1074,10 @@ class be {
|
|
|
1067
1074
|
scheduleRunAckWatchdog(t) {
|
|
1068
1075
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1069
1076
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1070
|
-
},
|
|
1077
|
+
}, Ss);
|
|
1071
1078
|
}
|
|
1072
1079
|
recoverMissedRunAck(t) {
|
|
1073
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (
|
|
1080
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (A("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
1074
1081
|
sessionId: this.state.sessionId,
|
|
1075
1082
|
clientMessageId: t
|
|
1076
1083
|
}), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
|
|
@@ -1078,12 +1085,12 @@ class be {
|
|
|
1078
1085
|
scheduleRunAckResyncRetry(t) {
|
|
1079
1086
|
this.clearRunAckResyncRetryTimer();
|
|
1080
1087
|
const s = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1081
|
-
s >=
|
|
1088
|
+
s >= J || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1082
1089
|
this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
|
|
1083
1090
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1084
1091
|
isThinking: !0,
|
|
1085
1092
|
lastError: null
|
|
1086
|
-
}),
|
|
1093
|
+
}), A("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
1087
1094
|
sessionId: this.state.sessionId,
|
|
1088
1095
|
clientMessageId: t
|
|
1089
1096
|
}), this.state.sessionId ? this.send({
|
|
@@ -1092,7 +1099,7 @@ class be {
|
|
|
1092
1099
|
clientMessageId: t,
|
|
1093
1100
|
automatic: !0
|
|
1094
1101
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ne)));
|
|
1095
|
-
}, V(s,
|
|
1102
|
+
}, V(s, Es)));
|
|
1096
1103
|
}
|
|
1097
1104
|
clearRunAckResyncRetryTimer() {
|
|
1098
1105
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1105,7 +1112,7 @@ class be {
|
|
|
1105
1112
|
return;
|
|
1106
1113
|
const t = this.activeClientMessageId;
|
|
1107
1114
|
if (!t) {
|
|
1108
|
-
|
|
1115
|
+
A("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
1109
1116
|
sessionId: this.state.sessionId
|
|
1110
1117
|
}), this.setState({
|
|
1111
1118
|
isThinking: !1,
|
|
@@ -1115,8 +1122,8 @@ class be {
|
|
|
1115
1122
|
return;
|
|
1116
1123
|
}
|
|
1117
1124
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1118
|
-
if (n >=
|
|
1119
|
-
|
|
1125
|
+
if (n >= J) {
|
|
1126
|
+
A("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1120
1127
|
sessionId: this.state.sessionId,
|
|
1121
1128
|
clientMessageId: t
|
|
1122
1129
|
}), this.retryableClientMessageId = t, this.setState({
|
|
@@ -1127,18 +1134,18 @@ class be {
|
|
|
1127
1134
|
return;
|
|
1128
1135
|
}
|
|
1129
1136
|
if (s < 1) {
|
|
1130
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1,
|
|
1137
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, A("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
1131
1138
|
sessionId: this.state.sessionId,
|
|
1132
1139
|
clientMessageId: t,
|
|
1133
1140
|
resyncAttempts: s + 1
|
|
1134
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1141
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(As);
|
|
1135
1142
|
return;
|
|
1136
1143
|
}
|
|
1137
1144
|
this.setState({
|
|
1138
1145
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1139
1146
|
isThinking: !0,
|
|
1140
1147
|
lastError: null
|
|
1141
|
-
}),
|
|
1148
|
+
}), A("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
1142
1149
|
sessionId: this.state.sessionId,
|
|
1143
1150
|
clientMessageId: t,
|
|
1144
1151
|
retryAttempts: n + 1
|
|
@@ -1160,13 +1167,13 @@ class be {
|
|
|
1160
1167
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
|
|
1161
1168
|
}
|
|
1162
1169
|
async executeToolCall(t) {
|
|
1163
|
-
const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i =
|
|
1170
|
+
const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = O(
|
|
1164
1171
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
1165
1172
|
), o = t.rawInput;
|
|
1166
1173
|
if (!s || !n || !r)
|
|
1167
1174
|
return;
|
|
1168
1175
|
const a = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1169
|
-
if (r !== "execute_code" && !a || !
|
|
1176
|
+
if (r !== "execute_code" && !a || !ur(o)) {
|
|
1170
1177
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1171
1178
|
type: "tool.result",
|
|
1172
1179
|
sessionId: s,
|
|
@@ -1198,7 +1205,7 @@ class be {
|
|
|
1198
1205
|
});
|
|
1199
1206
|
return;
|
|
1200
1207
|
}
|
|
1201
|
-
const c =
|
|
1208
|
+
const c = qs(this.state.messages);
|
|
1202
1209
|
this.activeBrowserToolCalls.set(n, {
|
|
1203
1210
|
event: {
|
|
1204
1211
|
type: "tool.result",
|
|
@@ -1216,7 +1223,7 @@ class be {
|
|
|
1216
1223
|
let l = null, d;
|
|
1217
1224
|
l = await this.executeRuntimeHelper(), d = await oe(
|
|
1218
1225
|
o,
|
|
1219
|
-
|
|
1226
|
+
Vs(t.runtimeContext, this.options.backendUrl)
|
|
1220
1227
|
).catch((p) => ({
|
|
1221
1228
|
ok: !1,
|
|
1222
1229
|
exception: {
|
|
@@ -1229,11 +1236,11 @@ class be {
|
|
|
1229
1236
|
toolName: r,
|
|
1230
1237
|
summary: o.summary,
|
|
1231
1238
|
rawInput: k(o),
|
|
1232
|
-
rawOutput: k(
|
|
1233
|
-
}),
|
|
1239
|
+
rawOutput: k(yn(d, l))
|
|
1240
|
+
}), er(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1234
1241
|
}
|
|
1235
1242
|
setToolMessageLoading(t, s) {
|
|
1236
|
-
const n =
|
|
1243
|
+
const n = Un(
|
|
1237
1244
|
this.state.messages,
|
|
1238
1245
|
t,
|
|
1239
1246
|
s
|
|
@@ -1251,10 +1258,10 @@ class be {
|
|
|
1251
1258
|
};
|
|
1252
1259
|
}
|
|
1253
1260
|
installSessionUserFilesApi(t) {
|
|
1254
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1261
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Hs(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1255
1262
|
}
|
|
1256
1263
|
cleanupSessionUserFilesApi() {
|
|
1257
|
-
this.sessionUserFilesApiCleanup && (
|
|
1264
|
+
this.sessionUserFilesApiCleanup && (Ks(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1258
1265
|
}
|
|
1259
1266
|
async executeRuntimeHelper() {
|
|
1260
1267
|
if (!this.runtimeHelperJavascript?.trim())
|
|
@@ -1262,15 +1269,15 @@ class be {
|
|
|
1262
1269
|
const t = await oe({
|
|
1263
1270
|
javascript: this.runtimeHelperJavascript
|
|
1264
1271
|
});
|
|
1265
|
-
return t.ok === !1 ?
|
|
1272
|
+
return t.ok === !1 ? Tn(t) : null;
|
|
1266
1273
|
}
|
|
1267
1274
|
enableNetworkCapture() {
|
|
1268
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1269
|
-
|
|
1275
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = vs((t) => {
|
|
1276
|
+
mr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1270
1277
|
}));
|
|
1271
1278
|
}
|
|
1272
1279
|
enqueueNetworkEvent(t) {
|
|
1273
|
-
this.queuedNetworkEvents.length >=
|
|
1280
|
+
this.queuedNetworkEvents.length >= ks || (this.queuedNetworkEvents.push(gr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1274
1281
|
this.networkBatchTimer = null;
|
|
1275
1282
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1276
1283
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1279,15 +1286,15 @@ class be {
|
|
|
1279
1286
|
page: _(),
|
|
1280
1287
|
events: s
|
|
1281
1288
|
});
|
|
1282
|
-
},
|
|
1289
|
+
}, bs)));
|
|
1283
1290
|
}
|
|
1284
1291
|
scheduleReconnect() {
|
|
1285
1292
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1286
1293
|
return;
|
|
1287
|
-
const t =
|
|
1294
|
+
const t = Ds(this.reconnectAttempts);
|
|
1288
1295
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1289
1296
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1290
|
-
|
|
1297
|
+
A("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
1291
1298
|
message: s instanceof Error ? s.message : String(s),
|
|
1292
1299
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1293
1300
|
isThinking: this.state.isThinking
|
|
@@ -1299,9 +1306,9 @@ class be {
|
|
|
1299
1306
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
1300
1307
|
const t = this.socket;
|
|
1301
1308
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1302
|
-
this.socket === t && (
|
|
1303
|
-
},
|
|
1304
|
-
},
|
|
1309
|
+
this.socket === t && (A("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1310
|
+
}, ms));
|
|
1311
|
+
}, gs);
|
|
1305
1312
|
}
|
|
1306
1313
|
stopHeartbeat() {
|
|
1307
1314
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1327,20 +1334,20 @@ class be {
|
|
|
1327
1334
|
...t,
|
|
1328
1335
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1329
1336
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1330
|
-
},
|
|
1337
|
+
}, Qn(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
1331
1338
|
}
|
|
1332
1339
|
emit(t, s) {
|
|
1333
1340
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1334
1341
|
}
|
|
1335
1342
|
}
|
|
1336
|
-
const
|
|
1337
|
-
function
|
|
1338
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1343
|
+
const St = /* @__PURE__ */ new WeakMap();
|
|
1344
|
+
function vs(e) {
|
|
1345
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Ns();
|
|
1339
1346
|
return t.subscribers.add(e), () => {
|
|
1340
1347
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1341
1348
|
};
|
|
1342
1349
|
}
|
|
1343
|
-
function
|
|
1350
|
+
function Ns() {
|
|
1344
1351
|
const e = /* @__PURE__ */ new Set(), t = (y) => {
|
|
1345
1352
|
e.forEach((m) => {
|
|
1346
1353
|
try {
|
|
@@ -1353,24 +1360,24 @@ function xs() {
|
|
|
1353
1360
|
let f;
|
|
1354
1361
|
try {
|
|
1355
1362
|
f = s.call(this, m, u);
|
|
1356
|
-
} catch (
|
|
1357
|
-
throw
|
|
1363
|
+
} catch (T) {
|
|
1364
|
+
throw T;
|
|
1358
1365
|
}
|
|
1359
1366
|
try {
|
|
1360
|
-
const
|
|
1361
|
-
if (!
|
|
1367
|
+
const T = m instanceof Request ? m : null, x = dr(m, T), I = Oe(u?.headers ?? T?.headers);
|
|
1368
|
+
if (!N(x, I, u?.body)) {
|
|
1362
1369
|
const H = {
|
|
1363
1370
|
requestId: kt("fetch"),
|
|
1364
|
-
url: C(x,
|
|
1365
|
-
method: (u?.method ??
|
|
1366
|
-
requestHeaders:
|
|
1371
|
+
url: C(x, At),
|
|
1372
|
+
method: (u?.method ?? T?.method ?? "GET").toUpperCase(),
|
|
1373
|
+
requestHeaders: I,
|
|
1367
1374
|
requestBody: ye(u?.body),
|
|
1368
1375
|
resourceType: "fetch",
|
|
1369
1376
|
startedAt: new Date(h).toISOString()
|
|
1370
1377
|
};
|
|
1371
1378
|
f.then(
|
|
1372
1379
|
(R) => {
|
|
1373
|
-
|
|
1380
|
+
hr(R, H, h, t).catch(() => {
|
|
1374
1381
|
t({
|
|
1375
1382
|
...H,
|
|
1376
1383
|
responseStatus: R.status,
|
|
@@ -1390,29 +1397,29 @@ function xs() {
|
|
|
1390
1397
|
} catch {
|
|
1391
1398
|
}
|
|
1392
1399
|
return f;
|
|
1393
|
-
}, a = function(m, u, h, f,
|
|
1394
|
-
const x = n.call(this, m, u, h ?? !0, f ?? void 0,
|
|
1395
|
-
return
|
|
1400
|
+
}, a = function(m, u, h, f, T) {
|
|
1401
|
+
const x = n.call(this, m, u, h ?? !0, f ?? void 0, T ?? void 0), I = typeof u == "string" ? u : u.toString();
|
|
1402
|
+
return St.set(this, {
|
|
1396
1403
|
requestId: kt("xhr"),
|
|
1397
1404
|
method: String(m ?? "GET").toUpperCase(),
|
|
1398
|
-
url: C(
|
|
1405
|
+
url: C(I, At),
|
|
1399
1406
|
requestHeaders: {},
|
|
1400
1407
|
startedAtMs: Date.now(),
|
|
1401
1408
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1402
|
-
excluded:
|
|
1409
|
+
excluded: N(I)
|
|
1403
1410
|
}), x;
|
|
1404
1411
|
}, c = function(m, u) {
|
|
1405
|
-
const h = r.call(this, m, u), f =
|
|
1406
|
-
return f && Object.keys(f.requestHeaders).length < Bt && (f.requestHeaders[m] = jt(m, u), f.excluded = f.excluded ||
|
|
1412
|
+
const h = r.call(this, m, u), f = St.get(this);
|
|
1413
|
+
return f && Object.keys(f.requestHeaders).length < Bt && (f.requestHeaders[m] = jt(m, u), f.excluded = f.excluded || N(f.url, f.requestHeaders)), h;
|
|
1407
1414
|
}, l = function(m) {
|
|
1408
1415
|
try {
|
|
1409
|
-
const u =
|
|
1410
|
-
u && (u.excluded = u.excluded ||
|
|
1416
|
+
const u = St.get(this);
|
|
1417
|
+
u && (u.excluded = u.excluded || N(u.url, u.requestHeaders, m), u.requestBody = ye(m), u.excluded || this.addEventListener(
|
|
1411
1418
|
"loadend",
|
|
1412
1419
|
() => {
|
|
1413
1420
|
queueMicrotask(() => {
|
|
1414
1421
|
try {
|
|
1415
|
-
const h =
|
|
1422
|
+
const h = Tr(this.getAllResponseHeaders());
|
|
1416
1423
|
t({
|
|
1417
1424
|
requestId: u.requestId,
|
|
1418
1425
|
url: u.url,
|
|
@@ -1422,7 +1429,7 @@ function xs() {
|
|
|
1422
1429
|
resourceType: "xhr",
|
|
1423
1430
|
responseStatus: this.status,
|
|
1424
1431
|
responseHeaders: h,
|
|
1425
|
-
responseBody:
|
|
1432
|
+
responseBody: fr(this, h),
|
|
1426
1433
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1427
1434
|
startedAt: u.startedAt,
|
|
1428
1435
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -1459,12 +1466,12 @@ function xs() {
|
|
|
1459
1466
|
d = new PerformanceObserver((y) => {
|
|
1460
1467
|
for (const m of y.getEntries()) {
|
|
1461
1468
|
const u = m;
|
|
1462
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
1469
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || N(u.name))
|
|
1463
1470
|
continue;
|
|
1464
1471
|
const h = performance.timeOrigin + u.startTime;
|
|
1465
1472
|
t({
|
|
1466
1473
|
requestId: kt("resource"),
|
|
1467
|
-
url: C(u.name,
|
|
1474
|
+
url: C(u.name, At),
|
|
1468
1475
|
method: "GET",
|
|
1469
1476
|
resourceType: "resource",
|
|
1470
1477
|
responseStatus: u.responseStatus,
|
|
@@ -1503,7 +1510,7 @@ function xs() {
|
|
|
1503
1510
|
};
|
|
1504
1511
|
return window.__plunoProductAgentNetworkCapture = p, p;
|
|
1505
1512
|
}
|
|
1506
|
-
function
|
|
1513
|
+
function A(e, t, s) {
|
|
1507
1514
|
if (typeof window > "u")
|
|
1508
1515
|
return;
|
|
1509
1516
|
const n = window, r = {
|
|
@@ -1518,11 +1525,11 @@ function ie(e) {
|
|
|
1518
1525
|
const t = typeof e == "function" ? e() : e;
|
|
1519
1526
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1520
1527
|
}
|
|
1521
|
-
function
|
|
1528
|
+
function Os(e) {
|
|
1522
1529
|
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";
|
|
1523
1530
|
}
|
|
1524
|
-
const
|
|
1525
|
-
function
|
|
1531
|
+
const Ls = 5e3, Bs = 12e4;
|
|
1532
|
+
function qs(e) {
|
|
1526
1533
|
const t = [];
|
|
1527
1534
|
for (const s of e)
|
|
1528
1535
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1533,30 +1540,30 @@ function Ls(e) {
|
|
|
1533
1540
|
});
|
|
1534
1541
|
return t;
|
|
1535
1542
|
}
|
|
1536
|
-
function
|
|
1543
|
+
function Hs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1537
1544
|
const n = [
|
|
1538
|
-
|
|
1539
|
-
|
|
1545
|
+
$s(),
|
|
1546
|
+
Fs()
|
|
1540
1547
|
].filter((r) => typeof r == "function");
|
|
1541
1548
|
return () => {
|
|
1542
1549
|
for (const r of n.reverse())
|
|
1543
1550
|
r();
|
|
1544
1551
|
};
|
|
1545
1552
|
}
|
|
1546
|
-
function
|
|
1547
|
-
return
|
|
1553
|
+
function Fs() {
|
|
1554
|
+
return Ie(globalThis, "getPageSnapshot", async () => qt());
|
|
1548
1555
|
}
|
|
1549
|
-
function
|
|
1550
|
-
return
|
|
1551
|
-
inspectImage: async (t, s) => await
|
|
1556
|
+
function $s() {
|
|
1557
|
+
return Ie(globalThis, "pageImages", {
|
|
1558
|
+
inspectImage: async (t, s) => await Ws(t, s)
|
|
1552
1559
|
});
|
|
1553
1560
|
}
|
|
1554
|
-
async function
|
|
1555
|
-
const s =
|
|
1561
|
+
async function Ws(e, t = {}) {
|
|
1562
|
+
const s = Xs(t.name), n = await js(e);
|
|
1556
1563
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1557
1564
|
type: "pluno.pageImages.inspectImage",
|
|
1558
1565
|
imageAttached: !1,
|
|
1559
|
-
imageAttachmentError:
|
|
1566
|
+
imageAttachmentError: Ae
|
|
1560
1567
|
} : {
|
|
1561
1568
|
type: "pluno.pageImages.inspectImage",
|
|
1562
1569
|
imageAttached: !0,
|
|
@@ -1570,15 +1577,15 @@ async function Fs(e, t = {}) {
|
|
|
1570
1577
|
imageAttachmentError: n.error
|
|
1571
1578
|
};
|
|
1572
1579
|
}
|
|
1573
|
-
async function
|
|
1574
|
-
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:
|
|
1580
|
+
async function js(e) {
|
|
1581
|
+
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: Ae } : {
|
|
1575
1582
|
ok: !0,
|
|
1576
1583
|
mimeType: e.type,
|
|
1577
1584
|
sizeBytes: e.size,
|
|
1578
|
-
dataUrl: await
|
|
1579
|
-
} : { 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." } :
|
|
1585
|
+
dataUrl: await Js(e)
|
|
1586
|
+
} : { 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." } : zs(e);
|
|
1580
1587
|
}
|
|
1581
|
-
function
|
|
1588
|
+
function zs(e) {
|
|
1582
1589
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1583
1590
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1584
1591
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1589,7 +1596,7 @@ function Ws(e) {
|
|
|
1589
1596
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1590
1597
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1591
1598
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1592
|
-
const o =
|
|
1599
|
+
const o = Gs(i);
|
|
1593
1600
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1594
1601
|
ok: !0,
|
|
1595
1602
|
mimeType: r,
|
|
@@ -1597,22 +1604,22 @@ function Ws(e) {
|
|
|
1597
1604
|
dataUrl: `data:${r};base64,${i}`
|
|
1598
1605
|
};
|
|
1599
1606
|
}
|
|
1600
|
-
function
|
|
1607
|
+
function Gs(e) {
|
|
1601
1608
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1602
1609
|
return null;
|
|
1603
1610
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1604
1611
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1605
1612
|
}
|
|
1606
|
-
function
|
|
1613
|
+
function Xs(e) {
|
|
1607
1614
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1608
1615
|
}
|
|
1609
|
-
function
|
|
1616
|
+
function Ks(e) {
|
|
1610
1617
|
try {
|
|
1611
1618
|
e();
|
|
1612
1619
|
} catch {
|
|
1613
1620
|
}
|
|
1614
1621
|
}
|
|
1615
|
-
function
|
|
1622
|
+
function Js(e) {
|
|
1616
1623
|
return new Promise((t, s) => {
|
|
1617
1624
|
const n = new FileReader();
|
|
1618
1625
|
n.onload = () => {
|
|
@@ -1626,7 +1633,7 @@ function Xs(e) {
|
|
|
1626
1633
|
}
|
|
1627
1634
|
async function oe(e, t) {
|
|
1628
1635
|
const s = Object.getPrototypeOf(async function() {
|
|
1629
|
-
}).constructor, n = e.timeoutMs ??
|
|
1636
|
+
}).constructor, n = e.timeoutMs ?? Ls, r = Date.now(), i = [];
|
|
1630
1637
|
let o;
|
|
1631
1638
|
const a = {
|
|
1632
1639
|
log: console.log,
|
|
@@ -1644,7 +1651,7 @@ async function oe(e, t) {
|
|
|
1644
1651
|
o = window.setTimeout(() => p(l), n);
|
|
1645
1652
|
})
|
|
1646
1653
|
]);
|
|
1647
|
-
return d === l ?
|
|
1654
|
+
return d === l ? Ys(n) : {
|
|
1648
1655
|
ok: !0,
|
|
1649
1656
|
result: d,
|
|
1650
1657
|
console: i,
|
|
@@ -1673,7 +1680,7 @@ async function oe(e, t) {
|
|
|
1673
1680
|
t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
1674
1681
|
}
|
|
1675
1682
|
}
|
|
1676
|
-
function
|
|
1683
|
+
function Vs(e, t) {
|
|
1677
1684
|
if (!e || typeof e != "object")
|
|
1678
1685
|
return;
|
|
1679
1686
|
const s = e.sandboxFilesToken;
|
|
@@ -1683,7 +1690,7 @@ function Js(e, t) {
|
|
|
1683
1690
|
const r = () => {
|
|
1684
1691
|
if (!n)
|
|
1685
1692
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
1686
|
-
}, i = async (a, c) => await
|
|
1693
|
+
}, i = async (a, c) => await ls(`${t.replace(/\/$/, "")}${a}`, c);
|
|
1687
1694
|
return {
|
|
1688
1695
|
value: Object.freeze({
|
|
1689
1696
|
upload: async (a) => {
|
|
@@ -1717,7 +1724,7 @@ function Js(e, t) {
|
|
|
1717
1724
|
}
|
|
1718
1725
|
};
|
|
1719
1726
|
}
|
|
1720
|
-
function
|
|
1727
|
+
function Ys(e) {
|
|
1721
1728
|
return {
|
|
1722
1729
|
ok: !1,
|
|
1723
1730
|
exception: {
|
|
@@ -1731,10 +1738,10 @@ function Ks(e) {
|
|
|
1731
1738
|
}
|
|
1732
1739
|
};
|
|
1733
1740
|
}
|
|
1734
|
-
function
|
|
1741
|
+
function Zs(e) {
|
|
1735
1742
|
return e.replace(/\/+$/, "");
|
|
1736
1743
|
}
|
|
1737
|
-
function
|
|
1744
|
+
function Qs(e) {
|
|
1738
1745
|
const t = {
|
|
1739
1746
|
sidepanel: "extension_sidepanel",
|
|
1740
1747
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -1746,13 +1753,13 @@ function Ys(e) {
|
|
|
1746
1753
|
};
|
|
1747
1754
|
return e && e in t ? t[e] : e ?? "embedded_custom_ui";
|
|
1748
1755
|
}
|
|
1749
|
-
function
|
|
1756
|
+
function tn(e) {
|
|
1750
1757
|
return e === "pluno" ? "scheduled_continuation" : e ?? "user";
|
|
1751
1758
|
}
|
|
1752
|
-
function
|
|
1759
|
+
function en(e, t = location.origin) {
|
|
1753
1760
|
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;
|
|
1754
1761
|
}
|
|
1755
|
-
function
|
|
1762
|
+
function sn(e) {
|
|
1756
1763
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1757
1764
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1758
1765
|
}
|
|
@@ -1765,19 +1772,19 @@ function _() {
|
|
|
1765
1772
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1766
1773
|
};
|
|
1767
1774
|
}
|
|
1768
|
-
function
|
|
1775
|
+
function nn() {
|
|
1769
1776
|
return {
|
|
1770
1777
|
pageUrl: location.href,
|
|
1771
1778
|
pageTitle: document.title,
|
|
1772
1779
|
htmlContent: qt()
|
|
1773
1780
|
};
|
|
1774
1781
|
}
|
|
1775
|
-
function
|
|
1776
|
-
return tt.add(e), Y || (Y =
|
|
1782
|
+
function rn(e) {
|
|
1783
|
+
return tt.add(e), Y || (Y = on()), () => {
|
|
1777
1784
|
tt.delete(e), tt.size === 0 && (Y?.(), Y = null);
|
|
1778
1785
|
};
|
|
1779
1786
|
}
|
|
1780
|
-
function
|
|
1787
|
+
function on() {
|
|
1781
1788
|
const e = () => {
|
|
1782
1789
|
for (const i of Array.from(tt))
|
|
1783
1790
|
i();
|
|
@@ -1792,28 +1799,28 @@ function nn() {
|
|
|
1792
1799
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
1793
1800
|
};
|
|
1794
1801
|
}
|
|
1795
|
-
function
|
|
1802
|
+
function an() {
|
|
1796
1803
|
return _e()?.surface === "browser_extension_sdk_preview";
|
|
1797
1804
|
}
|
|
1798
1805
|
function qt() {
|
|
1799
1806
|
if (!document.body)
|
|
1800
1807
|
return "";
|
|
1801
1808
|
const e = [], t = [], s = (h, f) => {
|
|
1802
|
-
const
|
|
1803
|
-
!
|
|
1809
|
+
const T = B(f);
|
|
1810
|
+
!T || t.includes(T) || (e.push([h, T]), t.push(T));
|
|
1804
1811
|
};
|
|
1805
1812
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
1806
1813
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
1807
|
-
(h) =>
|
|
1814
|
+
(h) => be(h) && !h.parentElement?.closest(n)
|
|
1808
1815
|
);
|
|
1809
1816
|
for (const h of r.slice(0, 3))
|
|
1810
|
-
s("Active overlay",
|
|
1811
|
-
const i =
|
|
1812
|
-
s("Main page content", o), s("Additional visible page text",
|
|
1817
|
+
s("Active overlay", Et(j(h), t));
|
|
1818
|
+
const i = cn(), o = i ? Et(j(i), t) : "";
|
|
1819
|
+
s("Main page content", o), s("Additional visible page text", Et(j(document.body), t));
|
|
1813
1820
|
const a = e.map(([h, f]) => `${h}:
|
|
1814
1821
|
${f}`).join(`
|
|
1815
1822
|
|
|
1816
|
-
`).trim().slice(0, 12e3), c =
|
|
1823
|
+
`).trim().slice(0, 12e3), c = ln(r, i).trim(), l = `Simplified DOM outline:
|
|
1817
1824
|
`, d = `
|
|
1818
1825
|
|
|
1819
1826
|
Visible page text:
|
|
@@ -1831,20 +1838,20 @@ function B(e) {
|
|
|
1831
1838
|
|
|
1832
1839
|
`).trim();
|
|
1833
1840
|
}
|
|
1834
|
-
function
|
|
1841
|
+
function Et(e, t) {
|
|
1835
1842
|
let s = B(e);
|
|
1836
1843
|
for (const n of t)
|
|
1837
1844
|
s = s.replace(n, "");
|
|
1838
1845
|
return B(s);
|
|
1839
1846
|
}
|
|
1840
|
-
function
|
|
1847
|
+
function be(e) {
|
|
1841
1848
|
const t = window.getComputedStyle(e);
|
|
1842
1849
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
1843
1850
|
}
|
|
1844
|
-
function
|
|
1845
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
1851
|
+
function cn() {
|
|
1852
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(be).sort((e, t) => j(t).length - j(e).length)[0] ?? null;
|
|
1846
1853
|
}
|
|
1847
|
-
function
|
|
1854
|
+
function ln(e, t) {
|
|
1848
1855
|
const s = /* @__PURE__ */ new Set([
|
|
1849
1856
|
"main",
|
|
1850
1857
|
"nav",
|
|
@@ -1924,22 +1931,22 @@ function an(e, t) {
|
|
|
1924
1931
|
"data-test",
|
|
1925
1932
|
"data-qa",
|
|
1926
1933
|
"data-cy"
|
|
1927
|
-
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } =
|
|
1934
|
+
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = un(), y = new Set(e);
|
|
1928
1935
|
t && y.add(t);
|
|
1929
1936
|
let m = 0;
|
|
1930
|
-
const u = (
|
|
1931
|
-
const U =
|
|
1937
|
+
const u = (I) => {
|
|
1938
|
+
const U = I.getAttribute("role");
|
|
1932
1939
|
return U && !o.has(U) ? U : "";
|
|
1933
|
-
}, h = (
|
|
1934
|
-
const U =
|
|
1935
|
-
return `${
|
|
1936
|
-
}, f = (
|
|
1937
|
-
const R = (
|
|
1938
|
-
const
|
|
1939
|
-
if (m >= 1e3 && !z || H.has(
|
|
1940
|
+
}, h = (I) => {
|
|
1941
|
+
const U = I.getAttribute("data-testid") || I.getAttribute("data-test") || I.getAttribute("data-qa") || I.getAttribute("data-cy") || "";
|
|
1942
|
+
return `${I.tagName.toLowerCase()}|${u(I)}|${U}`;
|
|
1943
|
+
}, f = (I, U, H) => {
|
|
1944
|
+
const R = (S, ct) => {
|
|
1945
|
+
const b = S.tagName.toLowerCase(), lt = window.getComputedStyle(S), z = d.has(S);
|
|
1946
|
+
if (m >= 1e3 && !z || H.has(S) || i.has(b) || S.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || lt.display === "none" || lt.visibility === "hidden")
|
|
1940
1947
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
1941
1948
|
m += 1;
|
|
1942
|
-
const zt = u(
|
|
1949
|
+
const zt = u(S), G = Re(S), je = a.has(zt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && S.hasAttribute("href"), ut = Array.from(S.children).filter((g) => g instanceof HTMLElement), X = /* @__PURE__ */ new Map();
|
|
1943
1950
|
for (const g of ut) {
|
|
1944
1951
|
const w = h(g);
|
|
1945
1952
|
X.set(w, (X.get(w) ?? 0) + 1);
|
|
@@ -1949,26 +1956,26 @@ function an(e, t) {
|
|
|
1949
1956
|
const w = h(g), D = Gt.get(w) ?? 0;
|
|
1950
1957
|
Gt.set(w, D + 1), (X.get(w) ?? 0) > 8 && D >= 6 && !d.has(g) && dt.set(w, (dt.get(w) ?? 0) + 1);
|
|
1951
1958
|
}
|
|
1952
|
-
const Xt = /* @__PURE__ */ new Map(),
|
|
1959
|
+
const Xt = /* @__PURE__ */ new Map(), Kt = /* @__PURE__ */ new Set(), ht = [], Jt = [];
|
|
1953
1960
|
for (const g of ut) {
|
|
1954
1961
|
const w = h(g), D = X.get(w) ?? 0, Zt = Xt.get(w) ?? 0;
|
|
1955
1962
|
if (Xt.set(w, Zt + 1), D > 8 && Zt >= 6 && !d.has(g)) {
|
|
1956
|
-
|
|
1963
|
+
Kt.has(w) || (ht.push([`… ${dt.get(w) ?? 0} similar siblings omitted`]), Kt.add(w));
|
|
1957
1964
|
continue;
|
|
1958
1965
|
}
|
|
1959
1966
|
const Qt = R(g, ct);
|
|
1960
|
-
|
|
1967
|
+
Jt.push(Qt), ht.push(Qt.lines);
|
|
1961
1968
|
}
|
|
1962
1969
|
const pt = [];
|
|
1963
|
-
if (
|
|
1964
|
-
for (const g of Array.from(
|
|
1970
|
+
if (S.shadowRoot)
|
|
1971
|
+
for (const g of Array.from(S.shadowRoot.children))
|
|
1965
1972
|
g instanceof HTMLElement && pt.push(R(g, ct + 1));
|
|
1966
|
-
const
|
|
1967
|
-
[G, ...
|
|
1968
|
-
).slice(0, 180), ze =
|
|
1973
|
+
const K = [...Jt, ...pt], ft = G.length > 0 || je || K.some((g) => g.hasUsefulContent), Vt = B(
|
|
1974
|
+
[G, ...K.map((g) => g.textPreview)].filter(Boolean).join(" ")
|
|
1975
|
+
).slice(0, 180), ze = S.hasAttribute("contenteditable") && (G.length > 0 || !S.querySelector("[contenteditable]")), Yt = l.some((g) => S.hasAttribute(g)) || !!zt || ze, gt = (S.getClientRects().length > 0 || lt.display === "contents") && (s.has(b) || Yt || z) && (ft || z) && (!r.has(b) || ft || Yt || z), mt = gt ? 1 : 0, F = [];
|
|
1969
1976
|
if (gt) {
|
|
1970
|
-
const g =
|
|
1971
|
-
F.push(ke(
|
|
1977
|
+
const g = K.some((D) => D.containsTextElement), w = n.has(b) && !g ? Vt : G;
|
|
1978
|
+
F.push(ke(S, c, o, w.slice(0, 180)));
|
|
1972
1979
|
}
|
|
1973
1980
|
for (const g of ht)
|
|
1974
1981
|
F.push(...Z(g, mt));
|
|
@@ -1976,9 +1983,9 @@ function an(e, t) {
|
|
|
1976
1983
|
if (yt.length > 0) {
|
|
1977
1984
|
const g = yt.slice(0, 20);
|
|
1978
1985
|
yt.length > g.length && g.push("… shadow DOM omitted");
|
|
1979
|
-
const w =
|
|
1986
|
+
const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
|
|
1980
1987
|
if (ct < 2 && !w) {
|
|
1981
|
-
const D = gt ? "#shadow-root" : `${
|
|
1988
|
+
const D = gt ? "#shadow-root" : `${b} #shadow-root`;
|
|
1982
1989
|
F.push(...Z([D, ...Z(g, 1)], mt));
|
|
1983
1990
|
} else
|
|
1984
1991
|
F.push(...Z(g, mt));
|
|
@@ -1987,21 +1994,21 @@ function an(e, t) {
|
|
|
1987
1994
|
lines: F,
|
|
1988
1995
|
hasUsefulContent: ft,
|
|
1989
1996
|
textPreview: Vt,
|
|
1990
|
-
containsTextElement: n.has(
|
|
1997
|
+
containsTextElement: n.has(b) || K.some((g) => g.containsTextElement)
|
|
1991
1998
|
};
|
|
1992
1999
|
};
|
|
1993
|
-
return [`--- ${U} ---`, ...R(
|
|
2000
|
+
return [`--- ${U} ---`, ...R(I, 0).lines].join(`
|
|
1994
2001
|
`);
|
|
1995
|
-
},
|
|
1996
|
-
x &&
|
|
1997
|
-
${JSON.stringify(x)}`), p.length > 0 &&
|
|
1998
|
-
for (const
|
|
1999
|
-
|
|
2000
|
-
if (t &&
|
|
2001
|
-
const
|
|
2002
|
-
|
|
2003
|
-
}
|
|
2004
|
-
return
|
|
2002
|
+
}, T = [], x = B(window.getSelection()?.toString() ?? "");
|
|
2003
|
+
x && T.push(`--- selected text ---
|
|
2004
|
+
${JSON.stringify(x)}`), p.length > 0 && T.push(dn(p, s, c, o));
|
|
2005
|
+
for (const I of e.slice(0, 3))
|
|
2006
|
+
T.push(f(I, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2007
|
+
if (t && T.push(f(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
2008
|
+
const I = t || e.length ? "other visible DOM" : "visible DOM";
|
|
2009
|
+
T.push(f(document.body, I, y));
|
|
2010
|
+
}
|
|
2011
|
+
return T.join(`
|
|
2005
2012
|
|
|
2006
2013
|
`);
|
|
2007
2014
|
}
|
|
@@ -2009,7 +2016,7 @@ function ke(e, t, s, n) {
|
|
|
2009
2016
|
const r = e.tagName.toLowerCase();
|
|
2010
2017
|
let i = r;
|
|
2011
2018
|
const o = e.getAttribute("id");
|
|
2012
|
-
o &&
|
|
2019
|
+
o && hn(o) && (i += `#${o}`);
|
|
2013
2020
|
for (const a of t) {
|
|
2014
2021
|
const c = e.getAttribute(a);
|
|
2015
2022
|
c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
|
|
@@ -2022,7 +2029,7 @@ function ke(e, t, s, n) {
|
|
|
2022
2029
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2023
2030
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2024
2031
|
}
|
|
2025
|
-
function
|
|
2032
|
+
function un() {
|
|
2026
2033
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
|
|
2027
2034
|
if (!a)
|
|
2028
2035
|
return;
|
|
@@ -2065,7 +2072,7 @@ function cn() {
|
|
|
2065
2072
|
priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
|
|
2066
2073
|
};
|
|
2067
2074
|
}
|
|
2068
|
-
function
|
|
2075
|
+
function dn(e, t, s, n) {
|
|
2069
2076
|
const r = ["--- active/current elements ---"];
|
|
2070
2077
|
for (const i of e) {
|
|
2071
2078
|
const o = [];
|
|
@@ -2101,7 +2108,7 @@ function Re(e) {
|
|
|
2101
2108
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2102
2109
|
);
|
|
2103
2110
|
}
|
|
2104
|
-
function
|
|
2111
|
+
function hn(e) {
|
|
2105
2112
|
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);
|
|
2106
2113
|
}
|
|
2107
2114
|
function _e() {
|
|
@@ -2120,23 +2127,23 @@ function _e() {
|
|
|
2120
2127
|
},
|
|
2121
2128
|
{
|
|
2122
2129
|
name: "widget_root",
|
|
2123
|
-
selector:
|
|
2130
|
+
selector: us,
|
|
2124
2131
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2125
2132
|
},
|
|
2126
2133
|
{
|
|
2127
2134
|
name: "widget_panel",
|
|
2128
|
-
selector:
|
|
2135
|
+
selector: ds,
|
|
2129
2136
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2130
2137
|
},
|
|
2131
2138
|
{
|
|
2132
2139
|
name: "widget_timeline",
|
|
2133
|
-
selector:
|
|
2140
|
+
selector: hs,
|
|
2134
2141
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2135
2142
|
}
|
|
2136
2143
|
]
|
|
2137
2144
|
};
|
|
2138
2145
|
}
|
|
2139
|
-
function
|
|
2146
|
+
function pn(e) {
|
|
2140
2147
|
try {
|
|
2141
2148
|
const t = JSON.parse(e);
|
|
2142
2149
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2150,10 +2157,10 @@ function ce(e, t) {
|
|
|
2150
2157
|
const s = e[t];
|
|
2151
2158
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2152
2159
|
}
|
|
2153
|
-
function
|
|
2160
|
+
function fn(e) {
|
|
2154
2161
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2155
2162
|
}
|
|
2156
|
-
function
|
|
2163
|
+
function gn(e) {
|
|
2157
2164
|
if (!e || typeof e != "object")
|
|
2158
2165
|
return null;
|
|
2159
2166
|
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;
|
|
@@ -2164,13 +2171,13 @@ function pn(e) {
|
|
|
2164
2171
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2165
2172
|
};
|
|
2166
2173
|
}
|
|
2167
|
-
function
|
|
2174
|
+
function mn(e) {
|
|
2168
2175
|
if (!e || typeof e != "object")
|
|
2169
2176
|
return null;
|
|
2170
2177
|
const t = e.javascript;
|
|
2171
2178
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2172
2179
|
}
|
|
2173
|
-
function
|
|
2180
|
+
function yn(e, t) {
|
|
2174
2181
|
return t ? e && typeof e == "object" ? {
|
|
2175
2182
|
...e,
|
|
2176
2183
|
helperError: t
|
|
@@ -2180,23 +2187,23 @@ function gn(e, t) {
|
|
|
2180
2187
|
helperError: t
|
|
2181
2188
|
} : e;
|
|
2182
2189
|
}
|
|
2183
|
-
function
|
|
2190
|
+
function Tn(e) {
|
|
2184
2191
|
if (!e || typeof e != "object")
|
|
2185
2192
|
return e;
|
|
2186
2193
|
const t = e;
|
|
2187
2194
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2188
2195
|
}
|
|
2189
|
-
function
|
|
2196
|
+
function In() {
|
|
2190
2197
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2191
2198
|
if (t)
|
|
2192
2199
|
return t;
|
|
2193
2200
|
const s = crypto.randomUUID();
|
|
2194
2201
|
return window.localStorage.setItem(e, s), s;
|
|
2195
2202
|
}
|
|
2196
|
-
function
|
|
2203
|
+
function bt() {
|
|
2197
2204
|
return crypto.randomUUID();
|
|
2198
2205
|
}
|
|
2199
|
-
function
|
|
2206
|
+
function wn(e) {
|
|
2200
2207
|
if (!e || typeof e != "object")
|
|
2201
2208
|
return null;
|
|
2202
2209
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2207,23 +2214,23 @@ function In(e) {
|
|
|
2207
2214
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2208
2215
|
} : null;
|
|
2209
2216
|
}
|
|
2210
|
-
function
|
|
2217
|
+
function An(e, t) {
|
|
2211
2218
|
return Array.isArray(e) ? Dt(
|
|
2212
2219
|
xt(
|
|
2213
2220
|
e.map((s) => Me(s, t)).filter((s) => s !== null)
|
|
2214
2221
|
)
|
|
2215
2222
|
) : [];
|
|
2216
2223
|
}
|
|
2217
|
-
function
|
|
2224
|
+
function Sn(e) {
|
|
2218
2225
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2219
2226
|
if (!t || typeof t != "object")
|
|
2220
2227
|
return [];
|
|
2221
|
-
const s = t, n =
|
|
2228
|
+
const s = t, n = E(s, "id"), r = E(s, "createdAt"), i = E(s, "updatedAt"), o = E(s, "lastActiveAt");
|
|
2222
2229
|
return !n || !r || !i || !o ? [] : [
|
|
2223
2230
|
{
|
|
2224
2231
|
id: n,
|
|
2225
|
-
title:
|
|
2226
|
-
firstUserMessage:
|
|
2232
|
+
title: E(s, "title"),
|
|
2233
|
+
firstUserMessage: E(s, "firstUserMessage"),
|
|
2227
2234
|
currentPage: s.currentPage ?? null,
|
|
2228
2235
|
createdAt: r,
|
|
2229
2236
|
updatedAt: i,
|
|
@@ -2249,7 +2256,10 @@ function Me(e, t) {
|
|
|
2249
2256
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2250
2257
|
role: i,
|
|
2251
2258
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2252
|
-
content:
|
|
2259
|
+
content: Qe(
|
|
2260
|
+
Cn(r.content),
|
|
2261
|
+
t
|
|
2262
|
+
),
|
|
2253
2263
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2254
2264
|
respondsToUserMessageId: v(r) ?? void 0,
|
|
2255
2265
|
...M(r) ? { runId: M(r) } : {},
|
|
@@ -2264,7 +2274,7 @@ function Me(e, t) {
|
|
|
2264
2274
|
}), o;
|
|
2265
2275
|
}
|
|
2266
2276
|
if (r.type === "function_call_output") {
|
|
2267
|
-
const i =
|
|
2277
|
+
const i = bn(r.output);
|
|
2268
2278
|
return i ? {
|
|
2269
2279
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2270
2280
|
role: "tool",
|
|
@@ -2281,7 +2291,7 @@ function Me(e, t) {
|
|
|
2281
2291
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2282
2292
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2283
2293
|
role: "tool",
|
|
2284
|
-
content: r.type === "mcp_call" ?
|
|
2294
|
+
content: r.type === "mcp_call" ? En(r) : Rn(r),
|
|
2285
2295
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2286
2296
|
respondsToUserMessageId: v(r) ?? void 0,
|
|
2287
2297
|
...M(r) ? { runId: M(r) } : {},
|
|
@@ -2292,7 +2302,7 @@ function Me(e, t) {
|
|
|
2292
2302
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2293
2303
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2294
2304
|
role: "system",
|
|
2295
|
-
content:
|
|
2305
|
+
content: kn(r),
|
|
2296
2306
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2297
2307
|
respondsToUserMessageId: v(r) ?? void 0,
|
|
2298
2308
|
...M(r) ? { runId: M(r) } : {},
|
|
@@ -2302,11 +2312,11 @@ function Me(e, t) {
|
|
|
2302
2312
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2303
2313
|
} : null;
|
|
2304
2314
|
}
|
|
2305
|
-
function
|
|
2315
|
+
function En(e) {
|
|
2306
2316
|
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(" ");
|
|
2307
2317
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2308
2318
|
}
|
|
2309
|
-
function
|
|
2319
|
+
function bn(e) {
|
|
2310
2320
|
if (typeof e != "string")
|
|
2311
2321
|
return null;
|
|
2312
2322
|
try {
|
|
@@ -2323,10 +2333,10 @@ function An(e) {
|
|
|
2323
2333
|
return null;
|
|
2324
2334
|
}
|
|
2325
2335
|
}
|
|
2326
|
-
function
|
|
2336
|
+
function kn(e) {
|
|
2327
2337
|
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.";
|
|
2328
2338
|
}
|
|
2329
|
-
function
|
|
2339
|
+
function Rn(e) {
|
|
2330
2340
|
if (e.type === "web_search_call") {
|
|
2331
2341
|
const t = e.action;
|
|
2332
2342
|
if (t && typeof t == "object") {
|
|
@@ -2338,26 +2348,26 @@ function En(e) {
|
|
|
2338
2348
|
}
|
|
2339
2349
|
return "🔎 Searching the web";
|
|
2340
2350
|
}
|
|
2341
|
-
return
|
|
2351
|
+
return _n(e);
|
|
2342
2352
|
}
|
|
2343
|
-
function
|
|
2353
|
+
function _n(e) {
|
|
2344
2354
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2345
|
-
return
|
|
2355
|
+
return O(e.summary);
|
|
2346
2356
|
if (typeof e.arguments == "string")
|
|
2347
2357
|
try {
|
|
2348
2358
|
const t = JSON.parse(e.arguments);
|
|
2349
2359
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
2350
|
-
return
|
|
2360
|
+
return O(t.summary);
|
|
2351
2361
|
} catch {
|
|
2352
|
-
return typeof e.name == "string" && e.name.trim().length > 0 ?
|
|
2362
|
+
return typeof e.name == "string" && e.name.trim().length > 0 ? O(e.name) : "🛠️ Run tool";
|
|
2353
2363
|
}
|
|
2354
|
-
return typeof e.name == "string" && e.name.trim().length > 0 ?
|
|
2364
|
+
return typeof e.name == "string" && e.name.trim().length > 0 ? O(e.name) : "🛠️ Run tool";
|
|
2355
2365
|
}
|
|
2356
|
-
function
|
|
2366
|
+
function O(e) {
|
|
2357
2367
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2358
2368
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2359
2369
|
}
|
|
2360
|
-
function
|
|
2370
|
+
function Mn(e) {
|
|
2361
2371
|
if (e == null)
|
|
2362
2372
|
return e;
|
|
2363
2373
|
if (typeof e != "object")
|
|
@@ -2376,7 +2386,7 @@ function le(e) {
|
|
|
2376
2386
|
const t = e.callId ?? e.call_id;
|
|
2377
2387
|
return typeof t == "string" && t ? t : null;
|
|
2378
2388
|
}
|
|
2379
|
-
function
|
|
2389
|
+
function Cn(e) {
|
|
2380
2390
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2381
2391
|
if (!t || typeof t != "object")
|
|
2382
2392
|
return "";
|
|
@@ -2385,8 +2395,8 @@ function _n(e) {
|
|
|
2385
2395
|
}).filter(Boolean).join("") : "";
|
|
2386
2396
|
}
|
|
2387
2397
|
function Ce(e, t) {
|
|
2388
|
-
const s = Pe(e, t), n =
|
|
2389
|
-
|
|
2398
|
+
const s = Pe(e, t), n = xn(
|
|
2399
|
+
Ln(e, t),
|
|
2390
2400
|
s
|
|
2391
2401
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2392
2402
|
if (r === -1)
|
|
@@ -2396,7 +2406,7 @@ function Ce(e, t) {
|
|
|
2396
2406
|
const i = [...n];
|
|
2397
2407
|
return i[r] = s, Dt(xt(i));
|
|
2398
2408
|
}
|
|
2399
|
-
function
|
|
2409
|
+
function Pn(e, t) {
|
|
2400
2410
|
const s = e.findIndex(
|
|
2401
2411
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2402
2412
|
);
|
|
@@ -2409,17 +2419,17 @@ function Mn(e, t) {
|
|
|
2409
2419
|
loading: !0
|
|
2410
2420
|
}, n;
|
|
2411
2421
|
}
|
|
2412
|
-
function
|
|
2422
|
+
function Un(e, t, s) {
|
|
2413
2423
|
let n = !1;
|
|
2414
2424
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2415
2425
|
return n ? r : e;
|
|
2416
2426
|
}
|
|
2417
|
-
function
|
|
2427
|
+
function Dn(e) {
|
|
2418
2428
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
2419
2429
|
return !t || !s ? null : {
|
|
2420
2430
|
id: `transient-activity:${t}`,
|
|
2421
2431
|
role: "tool",
|
|
2422
|
-
content:
|
|
2432
|
+
content: O(
|
|
2423
2433
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
2424
2434
|
),
|
|
2425
2435
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2431,7 +2441,7 @@ function Pn(e) {
|
|
|
2431
2441
|
loading: !0
|
|
2432
2442
|
};
|
|
2433
2443
|
}
|
|
2434
|
-
function
|
|
2444
|
+
function xn(e, t) {
|
|
2435
2445
|
if (t.id.startsWith("transient-activity:"))
|
|
2436
2446
|
return e;
|
|
2437
2447
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2439,7 +2449,7 @@ function Un(e, t) {
|
|
|
2439
2449
|
(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)
|
|
2440
2450
|
);
|
|
2441
2451
|
}
|
|
2442
|
-
function
|
|
2452
|
+
function vn(e, t) {
|
|
2443
2453
|
const s = t.map(
|
|
2444
2454
|
(n) => Pe(e, n)
|
|
2445
2455
|
);
|
|
@@ -2454,19 +2464,19 @@ function Pe(e, t) {
|
|
|
2454
2464
|
if (!s?.attachments?.length)
|
|
2455
2465
|
return t;
|
|
2456
2466
|
const n = t.attachments.map((r) => {
|
|
2457
|
-
const i =
|
|
2458
|
-
return i ?
|
|
2467
|
+
const i = Nn(s.attachments ?? [], r);
|
|
2468
|
+
return i ? On(r, i) : r;
|
|
2459
2469
|
});
|
|
2460
2470
|
return { ...t, attachments: n };
|
|
2461
2471
|
}
|
|
2462
|
-
function
|
|
2472
|
+
function Nn(e, t) {
|
|
2463
2473
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2464
2474
|
}
|
|
2465
|
-
function
|
|
2475
|
+
function On(e, t) {
|
|
2466
2476
|
const { previewUrl: s } = t;
|
|
2467
2477
|
return s ? { ...e, previewUrl: s } : e;
|
|
2468
2478
|
}
|
|
2469
|
-
function
|
|
2479
|
+
function Ln(e, t) {
|
|
2470
2480
|
if (t.role !== "user")
|
|
2471
2481
|
return e;
|
|
2472
2482
|
const s = e.findIndex(
|
|
@@ -2510,7 +2520,7 @@ function de(e) {
|
|
|
2510
2520
|
}
|
|
2511
2521
|
return !1;
|
|
2512
2522
|
}
|
|
2513
|
-
function
|
|
2523
|
+
function Bn(e) {
|
|
2514
2524
|
const t = De(e);
|
|
2515
2525
|
return t === null ? e.some(q) : e.slice(t + 1).some(q);
|
|
2516
2526
|
}
|
|
@@ -2520,7 +2530,7 @@ function De(e) {
|
|
|
2520
2530
|
return t;
|
|
2521
2531
|
return null;
|
|
2522
2532
|
}
|
|
2523
|
-
function
|
|
2533
|
+
function qn(e) {
|
|
2524
2534
|
return q(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2525
2535
|
}
|
|
2526
2536
|
function it(e) {
|
|
@@ -2537,7 +2547,7 @@ function it(e) {
|
|
|
2537
2547
|
}
|
|
2538
2548
|
return null;
|
|
2539
2549
|
}
|
|
2540
|
-
function
|
|
2550
|
+
function Hn(e) {
|
|
2541
2551
|
const t = it(e);
|
|
2542
2552
|
if (t === null)
|
|
2543
2553
|
return null;
|
|
@@ -2559,7 +2569,7 @@ function Pt(e) {
|
|
|
2559
2569
|
function he(e) {
|
|
2560
2570
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2561
2571
|
}
|
|
2562
|
-
function
|
|
2572
|
+
function Fn(e, t) {
|
|
2563
2573
|
const s = it(t);
|
|
2564
2574
|
if (s === null)
|
|
2565
2575
|
return !1;
|
|
@@ -2567,7 +2577,7 @@ function qn(e, t) {
|
|
|
2567
2577
|
if (typeof r != "string" || !r)
|
|
2568
2578
|
return !1;
|
|
2569
2579
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2570
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
2580
|
+
return i === -1 ? !1 : e.slice(i + 1).some(qn);
|
|
2571
2581
|
}
|
|
2572
2582
|
function Ut(e) {
|
|
2573
2583
|
const t = it(e);
|
|
@@ -2582,7 +2592,7 @@ function Ut(e) {
|
|
|
2582
2592
|
const r = n.clientMessageId;
|
|
2583
2593
|
return typeof r == "string" ? r : null;
|
|
2584
2594
|
}
|
|
2585
|
-
function
|
|
2595
|
+
function $n(e) {
|
|
2586
2596
|
const t = it(e);
|
|
2587
2597
|
if (t === null)
|
|
2588
2598
|
return null;
|
|
@@ -2609,10 +2619,10 @@ function pe(e, t) {
|
|
|
2609
2619
|
const s = v(t);
|
|
2610
2620
|
if (!s)
|
|
2611
2621
|
return null;
|
|
2612
|
-
const n = e.find((i) =>
|
|
2622
|
+
const n = e.find((i) => E(i, "id") === s), r = L(n);
|
|
2613
2623
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2614
2624
|
}
|
|
2615
|
-
function
|
|
2625
|
+
function Wn(e, t) {
|
|
2616
2626
|
let s = 0;
|
|
2617
2627
|
for (const n of e) {
|
|
2618
2628
|
if (!n || typeof n != "object")
|
|
@@ -2626,12 +2636,12 @@ function Fn(e, t) {
|
|
|
2626
2636
|
return s;
|
|
2627
2637
|
}
|
|
2628
2638
|
function fe(e, t, s, n, r) {
|
|
2629
|
-
if (!t ||
|
|
2639
|
+
if (!t || !jn(e))
|
|
2630
2640
|
return !1;
|
|
2631
2641
|
const i = e;
|
|
2632
2642
|
return !(Pt(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && v(i) !== n || r !== null && M(i) !== r);
|
|
2633
2643
|
}
|
|
2634
|
-
function
|
|
2644
|
+
function jn(e) {
|
|
2635
2645
|
if (!e || typeof e != "object")
|
|
2636
2646
|
return !1;
|
|
2637
2647
|
const t = e;
|
|
@@ -2640,16 +2650,16 @@ function $n(e) {
|
|
|
2640
2650
|
function q(e) {
|
|
2641
2651
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
2642
2652
|
}
|
|
2643
|
-
function
|
|
2653
|
+
function zn(e) {
|
|
2644
2654
|
if (!e || typeof e != "object")
|
|
2645
2655
|
return !1;
|
|
2646
2656
|
const t = e;
|
|
2647
2657
|
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";
|
|
2648
2658
|
}
|
|
2649
2659
|
function Dt(e) {
|
|
2650
|
-
return e.filter((t, s) => Ft(t) ? !
|
|
2660
|
+
return e.filter((t, s) => Ft(t) ? !Yn(e, s) && !Jn(e, s) && !Vn(e, s) : Gn(t) ? t.retryable === !0 && Kn(e, s) ? !1 : !Xn(e, s) : !0);
|
|
2651
2661
|
}
|
|
2652
|
-
function
|
|
2662
|
+
function Gn(e) {
|
|
2653
2663
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
2654
2664
|
}
|
|
2655
2665
|
function Ft(e) {
|
|
@@ -2671,7 +2681,7 @@ function xt(e) {
|
|
|
2671
2681
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
2672
2682
|
return r;
|
|
2673
2683
|
}
|
|
2674
|
-
function
|
|
2684
|
+
function Xn(e, t) {
|
|
2675
2685
|
const s = e[t];
|
|
2676
2686
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2677
2687
|
const r = e[n];
|
|
@@ -2682,7 +2692,7 @@ function zn(e, t) {
|
|
|
2682
2692
|
}
|
|
2683
2693
|
return !1;
|
|
2684
2694
|
}
|
|
2685
|
-
function
|
|
2695
|
+
function Kn(e, t) {
|
|
2686
2696
|
const s = e[t];
|
|
2687
2697
|
if (!s.respondsToUserMessageId)
|
|
2688
2698
|
return !1;
|
|
@@ -2695,21 +2705,21 @@ function Gn(e, t) {
|
|
|
2695
2705
|
}
|
|
2696
2706
|
return !1;
|
|
2697
2707
|
}
|
|
2698
|
-
function
|
|
2708
|
+
function Jn(e, t) {
|
|
2699
2709
|
const s = e[t];
|
|
2700
2710
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2701
2711
|
if (e[n].role === "assistant" && ot(s, e[n]))
|
|
2702
2712
|
return !0;
|
|
2703
2713
|
return !1;
|
|
2704
2714
|
}
|
|
2705
|
-
function
|
|
2715
|
+
function Vn(e, t) {
|
|
2706
2716
|
const s = e[t];
|
|
2707
2717
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2708
2718
|
if (e[n].role === "tool" && ot(s, e[n]))
|
|
2709
2719
|
return !0;
|
|
2710
2720
|
return !1;
|
|
2711
2721
|
}
|
|
2712
|
-
function
|
|
2722
|
+
function Yn(e, t) {
|
|
2713
2723
|
const s = e[t];
|
|
2714
2724
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2715
2725
|
if (Ft(e[n]) && ot(s, e[n]))
|
|
@@ -2719,18 +2729,18 @@ function Kn(e, t) {
|
|
|
2719
2729
|
function ot(e, t) {
|
|
2720
2730
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
2721
2731
|
}
|
|
2722
|
-
function
|
|
2732
|
+
function E(e, t) {
|
|
2723
2733
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
2724
2734
|
}
|
|
2725
|
-
function
|
|
2735
|
+
function Zn(e, t) {
|
|
2726
2736
|
try {
|
|
2727
|
-
const s = window.localStorage.getItem(`${
|
|
2737
|
+
const s = window.localStorage.getItem(`${Se}${e}`);
|
|
2728
2738
|
if (!s)
|
|
2729
2739
|
return null;
|
|
2730
2740
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
2731
2741
|
if (t !== void 0 && r !== t)
|
|
2732
2742
|
return null;
|
|
2733
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2743
|
+
const i = Array.isArray(n.messages) ? n.messages.map(cr).filter((o) => !!o) : [];
|
|
2734
2744
|
return {
|
|
2735
2745
|
sessionId: r,
|
|
2736
2746
|
messages: i
|
|
@@ -2739,20 +2749,20 @@ function Vn(e, t) {
|
|
|
2739
2749
|
return null;
|
|
2740
2750
|
}
|
|
2741
2751
|
}
|
|
2742
|
-
function
|
|
2752
|
+
function Qn(e, t) {
|
|
2743
2753
|
try {
|
|
2744
2754
|
window.localStorage.setItem(
|
|
2745
|
-
`${
|
|
2755
|
+
`${Se}${e}`,
|
|
2746
2756
|
JSON.stringify({
|
|
2747
2757
|
sessionId: t.sessionId,
|
|
2748
|
-
messages: t.messages.slice(-
|
|
2758
|
+
messages: t.messages.slice(-Ps).map(lr)
|
|
2749
2759
|
})
|
|
2750
2760
|
);
|
|
2751
2761
|
} catch {
|
|
2752
2762
|
return;
|
|
2753
2763
|
}
|
|
2754
2764
|
}
|
|
2755
|
-
function
|
|
2765
|
+
function tr(e) {
|
|
2756
2766
|
try {
|
|
2757
2767
|
const t = window.localStorage.getItem(`${Ct}${e}`);
|
|
2758
2768
|
if (!t)
|
|
@@ -2794,7 +2804,7 @@ function xe(e, t) {
|
|
|
2794
2804
|
} catch {
|
|
2795
2805
|
}
|
|
2796
2806
|
}
|
|
2797
|
-
function
|
|
2807
|
+
function er(e, t) {
|
|
2798
2808
|
try {
|
|
2799
2809
|
if (window.sessionStorage.getItem(`${rt}${e}`) === null)
|
|
2800
2810
|
return;
|
|
@@ -2803,19 +2813,19 @@ function Qn(e, t) {
|
|
|
2803
2813
|
}
|
|
2804
2814
|
xe(e, t);
|
|
2805
2815
|
}
|
|
2806
|
-
function
|
|
2816
|
+
function sr(e) {
|
|
2807
2817
|
try {
|
|
2808
2818
|
const t = `${rt}${e}`, s = window.sessionStorage.getItem(t);
|
|
2809
2819
|
if (window.sessionStorage.removeItem(t), !s)
|
|
2810
2820
|
return [];
|
|
2811
2821
|
const n = JSON.parse(s);
|
|
2812
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2822
|
+
return Array.isArray(n) ? n.flatMap((r) => rr(r) ? [{
|
|
2813
2823
|
...r.event,
|
|
2814
2824
|
page: _(),
|
|
2815
2825
|
rawOutput: {
|
|
2816
2826
|
pageContextRestarted: !0,
|
|
2817
2827
|
outcome: "unknown",
|
|
2818
|
-
message:
|
|
2828
|
+
message: nr(location.href),
|
|
2819
2829
|
currentUrl: location.href,
|
|
2820
2830
|
console: [],
|
|
2821
2831
|
metadata: {
|
|
@@ -2832,17 +2842,17 @@ function tr(e) {
|
|
|
2832
2842
|
return [];
|
|
2833
2843
|
}
|
|
2834
2844
|
}
|
|
2835
|
-
function
|
|
2845
|
+
function nr(e) {
|
|
2836
2846
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
2837
2847
|
Current URL: ${e}`;
|
|
2838
2848
|
}
|
|
2839
|
-
function
|
|
2849
|
+
function rr(e) {
|
|
2840
2850
|
if (!e || typeof e != "object")
|
|
2841
2851
|
return !1;
|
|
2842
2852
|
const t = e, s = t.event;
|
|
2843
2853
|
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && $t(s) && s.type === "tool.result";
|
|
2844
2854
|
}
|
|
2845
|
-
function
|
|
2855
|
+
function ir(e, t) {
|
|
2846
2856
|
const s = new Set(
|
|
2847
2857
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2848
2858
|
);
|
|
@@ -2851,7 +2861,7 @@ function nr(e, t) {
|
|
|
2851
2861
|
...t.filter((n) => !s.has(n.callId))
|
|
2852
2862
|
];
|
|
2853
2863
|
}
|
|
2854
|
-
function
|
|
2864
|
+
function or(e) {
|
|
2855
2865
|
try {
|
|
2856
2866
|
window.sessionStorage.removeItem(`${rt}${e}`);
|
|
2857
2867
|
} catch {
|
|
@@ -2878,23 +2888,23 @@ function ve(e, t) {
|
|
|
2878
2888
|
return !1;
|
|
2879
2889
|
const i = r;
|
|
2880
2890
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2881
|
-
}), n = t ? s.map((r) =>
|
|
2891
|
+
}), n = t ? s.map((r) => Ne(r, t)) : s;
|
|
2882
2892
|
return n.length > 0 ? n : void 0;
|
|
2883
2893
|
}
|
|
2884
|
-
function
|
|
2894
|
+
function Ne(e, t) {
|
|
2885
2895
|
return e.fileUrl?.startsWith("/") ? {
|
|
2886
2896
|
...e,
|
|
2887
2897
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2888
2898
|
} : e;
|
|
2889
2899
|
}
|
|
2890
2900
|
function me(e) {
|
|
2891
|
-
return e.type ||
|
|
2901
|
+
return e.type || ar(e.name) || "application/octet-stream";
|
|
2892
2902
|
}
|
|
2893
|
-
function
|
|
2903
|
+
function ar(e) {
|
|
2894
2904
|
const t = e.toLowerCase();
|
|
2895
2905
|
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;
|
|
2896
2906
|
}
|
|
2897
|
-
function
|
|
2907
|
+
function cr(e) {
|
|
2898
2908
|
if (!e || typeof e != "object")
|
|
2899
2909
|
return null;
|
|
2900
2910
|
const t = e;
|
|
@@ -2911,7 +2921,7 @@ function or(e) {
|
|
|
2911
2921
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2912
2922
|
};
|
|
2913
2923
|
}
|
|
2914
|
-
function
|
|
2924
|
+
function lr(e) {
|
|
2915
2925
|
return e.attachments?.length ? {
|
|
2916
2926
|
...e,
|
|
2917
2927
|
attachments: e.attachments.map(Wt)
|
|
@@ -2934,11 +2944,11 @@ function M(e) {
|
|
|
2934
2944
|
const t = e.runId;
|
|
2935
2945
|
return typeof t == "string" && t ? t : null;
|
|
2936
2946
|
}
|
|
2937
|
-
function
|
|
2947
|
+
function ur(e) {
|
|
2938
2948
|
const t = e?.timeoutMs;
|
|
2939
|
-
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 <=
|
|
2949
|
+
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 <= Bs);
|
|
2940
2950
|
}
|
|
2941
|
-
function
|
|
2951
|
+
function Oe(e) {
|
|
2942
2952
|
const t = {};
|
|
2943
2953
|
try {
|
|
2944
2954
|
new Headers(e).forEach((s, n) => {
|
|
@@ -2950,22 +2960,22 @@ function Ne(e) {
|
|
|
2950
2960
|
return t;
|
|
2951
2961
|
}
|
|
2952
2962
|
function jt(e, t) {
|
|
2953
|
-
return $e(e) ? at : C(nt(t),
|
|
2963
|
+
return $e(e) ? at : C(nt(t), Ms);
|
|
2954
2964
|
}
|
|
2955
|
-
function
|
|
2965
|
+
function dr(e, t) {
|
|
2956
2966
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2957
2967
|
}
|
|
2958
|
-
async function
|
|
2959
|
-
const r =
|
|
2968
|
+
async function hr(e, t, s, n) {
|
|
2969
|
+
const r = Oe(e.headers);
|
|
2960
2970
|
n({
|
|
2961
2971
|
...t,
|
|
2962
2972
|
responseStatus: e.status,
|
|
2963
2973
|
responseHeaders: r,
|
|
2964
|
-
responseBody: await
|
|
2974
|
+
responseBody: await pr(e),
|
|
2965
2975
|
durationMs: Date.now() - s
|
|
2966
2976
|
});
|
|
2967
2977
|
}
|
|
2968
|
-
async function
|
|
2978
|
+
async function pr(e) {
|
|
2969
2979
|
if (!Le(e.headers))
|
|
2970
2980
|
return;
|
|
2971
2981
|
let t = null, s = null;
|
|
@@ -2975,7 +2985,7 @@ async function dr(e) {
|
|
|
2975
2985
|
const n = new Promise((a) => {
|
|
2976
2986
|
s = window.setTimeout(() => {
|
|
2977
2987
|
t?.cancel(), a("timeout");
|
|
2978
|
-
},
|
|
2988
|
+
}, Cs);
|
|
2979
2989
|
}), r = new TextDecoder();
|
|
2980
2990
|
let i = "", o = 0;
|
|
2981
2991
|
for (; ; ) {
|
|
@@ -2997,7 +3007,7 @@ async function dr(e) {
|
|
|
2997
3007
|
s !== null && window.clearTimeout(s);
|
|
2998
3008
|
}
|
|
2999
3009
|
}
|
|
3000
|
-
function
|
|
3010
|
+
function fr(e, t) {
|
|
3001
3011
|
if (Le(new Headers(t)))
|
|
3002
3012
|
try {
|
|
3003
3013
|
return e.responseType === "" || e.responseType === "text" ? C(e.responseText ?? "") : void 0;
|
|
@@ -3009,14 +3019,14 @@ function ye(e) {
|
|
|
3009
3019
|
if (typeof e == "string")
|
|
3010
3020
|
return C(e);
|
|
3011
3021
|
}
|
|
3012
|
-
function
|
|
3022
|
+
function gr(e) {
|
|
3013
3023
|
return k({
|
|
3014
3024
|
...e,
|
|
3015
|
-
requestBody:
|
|
3016
|
-
responseBody:
|
|
3025
|
+
requestBody: Te(e.requestBody),
|
|
3026
|
+
responseBody: Te(e.responseBody)
|
|
3017
3027
|
});
|
|
3018
3028
|
}
|
|
3019
|
-
function
|
|
3029
|
+
function Te(e) {
|
|
3020
3030
|
if (typeof e != "string")
|
|
3021
3031
|
return e;
|
|
3022
3032
|
const t = e.trim();
|
|
@@ -3034,8 +3044,8 @@ function Le(e) {
|
|
|
3034
3044
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3035
3045
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= Lt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3036
3046
|
}
|
|
3037
|
-
function
|
|
3038
|
-
if (
|
|
3047
|
+
function N(e, t = {}, s) {
|
|
3048
|
+
if (yr(s))
|
|
3039
3049
|
return !0;
|
|
3040
3050
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3041
3051
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3050,8 +3060,8 @@ function O(e, t = {}, s) {
|
|
|
3050
3060
|
return !0;
|
|
3051
3061
|
}
|
|
3052
3062
|
}
|
|
3053
|
-
function
|
|
3054
|
-
if (
|
|
3063
|
+
function mr(e, t) {
|
|
3064
|
+
if (N(e))
|
|
3055
3065
|
return !0;
|
|
3056
3066
|
try {
|
|
3057
3067
|
const s = new URL(e, location.href), n = new URL(t);
|
|
@@ -3060,10 +3070,10 @@ function fr(e, t) {
|
|
|
3060
3070
|
return !0;
|
|
3061
3071
|
}
|
|
3062
3072
|
}
|
|
3063
|
-
function
|
|
3073
|
+
function yr(e) {
|
|
3064
3074
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3065
3075
|
}
|
|
3066
|
-
function
|
|
3076
|
+
function Tr(e) {
|
|
3067
3077
|
const t = {};
|
|
3068
3078
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3069
3079
|
const n = s.indexOf(":");
|
|
@@ -3094,27 +3104,27 @@ async function Rt(e, t) {
|
|
|
3094
3104
|
try {
|
|
3095
3105
|
return await e();
|
|
3096
3106
|
} catch (r) {
|
|
3097
|
-
if (s = r, n >= re - 1 || !
|
|
3107
|
+
if (s = r, n >= re - 1 || !wr(r))
|
|
3098
3108
|
throw r;
|
|
3099
|
-
await
|
|
3109
|
+
await Ir(n);
|
|
3100
3110
|
}
|
|
3101
3111
|
throw s instanceof Error ? s : new Error(t);
|
|
3102
3112
|
}
|
|
3103
|
-
function
|
|
3113
|
+
function Ir(e) {
|
|
3104
3114
|
return new Promise((t) => {
|
|
3105
|
-
window.setTimeout(t,
|
|
3115
|
+
window.setTimeout(t, _s[e] ?? 0);
|
|
3106
3116
|
});
|
|
3107
3117
|
}
|
|
3108
|
-
function
|
|
3109
|
-
return e instanceof et ?
|
|
3118
|
+
function wr(e) {
|
|
3119
|
+
return e instanceof et ? Ar(e.status) : e instanceof TypeError;
|
|
3110
3120
|
}
|
|
3111
|
-
function
|
|
3121
|
+
function Ar(e) {
|
|
3112
3122
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3113
3123
|
}
|
|
3114
|
-
function
|
|
3124
|
+
function Sr(e) {
|
|
3115
3125
|
return e === 401 || e === 403;
|
|
3116
3126
|
}
|
|
3117
|
-
const at = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]",
|
|
3127
|
+
const at = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", Er = "[REDACTED_SIGNED_URL]", br = 20, kr = /^(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, Be = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, qe = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, He = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Fe = /\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, Rr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, _r = /\bhttps?:\/\/[^\s"'<>]+/gi, Mr = /[),.;\]]+$/;
|
|
3118
3128
|
function k(e) {
|
|
3119
3129
|
return st(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3120
3130
|
}
|
|
@@ -3123,7 +3133,7 @@ function st(e, t, s) {
|
|
|
3123
3133
|
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : nt(e);
|
|
3124
3134
|
if (e === null || typeof e != "object")
|
|
3125
3135
|
return e;
|
|
3126
|
-
if (t >=
|
|
3136
|
+
if (t >= br)
|
|
3127
3137
|
return "[REDACTED_MAX_DEPTH]";
|
|
3128
3138
|
if (s.has(e))
|
|
3129
3139
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -3131,44 +3141,44 @@ function st(e, t, s) {
|
|
|
3131
3141
|
return e.map((r) => st(r, t + 1, s));
|
|
3132
3142
|
const n = {};
|
|
3133
3143
|
for (const [r, i] of Object.entries(e))
|
|
3134
|
-
r === "pageContent" ? n[r] = i : $e(r) ? n[r] = at : n[r] = r.toLowerCase() === "url" ?
|
|
3144
|
+
r === "pageContent" ? n[r] = i : $e(r) ? n[r] = at : n[r] = r.toLowerCase() === "url" ? Cr(i) : st(i, t + 1, s);
|
|
3135
3145
|
return n;
|
|
3136
3146
|
}
|
|
3137
3147
|
function $e(e) {
|
|
3138
3148
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3139
3149
|
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");
|
|
3140
3150
|
}
|
|
3141
|
-
function
|
|
3151
|
+
function Cr(e) {
|
|
3142
3152
|
return typeof e == "string" ? We(e) : st(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3143
3153
|
}
|
|
3144
3154
|
function We(e) {
|
|
3145
3155
|
try {
|
|
3146
3156
|
const t = new URL(e, location.href);
|
|
3147
3157
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3148
|
-
|
|
3158
|
+
kr.test(s) && t.searchParams.set(s, P);
|
|
3149
3159
|
return t.username && (t.username = P), t.password && (t.password = P), t.toString();
|
|
3150
3160
|
} catch {
|
|
3151
|
-
return
|
|
3161
|
+
return Pr(e);
|
|
3152
3162
|
}
|
|
3153
3163
|
}
|
|
3154
3164
|
function nt(e) {
|
|
3155
|
-
return e.replace(
|
|
3165
|
+
return e.replace(Rr, Er).replace(_r, Ur).replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${at}`);
|
|
3156
3166
|
}
|
|
3157
|
-
function
|
|
3167
|
+
function Pr(e) {
|
|
3158
3168
|
return e.replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${at}`);
|
|
3159
3169
|
}
|
|
3160
|
-
function
|
|
3161
|
-
const t = e.match(
|
|
3170
|
+
function Ur(e) {
|
|
3171
|
+
const t = e.match(Mr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3162
3172
|
return `${We(s)}${t}`;
|
|
3163
3173
|
}
|
|
3164
3174
|
export {
|
|
3165
3175
|
te as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3166
3176
|
Mt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3177
|
+
ds as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3178
|
+
us as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3179
|
+
hs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3180
|
+
Ee as PlunoProductAgent,
|
|
3181
|
+
Ds as calculateReconnectDelay,
|
|
3182
|
+
Ee as default,
|
|
3183
|
+
en as getProductAgentOriginAccessErrorMessage
|
|
3174
3184
|
};
|