@pluno/product-agent-web 0.1.131 → 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 +413 -389
- 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
|
|
84
|
-
|
|
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);
|
|
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
|
-
i.persisted || (n.release(),
|
|
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
|
|
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,10 +254,10 @@ class be {
|
|
|
247
254
|
assistantDraftRunId: null,
|
|
248
255
|
isThinking: !1,
|
|
249
256
|
lastError: null
|
|
250
|
-
}), this.queuedClientEvents =
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
),
|
|
257
|
+
}), this.queuedClientEvents = ir(
|
|
258
|
+
tr(t.clientId),
|
|
259
|
+
sr(t.clientId)
|
|
260
|
+
), W(t.clientId, this.queuedClientEvents);
|
|
254
261
|
}
|
|
255
262
|
options;
|
|
256
263
|
listeners = {};
|
|
@@ -317,15 +324,15 @@ 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
|
-
|
|
335
|
+
Je().catch((r) => {
|
|
329
336
|
A("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
330
337
|
message: r instanceof Error ? r.message : String(r)
|
|
331
338
|
});
|
|
@@ -357,14 +364,14 @@ 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
373
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (A("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
367
|
-
},
|
|
374
|
+
}, Ts), n.addEventListener("open", () => {
|
|
368
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
|
|
@@ -376,9 +383,9 @@ class be {
|
|
|
376
383
|
pageUrl: location.href
|
|
377
384
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
378
385
|
this.socket === n && (A("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
379
|
-
},
|
|
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
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,
|
|
@@ -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,
|
|
@@ -449,14 +456,14 @@ class be {
|
|
|
449
456
|
try {
|
|
450
457
|
const u = [];
|
|
451
458
|
for (const h of i) {
|
|
452
|
-
const
|
|
459
|
+
const f = h.id ? this.attachmentFiles.get(h.id) : void 0;
|
|
453
460
|
if (h.sandboxPath) {
|
|
454
461
|
u.push(h);
|
|
455
462
|
continue;
|
|
456
463
|
}
|
|
457
|
-
if (!
|
|
464
|
+
if (!f)
|
|
458
465
|
throw new Error(`Attachment bytes are unavailable for ${h.name}`);
|
|
459
|
-
u.push(await this.uploadAttachmentForMessage({ file:
|
|
466
|
+
u.push(await this.uploadAttachmentForMessage({ file: f, attachment: h }));
|
|
460
467
|
}
|
|
461
468
|
i = u;
|
|
462
469
|
} catch (u) {
|
|
@@ -466,12 +473,12 @@ class be {
|
|
|
466
473
|
}), u;
|
|
467
474
|
}
|
|
468
475
|
this.retryableClientMessageId = null;
|
|
469
|
-
const y = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url,
|
|
476
|
+
const y = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, m = {
|
|
470
477
|
type: "chat.user_message",
|
|
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,
|
|
@@ -480,14 +487,14 @@ class be {
|
|
|
480
487
|
model: this.options.model,
|
|
481
488
|
metadata: ie(this.options.metadata)
|
|
482
489
|
};
|
|
483
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent =
|
|
490
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = m, this.markThinkingProgress(), this.send(m), a;
|
|
484
491
|
}
|
|
485
492
|
retryLastMessage() {
|
|
486
493
|
const t = this.state.sessionId, s = this.retryableClientMessageId;
|
|
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),
|
|
@@ -550,8 +557,8 @@ 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,
|
|
@@ -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",
|
|
@@ -661,7 +668,7 @@ class be {
|
|
|
661
668
|
});
|
|
662
669
|
}
|
|
663
670
|
send(t) {
|
|
664
|
-
this.sendNow(k(t)) || (this.queuedClientEvents.push(t),
|
|
671
|
+
this.sendNow(k(t)) || (this.queuedClientEvents.push(t), W(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
665
672
|
}
|
|
666
673
|
async getUploadToken() {
|
|
667
674
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -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({
|
|
@@ -719,14 +726,14 @@ class be {
|
|
|
719
726
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
720
727
|
return;
|
|
721
728
|
const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
722
|
-
|
|
729
|
+
W(this.options.clientId, this.queuedClientEvents);
|
|
723
730
|
for (let s = 0; s < t.length; s += 1) {
|
|
724
731
|
const n = t[s];
|
|
725
732
|
if (!this.sendNow(k(n))) {
|
|
726
|
-
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)),
|
|
733
|
+
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), W(this.options.clientId, this.queuedClientEvents);
|
|
727
734
|
return;
|
|
728
735
|
}
|
|
729
|
-
|
|
736
|
+
W(this.options.clientId, this.queuedClientEvents);
|
|
730
737
|
}
|
|
731
738
|
}
|
|
732
739
|
handleServerEvent(t) {
|
|
@@ -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 =
|
|
750
|
+
const s = gn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
744
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,39 +773,39 @@ 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
|
|
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
|
-
const o = s.filter((
|
|
782
|
-
const
|
|
783
|
-
return !he(
|
|
784
|
-
}), a =
|
|
788
|
+
const o = s.filter((f) => {
|
|
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
|
-
(
|
|
789
|
-
L(
|
|
795
|
+
(f) => fe(
|
|
796
|
+
L(f),
|
|
790
797
|
this.state.assistantDraft,
|
|
791
798
|
this.state.assistantDraftItemId,
|
|
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);
|
|
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 =
|
|
799
|
-
const
|
|
800
|
-
if (this.latestRecoverableClientMessageId =
|
|
801
|
-
sessionId:
|
|
805
|
+
this.lastUserMessagePageUrl = Hn(s);
|
|
806
|
+
const h = y ? null : Ut(s);
|
|
807
|
+
if (this.latestRecoverableClientMessageId = h, m && this.clearRetryTimers(), this.setState({
|
|
808
|
+
sessionId: E(t.session, "id") ?? this.state.sessionId,
|
|
802
809
|
messages: a,
|
|
803
810
|
...r ? {
|
|
804
811
|
assistantDraft: n?.content ?? "",
|
|
@@ -817,27 +824,33 @@ class be {
|
|
|
817
824
|
isThinking: !0,
|
|
818
825
|
lastError: null
|
|
819
826
|
} : y ? {
|
|
820
|
-
isThinking: !1
|
|
821
|
-
|
|
827
|
+
isThinking: !1,
|
|
828
|
+
...u ? {
|
|
829
|
+
status: "connected",
|
|
830
|
+
lastError: null,
|
|
831
|
+
lastErrorCode: null,
|
|
832
|
+
lastErrorSecuritySettingsUrl: null
|
|
833
|
+
} : {}
|
|
834
|
+
} : h ? {
|
|
822
835
|
isThinking: !0,
|
|
823
836
|
lastError: null
|
|
824
837
|
} : {}
|
|
825
|
-
}), y ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (p ||
|
|
826
|
-
const
|
|
827
|
-
|
|
838
|
+
}), y ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (p || h) && (h && (this.activeClientMessageId = h), this.markThinkingProgress()), i) {
|
|
839
|
+
const f = E(t.session, "id") ?? this.state.sessionId;
|
|
840
|
+
f && this.retryAfterInterruptedRun(f, i);
|
|
828
841
|
}
|
|
829
842
|
return;
|
|
830
843
|
}
|
|
831
844
|
if (t.type === "sessions.page") {
|
|
832
845
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
833
846
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
834
|
-
sessions:
|
|
847
|
+
sessions: Sn(t.sessions),
|
|
835
848
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
836
849
|
}));
|
|
837
850
|
return;
|
|
838
851
|
}
|
|
839
852
|
if (t.type === "session.updated") {
|
|
840
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
853
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: E(t.session, "id") ?? this.state.sessionId });
|
|
841
854
|
return;
|
|
842
855
|
}
|
|
843
856
|
if (t.type === "session.item") {
|
|
@@ -845,7 +858,7 @@ class be {
|
|
|
845
858
|
const s = L(t.item);
|
|
846
859
|
if (Pt(s)) {
|
|
847
860
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
848
|
-
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);
|
|
849
862
|
if (r && a) {
|
|
850
863
|
this.retryAfterInterruptedRun(r, a);
|
|
851
864
|
return;
|
|
@@ -860,16 +873,16 @@ class be {
|
|
|
860
873
|
const n = Me(t.item, this.options.backendUrl);
|
|
861
874
|
if (n) {
|
|
862
875
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
863
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
876
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), q(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
864
877
|
const i = t.item.data;
|
|
865
|
-
|
|
878
|
+
zn(i) && this.clearRunAckResyncRetryTimer();
|
|
866
879
|
const o = Ce(this.state.messages, n), a = de(o), c = fe(
|
|
867
880
|
i,
|
|
868
881
|
this.state.assistantDraft,
|
|
869
882
|
this.state.assistantDraftItemId,
|
|
870
883
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
871
884
|
this.state.assistantDraftRunId
|
|
872
|
-
), l = a && (!this.state.assistantDraft || c);
|
|
885
|
+
), l = a && (!this.state.assistantDraft || c), d = l && q(n);
|
|
873
886
|
this.setState({
|
|
874
887
|
messages: o,
|
|
875
888
|
...c ? {
|
|
@@ -879,7 +892,15 @@ class be {
|
|
|
879
892
|
assistantDraftRespondsToUserMessageId: null,
|
|
880
893
|
assistantDraftRunId: null
|
|
881
894
|
} : {},
|
|
882
|
-
...l ? {
|
|
895
|
+
...l ? {
|
|
896
|
+
isThinking: !1
|
|
897
|
+
} : {},
|
|
898
|
+
...d ? {
|
|
899
|
+
status: "connected",
|
|
900
|
+
lastError: null,
|
|
901
|
+
lastErrorCode: null,
|
|
902
|
+
lastErrorSecuritySettingsUrl: null
|
|
903
|
+
} : {}
|
|
883
904
|
}), l && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
884
905
|
}
|
|
885
906
|
return;
|
|
@@ -915,9 +936,9 @@ class be {
|
|
|
915
936
|
}
|
|
916
937
|
if (t.type === "tool.call") {
|
|
917
938
|
this.clearRunAckResyncRetryTimer();
|
|
918
|
-
const s =
|
|
939
|
+
const s = Dn(t);
|
|
919
940
|
if (s) {
|
|
920
|
-
const n =
|
|
941
|
+
const n = Pn(
|
|
921
942
|
this.state.messages,
|
|
922
943
|
s
|
|
923
944
|
);
|
|
@@ -958,7 +979,7 @@ class be {
|
|
|
958
979
|
return;
|
|
959
980
|
}
|
|
960
981
|
o && r && i && (this.retryableClientMessageId = i);
|
|
961
|
-
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);
|
|
962
983
|
c && console.error(c), this.setState({
|
|
963
984
|
status: "error",
|
|
964
985
|
isThinking: !1,
|
|
@@ -984,7 +1005,7 @@ class be {
|
|
|
984
1005
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
985
1006
|
return !0;
|
|
986
1007
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
987
|
-
if (i >=
|
|
1008
|
+
if (i >= J)
|
|
988
1009
|
return !1;
|
|
989
1010
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
990
1011
|
const o = V(
|
|
@@ -1004,7 +1025,7 @@ class be {
|
|
|
1004
1025
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1005
1026
|
return;
|
|
1006
1027
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1007
|
-
if (n >=
|
|
1028
|
+
if (n >= J) {
|
|
1008
1029
|
this.retryableClientMessageId = s, this.setState({
|
|
1009
1030
|
isThinking: !1,
|
|
1010
1031
|
lastError: "Pluno could not finish this message. Try it again.",
|
|
@@ -1023,7 +1044,7 @@ class be {
|
|
|
1023
1044
|
}
|
|
1024
1045
|
rememberUserMessageClientMessageIds(t) {
|
|
1025
1046
|
for (const s of t) {
|
|
1026
|
-
const n =
|
|
1047
|
+
const n = E(s, "id"), r = L(s);
|
|
1027
1048
|
n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
|
|
1028
1049
|
}
|
|
1029
1050
|
}
|
|
@@ -1053,7 +1074,7 @@ class be {
|
|
|
1053
1074
|
scheduleRunAckWatchdog(t) {
|
|
1054
1075
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1055
1076
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1056
|
-
},
|
|
1077
|
+
}, Ss);
|
|
1057
1078
|
}
|
|
1058
1079
|
recoverMissedRunAck(t) {
|
|
1059
1080
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (A("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1064,7 +1085,7 @@ class be {
|
|
|
1064
1085
|
scheduleRunAckResyncRetry(t) {
|
|
1065
1086
|
this.clearRunAckResyncRetryTimer();
|
|
1066
1087
|
const s = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1067
|
-
s >=
|
|
1088
|
+
s >= J || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1068
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({
|
|
1069
1090
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1070
1091
|
isThinking: !0,
|
|
@@ -1078,7 +1099,7 @@ class be {
|
|
|
1078
1099
|
clientMessageId: t,
|
|
1079
1100
|
automatic: !0
|
|
1080
1101
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ne)));
|
|
1081
|
-
}, V(s,
|
|
1102
|
+
}, V(s, Es)));
|
|
1082
1103
|
}
|
|
1083
1104
|
clearRunAckResyncRetryTimer() {
|
|
1084
1105
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1101,7 +1122,7 @@ class be {
|
|
|
1101
1122
|
return;
|
|
1102
1123
|
}
|
|
1103
1124
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1104
|
-
if (n >=
|
|
1125
|
+
if (n >= J) {
|
|
1105
1126
|
A("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1106
1127
|
sessionId: this.state.sessionId,
|
|
1107
1128
|
clientMessageId: t
|
|
@@ -1117,7 +1138,7 @@ class be {
|
|
|
1117
1138
|
sessionId: this.state.sessionId,
|
|
1118
1139
|
clientMessageId: t,
|
|
1119
1140
|
resyncAttempts: s + 1
|
|
1120
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1141
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(As);
|
|
1121
1142
|
return;
|
|
1122
1143
|
}
|
|
1123
1144
|
this.setState({
|
|
@@ -1146,13 +1167,13 @@ class be {
|
|
|
1146
1167
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
|
|
1147
1168
|
}
|
|
1148
1169
|
async executeToolCall(t) {
|
|
1149
|
-
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(
|
|
1150
1171
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
1151
1172
|
), o = t.rawInput;
|
|
1152
1173
|
if (!s || !n || !r)
|
|
1153
1174
|
return;
|
|
1154
1175
|
const a = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1155
|
-
if (r !== "execute_code" && !a || !
|
|
1176
|
+
if (r !== "execute_code" && !a || !ur(o)) {
|
|
1156
1177
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1157
1178
|
type: "tool.result",
|
|
1158
1179
|
sessionId: s,
|
|
@@ -1184,7 +1205,7 @@ class be {
|
|
|
1184
1205
|
});
|
|
1185
1206
|
return;
|
|
1186
1207
|
}
|
|
1187
|
-
const c =
|
|
1208
|
+
const c = qs(this.state.messages);
|
|
1188
1209
|
this.activeBrowserToolCalls.set(n, {
|
|
1189
1210
|
event: {
|
|
1190
1211
|
type: "tool.result",
|
|
@@ -1202,7 +1223,7 @@ class be {
|
|
|
1202
1223
|
let l = null, d;
|
|
1203
1224
|
l = await this.executeRuntimeHelper(), d = await oe(
|
|
1204
1225
|
o,
|
|
1205
|
-
|
|
1226
|
+
Vs(t.runtimeContext, this.options.backendUrl)
|
|
1206
1227
|
).catch((p) => ({
|
|
1207
1228
|
ok: !1,
|
|
1208
1229
|
exception: {
|
|
@@ -1215,11 +1236,11 @@ class be {
|
|
|
1215
1236
|
toolName: r,
|
|
1216
1237
|
summary: o.summary,
|
|
1217
1238
|
rawInput: k(o),
|
|
1218
|
-
rawOutput: k(
|
|
1219
|
-
}),
|
|
1239
|
+
rawOutput: k(yn(d, l))
|
|
1240
|
+
}), er(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1220
1241
|
}
|
|
1221
1242
|
setToolMessageLoading(t, s) {
|
|
1222
|
-
const n =
|
|
1243
|
+
const n = Un(
|
|
1223
1244
|
this.state.messages,
|
|
1224
1245
|
t,
|
|
1225
1246
|
s
|
|
@@ -1237,10 +1258,10 @@ class be {
|
|
|
1237
1258
|
};
|
|
1238
1259
|
}
|
|
1239
1260
|
installSessionUserFilesApi(t) {
|
|
1240
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1261
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Hs(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1241
1262
|
}
|
|
1242
1263
|
cleanupSessionUserFilesApi() {
|
|
1243
|
-
this.sessionUserFilesApiCleanup && (
|
|
1264
|
+
this.sessionUserFilesApiCleanup && (Ks(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1244
1265
|
}
|
|
1245
1266
|
async executeRuntimeHelper() {
|
|
1246
1267
|
if (!this.runtimeHelperJavascript?.trim())
|
|
@@ -1248,15 +1269,15 @@ class be {
|
|
|
1248
1269
|
const t = await oe({
|
|
1249
1270
|
javascript: this.runtimeHelperJavascript
|
|
1250
1271
|
});
|
|
1251
|
-
return t.ok === !1 ?
|
|
1272
|
+
return t.ok === !1 ? Tn(t) : null;
|
|
1252
1273
|
}
|
|
1253
1274
|
enableNetworkCapture() {
|
|
1254
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1255
|
-
|
|
1275
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = vs((t) => {
|
|
1276
|
+
mr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1256
1277
|
}));
|
|
1257
1278
|
}
|
|
1258
1279
|
enqueueNetworkEvent(t) {
|
|
1259
|
-
this.queuedNetworkEvents.length >=
|
|
1280
|
+
this.queuedNetworkEvents.length >= ks || (this.queuedNetworkEvents.push(gr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1260
1281
|
this.networkBatchTimer = null;
|
|
1261
1282
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1262
1283
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1265,12 +1286,12 @@ class be {
|
|
|
1265
1286
|
page: _(),
|
|
1266
1287
|
events: s
|
|
1267
1288
|
});
|
|
1268
|
-
},
|
|
1289
|
+
}, bs)));
|
|
1269
1290
|
}
|
|
1270
1291
|
scheduleReconnect() {
|
|
1271
1292
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1272
1293
|
return;
|
|
1273
|
-
const t =
|
|
1294
|
+
const t = Ds(this.reconnectAttempts);
|
|
1274
1295
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1275
1296
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1276
1297
|
A("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1286,8 +1307,8 @@ class be {
|
|
|
1286
1307
|
const t = this.socket;
|
|
1287
1308
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1288
1309
|
this.socket === t && (A("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1289
|
-
},
|
|
1290
|
-
},
|
|
1310
|
+
}, ms));
|
|
1311
|
+
}, gs);
|
|
1291
1312
|
}
|
|
1292
1313
|
stopHeartbeat() {
|
|
1293
1314
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1313,39 +1334,39 @@ class be {
|
|
|
1313
1334
|
...t,
|
|
1314
1335
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1315
1336
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1316
|
-
},
|
|
1337
|
+
}, Qn(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
1317
1338
|
}
|
|
1318
1339
|
emit(t, s) {
|
|
1319
1340
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1320
1341
|
}
|
|
1321
1342
|
}
|
|
1322
1343
|
const St = /* @__PURE__ */ new WeakMap();
|
|
1323
|
-
function
|
|
1324
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1344
|
+
function vs(e) {
|
|
1345
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Ns();
|
|
1325
1346
|
return t.subscribers.add(e), () => {
|
|
1326
1347
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1327
1348
|
};
|
|
1328
1349
|
}
|
|
1329
|
-
function
|
|
1350
|
+
function Ns() {
|
|
1330
1351
|
const e = /* @__PURE__ */ new Set(), t = (y) => {
|
|
1331
|
-
e.forEach((
|
|
1352
|
+
e.forEach((m) => {
|
|
1332
1353
|
try {
|
|
1333
|
-
|
|
1354
|
+
m(y);
|
|
1334
1355
|
} catch {
|
|
1335
1356
|
}
|
|
1336
1357
|
});
|
|
1337
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(
|
|
1358
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(m, u) {
|
|
1338
1359
|
const h = Date.now();
|
|
1339
|
-
let
|
|
1360
|
+
let f;
|
|
1340
1361
|
try {
|
|
1341
|
-
|
|
1362
|
+
f = s.call(this, m, u);
|
|
1342
1363
|
} catch (T) {
|
|
1343
1364
|
throw T;
|
|
1344
1365
|
}
|
|
1345
1366
|
try {
|
|
1346
|
-
const T =
|
|
1347
|
-
if (!
|
|
1348
|
-
const
|
|
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)) {
|
|
1369
|
+
const H = {
|
|
1349
1370
|
requestId: kt("fetch"),
|
|
1350
1371
|
url: C(x, At),
|
|
1351
1372
|
method: (u?.method ?? T?.method ?? "GET").toUpperCase(),
|
|
@@ -1354,11 +1375,11 @@ function xs() {
|
|
|
1354
1375
|
resourceType: "fetch",
|
|
1355
1376
|
startedAt: new Date(h).toISOString()
|
|
1356
1377
|
};
|
|
1357
|
-
|
|
1378
|
+
f.then(
|
|
1358
1379
|
(R) => {
|
|
1359
|
-
|
|
1380
|
+
hr(R, H, h, t).catch(() => {
|
|
1360
1381
|
t({
|
|
1361
|
-
...
|
|
1382
|
+
...H,
|
|
1362
1383
|
responseStatus: R.status,
|
|
1363
1384
|
durationMs: Date.now() - h
|
|
1364
1385
|
});
|
|
@@ -1366,7 +1387,7 @@ function xs() {
|
|
|
1366
1387
|
},
|
|
1367
1388
|
(R) => {
|
|
1368
1389
|
t({
|
|
1369
|
-
...
|
|
1390
|
+
...H,
|
|
1370
1391
|
errorText: C(R instanceof Error ? R.message : String(R)),
|
|
1371
1392
|
durationMs: Date.now() - h
|
|
1372
1393
|
});
|
|
@@ -1375,30 +1396,30 @@ function xs() {
|
|
|
1375
1396
|
}
|
|
1376
1397
|
} catch {
|
|
1377
1398
|
}
|
|
1378
|
-
return
|
|
1379
|
-
}, a = function(
|
|
1380
|
-
const x = n.call(this,
|
|
1399
|
+
return f;
|
|
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();
|
|
1381
1402
|
return St.set(this, {
|
|
1382
1403
|
requestId: kt("xhr"),
|
|
1383
|
-
method: String(
|
|
1404
|
+
method: String(m ?? "GET").toUpperCase(),
|
|
1384
1405
|
url: C(I, At),
|
|
1385
1406
|
requestHeaders: {},
|
|
1386
1407
|
startedAtMs: Date.now(),
|
|
1387
1408
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1388
|
-
excluded:
|
|
1409
|
+
excluded: N(I)
|
|
1389
1410
|
}), x;
|
|
1390
|
-
}, c = function(
|
|
1391
|
-
const h = r.call(this,
|
|
1392
|
-
return
|
|
1393
|
-
}, l = function(
|
|
1411
|
+
}, c = function(m, u) {
|
|
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;
|
|
1414
|
+
}, l = function(m) {
|
|
1394
1415
|
try {
|
|
1395
1416
|
const u = St.get(this);
|
|
1396
|
-
u && (u.excluded = u.excluded ||
|
|
1417
|
+
u && (u.excluded = u.excluded || N(u.url, u.requestHeaders, m), u.requestBody = ye(m), u.excluded || this.addEventListener(
|
|
1397
1418
|
"loadend",
|
|
1398
1419
|
() => {
|
|
1399
1420
|
queueMicrotask(() => {
|
|
1400
1421
|
try {
|
|
1401
|
-
const h =
|
|
1422
|
+
const h = Tr(this.getAllResponseHeaders());
|
|
1402
1423
|
t({
|
|
1403
1424
|
requestId: u.requestId,
|
|
1404
1425
|
url: u.url,
|
|
@@ -1408,7 +1429,7 @@ function xs() {
|
|
|
1408
1429
|
resourceType: "xhr",
|
|
1409
1430
|
responseStatus: this.status,
|
|
1410
1431
|
responseHeaders: h,
|
|
1411
|
-
responseBody:
|
|
1432
|
+
responseBody: fr(this, h),
|
|
1412
1433
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1413
1434
|
startedAt: u.startedAt,
|
|
1414
1435
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -1422,7 +1443,7 @@ function xs() {
|
|
|
1422
1443
|
));
|
|
1423
1444
|
} catch {
|
|
1424
1445
|
}
|
|
1425
|
-
return i.call(this,
|
|
1446
|
+
return i.call(this, m ?? null);
|
|
1426
1447
|
};
|
|
1427
1448
|
try {
|
|
1428
1449
|
window.fetch = o;
|
|
@@ -1443,9 +1464,9 @@ function xs() {
|
|
|
1443
1464
|
let d = null;
|
|
1444
1465
|
if (typeof PerformanceObserver < "u") {
|
|
1445
1466
|
d = new PerformanceObserver((y) => {
|
|
1446
|
-
for (const
|
|
1447
|
-
const u =
|
|
1448
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
1467
|
+
for (const m of y.getEntries()) {
|
|
1468
|
+
const u = m;
|
|
1469
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || N(u.name))
|
|
1449
1470
|
continue;
|
|
1450
1471
|
const h = performance.timeOrigin + u.startTime;
|
|
1451
1472
|
t({
|
|
@@ -1504,11 +1525,11 @@ function ie(e) {
|
|
|
1504
1525
|
const t = typeof e == "function" ? e() : e;
|
|
1505
1526
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1506
1527
|
}
|
|
1507
|
-
function
|
|
1528
|
+
function Os(e) {
|
|
1508
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";
|
|
1509
1530
|
}
|
|
1510
|
-
const
|
|
1511
|
-
function
|
|
1531
|
+
const Ls = 5e3, Bs = 12e4;
|
|
1532
|
+
function qs(e) {
|
|
1512
1533
|
const t = [];
|
|
1513
1534
|
for (const s of e)
|
|
1514
1535
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1519,26 +1540,26 @@ function Ls(e) {
|
|
|
1519
1540
|
});
|
|
1520
1541
|
return t;
|
|
1521
1542
|
}
|
|
1522
|
-
function
|
|
1543
|
+
function Hs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1523
1544
|
const n = [
|
|
1524
|
-
|
|
1525
|
-
|
|
1545
|
+
$s(),
|
|
1546
|
+
Fs()
|
|
1526
1547
|
].filter((r) => typeof r == "function");
|
|
1527
1548
|
return () => {
|
|
1528
1549
|
for (const r of n.reverse())
|
|
1529
1550
|
r();
|
|
1530
1551
|
};
|
|
1531
1552
|
}
|
|
1532
|
-
function
|
|
1533
|
-
return
|
|
1553
|
+
function Fs() {
|
|
1554
|
+
return Ie(globalThis, "getPageSnapshot", async () => qt());
|
|
1534
1555
|
}
|
|
1535
|
-
function
|
|
1536
|
-
return
|
|
1537
|
-
inspectImage: async (t, s) => await
|
|
1556
|
+
function $s() {
|
|
1557
|
+
return Ie(globalThis, "pageImages", {
|
|
1558
|
+
inspectImage: async (t, s) => await Ws(t, s)
|
|
1538
1559
|
});
|
|
1539
1560
|
}
|
|
1540
|
-
async function
|
|
1541
|
-
const s =
|
|
1561
|
+
async function Ws(e, t = {}) {
|
|
1562
|
+
const s = Xs(t.name), n = await js(e);
|
|
1542
1563
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1543
1564
|
type: "pluno.pageImages.inspectImage",
|
|
1544
1565
|
imageAttached: !1,
|
|
@@ -1556,15 +1577,15 @@ async function Fs(e, t = {}) {
|
|
|
1556
1577
|
imageAttachmentError: n.error
|
|
1557
1578
|
};
|
|
1558
1579
|
}
|
|
1559
|
-
async function
|
|
1580
|
+
async function js(e) {
|
|
1560
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 } : {
|
|
1561
1582
|
ok: !0,
|
|
1562
1583
|
mimeType: e.type,
|
|
1563
1584
|
sizeBytes: e.size,
|
|
1564
|
-
dataUrl: await
|
|
1565
|
-
} : { 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);
|
|
1566
1587
|
}
|
|
1567
|
-
function
|
|
1588
|
+
function zs(e) {
|
|
1568
1589
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1569
1590
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1570
1591
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1575,7 +1596,7 @@ function Ws(e) {
|
|
|
1575
1596
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1576
1597
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1577
1598
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1578
|
-
const o =
|
|
1599
|
+
const o = Gs(i);
|
|
1579
1600
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1580
1601
|
ok: !0,
|
|
1581
1602
|
mimeType: r,
|
|
@@ -1583,22 +1604,22 @@ function Ws(e) {
|
|
|
1583
1604
|
dataUrl: `data:${r};base64,${i}`
|
|
1584
1605
|
};
|
|
1585
1606
|
}
|
|
1586
|
-
function
|
|
1607
|
+
function Gs(e) {
|
|
1587
1608
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1588
1609
|
return null;
|
|
1589
1610
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1590
1611
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1591
1612
|
}
|
|
1592
|
-
function
|
|
1613
|
+
function Xs(e) {
|
|
1593
1614
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1594
1615
|
}
|
|
1595
|
-
function
|
|
1616
|
+
function Ks(e) {
|
|
1596
1617
|
try {
|
|
1597
1618
|
e();
|
|
1598
1619
|
} catch {
|
|
1599
1620
|
}
|
|
1600
1621
|
}
|
|
1601
|
-
function
|
|
1622
|
+
function Js(e) {
|
|
1602
1623
|
return new Promise((t, s) => {
|
|
1603
1624
|
const n = new FileReader();
|
|
1604
1625
|
n.onload = () => {
|
|
@@ -1612,7 +1633,7 @@ function Xs(e) {
|
|
|
1612
1633
|
}
|
|
1613
1634
|
async function oe(e, t) {
|
|
1614
1635
|
const s = Object.getPrototypeOf(async function() {
|
|
1615
|
-
}).constructor, n = e.timeoutMs ??
|
|
1636
|
+
}).constructor, n = e.timeoutMs ?? Ls, r = Date.now(), i = [];
|
|
1616
1637
|
let o;
|
|
1617
1638
|
const a = {
|
|
1618
1639
|
log: console.log,
|
|
@@ -1630,7 +1651,7 @@ async function oe(e, t) {
|
|
|
1630
1651
|
o = window.setTimeout(() => p(l), n);
|
|
1631
1652
|
})
|
|
1632
1653
|
]);
|
|
1633
|
-
return d === l ?
|
|
1654
|
+
return d === l ? Ys(n) : {
|
|
1634
1655
|
ok: !0,
|
|
1635
1656
|
result: d,
|
|
1636
1657
|
console: i,
|
|
@@ -1659,7 +1680,7 @@ async function oe(e, t) {
|
|
|
1659
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;
|
|
1660
1681
|
}
|
|
1661
1682
|
}
|
|
1662
|
-
function
|
|
1683
|
+
function Vs(e, t) {
|
|
1663
1684
|
if (!e || typeof e != "object")
|
|
1664
1685
|
return;
|
|
1665
1686
|
const s = e.sandboxFilesToken;
|
|
@@ -1669,7 +1690,7 @@ function Js(e, t) {
|
|
|
1669
1690
|
const r = () => {
|
|
1670
1691
|
if (!n)
|
|
1671
1692
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
1672
|
-
}, i = async (a, c) => await
|
|
1693
|
+
}, i = async (a, c) => await ls(`${t.replace(/\/$/, "")}${a}`, c);
|
|
1673
1694
|
return {
|
|
1674
1695
|
value: Object.freeze({
|
|
1675
1696
|
upload: async (a) => {
|
|
@@ -1703,7 +1724,7 @@ function Js(e, t) {
|
|
|
1703
1724
|
}
|
|
1704
1725
|
};
|
|
1705
1726
|
}
|
|
1706
|
-
function
|
|
1727
|
+
function Ys(e) {
|
|
1707
1728
|
return {
|
|
1708
1729
|
ok: !1,
|
|
1709
1730
|
exception: {
|
|
@@ -1717,10 +1738,10 @@ function Ks(e) {
|
|
|
1717
1738
|
}
|
|
1718
1739
|
};
|
|
1719
1740
|
}
|
|
1720
|
-
function
|
|
1741
|
+
function Zs(e) {
|
|
1721
1742
|
return e.replace(/\/+$/, "");
|
|
1722
1743
|
}
|
|
1723
|
-
function
|
|
1744
|
+
function Qs(e) {
|
|
1724
1745
|
const t = {
|
|
1725
1746
|
sidepanel: "extension_sidepanel",
|
|
1726
1747
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -1732,13 +1753,13 @@ function Ys(e) {
|
|
|
1732
1753
|
};
|
|
1733
1754
|
return e && e in t ? t[e] : e ?? "embedded_custom_ui";
|
|
1734
1755
|
}
|
|
1735
|
-
function
|
|
1756
|
+
function tn(e) {
|
|
1736
1757
|
return e === "pluno" ? "scheduled_continuation" : e ?? "user";
|
|
1737
1758
|
}
|
|
1738
|
-
function
|
|
1759
|
+
function en(e, t = location.origin) {
|
|
1739
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;
|
|
1740
1761
|
}
|
|
1741
|
-
function
|
|
1762
|
+
function sn(e) {
|
|
1742
1763
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1743
1764
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1744
1765
|
}
|
|
@@ -1751,19 +1772,19 @@ function _() {
|
|
|
1751
1772
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1752
1773
|
};
|
|
1753
1774
|
}
|
|
1754
|
-
function
|
|
1775
|
+
function nn() {
|
|
1755
1776
|
return {
|
|
1756
1777
|
pageUrl: location.href,
|
|
1757
1778
|
pageTitle: document.title,
|
|
1758
1779
|
htmlContent: qt()
|
|
1759
1780
|
};
|
|
1760
1781
|
}
|
|
1761
|
-
function
|
|
1762
|
-
return tt.add(e), Y || (Y =
|
|
1782
|
+
function rn(e) {
|
|
1783
|
+
return tt.add(e), Y || (Y = on()), () => {
|
|
1763
1784
|
tt.delete(e), tt.size === 0 && (Y?.(), Y = null);
|
|
1764
1785
|
};
|
|
1765
1786
|
}
|
|
1766
|
-
function
|
|
1787
|
+
function on() {
|
|
1767
1788
|
const e = () => {
|
|
1768
1789
|
for (const i of Array.from(tt))
|
|
1769
1790
|
i();
|
|
@@ -1778,35 +1799,35 @@ function nn() {
|
|
|
1778
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);
|
|
1779
1800
|
};
|
|
1780
1801
|
}
|
|
1781
|
-
function
|
|
1802
|
+
function an() {
|
|
1782
1803
|
return _e()?.surface === "browser_extension_sdk_preview";
|
|
1783
1804
|
}
|
|
1784
1805
|
function qt() {
|
|
1785
1806
|
if (!document.body)
|
|
1786
1807
|
return "";
|
|
1787
|
-
const e = [], t = [], s = (h,
|
|
1788
|
-
const T = B(
|
|
1808
|
+
const e = [], t = [], s = (h, f) => {
|
|
1809
|
+
const T = B(f);
|
|
1789
1810
|
!T || t.includes(T) || (e.push([h, T]), t.push(T));
|
|
1790
1811
|
};
|
|
1791
1812
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
1792
1813
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
1793
|
-
(h) =>
|
|
1814
|
+
(h) => be(h) && !h.parentElement?.closest(n)
|
|
1794
1815
|
);
|
|
1795
1816
|
for (const h of r.slice(0, 3))
|
|
1796
|
-
s("Active overlay",
|
|
1797
|
-
const i =
|
|
1798
|
-
s("Main page content", o), s("Additional visible page text",
|
|
1799
|
-
const a = e.map(([h,
|
|
1800
|
-
${
|
|
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));
|
|
1820
|
+
const a = e.map(([h, f]) => `${h}:
|
|
1821
|
+
${f}`).join(`
|
|
1801
1822
|
|
|
1802
|
-
`).trim().slice(0, 12e3), c =
|
|
1823
|
+
`).trim().slice(0, 12e3), c = ln(r, i).trim(), l = `Simplified DOM outline:
|
|
1803
1824
|
`, d = `
|
|
1804
1825
|
|
|
1805
1826
|
Visible page text:
|
|
1806
|
-
`, p = 12e3 - l.length - d.length, y = Math.min(a.length, 7900),
|
|
1807
|
-
return `${l}${
|
|
1827
|
+
`, p = 12e3 - l.length - d.length, y = Math.min(a.length, 7900), m = c.slice(0, p - y), u = a.slice(0, p - m.length);
|
|
1828
|
+
return `${l}${m}${d}${u}`;
|
|
1808
1829
|
}
|
|
1809
|
-
function
|
|
1830
|
+
function j(e) {
|
|
1810
1831
|
return e.innerText ?? e.textContent ?? "";
|
|
1811
1832
|
}
|
|
1812
1833
|
function B(e) {
|
|
@@ -1817,20 +1838,20 @@ function B(e) {
|
|
|
1817
1838
|
|
|
1818
1839
|
`).trim();
|
|
1819
1840
|
}
|
|
1820
|
-
function
|
|
1841
|
+
function Et(e, t) {
|
|
1821
1842
|
let s = B(e);
|
|
1822
1843
|
for (const n of t)
|
|
1823
1844
|
s = s.replace(n, "");
|
|
1824
1845
|
return B(s);
|
|
1825
1846
|
}
|
|
1826
|
-
function
|
|
1847
|
+
function be(e) {
|
|
1827
1848
|
const t = window.getComputedStyle(e);
|
|
1828
1849
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
1829
1850
|
}
|
|
1830
|
-
function
|
|
1831
|
-
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;
|
|
1832
1853
|
}
|
|
1833
|
-
function
|
|
1854
|
+
function ln(e, t) {
|
|
1834
1855
|
const s = /* @__PURE__ */ new Set([
|
|
1835
1856
|
"main",
|
|
1836
1857
|
"nav",
|
|
@@ -1910,22 +1931,22 @@ function an(e, t) {
|
|
|
1910
1931
|
"data-test",
|
|
1911
1932
|
"data-qa",
|
|
1912
1933
|
"data-cy"
|
|
1913
|
-
], 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);
|
|
1914
1935
|
t && y.add(t);
|
|
1915
|
-
let
|
|
1936
|
+
let m = 0;
|
|
1916
1937
|
const u = (I) => {
|
|
1917
1938
|
const U = I.getAttribute("role");
|
|
1918
1939
|
return U && !o.has(U) ? U : "";
|
|
1919
1940
|
}, h = (I) => {
|
|
1920
1941
|
const U = I.getAttribute("data-testid") || I.getAttribute("data-test") || I.getAttribute("data-qa") || I.getAttribute("data-cy") || "";
|
|
1921
1942
|
return `${I.tagName.toLowerCase()}|${u(I)}|${U}`;
|
|
1922
|
-
},
|
|
1943
|
+
}, f = (I, U, H) => {
|
|
1923
1944
|
const R = (S, ct) => {
|
|
1924
|
-
const
|
|
1925
|
-
if (
|
|
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")
|
|
1926
1947
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
1927
|
-
|
|
1928
|
-
const zt = u(S), G = Re(S), je = a.has(zt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(
|
|
1948
|
+
m += 1;
|
|
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();
|
|
1929
1950
|
for (const g of ut) {
|
|
1930
1951
|
const w = h(g);
|
|
1931
1952
|
X.set(w, (X.get(w) ?? 0) + 1);
|
|
@@ -1935,57 +1956,57 @@ function an(e, t) {
|
|
|
1935
1956
|
const w = h(g), D = Gt.get(w) ?? 0;
|
|
1936
1957
|
Gt.set(w, D + 1), (X.get(w) ?? 0) > 8 && D >= 6 && !d.has(g) && dt.set(w, (dt.get(w) ?? 0) + 1);
|
|
1937
1958
|
}
|
|
1938
|
-
const Xt = /* @__PURE__ */ new Map(),
|
|
1959
|
+
const Xt = /* @__PURE__ */ new Map(), Kt = /* @__PURE__ */ new Set(), ht = [], Jt = [];
|
|
1939
1960
|
for (const g of ut) {
|
|
1940
1961
|
const w = h(g), D = X.get(w) ?? 0, Zt = Xt.get(w) ?? 0;
|
|
1941
1962
|
if (Xt.set(w, Zt + 1), D > 8 && Zt >= 6 && !d.has(g)) {
|
|
1942
|
-
|
|
1963
|
+
Kt.has(w) || (ht.push([`… ${dt.get(w) ?? 0} similar siblings omitted`]), Kt.add(w));
|
|
1943
1964
|
continue;
|
|
1944
1965
|
}
|
|
1945
1966
|
const Qt = R(g, ct);
|
|
1946
|
-
|
|
1967
|
+
Jt.push(Qt), ht.push(Qt.lines);
|
|
1947
1968
|
}
|
|
1948
1969
|
const pt = [];
|
|
1949
1970
|
if (S.shadowRoot)
|
|
1950
1971
|
for (const g of Array.from(S.shadowRoot.children))
|
|
1951
1972
|
g instanceof HTMLElement && pt.push(R(g, ct + 1));
|
|
1952
|
-
const
|
|
1953
|
-
[G, ...
|
|
1954
|
-
).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(
|
|
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 = [];
|
|
1955
1976
|
if (gt) {
|
|
1956
|
-
const g =
|
|
1957
|
-
|
|
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)));
|
|
1958
1979
|
}
|
|
1959
1980
|
for (const g of ht)
|
|
1960
|
-
|
|
1981
|
+
F.push(...Z(g, mt));
|
|
1961
1982
|
const yt = pt.flatMap((g) => g.lines);
|
|
1962
1983
|
if (yt.length > 0) {
|
|
1963
1984
|
const g = yt.slice(0, 20);
|
|
1964
1985
|
yt.length > g.length && g.push("… shadow DOM omitted");
|
|
1965
|
-
const w =
|
|
1986
|
+
const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
|
|
1966
1987
|
if (ct < 2 && !w) {
|
|
1967
|
-
const D = gt ? "#shadow-root" : `${
|
|
1968
|
-
|
|
1988
|
+
const D = gt ? "#shadow-root" : `${b} #shadow-root`;
|
|
1989
|
+
F.push(...Z([D, ...Z(g, 1)], mt));
|
|
1969
1990
|
} else
|
|
1970
|
-
|
|
1991
|
+
F.push(...Z(g, mt));
|
|
1971
1992
|
}
|
|
1972
1993
|
return {
|
|
1973
|
-
lines:
|
|
1994
|
+
lines: F,
|
|
1974
1995
|
hasUsefulContent: ft,
|
|
1975
1996
|
textPreview: Vt,
|
|
1976
|
-
containsTextElement: n.has(
|
|
1997
|
+
containsTextElement: n.has(b) || K.some((g) => g.containsTextElement)
|
|
1977
1998
|
};
|
|
1978
1999
|
};
|
|
1979
2000
|
return [`--- ${U} ---`, ...R(I, 0).lines].join(`
|
|
1980
2001
|
`);
|
|
1981
2002
|
}, T = [], x = B(window.getSelection()?.toString() ?? "");
|
|
1982
2003
|
x && T.push(`--- selected text ---
|
|
1983
|
-
${JSON.stringify(x)}`), p.length > 0 && T.push(
|
|
2004
|
+
${JSON.stringify(x)}`), p.length > 0 && T.push(dn(p, s, c, o));
|
|
1984
2005
|
for (const I of e.slice(0, 3))
|
|
1985
|
-
T.push(
|
|
1986
|
-
if (t && T.push(
|
|
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) {
|
|
1987
2008
|
const I = t || e.length ? "other visible DOM" : "visible DOM";
|
|
1988
|
-
T.push(
|
|
2009
|
+
T.push(f(document.body, I, y));
|
|
1989
2010
|
}
|
|
1990
2011
|
return T.join(`
|
|
1991
2012
|
|
|
@@ -1995,7 +2016,7 @@ function ke(e, t, s, n) {
|
|
|
1995
2016
|
const r = e.tagName.toLowerCase();
|
|
1996
2017
|
let i = r;
|
|
1997
2018
|
const o = e.getAttribute("id");
|
|
1998
|
-
o &&
|
|
2019
|
+
o && hn(o) && (i += `#${o}`);
|
|
1999
2020
|
for (const a of t) {
|
|
2000
2021
|
const c = e.getAttribute(a);
|
|
2001
2022
|
c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
|
|
@@ -2008,7 +2029,7 @@ function ke(e, t, s, n) {
|
|
|
2008
2029
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2009
2030
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2010
2031
|
}
|
|
2011
|
-
function
|
|
2032
|
+
function un() {
|
|
2012
2033
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
|
|
2013
2034
|
if (!a)
|
|
2014
2035
|
return;
|
|
@@ -2051,7 +2072,7 @@ function cn() {
|
|
|
2051
2072
|
priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
|
|
2052
2073
|
};
|
|
2053
2074
|
}
|
|
2054
|
-
function
|
|
2075
|
+
function dn(e, t, s, n) {
|
|
2055
2076
|
const r = ["--- active/current elements ---"];
|
|
2056
2077
|
for (const i of e) {
|
|
2057
2078
|
const o = [];
|
|
@@ -2087,7 +2108,7 @@ function Re(e) {
|
|
|
2087
2108
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2088
2109
|
);
|
|
2089
2110
|
}
|
|
2090
|
-
function
|
|
2111
|
+
function hn(e) {
|
|
2091
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);
|
|
2092
2113
|
}
|
|
2093
2114
|
function _e() {
|
|
@@ -2106,23 +2127,23 @@ function _e() {
|
|
|
2106
2127
|
},
|
|
2107
2128
|
{
|
|
2108
2129
|
name: "widget_root",
|
|
2109
|
-
selector:
|
|
2130
|
+
selector: us,
|
|
2110
2131
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2111
2132
|
},
|
|
2112
2133
|
{
|
|
2113
2134
|
name: "widget_panel",
|
|
2114
|
-
selector:
|
|
2135
|
+
selector: ds,
|
|
2115
2136
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2116
2137
|
},
|
|
2117
2138
|
{
|
|
2118
2139
|
name: "widget_timeline",
|
|
2119
|
-
selector:
|
|
2140
|
+
selector: hs,
|
|
2120
2141
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2121
2142
|
}
|
|
2122
2143
|
]
|
|
2123
2144
|
};
|
|
2124
2145
|
}
|
|
2125
|
-
function
|
|
2146
|
+
function pn(e) {
|
|
2126
2147
|
try {
|
|
2127
2148
|
const t = JSON.parse(e);
|
|
2128
2149
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2136,10 +2157,10 @@ function ce(e, t) {
|
|
|
2136
2157
|
const s = e[t];
|
|
2137
2158
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2138
2159
|
}
|
|
2139
|
-
function
|
|
2160
|
+
function fn(e) {
|
|
2140
2161
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2141
2162
|
}
|
|
2142
|
-
function
|
|
2163
|
+
function gn(e) {
|
|
2143
2164
|
if (!e || typeof e != "object")
|
|
2144
2165
|
return null;
|
|
2145
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;
|
|
@@ -2150,13 +2171,13 @@ function pn(e) {
|
|
|
2150
2171
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2151
2172
|
};
|
|
2152
2173
|
}
|
|
2153
|
-
function
|
|
2174
|
+
function mn(e) {
|
|
2154
2175
|
if (!e || typeof e != "object")
|
|
2155
2176
|
return null;
|
|
2156
2177
|
const t = e.javascript;
|
|
2157
2178
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2158
2179
|
}
|
|
2159
|
-
function
|
|
2180
|
+
function yn(e, t) {
|
|
2160
2181
|
return t ? e && typeof e == "object" ? {
|
|
2161
2182
|
...e,
|
|
2162
2183
|
helperError: t
|
|
@@ -2166,23 +2187,23 @@ function gn(e, t) {
|
|
|
2166
2187
|
helperError: t
|
|
2167
2188
|
} : e;
|
|
2168
2189
|
}
|
|
2169
|
-
function
|
|
2190
|
+
function Tn(e) {
|
|
2170
2191
|
if (!e || typeof e != "object")
|
|
2171
2192
|
return e;
|
|
2172
2193
|
const t = e;
|
|
2173
2194
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2174
2195
|
}
|
|
2175
|
-
function
|
|
2196
|
+
function In() {
|
|
2176
2197
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2177
2198
|
if (t)
|
|
2178
2199
|
return t;
|
|
2179
2200
|
const s = crypto.randomUUID();
|
|
2180
2201
|
return window.localStorage.setItem(e, s), s;
|
|
2181
2202
|
}
|
|
2182
|
-
function
|
|
2203
|
+
function bt() {
|
|
2183
2204
|
return crypto.randomUUID();
|
|
2184
2205
|
}
|
|
2185
|
-
function
|
|
2206
|
+
function wn(e) {
|
|
2186
2207
|
if (!e || typeof e != "object")
|
|
2187
2208
|
return null;
|
|
2188
2209
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2193,23 +2214,23 @@ function In(e) {
|
|
|
2193
2214
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2194
2215
|
} : null;
|
|
2195
2216
|
}
|
|
2196
|
-
function
|
|
2217
|
+
function An(e, t) {
|
|
2197
2218
|
return Array.isArray(e) ? Dt(
|
|
2198
2219
|
xt(
|
|
2199
2220
|
e.map((s) => Me(s, t)).filter((s) => s !== null)
|
|
2200
2221
|
)
|
|
2201
2222
|
) : [];
|
|
2202
2223
|
}
|
|
2203
|
-
function
|
|
2224
|
+
function Sn(e) {
|
|
2204
2225
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2205
2226
|
if (!t || typeof t != "object")
|
|
2206
2227
|
return [];
|
|
2207
|
-
const s = t, n =
|
|
2228
|
+
const s = t, n = E(s, "id"), r = E(s, "createdAt"), i = E(s, "updatedAt"), o = E(s, "lastActiveAt");
|
|
2208
2229
|
return !n || !r || !i || !o ? [] : [
|
|
2209
2230
|
{
|
|
2210
2231
|
id: n,
|
|
2211
|
-
title:
|
|
2212
|
-
firstUserMessage:
|
|
2232
|
+
title: E(s, "title"),
|
|
2233
|
+
firstUserMessage: E(s, "firstUserMessage"),
|
|
2213
2234
|
currentPage: s.currentPage ?? null,
|
|
2214
2235
|
createdAt: r,
|
|
2215
2236
|
updatedAt: i,
|
|
@@ -2235,7 +2256,10 @@ function Me(e, t) {
|
|
|
2235
2256
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2236
2257
|
role: i,
|
|
2237
2258
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2238
|
-
content:
|
|
2259
|
+
content: Qe(
|
|
2260
|
+
Cn(r.content),
|
|
2261
|
+
t
|
|
2262
|
+
),
|
|
2239
2263
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2240
2264
|
respondsToUserMessageId: v(r) ?? void 0,
|
|
2241
2265
|
...M(r) ? { runId: M(r) } : {},
|
|
@@ -2250,7 +2274,7 @@ function Me(e, t) {
|
|
|
2250
2274
|
}), o;
|
|
2251
2275
|
}
|
|
2252
2276
|
if (r.type === "function_call_output") {
|
|
2253
|
-
const i =
|
|
2277
|
+
const i = bn(r.output);
|
|
2254
2278
|
return i ? {
|
|
2255
2279
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2256
2280
|
role: "tool",
|
|
@@ -2267,7 +2291,7 @@ function Me(e, t) {
|
|
|
2267
2291
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2268
2292
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2269
2293
|
role: "tool",
|
|
2270
|
-
content: r.type === "mcp_call" ?
|
|
2294
|
+
content: r.type === "mcp_call" ? En(r) : Rn(r),
|
|
2271
2295
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2272
2296
|
respondsToUserMessageId: v(r) ?? void 0,
|
|
2273
2297
|
...M(r) ? { runId: M(r) } : {},
|
|
@@ -2278,7 +2302,7 @@ function Me(e, t) {
|
|
|
2278
2302
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2279
2303
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2280
2304
|
role: "system",
|
|
2281
|
-
content:
|
|
2305
|
+
content: kn(r),
|
|
2282
2306
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2283
2307
|
respondsToUserMessageId: v(r) ?? void 0,
|
|
2284
2308
|
...M(r) ? { runId: M(r) } : {},
|
|
@@ -2288,11 +2312,11 @@ function Me(e, t) {
|
|
|
2288
2312
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2289
2313
|
} : null;
|
|
2290
2314
|
}
|
|
2291
|
-
function
|
|
2315
|
+
function En(e) {
|
|
2292
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(" ");
|
|
2293
2317
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2294
2318
|
}
|
|
2295
|
-
function
|
|
2319
|
+
function bn(e) {
|
|
2296
2320
|
if (typeof e != "string")
|
|
2297
2321
|
return null;
|
|
2298
2322
|
try {
|
|
@@ -2309,10 +2333,10 @@ function Sn(e) {
|
|
|
2309
2333
|
return null;
|
|
2310
2334
|
}
|
|
2311
2335
|
}
|
|
2312
|
-
function
|
|
2336
|
+
function kn(e) {
|
|
2313
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.";
|
|
2314
2338
|
}
|
|
2315
|
-
function
|
|
2339
|
+
function Rn(e) {
|
|
2316
2340
|
if (e.type === "web_search_call") {
|
|
2317
2341
|
const t = e.action;
|
|
2318
2342
|
if (t && typeof t == "object") {
|
|
@@ -2324,26 +2348,26 @@ function En(e) {
|
|
|
2324
2348
|
}
|
|
2325
2349
|
return "🔎 Searching the web";
|
|
2326
2350
|
}
|
|
2327
|
-
return
|
|
2351
|
+
return _n(e);
|
|
2328
2352
|
}
|
|
2329
|
-
function
|
|
2353
|
+
function _n(e) {
|
|
2330
2354
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2331
|
-
return
|
|
2355
|
+
return O(e.summary);
|
|
2332
2356
|
if (typeof e.arguments == "string")
|
|
2333
2357
|
try {
|
|
2334
2358
|
const t = JSON.parse(e.arguments);
|
|
2335
2359
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
2336
|
-
return
|
|
2360
|
+
return O(t.summary);
|
|
2337
2361
|
} catch {
|
|
2338
|
-
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";
|
|
2339
2363
|
}
|
|
2340
|
-
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";
|
|
2341
2365
|
}
|
|
2342
|
-
function
|
|
2366
|
+
function O(e) {
|
|
2343
2367
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2344
2368
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2345
2369
|
}
|
|
2346
|
-
function
|
|
2370
|
+
function Mn(e) {
|
|
2347
2371
|
if (e == null)
|
|
2348
2372
|
return e;
|
|
2349
2373
|
if (typeof e != "object")
|
|
@@ -2362,7 +2386,7 @@ function le(e) {
|
|
|
2362
2386
|
const t = e.callId ?? e.call_id;
|
|
2363
2387
|
return typeof t == "string" && t ? t : null;
|
|
2364
2388
|
}
|
|
2365
|
-
function
|
|
2389
|
+
function Cn(e) {
|
|
2366
2390
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2367
2391
|
if (!t || typeof t != "object")
|
|
2368
2392
|
return "";
|
|
@@ -2371,8 +2395,8 @@ function _n(e) {
|
|
|
2371
2395
|
}).filter(Boolean).join("") : "";
|
|
2372
2396
|
}
|
|
2373
2397
|
function Ce(e, t) {
|
|
2374
|
-
const s = Pe(e, t), n =
|
|
2375
|
-
|
|
2398
|
+
const s = Pe(e, t), n = xn(
|
|
2399
|
+
Ln(e, t),
|
|
2376
2400
|
s
|
|
2377
2401
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2378
2402
|
if (r === -1)
|
|
@@ -2382,7 +2406,7 @@ function Ce(e, t) {
|
|
|
2382
2406
|
const i = [...n];
|
|
2383
2407
|
return i[r] = s, Dt(xt(i));
|
|
2384
2408
|
}
|
|
2385
|
-
function
|
|
2409
|
+
function Pn(e, t) {
|
|
2386
2410
|
const s = e.findIndex(
|
|
2387
2411
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2388
2412
|
);
|
|
@@ -2395,17 +2419,17 @@ function Mn(e, t) {
|
|
|
2395
2419
|
loading: !0
|
|
2396
2420
|
}, n;
|
|
2397
2421
|
}
|
|
2398
|
-
function
|
|
2422
|
+
function Un(e, t, s) {
|
|
2399
2423
|
let n = !1;
|
|
2400
2424
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2401
2425
|
return n ? r : e;
|
|
2402
2426
|
}
|
|
2403
|
-
function
|
|
2427
|
+
function Dn(e) {
|
|
2404
2428
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
2405
2429
|
return !t || !s ? null : {
|
|
2406
2430
|
id: `transient-activity:${t}`,
|
|
2407
2431
|
role: "tool",
|
|
2408
|
-
content:
|
|
2432
|
+
content: O(
|
|
2409
2433
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
2410
2434
|
),
|
|
2411
2435
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2417,7 +2441,7 @@ function Pn(e) {
|
|
|
2417
2441
|
loading: !0
|
|
2418
2442
|
};
|
|
2419
2443
|
}
|
|
2420
|
-
function
|
|
2444
|
+
function xn(e, t) {
|
|
2421
2445
|
if (t.id.startsWith("transient-activity:"))
|
|
2422
2446
|
return e;
|
|
2423
2447
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2425,7 +2449,7 @@ function Un(e, t) {
|
|
|
2425
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)
|
|
2426
2450
|
);
|
|
2427
2451
|
}
|
|
2428
|
-
function
|
|
2452
|
+
function vn(e, t) {
|
|
2429
2453
|
const s = t.map(
|
|
2430
2454
|
(n) => Pe(e, n)
|
|
2431
2455
|
);
|
|
@@ -2440,19 +2464,19 @@ function Pe(e, t) {
|
|
|
2440
2464
|
if (!s?.attachments?.length)
|
|
2441
2465
|
return t;
|
|
2442
2466
|
const n = t.attachments.map((r) => {
|
|
2443
|
-
const i =
|
|
2444
|
-
return i ?
|
|
2467
|
+
const i = Nn(s.attachments ?? [], r);
|
|
2468
|
+
return i ? On(r, i) : r;
|
|
2445
2469
|
});
|
|
2446
2470
|
return { ...t, attachments: n };
|
|
2447
2471
|
}
|
|
2448
|
-
function
|
|
2472
|
+
function Nn(e, t) {
|
|
2449
2473
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2450
2474
|
}
|
|
2451
|
-
function
|
|
2475
|
+
function On(e, t) {
|
|
2452
2476
|
const { previewUrl: s } = t;
|
|
2453
2477
|
return s ? { ...e, previewUrl: s } : e;
|
|
2454
2478
|
}
|
|
2455
|
-
function
|
|
2479
|
+
function Ln(e, t) {
|
|
2456
2480
|
if (t.role !== "user")
|
|
2457
2481
|
return e;
|
|
2458
2482
|
const s = e.findIndex(
|
|
@@ -2485,7 +2509,7 @@ function de(e) {
|
|
|
2485
2509
|
return !1;
|
|
2486
2510
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
2487
2511
|
const n = e[s];
|
|
2488
|
-
if (
|
|
2512
|
+
if (q(n))
|
|
2489
2513
|
return !0;
|
|
2490
2514
|
if (n.role === "system") {
|
|
2491
2515
|
if (n.dataType === "run_error")
|
|
@@ -2496,9 +2520,9 @@ function de(e) {
|
|
|
2496
2520
|
}
|
|
2497
2521
|
return !1;
|
|
2498
2522
|
}
|
|
2499
|
-
function
|
|
2523
|
+
function Bn(e) {
|
|
2500
2524
|
const t = De(e);
|
|
2501
|
-
return t === null ? e.some(
|
|
2525
|
+
return t === null ? e.some(q) : e.slice(t + 1).some(q);
|
|
2502
2526
|
}
|
|
2503
2527
|
function De(e) {
|
|
2504
2528
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
@@ -2506,8 +2530,8 @@ function De(e) {
|
|
|
2506
2530
|
return t;
|
|
2507
2531
|
return null;
|
|
2508
2532
|
}
|
|
2509
|
-
function
|
|
2510
|
-
return
|
|
2533
|
+
function qn(e) {
|
|
2534
|
+
return q(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2511
2535
|
}
|
|
2512
2536
|
function it(e) {
|
|
2513
2537
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
@@ -2523,7 +2547,7 @@ function it(e) {
|
|
|
2523
2547
|
}
|
|
2524
2548
|
return null;
|
|
2525
2549
|
}
|
|
2526
|
-
function
|
|
2550
|
+
function Hn(e) {
|
|
2527
2551
|
const t = it(e);
|
|
2528
2552
|
if (t === null)
|
|
2529
2553
|
return null;
|
|
@@ -2545,7 +2569,7 @@ function Pt(e) {
|
|
|
2545
2569
|
function he(e) {
|
|
2546
2570
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2547
2571
|
}
|
|
2548
|
-
function
|
|
2572
|
+
function Fn(e, t) {
|
|
2549
2573
|
const s = it(t);
|
|
2550
2574
|
if (s === null)
|
|
2551
2575
|
return !1;
|
|
@@ -2553,7 +2577,7 @@ function qn(e, t) {
|
|
|
2553
2577
|
if (typeof r != "string" || !r)
|
|
2554
2578
|
return !1;
|
|
2555
2579
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2556
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
2580
|
+
return i === -1 ? !1 : e.slice(i + 1).some(qn);
|
|
2557
2581
|
}
|
|
2558
2582
|
function Ut(e) {
|
|
2559
2583
|
const t = it(e);
|
|
@@ -2568,7 +2592,7 @@ function Ut(e) {
|
|
|
2568
2592
|
const r = n.clientMessageId;
|
|
2569
2593
|
return typeof r == "string" ? r : null;
|
|
2570
2594
|
}
|
|
2571
|
-
function
|
|
2595
|
+
function $n(e) {
|
|
2572
2596
|
const t = it(e);
|
|
2573
2597
|
if (t === null)
|
|
2574
2598
|
return null;
|
|
@@ -2595,10 +2619,10 @@ function pe(e, t) {
|
|
|
2595
2619
|
const s = v(t);
|
|
2596
2620
|
if (!s)
|
|
2597
2621
|
return null;
|
|
2598
|
-
const n = e.find((i) =>
|
|
2622
|
+
const n = e.find((i) => E(i, "id") === s), r = L(n);
|
|
2599
2623
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2600
2624
|
}
|
|
2601
|
-
function
|
|
2625
|
+
function Wn(e, t) {
|
|
2602
2626
|
let s = 0;
|
|
2603
2627
|
for (const n of e) {
|
|
2604
2628
|
if (!n || typeof n != "object")
|
|
@@ -2612,30 +2636,30 @@ function Fn(e, t) {
|
|
|
2612
2636
|
return s;
|
|
2613
2637
|
}
|
|
2614
2638
|
function fe(e, t, s, n, r) {
|
|
2615
|
-
if (!t ||
|
|
2639
|
+
if (!t || !jn(e))
|
|
2616
2640
|
return !1;
|
|
2617
2641
|
const i = e;
|
|
2618
2642
|
return !(Pt(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && v(i) !== n || r !== null && M(i) !== r);
|
|
2619
2643
|
}
|
|
2620
|
-
function
|
|
2644
|
+
function jn(e) {
|
|
2621
2645
|
if (!e || typeof e != "object")
|
|
2622
2646
|
return !1;
|
|
2623
2647
|
const t = e;
|
|
2624
2648
|
return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted");
|
|
2625
2649
|
}
|
|
2626
|
-
function
|
|
2650
|
+
function q(e) {
|
|
2627
2651
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
2628
2652
|
}
|
|
2629
|
-
function
|
|
2653
|
+
function zn(e) {
|
|
2630
2654
|
if (!e || typeof e != "object")
|
|
2631
2655
|
return !1;
|
|
2632
2656
|
const t = e;
|
|
2633
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";
|
|
2634
2658
|
}
|
|
2635
2659
|
function Dt(e) {
|
|
2636
|
-
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);
|
|
2637
2661
|
}
|
|
2638
|
-
function
|
|
2662
|
+
function Gn(e) {
|
|
2639
2663
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
2640
2664
|
}
|
|
2641
2665
|
function Ft(e) {
|
|
@@ -2657,7 +2681,7 @@ function xt(e) {
|
|
|
2657
2681
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
2658
2682
|
return r;
|
|
2659
2683
|
}
|
|
2660
|
-
function
|
|
2684
|
+
function Xn(e, t) {
|
|
2661
2685
|
const s = e[t];
|
|
2662
2686
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2663
2687
|
const r = e[n];
|
|
@@ -2668,7 +2692,7 @@ function zn(e, t) {
|
|
|
2668
2692
|
}
|
|
2669
2693
|
return !1;
|
|
2670
2694
|
}
|
|
2671
|
-
function
|
|
2695
|
+
function Kn(e, t) {
|
|
2672
2696
|
const s = e[t];
|
|
2673
2697
|
if (!s.respondsToUserMessageId)
|
|
2674
2698
|
return !1;
|
|
@@ -2681,21 +2705,21 @@ function Gn(e, t) {
|
|
|
2681
2705
|
}
|
|
2682
2706
|
return !1;
|
|
2683
2707
|
}
|
|
2684
|
-
function
|
|
2708
|
+
function Jn(e, t) {
|
|
2685
2709
|
const s = e[t];
|
|
2686
2710
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2687
2711
|
if (e[n].role === "assistant" && ot(s, e[n]))
|
|
2688
2712
|
return !0;
|
|
2689
2713
|
return !1;
|
|
2690
2714
|
}
|
|
2691
|
-
function
|
|
2715
|
+
function Vn(e, t) {
|
|
2692
2716
|
const s = e[t];
|
|
2693
2717
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2694
2718
|
if (e[n].role === "tool" && ot(s, e[n]))
|
|
2695
2719
|
return !0;
|
|
2696
2720
|
return !1;
|
|
2697
2721
|
}
|
|
2698
|
-
function
|
|
2722
|
+
function Yn(e, t) {
|
|
2699
2723
|
const s = e[t];
|
|
2700
2724
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2701
2725
|
if (Ft(e[n]) && ot(s, e[n]))
|
|
@@ -2705,10 +2729,10 @@ function Kn(e, t) {
|
|
|
2705
2729
|
function ot(e, t) {
|
|
2706
2730
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
2707
2731
|
}
|
|
2708
|
-
function
|
|
2732
|
+
function E(e, t) {
|
|
2709
2733
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
2710
2734
|
}
|
|
2711
|
-
function
|
|
2735
|
+
function Zn(e, t) {
|
|
2712
2736
|
try {
|
|
2713
2737
|
const s = window.localStorage.getItem(`${Se}${e}`);
|
|
2714
2738
|
if (!s)
|
|
@@ -2716,7 +2740,7 @@ function Vn(e, t) {
|
|
|
2716
2740
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
2717
2741
|
if (t !== void 0 && r !== t)
|
|
2718
2742
|
return null;
|
|
2719
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2743
|
+
const i = Array.isArray(n.messages) ? n.messages.map(cr).filter((o) => !!o) : [];
|
|
2720
2744
|
return {
|
|
2721
2745
|
sessionId: r,
|
|
2722
2746
|
messages: i
|
|
@@ -2725,20 +2749,20 @@ function Vn(e, t) {
|
|
|
2725
2749
|
return null;
|
|
2726
2750
|
}
|
|
2727
2751
|
}
|
|
2728
|
-
function
|
|
2752
|
+
function Qn(e, t) {
|
|
2729
2753
|
try {
|
|
2730
2754
|
window.localStorage.setItem(
|
|
2731
2755
|
`${Se}${e}`,
|
|
2732
2756
|
JSON.stringify({
|
|
2733
2757
|
sessionId: t.sessionId,
|
|
2734
|
-
messages: t.messages.slice(-
|
|
2758
|
+
messages: t.messages.slice(-Ps).map(lr)
|
|
2735
2759
|
})
|
|
2736
2760
|
);
|
|
2737
2761
|
} catch {
|
|
2738
2762
|
return;
|
|
2739
2763
|
}
|
|
2740
2764
|
}
|
|
2741
|
-
function
|
|
2765
|
+
function tr(e) {
|
|
2742
2766
|
try {
|
|
2743
2767
|
const t = window.localStorage.getItem(`${Ct}${e}`);
|
|
2744
2768
|
if (!t)
|
|
@@ -2749,7 +2773,7 @@ function Zn(e) {
|
|
|
2749
2773
|
return [];
|
|
2750
2774
|
}
|
|
2751
2775
|
}
|
|
2752
|
-
function
|
|
2776
|
+
function W(e, t) {
|
|
2753
2777
|
try {
|
|
2754
2778
|
const s = t.filter($t);
|
|
2755
2779
|
if (s.length === 0) {
|
|
@@ -2780,7 +2804,7 @@ function xe(e, t) {
|
|
|
2780
2804
|
} catch {
|
|
2781
2805
|
}
|
|
2782
2806
|
}
|
|
2783
|
-
function
|
|
2807
|
+
function er(e, t) {
|
|
2784
2808
|
try {
|
|
2785
2809
|
if (window.sessionStorage.getItem(`${rt}${e}`) === null)
|
|
2786
2810
|
return;
|
|
@@ -2789,19 +2813,19 @@ function Qn(e, t) {
|
|
|
2789
2813
|
}
|
|
2790
2814
|
xe(e, t);
|
|
2791
2815
|
}
|
|
2792
|
-
function
|
|
2816
|
+
function sr(e) {
|
|
2793
2817
|
try {
|
|
2794
2818
|
const t = `${rt}${e}`, s = window.sessionStorage.getItem(t);
|
|
2795
2819
|
if (window.sessionStorage.removeItem(t), !s)
|
|
2796
2820
|
return [];
|
|
2797
2821
|
const n = JSON.parse(s);
|
|
2798
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2822
|
+
return Array.isArray(n) ? n.flatMap((r) => rr(r) ? [{
|
|
2799
2823
|
...r.event,
|
|
2800
2824
|
page: _(),
|
|
2801
2825
|
rawOutput: {
|
|
2802
2826
|
pageContextRestarted: !0,
|
|
2803
2827
|
outcome: "unknown",
|
|
2804
|
-
message:
|
|
2828
|
+
message: nr(location.href),
|
|
2805
2829
|
currentUrl: location.href,
|
|
2806
2830
|
console: [],
|
|
2807
2831
|
metadata: {
|
|
@@ -2818,17 +2842,17 @@ function tr(e) {
|
|
|
2818
2842
|
return [];
|
|
2819
2843
|
}
|
|
2820
2844
|
}
|
|
2821
|
-
function
|
|
2845
|
+
function nr(e) {
|
|
2822
2846
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
2823
2847
|
Current URL: ${e}`;
|
|
2824
2848
|
}
|
|
2825
|
-
function
|
|
2849
|
+
function rr(e) {
|
|
2826
2850
|
if (!e || typeof e != "object")
|
|
2827
2851
|
return !1;
|
|
2828
2852
|
const t = e, s = t.event;
|
|
2829
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";
|
|
2830
2854
|
}
|
|
2831
|
-
function
|
|
2855
|
+
function ir(e, t) {
|
|
2832
2856
|
const s = new Set(
|
|
2833
2857
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2834
2858
|
);
|
|
@@ -2837,7 +2861,7 @@ function nr(e, t) {
|
|
|
2837
2861
|
...t.filter((n) => !s.has(n.callId))
|
|
2838
2862
|
];
|
|
2839
2863
|
}
|
|
2840
|
-
function
|
|
2864
|
+
function or(e) {
|
|
2841
2865
|
try {
|
|
2842
2866
|
window.sessionStorage.removeItem(`${rt}${e}`);
|
|
2843
2867
|
} catch {
|
|
@@ -2864,23 +2888,23 @@ function ve(e, t) {
|
|
|
2864
2888
|
return !1;
|
|
2865
2889
|
const i = r;
|
|
2866
2890
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2867
|
-
}), n = t ? s.map((r) =>
|
|
2891
|
+
}), n = t ? s.map((r) => Ne(r, t)) : s;
|
|
2868
2892
|
return n.length > 0 ? n : void 0;
|
|
2869
2893
|
}
|
|
2870
|
-
function
|
|
2894
|
+
function Ne(e, t) {
|
|
2871
2895
|
return e.fileUrl?.startsWith("/") ? {
|
|
2872
2896
|
...e,
|
|
2873
2897
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2874
2898
|
} : e;
|
|
2875
2899
|
}
|
|
2876
2900
|
function me(e) {
|
|
2877
|
-
return e.type ||
|
|
2901
|
+
return e.type || ar(e.name) || "application/octet-stream";
|
|
2878
2902
|
}
|
|
2879
|
-
function
|
|
2903
|
+
function ar(e) {
|
|
2880
2904
|
const t = e.toLowerCase();
|
|
2881
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;
|
|
2882
2906
|
}
|
|
2883
|
-
function
|
|
2907
|
+
function cr(e) {
|
|
2884
2908
|
if (!e || typeof e != "object")
|
|
2885
2909
|
return null;
|
|
2886
2910
|
const t = e;
|
|
@@ -2897,7 +2921,7 @@ function or(e) {
|
|
|
2897
2921
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2898
2922
|
};
|
|
2899
2923
|
}
|
|
2900
|
-
function
|
|
2924
|
+
function lr(e) {
|
|
2901
2925
|
return e.attachments?.length ? {
|
|
2902
2926
|
...e,
|
|
2903
2927
|
attachments: e.attachments.map(Wt)
|
|
@@ -2920,11 +2944,11 @@ function M(e) {
|
|
|
2920
2944
|
const t = e.runId;
|
|
2921
2945
|
return typeof t == "string" && t ? t : null;
|
|
2922
2946
|
}
|
|
2923
|
-
function
|
|
2947
|
+
function ur(e) {
|
|
2924
2948
|
const t = e?.timeoutMs;
|
|
2925
|
-
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);
|
|
2926
2950
|
}
|
|
2927
|
-
function
|
|
2951
|
+
function Oe(e) {
|
|
2928
2952
|
const t = {};
|
|
2929
2953
|
try {
|
|
2930
2954
|
new Headers(e).forEach((s, n) => {
|
|
@@ -2936,22 +2960,22 @@ function Ne(e) {
|
|
|
2936
2960
|
return t;
|
|
2937
2961
|
}
|
|
2938
2962
|
function jt(e, t) {
|
|
2939
|
-
return $e(e) ? at : C(nt(t),
|
|
2963
|
+
return $e(e) ? at : C(nt(t), Ms);
|
|
2940
2964
|
}
|
|
2941
|
-
function
|
|
2965
|
+
function dr(e, t) {
|
|
2942
2966
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2943
2967
|
}
|
|
2944
|
-
async function
|
|
2945
|
-
const r =
|
|
2968
|
+
async function hr(e, t, s, n) {
|
|
2969
|
+
const r = Oe(e.headers);
|
|
2946
2970
|
n({
|
|
2947
2971
|
...t,
|
|
2948
2972
|
responseStatus: e.status,
|
|
2949
2973
|
responseHeaders: r,
|
|
2950
|
-
responseBody: await
|
|
2974
|
+
responseBody: await pr(e),
|
|
2951
2975
|
durationMs: Date.now() - s
|
|
2952
2976
|
});
|
|
2953
2977
|
}
|
|
2954
|
-
async function
|
|
2978
|
+
async function pr(e) {
|
|
2955
2979
|
if (!Le(e.headers))
|
|
2956
2980
|
return;
|
|
2957
2981
|
let t = null, s = null;
|
|
@@ -2961,7 +2985,7 @@ async function dr(e) {
|
|
|
2961
2985
|
const n = new Promise((a) => {
|
|
2962
2986
|
s = window.setTimeout(() => {
|
|
2963
2987
|
t?.cancel(), a("timeout");
|
|
2964
|
-
},
|
|
2988
|
+
}, Cs);
|
|
2965
2989
|
}), r = new TextDecoder();
|
|
2966
2990
|
let i = "", o = 0;
|
|
2967
2991
|
for (; ; ) {
|
|
@@ -2983,7 +3007,7 @@ async function dr(e) {
|
|
|
2983
3007
|
s !== null && window.clearTimeout(s);
|
|
2984
3008
|
}
|
|
2985
3009
|
}
|
|
2986
|
-
function
|
|
3010
|
+
function fr(e, t) {
|
|
2987
3011
|
if (Le(new Headers(t)))
|
|
2988
3012
|
try {
|
|
2989
3013
|
return e.responseType === "" || e.responseType === "text" ? C(e.responseText ?? "") : void 0;
|
|
@@ -2995,14 +3019,14 @@ function ye(e) {
|
|
|
2995
3019
|
if (typeof e == "string")
|
|
2996
3020
|
return C(e);
|
|
2997
3021
|
}
|
|
2998
|
-
function
|
|
3022
|
+
function gr(e) {
|
|
2999
3023
|
return k({
|
|
3000
3024
|
...e,
|
|
3001
|
-
requestBody:
|
|
3002
|
-
responseBody:
|
|
3025
|
+
requestBody: Te(e.requestBody),
|
|
3026
|
+
responseBody: Te(e.responseBody)
|
|
3003
3027
|
});
|
|
3004
3028
|
}
|
|
3005
|
-
function
|
|
3029
|
+
function Te(e) {
|
|
3006
3030
|
if (typeof e != "string")
|
|
3007
3031
|
return e;
|
|
3008
3032
|
const t = e.trim();
|
|
@@ -3020,8 +3044,8 @@ function Le(e) {
|
|
|
3020
3044
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3021
3045
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= Lt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3022
3046
|
}
|
|
3023
|
-
function
|
|
3024
|
-
if (
|
|
3047
|
+
function N(e, t = {}, s) {
|
|
3048
|
+
if (yr(s))
|
|
3025
3049
|
return !0;
|
|
3026
3050
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3027
3051
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3036,8 +3060,8 @@ function O(e, t = {}, s) {
|
|
|
3036
3060
|
return !0;
|
|
3037
3061
|
}
|
|
3038
3062
|
}
|
|
3039
|
-
function
|
|
3040
|
-
if (
|
|
3063
|
+
function mr(e, t) {
|
|
3064
|
+
if (N(e))
|
|
3041
3065
|
return !0;
|
|
3042
3066
|
try {
|
|
3043
3067
|
const s = new URL(e, location.href), n = new URL(t);
|
|
@@ -3046,10 +3070,10 @@ function fr(e, t) {
|
|
|
3046
3070
|
return !0;
|
|
3047
3071
|
}
|
|
3048
3072
|
}
|
|
3049
|
-
function
|
|
3073
|
+
function yr(e) {
|
|
3050
3074
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3051
3075
|
}
|
|
3052
|
-
function
|
|
3076
|
+
function Tr(e) {
|
|
3053
3077
|
const t = {};
|
|
3054
3078
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3055
3079
|
const n = s.indexOf(":");
|
|
@@ -3080,27 +3104,27 @@ async function Rt(e, t) {
|
|
|
3080
3104
|
try {
|
|
3081
3105
|
return await e();
|
|
3082
3106
|
} catch (r) {
|
|
3083
|
-
if (s = r, n >= re - 1 || !
|
|
3107
|
+
if (s = r, n >= re - 1 || !wr(r))
|
|
3084
3108
|
throw r;
|
|
3085
|
-
await
|
|
3109
|
+
await Ir(n);
|
|
3086
3110
|
}
|
|
3087
3111
|
throw s instanceof Error ? s : new Error(t);
|
|
3088
3112
|
}
|
|
3089
|
-
function
|
|
3113
|
+
function Ir(e) {
|
|
3090
3114
|
return new Promise((t) => {
|
|
3091
|
-
window.setTimeout(t,
|
|
3115
|
+
window.setTimeout(t, _s[e] ?? 0);
|
|
3092
3116
|
});
|
|
3093
3117
|
}
|
|
3094
|
-
function
|
|
3095
|
-
return e instanceof et ?
|
|
3118
|
+
function wr(e) {
|
|
3119
|
+
return e instanceof et ? Ar(e.status) : e instanceof TypeError;
|
|
3096
3120
|
}
|
|
3097
|
-
function
|
|
3121
|
+
function Ar(e) {
|
|
3098
3122
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3099
3123
|
}
|
|
3100
|
-
function
|
|
3124
|
+
function Sr(e) {
|
|
3101
3125
|
return e === 401 || e === 403;
|
|
3102
3126
|
}
|
|
3103
|
-
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 = /[),.;\]]+$/;
|
|
3104
3128
|
function k(e) {
|
|
3105
3129
|
return st(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3106
3130
|
}
|
|
@@ -3109,7 +3133,7 @@ function st(e, t, s) {
|
|
|
3109
3133
|
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : nt(e);
|
|
3110
3134
|
if (e === null || typeof e != "object")
|
|
3111
3135
|
return e;
|
|
3112
|
-
if (t >=
|
|
3136
|
+
if (t >= br)
|
|
3113
3137
|
return "[REDACTED_MAX_DEPTH]";
|
|
3114
3138
|
if (s.has(e))
|
|
3115
3139
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -3117,44 +3141,44 @@ function st(e, t, s) {
|
|
|
3117
3141
|
return e.map((r) => st(r, t + 1, s));
|
|
3118
3142
|
const n = {};
|
|
3119
3143
|
for (const [r, i] of Object.entries(e))
|
|
3120
|
-
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);
|
|
3121
3145
|
return n;
|
|
3122
3146
|
}
|
|
3123
3147
|
function $e(e) {
|
|
3124
3148
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3125
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");
|
|
3126
3150
|
}
|
|
3127
|
-
function
|
|
3151
|
+
function Cr(e) {
|
|
3128
3152
|
return typeof e == "string" ? We(e) : st(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3129
3153
|
}
|
|
3130
3154
|
function We(e) {
|
|
3131
3155
|
try {
|
|
3132
3156
|
const t = new URL(e, location.href);
|
|
3133
3157
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3134
|
-
|
|
3158
|
+
kr.test(s) && t.searchParams.set(s, P);
|
|
3135
3159
|
return t.username && (t.username = P), t.password && (t.password = P), t.toString();
|
|
3136
3160
|
} catch {
|
|
3137
|
-
return
|
|
3161
|
+
return Pr(e);
|
|
3138
3162
|
}
|
|
3139
3163
|
}
|
|
3140
3164
|
function nt(e) {
|
|
3141
|
-
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}`);
|
|
3142
3166
|
}
|
|
3143
|
-
function
|
|
3167
|
+
function Pr(e) {
|
|
3144
3168
|
return e.replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${at}`);
|
|
3145
3169
|
}
|
|
3146
|
-
function
|
|
3147
|
-
const t = e.match(
|
|
3170
|
+
function Ur(e) {
|
|
3171
|
+
const t = e.match(Mr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3148
3172
|
return `${We(s)}${t}`;
|
|
3149
3173
|
}
|
|
3150
3174
|
export {
|
|
3151
3175
|
te as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3152
3176
|
Mt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
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
|
|
3160
3184
|
};
|