@pluno/product-agent-web 0.1.151 → 0.1.153
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/attachmentStorage.d.ts +2 -1
- package/dist/index.d.ts +6 -4
- package/dist/product-agent-sdk.js +587 -567
- package/dist/product-agent-widget.js +3041 -2994
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const t = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
1
|
+
const es = "pluno-product-agent-attachments";
|
|
2
|
+
const Ut = "files";
|
|
3
|
+
async function ss(e) {
|
|
4
|
+
const t = await Wt();
|
|
5
|
+
await is(t, "readwrite", (s) => s.put(e));
|
|
6
|
+
}
|
|
7
|
+
async function ns(e, t) {
|
|
8
|
+
const s = await Wt();
|
|
9
|
+
await $t(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await jt(
|
|
11
11
|
n.get(e)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,28 +16,28 @@ async function es(e, t) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const t = await
|
|
21
|
-
await
|
|
19
|
+
async function rs(e = 864e5) {
|
|
20
|
+
const t = await Wt(), s = Date.now() - e;
|
|
21
|
+
await $t(t, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await jt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Wt() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
28
|
-
const s = indexedDB.open(
|
|
28
|
+
const s = indexedDB.open(es, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(Ut, { keyPath: "attachmentId" });
|
|
31
31
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
32
32
|
}, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
return await
|
|
35
|
+
async function is(e, t, s) {
|
|
36
|
+
return await $t(e, t, async (n) => await jt(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function $t(e, t, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = e.transaction(
|
|
40
|
+
const i = e.transaction(Ut, t), o = i.objectStore(Ut);
|
|
41
41
|
let a, c = !1;
|
|
42
42
|
s(o).then((l) => {
|
|
43
43
|
a = l;
|
|
@@ -57,16 +57,16 @@ function Ht(e, t, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function jt(e) {
|
|
61
61
|
return new Promise((t, s) => {
|
|
62
62
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function os(e) {
|
|
66
66
|
return e !== null && (typeof e == "object" || typeof e == "function");
|
|
67
67
|
}
|
|
68
68
|
function be(e, t, s) {
|
|
69
|
-
const n = Reflect.get(e, "pluno"), r =
|
|
69
|
+
const n = Reflect.get(e, "pluno"), r = os(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(e, "pluno", r))
|
|
71
71
|
return null;
|
|
72
72
|
const i = Object.getOwnPropertyDescriptor(r, t);
|
|
@@ -80,14 +80,14 @@ function be(e, t, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const as = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function cs(e, t) {
|
|
85
85
|
return t ? e.replace(
|
|
86
|
-
|
|
86
|
+
as,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
|
|
88
88
|
) : e;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function ls(e, t, s) {
|
|
91
91
|
const n = t.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
92
92
|
n.flatMap(
|
|
93
93
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
@@ -105,36 +105,36 @@ function as(e, t, s) {
|
|
|
105
105
|
), l = /* @__PURE__ */ new Map();
|
|
106
106
|
for (const { item: u, identity: d } of i)
|
|
107
107
|
for (const p of d.activityKeys ?? []) {
|
|
108
|
-
const
|
|
109
|
-
(!
|
|
108
|
+
const g = l.get(p);
|
|
109
|
+
(!g || s(g).isTransient) && l.set(p, u);
|
|
110
110
|
}
|
|
111
111
|
const h = new Set(i.map(({ identity: u }) => u.id)), f = new Set(
|
|
112
112
|
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
113
|
-
), I = /* @__PURE__ */ new Set(),
|
|
113
|
+
), I = /* @__PURE__ */ new Set(), m = [];
|
|
114
114
|
for (const u of e) {
|
|
115
115
|
const d = s(u);
|
|
116
116
|
let p = o.get(d.id);
|
|
117
|
-
if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((
|
|
118
|
-
|
|
117
|
+
if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((A) => l.get(A)).find((A) => A !== void 0) ?? p), p && !I.has(p)) {
|
|
118
|
+
m.push(p), I.add(p);
|
|
119
119
|
continue;
|
|
120
120
|
}
|
|
121
|
-
const
|
|
122
|
-
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) &&
|
|
121
|
+
const g = d.respondsToUserMessageId !== void 0 && h.has(d.respondsToUserMessageId) || d.runId !== void 0 && f.has(d.runId);
|
|
122
|
+
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) && g) && m.push(u);
|
|
123
123
|
}
|
|
124
124
|
for (const { item: u } of i)
|
|
125
|
-
I.has(u) ||
|
|
126
|
-
return
|
|
125
|
+
I.has(u) || m.push(u);
|
|
126
|
+
return m;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function us(e, t, s, n) {
|
|
129
129
|
return e.filter((r) => {
|
|
130
130
|
const i = n(r);
|
|
131
131
|
return !i.isActivity || !i.isTransient ? !0 : t !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== t : s === null || i.runId !== s;
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
const St = "pluno.productAgent.transportId",
|
|
135
|
-
let
|
|
134
|
+
const St = "pluno.productAgent.transportId", ds = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", hs = 50, ps = globalThis.setTimeout.bind(globalThis);
|
|
135
|
+
let $ = null;
|
|
136
136
|
const et = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Map();
|
|
137
|
-
async function
|
|
137
|
+
async function fs(e = Me()) {
|
|
138
138
|
const t = e.randomUUID(), s = e.storage.getItem(St);
|
|
139
139
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
140
140
|
const o = e.channel.subscribe((c) => {
|
|
@@ -170,14 +170,14 @@ async function hs(e = Me()) {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
174
|
-
|
|
173
|
+
async function gs() {
|
|
174
|
+
$ || ($ = fs(Me()), $.then((n) => {
|
|
175
175
|
const r = (i) => {
|
|
176
|
-
i.persisted || (n.release(),
|
|
176
|
+
i.persisted || (n.release(), $ = null, et.clear(), window.removeEventListener("pagehide", r));
|
|
177
177
|
};
|
|
178
178
|
window.addEventListener("pagehide", r);
|
|
179
179
|
}));
|
|
180
|
-
const e = await
|
|
180
|
+
const e = await $, t = ms();
|
|
181
181
|
et.add(t);
|
|
182
182
|
let s = !1;
|
|
183
183
|
return {
|
|
@@ -188,7 +188,7 @@ async function ps() {
|
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function ms() {
|
|
192
192
|
let e = 0;
|
|
193
193
|
for (; et.has(e); )
|
|
194
194
|
e += 1;
|
|
@@ -196,13 +196,13 @@ function fs() {
|
|
|
196
196
|
}
|
|
197
197
|
function Me() {
|
|
198
198
|
return {
|
|
199
|
-
storage:
|
|
200
|
-
channel:
|
|
199
|
+
storage: ys(),
|
|
200
|
+
channel: Is(),
|
|
201
201
|
randomUUID: () => crypto.randomUUID(),
|
|
202
|
-
settle: () => new Promise((e) =>
|
|
202
|
+
settle: () => new Promise((e) => ps(e, hs))
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function ys() {
|
|
206
206
|
return {
|
|
207
207
|
getItem: (e) => {
|
|
208
208
|
try {
|
|
@@ -220,9 +220,9 @@ function gs() {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function Is() {
|
|
224
224
|
if (typeof BroadcastChannel < "u") {
|
|
225
|
-
const e = new BroadcastChannel(
|
|
225
|
+
const e = new BroadcastChannel(ds);
|
|
226
226
|
return {
|
|
227
227
|
postMessage: (t) => e.postMessage(t),
|
|
228
228
|
subscribe: (t) => {
|
|
@@ -232,9 +232,9 @@ function ms() {
|
|
|
232
232
|
close: () => e.close()
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
-
return
|
|
235
|
+
return Ts();
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function Ts() {
|
|
238
238
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
239
239
|
if (s.key !== At || !s.newValue)
|
|
240
240
|
return;
|
|
@@ -256,7 +256,7 @@ function ys() {
|
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
const ke = "schedule_follow_up";
|
|
259
|
-
function
|
|
259
|
+
function ws(e) {
|
|
260
260
|
let t = e;
|
|
261
261
|
if (typeof t == "string")
|
|
262
262
|
try {
|
|
@@ -269,9 +269,9 @@ function Is(e) {
|
|
|
269
269
|
const s = t;
|
|
270
270
|
return s.ok !== !0 || s.toolName !== ke || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
let
|
|
274
|
-
function
|
|
272
|
+
const Ss = globalThis.fetch.bind(globalThis), Dt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', As = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Es = ".pluno-pa-widget__panel", Rs = ".pluno-pa-widget__timeline", oe = `${Dt}[data-pluno-sdk-preview-channel]`;
|
|
273
|
+
let bs = 0;
|
|
274
|
+
function ae(e) {
|
|
275
275
|
const t = {};
|
|
276
276
|
for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
|
|
277
277
|
const o = e[i];
|
|
@@ -296,25 +296,31 @@ function Rt(e, t, s) {
|
|
|
296
296
|
source: "web_sdk",
|
|
297
297
|
category: e,
|
|
298
298
|
name: t,
|
|
299
|
-
sequence: ++
|
|
299
|
+
sequence: ++bs,
|
|
300
300
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
301
301
|
monotonicMs: performance.now(),
|
|
302
302
|
data: s
|
|
303
303
|
};
|
|
304
304
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
305
305
|
}
|
|
306
|
-
const
|
|
306
|
+
const Ms = "https://app.pluno.ai", ks = "gpt-5.6-terra", _s = 2e4, Cs = 1e4, Ps = 1e4, Us = 1e4, Ds = 1e4, Ns = 1e3, ce = 3e4, le = 0.2, ue = 6e4, vs = 15e3, V = 8, Os = "Pluno could not finish this message. Try it again.", xs = "Browser connection was interrupted.", Ls = 15e3, Bs = 2e3, qs = 1e3, Hs = 100, de = 8e3, he = 3, Ws = [300, 1e3], _e = 50 * 1024 * 1024, $s = /* @__PURE__ */ new Set([
|
|
307
|
+
".jpeg:image/jpeg",
|
|
308
|
+
".jpg:image/jpeg",
|
|
309
|
+
".pdf:application/pdf",
|
|
310
|
+
".png:image/png",
|
|
311
|
+
".webp:image/webp"
|
|
312
|
+
]), Qr = ".pdf,.png,.jpg,.jpeg,.webp", Ft = 64e3, bt = 4e3, zt = 30, js = 2e3, Fs = 1e3, Ce = "Image is too large for model vision input.", zs = 100, Pe = "pluno.productAgent.state.", Nt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Ks = 100;
|
|
307
313
|
function Y(e, t = 0) {
|
|
308
314
|
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
309
315
|
return Math.max(t, s);
|
|
310
316
|
}
|
|
311
317
|
const st = /* @__PURE__ */ new Set();
|
|
312
318
|
let Z = null;
|
|
313
|
-
function
|
|
314
|
-
const s = Math.min(
|
|
315
|
-
return Math.min(
|
|
319
|
+
function Gs(e, t = Math.random) {
|
|
320
|
+
const s = Math.min(ce, Ns * 2 ** e), n = 1 - le + t() * le * 2;
|
|
321
|
+
return Math.min(ce, Math.round(s * n));
|
|
316
322
|
}
|
|
317
|
-
function
|
|
323
|
+
function Xs(e, t, s) {
|
|
318
324
|
return new Promise((n, r) => {
|
|
319
325
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
320
326
|
e.then(
|
|
@@ -331,9 +337,9 @@ class Ue {
|
|
|
331
337
|
constructor(t, s) {
|
|
332
338
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
333
339
|
...this.state,
|
|
334
|
-
starterPrompts:
|
|
340
|
+
starterPrompts: Cn(t.initialStarterPrompts)
|
|
335
341
|
};
|
|
336
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
342
|
+
const n = t.restorePersistedState === !1 ? null : yr(t.clientId, t.expectedPersistedSessionId);
|
|
337
343
|
n && (this.state = {
|
|
338
344
|
...this.state,
|
|
339
345
|
...n,
|
|
@@ -346,10 +352,10 @@ class Ue {
|
|
|
346
352
|
assistantDraftRunId: null,
|
|
347
353
|
isThinking: !1,
|
|
348
354
|
lastError: null
|
|
349
|
-
}), this.queuedClientEvents =
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
),
|
|
355
|
+
}), this.queuedClientEvents = Rr(
|
|
356
|
+
Tr(t.clientId),
|
|
357
|
+
Sr(t.clientId)
|
|
358
|
+
), F(t.clientId, this.queuedClientEvents);
|
|
353
359
|
}
|
|
354
360
|
options;
|
|
355
361
|
listeners = {};
|
|
@@ -393,8 +399,7 @@ class Ue {
|
|
|
393
399
|
retryableClientMessageId = null;
|
|
394
400
|
runtimeHelperJavascript = null;
|
|
395
401
|
attachmentFiles = /* @__PURE__ */ new Map();
|
|
396
|
-
|
|
397
|
-
sessionUserFilesApiCleanup = null;
|
|
402
|
+
sessionBrowserApisCleanup = null;
|
|
398
403
|
activeBrowserToolCalls = /* @__PURE__ */ new Map();
|
|
399
404
|
pendingToolLoadingByCallId = /* @__PURE__ */ new Map();
|
|
400
405
|
terminalToolCallIds = /* @__PURE__ */ new Set();
|
|
@@ -424,15 +429,15 @@ class Ue {
|
|
|
424
429
|
lastErrorSecuritySettingsUrl: null
|
|
425
430
|
};
|
|
426
431
|
static async init(t) {
|
|
427
|
-
const s = await
|
|
432
|
+
const s = await gs(), n = new Ue({
|
|
428
433
|
...t,
|
|
429
|
-
backendUrl:
|
|
430
|
-
clientId: t.clientId ??
|
|
431
|
-
model: t.model ??
|
|
432
|
-
entrySurface:
|
|
434
|
+
backendUrl: fn(t.backendUrl ?? Ms),
|
|
435
|
+
clientId: t.clientId ?? vn(),
|
|
436
|
+
model: t.model ?? ks,
|
|
437
|
+
entrySurface: gn(t.entrySurface)
|
|
433
438
|
}, s);
|
|
434
439
|
try {
|
|
435
|
-
|
|
440
|
+
rs().catch((r) => {
|
|
436
441
|
S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
437
442
|
message: r instanceof Error ? r.message : String(r)
|
|
438
443
|
});
|
|
@@ -463,14 +468,14 @@ class Ue {
|
|
|
463
468
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
464
469
|
);
|
|
465
470
|
try {
|
|
466
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
471
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await Xs(this.options.tokenProvider(), Ps, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
467
472
|
return;
|
|
468
473
|
if (!this.token && !this.options.webSocketFactory)
|
|
469
474
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
470
|
-
const s =
|
|
475
|
+
const s = In(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
471
476
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
472
477
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
473
|
-
},
|
|
478
|
+
}, Us), n.addEventListener("open", () => {
|
|
474
479
|
this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
|
|
475
480
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
476
481
|
isThinking: this.state.isThinking
|
|
@@ -482,9 +487,9 @@ class Ue {
|
|
|
482
487
|
pageUrl: location.href
|
|
483
488
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
484
489
|
this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
485
|
-
},
|
|
490
|
+
}, Ds));
|
|
486
491
|
}), n.addEventListener("message", (r) => {
|
|
487
|
-
this.socket === n && this.handleServerEvent(
|
|
492
|
+
this.socket === n && this.handleServerEvent(_n(r.data));
|
|
488
493
|
}), n.addEventListener("close", (r) => {
|
|
489
494
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
490
495
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -517,7 +522,7 @@ class Ue {
|
|
|
517
522
|
this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWarmupEvent = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
518
523
|
}
|
|
519
524
|
destroy() {
|
|
520
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.
|
|
525
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), br(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
521
526
|
for (const t of Object.values(this.listeners))
|
|
522
527
|
t?.clear();
|
|
523
528
|
}
|
|
@@ -533,16 +538,21 @@ class Ue {
|
|
|
533
538
|
}
|
|
534
539
|
async sendMessage(t, s = {}) {
|
|
535
540
|
const n = t.trim(), r = s.attachments ?? [];
|
|
536
|
-
|
|
541
|
+
if (!this.options.persistAttachmentUpload && (r.forEach(Fe), r.reduce(
|
|
542
|
+
(g, A) => g + A.sizeBytes,
|
|
543
|
+
0
|
|
544
|
+
) > _e))
|
|
545
|
+
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
546
|
+
let i = r.map(Jt);
|
|
537
547
|
if (!n && i.length === 0)
|
|
538
548
|
return null;
|
|
539
|
-
const o = M(), a = s.clientMessageId ??
|
|
549
|
+
const o = M(), a = s.clientMessageId ?? j(), c = {
|
|
540
550
|
id: `local-${a}`,
|
|
541
551
|
role: "user",
|
|
542
552
|
content: n,
|
|
543
553
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
544
554
|
...r.length > 0 ? { attachments: r } : {}
|
|
545
|
-
}, l = this.state.messages.some((p) => p.id === c.id || p.clientMessageId === a), h = this.state.isThinking, f = this.state.messages, I = l ? this.state.messages : [...this.state.messages, c],
|
|
555
|
+
}, l = this.state.messages.some((p) => p.id === c.id || p.clientMessageId === a), h = this.state.isThinking, f = this.state.messages, I = l ? this.state.messages : [...this.state.messages, c], m = {
|
|
546
556
|
assistantDraft: this.state.assistantDraft,
|
|
547
557
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
548
558
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -564,21 +574,21 @@ class Ue {
|
|
|
564
574
|
}), l || this.emit("message", c);
|
|
565
575
|
try {
|
|
566
576
|
const p = [];
|
|
567
|
-
for (const
|
|
568
|
-
const
|
|
569
|
-
if (
|
|
570
|
-
p.push(
|
|
577
|
+
for (const g of i) {
|
|
578
|
+
const A = g.id ? this.attachmentFiles.get(g.id) : void 0;
|
|
579
|
+
if (g.sandboxPath || g.storageKey) {
|
|
580
|
+
p.push(g);
|
|
571
581
|
continue;
|
|
572
582
|
}
|
|
573
|
-
if (!
|
|
574
|
-
throw new Error(`Attachment bytes are unavailable for ${
|
|
575
|
-
p.push(await this.uploadAttachmentForMessage({ file:
|
|
583
|
+
if (!A)
|
|
584
|
+
throw new Error(`Attachment bytes are unavailable for ${g.name}`);
|
|
585
|
+
p.push(await this.uploadAttachmentForMessage({ file: A, attachment: g }));
|
|
576
586
|
}
|
|
577
587
|
i = p;
|
|
578
588
|
} catch (p) {
|
|
579
589
|
throw this.setState({
|
|
580
590
|
...l ? {} : { messages: f },
|
|
581
|
-
...h ? {} : { ...
|
|
591
|
+
...h ? {} : { ...m, isThinking: !1 }
|
|
582
592
|
}), p;
|
|
583
593
|
}
|
|
584
594
|
this.retryableClientMessageId = null;
|
|
@@ -587,14 +597,14 @@ class Ue {
|
|
|
587
597
|
sessionId: this.state.sessionId ?? void 0,
|
|
588
598
|
clientMessageId: a,
|
|
589
599
|
initiatedBy: s.initiatedBy,
|
|
590
|
-
invocation:
|
|
600
|
+
invocation: mn(s.invocation ?? s.initiatedBy),
|
|
591
601
|
entrySurface: this.options.entrySurface,
|
|
592
602
|
content: n,
|
|
593
|
-
pageContent: u &&
|
|
603
|
+
pageContent: u && Kt() || void 0,
|
|
594
604
|
attachments: i.length > 0 ? i : void 0,
|
|
595
605
|
page: o,
|
|
596
606
|
model: this.options.model,
|
|
597
|
-
metadata:
|
|
607
|
+
metadata: pe(this.options.metadata)
|
|
598
608
|
};
|
|
599
609
|
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.browserConnectionInterruptedClientMessageIds.delete(a), this.markThinkingProgress(), this.send(d), a;
|
|
600
610
|
}
|
|
@@ -603,15 +613,16 @@ class Ue {
|
|
|
603
613
|
return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(s), this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
|
|
604
614
|
}
|
|
605
615
|
createLocalAttachment(t) {
|
|
606
|
-
|
|
616
|
+
this.options.persistAttachmentUpload || Mr(t);
|
|
617
|
+
const s = j(), n = {
|
|
607
618
|
id: s,
|
|
608
619
|
name: t.name || "attachment",
|
|
609
|
-
mimeType:
|
|
620
|
+
mimeType: Ht(t),
|
|
610
621
|
sizeBytes: t.size
|
|
611
622
|
};
|
|
612
|
-
this.attachmentFiles.set(s, t)
|
|
623
|
+
this.attachmentFiles.set(s, t);
|
|
613
624
|
const r = Date.now();
|
|
614
|
-
return
|
|
625
|
+
return ss({
|
|
615
626
|
attachmentId: s,
|
|
616
627
|
name: n.name,
|
|
617
628
|
mimeType: n.mimeType,
|
|
@@ -640,7 +651,7 @@ class Ue {
|
|
|
640
651
|
file: t,
|
|
641
652
|
attachment: s
|
|
642
653
|
}) {
|
|
643
|
-
const n = this.state.sessionId, r =
|
|
654
|
+
const n = this.state.sessionId, r = Ht(t), i = {
|
|
644
655
|
sessionId: n ?? void 0,
|
|
645
656
|
attachmentId: s.id,
|
|
646
657
|
clientId: this.options.clientId,
|
|
@@ -650,7 +661,7 @@ class Ue {
|
|
|
650
661
|
sizeBytes: t.size,
|
|
651
662
|
page: M(),
|
|
652
663
|
model: this.options.model,
|
|
653
|
-
metadata:
|
|
664
|
+
metadata: pe(this.options.metadata),
|
|
654
665
|
entrySurface: this.options.entrySurface
|
|
655
666
|
};
|
|
656
667
|
let o;
|
|
@@ -676,11 +687,12 @@ class Ue {
|
|
|
676
687
|
}, "Failed to upload attachment"), o = c;
|
|
677
688
|
}
|
|
678
689
|
this.setState({ sessionId: o.sessionId });
|
|
679
|
-
const a =
|
|
680
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
690
|
+
const a = je(o.attachment, this.options.backendUrl);
|
|
691
|
+
return this.updateAttachmentInState(s.id, a), s.id && ns(s.id, {
|
|
681
692
|
sessionId: o.sessionId,
|
|
682
693
|
fileUrl: a.fileUrl,
|
|
683
694
|
sandboxPath: a.sandboxPath,
|
|
695
|
+
storageKey: a.storageKey,
|
|
684
696
|
lastUsedAt: Date.now()
|
|
685
697
|
}).catch((c) => {
|
|
686
698
|
S("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
@@ -707,7 +719,7 @@ class Ue {
|
|
|
707
719
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
708
720
|
if (n.ok)
|
|
709
721
|
return await n.json();
|
|
710
|
-
if (
|
|
722
|
+
if (jr(n.status) && this.options.tokenProvider && !s) {
|
|
711
723
|
s = !0;
|
|
712
724
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
713
725
|
if (r.ok)
|
|
@@ -733,7 +745,7 @@ class Ue {
|
|
|
733
745
|
}
|
|
734
746
|
startNewSession(t = {}) {
|
|
735
747
|
const s = t.notifyTransport !== !1;
|
|
736
|
-
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.
|
|
748
|
+
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
|
|
737
749
|
type: "session.reset",
|
|
738
750
|
sessionId: this.state.sessionId ?? void 0,
|
|
739
751
|
page: M()
|
|
@@ -751,10 +763,10 @@ class Ue {
|
|
|
751
763
|
});
|
|
752
764
|
}
|
|
753
765
|
listSessions(t = {}) {
|
|
754
|
-
const s =
|
|
766
|
+
const s = j(), n = new Promise((i, o) => {
|
|
755
767
|
const a = window.setTimeout(() => {
|
|
756
768
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
757
|
-
},
|
|
769
|
+
}, de);
|
|
758
770
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
759
771
|
}), r = {
|
|
760
772
|
type: "sessions.list",
|
|
@@ -773,14 +785,14 @@ class Ue {
|
|
|
773
785
|
setSessionPinned(t, s) {
|
|
774
786
|
return this.sendSessionMutation(
|
|
775
787
|
this.pendingSessionPinRequests,
|
|
776
|
-
{ type: "session.pin", requestId:
|
|
788
|
+
{ type: "session.pin", requestId: j(), sessionId: t, pinned: s },
|
|
777
789
|
"Session pin did not respond in time"
|
|
778
790
|
);
|
|
779
791
|
}
|
|
780
792
|
renameSession(t, s) {
|
|
781
793
|
return this.sendSessionMutation(
|
|
782
794
|
this.pendingSessionRenameRequests,
|
|
783
|
-
{ type: "session.rename", requestId:
|
|
795
|
+
{ type: "session.rename", requestId: j(), sessionId: t, title: s },
|
|
784
796
|
"Session rename did not respond in time"
|
|
785
797
|
);
|
|
786
798
|
}
|
|
@@ -802,7 +814,7 @@ class Ue {
|
|
|
802
814
|
});
|
|
803
815
|
}
|
|
804
816
|
send(t) {
|
|
805
|
-
this.sendNow(_(t)) || (this.queuedClientEvents.push(t),
|
|
817
|
+
this.sendNow(_(t)) || (this.queuedClientEvents.push(t), F(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
806
818
|
}
|
|
807
819
|
async getUploadToken() {
|
|
808
820
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -815,7 +827,7 @@ class Ue {
|
|
|
815
827
|
return !1;
|
|
816
828
|
const s = this.socket;
|
|
817
829
|
try {
|
|
818
|
-
return s.send(JSON.stringify(t)), Rt("client_event", t.type,
|
|
830
|
+
return s.send(JSON.stringify(t)), Rt("client_event", t.type, ae(t)), !0;
|
|
819
831
|
} catch (n) {
|
|
820
832
|
return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
821
833
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -828,7 +840,7 @@ class Ue {
|
|
|
828
840
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
829
841
|
return;
|
|
830
842
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
831
|
-
const t =
|
|
843
|
+
const t = Tn();
|
|
832
844
|
this.sendNow(
|
|
833
845
|
_({
|
|
834
846
|
type: "starter_prompts.page_context",
|
|
@@ -839,13 +851,13 @@ class Ue {
|
|
|
839
851
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
840
852
|
}
|
|
841
853
|
startStarterPromptUrlWatcher() {
|
|
842
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
854
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = wn(() => this.handleStarterPromptUrlChange()));
|
|
843
855
|
}
|
|
844
856
|
handleStarterPromptUrlChange() {
|
|
845
857
|
const t = location.href;
|
|
846
858
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
847
859
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
848
|
-
},
|
|
860
|
+
}, Ks));
|
|
849
861
|
}
|
|
850
862
|
refreshStarterPromptsForCurrentUrl() {
|
|
851
863
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -860,21 +872,21 @@ class Ue {
|
|
|
860
872
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
861
873
|
return;
|
|
862
874
|
const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
863
|
-
|
|
875
|
+
F(this.options.clientId, this.queuedClientEvents);
|
|
864
876
|
for (let s = 0; s < t.length; s += 1) {
|
|
865
877
|
const n = t[s];
|
|
866
878
|
if (!this.sendNow(_(n))) {
|
|
867
|
-
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)),
|
|
879
|
+
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), F(this.options.clientId, this.queuedClientEvents);
|
|
868
880
|
return;
|
|
869
881
|
}
|
|
870
|
-
|
|
882
|
+
F(this.options.clientId, this.queuedClientEvents);
|
|
871
883
|
}
|
|
872
884
|
}
|
|
873
885
|
flushPendingWarmupEvent() {
|
|
874
886
|
!this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
|
|
875
887
|
}
|
|
876
888
|
handleServerEvent(t) {
|
|
877
|
-
if (Rt("server_event", t.type,
|
|
889
|
+
if (Rt("server_event", t.type, ae(t)), t.type === "run.ack") {
|
|
878
890
|
const s = kt(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
|
|
879
891
|
s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && n === this.activeClientMessageId && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(t);
|
|
880
892
|
return;
|
|
@@ -895,20 +907,20 @@ class Ue {
|
|
|
895
907
|
this.clearHeartbeatAckTimer();
|
|
896
908
|
return;
|
|
897
909
|
}
|
|
898
|
-
if (
|
|
910
|
+
if (Ys(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
899
911
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
|
|
900
|
-
const s =
|
|
912
|
+
const s = Pn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
901
913
|
S("web-sdk.agent", "Received auth.ok appearance", {
|
|
902
914
|
hasAppearance: n,
|
|
903
915
|
rawAppearance: t.appearance,
|
|
904
916
|
normalizedAppearance: s
|
|
905
|
-
}), this.runtimeHelperJavascript =
|
|
906
|
-
const r =
|
|
907
|
-
user:
|
|
917
|
+
}), this.runtimeHelperJavascript = Un(t.runtimeHelpers)?.javascript ?? null;
|
|
918
|
+
const r = me(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
919
|
+
user: On(t.user),
|
|
908
920
|
status: "connected",
|
|
909
921
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
910
922
|
};
|
|
911
|
-
(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 && !
|
|
923
|
+
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !An() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
912
924
|
type: "page.upsert",
|
|
913
925
|
sessionId: this.state.sessionId,
|
|
914
926
|
page: M(),
|
|
@@ -918,44 +930,44 @@ class Ue {
|
|
|
918
930
|
}
|
|
919
931
|
if (t.type === "starterPrompts.updated") {
|
|
920
932
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
921
|
-
starterPrompts:
|
|
933
|
+
starterPrompts: me(t, "starterPrompts"),
|
|
922
934
|
starterPromptsLoading: !1
|
|
923
935
|
});
|
|
924
936
|
return;
|
|
925
937
|
}
|
|
926
938
|
if (t.type === "conversation.state") {
|
|
927
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
939
|
+
const s = Array.isArray(t.items) ? t.items : [], n = jn(
|
|
928
940
|
t.assistantDraft
|
|
929
941
|
), r = n !== void 0;
|
|
930
942
|
this.rememberUserMessageClientMessageIds(s);
|
|
931
|
-
const i =
|
|
943
|
+
const i = ir(s);
|
|
932
944
|
if (i) {
|
|
933
|
-
const p =
|
|
945
|
+
const p = or(s, i);
|
|
934
946
|
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
935
947
|
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
936
948
|
p
|
|
937
949
|
);
|
|
938
950
|
}
|
|
939
951
|
const o = s.filter((p) => {
|
|
940
|
-
const
|
|
941
|
-
return !
|
|
942
|
-
}), a =
|
|
952
|
+
const g = B(p);
|
|
953
|
+
return !Ie(g) && (!i || !Lt(g));
|
|
954
|
+
}), a = Zn(
|
|
943
955
|
this.state.messages,
|
|
944
|
-
|
|
945
|
-
), c =
|
|
946
|
-
(p) =>
|
|
947
|
-
|
|
956
|
+
xn(o, this.options.backendUrl)
|
|
957
|
+
), c = ye(a), l = !r && s.some(
|
|
958
|
+
(p) => we(
|
|
959
|
+
B(p),
|
|
948
960
|
this.state.assistantDraft,
|
|
949
961
|
this.state.assistantDraftItemId,
|
|
950
962
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
951
963
|
this.state.assistantDraftRunId
|
|
952
964
|
)
|
|
953
|
-
), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l),
|
|
954
|
-
if (!c &&
|
|
965
|
+
), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), m = sr(a), u = I && m;
|
|
966
|
+
if (!c && rr(this.state.messages, s))
|
|
955
967
|
return;
|
|
956
|
-
this.lastUserMessagePageUrl =
|
|
957
|
-
const d = I ? null :
|
|
958
|
-
if (this.latestRecoverableClientMessageId = d,
|
|
968
|
+
this.lastUserMessagePageUrl = nr(s);
|
|
969
|
+
const d = I ? null : Bt(s);
|
|
970
|
+
if (this.latestRecoverableClientMessageId = d, m && this.clearRetryTimers(), this.setState({
|
|
959
971
|
sessionId: R(t.session, "id") ?? this.state.sessionId,
|
|
960
972
|
messages: a,
|
|
961
973
|
...r ? {
|
|
@@ -995,7 +1007,7 @@ class Ue {
|
|
|
995
1007
|
if (t.type === "sessions.page") {
|
|
996
1008
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
997
1009
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
998
|
-
sessions:
|
|
1010
|
+
sessions: Ln(t.sessions),
|
|
999
1011
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
1000
1012
|
}));
|
|
1001
1013
|
return;
|
|
@@ -1014,10 +1026,10 @@ class Ue {
|
|
|
1014
1026
|
}
|
|
1015
1027
|
if (t.type === "session.item") {
|
|
1016
1028
|
this.rememberUserMessageClientMessageIds([t.item]);
|
|
1017
|
-
const s =
|
|
1029
|
+
const s = B(t.item);
|
|
1018
1030
|
if (Lt(s)) {
|
|
1019
1031
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1020
|
-
const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ?
|
|
1032
|
+
const r = R(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);
|
|
1021
1033
|
if (r && a) {
|
|
1022
1034
|
this.retryAfterInterruptedRun(r, a);
|
|
1023
1035
|
return;
|
|
@@ -1027,21 +1039,21 @@ class Ue {
|
|
|
1027
1039
|
return;
|
|
1028
1040
|
}
|
|
1029
1041
|
}
|
|
1030
|
-
if (
|
|
1042
|
+
if (Ie(s))
|
|
1031
1043
|
return;
|
|
1032
|
-
const n =
|
|
1044
|
+
const n = xe(t.item, this.options.backendUrl);
|
|
1033
1045
|
if (n) {
|
|
1034
1046
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1035
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
1047
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), O(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1036
1048
|
const i = t.item.data;
|
|
1037
|
-
|
|
1038
|
-
const o =
|
|
1049
|
+
cr(i) && this.clearRunAckResyncRetryTimer();
|
|
1050
|
+
const o = vt(this.state.messages, n), a = ye(o), c = we(
|
|
1039
1051
|
i,
|
|
1040
1052
|
this.state.assistantDraft,
|
|
1041
1053
|
this.state.assistantDraftItemId,
|
|
1042
1054
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1043
1055
|
this.state.assistantDraftRunId
|
|
1044
|
-
), l = a && (!this.state.assistantDraft || c), h = l &&
|
|
1056
|
+
), l = a && (!this.state.assistantDraft || c), h = l && O(n);
|
|
1045
1057
|
this.setState({
|
|
1046
1058
|
messages: o,
|
|
1047
1059
|
...c ? {
|
|
@@ -1068,7 +1080,7 @@ class Ue {
|
|
|
1068
1080
|
this.clearRunAckResyncRetryTimer();
|
|
1069
1081
|
const s = typeof t.delta == "string" ? t.delta : "", n = typeof t.itemId == "string" ? t.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((f) => f.id === o), c = t.phase === "commentary" || t.phase === "final_answer" ? t.phase : r ? null : this.state.assistantDraftPhase, l = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
|
|
1070
1082
|
this.setState({
|
|
1071
|
-
messages:
|
|
1083
|
+
messages: vt(this.state.messages, {
|
|
1072
1084
|
id: o,
|
|
1073
1085
|
role: "assistant",
|
|
1074
1086
|
content: i,
|
|
@@ -1094,9 +1106,9 @@ class Ue {
|
|
|
1094
1106
|
const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null, r = typeof t.runId == "string" ? t.runId : null;
|
|
1095
1107
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1096
1108
|
return;
|
|
1097
|
-
const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c =
|
|
1109
|
+
const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = us(
|
|
1098
1110
|
this.state.messages.filter(
|
|
1099
|
-
(l) => l.dataType !== "assistant_draft" || !
|
|
1111
|
+
(l) => l.dataType !== "assistant_draft" || !Kn(
|
|
1100
1112
|
l,
|
|
1101
1113
|
n,
|
|
1102
1114
|
r
|
|
@@ -1104,11 +1116,11 @@ class Ue {
|
|
|
1104
1116
|
),
|
|
1105
1117
|
n,
|
|
1106
1118
|
r,
|
|
1107
|
-
|
|
1119
|
+
Le
|
|
1108
1120
|
);
|
|
1109
1121
|
this.setState({
|
|
1110
1122
|
sessionId: s,
|
|
1111
|
-
messages:
|
|
1123
|
+
messages: Gn(
|
|
1112
1124
|
c,
|
|
1113
1125
|
typeof t.responseId == "string" ? t.responseId : null,
|
|
1114
1126
|
n,
|
|
@@ -1129,9 +1141,9 @@ class Ue {
|
|
|
1129
1141
|
if (s)
|
|
1130
1142
|
this.nonTranscriptToolCallIds.add(s);
|
|
1131
1143
|
else {
|
|
1132
|
-
const n =
|
|
1144
|
+
const n = Vn(t);
|
|
1133
1145
|
if (n) {
|
|
1134
|
-
const r =
|
|
1146
|
+
const r = Xn(
|
|
1135
1147
|
this.state.messages,
|
|
1136
1148
|
n
|
|
1137
1149
|
);
|
|
@@ -1175,7 +1187,7 @@ class Ue {
|
|
|
1175
1187
|
return;
|
|
1176
1188
|
}
|
|
1177
1189
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1178
|
-
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c =
|
|
1190
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = yn(a.message);
|
|
1179
1191
|
c && console.error(c), this.setState({
|
|
1180
1192
|
status: "error",
|
|
1181
1193
|
isThinking: !1,
|
|
@@ -1187,7 +1199,7 @@ class Ue {
|
|
|
1187
1199
|
}
|
|
1188
1200
|
}
|
|
1189
1201
|
shouldIgnoreBackgroundSessionEvent(t) {
|
|
1190
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1202
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !Zs(t))
|
|
1191
1203
|
return !1;
|
|
1192
1204
|
const s = kt(t);
|
|
1193
1205
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
@@ -1250,7 +1262,7 @@ class Ue {
|
|
|
1250
1262
|
}
|
|
1251
1263
|
rememberUserMessageClientMessageIds(t) {
|
|
1252
1264
|
for (const s of t) {
|
|
1253
|
-
const n = R(s, "id"), r =
|
|
1265
|
+
const n = R(s, "id"), r = B(s);
|
|
1254
1266
|
n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
|
|
1255
1267
|
}
|
|
1256
1268
|
}
|
|
@@ -1263,7 +1275,7 @@ class Ue {
|
|
|
1263
1275
|
const r = new Promise((i, o) => {
|
|
1264
1276
|
const a = window.setTimeout(() => {
|
|
1265
1277
|
t.delete(s.requestId), o(new Error(n));
|
|
1266
|
-
},
|
|
1278
|
+
}, de);
|
|
1267
1279
|
t.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1268
1280
|
});
|
|
1269
1281
|
if (!this.sendNow(s)) {
|
|
@@ -1286,7 +1298,7 @@ class Ue {
|
|
|
1286
1298
|
t.clear();
|
|
1287
1299
|
}
|
|
1288
1300
|
markThinkingProgress() {
|
|
1289
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1301
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ue), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1290
1302
|
}
|
|
1291
1303
|
scheduleThinkingWatchdog(t) {
|
|
1292
1304
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1306,7 +1318,7 @@ class Ue {
|
|
|
1306
1318
|
handleRunSteered(t) {
|
|
1307
1319
|
const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
|
|
1308
1320
|
!this.state.isThinking || !s || this.setState({
|
|
1309
|
-
messages:
|
|
1321
|
+
messages: ur(
|
|
1310
1322
|
this.state.messages,
|
|
1311
1323
|
s
|
|
1312
1324
|
)
|
|
@@ -1315,7 +1327,7 @@ class Ue {
|
|
|
1315
1327
|
scheduleRunAckWatchdog(t) {
|
|
1316
1328
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1317
1329
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1318
|
-
},
|
|
1330
|
+
}, Ls);
|
|
1319
1331
|
}
|
|
1320
1332
|
recoverMissedRunAck(t) {
|
|
1321
1333
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -1339,8 +1351,8 @@ class Ue {
|
|
|
1339
1351
|
sessionId: this.state.sessionId,
|
|
1340
1352
|
clientMessageId: t,
|
|
1341
1353
|
automatic: !0
|
|
1342
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1343
|
-
}, Y(s,
|
|
1354
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ue)));
|
|
1355
|
+
}, Y(s, Bs)));
|
|
1344
1356
|
}
|
|
1345
1357
|
clearRunAckResyncRetryTimer() {
|
|
1346
1358
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1379,7 +1391,7 @@ class Ue {
|
|
|
1379
1391
|
sessionId: this.state.sessionId,
|
|
1380
1392
|
clientMessageId: t,
|
|
1381
1393
|
resyncAttempts: s + 1
|
|
1382
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1394
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(vs);
|
|
1383
1395
|
return;
|
|
1384
1396
|
}
|
|
1385
1397
|
this.setState({
|
|
@@ -1414,7 +1426,7 @@ class Ue {
|
|
|
1414
1426
|
if (!s || !n || !r)
|
|
1415
1427
|
return;
|
|
1416
1428
|
const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1417
|
-
if (!a && !c || !
|
|
1429
|
+
if (!a && !c || !Ur(o)) {
|
|
1418
1430
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1419
1431
|
type: "tool.result",
|
|
1420
1432
|
sessionId: s,
|
|
@@ -1446,7 +1458,6 @@ class Ue {
|
|
|
1446
1458
|
});
|
|
1447
1459
|
return;
|
|
1448
1460
|
}
|
|
1449
|
-
const l = Zs(this.state.messages);
|
|
1450
1461
|
this.activeBrowserToolCalls.set(n, {
|
|
1451
1462
|
event: {
|
|
1452
1463
|
type: "tool.result",
|
|
@@ -1460,15 +1471,15 @@ class Ue {
|
|
|
1460
1471
|
startedAtMs: Date.now(),
|
|
1461
1472
|
startedAtUrl: location.href,
|
|
1462
1473
|
startedAtOrigin: location.origin
|
|
1463
|
-
}), this.
|
|
1464
|
-
let
|
|
1465
|
-
|
|
1474
|
+
}), this.installSessionBrowserApis();
|
|
1475
|
+
let l = null, h;
|
|
1476
|
+
l = await this.executeRuntimeHelper(), h = await fe(
|
|
1466
1477
|
o,
|
|
1467
|
-
|
|
1468
|
-
).catch((
|
|
1478
|
+
hn(t.runtimeContext, this.options.backendUrl)
|
|
1479
|
+
).catch((f) => ({
|
|
1469
1480
|
ok: !1,
|
|
1470
1481
|
exception: {
|
|
1471
|
-
message:
|
|
1482
|
+
message: f instanceof Error ? f.message : String(f)
|
|
1472
1483
|
}
|
|
1473
1484
|
})), this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
1474
1485
|
type: "tool.result",
|
|
@@ -1477,11 +1488,11 @@ class Ue {
|
|
|
1477
1488
|
toolName: r,
|
|
1478
1489
|
summary: o.summary,
|
|
1479
1490
|
rawInput: _(o),
|
|
1480
|
-
rawOutput: _(
|
|
1481
|
-
}),
|
|
1491
|
+
rawOutput: _(Dn(h, l))
|
|
1492
|
+
}), wr(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1482
1493
|
}
|
|
1483
1494
|
setToolMessageLoading(t, s) {
|
|
1484
|
-
const n =
|
|
1495
|
+
const n = Jn(
|
|
1485
1496
|
this.state.messages,
|
|
1486
1497
|
t,
|
|
1487
1498
|
s
|
|
@@ -1492,33 +1503,33 @@ class Ue {
|
|
|
1492
1503
|
if (this.pageLifecycleCleanup)
|
|
1493
1504
|
return;
|
|
1494
1505
|
const t = () => {
|
|
1495
|
-
|
|
1506
|
+
We(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1496
1507
|
};
|
|
1497
1508
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
1498
1509
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
1499
1510
|
};
|
|
1500
1511
|
}
|
|
1501
|
-
|
|
1502
|
-
this.
|
|
1512
|
+
installSessionBrowserApis() {
|
|
1513
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = en();
|
|
1503
1514
|
}
|
|
1504
|
-
|
|
1505
|
-
this.
|
|
1515
|
+
cleanupSessionBrowserApis() {
|
|
1516
|
+
this.sessionBrowserApisCleanup && (un(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
1506
1517
|
}
|
|
1507
1518
|
async executeRuntimeHelper() {
|
|
1508
1519
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1509
1520
|
return null;
|
|
1510
|
-
const t = await
|
|
1521
|
+
const t = await fe({
|
|
1511
1522
|
javascript: this.runtimeHelperJavascript
|
|
1512
1523
|
});
|
|
1513
|
-
return t.ok === !1 ?
|
|
1524
|
+
return t.ok === !1 ? Nn(t) : null;
|
|
1514
1525
|
}
|
|
1515
1526
|
enableNetworkCapture() {
|
|
1516
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1517
|
-
|
|
1527
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = Js((t) => {
|
|
1528
|
+
Lr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1518
1529
|
}));
|
|
1519
1530
|
}
|
|
1520
1531
|
enqueueNetworkEvent(t) {
|
|
1521
|
-
this.queuedNetworkEvents.length >=
|
|
1532
|
+
this.queuedNetworkEvents.length >= Hs || (this.queuedNetworkEvents.push(xr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1522
1533
|
this.networkBatchTimer = null;
|
|
1523
1534
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1524
1535
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1527,12 +1538,12 @@ class Ue {
|
|
|
1527
1538
|
page: M(),
|
|
1528
1539
|
events: s
|
|
1529
1540
|
});
|
|
1530
|
-
},
|
|
1541
|
+
}, qs)));
|
|
1531
1542
|
}
|
|
1532
1543
|
scheduleReconnect() {
|
|
1533
1544
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1534
1545
|
return;
|
|
1535
|
-
const t =
|
|
1546
|
+
const t = Gs(this.reconnectAttempts);
|
|
1536
1547
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1537
1548
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1538
1549
|
S("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1548,8 +1559,8 @@ class Ue {
|
|
|
1548
1559
|
const t = this.socket;
|
|
1549
1560
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1550
1561
|
this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1551
|
-
},
|
|
1552
|
-
},
|
|
1562
|
+
}, Cs));
|
|
1563
|
+
}, _s);
|
|
1553
1564
|
}
|
|
1554
1565
|
stopHeartbeat() {
|
|
1555
1566
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1575,7 +1586,7 @@ class Ue {
|
|
|
1575
1586
|
...t,
|
|
1576
1587
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1577
1588
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1578
|
-
},
|
|
1589
|
+
}, Ir(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
|
|
1579
1590
|
status: this.state.status,
|
|
1580
1591
|
sessionId: this.state.sessionId,
|
|
1581
1592
|
messageCount: this.state.messages.length,
|
|
@@ -1592,42 +1603,42 @@ class Ue {
|
|
|
1592
1603
|
this.state.isThinking && this.activeClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId);
|
|
1593
1604
|
}
|
|
1594
1605
|
getRunRecoveryExhaustedErrorMessage(t) {
|
|
1595
|
-
return t && this.browserConnectionInterruptedClientMessageIds.has(t) ?
|
|
1606
|
+
return t && this.browserConnectionInterruptedClientMessageIds.has(t) ? xs : Os;
|
|
1596
1607
|
}
|
|
1597
1608
|
emit(t, s) {
|
|
1598
1609
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1599
1610
|
}
|
|
1600
1611
|
}
|
|
1601
1612
|
const Mt = /* @__PURE__ */ new WeakMap();
|
|
1602
|
-
function
|
|
1603
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1613
|
+
function Js(e) {
|
|
1614
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Vs();
|
|
1604
1615
|
return t.subscribers.add(e), () => {
|
|
1605
1616
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1606
1617
|
};
|
|
1607
1618
|
}
|
|
1608
|
-
function
|
|
1619
|
+
function Vs() {
|
|
1609
1620
|
const e = /* @__PURE__ */ new Set(), t = (I) => {
|
|
1610
|
-
e.forEach((
|
|
1621
|
+
e.forEach((m) => {
|
|
1611
1622
|
try {
|
|
1612
|
-
|
|
1623
|
+
m(I);
|
|
1613
1624
|
} catch {
|
|
1614
1625
|
}
|
|
1615
1626
|
});
|
|
1616
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(
|
|
1627
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(m, u) {
|
|
1617
1628
|
const d = Date.now();
|
|
1618
1629
|
let p;
|
|
1619
1630
|
try {
|
|
1620
|
-
p = s.call(this,
|
|
1621
|
-
} catch (
|
|
1622
|
-
throw
|
|
1631
|
+
p = s.call(this, m, u);
|
|
1632
|
+
} catch (g) {
|
|
1633
|
+
throw g;
|
|
1623
1634
|
}
|
|
1624
1635
|
try {
|
|
1625
|
-
const
|
|
1626
|
-
if (!x(
|
|
1627
|
-
const
|
|
1628
|
-
requestId:
|
|
1629
|
-
url:
|
|
1630
|
-
method: (u?.method ??
|
|
1636
|
+
const g = m instanceof Request ? m : null, A = Dr(m, g), T = ze(u?.headers ?? g?.headers);
|
|
1637
|
+
if (!x(A, T, u?.body)) {
|
|
1638
|
+
const H = {
|
|
1639
|
+
requestId: Pt("fetch"),
|
|
1640
|
+
url: P(A, bt),
|
|
1641
|
+
method: (u?.method ?? g?.method ?? "GET").toUpperCase(),
|
|
1631
1642
|
requestHeaders: T,
|
|
1632
1643
|
requestBody: Ee(u?.body),
|
|
1633
1644
|
resourceType: "fetch",
|
|
@@ -1635,9 +1646,9 @@ function Gs() {
|
|
|
1635
1646
|
};
|
|
1636
1647
|
p.then(
|
|
1637
1648
|
(C) => {
|
|
1638
|
-
|
|
1649
|
+
Nr(C, H, d, t).catch(() => {
|
|
1639
1650
|
t({
|
|
1640
|
-
...
|
|
1651
|
+
...H,
|
|
1641
1652
|
responseStatus: C.status,
|
|
1642
1653
|
durationMs: Date.now() - d
|
|
1643
1654
|
});
|
|
@@ -1645,8 +1656,8 @@ function Gs() {
|
|
|
1645
1656
|
},
|
|
1646
1657
|
(C) => {
|
|
1647
1658
|
t({
|
|
1648
|
-
...
|
|
1649
|
-
errorText:
|
|
1659
|
+
...H,
|
|
1660
|
+
errorText: P(C instanceof Error ? C.message : String(C)),
|
|
1650
1661
|
durationMs: Date.now() - d
|
|
1651
1662
|
});
|
|
1652
1663
|
}
|
|
@@ -1655,29 +1666,29 @@ function Gs() {
|
|
|
1655
1666
|
} catch {
|
|
1656
1667
|
}
|
|
1657
1668
|
return p;
|
|
1658
|
-
}, a = function(
|
|
1659
|
-
const
|
|
1669
|
+
}, a = function(m, u, d, p, g) {
|
|
1670
|
+
const A = n.call(this, m, u, d ?? !0, p ?? void 0, g ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
1660
1671
|
return Mt.set(this, {
|
|
1661
|
-
requestId:
|
|
1662
|
-
method: String(
|
|
1663
|
-
url:
|
|
1672
|
+
requestId: Pt("xhr"),
|
|
1673
|
+
method: String(m ?? "GET").toUpperCase(),
|
|
1674
|
+
url: P(T, bt),
|
|
1664
1675
|
requestHeaders: {},
|
|
1665
1676
|
startedAtMs: Date.now(),
|
|
1666
1677
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1667
1678
|
excluded: x(T)
|
|
1668
|
-
}),
|
|
1669
|
-
}, c = function(
|
|
1670
|
-
const d = r.call(this,
|
|
1671
|
-
return p && Object.keys(p.requestHeaders).length <
|
|
1672
|
-
}, l = function(
|
|
1679
|
+
}), A;
|
|
1680
|
+
}, c = function(m, u) {
|
|
1681
|
+
const d = r.call(this, m, u), p = Mt.get(this);
|
|
1682
|
+
return p && Object.keys(p.requestHeaders).length < zt && (p.requestHeaders[m] = Vt(m, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
|
|
1683
|
+
}, l = function(m) {
|
|
1673
1684
|
try {
|
|
1674
1685
|
const u = Mt.get(this);
|
|
1675
|
-
u && (u.excluded = u.excluded || x(u.url, u.requestHeaders,
|
|
1686
|
+
u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, m), u.requestBody = Ee(m), u.excluded || this.addEventListener(
|
|
1676
1687
|
"loadend",
|
|
1677
1688
|
() => {
|
|
1678
1689
|
queueMicrotask(() => {
|
|
1679
1690
|
try {
|
|
1680
|
-
const d =
|
|
1691
|
+
const d = qr(this.getAllResponseHeaders());
|
|
1681
1692
|
t({
|
|
1682
1693
|
requestId: u.requestId,
|
|
1683
1694
|
url: u.url,
|
|
@@ -1687,7 +1698,7 @@ function Gs() {
|
|
|
1687
1698
|
resourceType: "xhr",
|
|
1688
1699
|
responseStatus: this.status,
|
|
1689
1700
|
responseHeaders: d,
|
|
1690
|
-
responseBody:
|
|
1701
|
+
responseBody: Or(this, d),
|
|
1691
1702
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1692
1703
|
startedAt: u.startedAt,
|
|
1693
1704
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -1701,7 +1712,7 @@ function Gs() {
|
|
|
1701
1712
|
));
|
|
1702
1713
|
} catch {
|
|
1703
1714
|
}
|
|
1704
|
-
return i.call(this,
|
|
1715
|
+
return i.call(this, m ?? null);
|
|
1705
1716
|
};
|
|
1706
1717
|
try {
|
|
1707
1718
|
window.fetch = o;
|
|
@@ -1722,14 +1733,14 @@ function Gs() {
|
|
|
1722
1733
|
let h = null;
|
|
1723
1734
|
if (typeof PerformanceObserver < "u") {
|
|
1724
1735
|
h = new PerformanceObserver((I) => {
|
|
1725
|
-
for (const
|
|
1726
|
-
const u =
|
|
1736
|
+
for (const m of I.getEntries()) {
|
|
1737
|
+
const u = m;
|
|
1727
1738
|
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || x(u.name))
|
|
1728
1739
|
continue;
|
|
1729
1740
|
const d = performance.timeOrigin + u.startTime;
|
|
1730
1741
|
t({
|
|
1731
|
-
requestId:
|
|
1732
|
-
url:
|
|
1742
|
+
requestId: Pt("resource"),
|
|
1743
|
+
url: P(u.name, bt),
|
|
1733
1744
|
method: "GET",
|
|
1734
1745
|
resourceType: "resource",
|
|
1735
1746
|
responseStatus: u.responseStatus,
|
|
@@ -1779,14 +1790,14 @@ function S(e, t, s) {
|
|
|
1779
1790
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1780
1791
|
i.push(r), i.length > 120 && i.splice(0, i.length - 120), n.__plunoProductAgentDiagnostics__ = i, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: r }));
|
|
1781
1792
|
}
|
|
1782
|
-
function
|
|
1793
|
+
function pe(e) {
|
|
1783
1794
|
const t = typeof e == "function" ? e() : e;
|
|
1784
1795
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1785
1796
|
}
|
|
1786
|
-
function
|
|
1797
|
+
function Ys(e) {
|
|
1787
1798
|
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";
|
|
1788
1799
|
}
|
|
1789
|
-
function
|
|
1800
|
+
function Zs(e) {
|
|
1790
1801
|
return e.type === "run.steered" || e.type === "run.ack" || e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call" || e.type === "tool.status" || e.type === "error" && typeof e.requestId != "string";
|
|
1791
1802
|
}
|
|
1792
1803
|
function kt(e) {
|
|
@@ -1804,42 +1815,31 @@ function kt(e) {
|
|
|
1804
1815
|
}
|
|
1805
1816
|
return null;
|
|
1806
1817
|
}
|
|
1807
|
-
const
|
|
1808
|
-
function
|
|
1809
|
-
const
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
id: `${s.id}:attachment:${r}`,
|
|
1814
|
-
...n
|
|
1815
|
-
});
|
|
1816
|
-
});
|
|
1817
|
-
return t;
|
|
1818
|
-
}
|
|
1819
|
-
function Qs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1820
|
-
const n = [
|
|
1821
|
-
en(),
|
|
1822
|
-
tn()
|
|
1823
|
-
].filter((r) => typeof r == "function");
|
|
1818
|
+
const Qs = 5e3, tn = 12e4;
|
|
1819
|
+
function en() {
|
|
1820
|
+
const e = [
|
|
1821
|
+
nn(),
|
|
1822
|
+
sn()
|
|
1823
|
+
].filter((t) => typeof t == "function");
|
|
1824
1824
|
return () => {
|
|
1825
|
-
for (const
|
|
1826
|
-
|
|
1825
|
+
for (const t of e.reverse())
|
|
1826
|
+
t();
|
|
1827
1827
|
};
|
|
1828
1828
|
}
|
|
1829
|
-
function
|
|
1830
|
-
return be(globalThis, "getPageSnapshot", async () =>
|
|
1829
|
+
function sn() {
|
|
1830
|
+
return be(globalThis, "getPageSnapshot", async () => Kt());
|
|
1831
1831
|
}
|
|
1832
|
-
function
|
|
1832
|
+
function nn() {
|
|
1833
1833
|
return be(globalThis, "pageImages", {
|
|
1834
|
-
inspectImage: async (t, s) => await
|
|
1834
|
+
inspectImage: async (t, s) => await rn(t, s)
|
|
1835
1835
|
});
|
|
1836
1836
|
}
|
|
1837
|
-
async function
|
|
1838
|
-
const s =
|
|
1837
|
+
async function rn(e, t = {}) {
|
|
1838
|
+
const s = ln(t.name), n = await on(e);
|
|
1839
1839
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1840
1840
|
type: "pluno.pageImages.inspectImage",
|
|
1841
1841
|
imageAttached: !1,
|
|
1842
|
-
imageAttachmentError:
|
|
1842
|
+
imageAttachmentError: Ce
|
|
1843
1843
|
} : {
|
|
1844
1844
|
type: "pluno.pageImages.inspectImage",
|
|
1845
1845
|
imageAttached: !0,
|
|
@@ -1853,15 +1853,15 @@ async function sn(e, t = {}) {
|
|
|
1853
1853
|
imageAttachmentError: n.error
|
|
1854
1854
|
};
|
|
1855
1855
|
}
|
|
1856
|
-
async function
|
|
1857
|
-
return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error:
|
|
1856
|
+
async function on(e) {
|
|
1857
|
+
return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: Ce } : {
|
|
1858
1858
|
ok: !0,
|
|
1859
1859
|
mimeType: e.type,
|
|
1860
1860
|
sizeBytes: e.size,
|
|
1861
|
-
dataUrl: await
|
|
1862
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
1861
|
+
dataUrl: await dn(e)
|
|
1862
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : an(e);
|
|
1863
1863
|
}
|
|
1864
|
-
function
|
|
1864
|
+
function an(e) {
|
|
1865
1865
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1866
1866
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1867
1867
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1872,7 +1872,7 @@ function rn(e) {
|
|
|
1872
1872
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1873
1873
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1874
1874
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1875
|
-
const o =
|
|
1875
|
+
const o = cn(i);
|
|
1876
1876
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1877
1877
|
ok: !0,
|
|
1878
1878
|
mimeType: r,
|
|
@@ -1880,22 +1880,22 @@ function rn(e) {
|
|
|
1880
1880
|
dataUrl: `data:${r};base64,${i}`
|
|
1881
1881
|
};
|
|
1882
1882
|
}
|
|
1883
|
-
function
|
|
1883
|
+
function cn(e) {
|
|
1884
1884
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1885
1885
|
return null;
|
|
1886
1886
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1887
1887
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1888
1888
|
}
|
|
1889
|
-
function
|
|
1889
|
+
function ln(e) {
|
|
1890
1890
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1891
1891
|
}
|
|
1892
|
-
function
|
|
1892
|
+
function un(e) {
|
|
1893
1893
|
try {
|
|
1894
1894
|
e();
|
|
1895
1895
|
} catch {
|
|
1896
1896
|
}
|
|
1897
1897
|
}
|
|
1898
|
-
function
|
|
1898
|
+
function dn(e) {
|
|
1899
1899
|
return new Promise((t, s) => {
|
|
1900
1900
|
const n = new FileReader();
|
|
1901
1901
|
n.onload = () => {
|
|
@@ -1903,13 +1903,13 @@ function ln(e) {
|
|
|
1903
1903
|
t(n.result);
|
|
1904
1904
|
return;
|
|
1905
1905
|
}
|
|
1906
|
-
s(new Error("Failed to read
|
|
1907
|
-
}, n.onerror = () => s(n.error ?? new Error("Failed to read
|
|
1906
|
+
s(new Error("Failed to read page image"));
|
|
1907
|
+
}, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(e);
|
|
1908
1908
|
});
|
|
1909
1909
|
}
|
|
1910
|
-
async function
|
|
1910
|
+
async function fe(e, t) {
|
|
1911
1911
|
const s = Object.getPrototypeOf(async function() {
|
|
1912
|
-
}).constructor, n = e.timeoutMs ??
|
|
1912
|
+
}).constructor, n = e.timeoutMs ?? Qs, r = Date.now(), i = [];
|
|
1913
1913
|
let o;
|
|
1914
1914
|
const a = {
|
|
1915
1915
|
log: console.log,
|
|
@@ -1927,7 +1927,7 @@ async function pe(e, t) {
|
|
|
1927
1927
|
o = window.setTimeout(() => f(l), n);
|
|
1928
1928
|
})
|
|
1929
1929
|
]);
|
|
1930
|
-
return h === l ?
|
|
1930
|
+
return h === l ? pn(n) : {
|
|
1931
1931
|
ok: !0,
|
|
1932
1932
|
result: h,
|
|
1933
1933
|
console: i,
|
|
@@ -1956,7 +1956,7 @@ async function pe(e, t) {
|
|
|
1956
1956
|
t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
1957
1957
|
}
|
|
1958
1958
|
}
|
|
1959
|
-
function
|
|
1959
|
+
function hn(e, t) {
|
|
1960
1960
|
if (!e || typeof e != "object")
|
|
1961
1961
|
return;
|
|
1962
1962
|
const s = e.sandboxFilesToken;
|
|
@@ -1966,7 +1966,7 @@ function un(e, t) {
|
|
|
1966
1966
|
const r = () => {
|
|
1967
1967
|
if (!n)
|
|
1968
1968
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
1969
|
-
}, i = async (a, c) => await
|
|
1969
|
+
}, i = async (a, c) => await Ss(`${t.replace(/\/$/, "")}${a}`, c);
|
|
1970
1970
|
return {
|
|
1971
1971
|
value: Object.freeze({
|
|
1972
1972
|
upload: async (a) => {
|
|
@@ -2000,7 +2000,7 @@ function un(e, t) {
|
|
|
2000
2000
|
}
|
|
2001
2001
|
};
|
|
2002
2002
|
}
|
|
2003
|
-
function
|
|
2003
|
+
function pn(e) {
|
|
2004
2004
|
return {
|
|
2005
2005
|
ok: !1,
|
|
2006
2006
|
exception: {
|
|
@@ -2014,10 +2014,10 @@ function dn(e) {
|
|
|
2014
2014
|
}
|
|
2015
2015
|
};
|
|
2016
2016
|
}
|
|
2017
|
-
function
|
|
2017
|
+
function fn(e) {
|
|
2018
2018
|
return e.replace(/\/+$/, "");
|
|
2019
2019
|
}
|
|
2020
|
-
function
|
|
2020
|
+
function gn(e) {
|
|
2021
2021
|
const t = {
|
|
2022
2022
|
sidepanel: "extension_sidepanel",
|
|
2023
2023
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2029,13 +2029,13 @@ function pn(e) {
|
|
|
2029
2029
|
};
|
|
2030
2030
|
return e && e in t ? t[e] : e ?? "embedded_custom_ui";
|
|
2031
2031
|
}
|
|
2032
|
-
function
|
|
2032
|
+
function mn(e) {
|
|
2033
2033
|
return e === "pluno" ? "scheduled_continuation" : e ?? "user";
|
|
2034
2034
|
}
|
|
2035
|
-
function
|
|
2035
|
+
function yn(e, t = location.origin) {
|
|
2036
2036
|
return /origin (?:is not allowed|does not match browser origin)/i.test(e) ? `Pluno widget blocked on ${t}: this domain is not allowed. Add ${t} in Pluno under Integration > Domains.` : null;
|
|
2037
2037
|
}
|
|
2038
|
-
function
|
|
2038
|
+
function In(e) {
|
|
2039
2039
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
2040
2040
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
2041
2041
|
}
|
|
@@ -2048,19 +2048,19 @@ function M() {
|
|
|
2048
2048
|
...e ? { plunoProductAgentUi: e } : {}
|
|
2049
2049
|
};
|
|
2050
2050
|
}
|
|
2051
|
-
function
|
|
2051
|
+
function Tn() {
|
|
2052
2052
|
return {
|
|
2053
2053
|
pageUrl: location.href,
|
|
2054
2054
|
pageTitle: document.title,
|
|
2055
|
-
htmlContent:
|
|
2055
|
+
htmlContent: Kt()
|
|
2056
2056
|
};
|
|
2057
2057
|
}
|
|
2058
|
-
function
|
|
2059
|
-
return st.add(e), Z || (Z =
|
|
2058
|
+
function wn(e) {
|
|
2059
|
+
return st.add(e), Z || (Z = Sn()), () => {
|
|
2060
2060
|
st.delete(e), st.size === 0 && (Z?.(), Z = null);
|
|
2061
2061
|
};
|
|
2062
2062
|
}
|
|
2063
|
-
function
|
|
2063
|
+
function Sn() {
|
|
2064
2064
|
const e = () => {
|
|
2065
2065
|
for (const i of Array.from(st))
|
|
2066
2066
|
i();
|
|
@@ -2075,38 +2075,38 @@ function Tn() {
|
|
|
2075
2075
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
2076
2076
|
};
|
|
2077
2077
|
}
|
|
2078
|
-
function
|
|
2078
|
+
function An() {
|
|
2079
2079
|
return Oe()?.surface === "browser_extension_sdk_preview";
|
|
2080
2080
|
}
|
|
2081
|
-
function
|
|
2081
|
+
function Kt() {
|
|
2082
2082
|
if (!document.body)
|
|
2083
2083
|
return "";
|
|
2084
2084
|
const e = [], t = [], s = (d, p) => {
|
|
2085
|
-
const
|
|
2086
|
-
!
|
|
2085
|
+
const g = q(p);
|
|
2086
|
+
!g || t.includes(g) || (e.push([d, g]), t.push(g));
|
|
2087
2087
|
};
|
|
2088
2088
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2089
2089
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2090
|
-
(d) =>
|
|
2090
|
+
(d) => De(d) && !d.parentElement?.closest(n)
|
|
2091
2091
|
);
|
|
2092
2092
|
for (const d of r.slice(0, 3))
|
|
2093
2093
|
s("Active overlay", _t(z(d), t));
|
|
2094
|
-
const i =
|
|
2094
|
+
const i = En(), o = i ? _t(z(i), t) : "";
|
|
2095
2095
|
s("Main page content", o), s("Additional visible page text", _t(z(document.body), t));
|
|
2096
2096
|
const a = e.map(([d, p]) => `${d}:
|
|
2097
2097
|
${p}`).join(`
|
|
2098
2098
|
|
|
2099
|
-
`).trim().slice(0, 12e3), c =
|
|
2099
|
+
`).trim().slice(0, 12e3), c = Rn(r, i).trim(), l = `Simplified DOM outline:
|
|
2100
2100
|
`, h = `
|
|
2101
2101
|
|
|
2102
2102
|
Visible page text:
|
|
2103
|
-
`, f = 12e3 - l.length - h.length, I = Math.min(a.length, 7900),
|
|
2104
|
-
return `${l}${
|
|
2103
|
+
`, f = 12e3 - l.length - h.length, I = Math.min(a.length, 7900), m = c.slice(0, f - I), u = a.slice(0, f - m.length);
|
|
2104
|
+
return `${l}${m}${h}${u}`;
|
|
2105
2105
|
}
|
|
2106
2106
|
function z(e) {
|
|
2107
2107
|
return e.innerText ?? e.textContent ?? "";
|
|
2108
2108
|
}
|
|
2109
|
-
function
|
|
2109
|
+
function q(e) {
|
|
2110
2110
|
return (e ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2111
2111
|
`).split(`
|
|
2112
2112
|
`).map((t) => t.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2115,19 +2115,19 @@ function B(e) {
|
|
|
2115
2115
|
`).trim();
|
|
2116
2116
|
}
|
|
2117
2117
|
function _t(e, t) {
|
|
2118
|
-
let s =
|
|
2118
|
+
let s = q(e);
|
|
2119
2119
|
for (const n of t)
|
|
2120
2120
|
s = s.replace(n, "");
|
|
2121
|
-
return
|
|
2121
|
+
return q(s);
|
|
2122
2122
|
}
|
|
2123
|
-
function
|
|
2123
|
+
function De(e) {
|
|
2124
2124
|
const t = window.getComputedStyle(e);
|
|
2125
2125
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
2126
2126
|
}
|
|
2127
|
-
function
|
|
2128
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2127
|
+
function En() {
|
|
2128
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(De).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
|
|
2129
2129
|
}
|
|
2130
|
-
function
|
|
2130
|
+
function Rn(e, t) {
|
|
2131
2131
|
const s = /* @__PURE__ */ new Set([
|
|
2132
2132
|
"main",
|
|
2133
2133
|
"nav",
|
|
@@ -2207,92 +2207,92 @@ function An(e, t) {
|
|
|
2207
2207
|
"data-test",
|
|
2208
2208
|
"data-qa",
|
|
2209
2209
|
"data-cy"
|
|
2210
|
-
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } =
|
|
2210
|
+
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = bn(), I = new Set(e);
|
|
2211
2211
|
t && I.add(t);
|
|
2212
|
-
let
|
|
2212
|
+
let m = 0;
|
|
2213
2213
|
const u = (T) => {
|
|
2214
2214
|
const D = T.getAttribute("role");
|
|
2215
2215
|
return D && !o.has(D) ? D : "";
|
|
2216
2216
|
}, d = (T) => {
|
|
2217
2217
|
const D = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
|
|
2218
2218
|
return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
|
|
2219
|
-
}, p = (T, D,
|
|
2220
|
-
const C = (
|
|
2221
|
-
const b =
|
|
2222
|
-
if (
|
|
2219
|
+
}, p = (T, D, H) => {
|
|
2220
|
+
const C = (E, dt) => {
|
|
2221
|
+
const b = E.tagName.toLowerCase(), ht = window.getComputedStyle(E), K = h.has(E);
|
|
2222
|
+
if (m >= 1e3 && !K || H.has(E) || i.has(b) || E.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
|
|
2223
2223
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2224
|
-
|
|
2225
|
-
const
|
|
2224
|
+
m += 1;
|
|
2225
|
+
const Yt = u(E), G = ve(E), Qe = a.has(Yt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && E.hasAttribute("href"), pt = Array.from(E.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
|
|
2226
2226
|
for (const y of pt) {
|
|
2227
2227
|
const w = d(y);
|
|
2228
2228
|
X.set(w, (X.get(w) ?? 0) + 1);
|
|
2229
2229
|
}
|
|
2230
|
-
const ft = /* @__PURE__ */ new Map(),
|
|
2230
|
+
const ft = /* @__PURE__ */ new Map(), Zt = /* @__PURE__ */ new Map();
|
|
2231
2231
|
for (const y of pt) {
|
|
2232
|
-
const w = d(y),
|
|
2233
|
-
|
|
2232
|
+
const w = d(y), N = Zt.get(w) ?? 0;
|
|
2233
|
+
Zt.set(w, N + 1), (X.get(w) ?? 0) > 8 && N >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
|
|
2234
2234
|
}
|
|
2235
|
-
const
|
|
2235
|
+
const Qt = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Set(), gt = [], ee = [];
|
|
2236
2236
|
for (const y of pt) {
|
|
2237
|
-
const w = d(y),
|
|
2238
|
-
if (
|
|
2239
|
-
|
|
2237
|
+
const w = d(y), N = X.get(w) ?? 0, re = Qt.get(w) ?? 0;
|
|
2238
|
+
if (Qt.set(w, re + 1), N > 8 && re >= 6 && !h.has(y)) {
|
|
2239
|
+
te.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), te.add(w));
|
|
2240
2240
|
continue;
|
|
2241
2241
|
}
|
|
2242
|
-
const
|
|
2243
|
-
|
|
2242
|
+
const ie = C(y, dt);
|
|
2243
|
+
ee.push(ie), gt.push(ie.lines);
|
|
2244
2244
|
}
|
|
2245
2245
|
const mt = [];
|
|
2246
|
-
if (
|
|
2247
|
-
for (const y of Array.from(
|
|
2246
|
+
if (E.shadowRoot)
|
|
2247
|
+
for (const y of Array.from(E.shadowRoot.children))
|
|
2248
2248
|
y instanceof HTMLElement && mt.push(C(y, dt + 1));
|
|
2249
|
-
const J = [...
|
|
2249
|
+
const J = [...ee, ...mt], yt = G.length > 0 || Qe || J.some((y) => y.hasUsefulContent), se = q(
|
|
2250
2250
|
[G, ...J.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2251
|
-
).slice(0, 180),
|
|
2251
|
+
).slice(0, 180), ts = E.hasAttribute("contenteditable") && (G.length > 0 || !E.querySelector("[contenteditable]")), ne = l.some((y) => E.hasAttribute(y)) || !!Yt || ts, It = (E.getClientRects().length > 0 || ht.display === "contents") && (s.has(b) || ne || K) && (yt || K) && (!r.has(b) || yt || ne || K), Tt = It ? 1 : 0, W = [];
|
|
2252
2252
|
if (It) {
|
|
2253
|
-
const y = J.some((
|
|
2254
|
-
|
|
2253
|
+
const y = J.some((N) => N.containsTextElement), w = n.has(b) && !y ? se : G;
|
|
2254
|
+
W.push(Ne(E, c, o, w.slice(0, 180)));
|
|
2255
2255
|
}
|
|
2256
2256
|
for (const y of gt)
|
|
2257
|
-
|
|
2257
|
+
W.push(...Q(y, Tt));
|
|
2258
2258
|
const wt = mt.flatMap((y) => y.lines);
|
|
2259
2259
|
if (wt.length > 0) {
|
|
2260
2260
|
const y = wt.slice(0, 20);
|
|
2261
2261
|
wt.length > y.length && y.push("… shadow DOM omitted");
|
|
2262
2262
|
const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
|
|
2263
2263
|
if (dt < 2 && !w) {
|
|
2264
|
-
const
|
|
2265
|
-
|
|
2264
|
+
const N = It ? "#shadow-root" : `${b} #shadow-root`;
|
|
2265
|
+
W.push(...Q([N, ...Q(y, 1)], Tt));
|
|
2266
2266
|
} else
|
|
2267
|
-
|
|
2267
|
+
W.push(...Q(y, Tt));
|
|
2268
2268
|
}
|
|
2269
2269
|
return {
|
|
2270
|
-
lines:
|
|
2270
|
+
lines: W,
|
|
2271
2271
|
hasUsefulContent: yt,
|
|
2272
|
-
textPreview:
|
|
2272
|
+
textPreview: se,
|
|
2273
2273
|
containsTextElement: n.has(b) || J.some((y) => y.containsTextElement)
|
|
2274
2274
|
};
|
|
2275
2275
|
};
|
|
2276
2276
|
return [`--- ${D} ---`, ...C(T, 0).lines].join(`
|
|
2277
2277
|
`);
|
|
2278
|
-
},
|
|
2279
|
-
|
|
2280
|
-
${JSON.stringify(
|
|
2278
|
+
}, g = [], A = q(window.getSelection()?.toString() ?? "");
|
|
2279
|
+
A && g.push(`--- selected text ---
|
|
2280
|
+
${JSON.stringify(A)}`), f.length > 0 && g.push(Mn(f, s, c, o));
|
|
2281
2281
|
for (const T of e.slice(0, 3))
|
|
2282
|
-
|
|
2283
|
-
if (t &&
|
|
2282
|
+
g.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2283
|
+
if (t && g.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
2284
2284
|
const T = t || e.length ? "other visible DOM" : "visible DOM";
|
|
2285
|
-
|
|
2285
|
+
g.push(p(document.body, T, I));
|
|
2286
2286
|
}
|
|
2287
|
-
return
|
|
2287
|
+
return g.join(`
|
|
2288
2288
|
|
|
2289
2289
|
`);
|
|
2290
2290
|
}
|
|
2291
|
-
function
|
|
2291
|
+
function Ne(e, t, s, n) {
|
|
2292
2292
|
const r = e.tagName.toLowerCase();
|
|
2293
2293
|
let i = r;
|
|
2294
2294
|
const o = e.getAttribute("id");
|
|
2295
|
-
o &&
|
|
2295
|
+
o && kn(o) && (i += `#${o}`);
|
|
2296
2296
|
for (const a of t) {
|
|
2297
2297
|
const c = e.getAttribute(a);
|
|
2298
2298
|
c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
|
|
@@ -2305,7 +2305,7 @@ function De(e, t, s, n) {
|
|
|
2305
2305
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2306
2306
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2307
2307
|
}
|
|
2308
|
-
function
|
|
2308
|
+
function bn() {
|
|
2309
2309
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
|
|
2310
2310
|
if (!a)
|
|
2311
2311
|
return;
|
|
@@ -2326,7 +2326,7 @@ function En() {
|
|
|
2326
2326
|
n = n.shadowRoot.activeElement;
|
|
2327
2327
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2328
2328
|
const r = window.getSelection();
|
|
2329
|
-
r && !r.isCollapsed && (s(
|
|
2329
|
+
r && !r.isCollapsed && (s(ge(r.anchorNode), "selected text"), s(ge(r.focusNode), "selected text"));
|
|
2330
2330
|
const i = [
|
|
2331
2331
|
["[aria-selected='true']", "selected"],
|
|
2332
2332
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2348,7 +2348,7 @@ function En() {
|
|
|
2348
2348
|
priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
|
|
2349
2349
|
};
|
|
2350
2350
|
}
|
|
2351
|
-
function
|
|
2351
|
+
function Mn(e, t, s, n) {
|
|
2352
2352
|
const r = ["--- active/current elements ---"];
|
|
2353
2353
|
for (const i of e) {
|
|
2354
2354
|
const o = [];
|
|
@@ -2359,7 +2359,7 @@ function Rn(e, t, s, n) {
|
|
|
2359
2359
|
const f = a.getRootNode();
|
|
2360
2360
|
a = a.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
|
|
2361
2361
|
}
|
|
2362
|
-
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) =>
|
|
2362
|
+
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => Ne(
|
|
2363
2363
|
h,
|
|
2364
2364
|
s,
|
|
2365
2365
|
n,
|
|
@@ -2370,7 +2370,7 @@ function Rn(e, t, s, n) {
|
|
|
2370
2370
|
return r.join(`
|
|
2371
2371
|
`);
|
|
2372
2372
|
}
|
|
2373
|
-
function
|
|
2373
|
+
function ge(e) {
|
|
2374
2374
|
return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
|
|
2375
2375
|
}
|
|
2376
2376
|
function Q(e, t) {
|
|
@@ -2380,15 +2380,15 @@ function Q(e, t) {
|
|
|
2380
2380
|
return e.map((n) => `${s}${n}`);
|
|
2381
2381
|
}
|
|
2382
2382
|
function ve(e) {
|
|
2383
|
-
return
|
|
2383
|
+
return q(
|
|
2384
2384
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2385
2385
|
);
|
|
2386
2386
|
}
|
|
2387
|
-
function
|
|
2387
|
+
function kn(e) {
|
|
2388
2388
|
return e.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(e) && !/[a-f0-9]{12,}/i.test(e) && !/:r[0-9a-z]+:/i.test(e);
|
|
2389
2389
|
}
|
|
2390
2390
|
function Oe() {
|
|
2391
|
-
const e = document.querySelector(
|
|
2391
|
+
const e = document.querySelector(oe);
|
|
2392
2392
|
if (!(e ?? document.querySelector(Dt)))
|
|
2393
2393
|
return;
|
|
2394
2394
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
@@ -2398,28 +2398,28 @@ function Oe() {
|
|
|
2398
2398
|
selectors: [
|
|
2399
2399
|
{
|
|
2400
2400
|
name: "widget_host",
|
|
2401
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2401
|
+
selector: s === "browser_extension_sdk_preview" ? oe : Dt,
|
|
2402
2402
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2403
2403
|
},
|
|
2404
2404
|
{
|
|
2405
2405
|
name: "widget_root",
|
|
2406
|
-
selector:
|
|
2406
|
+
selector: As,
|
|
2407
2407
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2408
2408
|
},
|
|
2409
2409
|
{
|
|
2410
2410
|
name: "widget_panel",
|
|
2411
|
-
selector:
|
|
2411
|
+
selector: Es,
|
|
2412
2412
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2413
2413
|
},
|
|
2414
2414
|
{
|
|
2415
2415
|
name: "widget_timeline",
|
|
2416
|
-
selector:
|
|
2416
|
+
selector: Rs,
|
|
2417
2417
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2418
2418
|
}
|
|
2419
2419
|
]
|
|
2420
2420
|
};
|
|
2421
2421
|
}
|
|
2422
|
-
function
|
|
2422
|
+
function _n(e) {
|
|
2423
2423
|
try {
|
|
2424
2424
|
const t = JSON.parse(e);
|
|
2425
2425
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2427,16 +2427,16 @@ function Mn(e) {
|
|
|
2427
2427
|
return { type: "error", message: "Invalid server event" };
|
|
2428
2428
|
}
|
|
2429
2429
|
}
|
|
2430
|
-
function
|
|
2430
|
+
function me(e, t) {
|
|
2431
2431
|
if (!e || typeof e != "object")
|
|
2432
2432
|
return [];
|
|
2433
2433
|
const s = e[t];
|
|
2434
2434
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2435
2435
|
}
|
|
2436
|
-
function
|
|
2436
|
+
function Cn(e) {
|
|
2437
2437
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2438
2438
|
}
|
|
2439
|
-
function
|
|
2439
|
+
function Pn(e) {
|
|
2440
2440
|
if (!e || typeof e != "object")
|
|
2441
2441
|
return null;
|
|
2442
2442
|
const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -2447,13 +2447,13 @@ function _n(e) {
|
|
|
2447
2447
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2448
2448
|
};
|
|
2449
2449
|
}
|
|
2450
|
-
function
|
|
2450
|
+
function Un(e) {
|
|
2451
2451
|
if (!e || typeof e != "object")
|
|
2452
2452
|
return null;
|
|
2453
2453
|
const t = e.javascript;
|
|
2454
2454
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2455
2455
|
}
|
|
2456
|
-
function
|
|
2456
|
+
function Dn(e, t) {
|
|
2457
2457
|
return t ? e && typeof e == "object" ? {
|
|
2458
2458
|
...e,
|
|
2459
2459
|
helperError: t
|
|
@@ -2463,23 +2463,23 @@ function Un(e, t) {
|
|
|
2463
2463
|
helperError: t
|
|
2464
2464
|
} : e;
|
|
2465
2465
|
}
|
|
2466
|
-
function
|
|
2466
|
+
function Nn(e) {
|
|
2467
2467
|
if (!e || typeof e != "object")
|
|
2468
2468
|
return e;
|
|
2469
2469
|
const t = e;
|
|
2470
2470
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2471
2471
|
}
|
|
2472
|
-
function
|
|
2472
|
+
function vn() {
|
|
2473
2473
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2474
2474
|
if (t)
|
|
2475
2475
|
return t;
|
|
2476
2476
|
const s = crypto.randomUUID();
|
|
2477
2477
|
return window.localStorage.setItem(e, s), s;
|
|
2478
2478
|
}
|
|
2479
|
-
function
|
|
2479
|
+
function j() {
|
|
2480
2480
|
return crypto.randomUUID();
|
|
2481
2481
|
}
|
|
2482
|
-
function
|
|
2482
|
+
function On(e) {
|
|
2483
2483
|
if (!e || typeof e != "object")
|
|
2484
2484
|
return null;
|
|
2485
2485
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -2490,12 +2490,12 @@ function vn(e) {
|
|
|
2490
2490
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2491
2491
|
} : null;
|
|
2492
2492
|
}
|
|
2493
|
-
function
|
|
2494
|
-
return Array.isArray(e) ?
|
|
2495
|
-
e.map((s) =>
|
|
2493
|
+
function xn(e, t) {
|
|
2494
|
+
return Array.isArray(e) ? qt(
|
|
2495
|
+
e.map((s) => xe(s, t)).filter((s) => s !== null)
|
|
2496
2496
|
) : [];
|
|
2497
2497
|
}
|
|
2498
|
-
function
|
|
2498
|
+
function Ln(e) {
|
|
2499
2499
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2500
2500
|
if (!t || typeof t != "object")
|
|
2501
2501
|
return [];
|
|
@@ -2516,7 +2516,7 @@ function Nn(e) {
|
|
|
2516
2516
|
];
|
|
2517
2517
|
}) : [];
|
|
2518
2518
|
}
|
|
2519
|
-
function
|
|
2519
|
+
function xe(e, t) {
|
|
2520
2520
|
if (!e || typeof e != "object")
|
|
2521
2521
|
return null;
|
|
2522
2522
|
const s = e, n = s.data;
|
|
@@ -2530,14 +2530,14 @@ function Ne(e, t) {
|
|
|
2530
2530
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2531
2531
|
role: i,
|
|
2532
2532
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2533
|
-
content:
|
|
2534
|
-
|
|
2533
|
+
content: cs(
|
|
2534
|
+
Fn(r.content),
|
|
2535
2535
|
t
|
|
2536
2536
|
),
|
|
2537
2537
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2538
|
-
respondsToUserMessageId:
|
|
2538
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2539
2539
|
...k(r) ? { runId: k(r) } : {},
|
|
2540
|
-
attachments:
|
|
2540
|
+
attachments: $e(r.attachments, t)
|
|
2541
2541
|
};
|
|
2542
2542
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2543
2543
|
value: r.id,
|
|
@@ -2548,27 +2548,27 @@ function Ne(e, t) {
|
|
|
2548
2548
|
}), o;
|
|
2549
2549
|
}
|
|
2550
2550
|
if (r.type === "function_call_output") {
|
|
2551
|
-
const i =
|
|
2551
|
+
const i = ws(r.output);
|
|
2552
2552
|
if (i)
|
|
2553
2553
|
return {
|
|
2554
2554
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2555
2555
|
role: "tool",
|
|
2556
2556
|
content: "",
|
|
2557
2557
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2558
|
-
respondsToUserMessageId:
|
|
2558
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2559
2559
|
...k(r) ? { runId: k(r) } : {},
|
|
2560
2560
|
dataType: "scheduled_check_in",
|
|
2561
2561
|
toolName: ke,
|
|
2562
2562
|
callId: Ct(r) ?? void 0,
|
|
2563
2563
|
scheduledCheckInAt: i
|
|
2564
2564
|
};
|
|
2565
|
-
const o =
|
|
2565
|
+
const o = qn(r.output);
|
|
2566
2566
|
return o ? {
|
|
2567
2567
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2568
2568
|
role: "tool",
|
|
2569
2569
|
content: `Connect ${o.appName} to continue`,
|
|
2570
2570
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2571
|
-
respondsToUserMessageId:
|
|
2571
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2572
2572
|
...k(r) ? { runId: k(r) } : {},
|
|
2573
2573
|
dataType: "function_call_output",
|
|
2574
2574
|
toolName: "authenticate_pipedream_app",
|
|
@@ -2579,9 +2579,9 @@ function Ne(e, t) {
|
|
|
2579
2579
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2580
2580
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2581
2581
|
role: "tool",
|
|
2582
|
-
content: r.type === "mcp_call" ?
|
|
2582
|
+
content: r.type === "mcp_call" ? Bn(r) : Wn(r),
|
|
2583
2583
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2584
|
-
respondsToUserMessageId:
|
|
2584
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2585
2585
|
...k(r) ? { runId: k(r) } : {},
|
|
2586
2586
|
dataType: String(r.type),
|
|
2587
2587
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
@@ -2590,9 +2590,9 @@ function Ne(e, t) {
|
|
|
2590
2590
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2591
2591
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2592
2592
|
role: "system",
|
|
2593
|
-
content:
|
|
2593
|
+
content: Hn(r),
|
|
2594
2594
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2595
|
-
respondsToUserMessageId:
|
|
2595
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2596
2596
|
...k(r) ? { runId: k(r) } : {},
|
|
2597
2597
|
dataType: String(r.type),
|
|
2598
2598
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -2601,11 +2601,11 @@ function Ne(e, t) {
|
|
|
2601
2601
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2602
2602
|
} : null;
|
|
2603
2603
|
}
|
|
2604
|
-
function
|
|
2604
|
+
function Bn(e) {
|
|
2605
2605
|
const s = (typeof e.server_label == "string" ? e.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
2606
2606
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2607
2607
|
}
|
|
2608
|
-
function
|
|
2608
|
+
function qn(e) {
|
|
2609
2609
|
if (typeof e != "string")
|
|
2610
2610
|
return null;
|
|
2611
2611
|
try {
|
|
@@ -2622,10 +2622,10 @@ function Ln(e) {
|
|
|
2622
2622
|
return null;
|
|
2623
2623
|
}
|
|
2624
2624
|
}
|
|
2625
|
-
function
|
|
2625
|
+
function Hn(e) {
|
|
2626
2626
|
return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : e.type === "run_status" && e.status === "steered" ? "Steered" : typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
|
|
2627
2627
|
}
|
|
2628
|
-
function
|
|
2628
|
+
function Wn(e) {
|
|
2629
2629
|
if (e.type === "web_search_call") {
|
|
2630
2630
|
const t = e.action;
|
|
2631
2631
|
if (t && typeof t == "object") {
|
|
@@ -2637,9 +2637,9 @@ function Bn(e) {
|
|
|
2637
2637
|
}
|
|
2638
2638
|
return "🔎 Searching the web";
|
|
2639
2639
|
}
|
|
2640
|
-
return
|
|
2640
|
+
return $n(e);
|
|
2641
2641
|
}
|
|
2642
|
-
function
|
|
2642
|
+
function $n(e) {
|
|
2643
2643
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2644
2644
|
return L(e.summary);
|
|
2645
2645
|
if (typeof e.arguments == "string")
|
|
@@ -2656,7 +2656,7 @@ function L(e) {
|
|
|
2656
2656
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2657
2657
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2658
2658
|
}
|
|
2659
|
-
function
|
|
2659
|
+
function jn(e) {
|
|
2660
2660
|
if (e == null)
|
|
2661
2661
|
return e;
|
|
2662
2662
|
if (typeof e != "object")
|
|
@@ -2675,7 +2675,7 @@ function Ct(e) {
|
|
|
2675
2675
|
const t = e.callId ?? e.call_id;
|
|
2676
2676
|
return typeof t == "string" && t ? t : null;
|
|
2677
2677
|
}
|
|
2678
|
-
function
|
|
2678
|
+
function Fn(e) {
|
|
2679
2679
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2680
2680
|
if (!t || typeof t != "object")
|
|
2681
2681
|
return "";
|
|
@@ -2683,31 +2683,31 @@ function Wn(e) {
|
|
|
2683
2683
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2684
2684
|
}).filter(Boolean).join("") : "";
|
|
2685
2685
|
}
|
|
2686
|
-
function
|
|
2687
|
-
const s =
|
|
2688
|
-
|
|
2689
|
-
|
|
2686
|
+
function vt(e, t) {
|
|
2687
|
+
const s = Be(e, t), n = Yn(
|
|
2688
|
+
zn(
|
|
2689
|
+
er(e, t),
|
|
2690
2690
|
s
|
|
2691
2691
|
),
|
|
2692
2692
|
s
|
|
2693
2693
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2694
2694
|
if (r === -1)
|
|
2695
|
-
return
|
|
2695
|
+
return qt(
|
|
2696
2696
|
[...n, s]
|
|
2697
2697
|
);
|
|
2698
2698
|
const i = [...n];
|
|
2699
|
-
return i[r] = s,
|
|
2699
|
+
return i[r] = s, qt(i);
|
|
2700
2700
|
}
|
|
2701
|
-
function
|
|
2701
|
+
function zn(e, t) {
|
|
2702
2702
|
const s = t.assistantDraftItemId;
|
|
2703
2703
|
return s ? e.map(
|
|
2704
2704
|
(n) => n.dataType === "assistant_draft" && n.id === s ? t : n
|
|
2705
2705
|
) : e;
|
|
2706
2706
|
}
|
|
2707
|
-
function
|
|
2707
|
+
function Kn(e, t, s) {
|
|
2708
2708
|
return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
|
|
2709
2709
|
}
|
|
2710
|
-
function
|
|
2710
|
+
function Gn(e, t, s, n) {
|
|
2711
2711
|
if (s === null) return e;
|
|
2712
2712
|
let r = -1;
|
|
2713
2713
|
for (let o = e.length - 1; o >= 0; o -= 1) {
|
|
@@ -2724,12 +2724,12 @@ function zn(e, t, s, n) {
|
|
|
2724
2724
|
respondsToUserMessageId: s
|
|
2725
2725
|
}, i;
|
|
2726
2726
|
}
|
|
2727
|
-
function
|
|
2727
|
+
function Xn(e, t) {
|
|
2728
2728
|
const s = e.findIndex(
|
|
2729
2729
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2730
2730
|
);
|
|
2731
2731
|
if (s === -1)
|
|
2732
|
-
return
|
|
2732
|
+
return vt(e, t);
|
|
2733
2733
|
const n = [...e];
|
|
2734
2734
|
return n[s] = {
|
|
2735
2735
|
...n[s],
|
|
@@ -2741,12 +2741,12 @@ function Kn(e, t) {
|
|
|
2741
2741
|
...n[s].runId ? {} : { runId: t.runId }
|
|
2742
2742
|
}, n;
|
|
2743
2743
|
}
|
|
2744
|
-
function
|
|
2744
|
+
function Jn(e, t, s) {
|
|
2745
2745
|
let n = !1;
|
|
2746
2746
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2747
2747
|
return n ? r : e;
|
|
2748
2748
|
}
|
|
2749
|
-
function
|
|
2749
|
+
function Vn(e) {
|
|
2750
2750
|
if (e.hiddenFromTranscript === !0)
|
|
2751
2751
|
return null;
|
|
2752
2752
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
@@ -2765,7 +2765,7 @@ function Xn(e) {
|
|
|
2765
2765
|
loading: !0
|
|
2766
2766
|
};
|
|
2767
2767
|
}
|
|
2768
|
-
function
|
|
2768
|
+
function Yn(e, t) {
|
|
2769
2769
|
if (t.id.startsWith("transient-activity:"))
|
|
2770
2770
|
return e;
|
|
2771
2771
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2773,17 +2773,17 @@ function Jn(e, t) {
|
|
|
2773
2773
|
(n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId && n.runId === t.runId)
|
|
2774
2774
|
);
|
|
2775
2775
|
}
|
|
2776
|
-
function
|
|
2777
|
-
return
|
|
2776
|
+
function Zn(e, t) {
|
|
2777
|
+
return ls(
|
|
2778
2778
|
e,
|
|
2779
2779
|
t.map(
|
|
2780
|
-
(s) =>
|
|
2780
|
+
(s) => Be(e, s)
|
|
2781
2781
|
),
|
|
2782
|
-
|
|
2782
|
+
Le
|
|
2783
2783
|
);
|
|
2784
2784
|
}
|
|
2785
|
-
function
|
|
2786
|
-
const t =
|
|
2785
|
+
function Le(e) {
|
|
2786
|
+
const t = Ot(e) ?? void 0, s = e.assistantDraftItemId, n = [
|
|
2787
2787
|
...e.callId ? [`call:${e.callId}`] : [],
|
|
2788
2788
|
...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
|
|
2789
2789
|
];
|
|
@@ -2794,38 +2794,38 @@ function xe(e) {
|
|
|
2794
2794
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
2795
2795
|
...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
|
|
2796
2796
|
...e.runId ? { runId: e.runId } : {},
|
|
2797
|
-
isOptimistic:
|
|
2797
|
+
isOptimistic: Gt(e),
|
|
2798
2798
|
isAssistantDraft: e.dataType === "assistant_draft",
|
|
2799
2799
|
isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
|
|
2800
2800
|
isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
|
|
2801
2801
|
};
|
|
2802
2802
|
}
|
|
2803
|
-
function
|
|
2803
|
+
function Be(e, t) {
|
|
2804
2804
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2805
2805
|
return t;
|
|
2806
2806
|
const s = e.find(
|
|
2807
|
-
(r) => r.role === "user" && (r.id === t.id ||
|
|
2807
|
+
(r) => r.role === "user" && (r.id === t.id || Gt(r) && qe(r, t))
|
|
2808
2808
|
);
|
|
2809
2809
|
if (!s?.attachments?.length)
|
|
2810
2810
|
return t;
|
|
2811
2811
|
const n = t.attachments.map((r) => {
|
|
2812
|
-
const i =
|
|
2813
|
-
return i ?
|
|
2812
|
+
const i = Qn(s.attachments ?? [], r);
|
|
2813
|
+
return i ? tr(r, i) : r;
|
|
2814
2814
|
});
|
|
2815
2815
|
return { ...t, attachments: n };
|
|
2816
2816
|
}
|
|
2817
|
-
function
|
|
2817
|
+
function Qn(e, t) {
|
|
2818
2818
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2819
2819
|
}
|
|
2820
|
-
function
|
|
2820
|
+
function tr(e, t) {
|
|
2821
2821
|
const { previewUrl: s } = t;
|
|
2822
2822
|
return s ? { ...e, previewUrl: s } : e;
|
|
2823
2823
|
}
|
|
2824
|
-
function
|
|
2824
|
+
function er(e, t) {
|
|
2825
2825
|
if (t.role !== "user")
|
|
2826
2826
|
return e;
|
|
2827
2827
|
const s = e.findIndex(
|
|
2828
|
-
(r) =>
|
|
2828
|
+
(r) => Gt(r) && qe(r, t)
|
|
2829
2829
|
);
|
|
2830
2830
|
if (s === -1)
|
|
2831
2831
|
return e;
|
|
@@ -2833,13 +2833,13 @@ function Qn(e, t) {
|
|
|
2833
2833
|
return n.splice(s, 1), n;
|
|
2834
2834
|
}
|
|
2835
2835
|
function qe(e, t) {
|
|
2836
|
-
const s =
|
|
2836
|
+
const s = Ot(e), n = Ot(t);
|
|
2837
2837
|
return s && n ? s === n : e.content === t.content;
|
|
2838
2838
|
}
|
|
2839
|
-
function
|
|
2839
|
+
function Gt(e) {
|
|
2840
2840
|
return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
|
|
2841
2841
|
}
|
|
2842
|
-
function
|
|
2842
|
+
function Ot(e) {
|
|
2843
2843
|
const t = e.clientMessageId;
|
|
2844
2844
|
if (t)
|
|
2845
2845
|
return t;
|
|
@@ -2848,8 +2848,8 @@ function Nt(e) {
|
|
|
2848
2848
|
);
|
|
2849
2849
|
return n ? e.id.slice(n.length) : null;
|
|
2850
2850
|
}
|
|
2851
|
-
function
|
|
2852
|
-
const t =
|
|
2851
|
+
function ye(e) {
|
|
2852
|
+
const t = He(e);
|
|
2853
2853
|
if (t === null)
|
|
2854
2854
|
return !1;
|
|
2855
2855
|
const s = e[t].id, n = e.some(
|
|
@@ -2859,7 +2859,7 @@ function me(e) {
|
|
|
2859
2859
|
return n;
|
|
2860
2860
|
for (let r = e.length - 1; r > t; r -= 1) {
|
|
2861
2861
|
const i = e[r];
|
|
2862
|
-
if (
|
|
2862
|
+
if (O(i))
|
|
2863
2863
|
return !0;
|
|
2864
2864
|
if (i.role === "system") {
|
|
2865
2865
|
if (i.dataType === "run_error")
|
|
@@ -2870,23 +2870,23 @@ function me(e) {
|
|
|
2870
2870
|
}
|
|
2871
2871
|
return !1;
|
|
2872
2872
|
}
|
|
2873
|
-
function
|
|
2874
|
-
const t =
|
|
2873
|
+
function sr(e) {
|
|
2874
|
+
const t = He(e);
|
|
2875
2875
|
if (t === null)
|
|
2876
|
-
return e.some(
|
|
2876
|
+
return e.some(O);
|
|
2877
2877
|
const s = e[t].id;
|
|
2878
2878
|
return e.some((n) => n.respondsToUserMessageId === s) ? e.some(
|
|
2879
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
2880
|
-
) : e.slice(t + 1).some(
|
|
2879
|
+
(n) => n.respondsToUserMessageId === s && O(n)
|
|
2880
|
+
) : e.slice(t + 1).some(O);
|
|
2881
2881
|
}
|
|
2882
|
-
function
|
|
2882
|
+
function He(e) {
|
|
2883
2883
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2884
2884
|
if (e[t].role === "user")
|
|
2885
2885
|
return t;
|
|
2886
2886
|
return null;
|
|
2887
2887
|
}
|
|
2888
2888
|
function xt(e) {
|
|
2889
|
-
return
|
|
2889
|
+
return O(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2890
2890
|
}
|
|
2891
2891
|
function at(e) {
|
|
2892
2892
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
@@ -2902,17 +2902,17 @@ function at(e) {
|
|
|
2902
2902
|
}
|
|
2903
2903
|
return null;
|
|
2904
2904
|
}
|
|
2905
|
-
function
|
|
2905
|
+
function nr(e) {
|
|
2906
2906
|
const t = at(e);
|
|
2907
2907
|
if (t === null)
|
|
2908
2908
|
return null;
|
|
2909
|
-
const n =
|
|
2909
|
+
const n = B(e[t])?.page;
|
|
2910
2910
|
if (!n || typeof n != "object")
|
|
2911
2911
|
return null;
|
|
2912
2912
|
const r = n.url;
|
|
2913
2913
|
return typeof r == "string" ? r : null;
|
|
2914
2914
|
}
|
|
2915
|
-
function
|
|
2915
|
+
function B(e) {
|
|
2916
2916
|
if (!e || typeof e != "object")
|
|
2917
2917
|
return null;
|
|
2918
2918
|
const t = e.data;
|
|
@@ -2921,10 +2921,10 @@ function q(e) {
|
|
|
2921
2921
|
function Lt(e) {
|
|
2922
2922
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2923
2923
|
}
|
|
2924
|
-
function
|
|
2924
|
+
function Ie(e) {
|
|
2925
2925
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2926
2926
|
}
|
|
2927
|
-
function
|
|
2927
|
+
function rr(e, t) {
|
|
2928
2928
|
const s = at(t);
|
|
2929
2929
|
if (s === null)
|
|
2930
2930
|
return !1;
|
|
@@ -2936,7 +2936,7 @@ function sr(e, t) {
|
|
|
2936
2936
|
(o) => o.respondsToUserMessageId === r && xt(o)
|
|
2937
2937
|
) : e.slice(i + 1).some(xt);
|
|
2938
2938
|
}
|
|
2939
|
-
function
|
|
2939
|
+
function Bt(e) {
|
|
2940
2940
|
const t = at(e);
|
|
2941
2941
|
if (t === null)
|
|
2942
2942
|
return null;
|
|
@@ -2949,7 +2949,7 @@ function qt(e) {
|
|
|
2949
2949
|
const r = n.clientMessageId;
|
|
2950
2950
|
return typeof r == "string" ? r : null;
|
|
2951
2951
|
}
|
|
2952
|
-
function
|
|
2952
|
+
function ir(e) {
|
|
2953
2953
|
const t = at(e);
|
|
2954
2954
|
if (t === null)
|
|
2955
2955
|
return null;
|
|
@@ -2964,22 +2964,22 @@ function nr(e) {
|
|
|
2964
2964
|
if (i.type === "message" && i.role === "assistant")
|
|
2965
2965
|
return null;
|
|
2966
2966
|
if (i.type === "run_error")
|
|
2967
|
-
return i.retryable !== !0 ? null :
|
|
2967
|
+
return i.retryable !== !0 ? null : Te(e, i) ?? Bt(e);
|
|
2968
2968
|
if (i.type === "run_status")
|
|
2969
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
2969
|
+
return i.status === "interrupted" && i.retryable === !0 ? Te(e, i) ?? Bt(e) : null;
|
|
2970
2970
|
}
|
|
2971
2971
|
return null;
|
|
2972
2972
|
}
|
|
2973
|
-
function
|
|
2973
|
+
function Te(e, t) {
|
|
2974
2974
|
if (typeof t.clientMessageId == "string")
|
|
2975
2975
|
return t.clientMessageId;
|
|
2976
|
-
const s =
|
|
2976
|
+
const s = v(t);
|
|
2977
2977
|
if (!s)
|
|
2978
2978
|
return null;
|
|
2979
|
-
const n = e.find((i) => R(i, "id") === s), r =
|
|
2979
|
+
const n = e.find((i) => R(i, "id") === s), r = B(n);
|
|
2980
2980
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2981
2981
|
}
|
|
2982
|
-
function
|
|
2982
|
+
function or(e, t) {
|
|
2983
2983
|
let s = 0;
|
|
2984
2984
|
for (const n of e) {
|
|
2985
2985
|
if (!n || typeof n != "object")
|
|
@@ -2992,56 +2992,56 @@ function rr(e, t) {
|
|
|
2992
2992
|
}
|
|
2993
2993
|
return s;
|
|
2994
2994
|
}
|
|
2995
|
-
function
|
|
2996
|
-
if (!t || !
|
|
2995
|
+
function we(e, t, s, n, r) {
|
|
2996
|
+
if (!t || !ar(e))
|
|
2997
2997
|
return !1;
|
|
2998
2998
|
const i = e;
|
|
2999
|
-
return !(Lt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ?
|
|
2999
|
+
return !(Lt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? v(i) !== n : r !== null && k(i) !== r));
|
|
3000
3000
|
}
|
|
3001
|
-
function
|
|
3001
|
+
function ar(e) {
|
|
3002
3002
|
if (!e || typeof e != "object")
|
|
3003
3003
|
return !1;
|
|
3004
3004
|
const t = e;
|
|
3005
3005
|
return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted" || t.status === "failed");
|
|
3006
3006
|
}
|
|
3007
|
-
function
|
|
3007
|
+
function O(e) {
|
|
3008
3008
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
3009
3009
|
}
|
|
3010
|
-
function
|
|
3010
|
+
function cr(e) {
|
|
3011
3011
|
if (!e || typeof e != "object")
|
|
3012
3012
|
return !1;
|
|
3013
3013
|
const t = e;
|
|
3014
3014
|
return t.type === "message" && t.role === "user" ? !1 : t.type === "message" || t.type === "function_call" || t.type === "function_call_output" || t.type === "run_error" || t.type === "run_status";
|
|
3015
3015
|
}
|
|
3016
|
-
function
|
|
3017
|
-
return e.filter((t, s) => ct(t) ? !
|
|
3016
|
+
function qt(e) {
|
|
3017
|
+
return e.filter((t, s) => ct(t) ? !mr(e, s) && !fr(e, s) && !gr(e, s) : lr(t) ? t.retryable === !0 && pr(e, s) ? !1 : !hr(e, s) : !0);
|
|
3018
3018
|
}
|
|
3019
|
-
function
|
|
3019
|
+
function lr(e) {
|
|
3020
3020
|
return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
|
|
3021
3021
|
}
|
|
3022
3022
|
function ct(e) {
|
|
3023
3023
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
3024
3024
|
}
|
|
3025
|
-
function
|
|
3025
|
+
function ur(e, t) {
|
|
3026
3026
|
const s = [...e].reverse().find(
|
|
3027
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t &&
|
|
3027
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && Se(n) && !dr(
|
|
3028
3028
|
e,
|
|
3029
3029
|
n.respondsToUserMessageId
|
|
3030
3030
|
)
|
|
3031
3031
|
)?.respondsToUserMessageId;
|
|
3032
3032
|
return s ? e.map(
|
|
3033
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3033
|
+
(n) => n.respondsToUserMessageId === s && Se(n) ? { ...n, steered: !0 } : n
|
|
3034
3034
|
) : e;
|
|
3035
3035
|
}
|
|
3036
|
-
function
|
|
3036
|
+
function Se(e) {
|
|
3037
3037
|
return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
|
|
3038
3038
|
}
|
|
3039
|
-
function
|
|
3039
|
+
function dr(e, t) {
|
|
3040
3040
|
return e.some(
|
|
3041
|
-
(s) => s.respondsToUserMessageId === t && (
|
|
3041
|
+
(s) => s.respondsToUserMessageId === t && (O(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3042
3042
|
);
|
|
3043
3043
|
}
|
|
3044
|
-
function
|
|
3044
|
+
function hr(e, t) {
|
|
3045
3045
|
const s = e[t];
|
|
3046
3046
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
3047
3047
|
const r = e[n];
|
|
@@ -3050,7 +3050,7 @@ function ur(e, t) {
|
|
|
3050
3050
|
}
|
|
3051
3051
|
return !1;
|
|
3052
3052
|
}
|
|
3053
|
-
function
|
|
3053
|
+
function pr(e, t) {
|
|
3054
3054
|
const s = e[t];
|
|
3055
3055
|
if (!s.respondsToUserMessageId)
|
|
3056
3056
|
return !1;
|
|
@@ -3063,19 +3063,19 @@ function dr(e, t) {
|
|
|
3063
3063
|
}
|
|
3064
3064
|
return !1;
|
|
3065
3065
|
}
|
|
3066
|
-
function
|
|
3066
|
+
function fr(e, t) {
|
|
3067
3067
|
const s = e[t];
|
|
3068
3068
|
return e.some(
|
|
3069
3069
|
(n, r) => r !== t && n.role === "assistant" && lt(s, n)
|
|
3070
3070
|
);
|
|
3071
3071
|
}
|
|
3072
|
-
function
|
|
3072
|
+
function gr(e, t) {
|
|
3073
3073
|
const s = e[t];
|
|
3074
3074
|
return e.some(
|
|
3075
3075
|
(n, r) => r !== t && n.role === "tool" && lt(s, n)
|
|
3076
3076
|
);
|
|
3077
3077
|
}
|
|
3078
|
-
function
|
|
3078
|
+
function mr(e, t) {
|
|
3079
3079
|
const s = e[t];
|
|
3080
3080
|
for (let n = t + 1; n < e.length; n += 1)
|
|
3081
3081
|
if (ct(e[n]) && lt(s, e[n]))
|
|
@@ -3088,15 +3088,15 @@ function lt(e, t) {
|
|
|
3088
3088
|
function R(e, t) {
|
|
3089
3089
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
3090
3090
|
}
|
|
3091
|
-
function
|
|
3091
|
+
function yr(e, t) {
|
|
3092
3092
|
try {
|
|
3093
|
-
const s = window.localStorage.getItem(`${
|
|
3093
|
+
const s = window.localStorage.getItem(`${Pe}${e}`);
|
|
3094
3094
|
if (!s)
|
|
3095
3095
|
return null;
|
|
3096
3096
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3097
3097
|
if (t !== void 0 && r !== t)
|
|
3098
3098
|
return null;
|
|
3099
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3099
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Cr).filter((o) => !!o) : [];
|
|
3100
3100
|
return {
|
|
3101
3101
|
sessionId: r,
|
|
3102
3102
|
messages: i
|
|
@@ -3105,46 +3105,46 @@ function gr(e, t) {
|
|
|
3105
3105
|
return null;
|
|
3106
3106
|
}
|
|
3107
3107
|
}
|
|
3108
|
-
function
|
|
3108
|
+
function Ir(e, t) {
|
|
3109
3109
|
try {
|
|
3110
3110
|
window.localStorage.setItem(
|
|
3111
|
-
`${
|
|
3111
|
+
`${Pe}${e}`,
|
|
3112
3112
|
JSON.stringify({
|
|
3113
3113
|
sessionId: t.sessionId,
|
|
3114
|
-
messages: t.messages.slice(-
|
|
3114
|
+
messages: t.messages.slice(-zs).map(Pr)
|
|
3115
3115
|
})
|
|
3116
3116
|
);
|
|
3117
3117
|
} catch {
|
|
3118
3118
|
return;
|
|
3119
3119
|
}
|
|
3120
3120
|
}
|
|
3121
|
-
function
|
|
3121
|
+
function Tr(e) {
|
|
3122
3122
|
try {
|
|
3123
|
-
const t = window.localStorage.getItem(`${
|
|
3123
|
+
const t = window.localStorage.getItem(`${Nt}${e}`);
|
|
3124
3124
|
if (!t)
|
|
3125
3125
|
return [];
|
|
3126
3126
|
const s = JSON.parse(t);
|
|
3127
|
-
return Array.isArray(s) ? s.filter(
|
|
3127
|
+
return Array.isArray(s) ? s.filter(Xt) : [];
|
|
3128
3128
|
} catch {
|
|
3129
3129
|
return [];
|
|
3130
3130
|
}
|
|
3131
3131
|
}
|
|
3132
|
-
function
|
|
3132
|
+
function F(e, t) {
|
|
3133
3133
|
try {
|
|
3134
|
-
const s = t.filter(
|
|
3134
|
+
const s = t.filter(Xt);
|
|
3135
3135
|
if (s.length === 0) {
|
|
3136
|
-
window.localStorage.removeItem(`${
|
|
3136
|
+
window.localStorage.removeItem(`${Nt}${e}`);
|
|
3137
3137
|
return;
|
|
3138
3138
|
}
|
|
3139
3139
|
window.localStorage.setItem(
|
|
3140
|
-
`${
|
|
3140
|
+
`${Nt}${e}`,
|
|
3141
3141
|
JSON.stringify(s.slice(-25))
|
|
3142
3142
|
);
|
|
3143
3143
|
} catch {
|
|
3144
3144
|
return;
|
|
3145
3145
|
}
|
|
3146
3146
|
}
|
|
3147
|
-
function
|
|
3147
|
+
function We(e, t) {
|
|
3148
3148
|
try {
|
|
3149
3149
|
const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
3150
3150
|
...o,
|
|
@@ -3160,28 +3160,28 @@ function Fe(e, t) {
|
|
|
3160
3160
|
} catch {
|
|
3161
3161
|
}
|
|
3162
3162
|
}
|
|
3163
|
-
function
|
|
3163
|
+
function wr(e, t) {
|
|
3164
3164
|
try {
|
|
3165
3165
|
if (window.sessionStorage.getItem(`${ot}${e}`) === null)
|
|
3166
3166
|
return;
|
|
3167
3167
|
} catch {
|
|
3168
3168
|
return;
|
|
3169
3169
|
}
|
|
3170
|
-
|
|
3170
|
+
We(e, t);
|
|
3171
3171
|
}
|
|
3172
|
-
function
|
|
3172
|
+
function Sr(e) {
|
|
3173
3173
|
try {
|
|
3174
3174
|
const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
|
|
3175
3175
|
if (window.sessionStorage.removeItem(t), !s)
|
|
3176
3176
|
return [];
|
|
3177
3177
|
const n = JSON.parse(s);
|
|
3178
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3178
|
+
return Array.isArray(n) ? n.flatMap((r) => Er(r) ? [{
|
|
3179
3179
|
...r.event,
|
|
3180
3180
|
page: M(),
|
|
3181
3181
|
rawOutput: {
|
|
3182
3182
|
pageContextRestarted: !0,
|
|
3183
3183
|
outcome: "unknown",
|
|
3184
|
-
message:
|
|
3184
|
+
message: Ar(location.href),
|
|
3185
3185
|
currentUrl: location.href,
|
|
3186
3186
|
console: [],
|
|
3187
3187
|
metadata: {
|
|
@@ -3198,17 +3198,17 @@ function Tr(e) {
|
|
|
3198
3198
|
return [];
|
|
3199
3199
|
}
|
|
3200
3200
|
}
|
|
3201
|
-
function
|
|
3201
|
+
function Ar(e) {
|
|
3202
3202
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3203
3203
|
Current URL: ${e}`;
|
|
3204
3204
|
}
|
|
3205
|
-
function
|
|
3205
|
+
function Er(e) {
|
|
3206
3206
|
if (!e || typeof e != "object")
|
|
3207
3207
|
return !1;
|
|
3208
3208
|
const t = e, s = t.event;
|
|
3209
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
3209
|
+
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Xt(s) && s.type === "tool.result";
|
|
3210
3210
|
}
|
|
3211
|
-
function
|
|
3211
|
+
function Rr(e, t) {
|
|
3212
3212
|
const s = new Set(
|
|
3213
3213
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3214
3214
|
);
|
|
@@ -3217,26 +3217,26 @@ function Ar(e, t) {
|
|
|
3217
3217
|
...t.filter((n) => !s.has(n.callId))
|
|
3218
3218
|
];
|
|
3219
3219
|
}
|
|
3220
|
-
function
|
|
3220
|
+
function br(e) {
|
|
3221
3221
|
try {
|
|
3222
3222
|
window.sessionStorage.removeItem(`${ot}${e}`);
|
|
3223
3223
|
} catch {
|
|
3224
3224
|
return;
|
|
3225
3225
|
}
|
|
3226
3226
|
}
|
|
3227
|
-
function
|
|
3227
|
+
function Xt(e) {
|
|
3228
3228
|
if (!e || typeof e != "object")
|
|
3229
3229
|
return !1;
|
|
3230
3230
|
const t = e;
|
|
3231
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
3231
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && Ae(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Ae(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
|
|
3232
3232
|
}
|
|
3233
|
-
function
|
|
3233
|
+
function Ae(e) {
|
|
3234
3234
|
if (!e || typeof e != "object")
|
|
3235
3235
|
return !1;
|
|
3236
3236
|
const t = e;
|
|
3237
3237
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
3238
3238
|
}
|
|
3239
|
-
function
|
|
3239
|
+
function $e(e, t) {
|
|
3240
3240
|
if (!Array.isArray(e))
|
|
3241
3241
|
return;
|
|
3242
3242
|
const s = e.filter((r) => {
|
|
@@ -3244,23 +3244,41 @@ function He(e, t) {
|
|
|
3244
3244
|
return !1;
|
|
3245
3245
|
const i = r;
|
|
3246
3246
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3247
|
-
}), n = t ? s.map((r) =>
|
|
3247
|
+
}), n = t ? s.map((r) => je(r, t)) : s;
|
|
3248
3248
|
return n.length > 0 ? n : void 0;
|
|
3249
3249
|
}
|
|
3250
|
-
function
|
|
3250
|
+
function je(e, t) {
|
|
3251
3251
|
return e.fileUrl?.startsWith("/") ? {
|
|
3252
3252
|
...e,
|
|
3253
3253
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
3254
3254
|
} : e;
|
|
3255
3255
|
}
|
|
3256
|
-
function
|
|
3257
|
-
return e.type ||
|
|
3256
|
+
function Ht(e) {
|
|
3257
|
+
return e.type || _r(e.name) || "application/octet-stream";
|
|
3258
3258
|
}
|
|
3259
|
-
function
|
|
3259
|
+
function Mr(e) {
|
|
3260
|
+
Fe({
|
|
3261
|
+
name: e.name,
|
|
3262
|
+
mimeType: Ht(e),
|
|
3263
|
+
sizeBytes: e.size
|
|
3264
|
+
});
|
|
3265
|
+
}
|
|
3266
|
+
function Fe(e) {
|
|
3267
|
+
const t = kr(e.name), s = e.mimeType.trim().toLowerCase();
|
|
3268
|
+
if (!$s.has(`${t}:${s}`))
|
|
3269
|
+
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
3270
|
+
if (e.sizeBytes <= 0 || e.sizeBytes >= _e)
|
|
3271
|
+
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
3272
|
+
}
|
|
3273
|
+
function kr(e) {
|
|
3274
|
+
const t = e.trim().toLowerCase(), s = t.lastIndexOf(".");
|
|
3275
|
+
return s >= 0 ? t.slice(s) : "";
|
|
3276
|
+
}
|
|
3277
|
+
function _r(e) {
|
|
3260
3278
|
const t = e.toLowerCase();
|
|
3261
3279
|
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;
|
|
3262
3280
|
}
|
|
3263
|
-
function
|
|
3281
|
+
function Cr(e) {
|
|
3264
3282
|
if (!e || typeof e != "object")
|
|
3265
3283
|
return null;
|
|
3266
3284
|
const t = e;
|
|
@@ -3274,17 +3292,17 @@ function br(e) {
|
|
|
3274
3292
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
3275
3293
|
scheduledCheckInAt: typeof t.scheduledCheckInAt == "string" ? t.scheduledCheckInAt : void 0,
|
|
3276
3294
|
securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
|
|
3277
|
-
attachments:
|
|
3295
|
+
attachments: $e(t.attachments)?.map(Jt),
|
|
3278
3296
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
3279
3297
|
};
|
|
3280
3298
|
}
|
|
3281
|
-
function
|
|
3299
|
+
function Pr(e) {
|
|
3282
3300
|
return e.attachments?.length ? {
|
|
3283
3301
|
...e,
|
|
3284
|
-
attachments: e.attachments.map(
|
|
3302
|
+
attachments: e.attachments.map(Jt)
|
|
3285
3303
|
} : e;
|
|
3286
3304
|
}
|
|
3287
|
-
function
|
|
3305
|
+
function Jt(e) {
|
|
3288
3306
|
const {
|
|
3289
3307
|
dataUrl: t,
|
|
3290
3308
|
objectUrl: s,
|
|
@@ -3293,7 +3311,7 @@ function Xt(e) {
|
|
|
3293
3311
|
} = e;
|
|
3294
3312
|
return r;
|
|
3295
3313
|
}
|
|
3296
|
-
function
|
|
3314
|
+
function v(e) {
|
|
3297
3315
|
const t = e.respondsToUserMessageId;
|
|
3298
3316
|
return typeof t == "string" && t ? t : null;
|
|
3299
3317
|
}
|
|
@@ -3301,39 +3319,39 @@ function k(e) {
|
|
|
3301
3319
|
const t = e.runId;
|
|
3302
3320
|
return typeof t == "string" && t ? t : null;
|
|
3303
3321
|
}
|
|
3304
|
-
function
|
|
3322
|
+
function Ur(e) {
|
|
3305
3323
|
const t = e?.timeoutMs;
|
|
3306
|
-
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 <=
|
|
3324
|
+
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= tn);
|
|
3307
3325
|
}
|
|
3308
|
-
function
|
|
3326
|
+
function ze(e) {
|
|
3309
3327
|
const t = {};
|
|
3310
3328
|
try {
|
|
3311
3329
|
new Headers(e).forEach((s, n) => {
|
|
3312
|
-
Object.keys(t).length <
|
|
3330
|
+
Object.keys(t).length < zt && (t[n] = Vt(n, s));
|
|
3313
3331
|
});
|
|
3314
3332
|
} catch {
|
|
3315
3333
|
return {};
|
|
3316
3334
|
}
|
|
3317
3335
|
return t;
|
|
3318
3336
|
}
|
|
3319
|
-
function
|
|
3320
|
-
return
|
|
3337
|
+
function Vt(e, t) {
|
|
3338
|
+
return Ye(e) ? ut : P(it(t), js);
|
|
3321
3339
|
}
|
|
3322
|
-
function
|
|
3340
|
+
function Dr(e, t) {
|
|
3323
3341
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
3324
3342
|
}
|
|
3325
|
-
async function
|
|
3326
|
-
const r =
|
|
3343
|
+
async function Nr(e, t, s, n) {
|
|
3344
|
+
const r = ze(e.headers);
|
|
3327
3345
|
n({
|
|
3328
3346
|
...t,
|
|
3329
3347
|
responseStatus: e.status,
|
|
3330
3348
|
responseHeaders: r,
|
|
3331
|
-
responseBody: await
|
|
3349
|
+
responseBody: await vr(e),
|
|
3332
3350
|
durationMs: Date.now() - s
|
|
3333
3351
|
});
|
|
3334
3352
|
}
|
|
3335
|
-
async function
|
|
3336
|
-
if (!
|
|
3353
|
+
async function vr(e) {
|
|
3354
|
+
if (!Ke(e.headers))
|
|
3337
3355
|
return;
|
|
3338
3356
|
let t = null, s = null;
|
|
3339
3357
|
try {
|
|
@@ -3342,7 +3360,7 @@ async function Ur(e) {
|
|
|
3342
3360
|
const n = new Promise((a) => {
|
|
3343
3361
|
s = window.setTimeout(() => {
|
|
3344
3362
|
t?.cancel(), a("timeout");
|
|
3345
|
-
},
|
|
3363
|
+
}, Fs);
|
|
3346
3364
|
}), r = new TextDecoder();
|
|
3347
3365
|
let i = "", o = 0;
|
|
3348
3366
|
for (; ; ) {
|
|
@@ -3351,10 +3369,10 @@ async function Ur(e) {
|
|
|
3351
3369
|
return;
|
|
3352
3370
|
const { done: c, value: l } = a;
|
|
3353
3371
|
if (c)
|
|
3354
|
-
return
|
|
3355
|
-
const h =
|
|
3372
|
+
return P(i + r.decode());
|
|
3373
|
+
const h = Ft - o;
|
|
3356
3374
|
if (l.byteLength > h)
|
|
3357
|
-
return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${
|
|
3375
|
+
return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
|
|
3358
3376
|
o += l.byteLength, i += r.decode(l, { stream: !0 });
|
|
3359
3377
|
}
|
|
3360
3378
|
} catch {
|
|
@@ -3364,19 +3382,19 @@ async function Ur(e) {
|
|
|
3364
3382
|
s !== null && window.clearTimeout(s);
|
|
3365
3383
|
}
|
|
3366
3384
|
}
|
|
3367
|
-
function
|
|
3368
|
-
if (
|
|
3385
|
+
function Or(e, t) {
|
|
3386
|
+
if (Ke(new Headers(t)))
|
|
3369
3387
|
try {
|
|
3370
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
3388
|
+
return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
|
|
3371
3389
|
} catch {
|
|
3372
3390
|
return;
|
|
3373
3391
|
}
|
|
3374
3392
|
}
|
|
3375
3393
|
function Ee(e) {
|
|
3376
3394
|
if (typeof e == "string")
|
|
3377
|
-
return
|
|
3395
|
+
return P(e);
|
|
3378
3396
|
}
|
|
3379
|
-
function
|
|
3397
|
+
function xr(e) {
|
|
3380
3398
|
return _({
|
|
3381
3399
|
...e,
|
|
3382
3400
|
requestBody: Re(e.requestBody),
|
|
@@ -3395,14 +3413,14 @@ function Re(e) {
|
|
|
3395
3413
|
return it(e);
|
|
3396
3414
|
}
|
|
3397
3415
|
}
|
|
3398
|
-
function
|
|
3416
|
+
function Ke(e) {
|
|
3399
3417
|
if (!e)
|
|
3400
3418
|
return !1;
|
|
3401
3419
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3402
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3420
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= Ft && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3403
3421
|
}
|
|
3404
3422
|
function x(e, t = {}, s) {
|
|
3405
|
-
if (
|
|
3423
|
+
if (Br(s))
|
|
3406
3424
|
return !0;
|
|
3407
3425
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3408
3426
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3417,7 +3435,7 @@ function x(e, t = {}, s) {
|
|
|
3417
3435
|
return !0;
|
|
3418
3436
|
}
|
|
3419
3437
|
}
|
|
3420
|
-
function
|
|
3438
|
+
function Lr(e, t) {
|
|
3421
3439
|
if (x(e))
|
|
3422
3440
|
return !0;
|
|
3423
3441
|
try {
|
|
@@ -3427,26 +3445,26 @@ function vr(e, t) {
|
|
|
3427
3445
|
return !0;
|
|
3428
3446
|
}
|
|
3429
3447
|
}
|
|
3430
|
-
function
|
|
3448
|
+
function Br(e) {
|
|
3431
3449
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3432
3450
|
}
|
|
3433
|
-
function
|
|
3451
|
+
function qr(e) {
|
|
3434
3452
|
const t = {};
|
|
3435
3453
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3436
3454
|
const n = s.indexOf(":");
|
|
3437
3455
|
if (n <= 0)
|
|
3438
3456
|
continue;
|
|
3439
|
-
if (Object.keys(t).length >=
|
|
3457
|
+
if (Object.keys(t).length >= zt)
|
|
3440
3458
|
break;
|
|
3441
3459
|
const r = s.slice(0, n).trim();
|
|
3442
|
-
t[r] =
|
|
3460
|
+
t[r] = Vt(r, s.slice(n + 1).trim());
|
|
3443
3461
|
}
|
|
3444
3462
|
return t;
|
|
3445
3463
|
}
|
|
3446
|
-
function
|
|
3464
|
+
function P(e, t = Ft) {
|
|
3447
3465
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
3448
3466
|
}
|
|
3449
|
-
function
|
|
3467
|
+
function Pt(e) {
|
|
3450
3468
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3451
3469
|
}
|
|
3452
3470
|
class nt extends Error {
|
|
@@ -3457,31 +3475,31 @@ class nt extends Error {
|
|
|
3457
3475
|
}
|
|
3458
3476
|
async function tt(e, t) {
|
|
3459
3477
|
let s = null;
|
|
3460
|
-
for (let n = 0; n <
|
|
3478
|
+
for (let n = 0; n < he; n += 1)
|
|
3461
3479
|
try {
|
|
3462
3480
|
return await e();
|
|
3463
3481
|
} catch (r) {
|
|
3464
|
-
if (s = r, n >=
|
|
3482
|
+
if (s = r, n >= he - 1 || !Wr(r))
|
|
3465
3483
|
throw r;
|
|
3466
|
-
await
|
|
3484
|
+
await Hr(n);
|
|
3467
3485
|
}
|
|
3468
3486
|
throw s instanceof Error ? s : new Error(t);
|
|
3469
3487
|
}
|
|
3470
|
-
function
|
|
3488
|
+
function Hr(e) {
|
|
3471
3489
|
return new Promise((t) => {
|
|
3472
|
-
window.setTimeout(t,
|
|
3490
|
+
window.setTimeout(t, Ws[e] ?? 0);
|
|
3473
3491
|
});
|
|
3474
3492
|
}
|
|
3475
|
-
function
|
|
3476
|
-
return e instanceof nt ?
|
|
3493
|
+
function Wr(e) {
|
|
3494
|
+
return e instanceof nt ? $r(e.status) : e instanceof TypeError;
|
|
3477
3495
|
}
|
|
3478
|
-
function
|
|
3496
|
+
function $r(e) {
|
|
3479
3497
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3480
3498
|
}
|
|
3481
|
-
function
|
|
3499
|
+
function jr(e) {
|
|
3482
3500
|
return e === 401 || e === 403;
|
|
3483
3501
|
}
|
|
3484
|
-
const ut = "[REDACTED_SECRET]",
|
|
3502
|
+
const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", Fr = "[REDACTED_SIGNED_URL]", zr = 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, Ge = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Xe = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Je = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ve = /\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, Gr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Xr = /\bhttps?:\/\/[^\s"'<>]+/gi, Jr = /[),.;\]]+$/;
|
|
3485
3503
|
function _(e) {
|
|
3486
3504
|
return rt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3487
3505
|
}
|
|
@@ -3490,7 +3508,7 @@ function rt(e, t, s) {
|
|
|
3490
3508
|
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
|
|
3491
3509
|
if (e === null || typeof e != "object")
|
|
3492
3510
|
return e;
|
|
3493
|
-
if (t >=
|
|
3511
|
+
if (t >= zr)
|
|
3494
3512
|
return "[REDACTED_MAX_DEPTH]";
|
|
3495
3513
|
if (s.has(e))
|
|
3496
3514
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -3498,44 +3516,46 @@ function rt(e, t, s) {
|
|
|
3498
3516
|
return e.map((r) => rt(r, t + 1, s));
|
|
3499
3517
|
const n = {};
|
|
3500
3518
|
for (const [r, i] of Object.entries(e))
|
|
3501
|
-
r === "pageContent" ? n[r] = i :
|
|
3519
|
+
r === "pageContent" ? n[r] = i : Ye(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Vr(i) : rt(i, t + 1, s);
|
|
3502
3520
|
return n;
|
|
3503
3521
|
}
|
|
3504
|
-
function
|
|
3522
|
+
function Ye(e) {
|
|
3505
3523
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3506
3524
|
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");
|
|
3507
3525
|
}
|
|
3508
|
-
function
|
|
3509
|
-
return typeof e == "string" ?
|
|
3526
|
+
function Vr(e) {
|
|
3527
|
+
return typeof e == "string" ? Ze(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3510
3528
|
}
|
|
3511
|
-
function
|
|
3529
|
+
function Ze(e) {
|
|
3512
3530
|
try {
|
|
3513
3531
|
const t = new URL(e, location.href);
|
|
3514
3532
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3515
|
-
|
|
3516
|
-
return t.username && (t.username =
|
|
3533
|
+
Kr.test(s) && t.searchParams.set(s, U);
|
|
3534
|
+
return t.username && (t.username = U), t.password && (t.password = U), t.toString();
|
|
3517
3535
|
} catch {
|
|
3518
|
-
return
|
|
3536
|
+
return Yr(e);
|
|
3519
3537
|
}
|
|
3520
3538
|
}
|
|
3521
3539
|
function it(e) {
|
|
3522
|
-
return e.replace(
|
|
3540
|
+
return e.replace(Gr, Fr).replace(Xr, Zr).replace(Ge, `Bearer ${U}`).replace(Xe, `Basic ${U}`).replace(Je, U).replace(Ve, (t, s) => `${s}: ${ut}`);
|
|
3523
3541
|
}
|
|
3524
|
-
function
|
|
3525
|
-
return e.replace(
|
|
3542
|
+
function Yr(e) {
|
|
3543
|
+
return e.replace(Ge, `Bearer ${U}`).replace(Xe, `Basic ${U}`).replace(Je, U).replace(Ve, (t, s) => `${s}: ${ut}`);
|
|
3526
3544
|
}
|
|
3527
|
-
function
|
|
3528
|
-
const t = e.match(
|
|
3529
|
-
return `${
|
|
3545
|
+
function Zr(e) {
|
|
3546
|
+
const t = e.match(Jr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3547
|
+
return `${Ze(s)}${t}`;
|
|
3530
3548
|
}
|
|
3531
3549
|
export {
|
|
3532
|
-
|
|
3550
|
+
oe as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3533
3551
|
Dt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3552
|
+
Es as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3553
|
+
As as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3554
|
+
Rs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3555
|
+
Qr as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
3537
3556
|
Ue as PlunoProductAgent,
|
|
3538
|
-
|
|
3557
|
+
Gs as calculateReconnectDelay,
|
|
3539
3558
|
Ue as default,
|
|
3540
|
-
|
|
3559
|
+
yn as getProductAgentOriginAccessErrorMessage,
|
|
3560
|
+
Mr as validateProductAgentProviderInputFile
|
|
3541
3561
|
};
|