@pluno/product-agent-web 0.1.167 → 0.1.169
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 +10 -4
- package/dist/product-agent-sdk.js +842 -780
- package/dist/product-agent-widget.js +2672 -2509
- package/dist/widget.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
1
|
+
const gs = "pluno-product-agent-attachments";
|
|
2
|
+
const We = "files";
|
|
3
|
+
async function fs(t) {
|
|
4
4
|
const e = await Ve();
|
|
5
|
-
await
|
|
5
|
+
await Is(e, "readwrite", (s) => s.put(t));
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
7
|
+
async function ms(t, e) {
|
|
8
8
|
const s = await Ve();
|
|
9
9
|
await Je(s, "readwrite", async (n) => {
|
|
10
10
|
const r = await Ye(
|
|
@@ -16,7 +16,7 @@ async function ps(t, e) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
19
|
+
async function ys(t = 864e5) {
|
|
20
20
|
const e = await Ve(), s = Date.now() - t;
|
|
21
21
|
await Je(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
@@ -25,19 +25,19 @@ async function gs(t = 864e5) {
|
|
|
25
25
|
}
|
|
26
26
|
function Ve() {
|
|
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(gs, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(We, { 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
|
|
35
|
+
async function Is(t, e, s) {
|
|
36
36
|
return await Je(t, e, async (n) => await Ye(s(n)));
|
|
37
37
|
}
|
|
38
38
|
function Je(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(We, e), o = i.objectStore(We);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
s(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -62,11 +62,11 @@ function Ye(t) {
|
|
|
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 Ts(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 Nt(t, e, s) {
|
|
69
|
+
const n = Reflect.get(t, "pluno"), r = Ts(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,18 +80,18 @@ function Ot(t, e, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const Ss = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function ws(t, e) {
|
|
85
85
|
return e ? t.replace(
|
|
86
|
-
|
|
86
|
+
Ss,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
|
|
88
88
|
) : t;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
91
|
-
function
|
|
92
|
-
return (t.type === "function_call" || t.type === "tool_call") && t.name ===
|
|
90
|
+
const Ms = "save_runtime_captured_skill";
|
|
91
|
+
function As(t) {
|
|
92
|
+
return (t.type === "function_call" || t.type === "tool_call") && t.name === Ms;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function Rs(t, e, s) {
|
|
95
95
|
const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
96
96
|
n.flatMap(
|
|
97
97
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
@@ -108,38 +108,38 @@ function ws(t, e, s) {
|
|
|
108
108
|
)
|
|
109
109
|
), c = /* @__PURE__ */ new Map();
|
|
110
110
|
for (const { item: u, identity: d } of i)
|
|
111
|
-
for (const
|
|
112
|
-
const
|
|
113
|
-
(!
|
|
111
|
+
for (const g of d.activityKeys ?? []) {
|
|
112
|
+
const T = c.get(g);
|
|
113
|
+
(!T || s(T).isTransient) && c.set(g, u);
|
|
114
114
|
}
|
|
115
|
-
const h = new Set(i.map(({ identity: u }) => u.id)),
|
|
115
|
+
const h = new Set(i.map(({ identity: u }) => u.id)), p = new Set(
|
|
116
116
|
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
117
|
-
),
|
|
117
|
+
), I = /* @__PURE__ */ new Set(), f = [];
|
|
118
118
|
for (const u of t) {
|
|
119
119
|
const d = s(u);
|
|
120
|
-
let
|
|
121
|
-
if (d.isOptimistic && d.optimisticKey ?
|
|
122
|
-
f.push(
|
|
120
|
+
let g = o.get(d.id);
|
|
121
|
+
if (d.isOptimistic && d.optimisticKey ? g = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? g = l.get(d.assistantDraftKey) : d.isActivity && (g = d.activityKeys?.map((S) => c.get(S)).find((S) => S !== void 0) ?? g), g && !I.has(g)) {
|
|
122
|
+
f.push(g), I.add(g);
|
|
123
123
|
continue;
|
|
124
124
|
}
|
|
125
|
-
const
|
|
126
|
-
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) &&
|
|
125
|
+
const T = d.respondsToUserMessageId !== void 0 && h.has(d.respondsToUserMessageId) || d.runId !== void 0 && p.has(d.runId);
|
|
126
|
+
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) && T) && f.push(u);
|
|
127
127
|
}
|
|
128
128
|
for (const { item: u } of i)
|
|
129
|
-
|
|
129
|
+
I.has(u) || f.push(u);
|
|
130
130
|
return f;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function Es(t, e, s, n) {
|
|
133
133
|
return t.filter((r) => {
|
|
134
134
|
const i = n(r);
|
|
135
135
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
const
|
|
139
|
-
let
|
|
140
|
-
const
|
|
141
|
-
async function
|
|
142
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
138
|
+
const Pe = "pluno.productAgent.transportId", Cs = "pluno.productAgent.transportIdentity", Ue = "pluno.productAgent.transportIdentity.event", ks = 50, _s = globalThis.setTimeout.bind(globalThis);
|
|
139
|
+
let se = null;
|
|
140
|
+
const ge = /* @__PURE__ */ new Set(), De = /* @__PURE__ */ new Map();
|
|
141
|
+
async function bs(t = xt()) {
|
|
142
|
+
const e = t.randomUUID(), s = t.storage.getItem(Pe);
|
|
143
143
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
144
144
|
const o = t.channel.subscribe((l) => {
|
|
145
145
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -157,14 +157,14 @@ async function Cs(t = Lt()) {
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
if (!s)
|
|
160
|
-
t.storage.setItem(
|
|
160
|
+
t.storage.setItem(Pe, n), r = !0;
|
|
161
161
|
else
|
|
162
162
|
for (; ; ) {
|
|
163
163
|
if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
|
|
164
164
|
r = !0;
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
167
|
+
n = t.randomUUID(), t.storage.setItem(Pe, n);
|
|
168
168
|
}
|
|
169
169
|
let a = !1;
|
|
170
170
|
return {
|
|
@@ -174,49 +174,49 @@ async function Cs(t = Lt()) {
|
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
async function
|
|
178
|
-
|
|
177
|
+
async function Ps() {
|
|
178
|
+
se || (se = bs(xt()), se.then((n) => {
|
|
179
179
|
const r = (i) => {
|
|
180
|
-
i.persisted || (n.release(),
|
|
180
|
+
i.persisted || (n.release(), se = null, ge.clear(), window.removeEventListener("pagehide", r));
|
|
181
181
|
};
|
|
182
182
|
window.addEventListener("pagehide", r);
|
|
183
183
|
}));
|
|
184
|
-
const t = await
|
|
185
|
-
|
|
184
|
+
const t = await se, e = Us();
|
|
185
|
+
ge.add(e);
|
|
186
186
|
let s = !1;
|
|
187
187
|
return {
|
|
188
188
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
189
189
|
transportId: e === 0 ? t.transportId : `${t.transportId}.${e}`,
|
|
190
190
|
release: () => {
|
|
191
|
-
s || (s = !0,
|
|
191
|
+
s || (s = !0, ge.delete(e));
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function Us() {
|
|
196
196
|
let t = 0;
|
|
197
|
-
for (;
|
|
197
|
+
for (; ge.has(t); )
|
|
198
198
|
t += 1;
|
|
199
199
|
return t;
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function xt() {
|
|
202
202
|
return {
|
|
203
|
-
storage:
|
|
204
|
-
channel:
|
|
203
|
+
storage: Ds(),
|
|
204
|
+
channel: vs(),
|
|
205
205
|
randomUUID: () => crypto.randomUUID(),
|
|
206
|
-
settle: () => new Promise((t) =>
|
|
206
|
+
settle: () => new Promise((t) => _s(t, ks))
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function Ds() {
|
|
210
210
|
return {
|
|
211
211
|
getItem: (t) => {
|
|
212
212
|
try {
|
|
213
|
-
return window.sessionStorage?.getItem(t) ??
|
|
213
|
+
return window.sessionStorage?.getItem(t) ?? De.get(t) ?? null;
|
|
214
214
|
} catch {
|
|
215
|
-
return
|
|
215
|
+
return De.get(t) ?? null;
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
setItem: (t, e) => {
|
|
219
|
-
|
|
219
|
+
De.set(t, e);
|
|
220
220
|
try {
|
|
221
221
|
window.sessionStorage?.setItem(t, e);
|
|
222
222
|
} catch {
|
|
@@ -224,9 +224,9 @@ function _s() {
|
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function vs() {
|
|
228
228
|
if (typeof BroadcastChannel < "u") {
|
|
229
|
-
const t = new BroadcastChannel(
|
|
229
|
+
const t = new BroadcastChannel(Cs);
|
|
230
230
|
return {
|
|
231
231
|
postMessage: (e) => t.postMessage(e),
|
|
232
232
|
subscribe: (e) => {
|
|
@@ -236,11 +236,11 @@ function Ps() {
|
|
|
236
236
|
close: () => t.close()
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
|
-
return
|
|
239
|
+
return Os();
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function Os() {
|
|
242
242
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
243
|
-
if (s.key !==
|
|
243
|
+
if (s.key !== Ue || !s.newValue)
|
|
244
244
|
return;
|
|
245
245
|
const n = JSON.parse(s.newValue);
|
|
246
246
|
for (const r of t)
|
|
@@ -249,9 +249,9 @@ function Us() {
|
|
|
249
249
|
return window.addEventListener("storage", e), {
|
|
250
250
|
postMessage: (s) => {
|
|
251
251
|
window.localStorage.setItem(
|
|
252
|
-
|
|
252
|
+
Ue,
|
|
253
253
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
254
|
-
), window.localStorage.removeItem(
|
|
254
|
+
), window.localStorage.removeItem(Ue);
|
|
255
255
|
},
|
|
256
256
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
257
257
|
close: () => {
|
|
@@ -259,8 +259,8 @@ function Us() {
|
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
|
-
const
|
|
263
|
-
function
|
|
262
|
+
const Bt = "schedule_follow_up";
|
|
263
|
+
function qs(t) {
|
|
264
264
|
let e = t;
|
|
265
265
|
if (typeof e == "string")
|
|
266
266
|
try {
|
|
@@ -271,10 +271,10 @@ function Ds(t) {
|
|
|
271
271
|
if (!e || typeof e != "object")
|
|
272
272
|
return null;
|
|
273
273
|
const s = e;
|
|
274
|
-
return s.ok !== !0 || s.toolName !==
|
|
274
|
+
return s.ok !== !0 || s.toolName !== Bt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
275
275
|
}
|
|
276
|
-
const
|
|
277
|
-
let
|
|
276
|
+
const Ls = globalThis.fetch.bind(globalThis), He = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ns = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', xs = ".pluno-pa-widget__panel", Bs = ".pluno-pa-widget__timeline", ht = `${He}[data-pluno-sdk-preview-channel]`;
|
|
277
|
+
let Ws = 0;
|
|
278
278
|
function pt(t) {
|
|
279
279
|
const e = {};
|
|
280
280
|
for (const o of [
|
|
@@ -313,7 +313,7 @@ function pt(t) {
|
|
|
313
313
|
}
|
|
314
314
|
return e;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function ve(t, e, s) {
|
|
317
317
|
if (typeof window > "u")
|
|
318
318
|
return;
|
|
319
319
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -325,28 +325,28 @@ function Ue(t, e, s) {
|
|
|
325
325
|
source: "web_sdk",
|
|
326
326
|
category: t,
|
|
327
327
|
name: e,
|
|
328
|
-
sequence: ++
|
|
328
|
+
sequence: ++Ws,
|
|
329
329
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
330
330
|
monotonicMs: performance.now(),
|
|
331
331
|
data: s
|
|
332
332
|
};
|
|
333
333
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
334
334
|
}
|
|
335
|
-
const
|
|
335
|
+
const Hs = "https://app.pluno.ai", $s = "gpt-5.6-terra", js = 2e4, Fs = 1e4, zs = 1e4, Ks = 1e4, Gs = 1e4, Xs = 3e3, Vs = 3e4, Js = 1e3, gt = 3e4, ft = 0.2, mt = 6e4, yt = 15e3, ne = 8, It = "Browser connection was interrupted.", Tt = 15e3, Ys = "Pluno could not send this message. Try it again.", St = 2e3, Qs = 1e3, Zs = 100, wt = 8e3, en = 8e3, Mt = 3, tn = [300, 1e3], Wt = 50 * 1024 * 1024, sn = /* @__PURE__ */ new Set([
|
|
336
336
|
".jpeg:image/jpeg",
|
|
337
337
|
".jpg:image/jpeg",
|
|
338
338
|
".pdf:application/pdf",
|
|
339
339
|
".png:image/png",
|
|
340
340
|
".webp:image/webp"
|
|
341
|
-
]),
|
|
342
|
-
function
|
|
341
|
+
]), mi = ".pdf,.png,.jpg,.jpeg,.webp", Qe = 64e3, Oe = 4e3, Ze = 30, nn = 2e3, rn = 1e3, Ht = "Image is too large for model vision input.", on = 100, $t = "pluno.productAgent.state.", $e = "pluno.productAgent.pendingEvents.", Se = "pluno.productAgent.activeToolCalls.", an = 100;
|
|
342
|
+
function re(t, e = 0) {
|
|
343
343
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
344
344
|
return Math.max(e, s);
|
|
345
345
|
}
|
|
346
|
-
const
|
|
347
|
-
let
|
|
346
|
+
const fe = /* @__PURE__ */ new Set();
|
|
347
|
+
let le = null;
|
|
348
348
|
function ln(t, e = Math.random) {
|
|
349
|
-
const s = Math.min(gt,
|
|
349
|
+
const s = Math.min(gt, Js * 2 ** t), n = 1 - ft + e() * ft * 2;
|
|
350
350
|
return Math.min(gt, Math.round(s * n));
|
|
351
351
|
}
|
|
352
352
|
function cn(t, e, s) {
|
|
@@ -362,16 +362,19 @@ function cn(t, e, s) {
|
|
|
362
362
|
);
|
|
363
363
|
});
|
|
364
364
|
}
|
|
365
|
-
class
|
|
365
|
+
class jt {
|
|
366
366
|
constructor(e, s) {
|
|
367
367
|
this.options = e, this.transportIdentity = s, this.state = {
|
|
368
368
|
...this.state,
|
|
369
|
-
starterPrompts:
|
|
369
|
+
starterPrompts: jn(e.initialStarterPrompts)
|
|
370
370
|
};
|
|
371
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
371
|
+
const n = e.restorePersistedState === !1 ? null : qr(e.clientId, e.expectedPersistedSessionId);
|
|
372
372
|
n && (this.state = {
|
|
373
373
|
...this.state,
|
|
374
374
|
...n,
|
|
375
|
+
messages: n.messages.filter(
|
|
376
|
+
(i) => !H(i)
|
|
377
|
+
),
|
|
375
378
|
status: "idle",
|
|
376
379
|
user: null,
|
|
377
380
|
assistantDraft: "",
|
|
@@ -384,14 +387,14 @@ class Wt {
|
|
|
384
387
|
isThinking: !1,
|
|
385
388
|
isRetrying: !1,
|
|
386
389
|
lastError: null
|
|
387
|
-
}), this.queuedClientEvents =
|
|
388
|
-
|
|
389
|
-
|
|
390
|
+
}), this.queuedClientEvents = Hr(
|
|
391
|
+
Nr(e.clientId),
|
|
392
|
+
xr(e.clientId)
|
|
390
393
|
);
|
|
391
394
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
392
395
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
393
396
|
);
|
|
394
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"),
|
|
397
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), z(e.clientId, this.queuedClientEvents);
|
|
395
398
|
}
|
|
396
399
|
options;
|
|
397
400
|
listeners = {};
|
|
@@ -428,6 +431,7 @@ class Wt {
|
|
|
428
431
|
transportIdentity;
|
|
429
432
|
retryAttemptsByClientMessageId = {};
|
|
430
433
|
retryTimersByClientMessageId = {};
|
|
434
|
+
recoveryExhaustionRequestedClientMessageIds = /* @__PURE__ */ new Set();
|
|
431
435
|
reportedHealthSignalKeys = /* @__PURE__ */ new Set();
|
|
432
436
|
clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
|
|
433
437
|
backgroundSessionIds = /* @__PURE__ */ new Set();
|
|
@@ -448,7 +452,6 @@ class Wt {
|
|
|
448
452
|
activeResponseUserMessageId = null;
|
|
449
453
|
activeResponseRunId = null;
|
|
450
454
|
activeUserMessageEvent = null;
|
|
451
|
-
browserConnectionInterruptedClientMessageIds = /* @__PURE__ */ new Set();
|
|
452
455
|
latestRecoverableClientMessageId = null;
|
|
453
456
|
lastUserMessagePageUrl = null;
|
|
454
457
|
thinkingWatchdogResyncAttemptsByClientMessageId = {};
|
|
@@ -492,17 +495,17 @@ class Wt {
|
|
|
492
495
|
lastErrorSecuritySettingsUrl: null
|
|
493
496
|
};
|
|
494
497
|
static async init(e) {
|
|
495
|
-
const s = await
|
|
498
|
+
const s = await Ps(), n = new jt({
|
|
496
499
|
...e,
|
|
497
|
-
backendUrl:
|
|
500
|
+
backendUrl: _n(e.backendUrl ?? Hs),
|
|
498
501
|
clientId: e.clientId ?? Xn(),
|
|
499
|
-
model: e.model ??
|
|
502
|
+
model: e.model ?? $s,
|
|
500
503
|
productVariant: e.productVariant ?? "customer_embedded",
|
|
501
|
-
entrySurface:
|
|
504
|
+
entrySurface: bn(e.entrySurface)
|
|
502
505
|
}, s);
|
|
503
506
|
try {
|
|
504
|
-
|
|
505
|
-
|
|
507
|
+
ys().catch((r) => {
|
|
508
|
+
A("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
506
509
|
message: r instanceof Error ? r.message : String(r)
|
|
507
510
|
});
|
|
508
511
|
}), e.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await n.connect();
|
|
@@ -532,15 +535,15 @@ class Wt {
|
|
|
532
535
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
533
536
|
);
|
|
534
537
|
try {
|
|
535
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await cn(this.options.tokenProvider(),
|
|
538
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await cn(this.options.tokenProvider(), zs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
536
539
|
return;
|
|
537
540
|
if (!this.token && !this.options.webSocketFactory)
|
|
538
541
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
539
542
|
const s = Dn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
540
543
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
541
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (
|
|
542
|
-
},
|
|
543
|
-
this.socket !== n || (this.clearSocketConnectTimer(),
|
|
544
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (A("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
545
|
+
}, Ks), n.addEventListener("open", () => {
|
|
546
|
+
this.socket !== n || (this.clearSocketConnectTimer(), A("web-sdk.agent", "Pluno socket opened", {
|
|
544
547
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
545
548
|
isThinking: this.state.isThinking
|
|
546
549
|
}), !(this.token ? this.sendNow({
|
|
@@ -550,8 +553,8 @@ class Wt {
|
|
|
550
553
|
transportId: this.transportIdentity.transportId,
|
|
551
554
|
pageUrl: location.href
|
|
552
555
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
553
|
-
this.socket === n && (
|
|
554
|
-
},
|
|
556
|
+
this.socket === n && (A("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
557
|
+
}, Gs));
|
|
555
558
|
}), n.addEventListener("message", (r) => {
|
|
556
559
|
this.socket === n && this.handleServerEvent(Hn(r.data));
|
|
557
560
|
}), n.addEventListener("sendfailure", (r) => {
|
|
@@ -560,9 +563,9 @@ class Wt {
|
|
|
560
563
|
const i = $n(r?.detail?.data);
|
|
561
564
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
562
565
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
563
|
-
) && (this.queuedClientEvents.push(i),
|
|
566
|
+
) && (this.queuedClientEvents.push(i), z(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();
|
|
564
567
|
}), n.addEventListener("close", (r) => {
|
|
565
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (
|
|
568
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (A("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
566
569
|
code: typeof r?.code == "number" ? r.code : null,
|
|
567
570
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
568
571
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -570,10 +573,10 @@ class Wt {
|
|
|
570
573
|
isThinking: this.state.isThinking
|
|
571
574
|
}), this.setReconnectingState(), this.scheduleReconnect()));
|
|
572
575
|
}), n.addEventListener("error", () => {
|
|
573
|
-
this.socket !== n || this.state.status === "closed" || (
|
|
576
|
+
this.socket !== n || this.state.status === "closed" || (A("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
574
577
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
575
578
|
isThinking: this.state.isThinking
|
|
576
|
-
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.
|
|
579
|
+
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
577
580
|
});
|
|
578
581
|
} catch (s) {
|
|
579
582
|
if (e === this.connectionAttemptId && this.state.status !== "closed") {
|
|
@@ -593,15 +596,15 @@ class Wt {
|
|
|
593
596
|
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.clearSessionLoadRequest(), 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;
|
|
594
597
|
}
|
|
595
598
|
destroy() {
|
|
596
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
599
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), $r(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
597
600
|
for (const e of Object.values(this.listeners))
|
|
598
601
|
e?.clear();
|
|
599
602
|
}
|
|
600
603
|
warmup(e = "panel_open") {
|
|
601
|
-
const s =
|
|
604
|
+
const s = P(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
|
|
602
605
|
type: "runtime.warmup",
|
|
603
606
|
reason: e,
|
|
604
|
-
...e === "composer_input" ? { warmupId: r?.event.warmupId ??
|
|
607
|
+
...e === "composer_input" ? { warmupId: r?.event.warmupId ?? B() } : {},
|
|
605
608
|
entrySurface: this.options.entrySurface,
|
|
606
609
|
sessionId: this.state.sessionId ?? void 0,
|
|
607
610
|
page: s
|
|
@@ -616,23 +619,23 @@ class Wt {
|
|
|
616
619
|
}
|
|
617
620
|
async sendMessage(e, s = {}) {
|
|
618
621
|
const n = e.trim(), r = s.attachments ?? [];
|
|
619
|
-
if (this.options.productVariant === "customer_embedded" && (r.forEach(
|
|
622
|
+
if (this.options.productVariant === "customer_embedded" && (r.forEach(rs), r.reduce(
|
|
620
623
|
(m, C) => m + C.sizeBytes,
|
|
621
624
|
0
|
|
622
|
-
) >
|
|
625
|
+
) > Wt))
|
|
623
626
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
624
627
|
let i = r.map(st);
|
|
625
628
|
if (!n && i.length === 0)
|
|
626
629
|
return null;
|
|
627
630
|
if (this.pendingClientMessageId)
|
|
628
631
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
629
|
-
const o =
|
|
632
|
+
const o = P(), a = s.clientMessageId ?? B(), l = {
|
|
630
633
|
id: `local-${a}`,
|
|
631
634
|
role: "user",
|
|
632
635
|
content: n,
|
|
633
636
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
634
637
|
...r.length > 0 ? { attachments: r } : {}
|
|
635
|
-
}, c = this.state.messages.some((S) => S.id === l.id || S.clientMessageId === a), h = this.state.isThinking,
|
|
638
|
+
}, c = this.state.messages.some((S) => S.id === l.id || S.clientMessageId === a), h = this.state.isThinking, p = this.state.pendingMessageStatus, I = this.state.turnPhase, f = this.state.messages, u = c ? this.state.messages : [...this.state.messages, l], d = {
|
|
636
639
|
assistantDraft: this.state.assistantDraft,
|
|
637
640
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
638
641
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -650,7 +653,7 @@ class Wt {
|
|
|
650
653
|
assistantDraftRunId: null
|
|
651
654
|
},
|
|
652
655
|
pendingMessageStatus: "sending",
|
|
653
|
-
turnPhase: h ?
|
|
656
|
+
turnPhase: h ? I : "sending",
|
|
654
657
|
isThinking: h,
|
|
655
658
|
isRetrying: !1,
|
|
656
659
|
lastError: null
|
|
@@ -672,12 +675,12 @@ class Wt {
|
|
|
672
675
|
throw this.setState({
|
|
673
676
|
...c ? {} : { messages: f },
|
|
674
677
|
...h ? {} : { ...d, isThinking: !1 },
|
|
675
|
-
pendingMessageStatus:
|
|
676
|
-
turnPhase:
|
|
678
|
+
pendingMessageStatus: p,
|
|
679
|
+
turnPhase: I
|
|
677
680
|
}), S;
|
|
678
681
|
}
|
|
679
682
|
this.retryableClientMessageId = null;
|
|
680
|
-
const
|
|
683
|
+
const g = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, T = {
|
|
681
684
|
type: "chat.user_message",
|
|
682
685
|
sessionId: this.state.sessionId ?? void 0,
|
|
683
686
|
clientMessageId: a,
|
|
@@ -685,13 +688,13 @@ class Wt {
|
|
|
685
688
|
invocation: Pn(s.invocation ?? s.initiatedBy),
|
|
686
689
|
entrySurface: this.options.entrySurface,
|
|
687
690
|
content: n,
|
|
688
|
-
pageContent:
|
|
691
|
+
pageContent: g && et() || void 0,
|
|
689
692
|
attachments: i.length > 0 ? i : void 0,
|
|
690
693
|
page: o,
|
|
691
694
|
model: this.options.model,
|
|
692
|
-
metadata:
|
|
695
|
+
metadata: At(this.options.metadata)
|
|
693
696
|
};
|
|
694
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent =
|
|
697
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = T, this.send(T), this.schedulePendingDeliveryAck(a), a;
|
|
695
698
|
}
|
|
696
699
|
retryLastMessage() {
|
|
697
700
|
const e = this.state.sessionId, s = this.retryableClientMessageId;
|
|
@@ -706,11 +709,11 @@ class Wt {
|
|
|
706
709
|
lastErrorCode: null
|
|
707
710
|
}), this.send(n), this.schedulePendingDeliveryAck(s), !0;
|
|
708
711
|
}
|
|
709
|
-
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.
|
|
712
|
+
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.activeClientMessageId = 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;
|
|
710
713
|
}
|
|
711
714
|
createLocalAttachment(e) {
|
|
712
|
-
this.options.productVariant === "customer_embedded" &&
|
|
713
|
-
const s =
|
|
715
|
+
this.options.productVariant === "customer_embedded" && jr(e);
|
|
716
|
+
const s = B(), n = {
|
|
714
717
|
id: s,
|
|
715
718
|
name: e.name || "attachment",
|
|
716
719
|
mimeType: Xe(e),
|
|
@@ -718,18 +721,18 @@ class Wt {
|
|
|
718
721
|
};
|
|
719
722
|
this.attachmentFiles.set(s, e);
|
|
720
723
|
const r = Date.now();
|
|
721
|
-
return
|
|
724
|
+
return fs({
|
|
722
725
|
attachmentId: s,
|
|
723
726
|
name: n.name,
|
|
724
727
|
mimeType: n.mimeType,
|
|
725
728
|
sizeBytes: n.sizeBytes,
|
|
726
729
|
blob: e,
|
|
727
|
-
origin:
|
|
730
|
+
origin: P().origin,
|
|
728
731
|
sessionId: this.state.sessionId ?? void 0,
|
|
729
732
|
createdAt: r,
|
|
730
733
|
lastUsedAt: r
|
|
731
734
|
}).catch((i) => {
|
|
732
|
-
|
|
735
|
+
A("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
733
736
|
attachmentId: s,
|
|
734
737
|
name: n.name,
|
|
735
738
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -755,43 +758,43 @@ class Wt {
|
|
|
755
758
|
name: e.name || "attachment",
|
|
756
759
|
mimeType: r,
|
|
757
760
|
sizeBytes: e.size,
|
|
758
|
-
page:
|
|
761
|
+
page: P(),
|
|
759
762
|
model: this.options.model,
|
|
760
|
-
metadata:
|
|
763
|
+
metadata: At(this.options.metadata),
|
|
761
764
|
entrySurface: this.options.entrySurface
|
|
762
765
|
};
|
|
763
766
|
let o;
|
|
764
767
|
if (this.options.persistAttachmentUpload)
|
|
765
|
-
o = await
|
|
768
|
+
o = await pe(
|
|
766
769
|
() => this.options.persistAttachmentUpload(i, e),
|
|
767
770
|
"Failed to upload attachment"
|
|
768
771
|
);
|
|
769
772
|
else {
|
|
770
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
773
|
+
const l = this.options.prepareAttachmentUpload ? await pe(
|
|
771
774
|
() => this.options.prepareAttachmentUpload(i),
|
|
772
775
|
"Failed to prepare attachment upload"
|
|
773
776
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
774
|
-
await
|
|
777
|
+
await pe(async () => {
|
|
775
778
|
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
776
779
|
method: l.uploadMethod,
|
|
777
780
|
headers: l.uploadHeaders,
|
|
778
781
|
body: e
|
|
779
782
|
});
|
|
780
783
|
if (!c.ok)
|
|
781
|
-
throw new
|
|
784
|
+
throw new me("Failed to upload attachment", c.status);
|
|
782
785
|
return c;
|
|
783
786
|
}, "Failed to upload attachment"), o = l;
|
|
784
787
|
}
|
|
785
788
|
this.setState({ sessionId: o.sessionId });
|
|
786
|
-
const a =
|
|
787
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
789
|
+
const a = ns(o.attachment, this.options.backendUrl);
|
|
790
|
+
return this.updateAttachmentInState(s.id, a), s.id && ms(s.id, {
|
|
788
791
|
sessionId: o.sessionId,
|
|
789
792
|
fileUrl: a.fileUrl,
|
|
790
793
|
sandboxPath: a.sandboxPath,
|
|
791
794
|
storageKey: a.storageKey,
|
|
792
795
|
lastUsedAt: Date.now()
|
|
793
796
|
}).catch((l) => {
|
|
794
|
-
|
|
797
|
+
A("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
795
798
|
attachmentId: s.id,
|
|
796
799
|
name: a.name,
|
|
797
800
|
message: l instanceof Error ? l.message : String(l)
|
|
@@ -811,18 +814,18 @@ class Wt {
|
|
|
811
814
|
}
|
|
812
815
|
async prepareEmbedAttachmentUpload(e) {
|
|
813
816
|
let s = !1;
|
|
814
|
-
return await
|
|
817
|
+
return await pe(async () => {
|
|
815
818
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
816
819
|
if (n.ok)
|
|
817
820
|
return await n.json();
|
|
818
|
-
if (
|
|
821
|
+
if (oi(n.status) && this.options.tokenProvider && !s) {
|
|
819
822
|
s = !0;
|
|
820
823
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
821
824
|
if (r.ok)
|
|
822
825
|
return await r.json();
|
|
823
|
-
throw new
|
|
826
|
+
throw new me("Failed to prepare attachment upload", r.status);
|
|
824
827
|
}
|
|
825
|
-
throw new
|
|
828
|
+
throw new me("Failed to prepare attachment upload", n.status);
|
|
826
829
|
}, "Failed to prepare attachment upload");
|
|
827
830
|
}
|
|
828
831
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -840,7 +843,7 @@ class Wt {
|
|
|
840
843
|
if (!this.state.sessionId)
|
|
841
844
|
return;
|
|
842
845
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
843
|
-
const e =
|
|
846
|
+
const e = Cr(
|
|
844
847
|
this.state.messages,
|
|
845
848
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
846
849
|
this.state.assistantDraftRunId,
|
|
@@ -863,8 +866,8 @@ class Wt {
|
|
|
863
866
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
864
867
|
for (const [s, n] of this.activeBrowserToolCalls)
|
|
865
868
|
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
|
|
866
|
-
|
|
867
|
-
messages:
|
|
869
|
+
vt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
870
|
+
messages: Ut(
|
|
868
871
|
this.state.messages,
|
|
869
872
|
e.clientMessageId,
|
|
870
873
|
e.runId
|
|
@@ -883,7 +886,7 @@ class Wt {
|
|
|
883
886
|
type: "session.reset",
|
|
884
887
|
sessionId: this.state.sessionId ?? void 0,
|
|
885
888
|
warmupId: n ?? void 0,
|
|
886
|
-
page:
|
|
889
|
+
page: P()
|
|
887
890
|
}), this.setState({
|
|
888
891
|
sessionId: null,
|
|
889
892
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -903,15 +906,15 @@ class Wt {
|
|
|
903
906
|
});
|
|
904
907
|
}
|
|
905
908
|
listSessions(e = {}) {
|
|
906
|
-
const s =
|
|
909
|
+
const s = B(), n = new Promise((i, o) => {
|
|
907
910
|
const a = window.setTimeout(() => {
|
|
908
911
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
909
|
-
},
|
|
912
|
+
}, wt);
|
|
910
913
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
911
914
|
}), r = {
|
|
912
915
|
type: "sessions.list",
|
|
913
916
|
requestId: s,
|
|
914
|
-
page:
|
|
917
|
+
page: P(),
|
|
915
918
|
...e.cursor ? { cursor: e.cursor } : {},
|
|
916
919
|
...e.limit ? { limit: e.limit } : {},
|
|
917
920
|
...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
|
|
@@ -925,23 +928,23 @@ class Wt {
|
|
|
925
928
|
setSessionPinned(e, s) {
|
|
926
929
|
return this.sendSessionMutation(
|
|
927
930
|
this.pendingSessionPinRequests,
|
|
928
|
-
{ type: "session.pin", requestId:
|
|
931
|
+
{ type: "session.pin", requestId: B(), sessionId: e, pinned: s },
|
|
929
932
|
"Session pin did not respond in time"
|
|
930
933
|
);
|
|
931
934
|
}
|
|
932
935
|
renameSession(e, s) {
|
|
933
936
|
return this.sendSessionMutation(
|
|
934
937
|
this.pendingSessionRenameRequests,
|
|
935
|
-
{ type: "session.rename", requestId:
|
|
938
|
+
{ type: "session.rename", requestId: B(), sessionId: e, title: s },
|
|
936
939
|
"Session rename did not respond in time"
|
|
937
940
|
);
|
|
938
941
|
}
|
|
939
942
|
loadSession(e) {
|
|
940
|
-
const s =
|
|
943
|
+
const s = B(), n = this.activeComposerWarmupId;
|
|
941
944
|
!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(), n && this.send({
|
|
942
945
|
type: "session.reset",
|
|
943
946
|
warmupId: n,
|
|
944
|
-
page:
|
|
947
|
+
page: P()
|
|
945
948
|
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionLoadRequestTimer = window.setTimeout(() => {
|
|
946
949
|
this.sessionLoadRequestId === s && (this.clearSessionLoadRequest(), this.setState({
|
|
947
950
|
isLoadingSession: !1,
|
|
@@ -967,26 +970,26 @@ class Wt {
|
|
|
967
970
|
type: "session.load",
|
|
968
971
|
requestId: s,
|
|
969
972
|
sessionId: e,
|
|
970
|
-
page:
|
|
973
|
+
page: P()
|
|
971
974
|
});
|
|
972
975
|
}
|
|
973
976
|
loadOlderMessages() {
|
|
974
977
|
if (!this.state.sessionId || !this.sessionItemsCursor || this.state.isLoadingSession || this.state.isLoadingOlderMessages)
|
|
975
978
|
return;
|
|
976
|
-
const e =
|
|
979
|
+
const e = B();
|
|
977
980
|
this.sessionItemsRequestId = e, this.setState({ isLoadingOlderMessages: !0, lastError: null, lastErrorCode: null }), this.send({
|
|
978
981
|
type: "session.items.list",
|
|
979
982
|
requestId: e,
|
|
980
983
|
sessionId: this.state.sessionId,
|
|
981
984
|
cursor: this.sessionItemsCursor,
|
|
982
985
|
limit: 50,
|
|
983
|
-
page:
|
|
986
|
+
page: P()
|
|
984
987
|
});
|
|
985
988
|
}
|
|
986
989
|
send(e) {
|
|
987
|
-
this.sendNow(
|
|
990
|
+
this.sendNow(O(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
988
991
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
989
|
-
) || this.queuedClientEvents.push(e),
|
|
992
|
+
) || this.queuedClientEvents.push(e), z(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
990
993
|
status: "reconnecting",
|
|
991
994
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
992
995
|
}), this.scheduleReconnect());
|
|
@@ -1002,9 +1005,9 @@ class Wt {
|
|
|
1002
1005
|
return !1;
|
|
1003
1006
|
const s = this.socket;
|
|
1004
1007
|
try {
|
|
1005
|
-
return s.send(JSON.stringify(e)),
|
|
1008
|
+
return s.send(JSON.stringify(e)), ve("client_event", e.type, pt(e)), !0;
|
|
1006
1009
|
} catch (n) {
|
|
1007
|
-
return
|
|
1010
|
+
return A("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1008
1011
|
message: n instanceof Error ? n.message : String(n),
|
|
1009
1012
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1010
1013
|
isThinking: this.state.isThinking
|
|
@@ -1036,7 +1039,7 @@ class Wt {
|
|
|
1036
1039
|
}
|
|
1037
1040
|
}));
|
|
1038
1041
|
} catch (r) {
|
|
1039
|
-
|
|
1042
|
+
A("web-sdk.agent", "Pluno health signal send failed", {
|
|
1040
1043
|
name: e,
|
|
1041
1044
|
message: r instanceof Error ? r.message : String(r)
|
|
1042
1045
|
});
|
|
@@ -1048,7 +1051,7 @@ class Wt {
|
|
|
1048
1051
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
1049
1052
|
const e = vn();
|
|
1050
1053
|
this.sendNow(
|
|
1051
|
-
|
|
1054
|
+
O({
|
|
1052
1055
|
type: "starter_prompts.page_context",
|
|
1053
1056
|
pageUrl: e.pageUrl,
|
|
1054
1057
|
pageTitle: e.pageTitle,
|
|
@@ -1078,18 +1081,18 @@ class Wt {
|
|
|
1078
1081
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
1079
1082
|
return;
|
|
1080
1083
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
1081
|
-
|
|
1084
|
+
z(this.options.clientId, this.queuedClientEvents);
|
|
1082
1085
|
for (let s = 0; s < e.length; s += 1) {
|
|
1083
1086
|
const n = e[s];
|
|
1084
|
-
if (!this.sendNow(
|
|
1085
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1087
|
+
if (!this.sendNow(O(n))) {
|
|
1088
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), z(this.options.clientId, this.queuedClientEvents);
|
|
1086
1089
|
return;
|
|
1087
1090
|
}
|
|
1088
|
-
|
|
1091
|
+
z(this.options.clientId, this.queuedClientEvents);
|
|
1089
1092
|
}
|
|
1090
1093
|
}
|
|
1091
1094
|
resetForAuthenticationScopeChange() {
|
|
1092
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
1095
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], z(this.options.clientId, this.queuedClientEvents), this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear();
|
|
1093
1096
|
}
|
|
1094
1097
|
flushPendingPassiveWarmup() {
|
|
1095
1098
|
!this.pendingPassiveWarmupEvent || !this.sendNow(this.pendingPassiveWarmupEvent) || (this.pendingPassiveWarmupEvent = null);
|
|
@@ -1100,8 +1103,8 @@ class Wt {
|
|
|
1100
1103
|
return;
|
|
1101
1104
|
this.clearPendingWarmupAckTimer();
|
|
1102
1105
|
const s = Math.min(
|
|
1103
|
-
|
|
1104
|
-
|
|
1106
|
+
Xs * 2 ** e.retryAttempt,
|
|
1107
|
+
Vs
|
|
1105
1108
|
);
|
|
1106
1109
|
e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
|
|
1107
1110
|
this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
|
|
@@ -1114,23 +1117,23 @@ class Wt {
|
|
|
1114
1117
|
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;
|
|
1115
1118
|
}
|
|
1116
1119
|
findStoppedTurnForEvent(e) {
|
|
1117
|
-
const s = e.type === "session.item" ?
|
|
1120
|
+
const s = e.type === "session.item" ? U(e.item) : null;
|
|
1118
1121
|
return this.findStoppedTurn(
|
|
1119
|
-
|
|
1122
|
+
ce(e) ?? this.state.sessionId,
|
|
1120
1123
|
s ?? e
|
|
1121
1124
|
);
|
|
1122
1125
|
}
|
|
1123
1126
|
rememberDurablyStoppedTurn(e, s, n) {
|
|
1124
|
-
if (!e || !s || !
|
|
1127
|
+
if (!e || !s || !xe(s) || this.findStoppedTurn(e, s))
|
|
1125
1128
|
return;
|
|
1126
|
-
const r =
|
|
1129
|
+
const r = q(s), i = _(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1127
1130
|
this.stoppedTurns.push({
|
|
1128
1131
|
sessionId: e,
|
|
1129
1132
|
clientMessageId: o,
|
|
1130
1133
|
respondsToUserMessageId: r,
|
|
1131
1134
|
runId: i,
|
|
1132
1135
|
stoppedAt: n,
|
|
1133
|
-
stoppedCausalSequence:
|
|
1136
|
+
stoppedCausalSequence: v(s),
|
|
1134
1137
|
toolCallIds: new Set(
|
|
1135
1138
|
this.state.messages.filter(
|
|
1136
1139
|
(a) => Ne(a, r, i)
|
|
@@ -1143,15 +1146,15 @@ class Wt {
|
|
|
1143
1146
|
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1144
1147
|
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1145
1148
|
}
|
|
1146
|
-
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !
|
|
1149
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !xe(U(e.item)) : e.type !== "conversation.state" : !1;
|
|
1147
1150
|
}
|
|
1148
1151
|
filterStoppedSnapshotItems(e, s) {
|
|
1149
1152
|
return e.filter((n) => {
|
|
1150
|
-
const r =
|
|
1151
|
-
if (!i || r?.type === "message" && r.role === "user" ||
|
|
1153
|
+
const r = U(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1154
|
+
if (!i || r?.type === "message" && r.role === "user" || xe(r))
|
|
1152
1155
|
return !0;
|
|
1153
1156
|
if (i.stoppedCausalSequence !== null) {
|
|
1154
|
-
const o = r ?
|
|
1157
|
+
const o = r ? v(r) : null;
|
|
1155
1158
|
return o === null || o <= i.stoppedCausalSequence;
|
|
1156
1159
|
}
|
|
1157
1160
|
if (i.stoppedAt) {
|
|
@@ -1162,9 +1165,9 @@ class Wt {
|
|
|
1162
1165
|
});
|
|
1163
1166
|
}
|
|
1164
1167
|
handleServerEvent(e) {
|
|
1165
|
-
if (
|
|
1168
|
+
if (ve("server_event", e.type, pt(e)), e.type === "session.item" && this.rememberDurablyStoppedTurn(
|
|
1166
1169
|
w(e.item, "sessionId") ?? this.state.sessionId,
|
|
1167
|
-
|
|
1170
|
+
U(e.item),
|
|
1168
1171
|
w(e.item, "createdAt")
|
|
1169
1172
|
), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1170
1173
|
if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
|
|
@@ -1174,12 +1177,12 @@ class Wt {
|
|
|
1174
1177
|
if (e.type === "run.ack") {
|
|
1175
1178
|
if (this.shouldIgnoreStoppedTurnEvent(e))
|
|
1176
1179
|
return;
|
|
1177
|
-
const s =
|
|
1180
|
+
const s = ce(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1178
1181
|
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);
|
|
1179
1182
|
return;
|
|
1180
1183
|
}
|
|
1181
1184
|
if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
1182
|
-
const s =
|
|
1185
|
+
const s = ce(e);
|
|
1183
1186
|
if (s) {
|
|
1184
1187
|
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1185
1188
|
return;
|
|
@@ -1205,28 +1208,28 @@ class Wt {
|
|
|
1205
1208
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
1206
1209
|
const s = Vn(e.user);
|
|
1207
1210
|
this.authenticatedSocket !== this.socket && this.authenticatedUserId && s && s.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = s?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
1208
|
-
const n =
|
|
1209
|
-
|
|
1211
|
+
const n = Fn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1212
|
+
A("web-sdk.agent", "Received auth.ok appearance", {
|
|
1210
1213
|
hasAppearance: r,
|
|
1211
1214
|
rawAppearance: e.appearance,
|
|
1212
1215
|
normalizedAppearance: n
|
|
1213
1216
|
}), this.runtimeHelperJavascript = zn(e.runtimeHelpers)?.javascript ?? null;
|
|
1214
|
-
const i =
|
|
1217
|
+
const i = Ct(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1215
1218
|
user: s,
|
|
1216
1219
|
status: "connected",
|
|
1217
1220
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1218
1221
|
};
|
|
1219
|
-
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !
|
|
1222
|
+
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !ue() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1220
1223
|
type: "page.upsert",
|
|
1221
1224
|
sessionId: this.state.sessionId,
|
|
1222
|
-
page:
|
|
1225
|
+
page: P(),
|
|
1223
1226
|
model: this.options.model
|
|
1224
1227
|
});
|
|
1225
1228
|
return;
|
|
1226
1229
|
}
|
|
1227
1230
|
if (e.type === "starterPrompts.updated") {
|
|
1228
1231
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1229
|
-
starterPrompts:
|
|
1232
|
+
starterPrompts: Ct(e, "starterPrompts"),
|
|
1230
1233
|
starterPromptsLoading: !1
|
|
1231
1234
|
});
|
|
1232
1235
|
return;
|
|
@@ -1239,16 +1242,16 @@ class Wt {
|
|
|
1239
1242
|
for (const E of s)
|
|
1240
1243
|
this.rememberDurablyStoppedTurn(
|
|
1241
1244
|
n,
|
|
1242
|
-
|
|
1245
|
+
U(E),
|
|
1243
1246
|
w(E, "createdAt")
|
|
1244
1247
|
);
|
|
1245
|
-
const i =
|
|
1248
|
+
const i = Q(s), o = i === null ? null : s[i], a = U(o), l = this.findStoppedTurn(n, {
|
|
1246
1249
|
clientMessageId: a?.clientMessageId,
|
|
1247
1250
|
respondsToUserMessageId: w(o, "id"),
|
|
1248
1251
|
runId: a?.runId
|
|
1249
|
-
}), c = this.filterStoppedSnapshotItems(s, n), h = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null,
|
|
1250
|
-
h &&
|
|
1251
|
-
let u =
|
|
1252
|
+
}), c = this.filterStoppedSnapshotItems(s, n), h = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, p = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, I = e.isRetrying === !0, f = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1253
|
+
h && p && (this.pendingClientMessageId = p);
|
|
1254
|
+
let u = nr(
|
|
1252
1255
|
e.assistantDraft
|
|
1253
1256
|
);
|
|
1254
1257
|
u && this.findStoppedTurn(n, {
|
|
@@ -1257,38 +1260,39 @@ class Wt {
|
|
|
1257
1260
|
}) && (u = void 0);
|
|
1258
1261
|
const d = u !== void 0;
|
|
1259
1262
|
this.rememberUserMessageClientMessageIds(c);
|
|
1260
|
-
const
|
|
1261
|
-
if (
|
|
1262
|
-
const E =
|
|
1263
|
-
this.retryAttemptsByClientMessageId[
|
|
1264
|
-
this.retryAttemptsByClientMessageId[
|
|
1263
|
+
const g = Sr(c);
|
|
1264
|
+
if (g) {
|
|
1265
|
+
const E = wr(c, g);
|
|
1266
|
+
this.retryAttemptsByClientMessageId[g] = Math.max(
|
|
1267
|
+
this.retryAttemptsByClientMessageId[g] ?? 0,
|
|
1265
1268
|
E
|
|
1266
1269
|
);
|
|
1267
1270
|
}
|
|
1268
|
-
const
|
|
1269
|
-
const
|
|
1270
|
-
return bt(
|
|
1271
|
-
}), S =
|
|
1271
|
+
const T = c.filter((E) => {
|
|
1272
|
+
const b = U(E);
|
|
1273
|
+
return bt(b) ? !1 : !b || !g || !Fe(b) ? !0 : Ke(c, b) !== g;
|
|
1274
|
+
}), S = dr(
|
|
1272
1275
|
this.state.messages,
|
|
1273
|
-
|
|
1274
|
-
), m = this.hasLoadedOlderSessionItems ?
|
|
1276
|
+
kt(T, this.options.backendUrl)
|
|
1277
|
+
), m = this.hasLoadedOlderSessionItems ? hr(
|
|
1275
1278
|
this.state.messages,
|
|
1276
1279
|
S,
|
|
1277
1280
|
this.loadedOlderSessionItemIds
|
|
1278
|
-
) : S, C =
|
|
1279
|
-
(E) =>
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1281
|
+
) : S, C = _t(m), $ = d ? u?.content ?? "" : this.state.assistantDraft, D = d ? u?.itemId ?? null : this.state.assistantDraftItemId, R = d ? u?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, Z = d ? u?.runId ?? null : this.state.assistantDraftRunId, k = c.some(
|
|
1282
|
+
(E, b) => Pt(
|
|
1283
|
+
U(E),
|
|
1284
|
+
$,
|
|
1285
|
+
D,
|
|
1286
|
+
R,
|
|
1287
|
+
Z,
|
|
1288
|
+
Mr(c, b)
|
|
1285
1289
|
)
|
|
1286
|
-
),
|
|
1287
|
-
if (!C &&
|
|
1290
|
+
), ee = d ? u?.content ?? "" : this.state.assistantDraft, j = !!u?.content && !k, K = C && (!ee || k), G = yr(m);
|
|
1291
|
+
if (!C && Tr(this.state.messages, c))
|
|
1288
1292
|
return;
|
|
1289
|
-
this.lastUserMessagePageUrl =
|
|
1290
|
-
const
|
|
1291
|
-
if (this.latestRecoverableClientMessageId =
|
|
1293
|
+
this.lastUserMessagePageUrl = Ir(c);
|
|
1294
|
+
const F = K || l ? null : ze(c);
|
|
1295
|
+
if (this.latestRecoverableClientMessageId = F, G && this.clearRetryTimers(), this.setState({
|
|
1292
1296
|
sessionId: w(e.session, "id") ?? this.state.sessionId,
|
|
1293
1297
|
messages: m,
|
|
1294
1298
|
isLoadingSession: !1,
|
|
@@ -1296,50 +1300,48 @@ class Wt {
|
|
|
1296
1300
|
hasOlderMessages: this.sessionItemsCursor !== null,
|
|
1297
1301
|
...h ? { pendingMessageStatus: h } : {},
|
|
1298
1302
|
...f ? { turnPhase: f } : {},
|
|
1299
|
-
isRetrying:
|
|
1300
|
-
...
|
|
1301
|
-
assistantDraft: u?.content ?? "",
|
|
1302
|
-
assistantDraftItemId: u?.itemId ?? null,
|
|
1303
|
-
assistantDraftPhase: u?.phase ?? null,
|
|
1304
|
-
assistantDraftRespondsToUserMessageId: u?.respondsToUserMessageId ?? null,
|
|
1305
|
-
assistantDraftRunId: u?.runId ?? null
|
|
1306
|
-
} : B ? {
|
|
1303
|
+
isRetrying: I,
|
|
1304
|
+
...k ? {
|
|
1307
1305
|
assistantDraft: "",
|
|
1308
1306
|
assistantDraftItemId: null,
|
|
1309
1307
|
assistantDraftPhase: null,
|
|
1310
1308
|
assistantDraftRespondsToUserMessageId: null,
|
|
1311
1309
|
assistantDraftRunId: null
|
|
1310
|
+
} : d ? {
|
|
1311
|
+
assistantDraft: u?.content ?? "",
|
|
1312
|
+
assistantDraftItemId: u?.itemId ?? null,
|
|
1313
|
+
assistantDraftPhase: u?.phase ?? null,
|
|
1314
|
+
assistantDraftRespondsToUserMessageId: u?.respondsToUserMessageId ?? null,
|
|
1315
|
+
assistantDraftRunId: u?.runId ?? null
|
|
1312
1316
|
} : {},
|
|
1313
|
-
...
|
|
1317
|
+
...j ? {
|
|
1314
1318
|
isThinking: !0,
|
|
1315
1319
|
turnPhase: "thinking",
|
|
1316
1320
|
lastError: null
|
|
1317
|
-
} :
|
|
1321
|
+
} : K ? {
|
|
1318
1322
|
isThinking: !1,
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
} : {}
|
|
1325
|
-
} : O ? {
|
|
1323
|
+
status: "connected",
|
|
1324
|
+
lastError: null,
|
|
1325
|
+
lastErrorCode: null,
|
|
1326
|
+
lastErrorSecuritySettingsUrl: null
|
|
1327
|
+
} : F ? {
|
|
1326
1328
|
isThinking: !0,
|
|
1327
1329
|
turnPhase: f ?? this.state.turnPhase ?? "starting",
|
|
1328
1330
|
lastError: null
|
|
1329
1331
|
} : {}
|
|
1330
|
-
}),
|
|
1332
|
+
}), K)
|
|
1331
1333
|
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1332
|
-
else if (!l && (
|
|
1333
|
-
if (
|
|
1334
|
-
this.activeClientMessageId =
|
|
1335
|
-
const E =
|
|
1336
|
-
this.activeResponseUserMessageId = w(
|
|
1334
|
+
else if (!l && (j || F)) {
|
|
1335
|
+
if (F) {
|
|
1336
|
+
this.activeClientMessageId = F;
|
|
1337
|
+
const E = Q(c), b = E === null ? null : c[E];
|
|
1338
|
+
this.activeResponseUserMessageId = w(b, "id");
|
|
1337
1339
|
}
|
|
1338
1340
|
this.markThinkingProgress();
|
|
1339
1341
|
}
|
|
1340
|
-
if (
|
|
1342
|
+
if (g) {
|
|
1341
1343
|
const E = w(e.session, "id") ?? this.state.sessionId;
|
|
1342
|
-
E && this.retryAfterInterruptedRun(E,
|
|
1344
|
+
E && this.retryAfterInterruptedRun(E, g);
|
|
1343
1345
|
}
|
|
1344
1346
|
return;
|
|
1345
1347
|
}
|
|
@@ -1347,7 +1349,7 @@ class Wt {
|
|
|
1347
1349
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1348
1350
|
if (!s || s !== this.sessionItemsRequestId || n !== this.state.sessionId)
|
|
1349
1351
|
return;
|
|
1350
|
-
const r =
|
|
1352
|
+
const r = kt(
|
|
1351
1353
|
Array.isArray(e.items) ? e.items : [],
|
|
1352
1354
|
this.options.backendUrl
|
|
1353
1355
|
), i = new Set(r.map((o) => o.id));
|
|
@@ -1389,10 +1391,10 @@ class Wt {
|
|
|
1389
1391
|
}
|
|
1390
1392
|
if (e.type === "session.item") {
|
|
1391
1393
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1392
|
-
const s =
|
|
1393
|
-
if (
|
|
1394
|
+
const s = U(e.item);
|
|
1395
|
+
if (Fe(s)) {
|
|
1394
1396
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1395
|
-
const r = w(e.item, "sessionId") ?? this.state.sessionId, i = s ?
|
|
1397
|
+
const r = w(e.item, "sessionId") ?? this.state.sessionId, i = s ? q(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1396
1398
|
if (r && a) {
|
|
1397
1399
|
this.retryAfterInterruptedRun(r, a);
|
|
1398
1400
|
return;
|
|
@@ -1404,19 +1406,23 @@ class Wt {
|
|
|
1404
1406
|
}
|
|
1405
1407
|
if (bt(s))
|
|
1406
1408
|
return;
|
|
1407
|
-
const n =
|
|
1409
|
+
const n = Xt(e.item, this.options.backendUrl);
|
|
1408
1410
|
if (n) {
|
|
1409
1411
|
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1410
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
1412
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), W(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1411
1413
|
const i = e.item.data;
|
|
1412
|
-
|
|
1413
|
-
const o =
|
|
1414
|
+
Rr(i) && this.clearRunAckResyncRetryTimer();
|
|
1415
|
+
const o = je(this.state.messages, n), a = _t(o), l = Pt(
|
|
1414
1416
|
i,
|
|
1415
1417
|
this.state.assistantDraft,
|
|
1416
1418
|
this.state.assistantDraftItemId,
|
|
1417
1419
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1418
|
-
this.state.assistantDraftRunId
|
|
1419
|
-
|
|
1420
|
+
this.state.assistantDraftRunId,
|
|
1421
|
+
Zt(
|
|
1422
|
+
o,
|
|
1423
|
+
o.findIndex((p) => p.id === n.id)
|
|
1424
|
+
)
|
|
1425
|
+
), c = a && (!this.state.assistantDraft || l), h = ye(n) && (c || W(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
1420
1426
|
this.setState({
|
|
1421
1427
|
messages: o,
|
|
1422
1428
|
...l ? {
|
|
@@ -1430,7 +1436,7 @@ class Wt {
|
|
|
1430
1436
|
isThinking: !1,
|
|
1431
1437
|
isRetrying: !1
|
|
1432
1438
|
} : {},
|
|
1433
|
-
...h ? {
|
|
1439
|
+
...h && !this.failedUserMessageEvent ? {
|
|
1434
1440
|
status: "connected",
|
|
1435
1441
|
lastError: null,
|
|
1436
1442
|
lastErrorCode: null,
|
|
@@ -1442,9 +1448,9 @@ class Wt {
|
|
|
1442
1448
|
}
|
|
1443
1449
|
if (e.type === "chat.assistant_delta") {
|
|
1444
1450
|
this.clearRunAckResyncRetryTimer();
|
|
1445
|
-
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((
|
|
1451
|
+
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((p) => p.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, h = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1446
1452
|
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = h), this.setState({
|
|
1447
|
-
messages:
|
|
1453
|
+
messages: je(this.state.messages, {
|
|
1448
1454
|
id: o,
|
|
1449
1455
|
role: "assistant",
|
|
1450
1456
|
content: i,
|
|
@@ -1472,7 +1478,7 @@ class Wt {
|
|
|
1472
1478
|
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;
|
|
1473
1479
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1474
1480
|
return;
|
|
1475
|
-
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 =
|
|
1481
|
+
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 = Es(
|
|
1476
1482
|
this.state.messages.filter(
|
|
1477
1483
|
(c) => c.dataType !== "assistant_draft" || !Ne(
|
|
1478
1484
|
c,
|
|
@@ -1482,11 +1488,11 @@ class Wt {
|
|
|
1482
1488
|
),
|
|
1483
1489
|
n,
|
|
1484
1490
|
r,
|
|
1485
|
-
|
|
1491
|
+
Vt
|
|
1486
1492
|
);
|
|
1487
1493
|
this.setState({
|
|
1488
1494
|
sessionId: s,
|
|
1489
|
-
messages:
|
|
1495
|
+
messages: or(
|
|
1490
1496
|
l,
|
|
1491
1497
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
1492
1498
|
n,
|
|
@@ -1508,9 +1514,9 @@ class Wt {
|
|
|
1508
1514
|
if (s)
|
|
1509
1515
|
this.nonTranscriptToolCallIds.add(s);
|
|
1510
1516
|
else {
|
|
1511
|
-
const n =
|
|
1517
|
+
const n = cr(e);
|
|
1512
1518
|
if (n) {
|
|
1513
|
-
const r =
|
|
1519
|
+
const r = ar(
|
|
1514
1520
|
this.state.messages,
|
|
1515
1521
|
n
|
|
1516
1522
|
);
|
|
@@ -1578,19 +1584,30 @@ class Wt {
|
|
|
1578
1584
|
return;
|
|
1579
1585
|
}
|
|
1580
1586
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1581
|
-
const a = new Error(typeof e.message == "string" ? e.message
|
|
1582
|
-
l && console.error(l)
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1587
|
+
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Un(a.message);
|
|
1588
|
+
l && console.error(l);
|
|
1589
|
+
const c = i ?? this.activeClientMessageId, h = typeof e.runId == "string" ? e.runId : null, p = Ut(
|
|
1590
|
+
this.state.messages,
|
|
1591
|
+
c,
|
|
1592
|
+
h
|
|
1593
|
+
), I = mr(
|
|
1594
|
+
p,
|
|
1595
|
+
c,
|
|
1596
|
+
h
|
|
1597
|
+
);
|
|
1598
|
+
this.setState({
|
|
1599
|
+
status: I ? "connected" : "error",
|
|
1600
|
+
messages: p,
|
|
1601
|
+
assistantDraft: "",
|
|
1602
|
+
assistantDraftItemId: null,
|
|
1603
|
+
assistantDraftPhase: null,
|
|
1604
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1605
|
+
assistantDraftRunId: null,
|
|
1589
1606
|
isThinking: !1,
|
|
1590
1607
|
isRetrying: !1,
|
|
1591
|
-
lastError: a.message,
|
|
1592
|
-
lastErrorCode: typeof e.code == "string" ? e.code : null,
|
|
1593
|
-
lastErrorSecuritySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
|
|
1608
|
+
lastError: I ? null : a.message,
|
|
1609
|
+
lastErrorCode: I ? null : typeof e.code == "string" ? e.code : null,
|
|
1610
|
+
lastErrorSecuritySettingsUrl: I ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
|
|
1594
1611
|
}), this.clearThinkingWatchdog(), this.emit("error", a);
|
|
1595
1612
|
}
|
|
1596
1613
|
}
|
|
@@ -1599,7 +1616,7 @@ class Wt {
|
|
|
1599
1616
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1600
1617
|
if (!this.options.keepRunsActiveOnSessionNavigation || !pn(e))
|
|
1601
1618
|
return !1;
|
|
1602
|
-
const s =
|
|
1619
|
+
const s = ce(e);
|
|
1603
1620
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1604
1621
|
}
|
|
1605
1622
|
rememberCurrentRunAsBackground() {
|
|
@@ -1609,7 +1626,7 @@ class Wt {
|
|
|
1609
1626
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1610
1627
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1611
1628
|
return !1;
|
|
1612
|
-
if (
|
|
1629
|
+
if (ue())
|
|
1613
1630
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1614
1631
|
if (e.code === "run_still_active") {
|
|
1615
1632
|
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) {
|
|
@@ -1623,10 +1640,10 @@ class Wt {
|
|
|
1623
1640
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1624
1641
|
return !0;
|
|
1625
1642
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1626
|
-
if (i >=
|
|
1643
|
+
if (i >= ne)
|
|
1627
1644
|
return !1;
|
|
1628
1645
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1629
|
-
const o =
|
|
1646
|
+
const o = re(
|
|
1630
1647
|
i,
|
|
1631
1648
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1632
1649
|
);
|
|
@@ -1640,43 +1657,32 @@ class Wt {
|
|
|
1640
1657
|
}, o), !0;
|
|
1641
1658
|
}
|
|
1642
1659
|
retryAfterInterruptedRun(e, s) {
|
|
1643
|
-
if (
|
|
1660
|
+
if (ue()) {
|
|
1644
1661
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1645
1662
|
return;
|
|
1646
1663
|
}
|
|
1647
1664
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1648
1665
|
return;
|
|
1649
1666
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1650
|
-
if (n >=
|
|
1651
|
-
this.
|
|
1652
|
-
clientMessageId: s,
|
|
1653
|
-
retryAttempts: n,
|
|
1654
|
-
reason: "retry_budget_exhausted"
|
|
1655
|
-
}), this.retryableClientMessageId = s, this.setState({
|
|
1656
|
-
messages: ue(
|
|
1657
|
-
this.state.messages,
|
|
1658
|
-
s,
|
|
1659
|
-
null
|
|
1660
|
-
),
|
|
1661
|
-
isThinking: !1,
|
|
1662
|
-
isRetrying: !1,
|
|
1663
|
-
lastError: this.getRunRecoveryExhaustedErrorMessage(s),
|
|
1664
|
-
lastErrorCode: "run_recovery_exhausted"
|
|
1665
|
-
}), this.clearThinkingWatchdog();
|
|
1667
|
+
if (n >= ne) {
|
|
1668
|
+
this.requestSessionRecoveryExhaustion(e, s);
|
|
1666
1669
|
return;
|
|
1667
1670
|
}
|
|
1668
1671
|
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(() => {
|
|
1669
1672
|
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 });
|
|
1670
|
-
},
|
|
1673
|
+
}, re(n));
|
|
1674
|
+
}
|
|
1675
|
+
requestSessionRecoveryExhaustion(e, s) {
|
|
1676
|
+
this.retryableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.recoveryExhaustionRequestedClientMessageIds.has(s) ? this.resyncThinkingSession() : (this.recoveryExhaustionRequestedClientMessageIds.add(s), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 })), this.scheduleThinkingWatchdog(yt);
|
|
1671
1677
|
}
|
|
1672
1678
|
clearRetryTimers() {
|
|
1673
1679
|
for (const e of Object.values(this.retryTimersByClientMessageId))
|
|
1674
1680
|
window.clearTimeout(e);
|
|
1675
|
-
this.retryTimersByClientMessageId = {}, this.retryableFailureRunIdsAwaitingDone.clear();
|
|
1681
|
+
this.retryTimersByClientMessageId = {}, this.recoveryExhaustionRequestedClientMessageIds.clear(), this.retryableFailureRunIdsAwaitingDone.clear();
|
|
1676
1682
|
}
|
|
1677
1683
|
rememberUserMessageClientMessageIds(e) {
|
|
1678
1684
|
for (const s of e) {
|
|
1679
|
-
const n = w(s, "id"), r =
|
|
1685
|
+
const n = w(s, "id"), r = U(s);
|
|
1680
1686
|
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(
|
|
1681
1687
|
r.clientMessageId,
|
|
1682
1688
|
w(s, "sessionId") ?? this.state.sessionId,
|
|
@@ -1697,7 +1703,7 @@ class Wt {
|
|
|
1697
1703
|
const r = new Promise((i, o) => {
|
|
1698
1704
|
const a = window.setTimeout(() => {
|
|
1699
1705
|
e.delete(s.requestId), o(new Error(n));
|
|
1700
|
-
},
|
|
1706
|
+
}, wt);
|
|
1701
1707
|
e.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1702
1708
|
});
|
|
1703
1709
|
if (!this.sendNow(s)) {
|
|
@@ -1728,7 +1734,7 @@ class Wt {
|
|
|
1728
1734
|
}, e);
|
|
1729
1735
|
}
|
|
1730
1736
|
clearThinkingWatchdog() {
|
|
1731
|
-
this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId
|
|
1737
|
+
this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId = null, this.activeResponseUserMessageId = null, this.activeResponseRunId = null, this.activeUserMessageEvent = null;
|
|
1732
1738
|
}
|
|
1733
1739
|
handleRunAck(e) {
|
|
1734
1740
|
const s = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
@@ -1764,21 +1770,21 @@ class Wt {
|
|
|
1764
1770
|
}), this.markThinkingProgress();
|
|
1765
1771
|
}
|
|
1766
1772
|
schedulePendingDeliveryAck(e) {
|
|
1767
|
-
this.clearPendingDeliveryTimers(), !
|
|
1773
|
+
this.clearPendingDeliveryTimers(), !ue() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
1768
1774
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
1769
|
-
},
|
|
1775
|
+
}, Tt));
|
|
1770
1776
|
}
|
|
1771
1777
|
retryPendingDelivery(e) {
|
|
1772
1778
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
1773
1779
|
return;
|
|
1774
1780
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1775
|
-
if (s >=
|
|
1781
|
+
if (s >= ne) {
|
|
1776
1782
|
this.failPendingDelivery(e);
|
|
1777
1783
|
return;
|
|
1778
1784
|
}
|
|
1779
1785
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
1780
1786
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
1781
|
-
},
|
|
1787
|
+
}, re(s, St));
|
|
1782
1788
|
}
|
|
1783
1789
|
failPendingDelivery(e) {
|
|
1784
1790
|
if (this.pendingClientMessageId !== e)
|
|
@@ -1804,7 +1810,7 @@ class Wt {
|
|
|
1804
1810
|
s,
|
|
1805
1811
|
typeof e.runId == "string" ? e.runId : null
|
|
1806
1812
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
1807
|
-
messages:
|
|
1813
|
+
messages: _r(
|
|
1808
1814
|
this.state.messages,
|
|
1809
1815
|
s
|
|
1810
1816
|
)
|
|
@@ -1813,10 +1819,10 @@ class Wt {
|
|
|
1813
1819
|
scheduleRunAckWatchdog(e) {
|
|
1814
1820
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1815
1821
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
1816
|
-
},
|
|
1822
|
+
}, Tt);
|
|
1817
1823
|
}
|
|
1818
1824
|
recoverMissedRunAck(e) {
|
|
1819
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (
|
|
1825
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (A("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
1820
1826
|
sessionId: this.state.sessionId,
|
|
1821
1827
|
clientMessageId: e
|
|
1822
1828
|
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(e));
|
|
@@ -1824,12 +1830,12 @@ class Wt {
|
|
|
1824
1830
|
scheduleRunAckResyncRetry(e) {
|
|
1825
1831
|
this.clearRunAckResyncRetryTimer();
|
|
1826
1832
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1827
|
-
s >=
|
|
1833
|
+
s >= ne || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1828
1834
|
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({
|
|
1829
1835
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1830
1836
|
isThinking: !0,
|
|
1831
1837
|
lastError: null
|
|
1832
|
-
}),
|
|
1838
|
+
}), A("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
1833
1839
|
sessionId: this.state.sessionId,
|
|
1834
1840
|
clientMessageId: e
|
|
1835
1841
|
}), this.state.sessionId ? this.send({
|
|
@@ -1838,7 +1844,7 @@ class Wt {
|
|
|
1838
1844
|
clientMessageId: e,
|
|
1839
1845
|
automatic: !0
|
|
1840
1846
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(mt)));
|
|
1841
|
-
},
|
|
1847
|
+
}, re(s, St)));
|
|
1842
1848
|
}
|
|
1843
1849
|
clearRunAckResyncRetryTimer() {
|
|
1844
1850
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1851,51 +1857,45 @@ class Wt {
|
|
|
1851
1857
|
return;
|
|
1852
1858
|
const e = this.activeClientMessageId;
|
|
1853
1859
|
if (!e) {
|
|
1854
|
-
|
|
1860
|
+
A("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
1855
1861
|
sessionId: this.state.sessionId
|
|
1856
1862
|
}), this.reportHealthSignal("run_recovery_exhausted", {
|
|
1857
1863
|
reason: "missing_client_message_id"
|
|
1858
1864
|
}), this.setState({
|
|
1865
|
+
messages: this.state.messages.filter(
|
|
1866
|
+
(r) => !H(r)
|
|
1867
|
+
),
|
|
1859
1868
|
isThinking: !1,
|
|
1860
|
-
lastError:
|
|
1869
|
+
lastError: It,
|
|
1861
1870
|
lastErrorCode: "run_recovery_exhausted"
|
|
1862
1871
|
}), this.clearThinkingWatchdog();
|
|
1863
1872
|
return;
|
|
1864
1873
|
}
|
|
1865
1874
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1866
|
-
if (n >=
|
|
1867
|
-
|
|
1875
|
+
if (n >= ne) {
|
|
1876
|
+
A("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1868
1877
|
sessionId: this.state.sessionId,
|
|
1869
1878
|
clientMessageId: e
|
|
1870
|
-
}), this.
|
|
1871
|
-
clientMessageId: e,
|
|
1872
|
-
retryAttempts: n,
|
|
1873
|
-
reason: "retry_budget_exhausted"
|
|
1874
|
-
}), this.retryableClientMessageId = e, this.setState({
|
|
1875
|
-
messages: ue(
|
|
1876
|
-
this.state.messages,
|
|
1877
|
-
e,
|
|
1878
|
-
null
|
|
1879
|
-
),
|
|
1879
|
+
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
1880
1880
|
isThinking: !1,
|
|
1881
|
-
lastError:
|
|
1882
|
-
lastErrorCode: "
|
|
1883
|
-
}), this.clearThinkingWatchdog();
|
|
1881
|
+
lastError: It,
|
|
1882
|
+
lastErrorCode: "connection_failed"
|
|
1883
|
+
}), this.clearThinkingWatchdog());
|
|
1884
1884
|
return;
|
|
1885
1885
|
}
|
|
1886
1886
|
if (s < 1) {
|
|
1887
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1,
|
|
1887
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1, A("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
1888
1888
|
sessionId: this.state.sessionId,
|
|
1889
1889
|
clientMessageId: e,
|
|
1890
1890
|
resyncAttempts: s + 1
|
|
1891
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1891
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(yt);
|
|
1892
1892
|
return;
|
|
1893
1893
|
}
|
|
1894
1894
|
this.setState({
|
|
1895
1895
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1896
1896
|
isThinking: !0,
|
|
1897
1897
|
lastError: null
|
|
1898
|
-
}),
|
|
1898
|
+
}), A("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
1899
1899
|
sessionId: this.state.sessionId,
|
|
1900
1900
|
clientMessageId: e,
|
|
1901
1901
|
retryAttempts: n + 1
|
|
@@ -1906,32 +1906,32 @@ class Wt {
|
|
|
1906
1906
|
clientMessageId: e,
|
|
1907
1907
|
automatic: !0
|
|
1908
1908
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1909
|
-
},
|
|
1909
|
+
}, re(n)));
|
|
1910
1910
|
}
|
|
1911
1911
|
resyncThinkingSession() {
|
|
1912
1912
|
this.state.sessionId ? this.send({
|
|
1913
1913
|
type: "page.upsert",
|
|
1914
1914
|
sessionId: this.state.sessionId,
|
|
1915
|
-
page:
|
|
1915
|
+
page: P(),
|
|
1916
1916
|
model: this.options.model
|
|
1917
1917
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1918
1918
|
}
|
|
1919
1919
|
async executeToolCall(e) {
|
|
1920
|
-
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 =
|
|
1920
|
+
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 = V(
|
|
1921
1921
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
1922
1922
|
), o = e.rawInput;
|
|
1923
1923
|
if (!s || !n || !r)
|
|
1924
1924
|
return;
|
|
1925
1925
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1926
|
-
if (!a && !l || !
|
|
1926
|
+
if (!a && !l || !Xr(o)) {
|
|
1927
1927
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1928
1928
|
type: "tool.result",
|
|
1929
1929
|
sessionId: s,
|
|
1930
1930
|
callId: n,
|
|
1931
1931
|
toolName: r,
|
|
1932
1932
|
summary: i,
|
|
1933
|
-
rawInput:
|
|
1934
|
-
rawOutput:
|
|
1933
|
+
rawInput: O(o),
|
|
1934
|
+
rawOutput: O({
|
|
1935
1935
|
ok: !1,
|
|
1936
1936
|
toolName: r,
|
|
1937
1937
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -1946,7 +1946,7 @@ class Wt {
|
|
|
1946
1946
|
callId: n,
|
|
1947
1947
|
toolName: r,
|
|
1948
1948
|
summary: i,
|
|
1949
|
-
rawInput:
|
|
1949
|
+
rawInput: O(o),
|
|
1950
1950
|
rawOutput: {
|
|
1951
1951
|
ok: !1,
|
|
1952
1952
|
toolName: r,
|
|
@@ -1962,7 +1962,7 @@ class Wt {
|
|
|
1962
1962
|
callId: n,
|
|
1963
1963
|
toolName: r,
|
|
1964
1964
|
summary: i,
|
|
1965
|
-
rawInput:
|
|
1965
|
+
rawInput: O(o),
|
|
1966
1966
|
rawOutput: null
|
|
1967
1967
|
},
|
|
1968
1968
|
startedAtMs: Date.now(),
|
|
@@ -1970,13 +1970,13 @@ class Wt {
|
|
|
1970
1970
|
startedAtOrigin: location.origin
|
|
1971
1971
|
}), this.installSessionBrowserApis();
|
|
1972
1972
|
let c = null, h;
|
|
1973
|
-
c = await this.executeRuntimeHelper(), h = await
|
|
1973
|
+
c = await this.executeRuntimeHelper(), h = await Rt(
|
|
1974
1974
|
o,
|
|
1975
1975
|
Cn(e.runtimeContext, this.options.backendUrl)
|
|
1976
|
-
).catch((
|
|
1976
|
+
).catch((p) => ({
|
|
1977
1977
|
ok: !1,
|
|
1978
1978
|
exception: {
|
|
1979
|
-
message:
|
|
1979
|
+
message: p instanceof Error ? p.message : String(p)
|
|
1980
1980
|
}
|
|
1981
1981
|
})), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
1982
1982
|
type: "tool.result",
|
|
@@ -1984,12 +1984,12 @@ class Wt {
|
|
|
1984
1984
|
callId: n,
|
|
1985
1985
|
toolName: r,
|
|
1986
1986
|
summary: o.summary,
|
|
1987
|
-
rawInput:
|
|
1988
|
-
rawOutput:
|
|
1989
|
-
}),
|
|
1987
|
+
rawInput: O(o),
|
|
1988
|
+
rawOutput: O(Kn(h, c))
|
|
1989
|
+
}), vt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
1990
1990
|
}
|
|
1991
1991
|
setToolMessageLoading(e, s) {
|
|
1992
|
-
const n =
|
|
1992
|
+
const n = lr(
|
|
1993
1993
|
this.state.messages,
|
|
1994
1994
|
e,
|
|
1995
1995
|
s
|
|
@@ -2000,7 +2000,7 @@ class Wt {
|
|
|
2000
2000
|
if (this.pageLifecycleCleanup)
|
|
2001
2001
|
return;
|
|
2002
2002
|
const e = () => {
|
|
2003
|
-
|
|
2003
|
+
ts(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
2004
2004
|
};
|
|
2005
2005
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
2006
2006
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
@@ -2015,24 +2015,24 @@ class Wt {
|
|
|
2015
2015
|
async executeRuntimeHelper() {
|
|
2016
2016
|
if (!this.runtimeHelperJavascript?.trim())
|
|
2017
2017
|
return null;
|
|
2018
|
-
const e = await
|
|
2018
|
+
const e = await Rt({
|
|
2019
2019
|
javascript: this.runtimeHelperJavascript
|
|
2020
2020
|
});
|
|
2021
2021
|
return e.ok === !1 ? Gn(e) : null;
|
|
2022
2022
|
}
|
|
2023
2023
|
enableNetworkCapture() {
|
|
2024
2024
|
this.networkCaptureCleanup || (this.networkCaptureCleanup = un((e) => {
|
|
2025
|
-
|
|
2025
|
+
ei(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
2026
2026
|
}));
|
|
2027
2027
|
}
|
|
2028
2028
|
enqueueNetworkEvent(e) {
|
|
2029
|
-
this.queuedNetworkEvents.length >= Zs || (this.queuedNetworkEvents.push(
|
|
2029
|
+
this.queuedNetworkEvents.length >= Zs || (this.queuedNetworkEvents.push(Zr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
2030
2030
|
this.networkBatchTimer = null;
|
|
2031
2031
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
2032
2032
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
2033
2033
|
type: "network.batch",
|
|
2034
2034
|
sessionId: this.state.sessionId ?? void 0,
|
|
2035
|
-
page:
|
|
2035
|
+
page: P(),
|
|
2036
2036
|
events: s
|
|
2037
2037
|
});
|
|
2038
2038
|
}, Qs)));
|
|
@@ -2043,7 +2043,7 @@ class Wt {
|
|
|
2043
2043
|
const e = ln(this.reconnectAttempts);
|
|
2044
2044
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
2045
2045
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
2046
|
-
|
|
2046
|
+
A("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
2047
2047
|
message: s instanceof Error ? s.message : String(s),
|
|
2048
2048
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
2049
2049
|
isThinking: this.state.isThinking
|
|
@@ -2055,9 +2055,9 @@ class Wt {
|
|
|
2055
2055
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
2056
2056
|
const e = this.socket;
|
|
2057
2057
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
2058
|
-
this.socket === e && (
|
|
2059
|
-
},
|
|
2060
|
-
},
|
|
2058
|
+
this.socket === e && (A("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
2059
|
+
}, Fs));
|
|
2060
|
+
}, js);
|
|
2061
2061
|
}
|
|
2062
2062
|
stopHeartbeat() {
|
|
2063
2063
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -2081,18 +2081,20 @@ class Wt {
|
|
|
2081
2081
|
this.clearSocketConnectTimer(), this.clearSocketAuthTimer();
|
|
2082
2082
|
}
|
|
2083
2083
|
replaceTimedOutSocket(e) {
|
|
2084
|
-
this.socket !== e || this.state.status === "closed" || (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.
|
|
2084
|
+
this.socket !== e || this.state.status === "closed" || (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), e.readyState !== WebSocket.CLOSED && e.readyState !== WebSocket.CLOSING && e.close());
|
|
2085
2085
|
}
|
|
2086
2086
|
setState(e) {
|
|
2087
2087
|
const s = e.isThinking ?? this.state.isThinking, n = e.pendingMessageStatus !== void 0 ? e.pendingMessageStatus : this.state.pendingMessageStatus;
|
|
2088
2088
|
let r = e.turnPhase !== void 0 ? e.turnPhase : this.state.turnPhase;
|
|
2089
|
-
e.turnPhase === void 0 && (e.isThinking === !1 ? r = n ? "sending" : null : s && r === null ? r = "starting" : !s && n && r === null && (r = "sending"))
|
|
2089
|
+
e.turnPhase === void 0 && (e.isThinking === !1 ? r = n ? "sending" : null : s && r === null ? r = "starting" : !s && n && r === null && (r = "sending"));
|
|
2090
|
+
const i = {
|
|
2090
2091
|
...this.state,
|
|
2091
2092
|
...e,
|
|
2092
2093
|
turnPhase: r,
|
|
2093
2094
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2094
2095
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2095
|
-
}
|
|
2096
|
+
};
|
|
2097
|
+
this.state = i, Lr(this.options.clientId, this.state), this.emit("state", this.getState()), ve("state", this.state.status, {
|
|
2096
2098
|
status: this.state.status,
|
|
2097
2099
|
sessionId: this.state.sessionId,
|
|
2098
2100
|
messageCount: this.state.messages.length,
|
|
@@ -2109,17 +2111,11 @@ class Wt {
|
|
|
2109
2111
|
...this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
2110
2112
|
});
|
|
2111
2113
|
}
|
|
2112
|
-
rememberBrowserConnectionInterruptionForActiveRun() {
|
|
2113
|
-
this.state.isThinking && this.activeClientMessageId ? this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId) : this.pendingClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.pendingClientMessageId);
|
|
2114
|
-
}
|
|
2115
|
-
getRunRecoveryExhaustedErrorMessage(e) {
|
|
2116
|
-
return e && this.browserConnectionInterruptedClientMessageIds.has(e) ? Js : Vs;
|
|
2117
|
-
}
|
|
2118
2114
|
emit(e, s) {
|
|
2119
2115
|
this.listeners[e]?.forEach((r) => r(s));
|
|
2120
2116
|
}
|
|
2121
2117
|
}
|
|
2122
|
-
const
|
|
2118
|
+
const qe = /* @__PURE__ */ new WeakMap();
|
|
2123
2119
|
function un(t) {
|
|
2124
2120
|
const e = window.__plunoProductAgentNetworkCapture ?? dn();
|
|
2125
2121
|
return e.subscribers.add(t), () => {
|
|
@@ -2127,47 +2123,47 @@ function un(t) {
|
|
|
2127
2123
|
};
|
|
2128
2124
|
}
|
|
2129
2125
|
function dn() {
|
|
2130
|
-
const t = /* @__PURE__ */ new Set(), e = (
|
|
2126
|
+
const t = /* @__PURE__ */ new Set(), e = (I) => {
|
|
2131
2127
|
t.forEach((f) => {
|
|
2132
2128
|
try {
|
|
2133
|
-
f(
|
|
2129
|
+
f(I);
|
|
2134
2130
|
} catch {
|
|
2135
2131
|
}
|
|
2136
2132
|
});
|
|
2137
2133
|
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, u) {
|
|
2138
2134
|
const d = Date.now();
|
|
2139
|
-
let
|
|
2135
|
+
let g;
|
|
2140
2136
|
try {
|
|
2141
|
-
|
|
2142
|
-
} catch (
|
|
2143
|
-
throw
|
|
2137
|
+
g = s.call(this, f, u);
|
|
2138
|
+
} catch (T) {
|
|
2139
|
+
throw T;
|
|
2144
2140
|
}
|
|
2145
2141
|
try {
|
|
2146
|
-
const
|
|
2147
|
-
if (!
|
|
2148
|
-
const
|
|
2149
|
-
requestId:
|
|
2150
|
-
url:
|
|
2151
|
-
method: (u?.method ??
|
|
2142
|
+
const T = f instanceof Request ? f : null, S = Vr(f, T), m = is(u?.headers ?? T?.headers);
|
|
2143
|
+
if (!X(S, m, u?.body)) {
|
|
2144
|
+
const $ = {
|
|
2145
|
+
requestId: Be("fetch"),
|
|
2146
|
+
url: L(S, Oe),
|
|
2147
|
+
method: (u?.method ?? T?.method ?? "GET").toUpperCase(),
|
|
2152
2148
|
requestHeaders: m,
|
|
2153
|
-
requestBody:
|
|
2149
|
+
requestBody: qt(u?.body),
|
|
2154
2150
|
resourceType: "fetch",
|
|
2155
2151
|
startedAt: new Date(d).toISOString()
|
|
2156
2152
|
};
|
|
2157
|
-
|
|
2158
|
-
(
|
|
2159
|
-
|
|
2153
|
+
g.then(
|
|
2154
|
+
(D) => {
|
|
2155
|
+
Jr(D, $, d, e).catch(() => {
|
|
2160
2156
|
e({
|
|
2161
|
-
|
|
2162
|
-
responseStatus:
|
|
2157
|
+
...$,
|
|
2158
|
+
responseStatus: D.status,
|
|
2163
2159
|
durationMs: Date.now() - d
|
|
2164
2160
|
});
|
|
2165
2161
|
});
|
|
2166
2162
|
},
|
|
2167
|
-
(
|
|
2163
|
+
(D) => {
|
|
2168
2164
|
e({
|
|
2169
|
-
|
|
2170
|
-
errorText:
|
|
2165
|
+
...$,
|
|
2166
|
+
errorText: L(D instanceof Error ? D.message : String(D)),
|
|
2171
2167
|
durationMs: Date.now() - d
|
|
2172
2168
|
});
|
|
2173
2169
|
}
|
|
@@ -2175,30 +2171,30 @@ function dn() {
|
|
|
2175
2171
|
}
|
|
2176
2172
|
} catch {
|
|
2177
2173
|
}
|
|
2178
|
-
return
|
|
2179
|
-
}, a = function(f, u, d,
|
|
2180
|
-
const S = n.call(this, f, u, d ?? !0,
|
|
2181
|
-
return
|
|
2182
|
-
requestId:
|
|
2174
|
+
return g;
|
|
2175
|
+
}, a = function(f, u, d, g, T) {
|
|
2176
|
+
const S = n.call(this, f, u, d ?? !0, g ?? void 0, T ?? void 0), m = typeof u == "string" ? u : u.toString();
|
|
2177
|
+
return qe.set(this, {
|
|
2178
|
+
requestId: Be("xhr"),
|
|
2183
2179
|
method: String(f ?? "GET").toUpperCase(),
|
|
2184
|
-
url:
|
|
2180
|
+
url: L(m, Oe),
|
|
2185
2181
|
requestHeaders: {},
|
|
2186
2182
|
startedAtMs: Date.now(),
|
|
2187
2183
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2188
|
-
excluded:
|
|
2184
|
+
excluded: X(m)
|
|
2189
2185
|
}), S;
|
|
2190
2186
|
}, l = function(f, u) {
|
|
2191
|
-
const d = r.call(this, f, u),
|
|
2192
|
-
return
|
|
2187
|
+
const d = r.call(this, f, u), g = qe.get(this);
|
|
2188
|
+
return g && Object.keys(g.requestHeaders).length < Ze && (g.requestHeaders[f] = nt(f, u), g.excluded = g.excluded || X(g.url, g.requestHeaders)), d;
|
|
2193
2189
|
}, c = function(f) {
|
|
2194
2190
|
try {
|
|
2195
|
-
const u =
|
|
2196
|
-
u && (u.excluded = u.excluded ||
|
|
2191
|
+
const u = qe.get(this);
|
|
2192
|
+
u && (u.excluded = u.excluded || X(u.url, u.requestHeaders, f), u.requestBody = qt(f), u.excluded || this.addEventListener(
|
|
2197
2193
|
"loadend",
|
|
2198
2194
|
() => {
|
|
2199
2195
|
queueMicrotask(() => {
|
|
2200
2196
|
try {
|
|
2201
|
-
const d =
|
|
2197
|
+
const d = si(this.getAllResponseHeaders());
|
|
2202
2198
|
e({
|
|
2203
2199
|
requestId: u.requestId,
|
|
2204
2200
|
url: u.url,
|
|
@@ -2208,7 +2204,7 @@ function dn() {
|
|
|
2208
2204
|
resourceType: "xhr",
|
|
2209
2205
|
responseStatus: this.status,
|
|
2210
2206
|
responseHeaders: d,
|
|
2211
|
-
responseBody:
|
|
2207
|
+
responseBody: Qr(this, d),
|
|
2212
2208
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2213
2209
|
startedAt: u.startedAt,
|
|
2214
2210
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -2242,15 +2238,15 @@ function dn() {
|
|
|
2242
2238
|
}
|
|
2243
2239
|
let h = null;
|
|
2244
2240
|
if (typeof PerformanceObserver < "u") {
|
|
2245
|
-
h = new PerformanceObserver((
|
|
2246
|
-
for (const f of
|
|
2241
|
+
h = new PerformanceObserver((I) => {
|
|
2242
|
+
for (const f of I.getEntries()) {
|
|
2247
2243
|
const u = f;
|
|
2248
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
2244
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || X(u.name))
|
|
2249
2245
|
continue;
|
|
2250
2246
|
const d = performance.timeOrigin + u.startTime;
|
|
2251
2247
|
e({
|
|
2252
|
-
requestId:
|
|
2253
|
-
url:
|
|
2248
|
+
requestId: Be("resource"),
|
|
2249
|
+
url: L(u.name, Oe),
|
|
2254
2250
|
method: "GET",
|
|
2255
2251
|
resourceType: "resource",
|
|
2256
2252
|
responseStatus: u.responseStatus,
|
|
@@ -2265,7 +2261,7 @@ function dn() {
|
|
|
2265
2261
|
h.disconnect(), h = null;
|
|
2266
2262
|
}
|
|
2267
2263
|
}
|
|
2268
|
-
const
|
|
2264
|
+
const p = {
|
|
2269
2265
|
subscribers: t,
|
|
2270
2266
|
destroy: () => {
|
|
2271
2267
|
h?.disconnect();
|
|
@@ -2287,9 +2283,9 @@ function dn() {
|
|
|
2287
2283
|
}
|
|
2288
2284
|
}
|
|
2289
2285
|
};
|
|
2290
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
2286
|
+
return window.__plunoProductAgentNetworkCapture = p, p;
|
|
2291
2287
|
}
|
|
2292
|
-
function
|
|
2288
|
+
function A(t, e, s) {
|
|
2293
2289
|
if (typeof window > "u")
|
|
2294
2290
|
return;
|
|
2295
2291
|
const n = window, r = {
|
|
@@ -2300,7 +2296,7 @@ function R(t, e, s) {
|
|
|
2300
2296
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
2301
2297
|
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 }));
|
|
2302
2298
|
}
|
|
2303
|
-
function
|
|
2299
|
+
function At(t) {
|
|
2304
2300
|
const e = typeof t == "function" ? t() : t;
|
|
2305
2301
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2306
2302
|
}
|
|
@@ -2310,7 +2306,7 @@ function hn(t) {
|
|
|
2310
2306
|
function pn(t) {
|
|
2311
2307
|
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";
|
|
2312
2308
|
}
|
|
2313
|
-
function
|
|
2309
|
+
function ce(t) {
|
|
2314
2310
|
if (typeof t.sessionId == "string")
|
|
2315
2311
|
return t.sessionId;
|
|
2316
2312
|
if (t.session && typeof t.session == "object") {
|
|
@@ -2337,10 +2333,10 @@ function mn() {
|
|
|
2337
2333
|
};
|
|
2338
2334
|
}
|
|
2339
2335
|
function yn() {
|
|
2340
|
-
return
|
|
2336
|
+
return Nt(globalThis, "getPageSnapshot", async () => et());
|
|
2341
2337
|
}
|
|
2342
2338
|
function In() {
|
|
2343
|
-
return
|
|
2339
|
+
return Nt(globalThis, "pageImages", {
|
|
2344
2340
|
inspectImage: async (e, s) => await Tn(e, s)
|
|
2345
2341
|
});
|
|
2346
2342
|
}
|
|
@@ -2349,7 +2345,7 @@ async function Tn(t, e = {}) {
|
|
|
2349
2345
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2350
2346
|
type: "pluno.pageImages.inspectImage",
|
|
2351
2347
|
imageAttached: !1,
|
|
2352
|
-
imageAttachmentError:
|
|
2348
|
+
imageAttachmentError: Ht
|
|
2353
2349
|
} : {
|
|
2354
2350
|
type: "pluno.pageImages.inspectImage",
|
|
2355
2351
|
imageAttached: !0,
|
|
@@ -2364,7 +2360,7 @@ async function Tn(t, e = {}) {
|
|
|
2364
2360
|
};
|
|
2365
2361
|
}
|
|
2366
2362
|
async function Sn(t) {
|
|
2367
|
-
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:
|
|
2363
|
+
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: Ht } : {
|
|
2368
2364
|
ok: !0,
|
|
2369
2365
|
mimeType: t.type,
|
|
2370
2366
|
sizeBytes: t.size,
|
|
@@ -2417,7 +2413,7 @@ function En(t) {
|
|
|
2417
2413
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(t);
|
|
2418
2414
|
});
|
|
2419
2415
|
}
|
|
2420
|
-
async function
|
|
2416
|
+
async function Rt(t, e) {
|
|
2421
2417
|
const s = Object.getPrototypeOf(async function() {
|
|
2422
2418
|
}).constructor, n = t.timeoutMs ?? gn, r = Date.now(), i = [];
|
|
2423
2419
|
let o;
|
|
@@ -2433,11 +2429,11 @@ async function Mt(t, e) {
|
|
|
2433
2429
|
try {
|
|
2434
2430
|
const c = /* @__PURE__ */ Symbol("execute_code_timeout"), h = await Promise.race([
|
|
2435
2431
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
2436
|
-
new Promise((
|
|
2437
|
-
o = window.setTimeout(() =>
|
|
2432
|
+
new Promise((p) => {
|
|
2433
|
+
o = window.setTimeout(() => p(c), n);
|
|
2438
2434
|
})
|
|
2439
2435
|
]);
|
|
2440
|
-
return h === c ?
|
|
2436
|
+
return h === c ? kn(n) : {
|
|
2441
2437
|
ok: !0,
|
|
2442
2438
|
result: h,
|
|
2443
2439
|
console: i,
|
|
@@ -2476,7 +2472,7 @@ function Cn(t, e) {
|
|
|
2476
2472
|
const r = () => {
|
|
2477
2473
|
if (!n)
|
|
2478
2474
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2479
|
-
}, i = async (a, l) => await
|
|
2475
|
+
}, i = async (a, l) => await Ls(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2480
2476
|
return {
|
|
2481
2477
|
value: Object.freeze({
|
|
2482
2478
|
upload: async (a) => {
|
|
@@ -2499,8 +2495,8 @@ function Cn(t, e) {
|
|
|
2499
2495
|
);
|
|
2500
2496
|
if (!l.ok)
|
|
2501
2497
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
2502
|
-
const c = await l.blob(),
|
|
2503
|
-
return new File([c],
|
|
2498
|
+
const c = await l.blob(), p = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
2499
|
+
return new File([c], p || a.split("/").pop() || "file", {
|
|
2504
2500
|
type: c.type
|
|
2505
2501
|
});
|
|
2506
2502
|
}
|
|
@@ -2510,7 +2506,7 @@ function Cn(t, e) {
|
|
|
2510
2506
|
}
|
|
2511
2507
|
};
|
|
2512
2508
|
}
|
|
2513
|
-
function
|
|
2509
|
+
function kn(t) {
|
|
2514
2510
|
return {
|
|
2515
2511
|
ok: !1,
|
|
2516
2512
|
exception: {
|
|
@@ -2524,10 +2520,10 @@ function bn(t) {
|
|
|
2524
2520
|
}
|
|
2525
2521
|
};
|
|
2526
2522
|
}
|
|
2527
|
-
function
|
|
2523
|
+
function _n(t) {
|
|
2528
2524
|
return t.replace(/\/+$/, "");
|
|
2529
2525
|
}
|
|
2530
|
-
function
|
|
2526
|
+
function bn(t) {
|
|
2531
2527
|
const e = {
|
|
2532
2528
|
sidepanel: "extension_sidepanel",
|
|
2533
2529
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2549,8 +2545,8 @@ function Dn(t) {
|
|
|
2549
2545
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2550
2546
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2551
2547
|
}
|
|
2552
|
-
function
|
|
2553
|
-
const t =
|
|
2548
|
+
function P() {
|
|
2549
|
+
const t = Gt();
|
|
2554
2550
|
return {
|
|
2555
2551
|
url: location.href,
|
|
2556
2552
|
title: document.title,
|
|
@@ -2566,13 +2562,13 @@ function vn() {
|
|
|
2566
2562
|
};
|
|
2567
2563
|
}
|
|
2568
2564
|
function On(t) {
|
|
2569
|
-
return
|
|
2570
|
-
|
|
2565
|
+
return fe.add(t), le || (le = qn()), () => {
|
|
2566
|
+
fe.delete(t), fe.size === 0 && (le?.(), le = null);
|
|
2571
2567
|
};
|
|
2572
2568
|
}
|
|
2573
|
-
function
|
|
2569
|
+
function qn() {
|
|
2574
2570
|
const t = () => {
|
|
2575
|
-
for (const i of Array.from(
|
|
2571
|
+
for (const i of Array.from(fe))
|
|
2576
2572
|
i();
|
|
2577
2573
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2578
2574
|
const o = e(...i);
|
|
@@ -2585,38 +2581,38 @@ function Ln() {
|
|
|
2585
2581
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2586
2582
|
};
|
|
2587
2583
|
}
|
|
2588
|
-
function
|
|
2589
|
-
return
|
|
2584
|
+
function ue() {
|
|
2585
|
+
return Gt()?.surface === "browser_extension_sdk_preview";
|
|
2590
2586
|
}
|
|
2591
2587
|
function et() {
|
|
2592
2588
|
if (!document.body)
|
|
2593
2589
|
return "";
|
|
2594
|
-
const t = [], e = [], s = (d,
|
|
2595
|
-
const
|
|
2596
|
-
!
|
|
2590
|
+
const t = [], e = [], s = (d, g) => {
|
|
2591
|
+
const T = J(g);
|
|
2592
|
+
!T || e.includes(T) || (t.push([d, T]), e.push(T));
|
|
2597
2593
|
};
|
|
2598
2594
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2599
2595
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2600
|
-
(d) =>
|
|
2596
|
+
(d) => Ft(d) && !d.parentElement?.closest(n)
|
|
2601
2597
|
);
|
|
2602
2598
|
for (const d of r.slice(0, 3))
|
|
2603
|
-
s("Active overlay",
|
|
2604
|
-
const i =
|
|
2605
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2606
|
-
const a = t.map(([d,
|
|
2607
|
-
${
|
|
2599
|
+
s("Active overlay", Le(ie(d), e));
|
|
2600
|
+
const i = Ln(), o = i ? Le(ie(i), e) : "";
|
|
2601
|
+
s("Main page content", o), s("Additional visible page text", Le(ie(document.body), e));
|
|
2602
|
+
const a = t.map(([d, g]) => `${d}:
|
|
2603
|
+
${g}`).join(`
|
|
2608
2604
|
|
|
2609
|
-
`).trim().slice(0, 12e3), l =
|
|
2605
|
+
`).trim().slice(0, 12e3), l = Nn(r, i).trim(), c = `Simplified DOM outline:
|
|
2610
2606
|
`, h = `
|
|
2611
2607
|
|
|
2612
2608
|
Visible page text:
|
|
2613
|
-
`,
|
|
2609
|
+
`, p = 12e3 - c.length - h.length, I = Math.min(a.length, 7900), f = l.slice(0, p - I), u = a.slice(0, p - f.length);
|
|
2614
2610
|
return `${c}${f}${h}${u}`;
|
|
2615
2611
|
}
|
|
2616
|
-
function
|
|
2612
|
+
function ie(t) {
|
|
2617
2613
|
return t.innerText ?? t.textContent ?? "";
|
|
2618
2614
|
}
|
|
2619
|
-
function
|
|
2615
|
+
function J(t) {
|
|
2620
2616
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2621
2617
|
`).split(`
|
|
2622
2618
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2624,20 +2620,20 @@ function G(t) {
|
|
|
2624
2620
|
|
|
2625
2621
|
`).trim();
|
|
2626
2622
|
}
|
|
2627
|
-
function
|
|
2628
|
-
let s =
|
|
2623
|
+
function Le(t, e) {
|
|
2624
|
+
let s = J(t);
|
|
2629
2625
|
for (const n of e)
|
|
2630
2626
|
s = s.replace(n, "");
|
|
2631
|
-
return
|
|
2627
|
+
return J(s);
|
|
2632
2628
|
}
|
|
2633
|
-
function
|
|
2629
|
+
function Ft(t) {
|
|
2634
2630
|
const e = window.getComputedStyle(t);
|
|
2635
2631
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2636
2632
|
}
|
|
2637
|
-
function
|
|
2638
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2633
|
+
function Ln() {
|
|
2634
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ft).sort((t, e) => ie(e).length - ie(t).length)[0] ?? null;
|
|
2639
2635
|
}
|
|
2640
|
-
function
|
|
2636
|
+
function Nn(t, e) {
|
|
2641
2637
|
const s = /* @__PURE__ */ new Set([
|
|
2642
2638
|
"main",
|
|
2643
2639
|
"nav",
|
|
@@ -2717,8 +2713,8 @@ function qn(t, e) {
|
|
|
2717
2713
|
"data-test",
|
|
2718
2714
|
"data-qa",
|
|
2719
2715
|
"data-cy"
|
|
2720
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets:
|
|
2721
|
-
e &&
|
|
2716
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: p } = xn(), I = new Set(t);
|
|
2717
|
+
e && I.add(e);
|
|
2722
2718
|
let f = 0;
|
|
2723
2719
|
const u = (m) => {
|
|
2724
2720
|
const C = m.getAttribute("role");
|
|
@@ -2726,79 +2722,79 @@ function qn(t, e) {
|
|
|
2726
2722
|
}, d = (m) => {
|
|
2727
2723
|
const C = m.getAttribute("data-testid") || m.getAttribute("data-test") || m.getAttribute("data-qa") || m.getAttribute("data-cy") || "";
|
|
2728
2724
|
return `${m.tagName.toLowerCase()}|${u(m)}|${C}`;
|
|
2729
|
-
},
|
|
2730
|
-
const
|
|
2731
|
-
const
|
|
2732
|
-
if (f >= 1e3 && !
|
|
2725
|
+
}, g = (m, C, $) => {
|
|
2726
|
+
const D = (R, Z) => {
|
|
2727
|
+
const k = R.tagName.toLowerCase(), ee = window.getComputedStyle(R), j = h.has(R);
|
|
2728
|
+
if (f >= 1e3 && !j || $.has(R) || i.has(k) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ee.display === "none" || ee.visibility === "hidden")
|
|
2733
2729
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2734
2730
|
f += 1;
|
|
2735
|
-
const
|
|
2736
|
-
for (const y of
|
|
2737
|
-
const
|
|
2738
|
-
|
|
2731
|
+
const K = u(R), G = Kt(R), F = a.has(K) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(k) || k === "a" && R.hasAttribute("href"), E = Array.from(R.children).filter((y) => y instanceof HTMLElement), b = /* @__PURE__ */ new Map();
|
|
2732
|
+
for (const y of E) {
|
|
2733
|
+
const M = d(y);
|
|
2734
|
+
b.set(M, (b.get(M) ?? 0) + 1);
|
|
2739
2735
|
}
|
|
2740
|
-
const
|
|
2741
|
-
for (const y of
|
|
2742
|
-
const
|
|
2743
|
-
rt.set(
|
|
2736
|
+
const Ae = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Map();
|
|
2737
|
+
for (const y of E) {
|
|
2738
|
+
const M = d(y), x = rt.get(M) ?? 0;
|
|
2739
|
+
rt.set(M, x + 1), (b.get(M) ?? 0) > 8 && x >= 6 && !h.has(y) && Ae.set(M, (Ae.get(M) ?? 0) + 1);
|
|
2744
2740
|
}
|
|
2745
|
-
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(),
|
|
2746
|
-
for (const y of
|
|
2747
|
-
const
|
|
2748
|
-
if (it.set(
|
|
2749
|
-
ot.has(
|
|
2741
|
+
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(), Re = [], at = [];
|
|
2742
|
+
for (const y of E) {
|
|
2743
|
+
const M = d(y), x = b.get(M) ?? 0, ut = it.get(M) ?? 0;
|
|
2744
|
+
if (it.set(M, ut + 1), x > 8 && ut >= 6 && !h.has(y)) {
|
|
2745
|
+
ot.has(M) || (Re.push([`… ${Ae.get(M) ?? 0} similar siblings omitted`]), ot.add(M));
|
|
2750
2746
|
continue;
|
|
2751
2747
|
}
|
|
2752
|
-
const dt =
|
|
2753
|
-
at.push(dt),
|
|
2748
|
+
const dt = D(y, Z);
|
|
2749
|
+
at.push(dt), Re.push(dt.lines);
|
|
2754
2750
|
}
|
|
2755
|
-
const
|
|
2756
|
-
if (
|
|
2757
|
-
for (const y of Array.from(
|
|
2758
|
-
y instanceof HTMLElement &&
|
|
2759
|
-
const
|
|
2760
|
-
[
|
|
2761
|
-
).slice(0, 180),
|
|
2762
|
-
if (
|
|
2763
|
-
const y =
|
|
2764
|
-
|
|
2751
|
+
const Ee = [];
|
|
2752
|
+
if (R.shadowRoot)
|
|
2753
|
+
for (const y of Array.from(R.shadowRoot.children))
|
|
2754
|
+
y instanceof HTMLElement && Ee.push(D(y, Z + 1));
|
|
2755
|
+
const ae = [...at, ...Ee], Ce = G.length > 0 || F || ae.some((y) => y.hasUsefulContent), lt = J(
|
|
2756
|
+
[G, ...ae.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2757
|
+
).slice(0, 180), ps = R.hasAttribute("contenteditable") && (G.length > 0 || !R.querySelector("[contenteditable]")), ct = c.some((y) => R.hasAttribute(y)) || !!K || ps, ke = (R.getClientRects().length > 0 || ee.display === "contents") && (s.has(k) || ct || j) && (Ce || j) && (!r.has(k) || Ce || ct || j), _e = ke ? 1 : 0, te = [];
|
|
2758
|
+
if (ke) {
|
|
2759
|
+
const y = ae.some((x) => x.containsTextElement), M = n.has(k) && !y ? lt : G;
|
|
2760
|
+
te.push(zt(R, l, o, M.slice(0, 180)));
|
|
2765
2761
|
}
|
|
2766
|
-
for (const y of
|
|
2767
|
-
|
|
2768
|
-
const be =
|
|
2762
|
+
for (const y of Re)
|
|
2763
|
+
te.push(...de(y, _e));
|
|
2764
|
+
const be = Ee.flatMap((y) => y.lines);
|
|
2769
2765
|
if (be.length > 0) {
|
|
2770
2766
|
const y = be.slice(0, 20);
|
|
2771
2767
|
be.length > y.length && y.push("… shadow DOM omitted");
|
|
2772
|
-
const
|
|
2773
|
-
if (
|
|
2774
|
-
const
|
|
2775
|
-
|
|
2768
|
+
const M = k.includes("tooltip") || k.includes("popper") || k.includes("loader");
|
|
2769
|
+
if (Z < 2 && !M) {
|
|
2770
|
+
const x = ke ? "#shadow-root" : `${k} #shadow-root`;
|
|
2771
|
+
te.push(...de([x, ...de(y, 1)], _e));
|
|
2776
2772
|
} else
|
|
2777
|
-
|
|
2773
|
+
te.push(...de(y, _e));
|
|
2778
2774
|
}
|
|
2779
2775
|
return {
|
|
2780
|
-
lines:
|
|
2781
|
-
hasUsefulContent:
|
|
2776
|
+
lines: te,
|
|
2777
|
+
hasUsefulContent: Ce,
|
|
2782
2778
|
textPreview: lt,
|
|
2783
|
-
containsTextElement: n.has(
|
|
2779
|
+
containsTextElement: n.has(k) || ae.some((y) => y.containsTextElement)
|
|
2784
2780
|
};
|
|
2785
2781
|
};
|
|
2786
|
-
return [`--- ${C} ---`, ...
|
|
2782
|
+
return [`--- ${C} ---`, ...D(m, 0).lines].join(`
|
|
2787
2783
|
`);
|
|
2788
|
-
},
|
|
2789
|
-
S &&
|
|
2790
|
-
${JSON.stringify(S)}`),
|
|
2784
|
+
}, T = [], S = J(window.getSelection()?.toString() ?? "");
|
|
2785
|
+
S && T.push(`--- selected text ---
|
|
2786
|
+
${JSON.stringify(S)}`), p.length > 0 && T.push(Bn(p, s, l, o));
|
|
2791
2787
|
for (const m of t.slice(0, 3))
|
|
2792
|
-
|
|
2793
|
-
if (e &&
|
|
2788
|
+
T.push(g(m, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2789
|
+
if (e && T.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
2794
2790
|
const m = e || t.length ? "other visible DOM" : "visible DOM";
|
|
2795
|
-
|
|
2791
|
+
T.push(g(document.body, m, I));
|
|
2796
2792
|
}
|
|
2797
|
-
return
|
|
2793
|
+
return T.join(`
|
|
2798
2794
|
|
|
2799
2795
|
`);
|
|
2800
2796
|
}
|
|
2801
|
-
function
|
|
2797
|
+
function zt(t, e, s, n) {
|
|
2802
2798
|
const r = t.tagName.toLowerCase();
|
|
2803
2799
|
let i = r;
|
|
2804
2800
|
const o = t.getAttribute("id");
|
|
@@ -2824,11 +2820,11 @@ function xn() {
|
|
|
2824
2820
|
return;
|
|
2825
2821
|
const h = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
2826
2822
|
h.add(l), e.set(a, h);
|
|
2827
|
-
let
|
|
2828
|
-
for (;
|
|
2829
|
-
t.add(
|
|
2830
|
-
const
|
|
2831
|
-
|
|
2823
|
+
let p = a;
|
|
2824
|
+
for (; p; ) {
|
|
2825
|
+
t.add(p);
|
|
2826
|
+
const I = p.getRootNode();
|
|
2827
|
+
p = p.parentElement ?? (I instanceof ShadowRoot && I.host instanceof HTMLElement ? I.host : null);
|
|
2832
2828
|
}
|
|
2833
2829
|
};
|
|
2834
2830
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -2836,7 +2832,7 @@ function xn() {
|
|
|
2836
2832
|
n = n.shadowRoot.activeElement;
|
|
2837
2833
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2838
2834
|
const r = window.getSelection();
|
|
2839
|
-
r && !r.isCollapsed && (s(
|
|
2835
|
+
r && !r.isCollapsed && (s(Et(r.anchorNode), "selected text"), s(Et(r.focusNode), "selected text"));
|
|
2840
2836
|
const i = [
|
|
2841
2837
|
["[aria-selected='true']", "selected"],
|
|
2842
2838
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2848,8 +2844,8 @@ function xn() {
|
|
|
2848
2844
|
for (let a = 0; a < o.length; a += 1) {
|
|
2849
2845
|
const l = o[a];
|
|
2850
2846
|
for (const [c, h] of i)
|
|
2851
|
-
for (const
|
|
2852
|
-
s(
|
|
2847
|
+
for (const p of Array.from(l.querySelectorAll(c)))
|
|
2848
|
+
s(p, h);
|
|
2853
2849
|
for (const c of Array.from(l.querySelectorAll("*")))
|
|
2854
2850
|
c.shadowRoot && o.push(c.shadowRoot);
|
|
2855
2851
|
}
|
|
@@ -2866,40 +2862,40 @@ function Bn(t, e, s, n) {
|
|
|
2866
2862
|
for (; a; ) {
|
|
2867
2863
|
const h = a.tagName.toLowerCase();
|
|
2868
2864
|
(a === i.element || e.has(h) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
2869
|
-
const
|
|
2870
|
-
a = a.parentElement ?? (
|
|
2865
|
+
const p = a.getRootNode();
|
|
2866
|
+
a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
|
|
2871
2867
|
}
|
|
2872
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((h,
|
|
2868
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((h, p) => zt(
|
|
2873
2869
|
h,
|
|
2874
2870
|
s,
|
|
2875
2871
|
n,
|
|
2876
|
-
|
|
2872
|
+
p === l.length - 1 ? Kt(h).slice(0, 180) : ""
|
|
2877
2873
|
));
|
|
2878
2874
|
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
2879
2875
|
}
|
|
2880
2876
|
return r.join(`
|
|
2881
2877
|
`);
|
|
2882
2878
|
}
|
|
2883
|
-
function
|
|
2879
|
+
function Et(t) {
|
|
2884
2880
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
2885
2881
|
}
|
|
2886
|
-
function
|
|
2882
|
+
function de(t, e) {
|
|
2887
2883
|
if (e === 0)
|
|
2888
2884
|
return t;
|
|
2889
2885
|
const s = " ".repeat(e);
|
|
2890
2886
|
return t.map((n) => `${s}${n}`);
|
|
2891
2887
|
}
|
|
2892
|
-
function
|
|
2893
|
-
return
|
|
2888
|
+
function Kt(t) {
|
|
2889
|
+
return J(
|
|
2894
2890
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
2895
2891
|
);
|
|
2896
2892
|
}
|
|
2897
2893
|
function Wn(t) {
|
|
2898
2894
|
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);
|
|
2899
2895
|
}
|
|
2900
|
-
function
|
|
2896
|
+
function Gt() {
|
|
2901
2897
|
const t = document.querySelector(ht);
|
|
2902
|
-
if (!(t ?? document.querySelector(
|
|
2898
|
+
if (!(t ?? document.querySelector(He)))
|
|
2903
2899
|
return;
|
|
2904
2900
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2905
2901
|
return {
|
|
@@ -2908,22 +2904,22 @@ function jt() {
|
|
|
2908
2904
|
selectors: [
|
|
2909
2905
|
{
|
|
2910
2906
|
name: "widget_host",
|
|
2911
|
-
selector: s === "browser_extension_sdk_preview" ? ht :
|
|
2907
|
+
selector: s === "browser_extension_sdk_preview" ? ht : He,
|
|
2912
2908
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2913
2909
|
},
|
|
2914
2910
|
{
|
|
2915
2911
|
name: "widget_root",
|
|
2916
|
-
selector:
|
|
2912
|
+
selector: Ns,
|
|
2917
2913
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2918
2914
|
},
|
|
2919
2915
|
{
|
|
2920
2916
|
name: "widget_panel",
|
|
2921
|
-
selector:
|
|
2917
|
+
selector: xs,
|
|
2922
2918
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2923
2919
|
},
|
|
2924
2920
|
{
|
|
2925
2921
|
name: "widget_timeline",
|
|
2926
|
-
selector:
|
|
2922
|
+
selector: Bs,
|
|
2927
2923
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2928
2924
|
}
|
|
2929
2925
|
]
|
|
@@ -2947,16 +2943,16 @@ function $n(t) {
|
|
|
2947
2943
|
return null;
|
|
2948
2944
|
}
|
|
2949
2945
|
}
|
|
2950
|
-
function
|
|
2946
|
+
function Ct(t, e) {
|
|
2951
2947
|
if (!t || typeof t != "object")
|
|
2952
2948
|
return [];
|
|
2953
2949
|
const s = t[e];
|
|
2954
2950
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2955
2951
|
}
|
|
2956
|
-
function
|
|
2952
|
+
function jn(t) {
|
|
2957
2953
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
2958
2954
|
}
|
|
2959
|
-
function
|
|
2955
|
+
function Fn(t) {
|
|
2960
2956
|
if (!t || typeof t != "object")
|
|
2961
2957
|
return null;
|
|
2962
2958
|
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;
|
|
@@ -2996,7 +2992,7 @@ function Xn() {
|
|
|
2996
2992
|
const s = crypto.randomUUID();
|
|
2997
2993
|
return window.localStorage.setItem(t, s), s;
|
|
2998
2994
|
}
|
|
2999
|
-
function
|
|
2995
|
+
function B() {
|
|
3000
2996
|
return crypto.randomUUID();
|
|
3001
2997
|
}
|
|
3002
2998
|
function Vn(t) {
|
|
@@ -3010,9 +3006,9 @@ function Vn(t) {
|
|
|
3010
3006
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
3011
3007
|
} : null;
|
|
3012
3008
|
}
|
|
3013
|
-
function
|
|
3009
|
+
function kt(t, e) {
|
|
3014
3010
|
return Array.isArray(t) ? Ge(
|
|
3015
|
-
t.map((s) =>
|
|
3011
|
+
t.map((s) => Xt(s, e)).filter((s) => s !== null)
|
|
3016
3012
|
) : [];
|
|
3017
3013
|
}
|
|
3018
3014
|
function Jn(t) {
|
|
@@ -3036,29 +3032,29 @@ function Jn(t) {
|
|
|
3036
3032
|
];
|
|
3037
3033
|
}) : [];
|
|
3038
3034
|
}
|
|
3039
|
-
function
|
|
3035
|
+
function Xt(t, e) {
|
|
3040
3036
|
if (!t || typeof t != "object")
|
|
3041
3037
|
return null;
|
|
3042
3038
|
const s = t, n = s.data;
|
|
3043
3039
|
if (!n || typeof n != "object")
|
|
3044
3040
|
return null;
|
|
3045
3041
|
const r = n;
|
|
3046
|
-
if (r.hiddenFromTranscript === !0 ||
|
|
3042
|
+
if (r.hiddenFromTranscript === !0 || As(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
3047
3043
|
return null;
|
|
3048
3044
|
if (r.type === "message") {
|
|
3049
3045
|
const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
|
|
3050
3046
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3051
3047
|
role: i,
|
|
3052
3048
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
3053
|
-
content:
|
|
3054
|
-
|
|
3049
|
+
content: ws(
|
|
3050
|
+
rr(r.content),
|
|
3055
3051
|
e
|
|
3056
3052
|
),
|
|
3057
3053
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3058
|
-
...
|
|
3059
|
-
respondsToUserMessageId:
|
|
3060
|
-
...
|
|
3061
|
-
attachments:
|
|
3054
|
+
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3055
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3056
|
+
..._(r) ? { runId: _(r) } : {},
|
|
3057
|
+
attachments: ss(r.attachments, e)
|
|
3062
3058
|
};
|
|
3063
3059
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
3064
3060
|
value: r.id,
|
|
@@ -3069,55 +3065,67 @@ function zt(t, e) {
|
|
|
3069
3065
|
}), o;
|
|
3070
3066
|
}
|
|
3071
3067
|
if (r.type === "function_call_output") {
|
|
3072
|
-
const i =
|
|
3068
|
+
const i = qs(r.output);
|
|
3073
3069
|
if (i)
|
|
3074
3070
|
return {
|
|
3075
3071
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3076
3072
|
role: "tool",
|
|
3077
3073
|
content: "",
|
|
3078
3074
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3079
|
-
respondsToUserMessageId:
|
|
3080
|
-
...
|
|
3075
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3076
|
+
..._(r) ? { runId: _(r) } : {},
|
|
3081
3077
|
dataType: "scheduled_check_in",
|
|
3082
|
-
toolName:
|
|
3083
|
-
callId:
|
|
3078
|
+
toolName: Bt,
|
|
3079
|
+
callId: he(r) ?? void 0,
|
|
3084
3080
|
scheduledCheckInAt: i
|
|
3085
3081
|
};
|
|
3086
|
-
const o = Qn(r.output);
|
|
3082
|
+
const o = Qn(r.output), a = Zn(r.output);
|
|
3087
3083
|
return o ? {
|
|
3088
3084
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3089
3085
|
role: "tool",
|
|
3090
3086
|
content: `Connect ${o.appName} to continue`,
|
|
3091
3087
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3092
|
-
...
|
|
3093
|
-
respondsToUserMessageId:
|
|
3094
|
-
...
|
|
3088
|
+
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3089
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3090
|
+
..._(r) ? { runId: _(r) } : {},
|
|
3095
3091
|
dataType: "function_call_output",
|
|
3096
3092
|
toolName: "authenticate_pipedream_app",
|
|
3097
|
-
callId:
|
|
3093
|
+
callId: he(r) ?? void 0,
|
|
3098
3094
|
integrationAuthRequest: o
|
|
3095
|
+
} : a ? {
|
|
3096
|
+
id: String(s.id ?? crypto.randomUUID()),
|
|
3097
|
+
role: "tool",
|
|
3098
|
+
content: "Connect WhatsApp to continue",
|
|
3099
|
+
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3100
|
+
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3101
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3102
|
+
..._(r) ? { runId: _(r) } : {},
|
|
3103
|
+
dataType: "function_call_output",
|
|
3104
|
+
toolName: "request_personal_channel_connection",
|
|
3105
|
+
callId: he(r) ?? void 0,
|
|
3106
|
+
personalChannelConnectionRequest: a
|
|
3099
3107
|
} : null;
|
|
3100
3108
|
}
|
|
3101
3109
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
3102
3110
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3103
3111
|
role: "tool",
|
|
3104
|
-
content: r.type === "mcp_call" ? Yn(r) :
|
|
3112
|
+
content: r.type === "mcp_call" ? Yn(r) : tr(r),
|
|
3105
3113
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3106
|
-
...
|
|
3107
|
-
respondsToUserMessageId:
|
|
3108
|
-
...
|
|
3114
|
+
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3115
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3116
|
+
..._(r) ? { runId: _(r) } : {},
|
|
3109
3117
|
dataType: String(r.type),
|
|
3110
3118
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
3111
|
-
callId:
|
|
3119
|
+
callId: he(r) ?? void 0,
|
|
3112
3120
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
3113
3121
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
3114
3122
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3115
3123
|
role: "system",
|
|
3116
|
-
content:
|
|
3124
|
+
content: er(r),
|
|
3117
3125
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3118
|
-
...
|
|
3119
|
-
respondsToUserMessageId:
|
|
3120
|
-
...
|
|
3126
|
+
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3127
|
+
respondsToUserMessageId: q(r) ?? void 0,
|
|
3128
|
+
..._(r) ? { runId: _(r) } : {},
|
|
3121
3129
|
dataType: String(r.type),
|
|
3122
3130
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
3123
3131
|
...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
|
|
@@ -3147,9 +3155,24 @@ function Qn(t) {
|
|
|
3147
3155
|
}
|
|
3148
3156
|
}
|
|
3149
3157
|
function Zn(t) {
|
|
3150
|
-
|
|
3158
|
+
if (typeof t != "string")
|
|
3159
|
+
return null;
|
|
3160
|
+
try {
|
|
3161
|
+
const e = JSON.parse(t);
|
|
3162
|
+
return e.type !== "personal_channel_connection_required" || typeof e.request_id != "string" || e.channel !== "whatsapp" || typeof e.management_url != "string" ? null : {
|
|
3163
|
+
type: "personal_channel_connection_required",
|
|
3164
|
+
requestId: e.request_id,
|
|
3165
|
+
channel: "whatsapp",
|
|
3166
|
+
managementUrl: e.management_url
|
|
3167
|
+
};
|
|
3168
|
+
} catch {
|
|
3169
|
+
return null;
|
|
3170
|
+
}
|
|
3151
3171
|
}
|
|
3152
3172
|
function er(t) {
|
|
3173
|
+
return t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message : "";
|
|
3174
|
+
}
|
|
3175
|
+
function tr(t) {
|
|
3153
3176
|
if (t.type === "web_search_call") {
|
|
3154
3177
|
const e = t.action;
|
|
3155
3178
|
if (e && typeof e == "object") {
|
|
@@ -3161,26 +3184,26 @@ function er(t) {
|
|
|
3161
3184
|
}
|
|
3162
3185
|
return "🔎 Searching the web";
|
|
3163
3186
|
}
|
|
3164
|
-
return
|
|
3187
|
+
return sr(t);
|
|
3165
3188
|
}
|
|
3166
|
-
function
|
|
3189
|
+
function sr(t) {
|
|
3167
3190
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3168
|
-
return
|
|
3191
|
+
return V(t.summary);
|
|
3169
3192
|
if (typeof t.arguments == "string")
|
|
3170
3193
|
try {
|
|
3171
3194
|
const e = JSON.parse(t.arguments);
|
|
3172
3195
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
3173
|
-
return
|
|
3196
|
+
return V(e.summary);
|
|
3174
3197
|
} catch {
|
|
3175
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3198
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? V(t.name) : "🛠️ Run tool";
|
|
3176
3199
|
}
|
|
3177
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3200
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? V(t.name) : "🛠️ Run tool";
|
|
3178
3201
|
}
|
|
3179
|
-
function
|
|
3202
|
+
function V(t) {
|
|
3180
3203
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3181
3204
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3182
3205
|
}
|
|
3183
|
-
function
|
|
3206
|
+
function nr(t) {
|
|
3184
3207
|
if (t == null)
|
|
3185
3208
|
return t;
|
|
3186
3209
|
if (typeof t != "object")
|
|
@@ -3195,14 +3218,14 @@ function sr(t) {
|
|
|
3195
3218
|
runId: typeof e.runId == "string" ? e.runId : null
|
|
3196
3219
|
};
|
|
3197
3220
|
}
|
|
3198
|
-
function
|
|
3221
|
+
function he(t) {
|
|
3199
3222
|
const e = t.callId ?? t.call_id;
|
|
3200
3223
|
return typeof e == "string" && e ? e : null;
|
|
3201
3224
|
}
|
|
3202
|
-
function
|
|
3225
|
+
function v(t) {
|
|
3203
3226
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
3204
3227
|
}
|
|
3205
|
-
function
|
|
3228
|
+
function rr(t) {
|
|
3206
3229
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
3207
3230
|
if (!e || typeof e != "object")
|
|
3208
3231
|
return "";
|
|
@@ -3210,10 +3233,10 @@ function nr(t) {
|
|
|
3210
3233
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
3211
3234
|
}).filter(Boolean).join("") : "";
|
|
3212
3235
|
}
|
|
3213
|
-
function
|
|
3214
|
-
const s =
|
|
3215
|
-
|
|
3216
|
-
|
|
3236
|
+
function je(t, e) {
|
|
3237
|
+
const s = Jt(t, e), n = ur(
|
|
3238
|
+
ir(
|
|
3239
|
+
fr(t, e),
|
|
3217
3240
|
s
|
|
3218
3241
|
),
|
|
3219
3242
|
s
|
|
@@ -3225,7 +3248,7 @@ function $e(t, e) {
|
|
|
3225
3248
|
const i = [...n];
|
|
3226
3249
|
return i[r] = s, Ge(i);
|
|
3227
3250
|
}
|
|
3228
|
-
function
|
|
3251
|
+
function ir(t, e) {
|
|
3229
3252
|
const s = e.assistantDraftItemId;
|
|
3230
3253
|
return s ? t.map(
|
|
3231
3254
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
@@ -3234,7 +3257,7 @@ function rr(t, e) {
|
|
|
3234
3257
|
function Ne(t, e, s) {
|
|
3235
3258
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3236
3259
|
}
|
|
3237
|
-
function
|
|
3260
|
+
function or(t, e, s, n) {
|
|
3238
3261
|
if (s === null) return t;
|
|
3239
3262
|
let r = -1;
|
|
3240
3263
|
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
@@ -3251,12 +3274,12 @@ function ir(t, e, s, n) {
|
|
|
3251
3274
|
respondsToUserMessageId: s
|
|
3252
3275
|
}, i;
|
|
3253
3276
|
}
|
|
3254
|
-
function
|
|
3277
|
+
function ar(t, e) {
|
|
3255
3278
|
const s = t.findIndex(
|
|
3256
3279
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3257
3280
|
);
|
|
3258
3281
|
if (s === -1)
|
|
3259
|
-
return
|
|
3282
|
+
return je(t, e);
|
|
3260
3283
|
const n = [...t];
|
|
3261
3284
|
return n[s] = {
|
|
3262
3285
|
...n[s],
|
|
@@ -3268,19 +3291,19 @@ function or(t, e) {
|
|
|
3268
3291
|
...n[s].runId ? {} : { runId: e.runId }
|
|
3269
3292
|
}, n;
|
|
3270
3293
|
}
|
|
3271
|
-
function
|
|
3294
|
+
function lr(t, e, s) {
|
|
3272
3295
|
let n = !1;
|
|
3273
3296
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
3274
3297
|
return n ? r : t;
|
|
3275
3298
|
}
|
|
3276
|
-
function
|
|
3299
|
+
function cr(t) {
|
|
3277
3300
|
if (t.hiddenFromTranscript === !0)
|
|
3278
3301
|
return null;
|
|
3279
3302
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
3280
3303
|
return !e || !s ? null : {
|
|
3281
3304
|
id: `transient-activity:${e}`,
|
|
3282
3305
|
role: "tool",
|
|
3283
|
-
content:
|
|
3306
|
+
content: V(
|
|
3284
3307
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3285
3308
|
),
|
|
3286
3309
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3293,7 +3316,7 @@ function lr(t) {
|
|
|
3293
3316
|
loading: !0
|
|
3294
3317
|
};
|
|
3295
3318
|
}
|
|
3296
|
-
function
|
|
3319
|
+
function ur(t, e) {
|
|
3297
3320
|
if (e.id.startsWith("transient-activity:"))
|
|
3298
3321
|
return t;
|
|
3299
3322
|
const s = e.toolName === "tab_lifecycle";
|
|
@@ -3302,24 +3325,24 @@ function cr(t, e) {
|
|
|
3302
3325
|
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);
|
|
3303
3326
|
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
3304
3327
|
}
|
|
3305
|
-
function
|
|
3306
|
-
return
|
|
3328
|
+
function dr(t, e) {
|
|
3329
|
+
return Rs(
|
|
3307
3330
|
t,
|
|
3308
3331
|
e.map(
|
|
3309
|
-
(s) =>
|
|
3332
|
+
(s) => Jt(t, s)
|
|
3310
3333
|
),
|
|
3311
|
-
|
|
3334
|
+
Vt
|
|
3312
3335
|
);
|
|
3313
3336
|
}
|
|
3314
|
-
function
|
|
3337
|
+
function hr(t, e, s) {
|
|
3315
3338
|
const n = new Map(e.map((i) => [i.id, i]));
|
|
3316
3339
|
return [
|
|
3317
3340
|
...t.filter((i) => s.has(i.id)).map((i) => n.get(i.id) ?? i),
|
|
3318
3341
|
...e.filter((i) => !s.has(i.id))
|
|
3319
3342
|
];
|
|
3320
3343
|
}
|
|
3321
|
-
function
|
|
3322
|
-
const e =
|
|
3344
|
+
function Vt(t) {
|
|
3345
|
+
const e = Y(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3323
3346
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3324
3347
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3325
3348
|
];
|
|
@@ -3330,52 +3353,52 @@ function Kt(t) {
|
|
|
3330
3353
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3331
3354
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3332
3355
|
...t.runId ? { runId: t.runId } : {},
|
|
3333
|
-
isOptimistic:
|
|
3356
|
+
isOptimistic: we(t),
|
|
3334
3357
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3335
3358
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3336
3359
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3337
3360
|
};
|
|
3338
3361
|
}
|
|
3339
|
-
function
|
|
3362
|
+
function Jt(t, e) {
|
|
3340
3363
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3341
3364
|
return e;
|
|
3342
3365
|
const s = t.find(
|
|
3343
|
-
(r) => r.role === "user" && (r.id === e.id ||
|
|
3366
|
+
(r) => r.role === "user" && (r.id === e.id || we(r) && Yt(r, e))
|
|
3344
3367
|
);
|
|
3345
3368
|
if (!s?.attachments?.length)
|
|
3346
3369
|
return e;
|
|
3347
3370
|
const n = e.attachments.map((r) => {
|
|
3348
|
-
const i =
|
|
3349
|
-
return i ?
|
|
3371
|
+
const i = pr(s.attachments ?? [], r);
|
|
3372
|
+
return i ? gr(r, i) : r;
|
|
3350
3373
|
});
|
|
3351
3374
|
return { ...e, attachments: n };
|
|
3352
3375
|
}
|
|
3353
|
-
function
|
|
3376
|
+
function pr(t, e) {
|
|
3354
3377
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
3355
3378
|
}
|
|
3356
|
-
function
|
|
3379
|
+
function gr(t, e) {
|
|
3357
3380
|
const { previewUrl: s } = e;
|
|
3358
3381
|
return s ? { ...t, previewUrl: s } : t;
|
|
3359
3382
|
}
|
|
3360
|
-
function
|
|
3383
|
+
function fr(t, e) {
|
|
3361
3384
|
if (e.role !== "user")
|
|
3362
3385
|
return t;
|
|
3363
3386
|
const s = t.findIndex(
|
|
3364
|
-
(r) =>
|
|
3387
|
+
(r) => we(r) && Yt(r, e)
|
|
3365
3388
|
);
|
|
3366
3389
|
if (s === -1)
|
|
3367
3390
|
return t;
|
|
3368
3391
|
const n = [...t];
|
|
3369
3392
|
return n.splice(s, 1), n;
|
|
3370
3393
|
}
|
|
3371
|
-
function
|
|
3372
|
-
const s =
|
|
3394
|
+
function Yt(t, e) {
|
|
3395
|
+
const s = Y(t), n = Y(e);
|
|
3373
3396
|
return s && n ? s === n : t.content === e.content;
|
|
3374
3397
|
}
|
|
3375
|
-
function
|
|
3398
|
+
function we(t) {
|
|
3376
3399
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3377
3400
|
}
|
|
3378
|
-
function
|
|
3401
|
+
function Y(t) {
|
|
3379
3402
|
const e = t.clientMessageId;
|
|
3380
3403
|
if (e)
|
|
3381
3404
|
return e;
|
|
@@ -3384,47 +3407,69 @@ function se(t) {
|
|
|
3384
3407
|
);
|
|
3385
3408
|
return n ? t.id.slice(n.length) : null;
|
|
3386
3409
|
}
|
|
3387
|
-
function
|
|
3388
|
-
const e =
|
|
3410
|
+
function _t(t) {
|
|
3411
|
+
const e = Qt(t);
|
|
3389
3412
|
if (e === null)
|
|
3390
3413
|
return !1;
|
|
3391
|
-
const s = t[e].id
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
return
|
|
3414
|
+
const s = t[e].id;
|
|
3415
|
+
if (t.some(
|
|
3416
|
+
(r) => r.respondsToUserMessageId === s && ye(r)
|
|
3417
|
+
))
|
|
3418
|
+
return !0;
|
|
3396
3419
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3397
3420
|
const i = t[r];
|
|
3398
|
-
if (
|
|
3399
|
-
|
|
3400
|
-
if (i.role === "system") {
|
|
3401
|
-
if (i.dataType === "run_error")
|
|
3421
|
+
if (!i.respondsToUserMessageId) {
|
|
3422
|
+
if (W(i))
|
|
3402
3423
|
return !0;
|
|
3403
|
-
if (i.
|
|
3404
|
-
|
|
3424
|
+
if (i.role === "system") {
|
|
3425
|
+
if (i.dataType === "run_error")
|
|
3426
|
+
return !0;
|
|
3427
|
+
if (i.dataType === "run_status")
|
|
3428
|
+
return i.loading !== !0;
|
|
3429
|
+
}
|
|
3405
3430
|
}
|
|
3406
3431
|
}
|
|
3407
3432
|
return !1;
|
|
3408
3433
|
}
|
|
3409
|
-
function
|
|
3410
|
-
const
|
|
3434
|
+
function mr(t, e, s) {
|
|
3435
|
+
const n = new Set(
|
|
3436
|
+
t.filter(
|
|
3437
|
+
(r) => r.role === "user" && e !== null && Y(r) === e
|
|
3438
|
+
).map((r) => r.id)
|
|
3439
|
+
);
|
|
3440
|
+
return t.some((r, i) => {
|
|
3441
|
+
if (r.role !== "system" || r.dataType !== "run_error" && (r.dataType !== "run_status" || r.loading === !0 || r.steered === !0))
|
|
3442
|
+
return !1;
|
|
3443
|
+
if (r.respondsToUserMessageId && n.has(r.respondsToUserMessageId))
|
|
3444
|
+
return !0;
|
|
3445
|
+
if (s && r.runId === s) {
|
|
3446
|
+
if (n.size === 0)
|
|
3447
|
+
return !0;
|
|
3448
|
+
const o = Zt(t, i);
|
|
3449
|
+
return !r.respondsToUserMessageId && o !== null && n.has(o);
|
|
3450
|
+
}
|
|
3451
|
+
return !1;
|
|
3452
|
+
});
|
|
3453
|
+
}
|
|
3454
|
+
function yr(t) {
|
|
3455
|
+
const e = Qt(t);
|
|
3411
3456
|
if (e === null)
|
|
3412
|
-
return t.some(
|
|
3457
|
+
return t.some(W);
|
|
3413
3458
|
const s = t[e].id;
|
|
3414
3459
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3415
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3416
|
-
) : t.slice(e + 1).some(
|
|
3460
|
+
(n) => n.respondsToUserMessageId === s && W(n)
|
|
3461
|
+
) : t.slice(e + 1).some(W);
|
|
3417
3462
|
}
|
|
3418
|
-
function
|
|
3463
|
+
function Qt(t) {
|
|
3419
3464
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3420
|
-
if (t[e].role === "user" && !
|
|
3465
|
+
if (t[e].role === "user" && !we(t[e]))
|
|
3421
3466
|
return e;
|
|
3422
3467
|
return null;
|
|
3423
3468
|
}
|
|
3424
|
-
function
|
|
3425
|
-
return
|
|
3469
|
+
function ye(t) {
|
|
3470
|
+
return W(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3426
3471
|
}
|
|
3427
|
-
function
|
|
3472
|
+
function Q(t) {
|
|
3428
3473
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
3429
3474
|
const s = t[e];
|
|
3430
3475
|
if (!s || typeof s != "object")
|
|
@@ -3438,30 +3483,30 @@ function X(t) {
|
|
|
3438
3483
|
}
|
|
3439
3484
|
return null;
|
|
3440
3485
|
}
|
|
3441
|
-
function
|
|
3442
|
-
const e =
|
|
3486
|
+
function Ir(t) {
|
|
3487
|
+
const e = Q(t);
|
|
3443
3488
|
if (e === null)
|
|
3444
3489
|
return null;
|
|
3445
|
-
const n =
|
|
3490
|
+
const n = U(t[e])?.page;
|
|
3446
3491
|
if (!n || typeof n != "object")
|
|
3447
3492
|
return null;
|
|
3448
3493
|
const r = n.url;
|
|
3449
3494
|
return typeof r == "string" ? r : null;
|
|
3450
3495
|
}
|
|
3451
|
-
function
|
|
3496
|
+
function U(t) {
|
|
3452
3497
|
if (!t || typeof t != "object")
|
|
3453
3498
|
return null;
|
|
3454
3499
|
const e = t.data;
|
|
3455
3500
|
return e && typeof e == "object" ? e : null;
|
|
3456
3501
|
}
|
|
3457
|
-
function
|
|
3502
|
+
function Fe(t) {
|
|
3458
3503
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3459
3504
|
}
|
|
3460
3505
|
function bt(t) {
|
|
3461
3506
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3462
3507
|
}
|
|
3463
|
-
function
|
|
3464
|
-
const s =
|
|
3508
|
+
function Tr(t, e) {
|
|
3509
|
+
const s = Q(e);
|
|
3465
3510
|
if (s === null)
|
|
3466
3511
|
return !1;
|
|
3467
3512
|
const n = e[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -3469,11 +3514,11 @@ function yr(t, e) {
|
|
|
3469
3514
|
return !1;
|
|
3470
3515
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3471
3516
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3472
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3473
|
-
) : t.slice(i + 1).some(
|
|
3517
|
+
(o) => o.respondsToUserMessageId === r && ye(o)
|
|
3518
|
+
) : t.slice(i + 1).some(ye);
|
|
3474
3519
|
}
|
|
3475
3520
|
function ze(t) {
|
|
3476
|
-
const e =
|
|
3521
|
+
const e = Q(t);
|
|
3477
3522
|
if (e === null)
|
|
3478
3523
|
return null;
|
|
3479
3524
|
const s = t[e];
|
|
@@ -3485,8 +3530,8 @@ function ze(t) {
|
|
|
3485
3530
|
const r = n.clientMessageId;
|
|
3486
3531
|
return typeof r == "string" ? r : null;
|
|
3487
3532
|
}
|
|
3488
|
-
function
|
|
3489
|
-
const e =
|
|
3533
|
+
function Sr(t) {
|
|
3534
|
+
const e = Q(t);
|
|
3490
3535
|
if (e === null)
|
|
3491
3536
|
return null;
|
|
3492
3537
|
for (let s = t.length - 1; s > e; s -= 1) {
|
|
@@ -3509,13 +3554,13 @@ function Ir(t) {
|
|
|
3509
3554
|
function Ke(t, e) {
|
|
3510
3555
|
if (typeof e.clientMessageId == "string")
|
|
3511
3556
|
return e.clientMessageId;
|
|
3512
|
-
const s =
|
|
3557
|
+
const s = q(e);
|
|
3513
3558
|
if (!s)
|
|
3514
3559
|
return null;
|
|
3515
|
-
const n = t.find((i) => w(i, "id") === s), r =
|
|
3560
|
+
const n = t.find((i) => w(i, "id") === s), r = U(n);
|
|
3516
3561
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3517
3562
|
}
|
|
3518
|
-
function
|
|
3563
|
+
function wr(t, e) {
|
|
3519
3564
|
let s = 0;
|
|
3520
3565
|
for (const n of t) {
|
|
3521
3566
|
if (!n || typeof n != "object")
|
|
@@ -3528,73 +3573,90 @@ function Tr(t, e) {
|
|
|
3528
3573
|
}
|
|
3529
3574
|
return s;
|
|
3530
3575
|
}
|
|
3531
|
-
function
|
|
3532
|
-
if (!e || !
|
|
3576
|
+
function Pt(t, e, s, n, r, i) {
|
|
3577
|
+
if (!e || !Ar(t))
|
|
3578
|
+
return !1;
|
|
3579
|
+
const o = t;
|
|
3580
|
+
if (Fe(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3533
3581
|
return !1;
|
|
3534
|
-
const
|
|
3535
|
-
return
|
|
3582
|
+
const a = q(o);
|
|
3583
|
+
return n !== null ? a !== null ? a === n : r !== null && _(o) === r && i === n : r === null || _(o) === r;
|
|
3536
3584
|
}
|
|
3537
|
-
function
|
|
3585
|
+
function Mr(t, e) {
|
|
3586
|
+
for (let s = e - 1; s >= 0; s -= 1) {
|
|
3587
|
+
const n = U(t[s]);
|
|
3588
|
+
if (n?.type === "message" && n.role === "user")
|
|
3589
|
+
return w(t[s], "id");
|
|
3590
|
+
}
|
|
3591
|
+
return null;
|
|
3592
|
+
}
|
|
3593
|
+
function Zt(t, e) {
|
|
3594
|
+
for (let s = e - 1; s >= 0; s -= 1)
|
|
3595
|
+
if (t[s].role === "user")
|
|
3596
|
+
return t[s].id;
|
|
3597
|
+
return null;
|
|
3598
|
+
}
|
|
3599
|
+
function Ar(t) {
|
|
3538
3600
|
if (!t || typeof t != "object")
|
|
3539
3601
|
return !1;
|
|
3540
3602
|
const e = t;
|
|
3541
3603
|
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");
|
|
3542
3604
|
}
|
|
3543
|
-
function
|
|
3605
|
+
function W(t) {
|
|
3544
3606
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3545
3607
|
}
|
|
3546
|
-
function
|
|
3608
|
+
function Rr(t) {
|
|
3547
3609
|
if (!t || typeof t != "object")
|
|
3548
3610
|
return !1;
|
|
3549
3611
|
const e = t;
|
|
3550
3612
|
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";
|
|
3551
3613
|
}
|
|
3552
3614
|
function Ge(t) {
|
|
3553
|
-
return t.filter((e, s) =>
|
|
3615
|
+
return t.filter((e, s) => H(e) ? !Or(t, s) && !es(t, s) && !Dr(t, s) && !vr(t, s) : Er(e) ? e.retryable === !0 && Ur(t, s) ? !1 : !Pr(t, s) : !0);
|
|
3554
3616
|
}
|
|
3555
|
-
function
|
|
3617
|
+
function Er(t) {
|
|
3556
3618
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3557
3619
|
}
|
|
3558
|
-
function
|
|
3620
|
+
function H(t) {
|
|
3559
3621
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3560
3622
|
}
|
|
3561
|
-
function
|
|
3623
|
+
function Cr(t, e, s, n) {
|
|
3562
3624
|
const r = t.findIndex(
|
|
3563
|
-
(l, c) =>
|
|
3625
|
+
(l, c) => H(l) && !es(t, c)
|
|
3564
3626
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3565
3627
|
(l) => l.role === "user" && l.id === o
|
|
3566
3628
|
) : null;
|
|
3567
3629
|
return {
|
|
3568
|
-
clientMessageId: a ?
|
|
3630
|
+
clientMessageId: a ? Y(a) : o ? null : n,
|
|
3569
3631
|
respondsToUserMessageId: o,
|
|
3570
3632
|
runId: s ?? i?.runId ?? null
|
|
3571
3633
|
};
|
|
3572
3634
|
}
|
|
3573
|
-
function
|
|
3635
|
+
function xe(t) {
|
|
3574
3636
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3575
3637
|
}
|
|
3576
|
-
function
|
|
3638
|
+
function Ut(t, e, s) {
|
|
3577
3639
|
const n = new Set(
|
|
3578
3640
|
t.filter(
|
|
3579
|
-
(r) => r.role === "user" && e !== null &&
|
|
3641
|
+
(r) => r.role === "user" && e !== null && Y(r) === e
|
|
3580
3642
|
).map((r) => r.id)
|
|
3581
3643
|
);
|
|
3582
3644
|
return t.filter(
|
|
3583
|
-
(r) => !
|
|
3645
|
+
(r) => !H(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3584
3646
|
);
|
|
3585
3647
|
}
|
|
3586
|
-
function
|
|
3648
|
+
function es(t, e) {
|
|
3587
3649
|
return t.some(
|
|
3588
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
3650
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && kr(
|
|
3589
3651
|
t,
|
|
3590
3652
|
e,
|
|
3591
3653
|
n
|
|
3592
3654
|
)
|
|
3593
3655
|
);
|
|
3594
3656
|
}
|
|
3595
|
-
function
|
|
3657
|
+
function kr(t, e, s) {
|
|
3596
3658
|
const n = t[e], r = t[s];
|
|
3597
|
-
if (
|
|
3659
|
+
if (oe(n, r))
|
|
3598
3660
|
return !0;
|
|
3599
3661
|
if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
|
|
3600
3662
|
return !1;
|
|
@@ -3603,35 +3665,35 @@ function Rr(t, e, s) {
|
|
|
3603
3665
|
return t[i].id === n.respondsToUserMessageId;
|
|
3604
3666
|
return !1;
|
|
3605
3667
|
}
|
|
3606
|
-
function
|
|
3668
|
+
function _r(t, e) {
|
|
3607
3669
|
const s = [...t].reverse().find(
|
|
3608
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
3670
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Dt(n) && !br(
|
|
3609
3671
|
t,
|
|
3610
3672
|
n.respondsToUserMessageId
|
|
3611
3673
|
)
|
|
3612
3674
|
)?.respondsToUserMessageId;
|
|
3613
3675
|
return s ? t.map(
|
|
3614
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3676
|
+
(n) => n.respondsToUserMessageId === s && Dt(n) ? { ...n, steered: !0 } : n
|
|
3615
3677
|
) : t;
|
|
3616
3678
|
}
|
|
3617
|
-
function
|
|
3618
|
-
return t.role === "tool" ||
|
|
3679
|
+
function Dt(t) {
|
|
3680
|
+
return t.role === "tool" || H(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3619
3681
|
}
|
|
3620
|
-
function
|
|
3682
|
+
function br(t, e) {
|
|
3621
3683
|
return t.some(
|
|
3622
|
-
(s) => s.respondsToUserMessageId === e && (
|
|
3684
|
+
(s) => s.respondsToUserMessageId === e && (W(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3623
3685
|
);
|
|
3624
3686
|
}
|
|
3625
|
-
function
|
|
3687
|
+
function Pr(t, e) {
|
|
3626
3688
|
const s = t[e];
|
|
3627
3689
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
3628
3690
|
const r = t[n];
|
|
3629
|
-
if (r.role === "assistant" &&
|
|
3691
|
+
if (r.role === "assistant" && oe(s, r))
|
|
3630
3692
|
return !0;
|
|
3631
3693
|
}
|
|
3632
3694
|
return !1;
|
|
3633
3695
|
}
|
|
3634
|
-
function
|
|
3696
|
+
function Ur(t, e) {
|
|
3635
3697
|
const s = t[e];
|
|
3636
3698
|
if (!s.respondsToUserMessageId)
|
|
3637
3699
|
return !1;
|
|
@@ -3639,45 +3701,45 @@ function kr(t, e) {
|
|
|
3639
3701
|
const r = t[n];
|
|
3640
3702
|
if (r.role === "user")
|
|
3641
3703
|
return !1;
|
|
3642
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3704
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || H(r)))
|
|
3643
3705
|
return !0;
|
|
3644
3706
|
}
|
|
3645
3707
|
return !1;
|
|
3646
3708
|
}
|
|
3647
|
-
function
|
|
3709
|
+
function Dr(t, e) {
|
|
3648
3710
|
const s = t[e];
|
|
3649
3711
|
return t.some(
|
|
3650
|
-
(n, r) => r !== e && n.role === "assistant" &&
|
|
3712
|
+
(n, r) => r !== e && n.role === "assistant" && oe(s, n)
|
|
3651
3713
|
);
|
|
3652
3714
|
}
|
|
3653
|
-
function
|
|
3715
|
+
function vr(t, e) {
|
|
3654
3716
|
const s = t[e];
|
|
3655
3717
|
return t.some(
|
|
3656
|
-
(n, r) => r !== e && n.role === "tool" &&
|
|
3718
|
+
(n, r) => r !== e && n.role === "tool" && oe(s, n)
|
|
3657
3719
|
);
|
|
3658
3720
|
}
|
|
3659
|
-
function
|
|
3721
|
+
function Or(t, e) {
|
|
3660
3722
|
const s = t[e];
|
|
3661
3723
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3662
|
-
if (
|
|
3724
|
+
if (H(t[n]) && oe(s, t[n]))
|
|
3663
3725
|
return !0;
|
|
3664
3726
|
return !1;
|
|
3665
3727
|
}
|
|
3666
|
-
function
|
|
3728
|
+
function oe(t, e) {
|
|
3667
3729
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
3668
3730
|
}
|
|
3669
3731
|
function w(t, e) {
|
|
3670
3732
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
3671
3733
|
}
|
|
3672
|
-
function
|
|
3734
|
+
function qr(t, e) {
|
|
3673
3735
|
try {
|
|
3674
|
-
const s = window.localStorage.getItem(`${
|
|
3736
|
+
const s = window.localStorage.getItem(`${$t}${t}`);
|
|
3675
3737
|
if (!s)
|
|
3676
3738
|
return null;
|
|
3677
3739
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3678
3740
|
if (e !== void 0 && r !== e)
|
|
3679
3741
|
return null;
|
|
3680
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3742
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Kr).filter((o) => !!o) : [];
|
|
3681
3743
|
return {
|
|
3682
3744
|
sessionId: r,
|
|
3683
3745
|
messages: i
|
|
@@ -3686,22 +3748,22 @@ function Dr(t, e) {
|
|
|
3686
3748
|
return null;
|
|
3687
3749
|
}
|
|
3688
3750
|
}
|
|
3689
|
-
function
|
|
3751
|
+
function Lr(t, e) {
|
|
3690
3752
|
try {
|
|
3691
3753
|
window.localStorage.setItem(
|
|
3692
|
-
`${
|
|
3754
|
+
`${$t}${t}`,
|
|
3693
3755
|
JSON.stringify({
|
|
3694
3756
|
sessionId: e.sessionId,
|
|
3695
|
-
messages: e.messages.slice(-on).map(
|
|
3757
|
+
messages: e.messages.slice(-on).map(Gr)
|
|
3696
3758
|
})
|
|
3697
3759
|
);
|
|
3698
3760
|
} catch {
|
|
3699
3761
|
return;
|
|
3700
3762
|
}
|
|
3701
3763
|
}
|
|
3702
|
-
function
|
|
3764
|
+
function Nr(t) {
|
|
3703
3765
|
try {
|
|
3704
|
-
const e = window.localStorage.getItem(`${
|
|
3766
|
+
const e = window.localStorage.getItem(`${$e}${t}`);
|
|
3705
3767
|
if (!e)
|
|
3706
3768
|
return [];
|
|
3707
3769
|
const s = JSON.parse(e);
|
|
@@ -3710,24 +3772,24 @@ function Or(t) {
|
|
|
3710
3772
|
return [];
|
|
3711
3773
|
}
|
|
3712
3774
|
}
|
|
3713
|
-
function
|
|
3775
|
+
function z(t, e) {
|
|
3714
3776
|
try {
|
|
3715
3777
|
const s = e.filter(tt);
|
|
3716
3778
|
if (s.length === 0) {
|
|
3717
|
-
window.localStorage.removeItem(`${
|
|
3779
|
+
window.localStorage.removeItem(`${$e}${t}`);
|
|
3718
3780
|
return;
|
|
3719
3781
|
}
|
|
3720
3782
|
window.localStorage.setItem(
|
|
3721
|
-
`${
|
|
3783
|
+
`${$e}${t}`,
|
|
3722
3784
|
JSON.stringify(s.slice(-25))
|
|
3723
3785
|
);
|
|
3724
3786
|
} catch {
|
|
3725
3787
|
return;
|
|
3726
3788
|
}
|
|
3727
3789
|
}
|
|
3728
|
-
function
|
|
3790
|
+
function ts(t, e) {
|
|
3729
3791
|
try {
|
|
3730
|
-
const s = `${
|
|
3792
|
+
const s = `${Se}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
3731
3793
|
...o,
|
|
3732
3794
|
storedAt: Date.now(),
|
|
3733
3795
|
unloadUrl: n,
|
|
@@ -3741,28 +3803,28 @@ function Yt(t, e) {
|
|
|
3741
3803
|
} catch {
|
|
3742
3804
|
}
|
|
3743
3805
|
}
|
|
3744
|
-
function
|
|
3806
|
+
function vt(t, e) {
|
|
3745
3807
|
try {
|
|
3746
|
-
if (window.sessionStorage.getItem(`${
|
|
3808
|
+
if (window.sessionStorage.getItem(`${Se}${t}`) === null)
|
|
3747
3809
|
return;
|
|
3748
3810
|
} catch {
|
|
3749
3811
|
return;
|
|
3750
3812
|
}
|
|
3751
|
-
|
|
3813
|
+
ts(t, e);
|
|
3752
3814
|
}
|
|
3753
|
-
function
|
|
3815
|
+
function xr(t) {
|
|
3754
3816
|
try {
|
|
3755
|
-
const e = `${
|
|
3817
|
+
const e = `${Se}${t}`, s = window.sessionStorage.getItem(e);
|
|
3756
3818
|
if (window.sessionStorage.removeItem(e), !s)
|
|
3757
3819
|
return [];
|
|
3758
3820
|
const n = JSON.parse(s);
|
|
3759
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3821
|
+
return Array.isArray(n) ? n.flatMap((r) => Wr(r) ? [{
|
|
3760
3822
|
...r.event,
|
|
3761
|
-
page:
|
|
3823
|
+
page: P(),
|
|
3762
3824
|
rawOutput: {
|
|
3763
3825
|
pageContextRestarted: !0,
|
|
3764
3826
|
outcome: "unknown",
|
|
3765
|
-
message:
|
|
3827
|
+
message: Br(location.href),
|
|
3766
3828
|
currentUrl: location.href,
|
|
3767
3829
|
console: [],
|
|
3768
3830
|
metadata: {
|
|
@@ -3779,17 +3841,17 @@ function Lr(t) {
|
|
|
3779
3841
|
return [];
|
|
3780
3842
|
}
|
|
3781
3843
|
}
|
|
3782
|
-
function
|
|
3844
|
+
function Br(t) {
|
|
3783
3845
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3784
3846
|
Current URL: ${t}`;
|
|
3785
3847
|
}
|
|
3786
|
-
function
|
|
3848
|
+
function Wr(t) {
|
|
3787
3849
|
if (!t || typeof t != "object")
|
|
3788
3850
|
return !1;
|
|
3789
3851
|
const e = t, s = e.event;
|
|
3790
3852
|
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && tt(s) && s.type === "tool.result";
|
|
3791
3853
|
}
|
|
3792
|
-
function
|
|
3854
|
+
function Hr(t, e) {
|
|
3793
3855
|
const s = new Set(
|
|
3794
3856
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3795
3857
|
);
|
|
@@ -3798,9 +3860,9 @@ function xr(t, e) {
|
|
|
3798
3860
|
...e.filter((n) => !s.has(n.callId))
|
|
3799
3861
|
];
|
|
3800
3862
|
}
|
|
3801
|
-
function
|
|
3863
|
+
function $r(t) {
|
|
3802
3864
|
try {
|
|
3803
|
-
window.sessionStorage.removeItem(`${
|
|
3865
|
+
window.sessionStorage.removeItem(`${Se}${t}`);
|
|
3804
3866
|
} catch {
|
|
3805
3867
|
return;
|
|
3806
3868
|
}
|
|
@@ -3809,15 +3871,15 @@ function tt(t) {
|
|
|
3809
3871
|
if (!t || typeof t != "object")
|
|
3810
3872
|
return !1;
|
|
3811
3873
|
const e = t;
|
|
3812
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
3874
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && Ot(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Ot(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;
|
|
3813
3875
|
}
|
|
3814
|
-
function
|
|
3876
|
+
function Ot(t) {
|
|
3815
3877
|
if (!t || typeof t != "object")
|
|
3816
3878
|
return !1;
|
|
3817
3879
|
const e = t;
|
|
3818
3880
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
3819
3881
|
}
|
|
3820
|
-
function
|
|
3882
|
+
function ss(t, e) {
|
|
3821
3883
|
if (!Array.isArray(t))
|
|
3822
3884
|
return;
|
|
3823
3885
|
const s = t.filter((r) => {
|
|
@@ -3825,41 +3887,41 @@ function Qt(t, e) {
|
|
|
3825
3887
|
return !1;
|
|
3826
3888
|
const i = r;
|
|
3827
3889
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3828
|
-
}), n = e ? s.map((r) =>
|
|
3890
|
+
}), n = e ? s.map((r) => ns(r, e)) : s;
|
|
3829
3891
|
return n.length > 0 ? n : void 0;
|
|
3830
3892
|
}
|
|
3831
|
-
function
|
|
3893
|
+
function ns(t, e) {
|
|
3832
3894
|
return t.fileUrl?.startsWith("/") ? {
|
|
3833
3895
|
...t,
|
|
3834
3896
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
3835
3897
|
} : t;
|
|
3836
3898
|
}
|
|
3837
3899
|
function Xe(t) {
|
|
3838
|
-
return t.type ||
|
|
3900
|
+
return t.type || zr(t.name) || "application/octet-stream";
|
|
3839
3901
|
}
|
|
3840
|
-
function
|
|
3841
|
-
|
|
3902
|
+
function jr(t) {
|
|
3903
|
+
rs({
|
|
3842
3904
|
name: t.name,
|
|
3843
3905
|
mimeType: Xe(t),
|
|
3844
3906
|
sizeBytes: t.size
|
|
3845
3907
|
});
|
|
3846
3908
|
}
|
|
3847
|
-
function
|
|
3848
|
-
const e =
|
|
3909
|
+
function rs(t) {
|
|
3910
|
+
const e = Fr(t.name), s = t.mimeType.trim().toLowerCase();
|
|
3849
3911
|
if (!sn.has(`${e}:${s}`))
|
|
3850
3912
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
3851
|
-
if (t.sizeBytes <= 0 || t.sizeBytes >=
|
|
3913
|
+
if (t.sizeBytes <= 0 || t.sizeBytes >= Wt)
|
|
3852
3914
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
3853
3915
|
}
|
|
3854
|
-
function
|
|
3916
|
+
function Fr(t) {
|
|
3855
3917
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
3856
3918
|
return s >= 0 ? e.slice(s) : "";
|
|
3857
3919
|
}
|
|
3858
|
-
function
|
|
3920
|
+
function zr(t) {
|
|
3859
3921
|
const e = t.toLowerCase();
|
|
3860
3922
|
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;
|
|
3861
3923
|
}
|
|
3862
|
-
function
|
|
3924
|
+
function Kr(t) {
|
|
3863
3925
|
if (!t || typeof t != "object")
|
|
3864
3926
|
return null;
|
|
3865
3927
|
const e = t;
|
|
@@ -3876,11 +3938,11 @@ function Fr(t) {
|
|
|
3876
3938
|
dataType: typeof e.dataType == "string" ? e.dataType : void 0,
|
|
3877
3939
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
3878
3940
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
3879
|
-
attachments:
|
|
3941
|
+
attachments: ss(e.attachments)?.map(st),
|
|
3880
3942
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
3881
3943
|
};
|
|
3882
3944
|
}
|
|
3883
|
-
function
|
|
3945
|
+
function Gr(t) {
|
|
3884
3946
|
return t.attachments?.length ? {
|
|
3885
3947
|
...t,
|
|
3886
3948
|
attachments: t.attachments.map(st)
|
|
@@ -3895,19 +3957,19 @@ function st(t) {
|
|
|
3895
3957
|
} = t;
|
|
3896
3958
|
return r;
|
|
3897
3959
|
}
|
|
3898
|
-
function
|
|
3960
|
+
function q(t) {
|
|
3899
3961
|
const e = t.respondsToUserMessageId;
|
|
3900
3962
|
return typeof e == "string" && e ? e : null;
|
|
3901
3963
|
}
|
|
3902
|
-
function
|
|
3964
|
+
function _(t) {
|
|
3903
3965
|
const e = t.runId;
|
|
3904
3966
|
return typeof e == "string" && e ? e : null;
|
|
3905
3967
|
}
|
|
3906
|
-
function
|
|
3968
|
+
function Xr(t) {
|
|
3907
3969
|
const e = t?.timeoutMs;
|
|
3908
3970
|
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 <= fn);
|
|
3909
3971
|
}
|
|
3910
|
-
function
|
|
3972
|
+
function is(t) {
|
|
3911
3973
|
const e = {};
|
|
3912
3974
|
try {
|
|
3913
3975
|
new Headers(t).forEach((s, n) => {
|
|
@@ -3919,23 +3981,23 @@ function ts(t) {
|
|
|
3919
3981
|
return e;
|
|
3920
3982
|
}
|
|
3921
3983
|
function nt(t, e) {
|
|
3922
|
-
return
|
|
3984
|
+
return ds(t) ? Me : L(Te(e), nn);
|
|
3923
3985
|
}
|
|
3924
|
-
function
|
|
3986
|
+
function Vr(t, e) {
|
|
3925
3987
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
3926
3988
|
}
|
|
3927
|
-
async function
|
|
3928
|
-
const r =
|
|
3989
|
+
async function Jr(t, e, s, n) {
|
|
3990
|
+
const r = is(t.headers);
|
|
3929
3991
|
n({
|
|
3930
3992
|
...e,
|
|
3931
3993
|
responseStatus: t.status,
|
|
3932
3994
|
responseHeaders: r,
|
|
3933
|
-
responseBody: await
|
|
3995
|
+
responseBody: await Yr(t),
|
|
3934
3996
|
durationMs: Date.now() - s
|
|
3935
3997
|
});
|
|
3936
3998
|
}
|
|
3937
|
-
async function
|
|
3938
|
-
if (!
|
|
3999
|
+
async function Yr(t) {
|
|
4000
|
+
if (!os(t.headers))
|
|
3939
4001
|
return;
|
|
3940
4002
|
let e = null, s = null;
|
|
3941
4003
|
try {
|
|
@@ -3953,10 +4015,10 @@ async function Xr(t) {
|
|
|
3953
4015
|
return;
|
|
3954
4016
|
const { done: l, value: c } = a;
|
|
3955
4017
|
if (l)
|
|
3956
|
-
return
|
|
4018
|
+
return L(i + r.decode());
|
|
3957
4019
|
const h = Qe - o;
|
|
3958
4020
|
if (c.byteLength > h)
|
|
3959
|
-
return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${
|
|
4021
|
+
return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${L(i)}... [truncated]`;
|
|
3960
4022
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
3961
4023
|
}
|
|
3962
4024
|
} catch {
|
|
@@ -3966,45 +4028,45 @@ async function Xr(t) {
|
|
|
3966
4028
|
s !== null && window.clearTimeout(s);
|
|
3967
4029
|
}
|
|
3968
4030
|
}
|
|
3969
|
-
function
|
|
3970
|
-
if (
|
|
4031
|
+
function Qr(t, e) {
|
|
4032
|
+
if (os(new Headers(e)))
|
|
3971
4033
|
try {
|
|
3972
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
4034
|
+
return t.responseType === "" || t.responseType === "text" ? L(t.responseText ?? "") : void 0;
|
|
3973
4035
|
} catch {
|
|
3974
4036
|
return;
|
|
3975
4037
|
}
|
|
3976
4038
|
}
|
|
3977
|
-
function
|
|
4039
|
+
function qt(t) {
|
|
3978
4040
|
if (typeof t == "string")
|
|
3979
|
-
return
|
|
4041
|
+
return L(t);
|
|
3980
4042
|
}
|
|
3981
|
-
function
|
|
3982
|
-
return
|
|
4043
|
+
function Zr(t) {
|
|
4044
|
+
return O({
|
|
3983
4045
|
...t,
|
|
3984
|
-
requestBody:
|
|
3985
|
-
responseBody:
|
|
4046
|
+
requestBody: Lt(t.requestBody),
|
|
4047
|
+
responseBody: Lt(t.responseBody)
|
|
3986
4048
|
});
|
|
3987
4049
|
}
|
|
3988
|
-
function
|
|
4050
|
+
function Lt(t) {
|
|
3989
4051
|
if (typeof t != "string")
|
|
3990
4052
|
return t;
|
|
3991
4053
|
const e = t.trim();
|
|
3992
4054
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
3993
|
-
return
|
|
4055
|
+
return Te(t);
|
|
3994
4056
|
try {
|
|
3995
|
-
return JSON.stringify(
|
|
4057
|
+
return JSON.stringify(O(JSON.parse(t)));
|
|
3996
4058
|
} catch {
|
|
3997
|
-
return
|
|
4059
|
+
return Te(t);
|
|
3998
4060
|
}
|
|
3999
4061
|
}
|
|
4000
|
-
function
|
|
4062
|
+
function os(t) {
|
|
4001
4063
|
if (!t)
|
|
4002
4064
|
return !1;
|
|
4003
4065
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4004
4066
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= Qe && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4005
4067
|
}
|
|
4006
|
-
function
|
|
4007
|
-
if (
|
|
4068
|
+
function X(t, e = {}, s) {
|
|
4069
|
+
if (ti(s))
|
|
4008
4070
|
return !0;
|
|
4009
4071
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
4010
4072
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -4019,8 +4081,8 @@ function z(t, e = {}, s) {
|
|
|
4019
4081
|
return !0;
|
|
4020
4082
|
}
|
|
4021
4083
|
}
|
|
4022
|
-
function
|
|
4023
|
-
if (
|
|
4084
|
+
function ei(t, e) {
|
|
4085
|
+
if (X(t))
|
|
4024
4086
|
return !0;
|
|
4025
4087
|
try {
|
|
4026
4088
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -4029,10 +4091,10 @@ function Yr(t, e) {
|
|
|
4029
4091
|
return !0;
|
|
4030
4092
|
}
|
|
4031
4093
|
}
|
|
4032
|
-
function
|
|
4094
|
+
function ti(t) {
|
|
4033
4095
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4034
4096
|
}
|
|
4035
|
-
function
|
|
4097
|
+
function si(t) {
|
|
4036
4098
|
const e = {};
|
|
4037
4099
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4038
4100
|
const n = s.indexOf(":");
|
|
@@ -4045,101 +4107,101 @@ function Zr(t) {
|
|
|
4045
4107
|
}
|
|
4046
4108
|
return e;
|
|
4047
4109
|
}
|
|
4048
|
-
function
|
|
4110
|
+
function L(t, e = Qe) {
|
|
4049
4111
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4050
4112
|
}
|
|
4051
|
-
function
|
|
4113
|
+
function Be(t) {
|
|
4052
4114
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4053
4115
|
}
|
|
4054
|
-
class
|
|
4116
|
+
class me extends Error {
|
|
4055
4117
|
constructor(e, s) {
|
|
4056
4118
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4057
4119
|
}
|
|
4058
4120
|
status;
|
|
4059
4121
|
}
|
|
4060
|
-
async function
|
|
4122
|
+
async function pe(t, e) {
|
|
4061
4123
|
let s = null;
|
|
4062
|
-
for (let n = 0; n <
|
|
4124
|
+
for (let n = 0; n < Mt; n += 1)
|
|
4063
4125
|
try {
|
|
4064
4126
|
return await t();
|
|
4065
4127
|
} catch (r) {
|
|
4066
|
-
if (s = r, n >=
|
|
4128
|
+
if (s = r, n >= Mt - 1 || !ri(r))
|
|
4067
4129
|
throw r;
|
|
4068
|
-
await
|
|
4130
|
+
await ni(n);
|
|
4069
4131
|
}
|
|
4070
4132
|
throw s instanceof Error ? s : new Error(e);
|
|
4071
4133
|
}
|
|
4072
|
-
function
|
|
4134
|
+
function ni(t) {
|
|
4073
4135
|
return new Promise((e) => {
|
|
4074
4136
|
window.setTimeout(e, tn[t] ?? 0);
|
|
4075
4137
|
});
|
|
4076
4138
|
}
|
|
4077
|
-
function
|
|
4078
|
-
return t instanceof
|
|
4139
|
+
function ri(t) {
|
|
4140
|
+
return t instanceof me ? ii(t.status) : t instanceof TypeError;
|
|
4079
4141
|
}
|
|
4080
|
-
function
|
|
4142
|
+
function ii(t) {
|
|
4081
4143
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
4082
4144
|
}
|
|
4083
|
-
function
|
|
4145
|
+
function oi(t) {
|
|
4084
4146
|
return t === 401 || t === 403;
|
|
4085
4147
|
}
|
|
4086
|
-
const
|
|
4087
|
-
function
|
|
4088
|
-
return
|
|
4148
|
+
const Me = "[REDACTED_SECRET]", N = "[REDACTED_TOKEN]", ai = "[REDACTED_SIGNED_URL]", li = 20, ci = /^(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, as = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ls = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, cs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, us = /\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, ui = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, di = /\bhttps?:\/\/[^\s"'<>]+/gi, hi = /[),.;\]]+$/;
|
|
4149
|
+
function O(t) {
|
|
4150
|
+
return Ie(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4089
4151
|
}
|
|
4090
|
-
function
|
|
4152
|
+
function Ie(t, e, s) {
|
|
4091
4153
|
if (typeof t == "string")
|
|
4092
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4154
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Te(t);
|
|
4093
4155
|
if (t === null || typeof t != "object")
|
|
4094
4156
|
return t;
|
|
4095
|
-
if (e >=
|
|
4157
|
+
if (e >= li)
|
|
4096
4158
|
return "[REDACTED_MAX_DEPTH]";
|
|
4097
4159
|
if (s.has(t))
|
|
4098
4160
|
return "[REDACTED_CIRCULAR]";
|
|
4099
4161
|
if (s.add(t), Array.isArray(t))
|
|
4100
|
-
return t.map((r) =>
|
|
4162
|
+
return t.map((r) => Ie(r, e + 1, s));
|
|
4101
4163
|
const n = {};
|
|
4102
4164
|
for (const [r, i] of Object.entries(t))
|
|
4103
|
-
r === "pageContent" ? n[r] = i :
|
|
4165
|
+
r === "pageContent" ? n[r] = i : ds(r) ? n[r] = Me : n[r] = r.toLowerCase() === "url" ? pi(i) : Ie(i, e + 1, s);
|
|
4104
4166
|
return n;
|
|
4105
4167
|
}
|
|
4106
|
-
function
|
|
4168
|
+
function ds(t) {
|
|
4107
4169
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
4108
4170
|
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");
|
|
4109
4171
|
}
|
|
4110
|
-
function
|
|
4111
|
-
return typeof t == "string" ?
|
|
4172
|
+
function pi(t) {
|
|
4173
|
+
return typeof t == "string" ? hs(t) : Ie(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4112
4174
|
}
|
|
4113
|
-
function
|
|
4175
|
+
function hs(t) {
|
|
4114
4176
|
try {
|
|
4115
4177
|
const e = new URL(t, location.href);
|
|
4116
4178
|
for (const s of Array.from(e.searchParams.keys()))
|
|
4117
|
-
|
|
4118
|
-
return e.username && (e.username =
|
|
4179
|
+
ci.test(s) && e.searchParams.set(s, N);
|
|
4180
|
+
return e.username && (e.username = N), e.password && (e.password = N), e.toString();
|
|
4119
4181
|
} catch {
|
|
4120
|
-
return
|
|
4182
|
+
return gi(t);
|
|
4121
4183
|
}
|
|
4122
4184
|
}
|
|
4123
|
-
function
|
|
4124
|
-
return t.replace(
|
|
4185
|
+
function Te(t) {
|
|
4186
|
+
return t.replace(ui, ai).replace(di, fi).replace(as, `Bearer ${N}`).replace(ls, `Basic ${N}`).replace(cs, N).replace(us, (e, s) => `${s}: ${Me}`);
|
|
4125
4187
|
}
|
|
4126
|
-
function
|
|
4127
|
-
return t.replace(
|
|
4188
|
+
function gi(t) {
|
|
4189
|
+
return t.replace(as, `Bearer ${N}`).replace(ls, `Basic ${N}`).replace(cs, N).replace(us, (e, s) => `${s}: ${Me}`);
|
|
4128
4190
|
}
|
|
4129
|
-
function
|
|
4130
|
-
const e = t.match(
|
|
4131
|
-
return `${
|
|
4191
|
+
function fi(t) {
|
|
4192
|
+
const e = t.match(hi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4193
|
+
return `${hs(s)}${e}`;
|
|
4132
4194
|
}
|
|
4133
4195
|
export {
|
|
4134
4196
|
ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4197
|
+
He as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4198
|
+
xs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4199
|
+
Ns as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4200
|
+
Bs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
4201
|
+
mi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
4202
|
+
jt as PlunoProductAgent,
|
|
4141
4203
|
ln as calculateReconnectDelay,
|
|
4142
|
-
|
|
4204
|
+
jt as default,
|
|
4143
4205
|
Un as getProductAgentOriginAccessErrorMessage,
|
|
4144
|
-
|
|
4206
|
+
jr as validateProductAgentProviderInputFile
|
|
4145
4207
|
};
|