@pluno/product-agent-web 0.1.162 → 0.1.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -0
- package/dist/internalToolVisibility.d.ts +2 -0
- package/dist/markdown.d.ts +1 -0
- package/dist/product-agent-sdk.js +1009 -873
- package/dist/product-agent-widget.js +3588 -3335
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const e = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
1
|
+
const us = "pluno-product-agent-attachments";
|
|
2
|
+
const Be = "files";
|
|
3
|
+
async function ds(t) {
|
|
4
|
+
const e = await Xe();
|
|
5
|
+
await gs(e, "readwrite", (s) => s.put(t));
|
|
6
|
+
}
|
|
7
|
+
async function ps(t, e) {
|
|
8
|
+
const s = await Xe();
|
|
9
|
+
await Ve(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await Je(
|
|
11
11
|
n.get(t)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,28 +16,28 @@ async function cs(t, e) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const e = await
|
|
21
|
-
await
|
|
19
|
+
async function hs(t = 864e5) {
|
|
20
|
+
const e = await Xe(), s = Date.now() - t;
|
|
21
|
+
await Ve(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await Je(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Xe() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
|
|
28
|
-
const s = indexedDB.open(
|
|
28
|
+
const s = indexedDB.open(us, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(Be, { 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 = () => t(s.result), s.onerror = () => e(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
return await
|
|
35
|
+
async function gs(t, e, s) {
|
|
36
|
+
return await Ve(t, e, async (n) => await Je(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Ve(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(Be, e), o = i.objectStore(Be);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
s(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -57,16 +57,16 @@ function Ge(t, e, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Je(t) {
|
|
61
61
|
return new Promise((e, s) => {
|
|
62
62
|
t.onsuccess = () => e(t.result), t.onerror = () => s(t.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function fs(t) {
|
|
66
66
|
return t !== null && (typeof t == "object" || typeof t == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const n = Reflect.get(t, "pluno"), r =
|
|
68
|
+
function vt(t, e, s) {
|
|
69
|
+
const n = Reflect.get(t, "pluno"), r = fs(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(t, "pluno", r))
|
|
71
71
|
return null;
|
|
72
72
|
const i = Object.getOwnPropertyDescriptor(r, e);
|
|
@@ -80,14 +80,18 @@ function Pt(t, e, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const ms = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function ys(t, e) {
|
|
85
85
|
return e ? t.replace(
|
|
86
|
-
|
|
86
|
+
ms,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
|
|
88
88
|
) : t;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
const Is = "save_runtime_captured_skill";
|
|
91
|
+
function Ts(t) {
|
|
92
|
+
return (t.type === "function_call" || t.type === "tool_call") && t.name === Is;
|
|
93
|
+
}
|
|
94
|
+
function ws(t, e, s) {
|
|
91
95
|
const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
92
96
|
n.flatMap(
|
|
93
97
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
@@ -104,38 +108,38 @@ function fs(t, e, s) {
|
|
|
104
108
|
)
|
|
105
109
|
), c = /* @__PURE__ */ new Map();
|
|
106
110
|
for (const { item: u, identity: d } of i)
|
|
107
|
-
for (const
|
|
108
|
-
const
|
|
109
|
-
(!
|
|
111
|
+
for (const f of d.activityKeys ?? []) {
|
|
112
|
+
const I = c.get(f);
|
|
113
|
+
(!I || s(I).isTransient) && c.set(f, u);
|
|
110
114
|
}
|
|
111
|
-
const p = new Set(i.map(({ identity: u }) => u.id)),
|
|
115
|
+
const p = new Set(i.map(({ identity: u }) => u.id)), g = new Set(
|
|
112
116
|
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
113
|
-
),
|
|
117
|
+
), T = /* @__PURE__ */ new Set(), h = [];
|
|
114
118
|
for (const u of t) {
|
|
115
119
|
const d = s(u);
|
|
116
|
-
let
|
|
117
|
-
if (d.isOptimistic && d.optimisticKey ?
|
|
118
|
-
|
|
120
|
+
let f = o.get(d.id);
|
|
121
|
+
if (d.isOptimistic && d.optimisticKey ? f = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? f = l.get(d.assistantDraftKey) : d.isActivity && (f = d.activityKeys?.map((w) => c.get(w)).find((w) => w !== void 0) ?? f), f && !T.has(f)) {
|
|
122
|
+
h.push(f), T.add(f);
|
|
119
123
|
continue;
|
|
120
124
|
}
|
|
121
|
-
const
|
|
122
|
-
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) &&
|
|
125
|
+
const I = d.respondsToUserMessageId !== void 0 && p.has(d.respondsToUserMessageId) || d.runId !== void 0 && g.has(d.runId);
|
|
126
|
+
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) && I) && h.push(u);
|
|
123
127
|
}
|
|
124
128
|
for (const { item: u } of i)
|
|
125
|
-
|
|
126
|
-
return
|
|
129
|
+
T.has(u) || h.push(u);
|
|
130
|
+
return h;
|
|
127
131
|
}
|
|
128
|
-
function
|
|
132
|
+
function Ss(t, e, s, n) {
|
|
129
133
|
return t.filter((r) => {
|
|
130
134
|
const i = n(r);
|
|
131
135
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
132
136
|
});
|
|
133
137
|
}
|
|
134
|
-
const
|
|
135
|
-
let
|
|
136
|
-
const
|
|
137
|
-
async function
|
|
138
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
138
|
+
const be = "pluno.productAgent.transportId", Ms = "pluno.productAgent.transportIdentity", _e = "pluno.productAgent.transportIdentity.event", As = 50, Rs = globalThis.setTimeout.bind(globalThis);
|
|
139
|
+
let J = null;
|
|
140
|
+
const de = /* @__PURE__ */ new Set(), ke = /* @__PURE__ */ new Map();
|
|
141
|
+
async function Es(t = Nt()) {
|
|
142
|
+
const e = t.randomUUID(), s = t.storage.getItem(be);
|
|
139
143
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
140
144
|
const o = t.channel.subscribe((l) => {
|
|
141
145
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -153,14 +157,14 @@ async function ws(t = Ut()) {
|
|
|
153
157
|
}
|
|
154
158
|
});
|
|
155
159
|
if (!s)
|
|
156
|
-
t.storage.setItem(
|
|
160
|
+
t.storage.setItem(be, n), r = !0;
|
|
157
161
|
else
|
|
158
162
|
for (; ; ) {
|
|
159
163
|
if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
|
|
160
164
|
r = !0;
|
|
161
165
|
break;
|
|
162
166
|
}
|
|
163
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
167
|
+
n = t.randomUUID(), t.storage.setItem(be, n);
|
|
164
168
|
}
|
|
165
169
|
let a = !1;
|
|
166
170
|
return {
|
|
@@ -170,49 +174,49 @@ async function ws(t = Ut()) {
|
|
|
170
174
|
}
|
|
171
175
|
};
|
|
172
176
|
}
|
|
173
|
-
async function
|
|
174
|
-
|
|
177
|
+
async function Cs() {
|
|
178
|
+
J || (J = Es(Nt()), J.then((n) => {
|
|
175
179
|
const r = (i) => {
|
|
176
|
-
i.persisted || (n.release(),
|
|
180
|
+
i.persisted || (n.release(), J = null, de.clear(), window.removeEventListener("pagehide", r));
|
|
177
181
|
};
|
|
178
182
|
window.addEventListener("pagehide", r);
|
|
179
183
|
}));
|
|
180
|
-
const t = await
|
|
181
|
-
|
|
184
|
+
const t = await J, e = bs();
|
|
185
|
+
de.add(e);
|
|
182
186
|
let s = !1;
|
|
183
187
|
return {
|
|
184
188
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
185
189
|
transportId: e === 0 ? t.transportId : `${t.transportId}.${e}`,
|
|
186
190
|
release: () => {
|
|
187
|
-
s || (s = !0,
|
|
191
|
+
s || (s = !0, de.delete(e));
|
|
188
192
|
}
|
|
189
193
|
};
|
|
190
194
|
}
|
|
191
|
-
function
|
|
195
|
+
function bs() {
|
|
192
196
|
let t = 0;
|
|
193
|
-
for (;
|
|
197
|
+
for (; de.has(t); )
|
|
194
198
|
t += 1;
|
|
195
199
|
return t;
|
|
196
200
|
}
|
|
197
|
-
function
|
|
201
|
+
function Nt() {
|
|
198
202
|
return {
|
|
199
|
-
storage:
|
|
200
|
-
channel:
|
|
203
|
+
storage: _s(),
|
|
204
|
+
channel: ks(),
|
|
201
205
|
randomUUID: () => crypto.randomUUID(),
|
|
202
|
-
settle: () => new Promise((t) =>
|
|
206
|
+
settle: () => new Promise((t) => Rs(t, As))
|
|
203
207
|
};
|
|
204
208
|
}
|
|
205
|
-
function
|
|
209
|
+
function _s() {
|
|
206
210
|
return {
|
|
207
211
|
getItem: (t) => {
|
|
208
212
|
try {
|
|
209
|
-
return window.sessionStorage?.getItem(t) ??
|
|
213
|
+
return window.sessionStorage?.getItem(t) ?? ke.get(t) ?? null;
|
|
210
214
|
} catch {
|
|
211
|
-
return
|
|
215
|
+
return ke.get(t) ?? null;
|
|
212
216
|
}
|
|
213
217
|
},
|
|
214
218
|
setItem: (t, e) => {
|
|
215
|
-
|
|
219
|
+
ke.set(t, e);
|
|
216
220
|
try {
|
|
217
221
|
window.sessionStorage?.setItem(t, e);
|
|
218
222
|
} catch {
|
|
@@ -220,9 +224,9 @@ function As() {
|
|
|
220
224
|
}
|
|
221
225
|
};
|
|
222
226
|
}
|
|
223
|
-
function
|
|
227
|
+
function ks() {
|
|
224
228
|
if (typeof BroadcastChannel < "u") {
|
|
225
|
-
const t = new BroadcastChannel(
|
|
229
|
+
const t = new BroadcastChannel(Ms);
|
|
226
230
|
return {
|
|
227
231
|
postMessage: (e) => t.postMessage(e),
|
|
228
232
|
subscribe: (e) => {
|
|
@@ -232,11 +236,11 @@ function Rs() {
|
|
|
232
236
|
close: () => t.close()
|
|
233
237
|
};
|
|
234
238
|
}
|
|
235
|
-
return
|
|
239
|
+
return Ps();
|
|
236
240
|
}
|
|
237
|
-
function
|
|
241
|
+
function Ps() {
|
|
238
242
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
239
|
-
if (s.key !==
|
|
243
|
+
if (s.key !== _e || !s.newValue)
|
|
240
244
|
return;
|
|
241
245
|
const n = JSON.parse(s.newValue);
|
|
242
246
|
for (const r of t)
|
|
@@ -245,9 +249,9 @@ function Es() {
|
|
|
245
249
|
return window.addEventListener("storage", e), {
|
|
246
250
|
postMessage: (s) => {
|
|
247
251
|
window.localStorage.setItem(
|
|
248
|
-
|
|
252
|
+
_e,
|
|
249
253
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
250
|
-
), window.localStorage.removeItem(
|
|
254
|
+
), window.localStorage.removeItem(_e);
|
|
251
255
|
},
|
|
252
256
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
253
257
|
close: () => {
|
|
@@ -255,8 +259,8 @@ function Es() {
|
|
|
255
259
|
}
|
|
256
260
|
};
|
|
257
261
|
}
|
|
258
|
-
const
|
|
259
|
-
function
|
|
262
|
+
const Ot = "schedule_follow_up";
|
|
263
|
+
function Us(t) {
|
|
260
264
|
let e = t;
|
|
261
265
|
if (typeof e == "string")
|
|
262
266
|
try {
|
|
@@ -267,11 +271,11 @@ function Cs(t) {
|
|
|
267
271
|
if (!e || typeof e != "object")
|
|
268
272
|
return null;
|
|
269
273
|
const s = e;
|
|
270
|
-
return s.ok !== !0 || s.toolName !==
|
|
274
|
+
return s.ok !== !0 || s.toolName !== Ot || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
271
275
|
}
|
|
272
|
-
const
|
|
273
|
-
let
|
|
274
|
-
function
|
|
276
|
+
const Ds = globalThis.fetch.bind(globalThis), qe = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', vs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ns = ".pluno-pa-widget__panel", Os = ".pluno-pa-widget__timeline", pt = `${qe}[data-pluno-sdk-preview-channel]`;
|
|
277
|
+
let xs = 0;
|
|
278
|
+
function ht(t) {
|
|
275
279
|
const e = {};
|
|
276
280
|
for (const o of [
|
|
277
281
|
"type",
|
|
@@ -309,7 +313,7 @@ function dt(t) {
|
|
|
309
313
|
}
|
|
310
314
|
return e;
|
|
311
315
|
}
|
|
312
|
-
function
|
|
316
|
+
function Pe(t, e, s) {
|
|
313
317
|
if (typeof window > "u")
|
|
314
318
|
return;
|
|
315
319
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -321,31 +325,31 @@ function ke(t, e, s) {
|
|
|
321
325
|
source: "web_sdk",
|
|
322
326
|
category: t,
|
|
323
327
|
name: e,
|
|
324
|
-
sequence: ++
|
|
328
|
+
sequence: ++xs,
|
|
325
329
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
326
330
|
monotonicMs: performance.now(),
|
|
327
331
|
data: s
|
|
328
332
|
};
|
|
329
333
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
330
334
|
}
|
|
331
|
-
const
|
|
335
|
+
const Ls = "https://app.pluno.ai", Bs = "gpt-5.6-terra", qs = 2e4, Ws = 1e4, Hs = 1e4, $s = 1e4, js = 1e4, Fs = 3e3, zs = 3e4, Ks = 1e3, gt = 3e4, ft = 0.2, mt = 6e4, Gs = 15e3, Y = 8, Xs = "Pluno could not finish this message. Try it again.", Vs = "Browser connection was interrupted.", yt = 15e3, Js = "Pluno could not send this message. Try it again.", It = 2e3, Ys = 1e3, Qs = 100, Tt = 8e3, wt = 3, Zs = [300, 1e3], xt = 50 * 1024 * 1024, en = /* @__PURE__ */ new Set([
|
|
332
336
|
".jpeg:image/jpeg",
|
|
333
337
|
".jpg:image/jpeg",
|
|
334
338
|
".pdf:application/pdf",
|
|
335
339
|
".png:image/png",
|
|
336
340
|
".webp:image/webp"
|
|
337
|
-
]),
|
|
338
|
-
function
|
|
341
|
+
]), di = ".pdf,.png,.jpg,.jpeg,.webp", Ye = 64e3, Ue = 4e3, Qe = 30, tn = 2e3, sn = 1e3, Lt = "Image is too large for model vision input.", nn = 100, Bt = "pluno.productAgent.state.", We = "pluno.productAgent.pendingEvents.", me = "pluno.productAgent.activeToolCalls.", rn = 100;
|
|
342
|
+
function Q(t, e = 0) {
|
|
339
343
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
340
344
|
return Math.max(e, s);
|
|
341
345
|
}
|
|
342
|
-
const
|
|
343
|
-
let
|
|
344
|
-
function
|
|
345
|
-
const s = Math.min(
|
|
346
|
-
return Math.min(
|
|
346
|
+
const pe = /* @__PURE__ */ new Set();
|
|
347
|
+
let ie = null;
|
|
348
|
+
function on(t, e = Math.random) {
|
|
349
|
+
const s = Math.min(gt, Ks * 2 ** t), n = 1 - ft + e() * ft * 2;
|
|
350
|
+
return Math.min(gt, Math.round(s * n));
|
|
347
351
|
}
|
|
348
|
-
function
|
|
352
|
+
function an(t, e, s) {
|
|
349
353
|
return new Promise((n, r) => {
|
|
350
354
|
const i = setTimeout(() => r(new Error(s)), e);
|
|
351
355
|
t.then(
|
|
@@ -358,13 +362,13 @@ function tn(t, e, s) {
|
|
|
358
362
|
);
|
|
359
363
|
});
|
|
360
364
|
}
|
|
361
|
-
class
|
|
365
|
+
class qt {
|
|
362
366
|
constructor(e, s) {
|
|
363
367
|
this.options = e, this.transportIdentity = s, this.state = {
|
|
364
368
|
...this.state,
|
|
365
|
-
starterPrompts:
|
|
369
|
+
starterPrompts: Hn(e.initialStarterPrompts)
|
|
366
370
|
};
|
|
367
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
371
|
+
const n = e.restorePersistedState === !1 ? null : Pr(e.clientId, e.expectedPersistedSessionId);
|
|
368
372
|
n && (this.state = {
|
|
369
373
|
...this.state,
|
|
370
374
|
...n,
|
|
@@ -376,17 +380,18 @@ class xt {
|
|
|
376
380
|
assistantDraftRespondsToUserMessageId: null,
|
|
377
381
|
assistantDraftRunId: null,
|
|
378
382
|
pendingMessageStatus: null,
|
|
383
|
+
turnPhase: null,
|
|
379
384
|
isThinking: !1,
|
|
380
385
|
isRetrying: !1,
|
|
381
386
|
lastError: null
|
|
382
|
-
}), this.queuedClientEvents =
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
}), this.queuedClientEvents = xr(
|
|
388
|
+
Dr(e.clientId),
|
|
389
|
+
vr(e.clientId)
|
|
385
390
|
);
|
|
386
391
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
387
392
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
388
393
|
);
|
|
389
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting"),
|
|
394
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), $(e.clientId, this.queuedClientEvents);
|
|
390
395
|
}
|
|
391
396
|
options;
|
|
392
397
|
listeners = {};
|
|
@@ -415,6 +420,7 @@ class xt {
|
|
|
415
420
|
transportIdentity;
|
|
416
421
|
retryAttemptsByClientMessageId = {};
|
|
417
422
|
retryTimersByClientMessageId = {};
|
|
423
|
+
reportedHealthSignalKeys = /* @__PURE__ */ new Set();
|
|
418
424
|
clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
|
|
419
425
|
backgroundSessionIds = /* @__PURE__ */ new Set();
|
|
420
426
|
backgroundClientMessageIds = /* @__PURE__ */ new Set();
|
|
@@ -443,6 +449,7 @@ class xt {
|
|
|
443
449
|
attachmentFiles = /* @__PURE__ */ new Map();
|
|
444
450
|
sessionBrowserApisCleanup = null;
|
|
445
451
|
activeBrowserToolCalls = /* @__PURE__ */ new Map();
|
|
452
|
+
stoppedTurns = [];
|
|
446
453
|
pendingToolLoadingByCallId = /* @__PURE__ */ new Map();
|
|
447
454
|
terminalToolCallIds = /* @__PURE__ */ new Set();
|
|
448
455
|
nonTranscriptToolCallIds = /* @__PURE__ */ new Set();
|
|
@@ -466,6 +473,7 @@ class xt {
|
|
|
466
473
|
assistantDraftRespondsToUserMessageId: null,
|
|
467
474
|
assistantDraftRunId: null,
|
|
468
475
|
pendingMessageStatus: null,
|
|
476
|
+
turnPhase: null,
|
|
469
477
|
isThinking: !1,
|
|
470
478
|
isRetrying: !1,
|
|
471
479
|
lastError: null,
|
|
@@ -473,17 +481,17 @@ class xt {
|
|
|
473
481
|
lastErrorSecuritySettingsUrl: null
|
|
474
482
|
};
|
|
475
483
|
static async init(e) {
|
|
476
|
-
const s = await
|
|
484
|
+
const s = await Cs(), n = new qt({
|
|
477
485
|
...e,
|
|
478
|
-
backendUrl:
|
|
479
|
-
clientId: e.clientId ??
|
|
480
|
-
model: e.model ??
|
|
486
|
+
backendUrl: Cn(e.backendUrl ?? Ls),
|
|
487
|
+
clientId: e.clientId ?? Kn(),
|
|
488
|
+
model: e.model ?? Bs,
|
|
481
489
|
productVariant: e.productVariant ?? "customer_embedded",
|
|
482
|
-
entrySurface:
|
|
490
|
+
entrySurface: bn(e.entrySurface)
|
|
483
491
|
}, s);
|
|
484
492
|
try {
|
|
485
|
-
|
|
486
|
-
|
|
493
|
+
hs().catch((r) => {
|
|
494
|
+
R("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
487
495
|
message: r instanceof Error ? r.message : String(r)
|
|
488
496
|
});
|
|
489
497
|
}), e.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await n.connect();
|
|
@@ -513,15 +521,15 @@ class xt {
|
|
|
513
521
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
514
522
|
);
|
|
515
523
|
try {
|
|
516
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
524
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await an(this.options.tokenProvider(), Hs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
517
525
|
return;
|
|
518
526
|
if (!this.token && !this.options.webSocketFactory)
|
|
519
527
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
520
|
-
const s =
|
|
528
|
+
const s = Pn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
521
529
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
522
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (
|
|
523
|
-
},
|
|
524
|
-
this.socket !== n || (this.clearSocketConnectTimer(),
|
|
530
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (R("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
531
|
+
}, $s), n.addEventListener("open", () => {
|
|
532
|
+
this.socket !== n || (this.clearSocketConnectTimer(), R("web-sdk.agent", "Pluno socket opened", {
|
|
525
533
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
526
534
|
isThinking: this.state.isThinking
|
|
527
535
|
}), !(this.token ? this.sendNow({
|
|
@@ -531,19 +539,19 @@ class xt {
|
|
|
531
539
|
transportId: this.transportIdentity.transportId,
|
|
532
540
|
pageUrl: location.href
|
|
533
541
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
534
|
-
this.socket === n && (
|
|
535
|
-
},
|
|
542
|
+
this.socket === n && (R("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
543
|
+
}, js));
|
|
536
544
|
}), n.addEventListener("message", (r) => {
|
|
537
|
-
this.socket === n && this.handleServerEvent(
|
|
545
|
+
this.socket === n && this.handleServerEvent(qn(r.data));
|
|
538
546
|
}), n.addEventListener("sendfailure", (r) => {
|
|
539
547
|
if (this.socket !== n)
|
|
540
548
|
return;
|
|
541
|
-
const i =
|
|
549
|
+
const i = Wn(r?.detail?.data);
|
|
542
550
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
543
551
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
544
|
-
) && (this.queuedClientEvents.push(i),
|
|
552
|
+
) && (this.queuedClientEvents.push(i), $(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
|
|
545
553
|
}), n.addEventListener("close", (r) => {
|
|
546
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(),
|
|
554
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), R("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
547
555
|
code: typeof r?.code == "number" ? r.code : null,
|
|
548
556
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
549
557
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -551,7 +559,7 @@ class xt {
|
|
|
551
559
|
isThinking: this.state.isThinking
|
|
552
560
|
}), this.setReconnectingState(), this.scheduleReconnect()));
|
|
553
561
|
}), n.addEventListener("error", () => {
|
|
554
|
-
this.socket !== n || this.state.status === "closed" || (
|
|
562
|
+
this.socket !== n || this.state.status === "closed" || (R("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
555
563
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
556
564
|
isThinking: this.state.isThinking
|
|
557
565
|
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.rememberBrowserConnectionInterruptionForActiveRun(), this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
@@ -574,15 +582,15 @@ class xt {
|
|
|
574
582
|
this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, 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.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
575
583
|
}
|
|
576
584
|
destroy() {
|
|
577
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
585
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Lr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
578
586
|
for (const e of Object.values(this.listeners))
|
|
579
587
|
e?.clear();
|
|
580
588
|
}
|
|
581
589
|
warmup(e = "panel_open") {
|
|
582
|
-
const s =
|
|
590
|
+
const s = k(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
|
|
583
591
|
type: "runtime.warmup",
|
|
584
592
|
reason: e,
|
|
585
|
-
...e === "composer_input" ? { warmupId: r?.event.warmupId ??
|
|
593
|
+
...e === "composer_input" ? { warmupId: r?.event.warmupId ?? H() } : {},
|
|
586
594
|
entrySurface: this.options.entrySurface,
|
|
587
595
|
sessionId: this.state.sessionId ?? void 0,
|
|
588
596
|
page: s
|
|
@@ -597,23 +605,23 @@ class xt {
|
|
|
597
605
|
}
|
|
598
606
|
async sendMessage(e, s = {}) {
|
|
599
607
|
const n = e.trim(), r = s.attachments ?? [];
|
|
600
|
-
if (this.options.productVariant === "customer_embedded" && (r.forEach(
|
|
601
|
-
(
|
|
608
|
+
if (this.options.productVariant === "customer_embedded" && (r.forEach(Zt), r.reduce(
|
|
609
|
+
(m, b) => m + b.sizeBytes,
|
|
602
610
|
0
|
|
603
|
-
) >
|
|
611
|
+
) > xt))
|
|
604
612
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
605
|
-
let i = r.map(
|
|
613
|
+
let i = r.map(tt);
|
|
606
614
|
if (!n && i.length === 0)
|
|
607
615
|
return null;
|
|
608
616
|
if (this.pendingClientMessageId)
|
|
609
617
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
610
|
-
const o =
|
|
618
|
+
const o = k(), a = s.clientMessageId ?? H(), l = {
|
|
611
619
|
id: `local-${a}`,
|
|
612
620
|
role: "user",
|
|
613
621
|
content: n,
|
|
614
622
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
615
623
|
...r.length > 0 ? { attachments: r } : {}
|
|
616
|
-
}, c = this.state.messages.some((
|
|
624
|
+
}, c = this.state.messages.some((w) => w.id === l.id || w.clientMessageId === a), p = this.state.isThinking, g = this.state.pendingMessageStatus, T = this.state.turnPhase, h = this.state.messages, u = c ? this.state.messages : [...this.state.messages, l], d = {
|
|
617
625
|
assistantDraft: this.state.assistantDraft,
|
|
618
626
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
619
627
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -622,7 +630,7 @@ class xt {
|
|
|
622
630
|
lastError: this.state.lastError
|
|
623
631
|
};
|
|
624
632
|
this.setState({
|
|
625
|
-
messages:
|
|
633
|
+
messages: u,
|
|
626
634
|
...p ? {} : {
|
|
627
635
|
assistantDraft: "",
|
|
628
636
|
assistantDraftItemId: null,
|
|
@@ -631,46 +639,48 @@ class xt {
|
|
|
631
639
|
assistantDraftRunId: null
|
|
632
640
|
},
|
|
633
641
|
pendingMessageStatus: "sending",
|
|
642
|
+
turnPhase: p ? T : "sending",
|
|
634
643
|
isThinking: p,
|
|
635
644
|
isRetrying: !1,
|
|
636
645
|
lastError: null
|
|
637
646
|
}), c || this.emit("message", l);
|
|
638
647
|
try {
|
|
639
|
-
const
|
|
640
|
-
for (const
|
|
641
|
-
const
|
|
642
|
-
if (
|
|
643
|
-
|
|
648
|
+
const w = [];
|
|
649
|
+
for (const m of i) {
|
|
650
|
+
const b = m.id ? this.attachmentFiles.get(m.id) : void 0;
|
|
651
|
+
if (m.sandboxPath || m.storageKey) {
|
|
652
|
+
w.push(m);
|
|
644
653
|
continue;
|
|
645
654
|
}
|
|
646
|
-
if (!
|
|
647
|
-
throw new Error(`Attachment bytes are unavailable for ${
|
|
648
|
-
|
|
655
|
+
if (!b)
|
|
656
|
+
throw new Error(`Attachment bytes are unavailable for ${m.name}`);
|
|
657
|
+
w.push(await this.uploadAttachmentForMessage({ file: b, attachment: m }));
|
|
649
658
|
}
|
|
650
|
-
i =
|
|
651
|
-
} catch (
|
|
659
|
+
i = w;
|
|
660
|
+
} catch (w) {
|
|
652
661
|
throw this.setState({
|
|
653
|
-
...c ? {} : { messages:
|
|
654
|
-
...p ? {} : { ...
|
|
655
|
-
pendingMessageStatus:
|
|
656
|
-
|
|
662
|
+
...c ? {} : { messages: h },
|
|
663
|
+
...p ? {} : { ...d, isThinking: !1 },
|
|
664
|
+
pendingMessageStatus: g,
|
|
665
|
+
turnPhase: T
|
|
666
|
+
}), w;
|
|
657
667
|
}
|
|
658
668
|
this.retryableClientMessageId = null;
|
|
659
|
-
const
|
|
669
|
+
const f = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, I = {
|
|
660
670
|
type: "chat.user_message",
|
|
661
671
|
sessionId: this.state.sessionId ?? void 0,
|
|
662
672
|
clientMessageId: a,
|
|
663
673
|
initiatedBy: s.initiatedBy,
|
|
664
|
-
invocation:
|
|
674
|
+
invocation: _n(s.invocation ?? s.initiatedBy),
|
|
665
675
|
entrySurface: this.options.entrySurface,
|
|
666
676
|
content: n,
|
|
667
|
-
pageContent:
|
|
677
|
+
pageContent: f && Ze() || void 0,
|
|
668
678
|
attachments: i.length > 0 ? i : void 0,
|
|
669
679
|
page: o,
|
|
670
680
|
model: this.options.model,
|
|
671
|
-
metadata:
|
|
681
|
+
metadata: St(this.options.metadata)
|
|
672
682
|
};
|
|
673
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent =
|
|
683
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = I, this.browserConnectionInterruptedClientMessageIds.delete(a), this.send(I), this.schedulePendingDeliveryAck(a), a;
|
|
674
684
|
}
|
|
675
685
|
retryLastMessage() {
|
|
676
686
|
const e = this.state.sessionId, s = this.retryableClientMessageId;
|
|
@@ -688,27 +698,27 @@ class xt {
|
|
|
688
698
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(s), this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
|
|
689
699
|
}
|
|
690
700
|
createLocalAttachment(e) {
|
|
691
|
-
this.options.productVariant === "customer_embedded" &&
|
|
692
|
-
const s =
|
|
701
|
+
this.options.productVariant === "customer_embedded" && Br(e);
|
|
702
|
+
const s = H(), n = {
|
|
693
703
|
id: s,
|
|
694
704
|
name: e.name || "attachment",
|
|
695
|
-
mimeType:
|
|
705
|
+
mimeType: Ge(e),
|
|
696
706
|
sizeBytes: e.size
|
|
697
707
|
};
|
|
698
708
|
this.attachmentFiles.set(s, e);
|
|
699
709
|
const r = Date.now();
|
|
700
|
-
return
|
|
710
|
+
return ds({
|
|
701
711
|
attachmentId: s,
|
|
702
712
|
name: n.name,
|
|
703
713
|
mimeType: n.mimeType,
|
|
704
714
|
sizeBytes: n.sizeBytes,
|
|
705
715
|
blob: e,
|
|
706
|
-
origin:
|
|
716
|
+
origin: k().origin,
|
|
707
717
|
sessionId: this.state.sessionId ?? void 0,
|
|
708
718
|
createdAt: r,
|
|
709
719
|
lastUsedAt: r
|
|
710
720
|
}).catch((i) => {
|
|
711
|
-
|
|
721
|
+
R("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
712
722
|
attachmentId: s,
|
|
713
723
|
name: n.name,
|
|
714
724
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -726,7 +736,7 @@ class xt {
|
|
|
726
736
|
file: e,
|
|
727
737
|
attachment: s
|
|
728
738
|
}) {
|
|
729
|
-
const n = this.state.sessionId, r =
|
|
739
|
+
const n = this.state.sessionId, r = Ge(e), i = {
|
|
730
740
|
sessionId: n ?? void 0,
|
|
731
741
|
attachmentId: s.id,
|
|
732
742
|
clientId: this.options.clientId,
|
|
@@ -734,43 +744,43 @@ class xt {
|
|
|
734
744
|
name: e.name || "attachment",
|
|
735
745
|
mimeType: r,
|
|
736
746
|
sizeBytes: e.size,
|
|
737
|
-
page:
|
|
747
|
+
page: k(),
|
|
738
748
|
model: this.options.model,
|
|
739
|
-
metadata:
|
|
749
|
+
metadata: St(this.options.metadata),
|
|
740
750
|
entrySurface: this.options.entrySurface
|
|
741
751
|
};
|
|
742
752
|
let o;
|
|
743
753
|
if (this.options.persistAttachmentUpload)
|
|
744
|
-
o = await
|
|
754
|
+
o = await ue(
|
|
745
755
|
() => this.options.persistAttachmentUpload(i, e),
|
|
746
756
|
"Failed to upload attachment"
|
|
747
757
|
);
|
|
748
758
|
else {
|
|
749
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
759
|
+
const l = this.options.prepareAttachmentUpload ? await ue(
|
|
750
760
|
() => this.options.prepareAttachmentUpload(i),
|
|
751
761
|
"Failed to prepare attachment upload"
|
|
752
762
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
753
|
-
await
|
|
763
|
+
await ue(async () => {
|
|
754
764
|
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
755
765
|
method: l.uploadMethod,
|
|
756
766
|
headers: l.uploadHeaders,
|
|
757
767
|
body: e
|
|
758
768
|
});
|
|
759
769
|
if (!c.ok)
|
|
760
|
-
throw new
|
|
770
|
+
throw new he("Failed to upload attachment", c.status);
|
|
761
771
|
return c;
|
|
762
772
|
}, "Failed to upload attachment"), o = l;
|
|
763
773
|
}
|
|
764
774
|
this.setState({ sessionId: o.sessionId });
|
|
765
|
-
const a =
|
|
766
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
775
|
+
const a = Qt(o.attachment, this.options.backendUrl);
|
|
776
|
+
return this.updateAttachmentInState(s.id, a), s.id && ps(s.id, {
|
|
767
777
|
sessionId: o.sessionId,
|
|
768
778
|
fileUrl: a.fileUrl,
|
|
769
779
|
sandboxPath: a.sandboxPath,
|
|
770
780
|
storageKey: a.storageKey,
|
|
771
781
|
lastUsedAt: Date.now()
|
|
772
782
|
}).catch((l) => {
|
|
773
|
-
|
|
783
|
+
R("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
774
784
|
attachmentId: s.id,
|
|
775
785
|
name: a.name,
|
|
776
786
|
message: l instanceof Error ? l.message : String(l)
|
|
@@ -790,18 +800,18 @@ class xt {
|
|
|
790
800
|
}
|
|
791
801
|
async prepareEmbedAttachmentUpload(e) {
|
|
792
802
|
let s = !1;
|
|
793
|
-
return await
|
|
803
|
+
return await ue(async () => {
|
|
794
804
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
795
805
|
if (n.ok)
|
|
796
806
|
return await n.json();
|
|
797
|
-
if (
|
|
807
|
+
if (ti(n.status) && this.options.tokenProvider && !s) {
|
|
798
808
|
s = !0;
|
|
799
809
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
800
810
|
if (r.ok)
|
|
801
811
|
return await r.json();
|
|
802
|
-
throw new
|
|
812
|
+
throw new he("Failed to prepare attachment upload", r.status);
|
|
803
813
|
}
|
|
804
|
-
throw new
|
|
814
|
+
throw new he("Failed to prepare attachment upload", n.status);
|
|
805
815
|
}, "Failed to prepare attachment upload");
|
|
806
816
|
}
|
|
807
817
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -819,21 +829,42 @@ class xt {
|
|
|
819
829
|
if (!this.state.sessionId)
|
|
820
830
|
return;
|
|
821
831
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
822
|
-
const e =
|
|
832
|
+
const e = Sr(
|
|
823
833
|
this.state.messages,
|
|
824
834
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
825
835
|
this.state.assistantDraftRunId,
|
|
826
836
|
this.activeClientMessageId
|
|
827
837
|
);
|
|
828
|
-
this.
|
|
829
|
-
|
|
838
|
+
this.stoppedTurns.push({
|
|
839
|
+
sessionId: this.state.sessionId,
|
|
840
|
+
...e,
|
|
841
|
+
stoppedAt: null,
|
|
842
|
+
stoppedCausalSequence: null,
|
|
843
|
+
toolCallIds: new Set(
|
|
844
|
+
this.state.messages.filter(
|
|
845
|
+
(s) => Oe(
|
|
846
|
+
s,
|
|
847
|
+
e.respondsToUserMessageId,
|
|
848
|
+
e.runId
|
|
849
|
+
)
|
|
850
|
+
).map((s) => s.callId).filter((s) => typeof s == "string")
|
|
851
|
+
)
|
|
852
|
+
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
853
|
+
for (const [s, n] of this.activeBrowserToolCalls)
|
|
854
|
+
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
|
|
855
|
+
kt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
856
|
+
messages: ce(
|
|
830
857
|
this.state.messages,
|
|
831
858
|
e.clientMessageId,
|
|
832
859
|
e.runId
|
|
833
860
|
),
|
|
861
|
+
pendingMessageStatus: null,
|
|
834
862
|
isThinking: !1,
|
|
835
|
-
isRetrying: !1
|
|
836
|
-
|
|
863
|
+
isRetrying: !1,
|
|
864
|
+
lastError: null,
|
|
865
|
+
lastErrorCode: null,
|
|
866
|
+
lastErrorSecuritySettingsUrl: null
|
|
867
|
+
}), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.clearThinkingWatchdog();
|
|
837
868
|
}
|
|
838
869
|
startNewSession(e = {}) {
|
|
839
870
|
const s = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
|
|
@@ -841,7 +872,7 @@ class xt {
|
|
|
841
872
|
type: "session.reset",
|
|
842
873
|
sessionId: this.state.sessionId ?? void 0,
|
|
843
874
|
warmupId: n ?? void 0,
|
|
844
|
-
page:
|
|
875
|
+
page: k()
|
|
845
876
|
}), this.setState({
|
|
846
877
|
sessionId: null,
|
|
847
878
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -858,15 +889,15 @@ class xt {
|
|
|
858
889
|
});
|
|
859
890
|
}
|
|
860
891
|
listSessions(e = {}) {
|
|
861
|
-
const s =
|
|
892
|
+
const s = H(), n = new Promise((i, o) => {
|
|
862
893
|
const a = window.setTimeout(() => {
|
|
863
894
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
864
|
-
},
|
|
895
|
+
}, Tt);
|
|
865
896
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
866
897
|
}), r = {
|
|
867
898
|
type: "sessions.list",
|
|
868
899
|
requestId: s,
|
|
869
|
-
page:
|
|
900
|
+
page: k(),
|
|
870
901
|
...e.cursor ? { cursor: e.cursor } : {},
|
|
871
902
|
...e.limit ? { limit: e.limit } : {},
|
|
872
903
|
...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
|
|
@@ -880,14 +911,14 @@ class xt {
|
|
|
880
911
|
setSessionPinned(e, s) {
|
|
881
912
|
return this.sendSessionMutation(
|
|
882
913
|
this.pendingSessionPinRequests,
|
|
883
|
-
{ type: "session.pin", requestId:
|
|
914
|
+
{ type: "session.pin", requestId: H(), sessionId: e, pinned: s },
|
|
884
915
|
"Session pin did not respond in time"
|
|
885
916
|
);
|
|
886
917
|
}
|
|
887
918
|
renameSession(e, s) {
|
|
888
919
|
return this.sendSessionMutation(
|
|
889
920
|
this.pendingSessionRenameRequests,
|
|
890
|
-
{ type: "session.rename", requestId:
|
|
921
|
+
{ type: "session.rename", requestId: H(), sessionId: e, title: s },
|
|
891
922
|
"Session rename did not respond in time"
|
|
892
923
|
);
|
|
893
924
|
}
|
|
@@ -896,7 +927,7 @@ class xt {
|
|
|
896
927
|
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), s && this.send({
|
|
897
928
|
type: "session.reset",
|
|
898
929
|
warmupId: s,
|
|
899
|
-
page:
|
|
930
|
+
page: k()
|
|
900
931
|
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.setState({
|
|
901
932
|
sessionId: e,
|
|
902
933
|
assistantDraft: "",
|
|
@@ -912,13 +943,13 @@ class xt {
|
|
|
912
943
|
}), this.send({
|
|
913
944
|
type: "session.load",
|
|
914
945
|
sessionId: e,
|
|
915
|
-
page:
|
|
946
|
+
page: k()
|
|
916
947
|
});
|
|
917
948
|
}
|
|
918
949
|
send(e) {
|
|
919
|
-
this.sendNow(
|
|
950
|
+
this.sendNow(v(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
920
951
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
921
|
-
) || this.queuedClientEvents.push(e),
|
|
952
|
+
) || this.queuedClientEvents.push(e), $(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
922
953
|
status: "reconnecting",
|
|
923
954
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
924
955
|
}), this.scheduleReconnect());
|
|
@@ -934,9 +965,9 @@ class xt {
|
|
|
934
965
|
return !1;
|
|
935
966
|
const s = this.socket;
|
|
936
967
|
try {
|
|
937
|
-
return s.send(JSON.stringify(e)),
|
|
968
|
+
return s.send(JSON.stringify(e)), Pe("client_event", e.type, ht(e)), !0;
|
|
938
969
|
} catch (n) {
|
|
939
|
-
return
|
|
970
|
+
return R("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
940
971
|
message: n instanceof Error ? n.message : String(n),
|
|
941
972
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
942
973
|
isThinking: this.state.isThinking
|
|
@@ -944,35 +975,43 @@ class xt {
|
|
|
944
975
|
}
|
|
945
976
|
}
|
|
946
977
|
reportHealthSignal(e, s = {}) {
|
|
947
|
-
if (!
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
}));
|
|
962
|
-
} catch (n) {
|
|
963
|
-
M("web-sdk.agent", "Pluno health signal send failed", {
|
|
978
|
+
if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
|
|
979
|
+
return;
|
|
980
|
+
const n = s.clientMessageId ?? this.activeResponseRunId;
|
|
981
|
+
if (n) {
|
|
982
|
+
const r = `${e}:${n}`;
|
|
983
|
+
if (this.reportedHealthSignalKeys.has(r))
|
|
984
|
+
return;
|
|
985
|
+
this.reportedHealthSignalKeys.add(r);
|
|
986
|
+
}
|
|
987
|
+
try {
|
|
988
|
+
this.socket.send(JSON.stringify({
|
|
989
|
+
type: "runtime.health",
|
|
990
|
+
signal: {
|
|
991
|
+
id: crypto.randomUUID(),
|
|
964
992
|
name: e,
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
993
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
994
|
+
source: "web_sdk",
|
|
995
|
+
entrySurface: this.options.entrySurface,
|
|
996
|
+
...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
|
|
997
|
+
...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
|
|
998
|
+
...s
|
|
999
|
+
}
|
|
1000
|
+
}));
|
|
1001
|
+
} catch (r) {
|
|
1002
|
+
R("web-sdk.agent", "Pluno health signal send failed", {
|
|
1003
|
+
name: e,
|
|
1004
|
+
message: r instanceof Error ? r.message : String(r)
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
968
1007
|
}
|
|
969
1008
|
requestTransientStarterPrompts() {
|
|
970
1009
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
971
1010
|
return;
|
|
972
1011
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
973
|
-
const e =
|
|
1012
|
+
const e = Un();
|
|
974
1013
|
this.sendNow(
|
|
975
|
-
|
|
1014
|
+
v({
|
|
976
1015
|
type: "starter_prompts.page_context",
|
|
977
1016
|
pageUrl: e.pageUrl,
|
|
978
1017
|
pageTitle: e.pageTitle,
|
|
@@ -981,13 +1020,13 @@ class xt {
|
|
|
981
1020
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
982
1021
|
}
|
|
983
1022
|
startStarterPromptUrlWatcher() {
|
|
984
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
1023
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = Dn(() => this.handleStarterPromptUrlChange()));
|
|
985
1024
|
}
|
|
986
1025
|
handleStarterPromptUrlChange() {
|
|
987
1026
|
const e = location.href;
|
|
988
1027
|
e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
989
1028
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
990
|
-
},
|
|
1029
|
+
}, rn));
|
|
991
1030
|
}
|
|
992
1031
|
refreshStarterPromptsForCurrentUrl() {
|
|
993
1032
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -1002,14 +1041,14 @@ class xt {
|
|
|
1002
1041
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
1003
1042
|
return;
|
|
1004
1043
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
1005
|
-
|
|
1044
|
+
$(this.options.clientId, this.queuedClientEvents);
|
|
1006
1045
|
for (let s = 0; s < e.length; s += 1) {
|
|
1007
1046
|
const n = e[s];
|
|
1008
|
-
if (!this.sendNow(
|
|
1009
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1047
|
+
if (!this.sendNow(v(n))) {
|
|
1048
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), $(this.options.clientId, this.queuedClientEvents);
|
|
1010
1049
|
return;
|
|
1011
1050
|
}
|
|
1012
|
-
|
|
1051
|
+
$(this.options.clientId, this.queuedClientEvents);
|
|
1013
1052
|
}
|
|
1014
1053
|
}
|
|
1015
1054
|
flushPendingPassiveWarmup() {
|
|
@@ -1021,32 +1060,92 @@ class xt {
|
|
|
1021
1060
|
return;
|
|
1022
1061
|
this.clearPendingWarmupAckTimer();
|
|
1023
1062
|
const s = Math.min(
|
|
1024
|
-
|
|
1025
|
-
|
|
1063
|
+
Fs * 2 ** e.retryAttempt,
|
|
1064
|
+
zs
|
|
1026
1065
|
);
|
|
1027
1066
|
e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
|
|
1028
1067
|
this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
|
|
1029
1068
|
}, s);
|
|
1030
1069
|
}
|
|
1070
|
+
findStoppedTurn(e, s) {
|
|
1071
|
+
if (!e)
|
|
1072
|
+
return null;
|
|
1073
|
+
const n = typeof s.clientMessageId == "string" ? s.clientMessageId : null, r = typeof s.respondsToUserMessageId == "string" ? s.respondsToUserMessageId : null, i = typeof s.runId == "string" ? s.runId : null;
|
|
1074
|
+
return [...this.stoppedTurns].reverse().find((o) => o.sessionId !== e ? !1 : r && o.respondsToUserMessageId ? r === o.respondsToUserMessageId : n && o.clientMessageId ? n === o.clientMessageId : !!(i && o.runId && i === o.runId)) ?? null;
|
|
1075
|
+
}
|
|
1076
|
+
findStoppedTurnForEvent(e) {
|
|
1077
|
+
const s = e.type === "session.item" ? P(e.item) : null;
|
|
1078
|
+
return this.findStoppedTurn(
|
|
1079
|
+
oe(e) ?? this.state.sessionId,
|
|
1080
|
+
s ?? e
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
rememberDurablyStoppedTurn(e, s, n) {
|
|
1084
|
+
if (!e || !s || !xe(s) || this.findStoppedTurn(e, s))
|
|
1085
|
+
return;
|
|
1086
|
+
const r = O(s), i = U(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1087
|
+
this.stoppedTurns.push({
|
|
1088
|
+
sessionId: e,
|
|
1089
|
+
clientMessageId: o,
|
|
1090
|
+
respondsToUserMessageId: r,
|
|
1091
|
+
runId: i,
|
|
1092
|
+
stoppedAt: n,
|
|
1093
|
+
stoppedCausalSequence: N(s),
|
|
1094
|
+
toolCallIds: new Set(
|
|
1095
|
+
this.state.messages.filter(
|
|
1096
|
+
(a) => Oe(a, r, i)
|
|
1097
|
+
).map((a) => a.callId).filter((a) => typeof a == "string")
|
|
1098
|
+
)
|
|
1099
|
+
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
1100
|
+
}
|
|
1101
|
+
shouldIgnoreStoppedTurnEvent(e) {
|
|
1102
|
+
if (e.type === "tool.status") {
|
|
1103
|
+
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1104
|
+
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1105
|
+
}
|
|
1106
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !xe(P(e.item)) : e.type !== "conversation.state" : !1;
|
|
1107
|
+
}
|
|
1108
|
+
filterStoppedSnapshotItems(e, s) {
|
|
1109
|
+
return e.filter((n) => {
|
|
1110
|
+
const r = P(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1111
|
+
if (!i || r?.type === "message" && r.role === "user" || xe(r))
|
|
1112
|
+
return !0;
|
|
1113
|
+
if (i.stoppedCausalSequence !== null) {
|
|
1114
|
+
const o = r ? N(r) : null;
|
|
1115
|
+
return o === null || o <= i.stoppedCausalSequence;
|
|
1116
|
+
}
|
|
1117
|
+
if (i.stoppedAt) {
|
|
1118
|
+
const o = S(n, "createdAt");
|
|
1119
|
+
return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
|
|
1120
|
+
}
|
|
1121
|
+
return !1;
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1031
1124
|
handleServerEvent(e) {
|
|
1032
|
-
if (
|
|
1125
|
+
if (Pe("server_event", e.type, ht(e)), e.type === "session.item" && this.rememberDurablyStoppedTurn(
|
|
1126
|
+
S(e.item, "sessionId") ?? this.state.sessionId,
|
|
1127
|
+
P(e.item),
|
|
1128
|
+
S(e.item, "createdAt")
|
|
1129
|
+
), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1033
1130
|
if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
|
|
1034
1131
|
this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
|
|
1035
1132
|
return;
|
|
1036
1133
|
}
|
|
1037
1134
|
if (e.type === "run.ack") {
|
|
1038
|
-
|
|
1135
|
+
if (this.shouldIgnoreStoppedTurnEvent(e))
|
|
1136
|
+
return;
|
|
1137
|
+
const s = oe(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1039
1138
|
s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && (n === this.activeClientMessageId || n === this.pendingClientMessageId) && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(e);
|
|
1040
1139
|
return;
|
|
1041
1140
|
}
|
|
1042
1141
|
if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
1043
|
-
const s =
|
|
1142
|
+
const s = oe(e);
|
|
1044
1143
|
if (s) {
|
|
1045
1144
|
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1046
1145
|
return;
|
|
1047
1146
|
}
|
|
1048
1147
|
}
|
|
1049
|
-
if (!this.shouldIgnoreBackgroundSessionEvent(e)) {
|
|
1148
|
+
if (!this.shouldIgnoreBackgroundSessionEvent(e) && !this.shouldIgnoreStoppedTurnEvent(e)) {
|
|
1050
1149
|
if (e.type === "run.steered") {
|
|
1051
1150
|
this.handleRunSteered(e);
|
|
1052
1151
|
return;
|
|
@@ -1055,121 +1154,147 @@ class xt {
|
|
|
1055
1154
|
this.clearHeartbeatAckTimer();
|
|
1056
1155
|
return;
|
|
1057
1156
|
}
|
|
1058
|
-
if (
|
|
1157
|
+
if (e.type === "run.model_started") {
|
|
1158
|
+
const s = typeof e.runId == "string" ? e.runId : null;
|
|
1159
|
+
if (!this.state.isThinking || !s || this.activeResponseRunId && this.activeResponseRunId !== s)
|
|
1160
|
+
return;
|
|
1161
|
+
this.activeResponseRunId = s, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
if (un(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
1059
1165
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
1060
|
-
const s =
|
|
1061
|
-
|
|
1166
|
+
const s = $n(e), n = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1167
|
+
R("web-sdk.agent", "Received auth.ok appearance", {
|
|
1062
1168
|
hasAppearance: n,
|
|
1063
1169
|
rawAppearance: e.appearance,
|
|
1064
1170
|
normalizedAppearance: s
|
|
1065
|
-
}), this.runtimeHelperJavascript =
|
|
1066
|
-
const r =
|
|
1067
|
-
user:
|
|
1171
|
+
}), this.runtimeHelperJavascript = jn(e.runtimeHelpers)?.javascript ?? null;
|
|
1172
|
+
const r = Rt(e, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), o = e.starterPromptsLoading === !0, a = {
|
|
1173
|
+
user: Gn(e.user),
|
|
1068
1174
|
status: "connected",
|
|
1069
1175
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1070
1176
|
};
|
|
1071
|
-
(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 && !
|
|
1177
|
+
(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 && !ae() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1072
1178
|
type: "page.upsert",
|
|
1073
1179
|
sessionId: this.state.sessionId,
|
|
1074
|
-
page:
|
|
1180
|
+
page: k(),
|
|
1075
1181
|
model: this.options.model
|
|
1076
1182
|
});
|
|
1077
1183
|
return;
|
|
1078
1184
|
}
|
|
1079
1185
|
if (e.type === "starterPrompts.updated") {
|
|
1080
1186
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1081
|
-
starterPrompts:
|
|
1187
|
+
starterPrompts: Rt(e, "starterPrompts"),
|
|
1082
1188
|
starterPromptsLoading: !1
|
|
1083
1189
|
});
|
|
1084
1190
|
return;
|
|
1085
1191
|
}
|
|
1086
1192
|
if (e.type === "conversation.state") {
|
|
1087
|
-
const s = Array.isArray(e.items) ? e.items : [], n = e.
|
|
1088
|
-
|
|
1089
|
-
|
|
1193
|
+
const s = Array.isArray(e.items) ? e.items : [], n = S(e.session, "id") ?? this.state.sessionId;
|
|
1194
|
+
for (const E of s)
|
|
1195
|
+
this.rememberDurablyStoppedTurn(
|
|
1196
|
+
n,
|
|
1197
|
+
P(E),
|
|
1198
|
+
S(E, "createdAt")
|
|
1199
|
+
);
|
|
1200
|
+
const r = K(s), i = r === null ? null : s[r], o = P(i), a = this.findStoppedTurn(n, {
|
|
1201
|
+
clientMessageId: o?.clientMessageId,
|
|
1202
|
+
respondsToUserMessageId: S(i, "id"),
|
|
1203
|
+
runId: o?.runId
|
|
1204
|
+
}), l = this.filterStoppedSnapshotItems(s, n), c = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, p = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, g = e.isRetrying === !0, T = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1205
|
+
c && p && (this.pendingClientMessageId = p);
|
|
1206
|
+
let h = tr(
|
|
1090
1207
|
e.assistantDraft
|
|
1091
|
-
)
|
|
1092
|
-
this.
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1208
|
+
);
|
|
1209
|
+
h && this.findStoppedTurn(n, {
|
|
1210
|
+
respondsToUserMessageId: h.respondsToUserMessageId,
|
|
1211
|
+
runId: h.runId
|
|
1212
|
+
}) && (h = void 0);
|
|
1213
|
+
const u = h !== void 0;
|
|
1214
|
+
this.rememberUserMessageClientMessageIds(l);
|
|
1215
|
+
const d = mr(l);
|
|
1216
|
+
if (d) {
|
|
1217
|
+
const E = yr(l, d);
|
|
1218
|
+
this.retryAttemptsByClientMessageId[d] = Math.max(
|
|
1219
|
+
this.retryAttemptsByClientMessageId[d] ?? 0,
|
|
1220
|
+
E
|
|
1099
1221
|
);
|
|
1100
1222
|
}
|
|
1101
|
-
const
|
|
1102
|
-
const
|
|
1103
|
-
return
|
|
1104
|
-
}),
|
|
1223
|
+
const f = l.filter((E) => {
|
|
1224
|
+
const D = P(E);
|
|
1225
|
+
return Ct(D) ? !1 : !D || !d || !je(D) ? !0 : ze(l, D) !== d;
|
|
1226
|
+
}), I = cr(
|
|
1105
1227
|
this.state.messages,
|
|
1106
|
-
|
|
1107
|
-
),
|
|
1108
|
-
(
|
|
1109
|
-
|
|
1228
|
+
Xn(f, this.options.backendUrl)
|
|
1229
|
+
), w = Et(I), m = !u && l.some(
|
|
1230
|
+
(E) => bt(
|
|
1231
|
+
P(E),
|
|
1110
1232
|
this.state.assistantDraft,
|
|
1111
1233
|
this.state.assistantDraftItemId,
|
|
1112
1234
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1113
1235
|
this.state.assistantDraftRunId
|
|
1114
1236
|
)
|
|
1115
|
-
),
|
|
1116
|
-
if (!
|
|
1237
|
+
), b = u ? h?.content ?? "" : this.state.assistantDraft, B = !!h?.content, _ = w && (!b || m), M = hr(I), X = _ && M;
|
|
1238
|
+
if (!w && fr(this.state.messages, l))
|
|
1117
1239
|
return;
|
|
1118
|
-
this.lastUserMessagePageUrl =
|
|
1119
|
-
const
|
|
1120
|
-
if (this.latestRecoverableClientMessageId =
|
|
1121
|
-
sessionId:
|
|
1122
|
-
messages:
|
|
1123
|
-
...
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1240
|
+
this.lastUserMessagePageUrl = gr(l);
|
|
1241
|
+
const C = _ || a ? null : Fe(l);
|
|
1242
|
+
if (this.latestRecoverableClientMessageId = C, M && this.clearRetryTimers(), this.setState({
|
|
1243
|
+
sessionId: S(e.session, "id") ?? this.state.sessionId,
|
|
1244
|
+
messages: I,
|
|
1245
|
+
...c ? { pendingMessageStatus: c } : {},
|
|
1246
|
+
...T ? { turnPhase: T } : {},
|
|
1247
|
+
isRetrying: g,
|
|
1248
|
+
...u ? {
|
|
1249
|
+
assistantDraft: h?.content ?? "",
|
|
1250
|
+
assistantDraftItemId: h?.itemId ?? null,
|
|
1251
|
+
assistantDraftPhase: h?.phase ?? null,
|
|
1252
|
+
assistantDraftRespondsToUserMessageId: h?.respondsToUserMessageId ?? null,
|
|
1253
|
+
assistantDraftRunId: h?.runId ?? null
|
|
1254
|
+
} : m ? {
|
|
1132
1255
|
assistantDraft: "",
|
|
1133
1256
|
assistantDraftItemId: null,
|
|
1134
1257
|
assistantDraftPhase: null,
|
|
1135
1258
|
assistantDraftRespondsToUserMessageId: null,
|
|
1136
1259
|
assistantDraftRunId: null
|
|
1137
1260
|
} : {},
|
|
1138
|
-
...
|
|
1261
|
+
...B ? {
|
|
1139
1262
|
isThinking: !0,
|
|
1263
|
+
turnPhase: "thinking",
|
|
1140
1264
|
lastError: null
|
|
1141
|
-
} :
|
|
1265
|
+
} : _ ? {
|
|
1142
1266
|
isThinking: !1,
|
|
1143
|
-
...
|
|
1267
|
+
...X ? {
|
|
1144
1268
|
status: "connected",
|
|
1145
1269
|
lastError: null,
|
|
1146
1270
|
lastErrorCode: null,
|
|
1147
1271
|
lastErrorSecuritySettingsUrl: null
|
|
1148
1272
|
} : {}
|
|
1149
|
-
} :
|
|
1273
|
+
} : C ? {
|
|
1150
1274
|
isThinking: !0,
|
|
1275
|
+
turnPhase: T ?? this.state.turnPhase ?? "starting",
|
|
1151
1276
|
lastError: null
|
|
1152
1277
|
} : {}
|
|
1153
|
-
}),
|
|
1278
|
+
}), _)
|
|
1154
1279
|
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1155
|
-
else if (
|
|
1156
|
-
if (
|
|
1157
|
-
this.activeClientMessageId =
|
|
1158
|
-
const
|
|
1159
|
-
this.activeResponseUserMessageId =
|
|
1280
|
+
else if (!a && (B || C)) {
|
|
1281
|
+
if (C) {
|
|
1282
|
+
this.activeClientMessageId = C;
|
|
1283
|
+
const E = K(l), D = E === null ? null : l[E];
|
|
1284
|
+
this.activeResponseUserMessageId = S(D, "id");
|
|
1160
1285
|
}
|
|
1161
1286
|
this.markThinkingProgress();
|
|
1162
1287
|
}
|
|
1163
|
-
if (
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1288
|
+
if (d) {
|
|
1289
|
+
const E = S(e.session, "id") ?? this.state.sessionId;
|
|
1290
|
+
E && this.retryAfterInterruptedRun(E, d);
|
|
1166
1291
|
}
|
|
1167
1292
|
return;
|
|
1168
1293
|
}
|
|
1169
1294
|
if (e.type === "sessions.page") {
|
|
1170
1295
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1171
1296
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1172
|
-
sessions:
|
|
1297
|
+
sessions: Vn(e.sessions),
|
|
1173
1298
|
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1174
1299
|
}));
|
|
1175
1300
|
return;
|
|
@@ -1184,7 +1309,7 @@ class xt {
|
|
|
1184
1309
|
}
|
|
1185
1310
|
if (e.type === "session.updated") {
|
|
1186
1311
|
this.clearRunAckResyncRetryTimer();
|
|
1187
|
-
const s =
|
|
1312
|
+
const s = S(e.session, "id");
|
|
1188
1313
|
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1189
1314
|
...this.pendingComposerWarmup.event,
|
|
1190
1315
|
sessionId: s
|
|
@@ -1195,10 +1320,10 @@ class xt {
|
|
|
1195
1320
|
}
|
|
1196
1321
|
if (e.type === "session.item") {
|
|
1197
1322
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1198
|
-
const s =
|
|
1199
|
-
if (
|
|
1323
|
+
const s = P(e.item);
|
|
1324
|
+
if (je(s)) {
|
|
1200
1325
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1201
|
-
const r =
|
|
1326
|
+
const r = S(e.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1202
1327
|
if (r && a) {
|
|
1203
1328
|
this.retryAfterInterruptedRun(r, a);
|
|
1204
1329
|
return;
|
|
@@ -1208,21 +1333,21 @@ class xt {
|
|
|
1208
1333
|
return;
|
|
1209
1334
|
}
|
|
1210
1335
|
}
|
|
1211
|
-
if (
|
|
1336
|
+
if (Ct(s))
|
|
1212
1337
|
return;
|
|
1213
|
-
const n =
|
|
1338
|
+
const n = Ft(e.item, this.options.backendUrl);
|
|
1214
1339
|
if (n) {
|
|
1215
1340
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1216
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
1341
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), W(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1217
1342
|
const i = e.item.data;
|
|
1218
|
-
|
|
1219
|
-
const o =
|
|
1343
|
+
Tr(i) && this.clearRunAckResyncRetryTimer();
|
|
1344
|
+
const o = He(this.state.messages, n), a = Et(o), l = bt(
|
|
1220
1345
|
i,
|
|
1221
1346
|
this.state.assistantDraft,
|
|
1222
1347
|
this.state.assistantDraftItemId,
|
|
1223
1348
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1224
1349
|
this.state.assistantDraftRunId
|
|
1225
|
-
), c = a && (!this.state.assistantDraft || l), p =
|
|
1350
|
+
), c = a && (!this.state.assistantDraft || l), p = W(n) && (c || !this.state.isThinking && this.activeClientMessageId === null);
|
|
1226
1351
|
this.setState({
|
|
1227
1352
|
messages: o,
|
|
1228
1353
|
...l ? {
|
|
@@ -1248,9 +1373,9 @@ class xt {
|
|
|
1248
1373
|
}
|
|
1249
1374
|
if (e.type === "chat.assistant_delta") {
|
|
1250
1375
|
this.clearRunAckResyncRetryTimer();
|
|
1251
|
-
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.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((
|
|
1376
|
+
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.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((g) => g.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, p = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1252
1377
|
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = p), this.setState({
|
|
1253
|
-
messages:
|
|
1378
|
+
messages: He(this.state.messages, {
|
|
1254
1379
|
id: o,
|
|
1255
1380
|
role: "assistant",
|
|
1256
1381
|
content: i,
|
|
@@ -1278,9 +1403,9 @@ class xt {
|
|
|
1278
1403
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null;
|
|
1279
1404
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1280
1405
|
return;
|
|
1281
|
-
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l =
|
|
1406
|
+
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = Ss(
|
|
1282
1407
|
this.state.messages.filter(
|
|
1283
|
-
(c) => c.dataType !== "assistant_draft" || !
|
|
1408
|
+
(c) => c.dataType !== "assistant_draft" || !Oe(
|
|
1284
1409
|
c,
|
|
1285
1410
|
n,
|
|
1286
1411
|
r
|
|
@@ -1288,11 +1413,11 @@ class xt {
|
|
|
1288
1413
|
),
|
|
1289
1414
|
n,
|
|
1290
1415
|
r,
|
|
1291
|
-
|
|
1416
|
+
zt
|
|
1292
1417
|
);
|
|
1293
1418
|
this.setState({
|
|
1294
1419
|
sessionId: s,
|
|
1295
|
-
messages:
|
|
1420
|
+
messages: rr(
|
|
1296
1421
|
l,
|
|
1297
1422
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
1298
1423
|
n,
|
|
@@ -1314,9 +1439,9 @@ class xt {
|
|
|
1314
1439
|
if (s)
|
|
1315
1440
|
this.nonTranscriptToolCallIds.add(s);
|
|
1316
1441
|
else {
|
|
1317
|
-
const n =
|
|
1442
|
+
const n = ar(e);
|
|
1318
1443
|
if (n) {
|
|
1319
|
-
const r =
|
|
1444
|
+
const r = ir(
|
|
1320
1445
|
this.state.messages,
|
|
1321
1446
|
n
|
|
1322
1447
|
);
|
|
@@ -1369,9 +1494,9 @@ class xt {
|
|
|
1369
1494
|
return;
|
|
1370
1495
|
}
|
|
1371
1496
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1372
|
-
const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l =
|
|
1497
|
+
const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l = kn(a.message);
|
|
1373
1498
|
l && console.error(l), this.setState({
|
|
1374
|
-
messages:
|
|
1499
|
+
messages: ce(
|
|
1375
1500
|
this.state.messages,
|
|
1376
1501
|
i ?? this.activeClientMessageId,
|
|
1377
1502
|
typeof e.runId == "string" ? e.runId : null
|
|
@@ -1388,9 +1513,9 @@ class xt {
|
|
|
1388
1513
|
}
|
|
1389
1514
|
}
|
|
1390
1515
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1391
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1516
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !dn(e))
|
|
1392
1517
|
return !1;
|
|
1393
|
-
const s =
|
|
1518
|
+
const s = oe(e);
|
|
1394
1519
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1395
1520
|
}
|
|
1396
1521
|
rememberCurrentRunAsBackground() {
|
|
@@ -1400,7 +1525,7 @@ class xt {
|
|
|
1400
1525
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1401
1526
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1402
1527
|
return !1;
|
|
1403
|
-
if (
|
|
1528
|
+
if (ae())
|
|
1404
1529
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1405
1530
|
if (e.code === "run_still_active") {
|
|
1406
1531
|
if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
|
|
@@ -1414,10 +1539,10 @@ class xt {
|
|
|
1414
1539
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1415
1540
|
return !0;
|
|
1416
1541
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1417
|
-
if (i >=
|
|
1542
|
+
if (i >= Y)
|
|
1418
1543
|
return !1;
|
|
1419
1544
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1420
|
-
const o =
|
|
1545
|
+
const o = Q(
|
|
1421
1546
|
i,
|
|
1422
1547
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1423
1548
|
);
|
|
@@ -1431,20 +1556,20 @@ class xt {
|
|
|
1431
1556
|
}, o), !0;
|
|
1432
1557
|
}
|
|
1433
1558
|
retryAfterInterruptedRun(e, s) {
|
|
1434
|
-
if (
|
|
1559
|
+
if (ae()) {
|
|
1435
1560
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1436
1561
|
return;
|
|
1437
1562
|
}
|
|
1438
1563
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1439
1564
|
return;
|
|
1440
1565
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1441
|
-
if (n >=
|
|
1566
|
+
if (n >= Y) {
|
|
1442
1567
|
this.reportHealthSignal("run_recovery_exhausted", {
|
|
1443
1568
|
clientMessageId: s,
|
|
1444
1569
|
retryAttempts: n,
|
|
1445
1570
|
reason: "retry_budget_exhausted"
|
|
1446
1571
|
}), this.retryableClientMessageId = s, this.setState({
|
|
1447
|
-
messages:
|
|
1572
|
+
messages: ce(
|
|
1448
1573
|
this.state.messages,
|
|
1449
1574
|
s,
|
|
1450
1575
|
null
|
|
@@ -1458,7 +1583,7 @@ class xt {
|
|
|
1458
1583
|
}
|
|
1459
1584
|
this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
|
|
1460
1585
|
delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 });
|
|
1461
|
-
},
|
|
1586
|
+
}, Q(n));
|
|
1462
1587
|
}
|
|
1463
1588
|
clearRetryTimers() {
|
|
1464
1589
|
for (const e of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1467,10 +1592,10 @@ class xt {
|
|
|
1467
1592
|
}
|
|
1468
1593
|
rememberUserMessageClientMessageIds(e) {
|
|
1469
1594
|
for (const s of e) {
|
|
1470
|
-
const n =
|
|
1595
|
+
const n = S(s, "id"), r = P(s);
|
|
1471
1596
|
n && r?.type === "message" && r.role === "user" && r.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof r.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId), r.clientMessageId === this.pendingClientMessageId && this.promotePendingDelivery(
|
|
1472
1597
|
r.clientMessageId,
|
|
1473
|
-
|
|
1598
|
+
S(s, "sessionId") ?? this.state.sessionId,
|
|
1474
1599
|
n,
|
|
1475
1600
|
null
|
|
1476
1601
|
), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
|
|
@@ -1485,7 +1610,7 @@ class xt {
|
|
|
1485
1610
|
const r = new Promise((i, o) => {
|
|
1486
1611
|
const a = window.setTimeout(() => {
|
|
1487
1612
|
e.delete(s.requestId), o(new Error(n));
|
|
1488
|
-
},
|
|
1613
|
+
}, Tt);
|
|
1489
1614
|
e.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1490
1615
|
});
|
|
1491
1616
|
if (!this.sendNow(s)) {
|
|
@@ -1508,7 +1633,7 @@ class xt {
|
|
|
1508
1633
|
e.clear();
|
|
1509
1634
|
}
|
|
1510
1635
|
markThinkingProgress() {
|
|
1511
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1636
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(mt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1512
1637
|
}
|
|
1513
1638
|
scheduleThinkingWatchdog(e) {
|
|
1514
1639
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1543,6 +1668,7 @@ class xt {
|
|
|
1543
1668
|
this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.activeClientMessageId = e, this.activeResponseUserMessageId = n, this.activeResponseRunId = r, this.activeUserMessageEvent = i, this.latestRecoverableClientMessageId = e, this.setState({
|
|
1544
1669
|
sessionId: s ?? this.state.sessionId,
|
|
1545
1670
|
pendingMessageStatus: null,
|
|
1671
|
+
turnPhase: "starting",
|
|
1546
1672
|
status: "connected",
|
|
1547
1673
|
isThinking: !0,
|
|
1548
1674
|
isRetrying: !1,
|
|
@@ -1551,21 +1677,21 @@ class xt {
|
|
|
1551
1677
|
}), this.markThinkingProgress();
|
|
1552
1678
|
}
|
|
1553
1679
|
schedulePendingDeliveryAck(e) {
|
|
1554
|
-
this.clearPendingDeliveryTimers(), !
|
|
1680
|
+
this.clearPendingDeliveryTimers(), !ae() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
1555
1681
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
1556
|
-
},
|
|
1682
|
+
}, yt));
|
|
1557
1683
|
}
|
|
1558
1684
|
retryPendingDelivery(e) {
|
|
1559
1685
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
1560
1686
|
return;
|
|
1561
1687
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1562
|
-
if (s >=
|
|
1688
|
+
if (s >= Y) {
|
|
1563
1689
|
this.failPendingDelivery(e);
|
|
1564
1690
|
return;
|
|
1565
1691
|
}
|
|
1566
1692
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
1567
1693
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
1568
|
-
},
|
|
1694
|
+
}, Q(s, It));
|
|
1569
1695
|
}
|
|
1570
1696
|
failPendingDelivery(e) {
|
|
1571
1697
|
if (this.pendingClientMessageId !== e)
|
|
@@ -1573,8 +1699,10 @@ class xt {
|
|
|
1573
1699
|
const s = this.pendingUserMessageEvent;
|
|
1574
1700
|
this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = s, this.retryableClientMessageId = e, this.setState({
|
|
1575
1701
|
pendingMessageStatus: null,
|
|
1702
|
+
// A failed follow-up delivery must not hide an older acknowledged response that is still active.
|
|
1703
|
+
...this.state.isThinking ? {} : { turnPhase: null },
|
|
1576
1704
|
isRetrying: !1,
|
|
1577
|
-
lastError:
|
|
1705
|
+
lastError: Js,
|
|
1578
1706
|
lastErrorCode: "message_delivery_failed"
|
|
1579
1707
|
});
|
|
1580
1708
|
}
|
|
@@ -1589,7 +1717,7 @@ class xt {
|
|
|
1589
1717
|
s,
|
|
1590
1718
|
typeof e.runId == "string" ? e.runId : null
|
|
1591
1719
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
1592
|
-
messages:
|
|
1720
|
+
messages: Ar(
|
|
1593
1721
|
this.state.messages,
|
|
1594
1722
|
s
|
|
1595
1723
|
)
|
|
@@ -1598,10 +1726,10 @@ class xt {
|
|
|
1598
1726
|
scheduleRunAckWatchdog(e) {
|
|
1599
1727
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1600
1728
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
1601
|
-
},
|
|
1729
|
+
}, yt);
|
|
1602
1730
|
}
|
|
1603
1731
|
recoverMissedRunAck(e) {
|
|
1604
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (
|
|
1732
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (R("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
1605
1733
|
sessionId: this.state.sessionId,
|
|
1606
1734
|
clientMessageId: e
|
|
1607
1735
|
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(e));
|
|
@@ -1609,12 +1737,12 @@ class xt {
|
|
|
1609
1737
|
scheduleRunAckResyncRetry(e) {
|
|
1610
1738
|
this.clearRunAckResyncRetryTimer();
|
|
1611
1739
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1612
|
-
s >=
|
|
1740
|
+
s >= Y || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1613
1741
|
this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[e] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || this.latestRecoverableClientMessageId !== e || (this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({
|
|
1614
1742
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1615
1743
|
isThinking: !0,
|
|
1616
1744
|
lastError: null
|
|
1617
|
-
}),
|
|
1745
|
+
}), R("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
1618
1746
|
sessionId: this.state.sessionId,
|
|
1619
1747
|
clientMessageId: e
|
|
1620
1748
|
}), this.state.sessionId ? this.send({
|
|
@@ -1622,8 +1750,8 @@ class xt {
|
|
|
1622
1750
|
sessionId: this.state.sessionId,
|
|
1623
1751
|
clientMessageId: e,
|
|
1624
1752
|
automatic: !0
|
|
1625
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1626
|
-
},
|
|
1753
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(mt)));
|
|
1754
|
+
}, Q(s, It)));
|
|
1627
1755
|
}
|
|
1628
1756
|
clearRunAckResyncRetryTimer() {
|
|
1629
1757
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1636,7 +1764,7 @@ class xt {
|
|
|
1636
1764
|
return;
|
|
1637
1765
|
const e = this.activeClientMessageId;
|
|
1638
1766
|
if (!e) {
|
|
1639
|
-
|
|
1767
|
+
R("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
1640
1768
|
sessionId: this.state.sessionId
|
|
1641
1769
|
}), this.reportHealthSignal("run_recovery_exhausted", {
|
|
1642
1770
|
reason: "missing_client_message_id"
|
|
@@ -1648,8 +1776,8 @@ class xt {
|
|
|
1648
1776
|
return;
|
|
1649
1777
|
}
|
|
1650
1778
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1651
|
-
if (n >=
|
|
1652
|
-
|
|
1779
|
+
if (n >= Y) {
|
|
1780
|
+
R("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1653
1781
|
sessionId: this.state.sessionId,
|
|
1654
1782
|
clientMessageId: e
|
|
1655
1783
|
}), this.reportHealthSignal("run_recovery_exhausted", {
|
|
@@ -1657,7 +1785,7 @@ class xt {
|
|
|
1657
1785
|
retryAttempts: n,
|
|
1658
1786
|
reason: "retry_budget_exhausted"
|
|
1659
1787
|
}), this.retryableClientMessageId = e, this.setState({
|
|
1660
|
-
messages:
|
|
1788
|
+
messages: ce(
|
|
1661
1789
|
this.state.messages,
|
|
1662
1790
|
e,
|
|
1663
1791
|
null
|
|
@@ -1669,18 +1797,18 @@ class xt {
|
|
|
1669
1797
|
return;
|
|
1670
1798
|
}
|
|
1671
1799
|
if (s < 1) {
|
|
1672
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1,
|
|
1800
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1, R("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
1673
1801
|
sessionId: this.state.sessionId,
|
|
1674
1802
|
clientMessageId: e,
|
|
1675
1803
|
resyncAttempts: s + 1
|
|
1676
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1804
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Gs);
|
|
1677
1805
|
return;
|
|
1678
1806
|
}
|
|
1679
1807
|
this.setState({
|
|
1680
1808
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1681
1809
|
isThinking: !0,
|
|
1682
1810
|
lastError: null
|
|
1683
|
-
}),
|
|
1811
|
+
}), R("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
1684
1812
|
sessionId: this.state.sessionId,
|
|
1685
1813
|
clientMessageId: e,
|
|
1686
1814
|
retryAttempts: n + 1
|
|
@@ -1691,32 +1819,32 @@ class xt {
|
|
|
1691
1819
|
clientMessageId: e,
|
|
1692
1820
|
automatic: !0
|
|
1693
1821
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1694
|
-
},
|
|
1822
|
+
}, Q(n)));
|
|
1695
1823
|
}
|
|
1696
1824
|
resyncThinkingSession() {
|
|
1697
1825
|
this.state.sessionId ? this.send({
|
|
1698
1826
|
type: "page.upsert",
|
|
1699
1827
|
sessionId: this.state.sessionId,
|
|
1700
|
-
page:
|
|
1828
|
+
page: k(),
|
|
1701
1829
|
model: this.options.model
|
|
1702
1830
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1703
1831
|
}
|
|
1704
1832
|
async executeToolCall(e) {
|
|
1705
|
-
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i =
|
|
1833
|
+
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i = F(
|
|
1706
1834
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
1707
1835
|
), o = e.rawInput;
|
|
1708
1836
|
if (!s || !n || !r)
|
|
1709
1837
|
return;
|
|
1710
1838
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1711
|
-
if (!a && !l || !
|
|
1839
|
+
if (!a && !l || !jr(o)) {
|
|
1712
1840
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1713
1841
|
type: "tool.result",
|
|
1714
1842
|
sessionId: s,
|
|
1715
1843
|
callId: n,
|
|
1716
1844
|
toolName: r,
|
|
1717
1845
|
summary: i,
|
|
1718
|
-
rawInput:
|
|
1719
|
-
rawOutput:
|
|
1846
|
+
rawInput: v(o),
|
|
1847
|
+
rawOutput: v({
|
|
1720
1848
|
ok: !1,
|
|
1721
1849
|
toolName: r,
|
|
1722
1850
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -1731,7 +1859,7 @@ class xt {
|
|
|
1731
1859
|
callId: n,
|
|
1732
1860
|
toolName: r,
|
|
1733
1861
|
summary: i,
|
|
1734
|
-
rawInput:
|
|
1862
|
+
rawInput: v(o),
|
|
1735
1863
|
rawOutput: {
|
|
1736
1864
|
ok: !1,
|
|
1737
1865
|
toolName: r,
|
|
@@ -1747,7 +1875,7 @@ class xt {
|
|
|
1747
1875
|
callId: n,
|
|
1748
1876
|
toolName: r,
|
|
1749
1877
|
summary: i,
|
|
1750
|
-
rawInput:
|
|
1878
|
+
rawInput: v(o),
|
|
1751
1879
|
rawOutput: null
|
|
1752
1880
|
},
|
|
1753
1881
|
startedAtMs: Date.now(),
|
|
@@ -1755,26 +1883,26 @@ class xt {
|
|
|
1755
1883
|
startedAtOrigin: location.origin
|
|
1756
1884
|
}), this.installSessionBrowserApis();
|
|
1757
1885
|
let c = null, p;
|
|
1758
|
-
c = await this.executeRuntimeHelper(), p = await
|
|
1886
|
+
c = await this.executeRuntimeHelper(), p = await Mt(
|
|
1759
1887
|
o,
|
|
1760
|
-
|
|
1761
|
-
).catch((
|
|
1888
|
+
Rn(e.runtimeContext, this.options.backendUrl)
|
|
1889
|
+
).catch((g) => ({
|
|
1762
1890
|
ok: !1,
|
|
1763
1891
|
exception: {
|
|
1764
|
-
message:
|
|
1892
|
+
message: g instanceof Error ? g.message : String(g)
|
|
1765
1893
|
}
|
|
1766
|
-
})), this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
1894
|
+
})), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
1767
1895
|
type: "tool.result",
|
|
1768
1896
|
sessionId: s,
|
|
1769
1897
|
callId: n,
|
|
1770
1898
|
toolName: r,
|
|
1771
1899
|
summary: o.summary,
|
|
1772
|
-
rawInput:
|
|
1773
|
-
rawOutput:
|
|
1774
|
-
}),
|
|
1900
|
+
rawInput: v(o),
|
|
1901
|
+
rawOutput: v(Fn(p, c))
|
|
1902
|
+
}), kt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
1775
1903
|
}
|
|
1776
1904
|
setToolMessageLoading(e, s) {
|
|
1777
|
-
const n =
|
|
1905
|
+
const n = or(
|
|
1778
1906
|
this.state.messages,
|
|
1779
1907
|
e,
|
|
1780
1908
|
s
|
|
@@ -1785,50 +1913,50 @@ class xt {
|
|
|
1785
1913
|
if (this.pageLifecycleCleanup)
|
|
1786
1914
|
return;
|
|
1787
1915
|
const e = () => {
|
|
1788
|
-
|
|
1916
|
+
Jt(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1789
1917
|
};
|
|
1790
1918
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
1791
1919
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
1792
1920
|
};
|
|
1793
1921
|
}
|
|
1794
1922
|
installSessionBrowserApis() {
|
|
1795
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
1923
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = gn();
|
|
1796
1924
|
}
|
|
1797
1925
|
cleanupSessionBrowserApis() {
|
|
1798
|
-
this.sessionBrowserApisCleanup && (
|
|
1926
|
+
this.sessionBrowserApisCleanup && (Mn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
1799
1927
|
}
|
|
1800
1928
|
async executeRuntimeHelper() {
|
|
1801
1929
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1802
1930
|
return null;
|
|
1803
|
-
const e = await
|
|
1931
|
+
const e = await Mt({
|
|
1804
1932
|
javascript: this.runtimeHelperJavascript
|
|
1805
1933
|
});
|
|
1806
|
-
return e.ok === !1 ?
|
|
1934
|
+
return e.ok === !1 ? zn(e) : null;
|
|
1807
1935
|
}
|
|
1808
1936
|
enableNetworkCapture() {
|
|
1809
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1810
|
-
|
|
1937
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = ln((e) => {
|
|
1938
|
+
Vr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
1811
1939
|
}));
|
|
1812
1940
|
}
|
|
1813
1941
|
enqueueNetworkEvent(e) {
|
|
1814
|
-
this.queuedNetworkEvents.length >=
|
|
1942
|
+
this.queuedNetworkEvents.length >= Qs || (this.queuedNetworkEvents.push(Xr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1815
1943
|
this.networkBatchTimer = null;
|
|
1816
1944
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1817
1945
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
1818
1946
|
type: "network.batch",
|
|
1819
1947
|
sessionId: this.state.sessionId ?? void 0,
|
|
1820
|
-
page:
|
|
1948
|
+
page: k(),
|
|
1821
1949
|
events: s
|
|
1822
1950
|
});
|
|
1823
|
-
},
|
|
1951
|
+
}, Ys)));
|
|
1824
1952
|
}
|
|
1825
1953
|
scheduleReconnect() {
|
|
1826
1954
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1827
1955
|
return;
|
|
1828
|
-
const e =
|
|
1956
|
+
const e = on(this.reconnectAttempts);
|
|
1829
1957
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1830
1958
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1831
|
-
|
|
1959
|
+
R("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
1832
1960
|
message: s instanceof Error ? s.message : String(s),
|
|
1833
1961
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1834
1962
|
isThinking: this.state.isThinking
|
|
@@ -1840,9 +1968,9 @@ class xt {
|
|
|
1840
1968
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
1841
1969
|
const e = this.socket;
|
|
1842
1970
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1843
|
-
this.socket === e && (
|
|
1844
|
-
},
|
|
1845
|
-
},
|
|
1971
|
+
this.socket === e && (R("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
1972
|
+
}, Ws));
|
|
1973
|
+
}, qs);
|
|
1846
1974
|
}
|
|
1847
1975
|
stopHeartbeat() {
|
|
1848
1976
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1869,17 +1997,21 @@ class xt {
|
|
|
1869
1997
|
this.socket !== e || this.state.status === "closed" || (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.rememberBrowserConnectionInterruptionForActiveRun(), this.setReconnectingState(), this.scheduleReconnect(), e.readyState !== WebSocket.CLOSED && e.readyState !== WebSocket.CLOSING && e.close());
|
|
1870
1998
|
}
|
|
1871
1999
|
setState(e) {
|
|
1872
|
-
this.state =
|
|
2000
|
+
const s = e.isThinking ?? this.state.isThinking, n = e.pendingMessageStatus !== void 0 ? e.pendingMessageStatus : this.state.pendingMessageStatus;
|
|
2001
|
+
let r = e.turnPhase !== void 0 ? e.turnPhase : this.state.turnPhase;
|
|
2002
|
+
e.turnPhase === void 0 && (e.isThinking === !1 ? r = n ? "sending" : null : s && r === null ? r = "starting" : !s && n && r === null && (r = "sending")), this.state = {
|
|
1873
2003
|
...this.state,
|
|
1874
2004
|
...e,
|
|
2005
|
+
turnPhase: r,
|
|
1875
2006
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1876
2007
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1877
|
-
},
|
|
2008
|
+
}, Ur(this.options.clientId, this.state), this.emit("state", this.getState()), Pe("state", this.state.status, {
|
|
1878
2009
|
status: this.state.status,
|
|
1879
2010
|
sessionId: this.state.sessionId,
|
|
1880
2011
|
messageCount: this.state.messages.length,
|
|
1881
2012
|
assistantDraftLength: this.state.assistantDraft.length,
|
|
1882
2013
|
isThinking: this.state.isThinking,
|
|
2014
|
+
turnPhase: this.state.turnPhase,
|
|
1883
2015
|
hasError: this.state.lastError !== null
|
|
1884
2016
|
});
|
|
1885
2017
|
}
|
|
@@ -1894,61 +2026,61 @@ class xt {
|
|
|
1894
2026
|
this.state.isThinking && this.activeClientMessageId ? this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId) : this.pendingClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.pendingClientMessageId);
|
|
1895
2027
|
}
|
|
1896
2028
|
getRunRecoveryExhaustedErrorMessage(e) {
|
|
1897
|
-
return e && this.browserConnectionInterruptedClientMessageIds.has(e) ?
|
|
2029
|
+
return e && this.browserConnectionInterruptedClientMessageIds.has(e) ? Vs : Xs;
|
|
1898
2030
|
}
|
|
1899
2031
|
emit(e, s) {
|
|
1900
2032
|
this.listeners[e]?.forEach((r) => r(s));
|
|
1901
2033
|
}
|
|
1902
2034
|
}
|
|
1903
|
-
const
|
|
1904
|
-
function
|
|
1905
|
-
const e = window.__plunoProductAgentNetworkCapture ??
|
|
2035
|
+
const De = /* @__PURE__ */ new WeakMap();
|
|
2036
|
+
function ln(t) {
|
|
2037
|
+
const e = window.__plunoProductAgentNetworkCapture ?? cn();
|
|
1906
2038
|
return e.subscribers.add(t), () => {
|
|
1907
2039
|
e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
1908
2040
|
};
|
|
1909
2041
|
}
|
|
1910
|
-
function
|
|
1911
|
-
const t = /* @__PURE__ */ new Set(), e = (
|
|
1912
|
-
t.forEach((
|
|
2042
|
+
function cn() {
|
|
2043
|
+
const t = /* @__PURE__ */ new Set(), e = (T) => {
|
|
2044
|
+
t.forEach((h) => {
|
|
1913
2045
|
try {
|
|
1914
|
-
|
|
2046
|
+
h(T);
|
|
1915
2047
|
} catch {
|
|
1916
2048
|
}
|
|
1917
2049
|
});
|
|
1918
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(
|
|
2050
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(h, u) {
|
|
1919
2051
|
const d = Date.now();
|
|
1920
|
-
let
|
|
2052
|
+
let f;
|
|
1921
2053
|
try {
|
|
1922
|
-
|
|
1923
|
-
} catch (
|
|
1924
|
-
throw
|
|
2054
|
+
f = s.call(this, h, u);
|
|
2055
|
+
} catch (I) {
|
|
2056
|
+
throw I;
|
|
1925
2057
|
}
|
|
1926
2058
|
try {
|
|
1927
|
-
const
|
|
1928
|
-
if (!
|
|
1929
|
-
const
|
|
1930
|
-
requestId:
|
|
1931
|
-
url:
|
|
1932
|
-
method: (u?.method ??
|
|
1933
|
-
requestHeaders:
|
|
1934
|
-
requestBody:
|
|
2059
|
+
const I = h instanceof Request ? h : null, w = Fr(h, I), m = es(u?.headers ?? I?.headers);
|
|
2060
|
+
if (!j(w, m, u?.body)) {
|
|
2061
|
+
const B = {
|
|
2062
|
+
requestId: Le("fetch"),
|
|
2063
|
+
url: x(w, Ue),
|
|
2064
|
+
method: (u?.method ?? I?.method ?? "GET").toUpperCase(),
|
|
2065
|
+
requestHeaders: m,
|
|
2066
|
+
requestBody: Ut(u?.body),
|
|
1935
2067
|
resourceType: "fetch",
|
|
1936
2068
|
startedAt: new Date(d).toISOString()
|
|
1937
2069
|
};
|
|
1938
|
-
|
|
1939
|
-
(
|
|
1940
|
-
|
|
2070
|
+
f.then(
|
|
2071
|
+
(_) => {
|
|
2072
|
+
zr(_, B, d, e).catch(() => {
|
|
1941
2073
|
e({
|
|
1942
|
-
...
|
|
1943
|
-
responseStatus:
|
|
2074
|
+
...B,
|
|
2075
|
+
responseStatus: _.status,
|
|
1944
2076
|
durationMs: Date.now() - d
|
|
1945
2077
|
});
|
|
1946
2078
|
});
|
|
1947
2079
|
},
|
|
1948
|
-
(
|
|
2080
|
+
(_) => {
|
|
1949
2081
|
e({
|
|
1950
|
-
...
|
|
1951
|
-
errorText:
|
|
2082
|
+
...B,
|
|
2083
|
+
errorText: x(_ instanceof Error ? _.message : String(_)),
|
|
1952
2084
|
durationMs: Date.now() - d
|
|
1953
2085
|
});
|
|
1954
2086
|
}
|
|
@@ -1956,30 +2088,30 @@ function nn() {
|
|
|
1956
2088
|
}
|
|
1957
2089
|
} catch {
|
|
1958
2090
|
}
|
|
1959
|
-
return
|
|
1960
|
-
}, a = function(
|
|
1961
|
-
const
|
|
1962
|
-
return
|
|
1963
|
-
requestId:
|
|
1964
|
-
method: String(
|
|
1965
|
-
url:
|
|
2091
|
+
return f;
|
|
2092
|
+
}, a = function(h, u, d, f, I) {
|
|
2093
|
+
const w = n.call(this, h, u, d ?? !0, f ?? void 0, I ?? void 0), m = typeof u == "string" ? u : u.toString();
|
|
2094
|
+
return De.set(this, {
|
|
2095
|
+
requestId: Le("xhr"),
|
|
2096
|
+
method: String(h ?? "GET").toUpperCase(),
|
|
2097
|
+
url: x(m, Ue),
|
|
1966
2098
|
requestHeaders: {},
|
|
1967
2099
|
startedAtMs: Date.now(),
|
|
1968
2100
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1969
|
-
excluded:
|
|
1970
|
-
}),
|
|
1971
|
-
}, l = function(
|
|
1972
|
-
const d = r.call(this,
|
|
1973
|
-
return
|
|
1974
|
-
}, c = function(
|
|
2101
|
+
excluded: j(m)
|
|
2102
|
+
}), w;
|
|
2103
|
+
}, l = function(h, u) {
|
|
2104
|
+
const d = r.call(this, h, u), f = De.get(this);
|
|
2105
|
+
return f && Object.keys(f.requestHeaders).length < Qe && (f.requestHeaders[h] = st(h, u), f.excluded = f.excluded || j(f.url, f.requestHeaders)), d;
|
|
2106
|
+
}, c = function(h) {
|
|
1975
2107
|
try {
|
|
1976
|
-
const u =
|
|
1977
|
-
u && (u.excluded = u.excluded ||
|
|
2108
|
+
const u = De.get(this);
|
|
2109
|
+
u && (u.excluded = u.excluded || j(u.url, u.requestHeaders, h), u.requestBody = Ut(h), u.excluded || this.addEventListener(
|
|
1978
2110
|
"loadend",
|
|
1979
2111
|
() => {
|
|
1980
2112
|
queueMicrotask(() => {
|
|
1981
2113
|
try {
|
|
1982
|
-
const d =
|
|
2114
|
+
const d = Yr(this.getAllResponseHeaders());
|
|
1983
2115
|
e({
|
|
1984
2116
|
requestId: u.requestId,
|
|
1985
2117
|
url: u.url,
|
|
@@ -1989,7 +2121,7 @@ function nn() {
|
|
|
1989
2121
|
resourceType: "xhr",
|
|
1990
2122
|
responseStatus: this.status,
|
|
1991
2123
|
responseHeaders: d,
|
|
1992
|
-
responseBody:
|
|
2124
|
+
responseBody: Gr(this, d),
|
|
1993
2125
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1994
2126
|
startedAt: u.startedAt,
|
|
1995
2127
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -2003,7 +2135,7 @@ function nn() {
|
|
|
2003
2135
|
));
|
|
2004
2136
|
} catch {
|
|
2005
2137
|
}
|
|
2006
|
-
return i.call(this,
|
|
2138
|
+
return i.call(this, h ?? null);
|
|
2007
2139
|
};
|
|
2008
2140
|
try {
|
|
2009
2141
|
window.fetch = o;
|
|
@@ -2023,15 +2155,15 @@ function nn() {
|
|
|
2023
2155
|
}
|
|
2024
2156
|
let p = null;
|
|
2025
2157
|
if (typeof PerformanceObserver < "u") {
|
|
2026
|
-
p = new PerformanceObserver((
|
|
2027
|
-
for (const
|
|
2028
|
-
const u =
|
|
2029
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
2158
|
+
p = new PerformanceObserver((T) => {
|
|
2159
|
+
for (const h of T.getEntries()) {
|
|
2160
|
+
const u = h;
|
|
2161
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || j(u.name))
|
|
2030
2162
|
continue;
|
|
2031
2163
|
const d = performance.timeOrigin + u.startTime;
|
|
2032
2164
|
e({
|
|
2033
|
-
requestId:
|
|
2034
|
-
url:
|
|
2165
|
+
requestId: Le("resource"),
|
|
2166
|
+
url: x(u.name, Ue),
|
|
2035
2167
|
method: "GET",
|
|
2036
2168
|
resourceType: "resource",
|
|
2037
2169
|
responseStatus: u.responseStatus,
|
|
@@ -2046,7 +2178,7 @@ function nn() {
|
|
|
2046
2178
|
p.disconnect(), p = null;
|
|
2047
2179
|
}
|
|
2048
2180
|
}
|
|
2049
|
-
const
|
|
2181
|
+
const g = {
|
|
2050
2182
|
subscribers: t,
|
|
2051
2183
|
destroy: () => {
|
|
2052
2184
|
p?.disconnect();
|
|
@@ -2068,9 +2200,9 @@ function nn() {
|
|
|
2068
2200
|
}
|
|
2069
2201
|
}
|
|
2070
2202
|
};
|
|
2071
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
2203
|
+
return window.__plunoProductAgentNetworkCapture = g, g;
|
|
2072
2204
|
}
|
|
2073
|
-
function
|
|
2205
|
+
function R(t, e, s) {
|
|
2074
2206
|
if (typeof window > "u")
|
|
2075
2207
|
return;
|
|
2076
2208
|
const n = window, r = {
|
|
@@ -2081,17 +2213,17 @@ function M(t, e, s) {
|
|
|
2081
2213
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
2082
2214
|
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 }));
|
|
2083
2215
|
}
|
|
2084
|
-
function
|
|
2216
|
+
function St(t) {
|
|
2085
2217
|
const e = typeof t == "function" ? t() : t;
|
|
2086
2218
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2087
2219
|
}
|
|
2088
|
-
function
|
|
2089
|
-
return t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call";
|
|
2220
|
+
function un(t) {
|
|
2221
|
+
return t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call";
|
|
2090
2222
|
}
|
|
2091
|
-
function
|
|
2092
|
-
return t.type === "run.steered" || t.type === "run.ack" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
|
|
2223
|
+
function dn(t) {
|
|
2224
|
+
return t.type === "run.steered" || t.type === "run.ack" || t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
|
|
2093
2225
|
}
|
|
2094
|
-
function
|
|
2226
|
+
function oe(t) {
|
|
2095
2227
|
if (typeof t.sessionId == "string")
|
|
2096
2228
|
return t.sessionId;
|
|
2097
2229
|
if (t.session && typeof t.session == "object") {
|
|
@@ -2106,31 +2238,31 @@ function De(t) {
|
|
|
2106
2238
|
}
|
|
2107
2239
|
return null;
|
|
2108
2240
|
}
|
|
2109
|
-
const
|
|
2110
|
-
function
|
|
2241
|
+
const pn = 5e3, hn = 12e4;
|
|
2242
|
+
function gn() {
|
|
2111
2243
|
const t = [
|
|
2112
|
-
|
|
2113
|
-
|
|
2244
|
+
mn(),
|
|
2245
|
+
fn()
|
|
2114
2246
|
].filter((e) => typeof e == "function");
|
|
2115
2247
|
return () => {
|
|
2116
2248
|
for (const e of t.reverse())
|
|
2117
2249
|
e();
|
|
2118
2250
|
};
|
|
2119
2251
|
}
|
|
2120
|
-
function
|
|
2121
|
-
return
|
|
2252
|
+
function fn() {
|
|
2253
|
+
return vt(globalThis, "getPageSnapshot", async () => Ze());
|
|
2122
2254
|
}
|
|
2123
|
-
function
|
|
2124
|
-
return
|
|
2125
|
-
inspectImage: async (e, s) => await
|
|
2255
|
+
function mn() {
|
|
2256
|
+
return vt(globalThis, "pageImages", {
|
|
2257
|
+
inspectImage: async (e, s) => await yn(e, s)
|
|
2126
2258
|
});
|
|
2127
2259
|
}
|
|
2128
|
-
async function
|
|
2129
|
-
const s =
|
|
2260
|
+
async function yn(t, e = {}) {
|
|
2261
|
+
const s = Sn(e.name), n = await In(t);
|
|
2130
2262
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2131
2263
|
type: "pluno.pageImages.inspectImage",
|
|
2132
2264
|
imageAttached: !1,
|
|
2133
|
-
imageAttachmentError:
|
|
2265
|
+
imageAttachmentError: Lt
|
|
2134
2266
|
} : {
|
|
2135
2267
|
type: "pluno.pageImages.inspectImage",
|
|
2136
2268
|
imageAttached: !0,
|
|
@@ -2144,15 +2276,15 @@ async function pn(t, e = {}) {
|
|
|
2144
2276
|
imageAttachmentError: n.error
|
|
2145
2277
|
};
|
|
2146
2278
|
}
|
|
2147
|
-
async function
|
|
2148
|
-
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error:
|
|
2279
|
+
async function In(t) {
|
|
2280
|
+
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: Lt } : {
|
|
2149
2281
|
ok: !0,
|
|
2150
2282
|
mimeType: t.type,
|
|
2151
2283
|
sizeBytes: t.size,
|
|
2152
|
-
dataUrl: await
|
|
2153
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
2284
|
+
dataUrl: await An(t)
|
|
2285
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Tn(t);
|
|
2154
2286
|
}
|
|
2155
|
-
function
|
|
2287
|
+
function Tn(t) {
|
|
2156
2288
|
if (!t.startsWith("data:") || !t.includes(","))
|
|
2157
2289
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
2158
2290
|
const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -2163,7 +2295,7 @@ function gn(t) {
|
|
|
2163
2295
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
2164
2296
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
2165
2297
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
2166
|
-
const o =
|
|
2298
|
+
const o = wn(i);
|
|
2167
2299
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
2168
2300
|
ok: !0,
|
|
2169
2301
|
mimeType: r,
|
|
@@ -2171,22 +2303,22 @@ function gn(t) {
|
|
|
2171
2303
|
dataUrl: `data:${r};base64,${i}`
|
|
2172
2304
|
};
|
|
2173
2305
|
}
|
|
2174
|
-
function
|
|
2306
|
+
function wn(t) {
|
|
2175
2307
|
if (t.length === 0 || t.length % 4 !== 0)
|
|
2176
2308
|
return null;
|
|
2177
2309
|
const e = t.length - t.replace(/=+$/, "").length;
|
|
2178
2310
|
return e > 2 ? null : t.length / 4 * 3 - e;
|
|
2179
2311
|
}
|
|
2180
|
-
function
|
|
2312
|
+
function Sn(t) {
|
|
2181
2313
|
return (typeof t == "string" ? t.trim() : "") || "Page image";
|
|
2182
2314
|
}
|
|
2183
|
-
function
|
|
2315
|
+
function Mn(t) {
|
|
2184
2316
|
try {
|
|
2185
2317
|
t();
|
|
2186
2318
|
} catch {
|
|
2187
2319
|
}
|
|
2188
2320
|
}
|
|
2189
|
-
function
|
|
2321
|
+
function An(t) {
|
|
2190
2322
|
return new Promise((e, s) => {
|
|
2191
2323
|
const n = new FileReader();
|
|
2192
2324
|
n.onload = () => {
|
|
@@ -2198,9 +2330,9 @@ function In(t) {
|
|
|
2198
2330
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(t);
|
|
2199
2331
|
});
|
|
2200
2332
|
}
|
|
2201
|
-
async function
|
|
2333
|
+
async function Mt(t, e) {
|
|
2202
2334
|
const s = Object.getPrototypeOf(async function() {
|
|
2203
|
-
}).constructor, n = t.timeoutMs ??
|
|
2335
|
+
}).constructor, n = t.timeoutMs ?? pn, r = Date.now(), i = [];
|
|
2204
2336
|
let o;
|
|
2205
2337
|
const a = {
|
|
2206
2338
|
log: console.log,
|
|
@@ -2214,11 +2346,11 @@ async function wt(t, e) {
|
|
|
2214
2346
|
try {
|
|
2215
2347
|
const c = /* @__PURE__ */ Symbol("execute_code_timeout"), p = await Promise.race([
|
|
2216
2348
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
2217
|
-
new Promise((
|
|
2218
|
-
o = window.setTimeout(() =>
|
|
2349
|
+
new Promise((g) => {
|
|
2350
|
+
o = window.setTimeout(() => g(c), n);
|
|
2219
2351
|
})
|
|
2220
2352
|
]);
|
|
2221
|
-
return p === c ?
|
|
2353
|
+
return p === c ? En(n) : {
|
|
2222
2354
|
ok: !0,
|
|
2223
2355
|
result: p,
|
|
2224
2356
|
console: i,
|
|
@@ -2247,7 +2379,7 @@ async function wt(t, e) {
|
|
|
2247
2379
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2248
2380
|
}
|
|
2249
2381
|
}
|
|
2250
|
-
function
|
|
2382
|
+
function Rn(t, e) {
|
|
2251
2383
|
if (!t || typeof t != "object")
|
|
2252
2384
|
return;
|
|
2253
2385
|
const s = t.sandboxFilesToken;
|
|
@@ -2257,7 +2389,7 @@ function Tn(t, e) {
|
|
|
2257
2389
|
const r = () => {
|
|
2258
2390
|
if (!n)
|
|
2259
2391
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2260
|
-
}, i = async (a, l) => await
|
|
2392
|
+
}, i = async (a, l) => await Ds(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2261
2393
|
return {
|
|
2262
2394
|
value: Object.freeze({
|
|
2263
2395
|
upload: async (a) => {
|
|
@@ -2280,8 +2412,8 @@ function Tn(t, e) {
|
|
|
2280
2412
|
);
|
|
2281
2413
|
if (!l.ok)
|
|
2282
2414
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
2283
|
-
const c = await l.blob(),
|
|
2284
|
-
return new File([c],
|
|
2415
|
+
const c = await l.blob(), g = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
2416
|
+
return new File([c], g || a.split("/").pop() || "file", {
|
|
2285
2417
|
type: c.type
|
|
2286
2418
|
});
|
|
2287
2419
|
}
|
|
@@ -2291,7 +2423,7 @@ function Tn(t, e) {
|
|
|
2291
2423
|
}
|
|
2292
2424
|
};
|
|
2293
2425
|
}
|
|
2294
|
-
function
|
|
2426
|
+
function En(t) {
|
|
2295
2427
|
return {
|
|
2296
2428
|
ok: !1,
|
|
2297
2429
|
exception: {
|
|
@@ -2305,10 +2437,10 @@ function wn(t) {
|
|
|
2305
2437
|
}
|
|
2306
2438
|
};
|
|
2307
2439
|
}
|
|
2308
|
-
function
|
|
2440
|
+
function Cn(t) {
|
|
2309
2441
|
return t.replace(/\/+$/, "");
|
|
2310
2442
|
}
|
|
2311
|
-
function
|
|
2443
|
+
function bn(t) {
|
|
2312
2444
|
const e = {
|
|
2313
2445
|
sidepanel: "extension_sidepanel",
|
|
2314
2446
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2320,18 +2452,18 @@ function Mn(t) {
|
|
|
2320
2452
|
};
|
|
2321
2453
|
return t && t in e ? e[t] : t ?? "embedded_custom_ui";
|
|
2322
2454
|
}
|
|
2323
|
-
function
|
|
2455
|
+
function _n(t) {
|
|
2324
2456
|
return t === "pluno" ? "scheduled_continuation" : t ?? "user";
|
|
2325
2457
|
}
|
|
2326
|
-
function
|
|
2458
|
+
function kn(t, e = location.origin) {
|
|
2327
2459
|
return /origin (?:is not allowed|does not match browser origin)/i.test(t) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
|
|
2328
2460
|
}
|
|
2329
|
-
function
|
|
2461
|
+
function Pn(t) {
|
|
2330
2462
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2331
2463
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2332
2464
|
}
|
|
2333
|
-
function
|
|
2334
|
-
const t =
|
|
2465
|
+
function k() {
|
|
2466
|
+
const t = jt();
|
|
2335
2467
|
return {
|
|
2336
2468
|
url: location.href,
|
|
2337
2469
|
title: document.title,
|
|
@@ -2339,21 +2471,21 @@ function C() {
|
|
|
2339
2471
|
...t ? { plunoProductAgentUi: t } : {}
|
|
2340
2472
|
};
|
|
2341
2473
|
}
|
|
2342
|
-
function
|
|
2474
|
+
function Un() {
|
|
2343
2475
|
return {
|
|
2344
2476
|
pageUrl: location.href,
|
|
2345
2477
|
pageTitle: document.title,
|
|
2346
|
-
htmlContent:
|
|
2478
|
+
htmlContent: Ze()
|
|
2347
2479
|
};
|
|
2348
2480
|
}
|
|
2349
|
-
function
|
|
2350
|
-
return
|
|
2351
|
-
|
|
2481
|
+
function Dn(t) {
|
|
2482
|
+
return pe.add(t), ie || (ie = vn()), () => {
|
|
2483
|
+
pe.delete(t), pe.size === 0 && (ie?.(), ie = null);
|
|
2352
2484
|
};
|
|
2353
2485
|
}
|
|
2354
|
-
function
|
|
2486
|
+
function vn() {
|
|
2355
2487
|
const t = () => {
|
|
2356
|
-
for (const i of Array.from(
|
|
2488
|
+
for (const i of Array.from(pe))
|
|
2357
2489
|
i();
|
|
2358
2490
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2359
2491
|
const o = e(...i);
|
|
@@ -2366,38 +2498,38 @@ function _n() {
|
|
|
2366
2498
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2367
2499
|
};
|
|
2368
2500
|
}
|
|
2369
|
-
function
|
|
2370
|
-
return
|
|
2501
|
+
function ae() {
|
|
2502
|
+
return jt()?.surface === "browser_extension_sdk_preview";
|
|
2371
2503
|
}
|
|
2372
|
-
function
|
|
2504
|
+
function Ze() {
|
|
2373
2505
|
if (!document.body)
|
|
2374
2506
|
return "";
|
|
2375
|
-
const t = [], e = [], s = (d,
|
|
2376
|
-
const
|
|
2377
|
-
!
|
|
2507
|
+
const t = [], e = [], s = (d, f) => {
|
|
2508
|
+
const I = z(f);
|
|
2509
|
+
!I || e.includes(I) || (t.push([d, I]), e.push(I));
|
|
2378
2510
|
};
|
|
2379
2511
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2380
2512
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2381
|
-
(d) =>
|
|
2513
|
+
(d) => Wt(d) && !d.parentElement?.closest(n)
|
|
2382
2514
|
);
|
|
2383
2515
|
for (const d of r.slice(0, 3))
|
|
2384
|
-
s("Active overlay", ve(
|
|
2385
|
-
const i =
|
|
2386
|
-
s("Main page content", o), s("Additional visible page text", ve(
|
|
2387
|
-
const a = t.map(([d,
|
|
2388
|
-
${
|
|
2516
|
+
s("Active overlay", ve(Z(d), e));
|
|
2517
|
+
const i = Nn(), o = i ? ve(Z(i), e) : "";
|
|
2518
|
+
s("Main page content", o), s("Additional visible page text", ve(Z(document.body), e));
|
|
2519
|
+
const a = t.map(([d, f]) => `${d}:
|
|
2520
|
+
${f}`).join(`
|
|
2389
2521
|
|
|
2390
|
-
`).trim().slice(0, 12e3), l =
|
|
2522
|
+
`).trim().slice(0, 12e3), l = On(r, i).trim(), c = `Simplified DOM outline:
|
|
2391
2523
|
`, p = `
|
|
2392
2524
|
|
|
2393
2525
|
Visible page text:
|
|
2394
|
-
`,
|
|
2395
|
-
return `${c}${
|
|
2526
|
+
`, g = 12e3 - c.length - p.length, T = Math.min(a.length, 7900), h = l.slice(0, g - T), u = a.slice(0, g - h.length);
|
|
2527
|
+
return `${c}${h}${p}${u}`;
|
|
2396
2528
|
}
|
|
2397
|
-
function
|
|
2529
|
+
function Z(t) {
|
|
2398
2530
|
return t.innerText ?? t.textContent ?? "";
|
|
2399
2531
|
}
|
|
2400
|
-
function
|
|
2532
|
+
function z(t) {
|
|
2401
2533
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2402
2534
|
`).split(`
|
|
2403
2535
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2406,19 +2538,19 @@ function $(t) {
|
|
|
2406
2538
|
`).trim();
|
|
2407
2539
|
}
|
|
2408
2540
|
function ve(t, e) {
|
|
2409
|
-
let s =
|
|
2541
|
+
let s = z(t);
|
|
2410
2542
|
for (const n of e)
|
|
2411
2543
|
s = s.replace(n, "");
|
|
2412
|
-
return
|
|
2544
|
+
return z(s);
|
|
2413
2545
|
}
|
|
2414
|
-
function
|
|
2546
|
+
function Wt(t) {
|
|
2415
2547
|
const e = window.getComputedStyle(t);
|
|
2416
2548
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2417
2549
|
}
|
|
2418
|
-
function
|
|
2419
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2550
|
+
function Nn() {
|
|
2551
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Wt).sort((t, e) => Z(e).length - Z(t).length)[0] ?? null;
|
|
2420
2552
|
}
|
|
2421
|
-
function
|
|
2553
|
+
function On(t, e) {
|
|
2422
2554
|
const s = /* @__PURE__ */ new Set([
|
|
2423
2555
|
"main",
|
|
2424
2556
|
"nav",
|
|
@@ -2498,92 +2630,92 @@ function Pn(t, e) {
|
|
|
2498
2630
|
"data-test",
|
|
2499
2631
|
"data-qa",
|
|
2500
2632
|
"data-cy"
|
|
2501
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: p, priorityTargets:
|
|
2502
|
-
e &&
|
|
2503
|
-
let
|
|
2504
|
-
const u = (
|
|
2505
|
-
const
|
|
2506
|
-
return
|
|
2507
|
-
}, d = (
|
|
2508
|
-
const
|
|
2509
|
-
return `${
|
|
2510
|
-
},
|
|
2511
|
-
const
|
|
2512
|
-
const
|
|
2513
|
-
if (
|
|
2633
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: p, priorityTargets: g } = xn(), T = new Set(t);
|
|
2634
|
+
e && T.add(e);
|
|
2635
|
+
let h = 0;
|
|
2636
|
+
const u = (m) => {
|
|
2637
|
+
const b = m.getAttribute("role");
|
|
2638
|
+
return b && !o.has(b) ? b : "";
|
|
2639
|
+
}, d = (m) => {
|
|
2640
|
+
const b = m.getAttribute("data-testid") || m.getAttribute("data-test") || m.getAttribute("data-qa") || m.getAttribute("data-cy") || "";
|
|
2641
|
+
return `${m.tagName.toLowerCase()}|${u(m)}|${b}`;
|
|
2642
|
+
}, f = (m, b, B) => {
|
|
2643
|
+
const _ = (M, X) => {
|
|
2644
|
+
const C = M.tagName.toLowerCase(), E = window.getComputedStyle(M), D = p.has(M);
|
|
2645
|
+
if (h >= 1e3 && !D || B.has(M) || i.has(C) || M.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || E.display === "none" || E.visibility === "hidden")
|
|
2514
2646
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2515
|
-
|
|
2516
|
-
const
|
|
2517
|
-
for (const
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2647
|
+
h += 1;
|
|
2648
|
+
const nt = u(M), se = $t(M), ls = a.has(nt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(C) || C === "a" && M.hasAttribute("href"), Te = Array.from(M.children).filter((y) => y instanceof HTMLElement), ne = /* @__PURE__ */ new Map();
|
|
2649
|
+
for (const y of Te) {
|
|
2650
|
+
const A = d(y);
|
|
2651
|
+
ne.set(A, (ne.get(A) ?? 0) + 1);
|
|
2520
2652
|
}
|
|
2521
|
-
const
|
|
2522
|
-
for (const
|
|
2523
|
-
const
|
|
2524
|
-
|
|
2653
|
+
const we = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Map();
|
|
2654
|
+
for (const y of Te) {
|
|
2655
|
+
const A = d(y), q = rt.get(A) ?? 0;
|
|
2656
|
+
rt.set(A, q + 1), (ne.get(A) ?? 0) > 8 && q >= 6 && !p.has(y) && we.set(A, (we.get(A) ?? 0) + 1);
|
|
2525
2657
|
}
|
|
2526
|
-
const
|
|
2527
|
-
for (const
|
|
2528
|
-
const
|
|
2529
|
-
if (
|
|
2530
|
-
|
|
2658
|
+
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(), Se = [], at = [];
|
|
2659
|
+
for (const y of Te) {
|
|
2660
|
+
const A = d(y), q = ne.get(A) ?? 0, ut = it.get(A) ?? 0;
|
|
2661
|
+
if (it.set(A, ut + 1), q > 8 && ut >= 6 && !p.has(y)) {
|
|
2662
|
+
ot.has(A) || (Se.push([`… ${we.get(A) ?? 0} similar siblings omitted`]), ot.add(A));
|
|
2531
2663
|
continue;
|
|
2532
2664
|
}
|
|
2533
|
-
const
|
|
2534
|
-
|
|
2665
|
+
const dt = _(y, X);
|
|
2666
|
+
at.push(dt), Se.push(dt.lines);
|
|
2535
2667
|
}
|
|
2536
|
-
const
|
|
2537
|
-
if (
|
|
2538
|
-
for (const
|
|
2539
|
-
|
|
2540
|
-
const
|
|
2541
|
-
[
|
|
2542
|
-
).slice(0, 180),
|
|
2543
|
-
if (
|
|
2544
|
-
const
|
|
2545
|
-
|
|
2668
|
+
const Me = [];
|
|
2669
|
+
if (M.shadowRoot)
|
|
2670
|
+
for (const y of Array.from(M.shadowRoot.children))
|
|
2671
|
+
y instanceof HTMLElement && Me.push(_(y, X + 1));
|
|
2672
|
+
const re = [...at, ...Me], Ae = se.length > 0 || ls || re.some((y) => y.hasUsefulContent), lt = z(
|
|
2673
|
+
[se, ...re.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2674
|
+
).slice(0, 180), cs = M.hasAttribute("contenteditable") && (se.length > 0 || !M.querySelector("[contenteditable]")), ct = c.some((y) => M.hasAttribute(y)) || !!nt || cs, Re = (M.getClientRects().length > 0 || E.display === "contents") && (s.has(C) || ct || D) && (Ae || D) && (!r.has(C) || Ae || ct || D), Ee = Re ? 1 : 0, V = [];
|
|
2675
|
+
if (Re) {
|
|
2676
|
+
const y = re.some((q) => q.containsTextElement), A = n.has(C) && !y ? lt : se;
|
|
2677
|
+
V.push(Ht(M, l, o, A.slice(0, 180)));
|
|
2546
2678
|
}
|
|
2547
|
-
for (const
|
|
2548
|
-
|
|
2549
|
-
const
|
|
2550
|
-
if (
|
|
2551
|
-
const
|
|
2552
|
-
|
|
2553
|
-
const
|
|
2554
|
-
if (
|
|
2555
|
-
const
|
|
2556
|
-
|
|
2679
|
+
for (const y of Se)
|
|
2680
|
+
V.push(...le(y, Ee));
|
|
2681
|
+
const Ce = Me.flatMap((y) => y.lines);
|
|
2682
|
+
if (Ce.length > 0) {
|
|
2683
|
+
const y = Ce.slice(0, 20);
|
|
2684
|
+
Ce.length > y.length && y.push("… shadow DOM omitted");
|
|
2685
|
+
const A = C.includes("tooltip") || C.includes("popper") || C.includes("loader");
|
|
2686
|
+
if (X < 2 && !A) {
|
|
2687
|
+
const q = Re ? "#shadow-root" : `${C} #shadow-root`;
|
|
2688
|
+
V.push(...le([q, ...le(y, 1)], Ee));
|
|
2557
2689
|
} else
|
|
2558
|
-
|
|
2690
|
+
V.push(...le(y, Ee));
|
|
2559
2691
|
}
|
|
2560
2692
|
return {
|
|
2561
|
-
lines:
|
|
2562
|
-
hasUsefulContent:
|
|
2563
|
-
textPreview:
|
|
2564
|
-
containsTextElement: n.has(
|
|
2693
|
+
lines: V,
|
|
2694
|
+
hasUsefulContent: Ae,
|
|
2695
|
+
textPreview: lt,
|
|
2696
|
+
containsTextElement: n.has(C) || re.some((y) => y.containsTextElement)
|
|
2565
2697
|
};
|
|
2566
2698
|
};
|
|
2567
|
-
return [`--- ${
|
|
2699
|
+
return [`--- ${b} ---`, ..._(m, 0).lines].join(`
|
|
2568
2700
|
`);
|
|
2569
|
-
},
|
|
2570
|
-
|
|
2571
|
-
${JSON.stringify(
|
|
2572
|
-
for (const
|
|
2573
|
-
|
|
2574
|
-
if (e &&
|
|
2575
|
-
const
|
|
2576
|
-
|
|
2577
|
-
}
|
|
2578
|
-
return
|
|
2701
|
+
}, I = [], w = z(window.getSelection()?.toString() ?? "");
|
|
2702
|
+
w && I.push(`--- selected text ---
|
|
2703
|
+
${JSON.stringify(w)}`), g.length > 0 && I.push(Ln(g, s, l, o));
|
|
2704
|
+
for (const m of t.slice(0, 3))
|
|
2705
|
+
I.push(f(m, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2706
|
+
if (e && I.push(f(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
2707
|
+
const m = e || t.length ? "other visible DOM" : "visible DOM";
|
|
2708
|
+
I.push(f(document.body, m, T));
|
|
2709
|
+
}
|
|
2710
|
+
return I.join(`
|
|
2579
2711
|
|
|
2580
2712
|
`);
|
|
2581
2713
|
}
|
|
2582
|
-
function
|
|
2714
|
+
function Ht(t, e, s, n) {
|
|
2583
2715
|
const r = t.tagName.toLowerCase();
|
|
2584
2716
|
let i = r;
|
|
2585
2717
|
const o = t.getAttribute("id");
|
|
2586
|
-
o &&
|
|
2718
|
+
o && Bn(o) && (i += `#${o}`);
|
|
2587
2719
|
for (const a of e) {
|
|
2588
2720
|
const l = t.getAttribute(a);
|
|
2589
2721
|
l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
|
|
@@ -2596,7 +2728,7 @@ function qt(t, e, s, n) {
|
|
|
2596
2728
|
t.hasAttribute(a) && (i += `[${a}]`);
|
|
2597
2729
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2598
2730
|
}
|
|
2599
|
-
function
|
|
2731
|
+
function xn() {
|
|
2600
2732
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
|
|
2601
2733
|
if (!a)
|
|
2602
2734
|
return;
|
|
@@ -2605,11 +2737,11 @@ function Un() {
|
|
|
2605
2737
|
return;
|
|
2606
2738
|
const p = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
2607
2739
|
p.add(l), e.set(a, p);
|
|
2608
|
-
let
|
|
2609
|
-
for (;
|
|
2610
|
-
t.add(
|
|
2611
|
-
const
|
|
2612
|
-
|
|
2740
|
+
let g = a;
|
|
2741
|
+
for (; g; ) {
|
|
2742
|
+
t.add(g);
|
|
2743
|
+
const T = g.getRootNode();
|
|
2744
|
+
g = g.parentElement ?? (T instanceof ShadowRoot && T.host instanceof HTMLElement ? T.host : null);
|
|
2613
2745
|
}
|
|
2614
2746
|
};
|
|
2615
2747
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -2617,7 +2749,7 @@ function Un() {
|
|
|
2617
2749
|
n = n.shadowRoot.activeElement;
|
|
2618
2750
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2619
2751
|
const r = window.getSelection();
|
|
2620
|
-
r && !r.isCollapsed && (s(
|
|
2752
|
+
r && !r.isCollapsed && (s(At(r.anchorNode), "selected text"), s(At(r.focusNode), "selected text"));
|
|
2621
2753
|
const i = [
|
|
2622
2754
|
["[aria-selected='true']", "selected"],
|
|
2623
2755
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2629,8 +2761,8 @@ function Un() {
|
|
|
2629
2761
|
for (let a = 0; a < o.length; a += 1) {
|
|
2630
2762
|
const l = o[a];
|
|
2631
2763
|
for (const [c, p] of i)
|
|
2632
|
-
for (const
|
|
2633
|
-
s(
|
|
2764
|
+
for (const g of Array.from(l.querySelectorAll(c)))
|
|
2765
|
+
s(g, p);
|
|
2634
2766
|
for (const c of Array.from(l.querySelectorAll("*")))
|
|
2635
2767
|
c.shadowRoot && o.push(c.shadowRoot);
|
|
2636
2768
|
}
|
|
@@ -2639,7 +2771,7 @@ function Un() {
|
|
|
2639
2771
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
2640
2772
|
};
|
|
2641
2773
|
}
|
|
2642
|
-
function
|
|
2774
|
+
function Ln(t, e, s, n) {
|
|
2643
2775
|
const r = ["--- active/current elements ---"];
|
|
2644
2776
|
for (const i of t) {
|
|
2645
2777
|
const o = [];
|
|
@@ -2647,40 +2779,40 @@ function Dn(t, e, s, n) {
|
|
|
2647
2779
|
for (; a; ) {
|
|
2648
2780
|
const p = a.tagName.toLowerCase();
|
|
2649
2781
|
(a === i.element || e.has(p) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
2650
|
-
const
|
|
2651
|
-
a = a.parentElement ?? (
|
|
2782
|
+
const g = a.getRootNode();
|
|
2783
|
+
a = a.parentElement ?? (g instanceof ShadowRoot && g.host instanceof HTMLElement ? g.host : null);
|
|
2652
2784
|
}
|
|
2653
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((p,
|
|
2785
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((p, g) => Ht(
|
|
2654
2786
|
p,
|
|
2655
2787
|
s,
|
|
2656
2788
|
n,
|
|
2657
|
-
|
|
2789
|
+
g === l.length - 1 ? $t(p).slice(0, 180) : ""
|
|
2658
2790
|
));
|
|
2659
2791
|
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
2660
2792
|
}
|
|
2661
2793
|
return r.join(`
|
|
2662
2794
|
`);
|
|
2663
2795
|
}
|
|
2664
|
-
function
|
|
2796
|
+
function At(t) {
|
|
2665
2797
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
2666
2798
|
}
|
|
2667
|
-
function
|
|
2799
|
+
function le(t, e) {
|
|
2668
2800
|
if (e === 0)
|
|
2669
2801
|
return t;
|
|
2670
2802
|
const s = " ".repeat(e);
|
|
2671
2803
|
return t.map((n) => `${s}${n}`);
|
|
2672
2804
|
}
|
|
2673
|
-
function
|
|
2674
|
-
return
|
|
2805
|
+
function $t(t) {
|
|
2806
|
+
return z(
|
|
2675
2807
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
2676
2808
|
);
|
|
2677
2809
|
}
|
|
2678
|
-
function
|
|
2810
|
+
function Bn(t) {
|
|
2679
2811
|
return t.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(t) && !/[a-f0-9]{12,}/i.test(t) && !/:r[0-9a-z]+:/i.test(t);
|
|
2680
2812
|
}
|
|
2681
|
-
function
|
|
2682
|
-
const t = document.querySelector(
|
|
2683
|
-
if (!(t ?? document.querySelector(
|
|
2813
|
+
function jt() {
|
|
2814
|
+
const t = document.querySelector(pt);
|
|
2815
|
+
if (!(t ?? document.querySelector(qe)))
|
|
2684
2816
|
return;
|
|
2685
2817
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2686
2818
|
return {
|
|
@@ -2689,28 +2821,28 @@ function Wt() {
|
|
|
2689
2821
|
selectors: [
|
|
2690
2822
|
{
|
|
2691
2823
|
name: "widget_host",
|
|
2692
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2824
|
+
selector: s === "browser_extension_sdk_preview" ? pt : qe,
|
|
2693
2825
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2694
2826
|
},
|
|
2695
2827
|
{
|
|
2696
2828
|
name: "widget_root",
|
|
2697
|
-
selector:
|
|
2829
|
+
selector: vs,
|
|
2698
2830
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2699
2831
|
},
|
|
2700
2832
|
{
|
|
2701
2833
|
name: "widget_panel",
|
|
2702
|
-
selector:
|
|
2834
|
+
selector: Ns,
|
|
2703
2835
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2704
2836
|
},
|
|
2705
2837
|
{
|
|
2706
2838
|
name: "widget_timeline",
|
|
2707
|
-
selector:
|
|
2839
|
+
selector: Os,
|
|
2708
2840
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2709
2841
|
}
|
|
2710
2842
|
]
|
|
2711
2843
|
};
|
|
2712
2844
|
}
|
|
2713
|
-
function
|
|
2845
|
+
function qn(t) {
|
|
2714
2846
|
try {
|
|
2715
2847
|
const e = JSON.parse(t);
|
|
2716
2848
|
return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
|
|
@@ -2718,7 +2850,7 @@ function Nn(t) {
|
|
|
2718
2850
|
return { type: "error", message: "Invalid server event" };
|
|
2719
2851
|
}
|
|
2720
2852
|
}
|
|
2721
|
-
function
|
|
2853
|
+
function Wn(t) {
|
|
2722
2854
|
if (typeof t != "string")
|
|
2723
2855
|
return null;
|
|
2724
2856
|
try {
|
|
@@ -2728,16 +2860,16 @@ function On(t) {
|
|
|
2728
2860
|
return null;
|
|
2729
2861
|
}
|
|
2730
2862
|
}
|
|
2731
|
-
function
|
|
2863
|
+
function Rt(t, e) {
|
|
2732
2864
|
if (!t || typeof t != "object")
|
|
2733
2865
|
return [];
|
|
2734
2866
|
const s = t[e];
|
|
2735
2867
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2736
2868
|
}
|
|
2737
|
-
function
|
|
2869
|
+
function Hn(t) {
|
|
2738
2870
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
2739
2871
|
}
|
|
2740
|
-
function
|
|
2872
|
+
function $n(t) {
|
|
2741
2873
|
if (!t || typeof t != "object")
|
|
2742
2874
|
return null;
|
|
2743
2875
|
const e = t, s = e.appearance, n = s && typeof s == "object" ? s : e, 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;
|
|
@@ -2748,13 +2880,13 @@ function Ln(t) {
|
|
|
2748
2880
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2749
2881
|
};
|
|
2750
2882
|
}
|
|
2751
|
-
function
|
|
2883
|
+
function jn(t) {
|
|
2752
2884
|
if (!t || typeof t != "object")
|
|
2753
2885
|
return null;
|
|
2754
2886
|
const e = t.javascript;
|
|
2755
2887
|
return typeof e != "string" || !e.trim() ? null : { javascript: e };
|
|
2756
2888
|
}
|
|
2757
|
-
function
|
|
2889
|
+
function Fn(t, e) {
|
|
2758
2890
|
return e ? t && typeof t == "object" ? {
|
|
2759
2891
|
...t,
|
|
2760
2892
|
helperError: e
|
|
@@ -2764,23 +2896,23 @@ function Bn(t, e) {
|
|
|
2764
2896
|
helperError: e
|
|
2765
2897
|
} : t;
|
|
2766
2898
|
}
|
|
2767
|
-
function
|
|
2899
|
+
function zn(t) {
|
|
2768
2900
|
if (!t || typeof t != "object")
|
|
2769
2901
|
return t;
|
|
2770
2902
|
const e = t;
|
|
2771
2903
|
return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : t;
|
|
2772
2904
|
}
|
|
2773
|
-
function
|
|
2905
|
+
function Kn() {
|
|
2774
2906
|
const t = "pluno.productAgent.clientId", e = window.localStorage.getItem(t);
|
|
2775
2907
|
if (e)
|
|
2776
2908
|
return e;
|
|
2777
2909
|
const s = crypto.randomUUID();
|
|
2778
2910
|
return window.localStorage.setItem(t, s), s;
|
|
2779
2911
|
}
|
|
2780
|
-
function
|
|
2912
|
+
function H() {
|
|
2781
2913
|
return crypto.randomUUID();
|
|
2782
2914
|
}
|
|
2783
|
-
function
|
|
2915
|
+
function Gn(t) {
|
|
2784
2916
|
if (!t || typeof t != "object")
|
|
2785
2917
|
return null;
|
|
2786
2918
|
const e = t, s = typeof e.id == "string" ? e.id : null;
|
|
@@ -2791,22 +2923,22 @@ function $n(t) {
|
|
|
2791
2923
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
2792
2924
|
} : null;
|
|
2793
2925
|
}
|
|
2794
|
-
function
|
|
2795
|
-
return Array.isArray(t) ?
|
|
2796
|
-
t.map((s) =>
|
|
2926
|
+
function Xn(t, e) {
|
|
2927
|
+
return Array.isArray(t) ? Ke(
|
|
2928
|
+
t.map((s) => Ft(s, e)).filter((s) => s !== null)
|
|
2797
2929
|
) : [];
|
|
2798
2930
|
}
|
|
2799
|
-
function
|
|
2931
|
+
function Vn(t) {
|
|
2800
2932
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
2801
2933
|
if (!e || typeof e != "object")
|
|
2802
2934
|
return [];
|
|
2803
|
-
const s = e, n =
|
|
2935
|
+
const s = e, n = S(s, "id"), r = S(s, "createdAt"), i = S(s, "updatedAt"), o = S(s, "lastActiveAt");
|
|
2804
2936
|
return !n || !r || !i || !o ? [] : [
|
|
2805
2937
|
{
|
|
2806
2938
|
id: n,
|
|
2807
|
-
title:
|
|
2808
|
-
customTitle:
|
|
2809
|
-
firstUserMessage:
|
|
2939
|
+
title: S(s, "title"),
|
|
2940
|
+
customTitle: S(s, "customTitle"),
|
|
2941
|
+
firstUserMessage: S(s, "firstUserMessage"),
|
|
2810
2942
|
currentPage: s.currentPage ?? null,
|
|
2811
2943
|
createdAt: r,
|
|
2812
2944
|
updatedAt: i,
|
|
@@ -2817,29 +2949,29 @@ function Fn(t) {
|
|
|
2817
2949
|
];
|
|
2818
2950
|
}) : [];
|
|
2819
2951
|
}
|
|
2820
|
-
function
|
|
2952
|
+
function Ft(t, e) {
|
|
2821
2953
|
if (!t || typeof t != "object")
|
|
2822
2954
|
return null;
|
|
2823
2955
|
const s = t, n = s.data;
|
|
2824
2956
|
if (!n || typeof n != "object")
|
|
2825
2957
|
return null;
|
|
2826
2958
|
const r = n;
|
|
2827
|
-
if (r.hiddenFromTranscript === !0 || r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
2959
|
+
if (r.hiddenFromTranscript === !0 || Ts(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
2828
2960
|
return null;
|
|
2829
2961
|
if (r.type === "message") {
|
|
2830
2962
|
const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
|
|
2831
2963
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2832
2964
|
role: i,
|
|
2833
2965
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2834
|
-
content:
|
|
2835
|
-
|
|
2966
|
+
content: ys(
|
|
2967
|
+
sr(r.content),
|
|
2836
2968
|
e
|
|
2837
2969
|
),
|
|
2838
2970
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2839
2971
|
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2840
2972
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2841
|
-
...
|
|
2842
|
-
attachments:
|
|
2973
|
+
...U(r) ? { runId: U(r) } : {},
|
|
2974
|
+
attachments: Yt(r.attachments, e)
|
|
2843
2975
|
};
|
|
2844
2976
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2845
2977
|
value: r.id,
|
|
@@ -2850,7 +2982,7 @@ function Ht(t, e) {
|
|
|
2850
2982
|
}), o;
|
|
2851
2983
|
}
|
|
2852
2984
|
if (r.type === "function_call_output") {
|
|
2853
|
-
const i =
|
|
2985
|
+
const i = Us(r.output);
|
|
2854
2986
|
if (i)
|
|
2855
2987
|
return {
|
|
2856
2988
|
id: String(s.id ?? crypto.randomUUID()),
|
|
@@ -2858,13 +2990,13 @@ function Ht(t, e) {
|
|
|
2858
2990
|
content: "",
|
|
2859
2991
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2860
2992
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2861
|
-
...
|
|
2993
|
+
...U(r) ? { runId: U(r) } : {},
|
|
2862
2994
|
dataType: "scheduled_check_in",
|
|
2863
|
-
toolName:
|
|
2995
|
+
toolName: Ot,
|
|
2864
2996
|
callId: Ne(r) ?? void 0,
|
|
2865
2997
|
scheduledCheckInAt: i
|
|
2866
2998
|
};
|
|
2867
|
-
const o =
|
|
2999
|
+
const o = Yn(r.output);
|
|
2868
3000
|
return o ? {
|
|
2869
3001
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2870
3002
|
role: "tool",
|
|
@@ -2872,7 +3004,7 @@ function Ht(t, e) {
|
|
|
2872
3004
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2873
3005
|
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2874
3006
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2875
|
-
...
|
|
3007
|
+
...U(r) ? { runId: U(r) } : {},
|
|
2876
3008
|
dataType: "function_call_output",
|
|
2877
3009
|
toolName: "authenticate_pipedream_app",
|
|
2878
3010
|
callId: Ne(r) ?? void 0,
|
|
@@ -2882,11 +3014,11 @@ function Ht(t, e) {
|
|
|
2882
3014
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2883
3015
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2884
3016
|
role: "tool",
|
|
2885
|
-
content: r.type === "mcp_call" ?
|
|
3017
|
+
content: r.type === "mcp_call" ? Jn(r) : Zn(r),
|
|
2886
3018
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2887
3019
|
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2888
3020
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2889
|
-
...
|
|
3021
|
+
...U(r) ? { runId: U(r) } : {},
|
|
2890
3022
|
dataType: String(r.type),
|
|
2891
3023
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2892
3024
|
callId: Ne(r) ?? void 0,
|
|
@@ -2894,11 +3026,11 @@ function Ht(t, e) {
|
|
|
2894
3026
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2895
3027
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2896
3028
|
role: "system",
|
|
2897
|
-
content:
|
|
3029
|
+
content: Qn(r),
|
|
2898
3030
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2899
3031
|
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2900
3032
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
2901
|
-
...
|
|
3033
|
+
...U(r) ? { runId: U(r) } : {},
|
|
2902
3034
|
dataType: String(r.type),
|
|
2903
3035
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
2904
3036
|
...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
|
|
@@ -2906,11 +3038,11 @@ function Ht(t, e) {
|
|
|
2906
3038
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2907
3039
|
} : null;
|
|
2908
3040
|
}
|
|
2909
|
-
function
|
|
3041
|
+
function Jn(t) {
|
|
2910
3042
|
const s = (typeof t.server_label == "string" ? t.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
2911
3043
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2912
3044
|
}
|
|
2913
|
-
function
|
|
3045
|
+
function Yn(t) {
|
|
2914
3046
|
if (typeof t != "string")
|
|
2915
3047
|
return null;
|
|
2916
3048
|
try {
|
|
@@ -2927,10 +3059,10 @@ function Kn(t) {
|
|
|
2927
3059
|
return null;
|
|
2928
3060
|
}
|
|
2929
3061
|
}
|
|
2930
|
-
function
|
|
3062
|
+
function Qn(t) {
|
|
2931
3063
|
return t.type === "run_status" && t.status === "stopped" ? "Run stopped by user" : t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message.replace(/Product Agent/g, "Pluno") : t.type === "run_status" && t.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
|
|
2932
3064
|
}
|
|
2933
|
-
function
|
|
3065
|
+
function Zn(t) {
|
|
2934
3066
|
if (t.type === "web_search_call") {
|
|
2935
3067
|
const e = t.action;
|
|
2936
3068
|
if (e && typeof e == "object") {
|
|
@@ -2942,26 +3074,26 @@ function Xn(t) {
|
|
|
2942
3074
|
}
|
|
2943
3075
|
return "🔎 Searching the web";
|
|
2944
3076
|
}
|
|
2945
|
-
return
|
|
3077
|
+
return er(t);
|
|
2946
3078
|
}
|
|
2947
|
-
function
|
|
3079
|
+
function er(t) {
|
|
2948
3080
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
2949
|
-
return
|
|
3081
|
+
return F(t.summary);
|
|
2950
3082
|
if (typeof t.arguments == "string")
|
|
2951
3083
|
try {
|
|
2952
3084
|
const e = JSON.parse(t.arguments);
|
|
2953
3085
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2954
|
-
return
|
|
3086
|
+
return F(e.summary);
|
|
2955
3087
|
} catch {
|
|
2956
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3088
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? F(t.name) : "🛠️ Run tool";
|
|
2957
3089
|
}
|
|
2958
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3090
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? F(t.name) : "🛠️ Run tool";
|
|
2959
3091
|
}
|
|
2960
|
-
function
|
|
3092
|
+
function F(t) {
|
|
2961
3093
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
2962
3094
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
2963
3095
|
}
|
|
2964
|
-
function
|
|
3096
|
+
function tr(t) {
|
|
2965
3097
|
if (t == null)
|
|
2966
3098
|
return t;
|
|
2967
3099
|
if (typeof t != "object")
|
|
@@ -2983,7 +3115,7 @@ function Ne(t) {
|
|
|
2983
3115
|
function N(t) {
|
|
2984
3116
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
2985
3117
|
}
|
|
2986
|
-
function
|
|
3118
|
+
function sr(t) {
|
|
2987
3119
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
2988
3120
|
if (!e || typeof e != "object")
|
|
2989
3121
|
return "";
|
|
@@ -2991,31 +3123,31 @@ function Yn(t) {
|
|
|
2991
3123
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2992
3124
|
}).filter(Boolean).join("") : "";
|
|
2993
3125
|
}
|
|
2994
|
-
function
|
|
2995
|
-
const s =
|
|
2996
|
-
|
|
2997
|
-
|
|
3126
|
+
function He(t, e) {
|
|
3127
|
+
const s = Kt(t, e), n = lr(
|
|
3128
|
+
nr(
|
|
3129
|
+
pr(t, e),
|
|
2998
3130
|
s
|
|
2999
3131
|
),
|
|
3000
3132
|
s
|
|
3001
3133
|
), r = n.findIndex((o) => o.id === s.id);
|
|
3002
3134
|
if (r === -1)
|
|
3003
|
-
return
|
|
3135
|
+
return Ke(
|
|
3004
3136
|
[...n, s]
|
|
3005
3137
|
);
|
|
3006
3138
|
const i = [...n];
|
|
3007
|
-
return i[r] = s,
|
|
3139
|
+
return i[r] = s, Ke(i);
|
|
3008
3140
|
}
|
|
3009
|
-
function
|
|
3141
|
+
function nr(t, e) {
|
|
3010
3142
|
const s = e.assistantDraftItemId;
|
|
3011
3143
|
return s ? t.map(
|
|
3012
3144
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
3013
3145
|
) : t;
|
|
3014
3146
|
}
|
|
3015
|
-
function
|
|
3147
|
+
function Oe(t, e, s) {
|
|
3016
3148
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3017
3149
|
}
|
|
3018
|
-
function
|
|
3150
|
+
function rr(t, e, s, n) {
|
|
3019
3151
|
if (s === null) return t;
|
|
3020
3152
|
let r = -1;
|
|
3021
3153
|
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
@@ -3032,12 +3164,12 @@ function er(t, e, s, n) {
|
|
|
3032
3164
|
respondsToUserMessageId: s
|
|
3033
3165
|
}, i;
|
|
3034
3166
|
}
|
|
3035
|
-
function
|
|
3167
|
+
function ir(t, e) {
|
|
3036
3168
|
const s = t.findIndex(
|
|
3037
3169
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3038
3170
|
);
|
|
3039
3171
|
if (s === -1)
|
|
3040
|
-
return
|
|
3172
|
+
return He(t, e);
|
|
3041
3173
|
const n = [...t];
|
|
3042
3174
|
return n[s] = {
|
|
3043
3175
|
...n[s],
|
|
@@ -3049,19 +3181,19 @@ function tr(t, e) {
|
|
|
3049
3181
|
...n[s].runId ? {} : { runId: e.runId }
|
|
3050
3182
|
}, n;
|
|
3051
3183
|
}
|
|
3052
|
-
function
|
|
3184
|
+
function or(t, e, s) {
|
|
3053
3185
|
let n = !1;
|
|
3054
3186
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
3055
3187
|
return n ? r : t;
|
|
3056
3188
|
}
|
|
3057
|
-
function
|
|
3189
|
+
function ar(t) {
|
|
3058
3190
|
if (t.hiddenFromTranscript === !0)
|
|
3059
3191
|
return null;
|
|
3060
3192
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
3061
3193
|
return !e || !s ? null : {
|
|
3062
3194
|
id: `transient-activity:${e}`,
|
|
3063
3195
|
role: "tool",
|
|
3064
|
-
content:
|
|
3196
|
+
content: F(
|
|
3065
3197
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3066
3198
|
),
|
|
3067
3199
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3074,7 +3206,7 @@ function nr(t) {
|
|
|
3074
3206
|
loading: !0
|
|
3075
3207
|
};
|
|
3076
3208
|
}
|
|
3077
|
-
function
|
|
3209
|
+
function lr(t, e) {
|
|
3078
3210
|
if (e.id.startsWith("transient-activity:"))
|
|
3079
3211
|
return t;
|
|
3080
3212
|
const s = e.toolName === "tab_lifecycle";
|
|
@@ -3083,17 +3215,17 @@ function rr(t, e) {
|
|
|
3083
3215
|
const n = (i) => i.id === `transient-activity:${e.callId}` && i.callId === e.callId || s && i.id.startsWith("transient-activity:") && i.toolName === "browser_tabs" && !!i.runId && i.runId === e.runId, r = t.findIndex(n);
|
|
3084
3216
|
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
3085
3217
|
}
|
|
3086
|
-
function
|
|
3087
|
-
return
|
|
3218
|
+
function cr(t, e) {
|
|
3219
|
+
return ws(
|
|
3088
3220
|
t,
|
|
3089
3221
|
e.map(
|
|
3090
|
-
(s) =>
|
|
3222
|
+
(s) => Kt(t, s)
|
|
3091
3223
|
),
|
|
3092
|
-
|
|
3224
|
+
zt
|
|
3093
3225
|
);
|
|
3094
3226
|
}
|
|
3095
|
-
function
|
|
3096
|
-
const e =
|
|
3227
|
+
function zt(t) {
|
|
3228
|
+
const e = ee(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3097
3229
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3098
3230
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3099
3231
|
];
|
|
@@ -3104,52 +3236,52 @@ function $t(t) {
|
|
|
3104
3236
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3105
3237
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3106
3238
|
...t.runId ? { runId: t.runId } : {},
|
|
3107
|
-
isOptimistic:
|
|
3239
|
+
isOptimistic: ye(t),
|
|
3108
3240
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3109
3241
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3110
3242
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3111
3243
|
};
|
|
3112
3244
|
}
|
|
3113
|
-
function
|
|
3245
|
+
function Kt(t, e) {
|
|
3114
3246
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3115
3247
|
return e;
|
|
3116
3248
|
const s = t.find(
|
|
3117
|
-
(r) => r.role === "user" && (r.id === e.id ||
|
|
3249
|
+
(r) => r.role === "user" && (r.id === e.id || ye(r) && Gt(r, e))
|
|
3118
3250
|
);
|
|
3119
3251
|
if (!s?.attachments?.length)
|
|
3120
3252
|
return e;
|
|
3121
3253
|
const n = e.attachments.map((r) => {
|
|
3122
|
-
const i =
|
|
3123
|
-
return i ?
|
|
3254
|
+
const i = ur(s.attachments ?? [], r);
|
|
3255
|
+
return i ? dr(r, i) : r;
|
|
3124
3256
|
});
|
|
3125
3257
|
return { ...e, attachments: n };
|
|
3126
3258
|
}
|
|
3127
|
-
function
|
|
3259
|
+
function ur(t, e) {
|
|
3128
3260
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
3129
3261
|
}
|
|
3130
|
-
function
|
|
3262
|
+
function dr(t, e) {
|
|
3131
3263
|
const { previewUrl: s } = e;
|
|
3132
3264
|
return s ? { ...t, previewUrl: s } : t;
|
|
3133
3265
|
}
|
|
3134
|
-
function
|
|
3266
|
+
function pr(t, e) {
|
|
3135
3267
|
if (e.role !== "user")
|
|
3136
3268
|
return t;
|
|
3137
3269
|
const s = t.findIndex(
|
|
3138
|
-
(r) =>
|
|
3270
|
+
(r) => ye(r) && Gt(r, e)
|
|
3139
3271
|
);
|
|
3140
3272
|
if (s === -1)
|
|
3141
3273
|
return t;
|
|
3142
3274
|
const n = [...t];
|
|
3143
3275
|
return n.splice(s, 1), n;
|
|
3144
3276
|
}
|
|
3145
|
-
function
|
|
3146
|
-
const s =
|
|
3277
|
+
function Gt(t, e) {
|
|
3278
|
+
const s = ee(t), n = ee(e);
|
|
3147
3279
|
return s && n ? s === n : t.content === e.content;
|
|
3148
3280
|
}
|
|
3149
|
-
function
|
|
3281
|
+
function ye(t) {
|
|
3150
3282
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3151
3283
|
}
|
|
3152
|
-
function
|
|
3284
|
+
function ee(t) {
|
|
3153
3285
|
const e = t.clientMessageId;
|
|
3154
3286
|
if (e)
|
|
3155
3287
|
return e;
|
|
@@ -3158,18 +3290,18 @@ function J(t) {
|
|
|
3158
3290
|
);
|
|
3159
3291
|
return n ? t.id.slice(n.length) : null;
|
|
3160
3292
|
}
|
|
3161
|
-
function
|
|
3162
|
-
const e =
|
|
3293
|
+
function Et(t) {
|
|
3294
|
+
const e = Xt(t);
|
|
3163
3295
|
if (e === null)
|
|
3164
3296
|
return !1;
|
|
3165
3297
|
const s = t[e].id, n = t.some(
|
|
3166
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3298
|
+
(r) => r.respondsToUserMessageId === s && $e(r)
|
|
3167
3299
|
);
|
|
3168
3300
|
if (t.some((r) => r.respondsToUserMessageId === s))
|
|
3169
3301
|
return n;
|
|
3170
3302
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3171
3303
|
const i = t[r];
|
|
3172
|
-
if (
|
|
3304
|
+
if (W(i))
|
|
3173
3305
|
return !0;
|
|
3174
3306
|
if (i.role === "system") {
|
|
3175
3307
|
if (i.dataType === "run_error")
|
|
@@ -3180,25 +3312,25 @@ function At(t) {
|
|
|
3180
3312
|
}
|
|
3181
3313
|
return !1;
|
|
3182
3314
|
}
|
|
3183
|
-
function
|
|
3184
|
-
const e =
|
|
3315
|
+
function hr(t) {
|
|
3316
|
+
const e = Xt(t);
|
|
3185
3317
|
if (e === null)
|
|
3186
|
-
return t.some(
|
|
3318
|
+
return t.some(W);
|
|
3187
3319
|
const s = t[e].id;
|
|
3188
3320
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3189
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3190
|
-
) : t.slice(e + 1).some(
|
|
3321
|
+
(n) => n.respondsToUserMessageId === s && W(n)
|
|
3322
|
+
) : t.slice(e + 1).some(W);
|
|
3191
3323
|
}
|
|
3192
|
-
function
|
|
3324
|
+
function Xt(t) {
|
|
3193
3325
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3194
|
-
if (t[e].role === "user" && !
|
|
3326
|
+
if (t[e].role === "user" && !ye(t[e]))
|
|
3195
3327
|
return e;
|
|
3196
3328
|
return null;
|
|
3197
3329
|
}
|
|
3198
|
-
function
|
|
3199
|
-
return
|
|
3330
|
+
function $e(t) {
|
|
3331
|
+
return W(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3200
3332
|
}
|
|
3201
|
-
function
|
|
3333
|
+
function K(t) {
|
|
3202
3334
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
3203
3335
|
const s = t[e];
|
|
3204
3336
|
if (!s || typeof s != "object")
|
|
@@ -3212,30 +3344,30 @@ function Y(t) {
|
|
|
3212
3344
|
}
|
|
3213
3345
|
return null;
|
|
3214
3346
|
}
|
|
3215
|
-
function
|
|
3216
|
-
const e =
|
|
3347
|
+
function gr(t) {
|
|
3348
|
+
const e = K(t);
|
|
3217
3349
|
if (e === null)
|
|
3218
3350
|
return null;
|
|
3219
|
-
const n =
|
|
3351
|
+
const n = P(t[e])?.page;
|
|
3220
3352
|
if (!n || typeof n != "object")
|
|
3221
3353
|
return null;
|
|
3222
3354
|
const r = n.url;
|
|
3223
3355
|
return typeof r == "string" ? r : null;
|
|
3224
3356
|
}
|
|
3225
|
-
function
|
|
3357
|
+
function P(t) {
|
|
3226
3358
|
if (!t || typeof t != "object")
|
|
3227
3359
|
return null;
|
|
3228
3360
|
const e = t.data;
|
|
3229
3361
|
return e && typeof e == "object" ? e : null;
|
|
3230
3362
|
}
|
|
3231
|
-
function
|
|
3363
|
+
function je(t) {
|
|
3232
3364
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3233
3365
|
}
|
|
3234
|
-
function
|
|
3366
|
+
function Ct(t) {
|
|
3235
3367
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3236
3368
|
}
|
|
3237
|
-
function
|
|
3238
|
-
const s =
|
|
3369
|
+
function fr(t, e) {
|
|
3370
|
+
const s = K(e);
|
|
3239
3371
|
if (s === null)
|
|
3240
3372
|
return !1;
|
|
3241
3373
|
const n = e[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -3243,11 +3375,11 @@ function dr(t, e) {
|
|
|
3243
3375
|
return !1;
|
|
3244
3376
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3245
3377
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3246
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3247
|
-
) : t.slice(i + 1).some(
|
|
3378
|
+
(o) => o.respondsToUserMessageId === r && $e(o)
|
|
3379
|
+
) : t.slice(i + 1).some($e);
|
|
3248
3380
|
}
|
|
3249
|
-
function
|
|
3250
|
-
const e =
|
|
3381
|
+
function Fe(t) {
|
|
3382
|
+
const e = K(t);
|
|
3251
3383
|
if (e === null)
|
|
3252
3384
|
return null;
|
|
3253
3385
|
const s = t[e];
|
|
@@ -3259,8 +3391,8 @@ function $e(t) {
|
|
|
3259
3391
|
const r = n.clientMessageId;
|
|
3260
3392
|
return typeof r == "string" ? r : null;
|
|
3261
3393
|
}
|
|
3262
|
-
function
|
|
3263
|
-
const e =
|
|
3394
|
+
function mr(t) {
|
|
3395
|
+
const e = K(t);
|
|
3264
3396
|
if (e === null)
|
|
3265
3397
|
return null;
|
|
3266
3398
|
for (let s = t.length - 1; s > e; s -= 1) {
|
|
@@ -3274,22 +3406,22 @@ function pr(t) {
|
|
|
3274
3406
|
if (i.type === "message" && i.role === "assistant")
|
|
3275
3407
|
return null;
|
|
3276
3408
|
if (i.type === "run_error")
|
|
3277
|
-
return i.retryable !== !0 ? null :
|
|
3409
|
+
return i.retryable !== !0 ? null : ze(t, i) ?? Fe(t);
|
|
3278
3410
|
if (i.type === "run_status")
|
|
3279
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3411
|
+
return i.status === "interrupted" && i.retryable === !0 ? ze(t, i) ?? Fe(t) : null;
|
|
3280
3412
|
}
|
|
3281
3413
|
return null;
|
|
3282
3414
|
}
|
|
3283
|
-
function
|
|
3415
|
+
function ze(t, e) {
|
|
3284
3416
|
if (typeof e.clientMessageId == "string")
|
|
3285
3417
|
return e.clientMessageId;
|
|
3286
3418
|
const s = O(e);
|
|
3287
3419
|
if (!s)
|
|
3288
3420
|
return null;
|
|
3289
|
-
const n = t.find((i) =>
|
|
3421
|
+
const n = t.find((i) => S(i, "id") === s), r = P(n);
|
|
3290
3422
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3291
3423
|
}
|
|
3292
|
-
function
|
|
3424
|
+
function yr(t, e) {
|
|
3293
3425
|
let s = 0;
|
|
3294
3426
|
for (const n of t) {
|
|
3295
3427
|
if (!n || typeof n != "object")
|
|
@@ -3302,69 +3434,73 @@ function hr(t, e) {
|
|
|
3302
3434
|
}
|
|
3303
3435
|
return s;
|
|
3304
3436
|
}
|
|
3305
|
-
function
|
|
3306
|
-
if (!e || !
|
|
3437
|
+
function bt(t, e, s, n, r) {
|
|
3438
|
+
if (!e || !Ir(t))
|
|
3307
3439
|
return !1;
|
|
3308
3440
|
const i = t;
|
|
3309
|
-
return !(
|
|
3441
|
+
return !(je(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && U(i) !== r));
|
|
3310
3442
|
}
|
|
3311
|
-
function
|
|
3443
|
+
function Ir(t) {
|
|
3312
3444
|
if (!t || typeof t != "object")
|
|
3313
3445
|
return !1;
|
|
3314
3446
|
const e = t;
|
|
3315
3447
|
return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
|
|
3316
3448
|
}
|
|
3317
|
-
function
|
|
3449
|
+
function W(t) {
|
|
3318
3450
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3319
3451
|
}
|
|
3320
|
-
function
|
|
3452
|
+
function Tr(t) {
|
|
3321
3453
|
if (!t || typeof t != "object")
|
|
3322
3454
|
return !1;
|
|
3323
3455
|
const e = t;
|
|
3324
3456
|
return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
|
|
3325
3457
|
}
|
|
3326
|
-
function
|
|
3327
|
-
return t.filter((e, s) =>
|
|
3458
|
+
function Ke(t) {
|
|
3459
|
+
return t.filter((e, s) => G(e) ? !kr(t, s) && !Vt(t, s) && !br(t, s) && !_r(t, s) : wr(e) ? e.retryable === !0 && Cr(t, s) ? !1 : !Er(t, s) : !0);
|
|
3328
3460
|
}
|
|
3329
|
-
function
|
|
3461
|
+
function wr(t) {
|
|
3330
3462
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3331
3463
|
}
|
|
3332
|
-
function
|
|
3464
|
+
function G(t) {
|
|
3333
3465
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3334
3466
|
}
|
|
3335
|
-
function
|
|
3467
|
+
function Sr(t, e, s, n) {
|
|
3336
3468
|
const r = t.findIndex(
|
|
3337
|
-
(l, c) =>
|
|
3469
|
+
(l, c) => G(l) && !Vt(t, c)
|
|
3338
3470
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3339
3471
|
(l) => l.role === "user" && l.id === o
|
|
3340
3472
|
) : null;
|
|
3341
3473
|
return {
|
|
3342
|
-
clientMessageId: a ?
|
|
3474
|
+
clientMessageId: a ? ee(a) : o ? null : n,
|
|
3475
|
+
respondsToUserMessageId: o,
|
|
3343
3476
|
runId: s ?? i?.runId ?? null
|
|
3344
3477
|
};
|
|
3345
3478
|
}
|
|
3346
|
-
function
|
|
3479
|
+
function xe(t) {
|
|
3480
|
+
return t?.type === "run_status" && t.status === "stopped";
|
|
3481
|
+
}
|
|
3482
|
+
function ce(t, e, s) {
|
|
3347
3483
|
const n = new Set(
|
|
3348
3484
|
t.filter(
|
|
3349
|
-
(r) => r.role === "user" && e !== null &&
|
|
3485
|
+
(r) => r.role === "user" && e !== null && ee(r) === e
|
|
3350
3486
|
).map((r) => r.id)
|
|
3351
3487
|
);
|
|
3352
3488
|
return t.filter(
|
|
3353
|
-
(r) => !
|
|
3489
|
+
(r) => !G(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3354
3490
|
);
|
|
3355
3491
|
}
|
|
3356
|
-
function
|
|
3492
|
+
function Vt(t, e) {
|
|
3357
3493
|
return t.some(
|
|
3358
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
3494
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && Mr(
|
|
3359
3495
|
t,
|
|
3360
3496
|
e,
|
|
3361
3497
|
n
|
|
3362
3498
|
)
|
|
3363
3499
|
);
|
|
3364
3500
|
}
|
|
3365
|
-
function
|
|
3501
|
+
function Mr(t, e, s) {
|
|
3366
3502
|
const n = t[e], r = t[s];
|
|
3367
|
-
if (
|
|
3503
|
+
if (te(n, r))
|
|
3368
3504
|
return !0;
|
|
3369
3505
|
if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
|
|
3370
3506
|
return !1;
|
|
@@ -3373,35 +3509,35 @@ function Ir(t, e, s) {
|
|
|
3373
3509
|
return t[i].id === n.respondsToUserMessageId;
|
|
3374
3510
|
return !1;
|
|
3375
3511
|
}
|
|
3376
|
-
function
|
|
3512
|
+
function Ar(t, e) {
|
|
3377
3513
|
const s = [...t].reverse().find(
|
|
3378
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
3514
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && _t(n) && !Rr(
|
|
3379
3515
|
t,
|
|
3380
3516
|
n.respondsToUserMessageId
|
|
3381
3517
|
)
|
|
3382
3518
|
)?.respondsToUserMessageId;
|
|
3383
3519
|
return s ? t.map(
|
|
3384
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3520
|
+
(n) => n.respondsToUserMessageId === s && _t(n) ? { ...n, steered: !0 } : n
|
|
3385
3521
|
) : t;
|
|
3386
3522
|
}
|
|
3387
|
-
function
|
|
3388
|
-
return t.role === "tool" ||
|
|
3523
|
+
function _t(t) {
|
|
3524
|
+
return t.role === "tool" || G(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3389
3525
|
}
|
|
3390
|
-
function
|
|
3526
|
+
function Rr(t, e) {
|
|
3391
3527
|
return t.some(
|
|
3392
|
-
(s) => s.respondsToUserMessageId === e && (
|
|
3528
|
+
(s) => s.respondsToUserMessageId === e && (W(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3393
3529
|
);
|
|
3394
3530
|
}
|
|
3395
|
-
function
|
|
3531
|
+
function Er(t, e) {
|
|
3396
3532
|
const s = t[e];
|
|
3397
3533
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
3398
3534
|
const r = t[n];
|
|
3399
|
-
if (r.role === "assistant" &&
|
|
3535
|
+
if (r.role === "assistant" && te(s, r))
|
|
3400
3536
|
return !0;
|
|
3401
3537
|
}
|
|
3402
3538
|
return !1;
|
|
3403
3539
|
}
|
|
3404
|
-
function
|
|
3540
|
+
function Cr(t, e) {
|
|
3405
3541
|
const s = t[e];
|
|
3406
3542
|
if (!s.respondsToUserMessageId)
|
|
3407
3543
|
return !1;
|
|
@@ -3409,45 +3545,45 @@ function Mr(t, e) {
|
|
|
3409
3545
|
const r = t[n];
|
|
3410
3546
|
if (r.role === "user")
|
|
3411
3547
|
return !1;
|
|
3412
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3548
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || G(r)))
|
|
3413
3549
|
return !0;
|
|
3414
3550
|
}
|
|
3415
3551
|
return !1;
|
|
3416
3552
|
}
|
|
3417
|
-
function
|
|
3553
|
+
function br(t, e) {
|
|
3418
3554
|
const s = t[e];
|
|
3419
3555
|
return t.some(
|
|
3420
|
-
(n, r) => r !== e && n.role === "assistant" &&
|
|
3556
|
+
(n, r) => r !== e && n.role === "assistant" && te(s, n)
|
|
3421
3557
|
);
|
|
3422
3558
|
}
|
|
3423
|
-
function
|
|
3559
|
+
function _r(t, e) {
|
|
3424
3560
|
const s = t[e];
|
|
3425
3561
|
return t.some(
|
|
3426
|
-
(n, r) => r !== e && n.role === "tool" &&
|
|
3562
|
+
(n, r) => r !== e && n.role === "tool" && te(s, n)
|
|
3427
3563
|
);
|
|
3428
3564
|
}
|
|
3429
|
-
function
|
|
3565
|
+
function kr(t, e) {
|
|
3430
3566
|
const s = t[e];
|
|
3431
3567
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3432
|
-
if (
|
|
3568
|
+
if (G(t[n]) && te(s, t[n]))
|
|
3433
3569
|
return !0;
|
|
3434
3570
|
return !1;
|
|
3435
3571
|
}
|
|
3436
|
-
function
|
|
3572
|
+
function te(t, e) {
|
|
3437
3573
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
3438
3574
|
}
|
|
3439
|
-
function
|
|
3575
|
+
function S(t, e) {
|
|
3440
3576
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
3441
3577
|
}
|
|
3442
|
-
function
|
|
3578
|
+
function Pr(t, e) {
|
|
3443
3579
|
try {
|
|
3444
|
-
const s = window.localStorage.getItem(`${
|
|
3580
|
+
const s = window.localStorage.getItem(`${Bt}${t}`);
|
|
3445
3581
|
if (!s)
|
|
3446
3582
|
return null;
|
|
3447
3583
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3448
3584
|
if (e !== void 0 && r !== e)
|
|
3449
3585
|
return null;
|
|
3450
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3586
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Hr).filter((o) => !!o) : [];
|
|
3451
3587
|
return {
|
|
3452
3588
|
sessionId: r,
|
|
3453
3589
|
messages: i
|
|
@@ -3456,48 +3592,48 @@ function Cr(t, e) {
|
|
|
3456
3592
|
return null;
|
|
3457
3593
|
}
|
|
3458
3594
|
}
|
|
3459
|
-
function
|
|
3595
|
+
function Ur(t, e) {
|
|
3460
3596
|
try {
|
|
3461
3597
|
window.localStorage.setItem(
|
|
3462
|
-
`${
|
|
3598
|
+
`${Bt}${t}`,
|
|
3463
3599
|
JSON.stringify({
|
|
3464
3600
|
sessionId: e.sessionId,
|
|
3465
|
-
messages: e.messages.slice(-
|
|
3601
|
+
messages: e.messages.slice(-nn).map($r)
|
|
3466
3602
|
})
|
|
3467
3603
|
);
|
|
3468
3604
|
} catch {
|
|
3469
3605
|
return;
|
|
3470
3606
|
}
|
|
3471
3607
|
}
|
|
3472
|
-
function
|
|
3608
|
+
function Dr(t) {
|
|
3473
3609
|
try {
|
|
3474
|
-
const e = window.localStorage.getItem(`${
|
|
3610
|
+
const e = window.localStorage.getItem(`${We}${t}`);
|
|
3475
3611
|
if (!e)
|
|
3476
3612
|
return [];
|
|
3477
3613
|
const s = JSON.parse(e);
|
|
3478
|
-
return Array.isArray(s) ? s.filter(
|
|
3614
|
+
return Array.isArray(s) ? s.filter(et) : [];
|
|
3479
3615
|
} catch {
|
|
3480
3616
|
return [];
|
|
3481
3617
|
}
|
|
3482
3618
|
}
|
|
3483
|
-
function
|
|
3619
|
+
function $(t, e) {
|
|
3484
3620
|
try {
|
|
3485
|
-
const s = e.filter(
|
|
3621
|
+
const s = e.filter(et);
|
|
3486
3622
|
if (s.length === 0) {
|
|
3487
|
-
window.localStorage.removeItem(`${
|
|
3623
|
+
window.localStorage.removeItem(`${We}${t}`);
|
|
3488
3624
|
return;
|
|
3489
3625
|
}
|
|
3490
3626
|
window.localStorage.setItem(
|
|
3491
|
-
`${
|
|
3627
|
+
`${We}${t}`,
|
|
3492
3628
|
JSON.stringify(s.slice(-25))
|
|
3493
3629
|
);
|
|
3494
3630
|
} catch {
|
|
3495
3631
|
return;
|
|
3496
3632
|
}
|
|
3497
3633
|
}
|
|
3498
|
-
function
|
|
3634
|
+
function Jt(t, e) {
|
|
3499
3635
|
try {
|
|
3500
|
-
const s = `${
|
|
3636
|
+
const s = `${me}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
3501
3637
|
...o,
|
|
3502
3638
|
storedAt: Date.now(),
|
|
3503
3639
|
unloadUrl: n,
|
|
@@ -3511,28 +3647,28 @@ function Gt(t, e) {
|
|
|
3511
3647
|
} catch {
|
|
3512
3648
|
}
|
|
3513
3649
|
}
|
|
3514
|
-
function
|
|
3650
|
+
function kt(t, e) {
|
|
3515
3651
|
try {
|
|
3516
|
-
if (window.sessionStorage.getItem(`${
|
|
3652
|
+
if (window.sessionStorage.getItem(`${me}${t}`) === null)
|
|
3517
3653
|
return;
|
|
3518
3654
|
} catch {
|
|
3519
3655
|
return;
|
|
3520
3656
|
}
|
|
3521
|
-
|
|
3657
|
+
Jt(t, e);
|
|
3522
3658
|
}
|
|
3523
|
-
function
|
|
3659
|
+
function vr(t) {
|
|
3524
3660
|
try {
|
|
3525
|
-
const e = `${
|
|
3661
|
+
const e = `${me}${t}`, s = window.sessionStorage.getItem(e);
|
|
3526
3662
|
if (window.sessionStorage.removeItem(e), !s)
|
|
3527
3663
|
return [];
|
|
3528
3664
|
const n = JSON.parse(s);
|
|
3529
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3665
|
+
return Array.isArray(n) ? n.flatMap((r) => Or(r) ? [{
|
|
3530
3666
|
...r.event,
|
|
3531
|
-
page:
|
|
3667
|
+
page: k(),
|
|
3532
3668
|
rawOutput: {
|
|
3533
3669
|
pageContextRestarted: !0,
|
|
3534
3670
|
outcome: "unknown",
|
|
3535
|
-
message:
|
|
3671
|
+
message: Nr(location.href),
|
|
3536
3672
|
currentUrl: location.href,
|
|
3537
3673
|
console: [],
|
|
3538
3674
|
metadata: {
|
|
@@ -3549,17 +3685,17 @@ function Pr(t) {
|
|
|
3549
3685
|
return [];
|
|
3550
3686
|
}
|
|
3551
3687
|
}
|
|
3552
|
-
function
|
|
3688
|
+
function Nr(t) {
|
|
3553
3689
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3554
3690
|
Current URL: ${t}`;
|
|
3555
3691
|
}
|
|
3556
|
-
function
|
|
3692
|
+
function Or(t) {
|
|
3557
3693
|
if (!t || typeof t != "object")
|
|
3558
3694
|
return !1;
|
|
3559
3695
|
const e = t, s = e.event;
|
|
3560
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
3696
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && et(s) && s.type === "tool.result";
|
|
3561
3697
|
}
|
|
3562
|
-
function
|
|
3698
|
+
function xr(t, e) {
|
|
3563
3699
|
const s = new Set(
|
|
3564
3700
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3565
3701
|
);
|
|
@@ -3568,26 +3704,26 @@ function vr(t, e) {
|
|
|
3568
3704
|
...e.filter((n) => !s.has(n.callId))
|
|
3569
3705
|
];
|
|
3570
3706
|
}
|
|
3571
|
-
function
|
|
3707
|
+
function Lr(t) {
|
|
3572
3708
|
try {
|
|
3573
|
-
window.sessionStorage.removeItem(`${
|
|
3709
|
+
window.sessionStorage.removeItem(`${me}${t}`);
|
|
3574
3710
|
} catch {
|
|
3575
3711
|
return;
|
|
3576
3712
|
}
|
|
3577
3713
|
}
|
|
3578
|
-
function
|
|
3714
|
+
function et(t) {
|
|
3579
3715
|
if (!t || typeof t != "object")
|
|
3580
3716
|
return !1;
|
|
3581
3717
|
const e = t;
|
|
3582
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
3718
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && Pt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Pt(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
|
|
3583
3719
|
}
|
|
3584
|
-
function
|
|
3720
|
+
function Pt(t) {
|
|
3585
3721
|
if (!t || typeof t != "object")
|
|
3586
3722
|
return !1;
|
|
3587
3723
|
const e = t;
|
|
3588
3724
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
3589
3725
|
}
|
|
3590
|
-
function
|
|
3726
|
+
function Yt(t, e) {
|
|
3591
3727
|
if (!Array.isArray(t))
|
|
3592
3728
|
return;
|
|
3593
3729
|
const s = t.filter((r) => {
|
|
@@ -3595,41 +3731,41 @@ function Xt(t, e) {
|
|
|
3595
3731
|
return !1;
|
|
3596
3732
|
const i = r;
|
|
3597
3733
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3598
|
-
}), n = e ? s.map((r) =>
|
|
3734
|
+
}), n = e ? s.map((r) => Qt(r, e)) : s;
|
|
3599
3735
|
return n.length > 0 ? n : void 0;
|
|
3600
3736
|
}
|
|
3601
|
-
function
|
|
3737
|
+
function Qt(t, e) {
|
|
3602
3738
|
return t.fileUrl?.startsWith("/") ? {
|
|
3603
3739
|
...t,
|
|
3604
3740
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
3605
3741
|
} : t;
|
|
3606
3742
|
}
|
|
3607
|
-
function
|
|
3608
|
-
return t.type ||
|
|
3743
|
+
function Ge(t) {
|
|
3744
|
+
return t.type || Wr(t.name) || "application/octet-stream";
|
|
3609
3745
|
}
|
|
3610
|
-
function
|
|
3611
|
-
|
|
3746
|
+
function Br(t) {
|
|
3747
|
+
Zt({
|
|
3612
3748
|
name: t.name,
|
|
3613
|
-
mimeType:
|
|
3749
|
+
mimeType: Ge(t),
|
|
3614
3750
|
sizeBytes: t.size
|
|
3615
3751
|
});
|
|
3616
3752
|
}
|
|
3617
|
-
function
|
|
3618
|
-
const e =
|
|
3619
|
-
if (!
|
|
3753
|
+
function Zt(t) {
|
|
3754
|
+
const e = qr(t.name), s = t.mimeType.trim().toLowerCase();
|
|
3755
|
+
if (!en.has(`${e}:${s}`))
|
|
3620
3756
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
3621
|
-
if (t.sizeBytes <= 0 || t.sizeBytes >=
|
|
3757
|
+
if (t.sizeBytes <= 0 || t.sizeBytes >= xt)
|
|
3622
3758
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
3623
3759
|
}
|
|
3624
|
-
function
|
|
3760
|
+
function qr(t) {
|
|
3625
3761
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
3626
3762
|
return s >= 0 ? e.slice(s) : "";
|
|
3627
3763
|
}
|
|
3628
|
-
function
|
|
3764
|
+
function Wr(t) {
|
|
3629
3765
|
const e = t.toLowerCase();
|
|
3630
3766
|
return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
|
|
3631
3767
|
}
|
|
3632
|
-
function
|
|
3768
|
+
function Hr(t) {
|
|
3633
3769
|
if (!t || typeof t != "object")
|
|
3634
3770
|
return null;
|
|
3635
3771
|
const e = t;
|
|
@@ -3646,17 +3782,17 @@ function qr(t) {
|
|
|
3646
3782
|
dataType: typeof e.dataType == "string" ? e.dataType : void 0,
|
|
3647
3783
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
3648
3784
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
3649
|
-
attachments:
|
|
3785
|
+
attachments: Yt(e.attachments)?.map(tt),
|
|
3650
3786
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
3651
3787
|
};
|
|
3652
3788
|
}
|
|
3653
|
-
function
|
|
3789
|
+
function $r(t) {
|
|
3654
3790
|
return t.attachments?.length ? {
|
|
3655
3791
|
...t,
|
|
3656
|
-
attachments: t.attachments.map(
|
|
3792
|
+
attachments: t.attachments.map(tt)
|
|
3657
3793
|
} : t;
|
|
3658
3794
|
}
|
|
3659
|
-
function
|
|
3795
|
+
function tt(t) {
|
|
3660
3796
|
const {
|
|
3661
3797
|
dataUrl: e,
|
|
3662
3798
|
objectUrl: s,
|
|
@@ -3669,43 +3805,43 @@ function O(t) {
|
|
|
3669
3805
|
const e = t.respondsToUserMessageId;
|
|
3670
3806
|
return typeof e == "string" && e ? e : null;
|
|
3671
3807
|
}
|
|
3672
|
-
function
|
|
3808
|
+
function U(t) {
|
|
3673
3809
|
const e = t.runId;
|
|
3674
3810
|
return typeof e == "string" && e ? e : null;
|
|
3675
3811
|
}
|
|
3676
|
-
function
|
|
3812
|
+
function jr(t) {
|
|
3677
3813
|
const e = t?.timeoutMs;
|
|
3678
|
-
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <=
|
|
3814
|
+
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= hn);
|
|
3679
3815
|
}
|
|
3680
|
-
function
|
|
3816
|
+
function es(t) {
|
|
3681
3817
|
const e = {};
|
|
3682
3818
|
try {
|
|
3683
3819
|
new Headers(t).forEach((s, n) => {
|
|
3684
|
-
Object.keys(e).length <
|
|
3820
|
+
Object.keys(e).length < Qe && (e[n] = st(n, s));
|
|
3685
3821
|
});
|
|
3686
3822
|
} catch {
|
|
3687
3823
|
return {};
|
|
3688
3824
|
}
|
|
3689
3825
|
return e;
|
|
3690
3826
|
}
|
|
3691
|
-
function
|
|
3692
|
-
return
|
|
3827
|
+
function st(t, e) {
|
|
3828
|
+
return os(t) ? Ie : x(fe(e), tn);
|
|
3693
3829
|
}
|
|
3694
|
-
function
|
|
3830
|
+
function Fr(t, e) {
|
|
3695
3831
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
3696
3832
|
}
|
|
3697
|
-
async function
|
|
3698
|
-
const r =
|
|
3833
|
+
async function zr(t, e, s, n) {
|
|
3834
|
+
const r = es(t.headers);
|
|
3699
3835
|
n({
|
|
3700
3836
|
...e,
|
|
3701
3837
|
responseStatus: t.status,
|
|
3702
3838
|
responseHeaders: r,
|
|
3703
|
-
responseBody: await
|
|
3839
|
+
responseBody: await Kr(t),
|
|
3704
3840
|
durationMs: Date.now() - s
|
|
3705
3841
|
});
|
|
3706
3842
|
}
|
|
3707
|
-
async function
|
|
3708
|
-
if (!
|
|
3843
|
+
async function Kr(t) {
|
|
3844
|
+
if (!ts(t.headers))
|
|
3709
3845
|
return;
|
|
3710
3846
|
let e = null, s = null;
|
|
3711
3847
|
try {
|
|
@@ -3714,7 +3850,7 @@ async function jr(t) {
|
|
|
3714
3850
|
const n = new Promise((a) => {
|
|
3715
3851
|
s = window.setTimeout(() => {
|
|
3716
3852
|
e?.cancel(), a("timeout");
|
|
3717
|
-
},
|
|
3853
|
+
}, sn);
|
|
3718
3854
|
}), r = new TextDecoder();
|
|
3719
3855
|
let i = "", o = 0;
|
|
3720
3856
|
for (; ; ) {
|
|
@@ -3723,10 +3859,10 @@ async function jr(t) {
|
|
|
3723
3859
|
return;
|
|
3724
3860
|
const { done: l, value: c } = a;
|
|
3725
3861
|
if (l)
|
|
3726
|
-
return
|
|
3727
|
-
const p =
|
|
3862
|
+
return x(i + r.decode());
|
|
3863
|
+
const p = Ye - o;
|
|
3728
3864
|
if (c.byteLength > p)
|
|
3729
|
-
return i += r.decode(c.subarray(0, Math.max(p, 0)), { stream: !0 }), e.cancel(), `${
|
|
3865
|
+
return i += r.decode(c.subarray(0, Math.max(p, 0)), { stream: !0 }), e.cancel(), `${x(i)}... [truncated]`;
|
|
3730
3866
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
3731
3867
|
}
|
|
3732
3868
|
} catch {
|
|
@@ -3736,45 +3872,45 @@ async function jr(t) {
|
|
|
3736
3872
|
s !== null && window.clearTimeout(s);
|
|
3737
3873
|
}
|
|
3738
3874
|
}
|
|
3739
|
-
function
|
|
3740
|
-
if (
|
|
3875
|
+
function Gr(t, e) {
|
|
3876
|
+
if (ts(new Headers(e)))
|
|
3741
3877
|
try {
|
|
3742
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
3878
|
+
return t.responseType === "" || t.responseType === "text" ? x(t.responseText ?? "") : void 0;
|
|
3743
3879
|
} catch {
|
|
3744
3880
|
return;
|
|
3745
3881
|
}
|
|
3746
3882
|
}
|
|
3747
|
-
function
|
|
3883
|
+
function Ut(t) {
|
|
3748
3884
|
if (typeof t == "string")
|
|
3749
|
-
return
|
|
3885
|
+
return x(t);
|
|
3750
3886
|
}
|
|
3751
|
-
function
|
|
3752
|
-
return
|
|
3887
|
+
function Xr(t) {
|
|
3888
|
+
return v({
|
|
3753
3889
|
...t,
|
|
3754
|
-
requestBody:
|
|
3755
|
-
responseBody:
|
|
3890
|
+
requestBody: Dt(t.requestBody),
|
|
3891
|
+
responseBody: Dt(t.responseBody)
|
|
3756
3892
|
});
|
|
3757
3893
|
}
|
|
3758
|
-
function
|
|
3894
|
+
function Dt(t) {
|
|
3759
3895
|
if (typeof t != "string")
|
|
3760
3896
|
return t;
|
|
3761
3897
|
const e = t.trim();
|
|
3762
3898
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
3763
|
-
return
|
|
3899
|
+
return fe(t);
|
|
3764
3900
|
try {
|
|
3765
|
-
return JSON.stringify(
|
|
3901
|
+
return JSON.stringify(v(JSON.parse(t)));
|
|
3766
3902
|
} catch {
|
|
3767
|
-
return
|
|
3903
|
+
return fe(t);
|
|
3768
3904
|
}
|
|
3769
3905
|
}
|
|
3770
|
-
function
|
|
3906
|
+
function ts(t) {
|
|
3771
3907
|
if (!t)
|
|
3772
3908
|
return !1;
|
|
3773
3909
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
3774
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3910
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= Ye && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
3775
3911
|
}
|
|
3776
|
-
function
|
|
3777
|
-
if (
|
|
3912
|
+
function j(t, e = {}, s) {
|
|
3913
|
+
if (Jr(s))
|
|
3778
3914
|
return !0;
|
|
3779
3915
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3780
3916
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3789,8 +3925,8 @@ function B(t, e = {}, s) {
|
|
|
3789
3925
|
return !0;
|
|
3790
3926
|
}
|
|
3791
3927
|
}
|
|
3792
|
-
function
|
|
3793
|
-
if (
|
|
3928
|
+
function Vr(t, e) {
|
|
3929
|
+
if (j(t))
|
|
3794
3930
|
return !0;
|
|
3795
3931
|
try {
|
|
3796
3932
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -3799,117 +3935,117 @@ function Kr(t, e) {
|
|
|
3799
3935
|
return !0;
|
|
3800
3936
|
}
|
|
3801
3937
|
}
|
|
3802
|
-
function
|
|
3938
|
+
function Jr(t) {
|
|
3803
3939
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
3804
3940
|
}
|
|
3805
|
-
function
|
|
3941
|
+
function Yr(t) {
|
|
3806
3942
|
const e = {};
|
|
3807
3943
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
3808
3944
|
const n = s.indexOf(":");
|
|
3809
3945
|
if (n <= 0)
|
|
3810
3946
|
continue;
|
|
3811
|
-
if (Object.keys(e).length >=
|
|
3947
|
+
if (Object.keys(e).length >= Qe)
|
|
3812
3948
|
break;
|
|
3813
3949
|
const r = s.slice(0, n).trim();
|
|
3814
|
-
e[r] =
|
|
3950
|
+
e[r] = st(r, s.slice(n + 1).trim());
|
|
3815
3951
|
}
|
|
3816
3952
|
return e;
|
|
3817
3953
|
}
|
|
3818
|
-
function
|
|
3954
|
+
function x(t, e = Ye) {
|
|
3819
3955
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
3820
3956
|
}
|
|
3821
|
-
function
|
|
3957
|
+
function Le(t) {
|
|
3822
3958
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3823
3959
|
}
|
|
3824
|
-
class
|
|
3960
|
+
class he extends Error {
|
|
3825
3961
|
constructor(e, s) {
|
|
3826
3962
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
3827
3963
|
}
|
|
3828
3964
|
status;
|
|
3829
3965
|
}
|
|
3830
|
-
async function
|
|
3966
|
+
async function ue(t, e) {
|
|
3831
3967
|
let s = null;
|
|
3832
|
-
for (let n = 0; n <
|
|
3968
|
+
for (let n = 0; n < wt; n += 1)
|
|
3833
3969
|
try {
|
|
3834
3970
|
return await t();
|
|
3835
3971
|
} catch (r) {
|
|
3836
|
-
if (s = r, n >=
|
|
3972
|
+
if (s = r, n >= wt - 1 || !Zr(r))
|
|
3837
3973
|
throw r;
|
|
3838
|
-
await
|
|
3974
|
+
await Qr(n);
|
|
3839
3975
|
}
|
|
3840
3976
|
throw s instanceof Error ? s : new Error(e);
|
|
3841
3977
|
}
|
|
3842
|
-
function
|
|
3978
|
+
function Qr(t) {
|
|
3843
3979
|
return new Promise((e) => {
|
|
3844
|
-
window.setTimeout(e,
|
|
3980
|
+
window.setTimeout(e, Zs[t] ?? 0);
|
|
3845
3981
|
});
|
|
3846
3982
|
}
|
|
3847
|
-
function
|
|
3848
|
-
return t instanceof
|
|
3983
|
+
function Zr(t) {
|
|
3984
|
+
return t instanceof he ? ei(t.status) : t instanceof TypeError;
|
|
3849
3985
|
}
|
|
3850
|
-
function
|
|
3986
|
+
function ei(t) {
|
|
3851
3987
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
3852
3988
|
}
|
|
3853
|
-
function
|
|
3989
|
+
function ti(t) {
|
|
3854
3990
|
return t === 401 || t === 403;
|
|
3855
3991
|
}
|
|
3856
|
-
const
|
|
3857
|
-
function
|
|
3858
|
-
return
|
|
3992
|
+
const Ie = "[REDACTED_SECRET]", L = "[REDACTED_TOKEN]", si = "[REDACTED_SIGNED_URL]", ni = 20, ri = /^(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, ss = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ns = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, rs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, is = /\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, ii = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, oi = /\bhttps?:\/\/[^\s"'<>]+/gi, ai = /[),.;\]]+$/;
|
|
3993
|
+
function v(t) {
|
|
3994
|
+
return ge(t, 0, /* @__PURE__ */ new WeakSet());
|
|
3859
3995
|
}
|
|
3860
|
-
function
|
|
3996
|
+
function ge(t, e, s) {
|
|
3861
3997
|
if (typeof t == "string")
|
|
3862
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
3998
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : fe(t);
|
|
3863
3999
|
if (t === null || typeof t != "object")
|
|
3864
4000
|
return t;
|
|
3865
|
-
if (e >=
|
|
4001
|
+
if (e >= ni)
|
|
3866
4002
|
return "[REDACTED_MAX_DEPTH]";
|
|
3867
4003
|
if (s.has(t))
|
|
3868
4004
|
return "[REDACTED_CIRCULAR]";
|
|
3869
4005
|
if (s.add(t), Array.isArray(t))
|
|
3870
|
-
return t.map((r) =>
|
|
4006
|
+
return t.map((r) => ge(r, e + 1, s));
|
|
3871
4007
|
const n = {};
|
|
3872
4008
|
for (const [r, i] of Object.entries(t))
|
|
3873
|
-
r === "pageContent" ? n[r] = i :
|
|
4009
|
+
r === "pageContent" ? n[r] = i : os(r) ? n[r] = Ie : n[r] = r.toLowerCase() === "url" ? li(i) : ge(i, e + 1, s);
|
|
3874
4010
|
return n;
|
|
3875
4011
|
}
|
|
3876
|
-
function
|
|
4012
|
+
function os(t) {
|
|
3877
4013
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3878
4014
|
return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
|
|
3879
4015
|
}
|
|
3880
|
-
function
|
|
3881
|
-
return typeof t == "string" ?
|
|
4016
|
+
function li(t) {
|
|
4017
|
+
return typeof t == "string" ? as(t) : ge(t, 0, /* @__PURE__ */ new WeakSet());
|
|
3882
4018
|
}
|
|
3883
|
-
function
|
|
4019
|
+
function as(t) {
|
|
3884
4020
|
try {
|
|
3885
4021
|
const e = new URL(t, location.href);
|
|
3886
4022
|
for (const s of Array.from(e.searchParams.keys()))
|
|
3887
|
-
|
|
3888
|
-
return e.username && (e.username =
|
|
4023
|
+
ri.test(s) && e.searchParams.set(s, L);
|
|
4024
|
+
return e.username && (e.username = L), e.password && (e.password = L), e.toString();
|
|
3889
4025
|
} catch {
|
|
3890
|
-
return
|
|
4026
|
+
return ci(t);
|
|
3891
4027
|
}
|
|
3892
4028
|
}
|
|
3893
|
-
function
|
|
3894
|
-
return t.replace(
|
|
4029
|
+
function fe(t) {
|
|
4030
|
+
return t.replace(ii, si).replace(oi, ui).replace(ss, `Bearer ${L}`).replace(ns, `Basic ${L}`).replace(rs, L).replace(is, (e, s) => `${s}: ${Ie}`);
|
|
3895
4031
|
}
|
|
3896
|
-
function
|
|
3897
|
-
return t.replace(
|
|
4032
|
+
function ci(t) {
|
|
4033
|
+
return t.replace(ss, `Bearer ${L}`).replace(ns, `Basic ${L}`).replace(rs, L).replace(is, (e, s) => `${s}: ${Ie}`);
|
|
3898
4034
|
}
|
|
3899
|
-
function
|
|
3900
|
-
const e = t.match(
|
|
3901
|
-
return `${
|
|
4035
|
+
function ui(t) {
|
|
4036
|
+
const e = t.match(ai)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4037
|
+
return `${as(s)}${e}`;
|
|
3902
4038
|
}
|
|
3903
4039
|
export {
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
4040
|
+
pt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4041
|
+
qe as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4042
|
+
Ns as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4043
|
+
vs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4044
|
+
Os as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
4045
|
+
di as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
4046
|
+
qt as PlunoProductAgent,
|
|
4047
|
+
on as calculateReconnectDelay,
|
|
4048
|
+
qt as default,
|
|
4049
|
+
kn as getProductAgentOriginAccessErrorMessage,
|
|
4050
|
+
Br as validateProductAgentProviderInputFile
|
|
3915
4051
|
};
|