@pluno/product-agent-web 0.1.185 → 0.1.187
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 +7 -0
- package/dist/modelSelection.d.ts +10 -0
- package/dist/product-agent-sdk.js +806 -765
- package/dist/product-agent-widget.js +2264 -2187
- package/dist/scheduledCheckIn.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const Ts = "pluno-product-agent-attachments";
|
|
2
|
-
const
|
|
2
|
+
const Ge = "files";
|
|
3
3
|
async function Ss(t) {
|
|
4
|
-
const e = await
|
|
4
|
+
const e = await tt();
|
|
5
5
|
await As(e, "readwrite", (s) => s.put(t));
|
|
6
6
|
}
|
|
7
7
|
async function ws(t, e) {
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
8
|
+
const s = await tt();
|
|
9
|
+
await st(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await nt(
|
|
11
11
|
n.get(t)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -17,27 +17,27 @@ async function ws(t, e) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
async function Ms(t = 864e5) {
|
|
20
|
-
const e = await
|
|
21
|
-
await
|
|
20
|
+
const e = await tt(), s = Date.now() - t;
|
|
21
|
+
await st(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await nt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function tt() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
|
|
28
28
|
const s = indexedDB.open(Ts, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(Ge, { 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
35
|
async function As(t, e, s) {
|
|
36
|
-
return await
|
|
36
|
+
return await st(t, e, async (n) => await nt(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function st(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(Ge, e), o = i.objectStore(Ge);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
s(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -57,7 +57,7 @@ function tt(t, e, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function nt(t) {
|
|
61
61
|
return new Promise((e, s) => {
|
|
62
62
|
t.onsuccess = () => e(t.result), t.onerror = () => s(t.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
@@ -112,33 +112,33 @@ function vs(t, e, s) {
|
|
|
112
112
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
113
113
|
)
|
|
114
114
|
), i = n.filter(
|
|
115
|
-
({ identity: u }) => !(u.isTransient && u.activityKeys?.some((
|
|
116
|
-
), o = new Map(i.map(({ item: u, identity:
|
|
115
|
+
({ identity: u }) => !(u.isTransient && u.activityKeys?.some((h) => r.has(h)))
|
|
116
|
+
), o = new Map(i.map(({ item: u, identity: h }) => [h.id, u])), a = new Map(
|
|
117
117
|
i.flatMap(
|
|
118
|
-
({ item: u, identity:
|
|
118
|
+
({ item: u, identity: h }) => h.optimisticKey ? [[h.optimisticKey, u]] : []
|
|
119
119
|
)
|
|
120
120
|
), l = new Map(
|
|
121
121
|
i.flatMap(
|
|
122
|
-
({ item: u, identity:
|
|
122
|
+
({ item: u, identity: h }) => h.assistantDraftKey ? [[h.assistantDraftKey, u]] : []
|
|
123
123
|
)
|
|
124
124
|
), c = /* @__PURE__ */ new Map();
|
|
125
|
-
for (const { item: u, identity:
|
|
126
|
-
for (const g of
|
|
125
|
+
for (const { item: u, identity: h } of i)
|
|
126
|
+
for (const g of h.activityKeys ?? []) {
|
|
127
127
|
const m = c.get(g);
|
|
128
128
|
(!m || s(m).isTransient) && c.set(g, u);
|
|
129
129
|
}
|
|
130
|
-
const d = new Set(i.map(({ identity: u }) => u.id)),
|
|
130
|
+
const d = new Set(i.map(({ identity: u }) => u.id)), p = new Set(
|
|
131
131
|
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
132
132
|
), y = /* @__PURE__ */ new Set(), f = [];
|
|
133
133
|
for (const u of t) {
|
|
134
|
-
const
|
|
135
|
-
let g = o.get(
|
|
136
|
-
if (
|
|
134
|
+
const h = s(u);
|
|
135
|
+
let g = o.get(h.id);
|
|
136
|
+
if (h.isOptimistic && h.optimisticKey ? g = a.get(h.optimisticKey) : h.isAssistantDraft && h.assistantDraftKey ? g = l.get(h.assistantDraftKey) : h.isActivity && (g = h.activityKeys?.map((C) => c.get(C)).find((C) => C !== void 0) ?? g), g && !y.has(g)) {
|
|
137
137
|
f.push(g), y.add(g);
|
|
138
138
|
continue;
|
|
139
139
|
}
|
|
140
|
-
const m =
|
|
141
|
-
(
|
|
140
|
+
const m = h.respondsToUserMessageId !== void 0 && d.has(h.respondsToUserMessageId) || h.runId !== void 0 && p.has(h.runId);
|
|
141
|
+
(h.isOptimistic || (h.isAssistantDraft || h.isActivity) && m) && f.push(u);
|
|
142
142
|
}
|
|
143
143
|
for (const { item: u } of i)
|
|
144
144
|
y.has(u) || f.push(u);
|
|
@@ -150,11 +150,11 @@ function Ds(t, e, s, n) {
|
|
|
150
150
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
const
|
|
154
|
-
let
|
|
155
|
-
const
|
|
153
|
+
const Ne = "pluno.productAgent.transportId", Os = "pluno.productAgent.transportIdentity", xe = "pluno.productAgent.transportIdentity.event", qs = 50, Ls = globalThis.setTimeout.bind(globalThis);
|
|
154
|
+
let re = null;
|
|
155
|
+
const Te = /* @__PURE__ */ new Set(), Be = /* @__PURE__ */ new Map();
|
|
156
156
|
async function Ns(t = Ht()) {
|
|
157
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
157
|
+
const e = t.randomUUID(), s = t.storage.getItem(Ne);
|
|
158
158
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
159
159
|
const o = t.channel.subscribe((l) => {
|
|
160
160
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -172,7 +172,7 @@ async function Ns(t = Ht()) {
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
if (!s)
|
|
175
|
-
t.storage.setItem(
|
|
175
|
+
t.storage.setItem(Ne, n), r = !0;
|
|
176
176
|
else if (t.skipStoredIdentityCollisionCheck)
|
|
177
177
|
r = !0;
|
|
178
178
|
else
|
|
@@ -181,7 +181,7 @@ async function Ns(t = Ht()) {
|
|
|
181
181
|
r = !0;
|
|
182
182
|
break;
|
|
183
183
|
}
|
|
184
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
184
|
+
n = t.randomUUID(), t.storage.setItem(Ne, n);
|
|
185
185
|
}
|
|
186
186
|
let a = !1;
|
|
187
187
|
return {
|
|
@@ -192,29 +192,29 @@ async function Ns(t = Ht()) {
|
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
194
|
async function xs(t = !1) {
|
|
195
|
-
|
|
195
|
+
re || (re = Ns({
|
|
196
196
|
...Ht(),
|
|
197
197
|
skipStoredIdentityCollisionCheck: t
|
|
198
|
-
}),
|
|
198
|
+
}), re.then((r) => {
|
|
199
199
|
const i = (o) => {
|
|
200
|
-
o.persisted || (r.release(),
|
|
200
|
+
o.persisted || (r.release(), re = null, Te.clear(), window.removeEventListener("pagehide", i));
|
|
201
201
|
};
|
|
202
202
|
window.addEventListener("pagehide", i);
|
|
203
203
|
}));
|
|
204
|
-
const e = await
|
|
205
|
-
|
|
204
|
+
const e = await re, s = Bs();
|
|
205
|
+
Te.add(s);
|
|
206
206
|
let n = !1;
|
|
207
207
|
return {
|
|
208
208
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
209
209
|
transportId: s === 0 ? e.transportId : `${e.transportId}.${s}`,
|
|
210
210
|
release: () => {
|
|
211
|
-
n || (n = !0,
|
|
211
|
+
n || (n = !0, Te.delete(s));
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
function Bs() {
|
|
216
216
|
let t = 0;
|
|
217
|
-
for (;
|
|
217
|
+
for (; Te.has(t); )
|
|
218
218
|
t += 1;
|
|
219
219
|
return t;
|
|
220
220
|
}
|
|
@@ -223,20 +223,20 @@ function Ht() {
|
|
|
223
223
|
storage: Ws(),
|
|
224
224
|
channel: Hs(),
|
|
225
225
|
randomUUID: () => crypto.randomUUID(),
|
|
226
|
-
settle: () => new Promise((t) => Ls(t,
|
|
226
|
+
settle: () => new Promise((t) => Ls(t, qs))
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
function Ws() {
|
|
230
230
|
return {
|
|
231
231
|
getItem: (t) => {
|
|
232
232
|
try {
|
|
233
|
-
return window.sessionStorage?.getItem(t) ??
|
|
233
|
+
return window.sessionStorage?.getItem(t) ?? Be.get(t) ?? null;
|
|
234
234
|
} catch {
|
|
235
|
-
return
|
|
235
|
+
return Be.get(t) ?? null;
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
setItem: (t, e) => {
|
|
239
|
-
|
|
239
|
+
Be.set(t, e);
|
|
240
240
|
try {
|
|
241
241
|
window.sessionStorage?.setItem(t, e);
|
|
242
242
|
} catch {
|
|
@@ -246,7 +246,7 @@ function Ws() {
|
|
|
246
246
|
}
|
|
247
247
|
function Hs() {
|
|
248
248
|
if (typeof BroadcastChannel < "u") {
|
|
249
|
-
const t = new BroadcastChannel(
|
|
249
|
+
const t = new BroadcastChannel(Os);
|
|
250
250
|
return {
|
|
251
251
|
postMessage: (e) => t.postMessage(e),
|
|
252
252
|
subscribe: (e) => {
|
|
@@ -260,7 +260,7 @@ function Hs() {
|
|
|
260
260
|
}
|
|
261
261
|
function $s() {
|
|
262
262
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
263
|
-
if (s.key !==
|
|
263
|
+
if (s.key !== xe || !s.newValue)
|
|
264
264
|
return;
|
|
265
265
|
const n = JSON.parse(s.newValue);
|
|
266
266
|
for (const r of t)
|
|
@@ -269,9 +269,9 @@ function $s() {
|
|
|
269
269
|
return window.addEventListener("storage", e), {
|
|
270
270
|
postMessage: (s) => {
|
|
271
271
|
window.localStorage.setItem(
|
|
272
|
-
|
|
272
|
+
xe,
|
|
273
273
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
274
|
-
), window.localStorage.removeItem(
|
|
274
|
+
), window.localStorage.removeItem(xe);
|
|
275
275
|
},
|
|
276
276
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
277
277
|
close: () => {
|
|
@@ -291,21 +291,24 @@ function js(t) {
|
|
|
291
291
|
if (!e || typeof e != "object")
|
|
292
292
|
return null;
|
|
293
293
|
const s = e;
|
|
294
|
-
return s.ok !== !0 || s.toolName !== $t || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null :
|
|
294
|
+
return s.ok !== !0 || s.toolName !== $t || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : {
|
|
295
|
+
id: typeof s.taskId == "string" && s.taskId ? s.taskId : null,
|
|
296
|
+
dueAt: s.dueAt
|
|
297
|
+
};
|
|
295
298
|
}
|
|
296
299
|
const Fs = [
|
|
297
|
-
{ value: "gpt-5.6-sol", label: "gpt-5.6-sol" },
|
|
298
|
-
{ value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5" },
|
|
299
|
-
{ value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash" }
|
|
300
|
+
{ value: "gpt-5.6-sol", label: "gpt-5.6-sol", price: "$$" },
|
|
301
|
+
{ value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5", price: "$$" },
|
|
302
|
+
{ value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash", price: "$" }
|
|
300
303
|
], zs = [
|
|
301
|
-
{ value: "anthropic/claude-opus-5", label: "Claude Opus 5" },
|
|
302
|
-
{ value: "gpt-5.6-terra", label: "gpt-5.6-terra" }
|
|
304
|
+
{ value: "anthropic/claude-opus-5", label: "Claude Opus 5", price: "$$$" },
|
|
305
|
+
{ value: "gpt-5.6-terra", label: "gpt-5.6-terra", price: "$$" }
|
|
303
306
|
], Ks = [
|
|
304
307
|
...Fs,
|
|
305
308
|
...zs
|
|
306
|
-
],
|
|
309
|
+
], We = (t) => Ks.some((e) => e.value === t), Gs = globalThis.fetch.bind(globalThis), Ve = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Vs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Xs = ".pluno-pa-widget__panel", Js = ".pluno-pa-widget__timeline", ft = `${Ve}[data-pluno-sdk-preview-channel]`;
|
|
307
310
|
let Ys = 0;
|
|
308
|
-
function
|
|
311
|
+
function mt(t) {
|
|
309
312
|
const e = {};
|
|
310
313
|
for (const o of [
|
|
311
314
|
"type",
|
|
@@ -343,7 +346,7 @@ function ft(t) {
|
|
|
343
346
|
}
|
|
344
347
|
return e;
|
|
345
348
|
}
|
|
346
|
-
function
|
|
349
|
+
function He(t, e, s) {
|
|
347
350
|
if (typeof window > "u")
|
|
348
351
|
return;
|
|
349
352
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -362,27 +365,27 @@ function We(t, e, s) {
|
|
|
362
365
|
};
|
|
363
366
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
364
367
|
}
|
|
365
|
-
class
|
|
368
|
+
class pe extends Error {
|
|
366
369
|
}
|
|
367
370
|
function Qs(t) {
|
|
368
371
|
return t === 408 || t === 425 || t === 429 || t >= 500;
|
|
369
372
|
}
|
|
370
|
-
const Zs = "https://app.pluno.ai", en = 2e4, tn = 1e4, sn = 1e4, nn = 1e4, rn = 1e4, on = 3e3, an = 3e4, ln = 1e3,
|
|
373
|
+
const Zs = "https://app.pluno.ai", en = 2e4, tn = 1e4, sn = 1e4, nn = 1e4, rn = 1e4, on = 3e3, an = 3e4, ln = 1e3, yt = 3e4, It = 0.2, Tt = 6e4, St = 15e3, ie = 8, wt = "Browser connection was interrupted.", Mt = 15e3, cn = "Pluno could not send this message. Try it again.", At = 2e3, un = 1e3, dn = 100, Rt = 8e3, Et = 3, hn = [300, 1e3], jt = 50 * 1024 * 1024, pn = /* @__PURE__ */ new Set([
|
|
371
374
|
".jpeg:image/jpeg",
|
|
372
375
|
".jpg:image/jpeg",
|
|
373
376
|
".pdf:application/pdf",
|
|
374
377
|
".png:image/png",
|
|
375
378
|
".webp:image/webp"
|
|
376
|
-
]), ki = ".pdf,.png,.jpg,.jpeg,.webp",
|
|
377
|
-
function
|
|
379
|
+
]), ki = ".pdf,.png,.jpg,.jpeg,.webp", rt = 64e3, $e = 4e3, it = 30, gn = 2e3, fn = 1e3, Ft = "Image is too large for model vision input.", mn = 100, zt = "pluno.productAgent.state.", Xe = "pluno.productAgent.pendingEvents.", be = "pluno.productAgent.activeToolCalls.", yn = 100;
|
|
380
|
+
function oe(t, e = 0) {
|
|
378
381
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
379
382
|
return Math.max(e, s);
|
|
380
383
|
}
|
|
381
|
-
const
|
|
384
|
+
const Se = /* @__PURE__ */ new Set();
|
|
382
385
|
let ge = null;
|
|
383
386
|
function In(t, e = Math.random) {
|
|
384
|
-
const s = Math.min(
|
|
385
|
-
return Math.min(
|
|
387
|
+
const s = Math.min(yt, ln * 2 ** t), n = 1 - It + e() * It * 2;
|
|
388
|
+
return Math.min(yt, Math.round(s * n));
|
|
386
389
|
}
|
|
387
390
|
function Tn(t, e, s) {
|
|
388
391
|
return new Promise((n, r) => {
|
|
@@ -399,7 +402,7 @@ function Tn(t, e, s) {
|
|
|
399
402
|
}
|
|
400
403
|
class Kt {
|
|
401
404
|
constructor(e, s) {
|
|
402
|
-
this.options = e, this.transportIdentity = s, this.personalModelSelectionOverride = e.productVariant === "personal" &&
|
|
405
|
+
this.options = e, this.transportIdentity = s, this.personalModelSelectionOverride = e.productVariant === "personal" && We(e.model) ? e.model : null, this.state = {
|
|
403
406
|
...this.state,
|
|
404
407
|
starterPrompts: Qn(e.initialStarterPrompts)
|
|
405
408
|
};
|
|
@@ -431,7 +434,7 @@ class Kt {
|
|
|
431
434
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
432
435
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
433
436
|
);
|
|
434
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"),
|
|
437
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), G(e.clientId, this.queuedClientEvents);
|
|
435
438
|
}
|
|
436
439
|
options;
|
|
437
440
|
listeners = {};
|
|
@@ -474,6 +477,9 @@ class Kt {
|
|
|
474
477
|
backgroundSessionIds = /* @__PURE__ */ new Set();
|
|
475
478
|
backgroundClientMessageIds = /* @__PURE__ */ new Set();
|
|
476
479
|
deferredSessionUpdatedSessionIds = /* @__PURE__ */ new Set();
|
|
480
|
+
detachedSessionIds = /* @__PURE__ */ new Set();
|
|
481
|
+
detachedClientMessageIds = /* @__PURE__ */ new Set();
|
|
482
|
+
deferredDetachedSessionEvents = /* @__PURE__ */ new Map();
|
|
477
483
|
// The backend closes a retryable failed run with assistant_done; that paired event is recovery control flow,
|
|
478
484
|
// not successful completion of the user turn.
|
|
479
485
|
retryableFailureRunIdsAwaitingDone = /* @__PURE__ */ new Set();
|
|
@@ -601,7 +607,7 @@ class Kt {
|
|
|
601
607
|
const i = Yn(r?.detail?.data);
|
|
602
608
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
603
609
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
604
|
-
) && (this.queuedClientEvents.push(i),
|
|
610
|
+
) && (this.queuedClientEvents.push(i), G(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();
|
|
605
611
|
}), n.addEventListener("close", (r) => {
|
|
606
612
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (w("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
607
613
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -634,7 +640,7 @@ class Kt {
|
|
|
634
640
|
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.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
635
641
|
}
|
|
636
642
|
destroy() {
|
|
637
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Qr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
643
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Qr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
|
|
638
644
|
for (const e of Object.values(this.listeners))
|
|
639
645
|
e?.clear();
|
|
640
646
|
}
|
|
@@ -678,7 +684,7 @@ class Kt {
|
|
|
678
684
|
0
|
|
679
685
|
) > jt))
|
|
680
686
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
681
|
-
let i = r.map(
|
|
687
|
+
let i = r.map(Ee);
|
|
682
688
|
if (!n && i.length === 0)
|
|
683
689
|
return null;
|
|
684
690
|
if (this.pendingClientMessageId)
|
|
@@ -689,7 +695,7 @@ class Kt {
|
|
|
689
695
|
content: n,
|
|
690
696
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
691
697
|
...r.length > 0 ? { attachments: r } : {}
|
|
692
|
-
}, c = this.state.messages.some((T) => T.id === l.id || T.clientMessageId === a), d = this.state.isThinking,
|
|
698
|
+
}, c = this.state.messages.some((T) => T.id === l.id || T.clientMessageId === a), d = this.state.isThinking, p = this.state.taskStatus, y = this.state.pendingMessageStatus, f = this.state.turnPhase, u = this.state.messages, h = c ? this.state.messages : [...this.state.messages, l], g = {
|
|
693
699
|
assistantDraft: this.state.assistantDraft,
|
|
694
700
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
695
701
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -698,7 +704,7 @@ class Kt {
|
|
|
698
704
|
lastError: this.state.lastError
|
|
699
705
|
};
|
|
700
706
|
this.setState({
|
|
701
|
-
messages:
|
|
707
|
+
messages: h,
|
|
702
708
|
...d ? {} : {
|
|
703
709
|
assistantDraft: "",
|
|
704
710
|
assistantDraftItemId: null,
|
|
@@ -732,7 +738,7 @@ class Kt {
|
|
|
732
738
|
...d ? {} : { ...g, isThinking: !1 },
|
|
733
739
|
pendingMessageStatus: y,
|
|
734
740
|
turnPhase: f,
|
|
735
|
-
taskStatus:
|
|
741
|
+
taskStatus: p
|
|
736
742
|
}), T;
|
|
737
743
|
}
|
|
738
744
|
this.retryableClientMessageId = null;
|
|
@@ -744,11 +750,11 @@ class Kt {
|
|
|
744
750
|
invocation: Bn(s.invocation ?? s.initiatedBy),
|
|
745
751
|
entrySurface: this.options.entrySurface,
|
|
746
752
|
content: n,
|
|
747
|
-
pageContent: m &&
|
|
748
|
-
attachments: i.length > 0 ? i.map(
|
|
753
|
+
pageContent: m && ot() || void 0,
|
|
754
|
+
attachments: i.length > 0 ? i.map(Ee) : void 0,
|
|
749
755
|
page: o,
|
|
750
756
|
model: this.options.model,
|
|
751
|
-
metadata:
|
|
757
|
+
metadata: kt(this.options.metadata)
|
|
752
758
|
};
|
|
753
759
|
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = C, this.send(C), this.schedulePendingDeliveryAck(a), a;
|
|
754
760
|
}
|
|
@@ -756,7 +762,7 @@ class Kt {
|
|
|
756
762
|
return this.options.model;
|
|
757
763
|
}
|
|
758
764
|
setModel(e) {
|
|
759
|
-
this.options.model = e, this.options.productVariant === "personal" &&
|
|
765
|
+
this.options.model = e, this.options.productVariant === "personal" && We(e) && (this.personalModelSelectionOverride = e);
|
|
760
766
|
}
|
|
761
767
|
retryLastMessage() {
|
|
762
768
|
const e = this.state.sessionId, s = this.retryableClientMessageId;
|
|
@@ -778,7 +784,7 @@ class Kt {
|
|
|
778
784
|
const s = B(), n = {
|
|
779
785
|
id: s,
|
|
780
786
|
name: e.name || "attachment",
|
|
781
|
-
mimeType:
|
|
787
|
+
mimeType: et(e),
|
|
782
788
|
sizeBytes: e.size
|
|
783
789
|
};
|
|
784
790
|
this.attachmentFiles.set(s, e);
|
|
@@ -812,7 +818,7 @@ class Kt {
|
|
|
812
818
|
file: e,
|
|
813
819
|
attachment: s
|
|
814
820
|
}) {
|
|
815
|
-
const n = this.state.sessionId, r =
|
|
821
|
+
const n = this.state.sessionId, r = et(e), i = {
|
|
816
822
|
sessionId: n ?? void 0,
|
|
817
823
|
attachmentId: s.id,
|
|
818
824
|
clientId: this.options.clientId,
|
|
@@ -822,28 +828,28 @@ class Kt {
|
|
|
822
828
|
sizeBytes: e.size,
|
|
823
829
|
page: b(),
|
|
824
830
|
model: this.options.model,
|
|
825
|
-
metadata:
|
|
831
|
+
metadata: kt(this.options.metadata),
|
|
826
832
|
entrySurface: this.options.entrySurface
|
|
827
833
|
};
|
|
828
834
|
let o;
|
|
829
835
|
if (this.options.persistAttachmentUpload)
|
|
830
|
-
o = await
|
|
836
|
+
o = await Ie(
|
|
831
837
|
() => this.options.persistAttachmentUpload(i, e),
|
|
832
838
|
"Failed to upload attachment"
|
|
833
839
|
);
|
|
834
840
|
else {
|
|
835
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
841
|
+
const l = this.options.prepareAttachmentUpload ? await Ie(
|
|
836
842
|
() => this.options.prepareAttachmentUpload(i),
|
|
837
843
|
"Failed to prepare attachment upload"
|
|
838
844
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
839
|
-
await
|
|
845
|
+
await Ie(async () => {
|
|
840
846
|
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
841
847
|
method: l.uploadMethod,
|
|
842
848
|
headers: l.uploadHeaders,
|
|
843
849
|
body: e
|
|
844
850
|
});
|
|
845
851
|
if (!c.ok)
|
|
846
|
-
throw new
|
|
852
|
+
throw new Me("Failed to upload attachment", c.status);
|
|
847
853
|
return c;
|
|
848
854
|
}, "Failed to upload attachment"), o = l;
|
|
849
855
|
}
|
|
@@ -876,7 +882,7 @@ class Kt {
|
|
|
876
882
|
}
|
|
877
883
|
async prepareEmbedAttachmentUpload(e) {
|
|
878
884
|
let s = !1;
|
|
879
|
-
return await
|
|
885
|
+
return await Ie(async () => {
|
|
880
886
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
881
887
|
if (n.ok)
|
|
882
888
|
return await n.json();
|
|
@@ -885,9 +891,9 @@ class Kt {
|
|
|
885
891
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
886
892
|
if (r.ok)
|
|
887
893
|
return await r.json();
|
|
888
|
-
throw new
|
|
894
|
+
throw new Me("Failed to prepare attachment upload", r.status);
|
|
889
895
|
}
|
|
890
|
-
throw new
|
|
896
|
+
throw new Me("Failed to prepare attachment upload", n.status);
|
|
891
897
|
}, "Failed to prepare attachment upload");
|
|
892
898
|
}
|
|
893
899
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -905,7 +911,7 @@ class Kt {
|
|
|
905
911
|
if (!this.state.sessionId)
|
|
906
912
|
return;
|
|
907
913
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
908
|
-
const e =
|
|
914
|
+
const e = qr(
|
|
909
915
|
this.state.messages,
|
|
910
916
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
911
917
|
this.state.assistantDraftRunId,
|
|
@@ -918,7 +924,7 @@ class Kt {
|
|
|
918
924
|
stoppedCausalSequence: null,
|
|
919
925
|
toolCallIds: new Set(
|
|
920
926
|
this.state.messages.filter(
|
|
921
|
-
(s) =>
|
|
927
|
+
(s) => ze(
|
|
922
928
|
s,
|
|
923
929
|
e.respondsToUserMessageId,
|
|
924
930
|
e.runId
|
|
@@ -929,7 +935,7 @@ class Kt {
|
|
|
929
935
|
for (const [s, n] of this.activeBrowserToolCalls)
|
|
930
936
|
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
|
|
931
937
|
Lt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
932
|
-
messages:
|
|
938
|
+
messages: Ot(
|
|
933
939
|
this.state.messages,
|
|
934
940
|
e.clientMessageId,
|
|
935
941
|
e.runId
|
|
@@ -945,7 +951,7 @@ class Kt {
|
|
|
945
951
|
}
|
|
946
952
|
startNewSession(e = {}) {
|
|
947
953
|
const s = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
|
|
948
|
-
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.personalModelSelectionOverride = null, this.options.model = void 0), s && this.send({
|
|
954
|
+
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.personalModelSelectionOverride = null, this.options.model = void 0), s && this.send({
|
|
949
955
|
type: "session.reset",
|
|
950
956
|
sessionId: this.state.sessionId ?? void 0,
|
|
951
957
|
warmupId: n ?? void 0,
|
|
@@ -971,7 +977,7 @@ class Kt {
|
|
|
971
977
|
const s = B(), n = new Promise((i, o) => {
|
|
972
978
|
const a = window.setTimeout(() => {
|
|
973
979
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
974
|
-
},
|
|
980
|
+
}, Rt);
|
|
975
981
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
976
982
|
}), r = {
|
|
977
983
|
type: "sessions.list",
|
|
@@ -1003,7 +1009,7 @@ class Kt {
|
|
|
1003
1009
|
}
|
|
1004
1010
|
loadSession(e) {
|
|
1005
1011
|
const s = B(), n = this.activeComposerWarmupId;
|
|
1006
|
-
!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({
|
|
1012
|
+
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId !== e && this.rememberCurrentRunAsDetached(), this.detachedSessionIds.delete(e), this.deferredDetachedSessionEvents.delete(e), !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({
|
|
1007
1013
|
type: "session.reset",
|
|
1008
1014
|
warmupId: n,
|
|
1009
1015
|
page: b()
|
|
@@ -1099,7 +1105,7 @@ class Kt {
|
|
|
1099
1105
|
try {
|
|
1100
1106
|
const o = this.options.token ?? await this.options.tokenProvider?.() ?? this.token;
|
|
1101
1107
|
if (!o)
|
|
1102
|
-
throw new
|
|
1108
|
+
throw new pe("Product Agent history requires authentication");
|
|
1103
1109
|
this.token = o;
|
|
1104
1110
|
const a = new URLSearchParams();
|
|
1105
1111
|
s === "activity" && a.set("limit", "200"), n && a.set("cursor", n);
|
|
@@ -1113,18 +1119,18 @@ class Kt {
|
|
|
1113
1119
|
});
|
|
1114
1120
|
if (!d.ok) {
|
|
1115
1121
|
const y = await d.text() || `History request failed (${d.status})`;
|
|
1116
|
-
throw Qs(d.status) ? new Error(y) : new
|
|
1122
|
+
throw Qs(d.status) ? new Error(y) : new pe(y);
|
|
1117
1123
|
}
|
|
1118
|
-
const
|
|
1119
|
-
if (!
|
|
1120
|
-
throw new
|
|
1124
|
+
const p = await d.json();
|
|
1125
|
+
if (!p?.session || !Array.isArray(p.items))
|
|
1126
|
+
throw new pe("Invalid Product Agent session history response");
|
|
1121
1127
|
return {
|
|
1122
|
-
session:
|
|
1123
|
-
items:
|
|
1124
|
-
nextCursor: typeof
|
|
1128
|
+
session: p.session,
|
|
1129
|
+
items: p.items,
|
|
1130
|
+
nextCursor: typeof p.nextCursor == "string" ? p.nextCursor : null
|
|
1125
1131
|
};
|
|
1126
1132
|
} catch (o) {
|
|
1127
|
-
if (o instanceof
|
|
1133
|
+
if (o instanceof pe)
|
|
1128
1134
|
throw o;
|
|
1129
1135
|
w("web-sdk.history", "HTTP session history page failed; retrying", {
|
|
1130
1136
|
sessionId: e,
|
|
@@ -1158,9 +1164,9 @@ class Kt {
|
|
|
1158
1164
|
});
|
|
1159
1165
|
}
|
|
1160
1166
|
send(e) {
|
|
1161
|
-
this.sendNow(
|
|
1167
|
+
this.sendNow(q(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
1162
1168
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
1163
|
-
) || this.queuedClientEvents.push(e),
|
|
1169
|
+
) || this.queuedClientEvents.push(e), G(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
1164
1170
|
status: "reconnecting",
|
|
1165
1171
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
1166
1172
|
}), this.scheduleReconnect());
|
|
@@ -1176,7 +1182,7 @@ class Kt {
|
|
|
1176
1182
|
return !1;
|
|
1177
1183
|
const s = this.socket;
|
|
1178
1184
|
try {
|
|
1179
|
-
return s.send(JSON.stringify(e)),
|
|
1185
|
+
return s.send(JSON.stringify(e)), He("client_event", e.type, mt(e)), !0;
|
|
1180
1186
|
} catch (n) {
|
|
1181
1187
|
return w("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1182
1188
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -1222,7 +1228,7 @@ class Kt {
|
|
|
1222
1228
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
1223
1229
|
const e = $n();
|
|
1224
1230
|
this.sendNow(
|
|
1225
|
-
|
|
1231
|
+
q({
|
|
1226
1232
|
type: "starter_prompts.page_context",
|
|
1227
1233
|
pageUrl: e.pageUrl,
|
|
1228
1234
|
pageTitle: e.pageTitle,
|
|
@@ -1252,18 +1258,18 @@ class Kt {
|
|
|
1252
1258
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
1253
1259
|
return;
|
|
1254
1260
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
1255
|
-
|
|
1261
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1256
1262
|
for (let s = 0; s < e.length; s += 1) {
|
|
1257
1263
|
const n = e[s];
|
|
1258
|
-
if (!this.sendNow(
|
|
1259
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1264
|
+
if (!this.sendNow(q(n))) {
|
|
1265
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), G(this.options.clientId, this.queuedClientEvents);
|
|
1260
1266
|
return;
|
|
1261
1267
|
}
|
|
1262
|
-
|
|
1268
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1263
1269
|
}
|
|
1264
1270
|
}
|
|
1265
1271
|
resetForAuthenticationScopeChange() {
|
|
1266
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
1272
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], G(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
|
|
1267
1273
|
}
|
|
1268
1274
|
flushPendingWidgetLifecycleEvents() {
|
|
1269
1275
|
if (this.authenticatedSocket !== this.socket || this.socket?.readyState !== WebSocket.OPEN || this.pendingWidgetLifecycleEvents.length === 0)
|
|
@@ -1300,12 +1306,12 @@ class Kt {
|
|
|
1300
1306
|
findStoppedTurnForEvent(e) {
|
|
1301
1307
|
const s = e.type === "session.item" ? U(e.item) : null;
|
|
1302
1308
|
return this.findStoppedTurn(
|
|
1303
|
-
|
|
1309
|
+
K(e) ?? this.state.sessionId,
|
|
1304
1310
|
s ?? e
|
|
1305
1311
|
);
|
|
1306
1312
|
}
|
|
1307
1313
|
rememberDurablyStoppedTurn(e, s, n) {
|
|
1308
|
-
if (!e || !s || !
|
|
1314
|
+
if (!e || !s || !we(s) || this.findStoppedTurn(e, s))
|
|
1309
1315
|
return;
|
|
1310
1316
|
const r = L(s), i = k(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1311
1317
|
this.stoppedTurns.push({
|
|
@@ -1317,7 +1323,7 @@ class Kt {
|
|
|
1317
1323
|
stoppedCausalSequence: D(s),
|
|
1318
1324
|
toolCallIds: new Set(
|
|
1319
1325
|
this.state.messages.filter(
|
|
1320
|
-
(a) =>
|
|
1326
|
+
(a) => ze(a, r, i)
|
|
1321
1327
|
).map((a) => a.callId).filter((a) => typeof a == "string")
|
|
1322
1328
|
)
|
|
1323
1329
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
@@ -1327,12 +1333,12 @@ class Kt {
|
|
|
1327
1333
|
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1328
1334
|
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1329
1335
|
}
|
|
1330
|
-
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !
|
|
1336
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !we(U(e.item)) : e.type !== "conversation.state" : !1;
|
|
1331
1337
|
}
|
|
1332
1338
|
filterStoppedSnapshotItems(e, s) {
|
|
1333
1339
|
return e.filter((n) => {
|
|
1334
1340
|
const r = U(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1335
|
-
if (!i || r?.type === "message" && r.role === "user" ||
|
|
1341
|
+
if (!i || r?.type === "message" && r.role === "user" || we(r))
|
|
1336
1342
|
return !0;
|
|
1337
1343
|
if (i.stoppedCausalSequence !== null) {
|
|
1338
1344
|
const o = r ? D(r) : null;
|
|
@@ -1346,7 +1352,7 @@ class Kt {
|
|
|
1346
1352
|
});
|
|
1347
1353
|
}
|
|
1348
1354
|
handleServerEvent(e) {
|
|
1349
|
-
if (
|
|
1355
|
+
if (He("server_event", e.type, mt(e)), e.type === "session.subscribed") {
|
|
1350
1356
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1351
1357
|
if (s && n && s === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
|
|
1352
1358
|
const r = this.pendingSessionSubscription;
|
|
@@ -1359,7 +1365,7 @@ class Kt {
|
|
|
1359
1365
|
this.pendingSessionSubscription = null, s.resolve(!1), n && (this.sessionHistoryHydration = null, this.handleServerEvent({ ...e, requestId: n.requestId }));
|
|
1360
1366
|
return;
|
|
1361
1367
|
}
|
|
1362
|
-
if (this.sessionHistoryHydration &&
|
|
1368
|
+
if (this.sessionHistoryHydration && fe(e) && K(e) === this.sessionHistoryHydration.sessionId) {
|
|
1363
1369
|
this.sessionHistoryHydration.bufferedEvents.push(e);
|
|
1364
1370
|
return;
|
|
1365
1371
|
}
|
|
@@ -1368,434 +1374,442 @@ class Kt {
|
|
|
1368
1374
|
U(e.item),
|
|
1369
1375
|
M(e.item, "createdAt")
|
|
1370
1376
|
), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1371
|
-
if (e.type === "
|
|
1372
|
-
this.
|
|
1373
|
-
return;
|
|
1374
|
-
}
|
|
1375
|
-
if (e.type === "run.ack") {
|
|
1376
|
-
if (this.shouldIgnoreStoppedTurnEvent(e))
|
|
1377
|
-
return;
|
|
1378
|
-
const s = oe(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1379
|
-
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);
|
|
1377
|
+
if (e.type === "run.ack" && typeof e.sessionId == "string" && typeof e.clientMessageId == "string" && this.detachedClientMessageIds.delete(e.clientMessageId) && e.sessionId !== this.state.sessionId) {
|
|
1378
|
+
this.detachedSessionIds.add(e.sessionId), this.deferredDetachedSessionEvents.delete(e.sessionId);
|
|
1380
1379
|
return;
|
|
1381
1380
|
}
|
|
1382
|
-
if (
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1381
|
+
if (!this.shouldDeferDetachedSessionEvent(e) && !this.shouldIgnoreDetachedSessionEvent(e)) {
|
|
1382
|
+
if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
|
|
1383
|
+
this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
|
|
1386
1384
|
return;
|
|
1387
1385
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
if (e.type === "run.steered") {
|
|
1391
|
-
this.handleRunSteered(e);
|
|
1392
|
-
return;
|
|
1393
|
-
}
|
|
1394
|
-
if (e.type === "runtime.pong") {
|
|
1395
|
-
this.clearHeartbeatAckTimer();
|
|
1396
|
-
return;
|
|
1397
|
-
}
|
|
1398
|
-
if (e.type === "run.model_started") {
|
|
1399
|
-
const s = typeof e.runId == "string" ? e.runId : null;
|
|
1400
|
-
if (!this.state.isThinking || !s || this.activeResponseRunId && this.activeResponseRunId !== s)
|
|
1386
|
+
if (e.type === "run.ack") {
|
|
1387
|
+
if (this.shouldIgnoreStoppedTurnEvent(e))
|
|
1401
1388
|
return;
|
|
1402
|
-
|
|
1389
|
+
const s = K(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null, r = s ? this.deferredDetachedSessionEvents.get(s) ?? [] : [];
|
|
1390
|
+
s && this.deferredDetachedSessionEvents.delete(s), 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);
|
|
1391
|
+
for (const i of r)
|
|
1392
|
+
this.handleServerEvent(i);
|
|
1403
1393
|
return;
|
|
1404
1394
|
}
|
|
1405
|
-
if (
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
hasAppearance: r,
|
|
1412
|
-
rawAppearance: e.appearance,
|
|
1413
|
-
normalizedAppearance: n
|
|
1414
|
-
}), this.runtimeHelperJavascript = er(e.runtimeHelpers)?.javascript ?? null;
|
|
1415
|
-
const i = _t(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1416
|
-
user: s,
|
|
1417
|
-
status: "connected",
|
|
1418
|
-
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1419
|
-
};
|
|
1420
|
-
(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 && !fe() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1421
|
-
type: "page.upsert",
|
|
1422
|
-
sessionId: this.state.sessionId,
|
|
1423
|
-
page: b(),
|
|
1424
|
-
model: this.options.model
|
|
1425
|
-
});
|
|
1426
|
-
return;
|
|
1427
|
-
}
|
|
1428
|
-
if (e.type === "starterPrompts.updated") {
|
|
1429
|
-
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1430
|
-
starterPrompts: _t(e, "starterPrompts"),
|
|
1431
|
-
starterPromptsLoading: !1
|
|
1432
|
-
});
|
|
1433
|
-
return;
|
|
1395
|
+
if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
1396
|
+
const s = K(e);
|
|
1397
|
+
if (s) {
|
|
1398
|
+
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1434
1401
|
}
|
|
1435
|
-
if (e
|
|
1436
|
-
|
|
1437
|
-
|
|
1402
|
+
if (!this.shouldIgnoreBackgroundSessionEvent(e) && !this.shouldIgnoreStoppedTurnEvent(e)) {
|
|
1403
|
+
if (e.type === "run.steered") {
|
|
1404
|
+
this.handleRunSteered(e);
|
|
1438
1405
|
return;
|
|
1439
|
-
this.updatePersonalModelFromSession(e.session), n === this.state.sessionId && this.clearSessionLoadRequest();
|
|
1440
|
-
for (const E of s)
|
|
1441
|
-
this.rememberDurablyStoppedTurn(
|
|
1442
|
-
n,
|
|
1443
|
-
U(E),
|
|
1444
|
-
M(E, "createdAt")
|
|
1445
|
-
);
|
|
1446
|
-
const o = Z(s), a = o === null ? null : s[o], l = U(a), c = this.findStoppedTurn(n, {
|
|
1447
|
-
clientMessageId: l?.clientMessageId,
|
|
1448
|
-
respondsToUserMessageId: M(a, "id"),
|
|
1449
|
-
runId: l?.runId
|
|
1450
|
-
}), d = this.filterStoppedSnapshotItems(s, n), h = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, y = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, f = e.isRetrying === !0, u = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1451
|
-
h && y && (this.pendingClientMessageId = y);
|
|
1452
|
-
let p = pr(
|
|
1453
|
-
e.assistantDraft
|
|
1454
|
-
);
|
|
1455
|
-
p && this.findStoppedTurn(n, {
|
|
1456
|
-
respondsToUserMessageId: p.respondsToUserMessageId,
|
|
1457
|
-
runId: p.runId
|
|
1458
|
-
}) && (p = void 0);
|
|
1459
|
-
const g = p !== void 0;
|
|
1460
|
-
this.rememberUserMessageClientMessageIds(d);
|
|
1461
|
-
const m = _r(d);
|
|
1462
|
-
if (m) {
|
|
1463
|
-
const E = Pr(d, m);
|
|
1464
|
-
this.retryAttemptsByClientMessageId[m] = Math.max(
|
|
1465
|
-
this.retryAttemptsByClientMessageId[m] ?? 0,
|
|
1466
|
-
E
|
|
1467
|
-
);
|
|
1468
1406
|
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
return vt(q) ? !1 : !q || !m || !Ae(q) ? !0 : Ye(d, q) !== m;
|
|
1472
|
-
}), S = Qt(
|
|
1473
|
-
this.state.messages,
|
|
1474
|
-
Pt(C, this.options.backendUrl)
|
|
1475
|
-
), _ = Ut(S), v = g ? p?.content ?? "" : this.state.assistantDraft, R = g ? p?.itemId ?? null : this.state.assistantDraftItemId, ee = g ? p?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, P = g ? p?.runId ?? null : this.state.assistantDraftRunId, F = d.some(
|
|
1476
|
-
(E, q) => Dt(
|
|
1477
|
-
U(E),
|
|
1478
|
-
v,
|
|
1479
|
-
R,
|
|
1480
|
-
ee,
|
|
1481
|
-
P,
|
|
1482
|
-
Ur(d, q)
|
|
1483
|
-
)
|
|
1484
|
-
), X = g ? p?.content ?? "" : this.state.assistantDraft, te = !!p?.content && !F, N = _ && (!X || F), ue = kr(S), z = N && ue ? "completed" : c ? "stopped" : N ? "failed" : null;
|
|
1485
|
-
if (!_ && br(this.state.messages, d))
|
|
1407
|
+
if (e.type === "runtime.pong") {
|
|
1408
|
+
this.clearHeartbeatAckTimer();
|
|
1486
1409
|
return;
|
|
1487
|
-
this.lastUserMessagePageUrl = Cr(d);
|
|
1488
|
-
const x = N || c ? null : Je(d);
|
|
1489
|
-
if (this.latestRecoverableClientMessageId = x, ue && this.clearRetryTimers(), this.setState({
|
|
1490
|
-
sessionId: M(e.session, "id") ?? this.state.sessionId,
|
|
1491
|
-
messages: S,
|
|
1492
|
-
isLoadingSession: !1,
|
|
1493
|
-
...h ? { pendingMessageStatus: h } : {},
|
|
1494
|
-
...u ? { turnPhase: u } : {},
|
|
1495
|
-
isRetrying: f,
|
|
1496
|
-
...z && this.state.taskStatus === "working" ? { taskStatus: z } : {},
|
|
1497
|
-
...F ? {
|
|
1498
|
-
assistantDraft: "",
|
|
1499
|
-
assistantDraftItemId: null,
|
|
1500
|
-
assistantDraftPhase: null,
|
|
1501
|
-
assistantDraftRespondsToUserMessageId: null,
|
|
1502
|
-
assistantDraftRunId: null
|
|
1503
|
-
} : g ? {
|
|
1504
|
-
assistantDraft: p?.content ?? "",
|
|
1505
|
-
assistantDraftItemId: p?.itemId ?? null,
|
|
1506
|
-
assistantDraftPhase: p?.phase ?? null,
|
|
1507
|
-
assistantDraftRespondsToUserMessageId: p?.respondsToUserMessageId ?? null,
|
|
1508
|
-
assistantDraftRunId: p?.runId ?? null
|
|
1509
|
-
} : {},
|
|
1510
|
-
...te ? {
|
|
1511
|
-
isThinking: !0,
|
|
1512
|
-
turnPhase: "thinking",
|
|
1513
|
-
lastError: null
|
|
1514
|
-
} : N ? {
|
|
1515
|
-
isThinking: !1,
|
|
1516
|
-
status: "connected",
|
|
1517
|
-
lastError: null,
|
|
1518
|
-
lastErrorCode: null,
|
|
1519
|
-
lastErrorSecuritySettingsUrl: null
|
|
1520
|
-
} : x ? {
|
|
1521
|
-
isThinking: !0,
|
|
1522
|
-
turnPhase: u ?? this.state.turnPhase ?? "starting",
|
|
1523
|
-
lastError: null
|
|
1524
|
-
} : {}
|
|
1525
|
-
}), N)
|
|
1526
|
-
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1527
|
-
else if (!c && (te || x)) {
|
|
1528
|
-
if (x) {
|
|
1529
|
-
this.activeClientMessageId = x;
|
|
1530
|
-
const E = Z(d), q = E === null ? null : d[E];
|
|
1531
|
-
this.activeResponseUserMessageId = M(q, "id");
|
|
1532
|
-
}
|
|
1533
|
-
this.markThinkingProgress();
|
|
1534
1410
|
}
|
|
1535
|
-
if (
|
|
1536
|
-
const
|
|
1537
|
-
|
|
1411
|
+
if (e.type === "run.model_started") {
|
|
1412
|
+
const s = typeof e.runId == "string" ? e.runId : null;
|
|
1413
|
+
if (!this.state.isThinking || !s || this.activeResponseRunId && this.activeResponseRunId !== s)
|
|
1414
|
+
return;
|
|
1415
|
+
this.activeResponseRunId = s, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
|
|
1416
|
+
return;
|
|
1538
1417
|
}
|
|
1539
|
-
|
|
1540
|
-
this.
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1418
|
+
if (Mn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
1419
|
+
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
1420
|
+
const s = rr(e.user);
|
|
1421
|
+
this.authenticatedSocket !== this.socket && this.authenticatedUserId && s && s.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = s?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
1422
|
+
const n = Zn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1423
|
+
w("web-sdk.agent", "Received auth.ok appearance", {
|
|
1424
|
+
hasAppearance: r,
|
|
1425
|
+
rawAppearance: e.appearance,
|
|
1426
|
+
normalizedAppearance: n
|
|
1427
|
+
}), this.runtimeHelperJavascript = er(e.runtimeHelpers)?.javascript ?? null;
|
|
1428
|
+
const i = _t(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1429
|
+
user: s,
|
|
1430
|
+
status: "connected",
|
|
1431
|
+
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1432
|
+
};
|
|
1433
|
+
(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 && !me() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1434
|
+
type: "page.upsert",
|
|
1435
|
+
sessionId: this.state.sessionId,
|
|
1436
|
+
page: b(),
|
|
1437
|
+
model: this.options.model
|
|
1438
|
+
});
|
|
1547
1439
|
return;
|
|
1548
|
-
const r = Pt(
|
|
1549
|
-
Array.isArray(e.items) ? e.items : [],
|
|
1550
|
-
this.options.backendUrl
|
|
1551
|
-
);
|
|
1552
|
-
s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
1553
|
-
messages: Sr(this.state.messages, r)
|
|
1554
|
-
});
|
|
1555
|
-
return;
|
|
1556
|
-
}
|
|
1557
|
-
if (e.type === "sessions.page") {
|
|
1558
|
-
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1559
|
-
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1560
|
-
sessions: ir(e.sessions),
|
|
1561
|
-
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1562
|
-
}));
|
|
1563
|
-
return;
|
|
1564
|
-
}
|
|
1565
|
-
if (e.type === "session.pin.updated") {
|
|
1566
|
-
this.resolvePendingSessionMutation(this.pendingSessionPinRequests, e);
|
|
1567
|
-
return;
|
|
1568
|
-
}
|
|
1569
|
-
if (e.type === "session.rename.updated") {
|
|
1570
|
-
this.resolvePendingSessionMutation(this.pendingSessionRenameRequests, e);
|
|
1571
|
-
return;
|
|
1572
|
-
}
|
|
1573
|
-
if (e.type === "session.updated") {
|
|
1574
|
-
this.clearRunAckResyncRetryTimer();
|
|
1575
|
-
const s = M(e.session, "id");
|
|
1576
|
-
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1577
|
-
...this.pendingComposerWarmup.event,
|
|
1578
|
-
sessionId: s
|
|
1579
|
-
}, this.pendingComposerWarmup.scope = `${s}:${this.pendingComposerWarmup.event.page.url}`), this.setState({ sessionId: s ?? this.state.sessionId }), this.updatePersonalModelFromSession(e.session);
|
|
1580
|
-
const n = e.session && typeof e.session == "object" ? e.session.metadata : null;
|
|
1581
|
-
typeof e.warmupId == "string" && e.warmupId === this.activeComposerWarmupId && n && typeof n == "object" && n.composerPreload && this.clearPendingComposerWarmup();
|
|
1582
|
-
return;
|
|
1583
|
-
}
|
|
1584
|
-
if (e.type === "session.item") {
|
|
1585
|
-
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1586
|
-
const s = U(e.item);
|
|
1587
|
-
if (Ae(s)) {
|
|
1588
|
-
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1589
|
-
const r = M(e.item, "sessionId") ?? this.state.sessionId, i = s ? L(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1590
|
-
if (r && a) {
|
|
1591
|
-
this.retryAfterInterruptedRun(r, a);
|
|
1592
|
-
return;
|
|
1593
|
-
}
|
|
1594
|
-
if (r && i) {
|
|
1595
|
-
this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
|
|
1596
|
-
return;
|
|
1597
|
-
}
|
|
1598
1440
|
}
|
|
1599
|
-
if (
|
|
1441
|
+
if (e.type === "starterPrompts.updated") {
|
|
1442
|
+
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1443
|
+
starterPrompts: _t(e, "starterPrompts"),
|
|
1444
|
+
starterPromptsLoading: !1
|
|
1445
|
+
});
|
|
1600
1446
|
return;
|
|
1601
|
-
|
|
1602
|
-
if (
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
this.
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1447
|
+
}
|
|
1448
|
+
if (e.type === "conversation.state") {
|
|
1449
|
+
const s = Array.isArray(e.items) ? e.items : [], n = M(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null, i = this.state.isLoadingSession && this.sessionLoadRequestId === null && r === null && n === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
|
|
1450
|
+
if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && this.sessionLoadRequestId !== null && r === null || this.state.isLoadingSession && n !== this.state.sessionId)
|
|
1451
|
+
return;
|
|
1452
|
+
this.updatePersonalModelFromSession(e.session), n === this.state.sessionId && this.clearSessionLoadRequest();
|
|
1453
|
+
for (const E of s)
|
|
1454
|
+
this.rememberDurablyStoppedTurn(
|
|
1455
|
+
n,
|
|
1456
|
+
U(E),
|
|
1457
|
+
M(E, "createdAt")
|
|
1458
|
+
);
|
|
1459
|
+
const o = ee(s), a = o === null ? null : s[o], l = U(a), c = this.findStoppedTurn(n, {
|
|
1460
|
+
clientMessageId: l?.clientMessageId,
|
|
1461
|
+
respondsToUserMessageId: M(a, "id"),
|
|
1462
|
+
runId: l?.runId
|
|
1463
|
+
}), d = this.filterStoppedSnapshotItems(s, n), p = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, y = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, f = e.isRetrying === !0, u = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1464
|
+
p && y && (this.pendingClientMessageId = y);
|
|
1465
|
+
let h = hr(
|
|
1466
|
+
e.assistantDraft
|
|
1467
|
+
);
|
|
1468
|
+
h && this.findStoppedTurn(n, {
|
|
1469
|
+
respondsToUserMessageId: h.respondsToUserMessageId,
|
|
1470
|
+
runId: h.runId
|
|
1471
|
+
}) && (h = void 0);
|
|
1472
|
+
const g = h !== void 0;
|
|
1473
|
+
this.rememberUserMessageClientMessageIds(d);
|
|
1474
|
+
const m = _r(d);
|
|
1475
|
+
if (m) {
|
|
1476
|
+
const E = Pr(d, m);
|
|
1477
|
+
this.retryAttemptsByClientMessageId[m] = Math.max(
|
|
1478
|
+
this.retryAttemptsByClientMessageId[m] ?? 0,
|
|
1479
|
+
E
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
const C = d.filter((E) => {
|
|
1483
|
+
const O = U(E);
|
|
1484
|
+
return vt(O) ? !1 : !O || !m || !Re(O) ? !0 : Qe(d, O) !== m;
|
|
1485
|
+
}), S = Qt(
|
|
1486
|
+
this.state.messages,
|
|
1487
|
+
Pt(C, this.options.backendUrl)
|
|
1488
|
+
), _ = Ut(S), v = g ? h?.content ?? "" : this.state.assistantDraft, R = g ? h?.itemId ?? null : this.state.assistantDraftItemId, te = g ? h?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, P = g ? h?.runId ?? null : this.state.assistantDraftRunId, F = d.some(
|
|
1489
|
+
(E, O) => Dt(
|
|
1490
|
+
U(E),
|
|
1491
|
+
v,
|
|
1492
|
+
R,
|
|
1493
|
+
te,
|
|
1494
|
+
P,
|
|
1495
|
+
Ur(d, O)
|
|
1614
1496
|
)
|
|
1615
|
-
),
|
|
1616
|
-
this.
|
|
1617
|
-
|
|
1618
|
-
|
|
1497
|
+
), J = g ? h?.content ?? "" : this.state.assistantDraft, se = !!h?.content && !F, N = _ && (!J || F), ue = kr(S), z = N && ue ? "completed" : c ? "stopped" : N ? "failed" : null;
|
|
1498
|
+
if (!_ && br(this.state.messages, d))
|
|
1499
|
+
return;
|
|
1500
|
+
this.lastUserMessagePageUrl = Cr(d);
|
|
1501
|
+
const x = N || c ? null : Ye(d);
|
|
1502
|
+
if (this.latestRecoverableClientMessageId = x, ue && this.clearRetryTimers(), this.setState({
|
|
1503
|
+
sessionId: M(e.session, "id") ?? this.state.sessionId,
|
|
1504
|
+
messages: S,
|
|
1505
|
+
isLoadingSession: !1,
|
|
1506
|
+
...p ? { pendingMessageStatus: p } : {},
|
|
1507
|
+
...u ? { turnPhase: u } : {},
|
|
1508
|
+
isRetrying: f,
|
|
1509
|
+
...z && this.state.taskStatus === "working" ? { taskStatus: z } : {},
|
|
1510
|
+
...F ? {
|
|
1619
1511
|
assistantDraft: "",
|
|
1620
1512
|
assistantDraftItemId: null,
|
|
1621
1513
|
assistantDraftPhase: null,
|
|
1622
1514
|
assistantDraftRespondsToUserMessageId: null,
|
|
1623
1515
|
assistantDraftRunId: null
|
|
1516
|
+
} : g ? {
|
|
1517
|
+
assistantDraft: h?.content ?? "",
|
|
1518
|
+
assistantDraftItemId: h?.itemId ?? null,
|
|
1519
|
+
assistantDraftPhase: h?.phase ?? null,
|
|
1520
|
+
assistantDraftRespondsToUserMessageId: h?.respondsToUserMessageId ?? null,
|
|
1521
|
+
assistantDraftRunId: h?.runId ?? null
|
|
1624
1522
|
} : {},
|
|
1625
|
-
...
|
|
1523
|
+
...se ? {
|
|
1524
|
+
isThinking: !0,
|
|
1525
|
+
turnPhase: "thinking",
|
|
1526
|
+
lastError: null
|
|
1527
|
+
} : N ? {
|
|
1626
1528
|
isThinking: !1,
|
|
1627
|
-
...r && this.state.taskStatus === "working" ? { taskStatus: r } : {},
|
|
1628
|
-
isRetrying: !1
|
|
1629
|
-
} : {},
|
|
1630
|
-
...d && !this.failedUserMessageEvent ? {
|
|
1631
1529
|
status: "connected",
|
|
1632
1530
|
lastError: null,
|
|
1633
1531
|
lastErrorCode: null,
|
|
1634
1532
|
lastErrorSecuritySettingsUrl: null
|
|
1533
|
+
} : x ? {
|
|
1534
|
+
isThinking: !0,
|
|
1535
|
+
turnPhase: u ?? this.state.turnPhase ?? "starting",
|
|
1536
|
+
lastError: null
|
|
1635
1537
|
} : {}
|
|
1636
|
-
}),
|
|
1538
|
+
}), N)
|
|
1539
|
+
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1540
|
+
else if (!c && (se || x)) {
|
|
1541
|
+
if (x) {
|
|
1542
|
+
this.activeClientMessageId = x;
|
|
1543
|
+
const E = ee(d), O = E === null ? null : d[E];
|
|
1544
|
+
this.activeResponseUserMessageId = M(O, "id");
|
|
1545
|
+
}
|
|
1546
|
+
this.markThinkingProgress();
|
|
1547
|
+
}
|
|
1548
|
+
if (m) {
|
|
1549
|
+
const E = M(e.session, "id") ?? this.state.sessionId;
|
|
1550
|
+
E && this.retryAfterInterruptedRun(E, m);
|
|
1551
|
+
}
|
|
1552
|
+
i && n && window.setTimeout(() => {
|
|
1553
|
+
this.autoLoadSessionActivity(n);
|
|
1554
|
+
}, 0);
|
|
1555
|
+
return;
|
|
1637
1556
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1650
|
-
dataType: "assistant_draft",
|
|
1651
|
-
...l ? { phase: l } : {},
|
|
1652
|
-
...c ? { respondsToUserMessageId: c } : {},
|
|
1653
|
-
...d ? { runId: d } : {}
|
|
1654
|
-
}),
|
|
1655
|
-
assistantDraft: i,
|
|
1656
|
-
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1657
|
-
assistantDraftPhase: l,
|
|
1658
|
-
assistantDraftRespondsToUserMessageId: c,
|
|
1659
|
-
assistantDraftRunId: d,
|
|
1660
|
-
isThinking: !0,
|
|
1661
|
-
taskStatus: "working",
|
|
1662
|
-
isRetrying: !1
|
|
1663
|
-
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1664
|
-
return;
|
|
1665
|
-
}
|
|
1666
|
-
if (e.type === "chat.assistant_done") {
|
|
1667
|
-
if (typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(e.runId))
|
|
1557
|
+
if (e.type === "session.activity.page") {
|
|
1558
|
+
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1559
|
+
if (!s || n !== this.state.sessionId)
|
|
1560
|
+
return;
|
|
1561
|
+
const r = Pt(
|
|
1562
|
+
Array.isArray(e.items) ? e.items : [],
|
|
1563
|
+
this.options.backendUrl
|
|
1564
|
+
);
|
|
1565
|
+
s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
1566
|
+
messages: Sr(this.state.messages, r)
|
|
1567
|
+
});
|
|
1668
1568
|
return;
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1569
|
+
}
|
|
1570
|
+
if (e.type === "sessions.page") {
|
|
1571
|
+
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1572
|
+
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1573
|
+
sessions: ir(e.sessions),
|
|
1574
|
+
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1575
|
+
}));
|
|
1672
1576
|
return;
|
|
1673
|
-
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 = Ds(
|
|
1674
|
-
this.state.messages.filter(
|
|
1675
|
-
(c) => c.dataType !== "assistant_draft" || !Fe(
|
|
1676
|
-
c,
|
|
1677
|
-
n,
|
|
1678
|
-
r
|
|
1679
|
-
)
|
|
1680
|
-
),
|
|
1681
|
-
n,
|
|
1682
|
-
r,
|
|
1683
|
-
Zt
|
|
1684
|
-
);
|
|
1685
|
-
this.setState({
|
|
1686
|
-
sessionId: s,
|
|
1687
|
-
messages: fr(
|
|
1688
|
-
l,
|
|
1689
|
-
typeof e.responseId == "string" ? e.responseId : null,
|
|
1690
|
-
n,
|
|
1691
|
-
r
|
|
1692
|
-
),
|
|
1693
|
-
assistantDraft: "",
|
|
1694
|
-
assistantDraftItemId: null,
|
|
1695
|
-
assistantDraftPhase: null,
|
|
1696
|
-
assistantDraftRespondsToUserMessageId: null,
|
|
1697
|
-
assistantDraftRunId: null,
|
|
1698
|
-
isThinking: a ? !1 : this.state.isThinking,
|
|
1699
|
-
...a && this.state.taskStatus === "working" ? { taskStatus: "completed" } : {},
|
|
1700
|
-
isRetrying: a ? !1 : this.state.isRetrying
|
|
1701
|
-
}), a && this.clearThinkingWatchdog();
|
|
1702
|
-
return;
|
|
1703
|
-
}
|
|
1704
|
-
if (e.type === "tool.call") {
|
|
1705
|
-
this.clearRunAckResyncRetryTimer();
|
|
1706
|
-
const s = e.hiddenFromTranscript === !0 && typeof e.callId == "string" ? e.callId : null;
|
|
1707
|
-
if (s)
|
|
1708
|
-
this.nonTranscriptToolCallIds.add(s);
|
|
1709
|
-
else {
|
|
1710
|
-
const n = Ir(e);
|
|
1711
|
-
if (n) {
|
|
1712
|
-
const r = mr(
|
|
1713
|
-
this.state.messages,
|
|
1714
|
-
n
|
|
1715
|
-
);
|
|
1716
|
-
this.setState({
|
|
1717
|
-
messages: r,
|
|
1718
|
-
isThinking: !0
|
|
1719
|
-
}), this.emit(
|
|
1720
|
-
"message",
|
|
1721
|
-
r.find(
|
|
1722
|
-
(i) => i.callId === n.callId
|
|
1723
|
-
) ?? n
|
|
1724
|
-
);
|
|
1725
|
-
}
|
|
1726
1577
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
}
|
|
1730
|
-
if (e.type === "tool.status") {
|
|
1731
|
-
const s = typeof e.callId == "string" ? e.callId : null;
|
|
1732
|
-
if (!s)
|
|
1578
|
+
if (e.type === "session.pin.updated") {
|
|
1579
|
+
this.resolvePendingSessionMutation(this.pendingSessionPinRequests, e);
|
|
1733
1580
|
return;
|
|
1734
|
-
|
|
1735
|
-
if (
|
|
1581
|
+
}
|
|
1582
|
+
if (e.type === "session.rename.updated") {
|
|
1583
|
+
this.resolvePendingSessionMutation(this.pendingSessionRenameRequests, e);
|
|
1736
1584
|
return;
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
lastError: typeof e.message == "string" ? e.message : "Could not load this chat."
|
|
1748
|
-
});
|
|
1585
|
+
}
|
|
1586
|
+
if (e.type === "session.updated") {
|
|
1587
|
+
this.clearRunAckResyncRetryTimer();
|
|
1588
|
+
const s = M(e.session, "id");
|
|
1589
|
+
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1590
|
+
...this.pendingComposerWarmup.event,
|
|
1591
|
+
sessionId: s
|
|
1592
|
+
}, this.pendingComposerWarmup.scope = `${s}:${this.pendingComposerWarmup.event.page.url}`), this.setState({ sessionId: s ?? this.state.sessionId }), this.updatePersonalModelFromSession(e.session);
|
|
1593
|
+
const n = e.session && typeof e.session == "object" ? e.session.metadata : null;
|
|
1594
|
+
typeof e.warmupId == "string" && e.warmupId === this.activeComposerWarmupId && n && typeof n == "object" && n.composerPreload && this.clearPendingComposerWarmup();
|
|
1749
1595
|
return;
|
|
1750
1596
|
}
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1597
|
+
if (e.type === "session.item") {
|
|
1598
|
+
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1599
|
+
const s = U(e.item);
|
|
1600
|
+
if (Re(s)) {
|
|
1601
|
+
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1602
|
+
const r = M(e.item, "sessionId") ?? this.state.sessionId, i = s ? L(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1603
|
+
if (r && a) {
|
|
1604
|
+
this.retryAfterInterruptedRun(r, a);
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
if (r && i) {
|
|
1608
|
+
this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
|
|
1609
|
+
return;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
if (vt(s))
|
|
1613
|
+
return;
|
|
1614
|
+
const n = Yt(e.item, this.options.backendUrl);
|
|
1615
|
+
if (n) {
|
|
1616
|
+
const r = Lr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1617
|
+
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), H(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Dr(s) && this.clearRunAckResyncRetryTimer();
|
|
1618
|
+
const o = Je(this.state.messages, n), a = Ut(o), l = Dt(
|
|
1619
|
+
s,
|
|
1620
|
+
this.state.assistantDraft,
|
|
1621
|
+
this.state.assistantDraftItemId,
|
|
1622
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
1623
|
+
this.state.assistantDraftRunId,
|
|
1624
|
+
ns(
|
|
1625
|
+
o,
|
|
1626
|
+
o.findIndex((p) => p.id === n.id)
|
|
1627
|
+
)
|
|
1628
|
+
), c = a && (!this.state.assistantDraft || l), d = Ae(n) && (c || H(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
1629
|
+
this.setState({
|
|
1630
|
+
messages: o,
|
|
1631
|
+
...l ? {
|
|
1632
|
+
assistantDraft: "",
|
|
1633
|
+
assistantDraftItemId: null,
|
|
1634
|
+
assistantDraftPhase: null,
|
|
1635
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1636
|
+
assistantDraftRunId: null
|
|
1637
|
+
} : {},
|
|
1638
|
+
...c ? {
|
|
1639
|
+
isThinking: !1,
|
|
1640
|
+
...r && this.state.taskStatus === "working" ? { taskStatus: r } : {},
|
|
1641
|
+
isRetrying: !1
|
|
1642
|
+
} : {},
|
|
1643
|
+
...d && !this.failedUserMessageEvent ? {
|
|
1644
|
+
status: "connected",
|
|
1645
|
+
lastError: null,
|
|
1646
|
+
lastErrorCode: null,
|
|
1647
|
+
lastErrorSecuritySettingsUrl: null
|
|
1648
|
+
} : {}
|
|
1649
|
+
}), c && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
1650
|
+
}
|
|
1754
1651
|
return;
|
|
1755
1652
|
}
|
|
1756
|
-
if (
|
|
1653
|
+
if (e.type === "chat.assistant_delta") {
|
|
1654
|
+
this.clearRunAckResyncRetryTimer();
|
|
1655
|
+
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, d = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1656
|
+
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = d), this.setState({
|
|
1657
|
+
messages: Je(this.state.messages, {
|
|
1658
|
+
id: o,
|
|
1659
|
+
role: "assistant",
|
|
1660
|
+
content: i,
|
|
1661
|
+
createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1662
|
+
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1663
|
+
dataType: "assistant_draft",
|
|
1664
|
+
...l ? { phase: l } : {},
|
|
1665
|
+
...c ? { respondsToUserMessageId: c } : {},
|
|
1666
|
+
...d ? { runId: d } : {}
|
|
1667
|
+
}),
|
|
1668
|
+
assistantDraft: i,
|
|
1669
|
+
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1670
|
+
assistantDraftPhase: l,
|
|
1671
|
+
assistantDraftRespondsToUserMessageId: c,
|
|
1672
|
+
assistantDraftRunId: d,
|
|
1673
|
+
isThinking: !0,
|
|
1674
|
+
taskStatus: "working",
|
|
1675
|
+
isRetrying: !1
|
|
1676
|
+
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1757
1677
|
return;
|
|
1758
|
-
|
|
1759
|
-
if (e.
|
|
1760
|
-
this.
|
|
1678
|
+
}
|
|
1679
|
+
if (e.type === "chat.assistant_done") {
|
|
1680
|
+
if (typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(e.runId))
|
|
1681
|
+
return;
|
|
1682
|
+
this.retryableClientMessageId = null;
|
|
1683
|
+
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;
|
|
1684
|
+
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1685
|
+
return;
|
|
1686
|
+
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 = Ds(
|
|
1687
|
+
this.state.messages.filter(
|
|
1688
|
+
(c) => c.dataType !== "assistant_draft" || !ze(
|
|
1689
|
+
c,
|
|
1690
|
+
n,
|
|
1691
|
+
r
|
|
1692
|
+
)
|
|
1693
|
+
),
|
|
1694
|
+
n,
|
|
1695
|
+
r,
|
|
1696
|
+
Zt
|
|
1697
|
+
);
|
|
1698
|
+
this.setState({
|
|
1699
|
+
sessionId: s,
|
|
1700
|
+
messages: fr(
|
|
1701
|
+
l,
|
|
1702
|
+
typeof e.responseId == "string" ? e.responseId : null,
|
|
1703
|
+
n,
|
|
1704
|
+
r
|
|
1705
|
+
),
|
|
1706
|
+
assistantDraft: "",
|
|
1707
|
+
assistantDraftItemId: null,
|
|
1708
|
+
assistantDraftPhase: null,
|
|
1709
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1710
|
+
assistantDraftRunId: null,
|
|
1711
|
+
isThinking: a ? !1 : this.state.isThinking,
|
|
1712
|
+
...a && this.state.taskStatus === "working" ? { taskStatus: "completed" } : {},
|
|
1713
|
+
isRetrying: a ? !1 : this.state.isRetrying
|
|
1714
|
+
}), a && this.clearThinkingWatchdog();
|
|
1761
1715
|
return;
|
|
1762
1716
|
}
|
|
1763
|
-
if (
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1717
|
+
if (e.type === "tool.call") {
|
|
1718
|
+
this.clearRunAckResyncRetryTimer();
|
|
1719
|
+
const s = e.hiddenFromTranscript === !0 && typeof e.callId == "string" ? e.callId : null;
|
|
1720
|
+
if (s)
|
|
1721
|
+
this.nonTranscriptToolCallIds.add(s);
|
|
1722
|
+
else {
|
|
1723
|
+
const n = Ir(e);
|
|
1724
|
+
if (n) {
|
|
1725
|
+
const r = mr(
|
|
1726
|
+
this.state.messages,
|
|
1727
|
+
n
|
|
1728
|
+
);
|
|
1729
|
+
this.setState({
|
|
1730
|
+
messages: r,
|
|
1731
|
+
isThinking: !0
|
|
1732
|
+
}), this.emit(
|
|
1733
|
+
"message",
|
|
1734
|
+
r.find(
|
|
1735
|
+
(i) => i.callId === n.callId
|
|
1736
|
+
) ?? n
|
|
1737
|
+
);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
this.executeToolCall(e);
|
|
1741
|
+
return;
|
|
1742
|
+
}
|
|
1743
|
+
if (e.type === "tool.status") {
|
|
1744
|
+
const s = typeof e.callId == "string" ? e.callId : null;
|
|
1745
|
+
if (!s)
|
|
1746
|
+
return;
|
|
1747
|
+
const n = e.status === "queued" || e.status === "running";
|
|
1748
|
+
if (this.nonTranscriptToolCallIds.has(s) || n && this.terminalToolCallIds.has(s))
|
|
1749
|
+
return;
|
|
1750
|
+
n || this.terminalToolCallIds.add(s), this.state.messages.some(
|
|
1751
|
+
(i) => i.callId === s
|
|
1752
|
+
) ? this.setToolMessageLoading(s, n) : this.pendingToolLoadingByCallId.set(s, n);
|
|
1770
1753
|
return;
|
|
1771
1754
|
}
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1755
|
+
if (e.type === "error") {
|
|
1756
|
+
const s = typeof e.requestId == "string" ? e.requestId : null;
|
|
1757
|
+
if (s && s === this.sessionLoadRequestId) {
|
|
1758
|
+
this.clearSessionLoadRequest(), this.setState({
|
|
1759
|
+
isLoadingSession: !1,
|
|
1760
|
+
lastError: typeof e.message == "string" ? e.message : "Could not load this chat."
|
|
1761
|
+
});
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
const n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1765
|
+
if (s && n) {
|
|
1766
|
+
window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof e.message == "string" ? e.message : "Pluno error"));
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
if (this.rejectPendingSessionMutation(this.pendingSessionPinRequests, e) || this.rejectPendingSessionMutation(this.pendingSessionRenameRequests, e))
|
|
1770
|
+
return;
|
|
1771
|
+
const r = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, i = typeof e.clientMessageId == "string" ? e.clientMessageId : null, o = e.retryable === !0 || e.code === "transient_model_error";
|
|
1772
|
+
if (e.code === "message_delivery_failed" && i && i === this.pendingClientMessageId) {
|
|
1773
|
+
this.failPendingDelivery(i);
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
if (i && i === this.pendingClientMessageId && this.promotePendingDelivery(
|
|
1777
|
+
i,
|
|
1778
|
+
r,
|
|
1779
|
+
typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null,
|
|
1780
|
+
typeof e.runId == "string" ? e.runId : null
|
|
1781
|
+
), this.retryAfterRetryableError(e)) {
|
|
1782
|
+
e.code !== "run_still_active" && typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(e.runId);
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
o && r && i && (this.retryableClientMessageId = i);
|
|
1786
|
+
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Wn(a.message);
|
|
1787
|
+
l && console.error(l);
|
|
1788
|
+
const c = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null, p = Ot(
|
|
1789
|
+
this.state.messages,
|
|
1790
|
+
c,
|
|
1791
|
+
d
|
|
1792
|
+
), y = Er(
|
|
1793
|
+
p,
|
|
1794
|
+
c,
|
|
1795
|
+
d
|
|
1796
|
+
);
|
|
1797
|
+
this.setState({
|
|
1798
|
+
status: y ? "connected" : "error",
|
|
1799
|
+
messages: p,
|
|
1800
|
+
assistantDraft: "",
|
|
1801
|
+
assistantDraftItemId: null,
|
|
1802
|
+
assistantDraftPhase: null,
|
|
1803
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1804
|
+
assistantDraftRunId: null,
|
|
1805
|
+
isThinking: !1,
|
|
1806
|
+
...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
|
|
1807
|
+
isRetrying: !1,
|
|
1808
|
+
lastError: y ? null : a.message,
|
|
1809
|
+
lastErrorCode: y ? null : typeof e.code == "string" ? e.code : null,
|
|
1810
|
+
lastErrorSecuritySettingsUrl: y ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
|
|
1811
|
+
}), this.clearThinkingWatchdog(), this.emit("error", a);
|
|
1812
|
+
}
|
|
1799
1813
|
}
|
|
1800
1814
|
}
|
|
1801
1815
|
}
|
|
@@ -1804,14 +1818,39 @@ class Kt {
|
|
|
1804
1818
|
if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
|
|
1805
1819
|
return;
|
|
1806
1820
|
const s = e.metadata, n = s && typeof s == "object" ? s.model : void 0;
|
|
1807
|
-
this.options.model =
|
|
1821
|
+
this.options.model = We(n) ? n : "gpt-5.6-sol";
|
|
1808
1822
|
}
|
|
1809
1823
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1810
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1824
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !fe(e))
|
|
1811
1825
|
return !1;
|
|
1812
|
-
const s =
|
|
1826
|
+
const s = K(e);
|
|
1813
1827
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1814
1828
|
}
|
|
1829
|
+
shouldIgnoreDetachedSessionEvent(e) {
|
|
1830
|
+
if (this.options.keepRunsActiveOnSessionNavigation || !fe(e))
|
|
1831
|
+
return !1;
|
|
1832
|
+
const s = K(e);
|
|
1833
|
+
return !!(s && this.detachedSessionIds.has(s));
|
|
1834
|
+
}
|
|
1835
|
+
shouldDeferDetachedSessionEvent(e) {
|
|
1836
|
+
if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !fe(e))
|
|
1837
|
+
return !1;
|
|
1838
|
+
const s = K(e);
|
|
1839
|
+
if (!s || s === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(s))
|
|
1840
|
+
return !1;
|
|
1841
|
+
const n = this.deferredDetachedSessionEvents.get(s) ?? [];
|
|
1842
|
+
return n.push(e), this.deferredDetachedSessionEvents.set(s, n.slice(-20)), !0;
|
|
1843
|
+
}
|
|
1844
|
+
rememberCurrentRunAsDetached() {
|
|
1845
|
+
if (this.options.keepRunsActiveOnSessionNavigation)
|
|
1846
|
+
return;
|
|
1847
|
+
if (this.state.sessionId) {
|
|
1848
|
+
this.detachedSessionIds.add(this.state.sessionId);
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
const e = this.pendingClientMessageId ?? this.activeClientMessageId;
|
|
1852
|
+
e && this.detachedClientMessageIds.add(e);
|
|
1853
|
+
}
|
|
1815
1854
|
rememberCurrentRunAsBackground() {
|
|
1816
1855
|
this.options.keepRunsActiveOnSessionNavigation && (this.state.sessionId ? this.backgroundSessionIds.add(this.state.sessionId) : this.state.isThinking && this.activeClientMessageId ? this.backgroundClientMessageIds.add(this.activeClientMessageId) : this.pendingClientMessageId && this.backgroundClientMessageIds.add(this.pendingClientMessageId));
|
|
1817
1856
|
}
|
|
@@ -1819,7 +1858,7 @@ class Kt {
|
|
|
1819
1858
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1820
1859
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1821
1860
|
return !1;
|
|
1822
|
-
if (
|
|
1861
|
+
if (me())
|
|
1823
1862
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1824
1863
|
if (e.code === "run_still_active") {
|
|
1825
1864
|
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) {
|
|
@@ -1833,10 +1872,10 @@ class Kt {
|
|
|
1833
1872
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1834
1873
|
return !0;
|
|
1835
1874
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1836
|
-
if (i >=
|
|
1875
|
+
if (i >= ie)
|
|
1837
1876
|
return !1;
|
|
1838
1877
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1839
|
-
const o =
|
|
1878
|
+
const o = oe(
|
|
1840
1879
|
i,
|
|
1841
1880
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1842
1881
|
);
|
|
@@ -1850,23 +1889,23 @@ class Kt {
|
|
|
1850
1889
|
}, o), !0;
|
|
1851
1890
|
}
|
|
1852
1891
|
retryAfterInterruptedRun(e, s) {
|
|
1853
|
-
if (
|
|
1892
|
+
if (me()) {
|
|
1854
1893
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1855
1894
|
return;
|
|
1856
1895
|
}
|
|
1857
1896
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1858
1897
|
return;
|
|
1859
1898
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1860
|
-
if (n >=
|
|
1899
|
+
if (n >= ie) {
|
|
1861
1900
|
this.requestSessionRecoveryExhaustion(e, s);
|
|
1862
1901
|
return;
|
|
1863
1902
|
}
|
|
1864
1903
|
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(() => {
|
|
1865
1904
|
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 });
|
|
1866
|
-
},
|
|
1905
|
+
}, oe(n));
|
|
1867
1906
|
}
|
|
1868
1907
|
requestSessionRecoveryExhaustion(e, s) {
|
|
1869
|
-
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(
|
|
1908
|
+
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(St);
|
|
1870
1909
|
}
|
|
1871
1910
|
clearRetryTimers() {
|
|
1872
1911
|
for (const e of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1897,7 +1936,7 @@ class Kt {
|
|
|
1897
1936
|
const r = new Promise((i, o) => {
|
|
1898
1937
|
const a = window.setTimeout(() => {
|
|
1899
1938
|
e.delete(s.requestId), o(new Error(n));
|
|
1900
|
-
},
|
|
1939
|
+
}, Rt);
|
|
1901
1940
|
e.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1902
1941
|
});
|
|
1903
1942
|
if (!this.sendNow(s)) {
|
|
@@ -1920,7 +1959,7 @@ class Kt {
|
|
|
1920
1959
|
e.clear();
|
|
1921
1960
|
}
|
|
1922
1961
|
markThinkingProgress() {
|
|
1923
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1962
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Tt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1924
1963
|
}
|
|
1925
1964
|
scheduleThinkingWatchdog(e) {
|
|
1926
1965
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1964,21 +2003,21 @@ class Kt {
|
|
|
1964
2003
|
}), this.markThinkingProgress();
|
|
1965
2004
|
}
|
|
1966
2005
|
schedulePendingDeliveryAck(e) {
|
|
1967
|
-
this.clearPendingDeliveryTimers(), !
|
|
2006
|
+
this.clearPendingDeliveryTimers(), !me() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
1968
2007
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
1969
|
-
},
|
|
2008
|
+
}, Mt));
|
|
1970
2009
|
}
|
|
1971
2010
|
retryPendingDelivery(e) {
|
|
1972
2011
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
1973
2012
|
return;
|
|
1974
2013
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1975
|
-
if (s >=
|
|
2014
|
+
if (s >= ie) {
|
|
1976
2015
|
this.failPendingDelivery(e);
|
|
1977
2016
|
return;
|
|
1978
2017
|
}
|
|
1979
2018
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
1980
2019
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
1981
|
-
},
|
|
2020
|
+
}, oe(s, At));
|
|
1982
2021
|
}
|
|
1983
2022
|
failPendingDelivery(e) {
|
|
1984
2023
|
if (this.pendingClientMessageId !== e)
|
|
@@ -2014,7 +2053,7 @@ class Kt {
|
|
|
2014
2053
|
scheduleRunAckWatchdog(e) {
|
|
2015
2054
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
2016
2055
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
2017
|
-
},
|
|
2056
|
+
}, Mt);
|
|
2018
2057
|
}
|
|
2019
2058
|
recoverMissedRunAck(e) {
|
|
2020
2059
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (w("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -2025,7 +2064,7 @@ class Kt {
|
|
|
2025
2064
|
scheduleRunAckResyncRetry(e) {
|
|
2026
2065
|
this.clearRunAckResyncRetryTimer();
|
|
2027
2066
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
2028
|
-
s >=
|
|
2067
|
+
s >= ie || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
2029
2068
|
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({
|
|
2030
2069
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
2031
2070
|
isThinking: !0,
|
|
@@ -2038,8 +2077,8 @@ class Kt {
|
|
|
2038
2077
|
sessionId: this.state.sessionId,
|
|
2039
2078
|
clientMessageId: e,
|
|
2040
2079
|
automatic: !0
|
|
2041
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
2042
|
-
},
|
|
2080
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(Tt)));
|
|
2081
|
+
}, oe(s, At)));
|
|
2043
2082
|
}
|
|
2044
2083
|
clearRunAckResyncRetryTimer() {
|
|
2045
2084
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -2058,24 +2097,24 @@ class Kt {
|
|
|
2058
2097
|
reason: "missing_client_message_id"
|
|
2059
2098
|
}), this.setState({
|
|
2060
2099
|
messages: this.state.messages.filter(
|
|
2061
|
-
(r) => !
|
|
2100
|
+
(r) => !X(r)
|
|
2062
2101
|
),
|
|
2063
2102
|
isThinking: !1,
|
|
2064
2103
|
taskStatus: "failed",
|
|
2065
|
-
lastError:
|
|
2104
|
+
lastError: wt,
|
|
2066
2105
|
lastErrorCode: "run_recovery_exhausted"
|
|
2067
2106
|
}), this.clearThinkingWatchdog();
|
|
2068
2107
|
return;
|
|
2069
2108
|
}
|
|
2070
2109
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
2071
|
-
if (n >=
|
|
2110
|
+
if (n >= ie) {
|
|
2072
2111
|
w("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
2073
2112
|
sessionId: this.state.sessionId,
|
|
2074
2113
|
clientMessageId: e
|
|
2075
2114
|
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
2076
2115
|
isThinking: !1,
|
|
2077
2116
|
taskStatus: "failed",
|
|
2078
|
-
lastError:
|
|
2117
|
+
lastError: wt,
|
|
2079
2118
|
lastErrorCode: "connection_failed"
|
|
2080
2119
|
}), this.clearThinkingWatchdog());
|
|
2081
2120
|
return;
|
|
@@ -2085,7 +2124,7 @@ class Kt {
|
|
|
2085
2124
|
sessionId: this.state.sessionId,
|
|
2086
2125
|
clientMessageId: e,
|
|
2087
2126
|
resyncAttempts: s + 1
|
|
2088
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
2127
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(St);
|
|
2089
2128
|
return;
|
|
2090
2129
|
}
|
|
2091
2130
|
this.setState({
|
|
@@ -2103,7 +2142,7 @@ class Kt {
|
|
|
2103
2142
|
clientMessageId: e,
|
|
2104
2143
|
automatic: !0
|
|
2105
2144
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
2106
|
-
},
|
|
2145
|
+
}, oe(n)));
|
|
2107
2146
|
}
|
|
2108
2147
|
resyncThinkingSession() {
|
|
2109
2148
|
this.state.sessionId ? this.send({
|
|
@@ -2114,7 +2153,7 @@ class Kt {
|
|
|
2114
2153
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
2115
2154
|
}
|
|
2116
2155
|
async executeToolCall(e) {
|
|
2117
|
-
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 =
|
|
2156
|
+
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 = Q(
|
|
2118
2157
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
2119
2158
|
), o = e.rawInput;
|
|
2120
2159
|
if (!s || !n || !r)
|
|
@@ -2127,8 +2166,8 @@ class Kt {
|
|
|
2127
2166
|
callId: n,
|
|
2128
2167
|
toolName: r,
|
|
2129
2168
|
summary: i,
|
|
2130
|
-
rawInput:
|
|
2131
|
-
rawOutput:
|
|
2169
|
+
rawInput: q(o),
|
|
2170
|
+
rawOutput: q({
|
|
2132
2171
|
ok: !1,
|
|
2133
2172
|
toolName: r,
|
|
2134
2173
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -2143,7 +2182,7 @@ class Kt {
|
|
|
2143
2182
|
callId: n,
|
|
2144
2183
|
toolName: r,
|
|
2145
2184
|
summary: i,
|
|
2146
|
-
rawInput:
|
|
2185
|
+
rawInput: q(o),
|
|
2147
2186
|
rawOutput: {
|
|
2148
2187
|
ok: !1,
|
|
2149
2188
|
toolName: r,
|
|
@@ -2159,7 +2198,7 @@ class Kt {
|
|
|
2159
2198
|
callId: n,
|
|
2160
2199
|
toolName: r,
|
|
2161
2200
|
summary: i,
|
|
2162
|
-
rawInput:
|
|
2201
|
+
rawInput: q(o),
|
|
2163
2202
|
rawOutput: null
|
|
2164
2203
|
},
|
|
2165
2204
|
startedAtMs: Date.now(),
|
|
@@ -2169,11 +2208,11 @@ class Kt {
|
|
|
2169
2208
|
let c = null, d;
|
|
2170
2209
|
c = await this.executeRuntimeHelper(), d = await Ct(
|
|
2171
2210
|
o,
|
|
2172
|
-
|
|
2173
|
-
).catch((
|
|
2211
|
+
qn(e.runtimeContext, this.options.backendUrl)
|
|
2212
|
+
).catch((p) => ({
|
|
2174
2213
|
ok: !1,
|
|
2175
2214
|
exception: {
|
|
2176
|
-
message:
|
|
2215
|
+
message: p instanceof Error ? p.message : String(p)
|
|
2177
2216
|
}
|
|
2178
2217
|
})), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
2179
2218
|
type: "tool.result",
|
|
@@ -2181,8 +2220,8 @@ class Kt {
|
|
|
2181
2220
|
callId: n,
|
|
2182
2221
|
toolName: r,
|
|
2183
2222
|
summary: o.summary,
|
|
2184
|
-
rawInput:
|
|
2185
|
-
rawOutput:
|
|
2223
|
+
rawInput: q(o),
|
|
2224
|
+
rawOutput: q(tr(d, c))
|
|
2186
2225
|
}), Lt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
2187
2226
|
}
|
|
2188
2227
|
setToolMessageLoading(e, s) {
|
|
@@ -2292,7 +2331,7 @@ class Kt {
|
|
|
2292
2331
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2293
2332
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2294
2333
|
};
|
|
2295
|
-
this.state = o, Kr(this.options.clientId, this.state), this.emit("state", this.getState()),
|
|
2334
|
+
this.state = o, Kr(this.options.clientId, this.state), this.emit("state", this.getState()), He("state", this.state.status, {
|
|
2296
2335
|
status: this.state.status,
|
|
2297
2336
|
sessionId: this.state.sessionId,
|
|
2298
2337
|
messageCount: this.state.messages.length,
|
|
@@ -2314,7 +2353,7 @@ class Kt {
|
|
|
2314
2353
|
this.listeners[e]?.forEach((r) => r(s));
|
|
2315
2354
|
}
|
|
2316
2355
|
}
|
|
2317
|
-
const
|
|
2356
|
+
const je = /* @__PURE__ */ new WeakMap();
|
|
2318
2357
|
function Sn(t) {
|
|
2319
2358
|
const e = window.__plunoProductAgentNetworkCapture ?? wn();
|
|
2320
2359
|
return e.subscribers.add(t), () => {
|
|
@@ -2330,7 +2369,7 @@ function wn() {
|
|
|
2330
2369
|
}
|
|
2331
2370
|
});
|
|
2332
2371
|
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, u) {
|
|
2333
|
-
const
|
|
2372
|
+
const h = Date.now();
|
|
2334
2373
|
let g;
|
|
2335
2374
|
try {
|
|
2336
2375
|
g = s.call(this, f, u);
|
|
@@ -2339,23 +2378,23 @@ function wn() {
|
|
|
2339
2378
|
}
|
|
2340
2379
|
try {
|
|
2341
2380
|
const m = f instanceof Request ? f : null, C = ii(f, m), T = us(u?.headers ?? m?.headers);
|
|
2342
|
-
if (!
|
|
2381
|
+
if (!Y(C, T, u?.body)) {
|
|
2343
2382
|
const _ = {
|
|
2344
|
-
requestId:
|
|
2345
|
-
url: W(C,
|
|
2383
|
+
requestId: Ke("fetch"),
|
|
2384
|
+
url: W(C, $e),
|
|
2346
2385
|
method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
2347
2386
|
requestHeaders: T,
|
|
2348
2387
|
requestBody: xt(u?.body),
|
|
2349
2388
|
resourceType: "fetch",
|
|
2350
|
-
startedAt: new Date(
|
|
2389
|
+
startedAt: new Date(h).toISOString()
|
|
2351
2390
|
};
|
|
2352
2391
|
g.then(
|
|
2353
2392
|
(v) => {
|
|
2354
|
-
oi(v, _,
|
|
2393
|
+
oi(v, _, h, e).catch(() => {
|
|
2355
2394
|
e({
|
|
2356
2395
|
..._,
|
|
2357
2396
|
responseStatus: v.status,
|
|
2358
|
-
durationMs: Date.now() -
|
|
2397
|
+
durationMs: Date.now() - h
|
|
2359
2398
|
});
|
|
2360
2399
|
});
|
|
2361
2400
|
},
|
|
@@ -2363,7 +2402,7 @@ function wn() {
|
|
|
2363
2402
|
e({
|
|
2364
2403
|
..._,
|
|
2365
2404
|
errorText: W(v instanceof Error ? v.message : String(v)),
|
|
2366
|
-
durationMs: Date.now() -
|
|
2405
|
+
durationMs: Date.now() - h
|
|
2367
2406
|
});
|
|
2368
2407
|
}
|
|
2369
2408
|
);
|
|
@@ -2371,29 +2410,29 @@ function wn() {
|
|
|
2371
2410
|
} catch {
|
|
2372
2411
|
}
|
|
2373
2412
|
return g;
|
|
2374
|
-
}, a = function(f, u,
|
|
2375
|
-
const C = n.call(this, f, u,
|
|
2376
|
-
return
|
|
2377
|
-
requestId:
|
|
2413
|
+
}, a = function(f, u, h, g, m) {
|
|
2414
|
+
const C = n.call(this, f, u, h ?? !0, g ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
2415
|
+
return je.set(this, {
|
|
2416
|
+
requestId: Ke("xhr"),
|
|
2378
2417
|
method: String(f ?? "GET").toUpperCase(),
|
|
2379
|
-
url: W(T,
|
|
2418
|
+
url: W(T, $e),
|
|
2380
2419
|
requestHeaders: {},
|
|
2381
2420
|
startedAtMs: Date.now(),
|
|
2382
2421
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2383
|
-
excluded:
|
|
2422
|
+
excluded: Y(T)
|
|
2384
2423
|
}), C;
|
|
2385
2424
|
}, l = function(f, u) {
|
|
2386
|
-
const
|
|
2387
|
-
return g && Object.keys(g.requestHeaders).length <
|
|
2425
|
+
const h = r.call(this, f, u), g = je.get(this);
|
|
2426
|
+
return g && Object.keys(g.requestHeaders).length < it && (g.requestHeaders[f] = lt(f, u), g.excluded = g.excluded || Y(g.url, g.requestHeaders)), h;
|
|
2388
2427
|
}, c = function(f) {
|
|
2389
2428
|
try {
|
|
2390
|
-
const u =
|
|
2391
|
-
u && (u.excluded = u.excluded ||
|
|
2429
|
+
const u = je.get(this);
|
|
2430
|
+
u && (u.excluded = u.excluded || Y(u.url, u.requestHeaders, f), u.requestBody = xt(f), u.excluded || this.addEventListener(
|
|
2392
2431
|
"loadend",
|
|
2393
2432
|
() => {
|
|
2394
2433
|
queueMicrotask(() => {
|
|
2395
2434
|
try {
|
|
2396
|
-
const
|
|
2435
|
+
const h = hi(this.getAllResponseHeaders());
|
|
2397
2436
|
e({
|
|
2398
2437
|
requestId: u.requestId,
|
|
2399
2438
|
url: u.url,
|
|
@@ -2402,8 +2441,8 @@ function wn() {
|
|
|
2402
2441
|
requestBody: u.requestBody,
|
|
2403
2442
|
resourceType: "xhr",
|
|
2404
2443
|
responseStatus: this.status,
|
|
2405
|
-
responseHeaders:
|
|
2406
|
-
responseBody: li(this,
|
|
2444
|
+
responseHeaders: h,
|
|
2445
|
+
responseBody: li(this, h),
|
|
2407
2446
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2408
2447
|
startedAt: u.startedAt,
|
|
2409
2448
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -2440,16 +2479,16 @@ function wn() {
|
|
|
2440
2479
|
d = new PerformanceObserver((y) => {
|
|
2441
2480
|
for (const f of y.getEntries()) {
|
|
2442
2481
|
const u = f;
|
|
2443
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
2482
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || Y(u.name))
|
|
2444
2483
|
continue;
|
|
2445
|
-
const
|
|
2484
|
+
const h = performance.timeOrigin + u.startTime;
|
|
2446
2485
|
e({
|
|
2447
|
-
requestId:
|
|
2448
|
-
url: W(u.name,
|
|
2486
|
+
requestId: Ke("resource"),
|
|
2487
|
+
url: W(u.name, $e),
|
|
2449
2488
|
method: "GET",
|
|
2450
2489
|
resourceType: "resource",
|
|
2451
2490
|
responseStatus: u.responseStatus,
|
|
2452
|
-
startedAt: new Date(
|
|
2491
|
+
startedAt: new Date(h).toISOString(),
|
|
2453
2492
|
durationMs: u.duration
|
|
2454
2493
|
});
|
|
2455
2494
|
}
|
|
@@ -2460,7 +2499,7 @@ function wn() {
|
|
|
2460
2499
|
d.disconnect(), d = null;
|
|
2461
2500
|
}
|
|
2462
2501
|
}
|
|
2463
|
-
const
|
|
2502
|
+
const p = {
|
|
2464
2503
|
subscribers: t,
|
|
2465
2504
|
destroy: () => {
|
|
2466
2505
|
d?.disconnect();
|
|
@@ -2482,7 +2521,7 @@ function wn() {
|
|
|
2482
2521
|
}
|
|
2483
2522
|
}
|
|
2484
2523
|
};
|
|
2485
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
2524
|
+
return window.__plunoProductAgentNetworkCapture = p, p;
|
|
2486
2525
|
}
|
|
2487
2526
|
function w(t, e, s) {
|
|
2488
2527
|
if (typeof window > "u")
|
|
@@ -2495,17 +2534,17 @@ function w(t, e, s) {
|
|
|
2495
2534
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
2496
2535
|
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 }));
|
|
2497
2536
|
}
|
|
2498
|
-
function
|
|
2537
|
+
function kt(t) {
|
|
2499
2538
|
const e = typeof t == "function" ? t() : t;
|
|
2500
2539
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2501
2540
|
}
|
|
2502
2541
|
function Mn(t) {
|
|
2503
2542
|
return t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call";
|
|
2504
2543
|
}
|
|
2505
|
-
function
|
|
2544
|
+
function fe(t) {
|
|
2506
2545
|
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";
|
|
2507
2546
|
}
|
|
2508
|
-
function
|
|
2547
|
+
function K(t) {
|
|
2509
2548
|
if (typeof t.sessionId == "string")
|
|
2510
2549
|
return t.sessionId;
|
|
2511
2550
|
if (t.session && typeof t.session == "object") {
|
|
@@ -2532,7 +2571,7 @@ function En() {
|
|
|
2532
2571
|
};
|
|
2533
2572
|
}
|
|
2534
2573
|
function kn() {
|
|
2535
|
-
return Wt(globalThis, "getPageSnapshot", async () =>
|
|
2574
|
+
return Wt(globalThis, "getPageSnapshot", async () => ot());
|
|
2536
2575
|
}
|
|
2537
2576
|
function Cn() {
|
|
2538
2577
|
return Wt(globalThis, "pageImages", {
|
|
@@ -2563,7 +2602,7 @@ async function _n(t) {
|
|
|
2563
2602
|
ok: !0,
|
|
2564
2603
|
mimeType: t.type,
|
|
2565
2604
|
sizeBytes: t.size,
|
|
2566
|
-
dataUrl: await
|
|
2605
|
+
dataUrl: await On(t)
|
|
2567
2606
|
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Pn(t);
|
|
2568
2607
|
}
|
|
2569
2608
|
function Pn(t) {
|
|
@@ -2600,7 +2639,7 @@ function Dn(t) {
|
|
|
2600
2639
|
} catch {
|
|
2601
2640
|
}
|
|
2602
2641
|
}
|
|
2603
|
-
function
|
|
2642
|
+
function On(t) {
|
|
2604
2643
|
return new Promise((e, s) => {
|
|
2605
2644
|
const n = new FileReader();
|
|
2606
2645
|
n.onload = () => {
|
|
@@ -2628,8 +2667,8 @@ async function Ct(t, e) {
|
|
|
2628
2667
|
try {
|
|
2629
2668
|
const c = /* @__PURE__ */ Symbol("execute_code_timeout"), d = await Promise.race([
|
|
2630
2669
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
2631
|
-
new Promise((
|
|
2632
|
-
o = window.setTimeout(() =>
|
|
2670
|
+
new Promise((p) => {
|
|
2671
|
+
o = window.setTimeout(() => p(c), n);
|
|
2633
2672
|
})
|
|
2634
2673
|
]);
|
|
2635
2674
|
return d === c ? Ln(n) : {
|
|
@@ -2661,7 +2700,7 @@ async function Ct(t, e) {
|
|
|
2661
2700
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2662
2701
|
}
|
|
2663
2702
|
}
|
|
2664
|
-
function
|
|
2703
|
+
function qn(t, e) {
|
|
2665
2704
|
if (!t || typeof t != "object")
|
|
2666
2705
|
return;
|
|
2667
2706
|
const s = t.sandboxFilesToken;
|
|
@@ -2694,8 +2733,8 @@ function On(t, e) {
|
|
|
2694
2733
|
);
|
|
2695
2734
|
if (!l.ok)
|
|
2696
2735
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
2697
|
-
const c = await l.blob(),
|
|
2698
|
-
return new File([c],
|
|
2736
|
+
const c = await l.blob(), p = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
2737
|
+
return new File([c], p || a.split("/").pop() || "file", {
|
|
2699
2738
|
type: c.type
|
|
2700
2739
|
});
|
|
2701
2740
|
}
|
|
@@ -2757,17 +2796,17 @@ function $n() {
|
|
|
2757
2796
|
return {
|
|
2758
2797
|
pageUrl: location.href,
|
|
2759
2798
|
pageTitle: document.title,
|
|
2760
|
-
htmlContent:
|
|
2799
|
+
htmlContent: ot()
|
|
2761
2800
|
};
|
|
2762
2801
|
}
|
|
2763
2802
|
function jn(t) {
|
|
2764
|
-
return
|
|
2765
|
-
|
|
2803
|
+
return Se.add(t), ge || (ge = Fn()), () => {
|
|
2804
|
+
Se.delete(t), Se.size === 0 && (ge?.(), ge = null);
|
|
2766
2805
|
};
|
|
2767
2806
|
}
|
|
2768
2807
|
function Fn() {
|
|
2769
2808
|
const t = () => {
|
|
2770
|
-
for (const i of Array.from(
|
|
2809
|
+
for (const i of Array.from(Se))
|
|
2771
2810
|
i();
|
|
2772
2811
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2773
2812
|
const o = e(...i);
|
|
@@ -2780,38 +2819,38 @@ function Fn() {
|
|
|
2780
2819
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2781
2820
|
};
|
|
2782
2821
|
}
|
|
2783
|
-
function
|
|
2822
|
+
function me() {
|
|
2784
2823
|
return Jt()?.surface === "browser_extension_sdk_preview";
|
|
2785
2824
|
}
|
|
2786
|
-
function
|
|
2825
|
+
function ot() {
|
|
2787
2826
|
if (!document.body)
|
|
2788
2827
|
return "";
|
|
2789
|
-
const t = [], e = [], s = (
|
|
2790
|
-
const m =
|
|
2791
|
-
!m || e.includes(m) || (t.push([
|
|
2828
|
+
const t = [], e = [], s = (h, g) => {
|
|
2829
|
+
const m = Z(g);
|
|
2830
|
+
!m || e.includes(m) || (t.push([h, m]), e.push(m));
|
|
2792
2831
|
};
|
|
2793
2832
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2794
2833
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2795
|
-
(
|
|
2834
|
+
(h) => Gt(h) && !h.parentElement?.closest(n)
|
|
2796
2835
|
);
|
|
2797
|
-
for (const
|
|
2798
|
-
s("Active overlay",
|
|
2799
|
-
const i = zn(), o = i ?
|
|
2800
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2801
|
-
const a = t.map(([
|
|
2836
|
+
for (const h of r.slice(0, 3))
|
|
2837
|
+
s("Active overlay", Fe(le(h), e));
|
|
2838
|
+
const i = zn(), o = i ? Fe(le(i), e) : "";
|
|
2839
|
+
s("Main page content", o), s("Additional visible page text", Fe(le(document.body), e));
|
|
2840
|
+
const a = t.map(([h, g]) => `${h}:
|
|
2802
2841
|
${g}`).join(`
|
|
2803
2842
|
|
|
2804
2843
|
`).trim().slice(0, 12e3), l = Kn(r, i).trim(), c = `Simplified DOM outline:
|
|
2805
2844
|
`, d = `
|
|
2806
2845
|
|
|
2807
2846
|
Visible page text:
|
|
2808
|
-
`,
|
|
2847
|
+
`, p = 12e3 - c.length - d.length, y = Math.min(a.length, 7900), f = l.slice(0, p - y), u = a.slice(0, p - f.length);
|
|
2809
2848
|
return `${c}${f}${d}${u}`;
|
|
2810
2849
|
}
|
|
2811
2850
|
function le(t) {
|
|
2812
2851
|
return t.innerText ?? t.textContent ?? "";
|
|
2813
2852
|
}
|
|
2814
|
-
function
|
|
2853
|
+
function Z(t) {
|
|
2815
2854
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2816
2855
|
`).split(`
|
|
2817
2856
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2819,11 +2858,11 @@ function Q(t) {
|
|
|
2819
2858
|
|
|
2820
2859
|
`).trim();
|
|
2821
2860
|
}
|
|
2822
|
-
function
|
|
2823
|
-
let s =
|
|
2861
|
+
function Fe(t, e) {
|
|
2862
|
+
let s = Z(t);
|
|
2824
2863
|
for (const n of e)
|
|
2825
2864
|
s = s.replace(n, "");
|
|
2826
|
-
return
|
|
2865
|
+
return Z(s);
|
|
2827
2866
|
}
|
|
2828
2867
|
function Gt(t) {
|
|
2829
2868
|
const e = window.getComputedStyle(t);
|
|
@@ -2912,77 +2951,77 @@ function Kn(t, e) {
|
|
|
2912
2951
|
"data-test",
|
|
2913
2952
|
"data-qa",
|
|
2914
2953
|
"data-cy"
|
|
2915
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets:
|
|
2954
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = Gn(), y = new Set(t);
|
|
2916
2955
|
e && y.add(e);
|
|
2917
2956
|
let f = 0;
|
|
2918
2957
|
const u = (T) => {
|
|
2919
2958
|
const S = T.getAttribute("role");
|
|
2920
2959
|
return S && !o.has(S) ? S : "";
|
|
2921
|
-
},
|
|
2960
|
+
}, h = (T) => {
|
|
2922
2961
|
const S = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
|
|
2923
2962
|
return `${T.tagName.toLowerCase()}|${u(T)}|${S}`;
|
|
2924
2963
|
}, g = (T, S, _) => {
|
|
2925
|
-
const v = (R,
|
|
2926
|
-
const P = R.tagName.toLowerCase(), F = window.getComputedStyle(R),
|
|
2927
|
-
if (f >= 1e3 && !
|
|
2964
|
+
const v = (R, te) => {
|
|
2965
|
+
const P = R.tagName.toLowerCase(), F = window.getComputedStyle(R), J = d.has(R);
|
|
2966
|
+
if (f >= 1e3 && !J || _.has(R) || i.has(P) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || F.display === "none" || F.visibility === "hidden")
|
|
2928
2967
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2929
2968
|
f += 1;
|
|
2930
|
-
const
|
|
2969
|
+
const se = u(R), N = Xt(R), ue = a.has(se) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(P) || P === "a" && R.hasAttribute("href"), de = Array.from(R.children).filter((I) => I instanceof HTMLElement), z = /* @__PURE__ */ new Map();
|
|
2931
2970
|
for (const I of de) {
|
|
2932
|
-
const A =
|
|
2971
|
+
const A = h(I);
|
|
2933
2972
|
z.set(A, (z.get(A) ?? 0) + 1);
|
|
2934
2973
|
}
|
|
2935
2974
|
const x = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
|
|
2936
2975
|
for (const I of de) {
|
|
2937
|
-
const A =
|
|
2976
|
+
const A = h(I), j = E.get(A) ?? 0;
|
|
2938
2977
|
E.set(A, j + 1), (z.get(A) ?? 0) > 8 && j >= 6 && !d.has(I) && x.set(A, (x.get(A) ?? 0) + 1);
|
|
2939
2978
|
}
|
|
2940
|
-
const
|
|
2979
|
+
const O = /* @__PURE__ */ new Map(), ct = /* @__PURE__ */ new Set(), Ue = [], ut = [];
|
|
2941
2980
|
for (const I of de) {
|
|
2942
|
-
const A =
|
|
2943
|
-
if (
|
|
2944
|
-
|
|
2981
|
+
const A = h(I), j = z.get(A) ?? 0, pt = O.get(A) ?? 0;
|
|
2982
|
+
if (O.set(A, pt + 1), j > 8 && pt >= 6 && !d.has(I)) {
|
|
2983
|
+
ct.has(A) || (Ue.push([`… ${x.get(A) ?? 0} similar siblings omitted`]), ct.add(A));
|
|
2945
2984
|
continue;
|
|
2946
2985
|
}
|
|
2947
|
-
const
|
|
2948
|
-
|
|
2986
|
+
const gt = v(I, te);
|
|
2987
|
+
ut.push(gt), Ue.push(gt.lines);
|
|
2949
2988
|
}
|
|
2950
|
-
const
|
|
2989
|
+
const ve = [];
|
|
2951
2990
|
if (R.shadowRoot)
|
|
2952
2991
|
for (const I of Array.from(R.shadowRoot.children))
|
|
2953
|
-
I instanceof HTMLElement &&
|
|
2954
|
-
const
|
|
2955
|
-
[N, ...
|
|
2956
|
-
).slice(0, 180), Is = R.hasAttribute("contenteditable") && (N.length > 0 || !R.querySelector("[contenteditable]")),
|
|
2957
|
-
if (
|
|
2958
|
-
const I =
|
|
2959
|
-
|
|
2992
|
+
I instanceof HTMLElement && ve.push(v(I, te + 1));
|
|
2993
|
+
const he = [...ut, ...ve], De = N.length > 0 || ue || he.some((I) => I.hasUsefulContent), dt = Z(
|
|
2994
|
+
[N, ...he.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
2995
|
+
).slice(0, 180), Is = R.hasAttribute("contenteditable") && (N.length > 0 || !R.querySelector("[contenteditable]")), ht = c.some((I) => R.hasAttribute(I)) || !!se || Is, Oe = (R.getClientRects().length > 0 || F.display === "contents") && (s.has(P) || ht || J) && (De || J) && (!r.has(P) || De || ht || J), qe = Oe ? 1 : 0, ne = [];
|
|
2996
|
+
if (Oe) {
|
|
2997
|
+
const I = he.some((j) => j.containsTextElement), A = n.has(P) && !I ? dt : N;
|
|
2998
|
+
ne.push(Vt(R, l, o, A.slice(0, 180)));
|
|
2960
2999
|
}
|
|
2961
|
-
for (const I of
|
|
2962
|
-
|
|
2963
|
-
const
|
|
2964
|
-
if (
|
|
2965
|
-
const I =
|
|
2966
|
-
|
|
3000
|
+
for (const I of Ue)
|
|
3001
|
+
ne.push(...ye(I, qe));
|
|
3002
|
+
const Le = ve.flatMap((I) => I.lines);
|
|
3003
|
+
if (Le.length > 0) {
|
|
3004
|
+
const I = Le.slice(0, 20);
|
|
3005
|
+
Le.length > I.length && I.push("… shadow DOM omitted");
|
|
2967
3006
|
const A = P.includes("tooltip") || P.includes("popper") || P.includes("loader");
|
|
2968
|
-
if (
|
|
2969
|
-
const j =
|
|
2970
|
-
|
|
3007
|
+
if (te < 2 && !A) {
|
|
3008
|
+
const j = Oe ? "#shadow-root" : `${P} #shadow-root`;
|
|
3009
|
+
ne.push(...ye([j, ...ye(I, 1)], qe));
|
|
2971
3010
|
} else
|
|
2972
|
-
|
|
3011
|
+
ne.push(...ye(I, qe));
|
|
2973
3012
|
}
|
|
2974
3013
|
return {
|
|
2975
|
-
lines:
|
|
2976
|
-
hasUsefulContent:
|
|
2977
|
-
textPreview:
|
|
2978
|
-
containsTextElement: n.has(P) ||
|
|
3014
|
+
lines: ne,
|
|
3015
|
+
hasUsefulContent: De,
|
|
3016
|
+
textPreview: dt,
|
|
3017
|
+
containsTextElement: n.has(P) || he.some((I) => I.containsTextElement)
|
|
2979
3018
|
};
|
|
2980
3019
|
};
|
|
2981
3020
|
return [`--- ${S} ---`, ...v(T, 0).lines].join(`
|
|
2982
3021
|
`);
|
|
2983
|
-
}, m = [], C =
|
|
3022
|
+
}, m = [], C = Z(window.getSelection()?.toString() ?? "");
|
|
2984
3023
|
C && m.push(`--- selected text ---
|
|
2985
|
-
${JSON.stringify(C)}`),
|
|
3024
|
+
${JSON.stringify(C)}`), p.length > 0 && m.push(Vn(p, s, l, o));
|
|
2986
3025
|
for (const T of t.slice(0, 3))
|
|
2987
3026
|
m.push(g(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2988
3027
|
if (e && m.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -3019,11 +3058,11 @@ function Gn() {
|
|
|
3019
3058
|
return;
|
|
3020
3059
|
const d = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
3021
3060
|
d.add(l), e.set(a, d);
|
|
3022
|
-
let
|
|
3023
|
-
for (;
|
|
3024
|
-
t.add(
|
|
3025
|
-
const y =
|
|
3026
|
-
|
|
3061
|
+
let p = a;
|
|
3062
|
+
for (; p; ) {
|
|
3063
|
+
t.add(p);
|
|
3064
|
+
const y = p.getRootNode();
|
|
3065
|
+
p = p.parentElement ?? (y instanceof ShadowRoot && y.host instanceof HTMLElement ? y.host : null);
|
|
3027
3066
|
}
|
|
3028
3067
|
};
|
|
3029
3068
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -3043,8 +3082,8 @@ function Gn() {
|
|
|
3043
3082
|
for (let a = 0; a < o.length; a += 1) {
|
|
3044
3083
|
const l = o[a];
|
|
3045
3084
|
for (const [c, d] of i)
|
|
3046
|
-
for (const
|
|
3047
|
-
s(
|
|
3085
|
+
for (const p of Array.from(l.querySelectorAll(c)))
|
|
3086
|
+
s(p, d);
|
|
3048
3087
|
for (const c of Array.from(l.querySelectorAll("*")))
|
|
3049
3088
|
c.shadowRoot && o.push(c.shadowRoot);
|
|
3050
3089
|
}
|
|
@@ -3061,14 +3100,14 @@ function Vn(t, e, s, n) {
|
|
|
3061
3100
|
for (; a; ) {
|
|
3062
3101
|
const d = a.tagName.toLowerCase();
|
|
3063
3102
|
(a === i.element || e.has(d) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
3064
|
-
const
|
|
3065
|
-
a = a.parentElement ?? (
|
|
3103
|
+
const p = a.getRootNode();
|
|
3104
|
+
a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
|
|
3066
3105
|
}
|
|
3067
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d,
|
|
3106
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d, p) => Vt(
|
|
3068
3107
|
d,
|
|
3069
3108
|
s,
|
|
3070
3109
|
n,
|
|
3071
|
-
|
|
3110
|
+
p === l.length - 1 ? Xt(d).slice(0, 180) : ""
|
|
3072
3111
|
));
|
|
3073
3112
|
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
3074
3113
|
}
|
|
@@ -3078,14 +3117,14 @@ function Vn(t, e, s, n) {
|
|
|
3078
3117
|
function bt(t) {
|
|
3079
3118
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
3080
3119
|
}
|
|
3081
|
-
function
|
|
3120
|
+
function ye(t, e) {
|
|
3082
3121
|
if (e === 0)
|
|
3083
3122
|
return t;
|
|
3084
3123
|
const s = " ".repeat(e);
|
|
3085
3124
|
return t.map((n) => `${s}${n}`);
|
|
3086
3125
|
}
|
|
3087
3126
|
function Xt(t) {
|
|
3088
|
-
return
|
|
3127
|
+
return Z(
|
|
3089
3128
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
3090
3129
|
);
|
|
3091
3130
|
}
|
|
@@ -3093,8 +3132,8 @@ function Xn(t) {
|
|
|
3093
3132
|
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);
|
|
3094
3133
|
}
|
|
3095
3134
|
function Jt() {
|
|
3096
|
-
const t = document.querySelector(
|
|
3097
|
-
if (!(t ?? document.querySelector(
|
|
3135
|
+
const t = document.querySelector(ft);
|
|
3136
|
+
if (!(t ?? document.querySelector(Ve)))
|
|
3098
3137
|
return;
|
|
3099
3138
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
3100
3139
|
return {
|
|
@@ -3103,7 +3142,7 @@ function Jt() {
|
|
|
3103
3142
|
selectors: [
|
|
3104
3143
|
{
|
|
3105
3144
|
name: "widget_host",
|
|
3106
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
3145
|
+
selector: s === "browser_extension_sdk_preview" ? ft : Ve,
|
|
3107
3146
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
3108
3147
|
},
|
|
3109
3148
|
{
|
|
@@ -3206,7 +3245,7 @@ function rr(t) {
|
|
|
3206
3245
|
} : null;
|
|
3207
3246
|
}
|
|
3208
3247
|
function Pt(t, e) {
|
|
3209
|
-
return Array.isArray(t) ?
|
|
3248
|
+
return Array.isArray(t) ? Ze(
|
|
3210
3249
|
t.map((s) => Yt(s, e)).filter((s) => s !== null)
|
|
3211
3250
|
) : [];
|
|
3212
3251
|
}
|
|
@@ -3246,7 +3285,7 @@ function Yt(t, e) {
|
|
|
3246
3285
|
role: i,
|
|
3247
3286
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
3248
3287
|
content: ks(
|
|
3249
|
-
|
|
3288
|
+
pr(r.content),
|
|
3250
3289
|
e
|
|
3251
3290
|
),
|
|
3252
3291
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3290,7 +3329,8 @@ function Yt(t, e) {
|
|
|
3290
3329
|
dataType: "scheduled_check_in",
|
|
3291
3330
|
toolName: $t,
|
|
3292
3331
|
callId: ae(r) ?? void 0,
|
|
3293
|
-
|
|
3332
|
+
scheduledCheckInId: o.id ?? void 0,
|
|
3333
|
+
scheduledCheckInAt: o.dueAt
|
|
3294
3334
|
};
|
|
3295
3335
|
const a = ar(r.output), l = lr(r.output);
|
|
3296
3336
|
return a ? {
|
|
@@ -3401,22 +3441,22 @@ function ur(t) {
|
|
|
3401
3441
|
}
|
|
3402
3442
|
function dr(t) {
|
|
3403
3443
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3404
|
-
return
|
|
3444
|
+
return Q(t.summary);
|
|
3405
3445
|
if (typeof t.arguments == "string")
|
|
3406
3446
|
try {
|
|
3407
3447
|
const e = JSON.parse(t.arguments);
|
|
3408
3448
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
3409
|
-
return
|
|
3449
|
+
return Q(e.summary);
|
|
3410
3450
|
} catch {
|
|
3411
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3451
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? Q(t.name) : "🛠️ Run tool";
|
|
3412
3452
|
}
|
|
3413
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3453
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? Q(t.name) : "🛠️ Run tool";
|
|
3414
3454
|
}
|
|
3415
|
-
function
|
|
3455
|
+
function Q(t) {
|
|
3416
3456
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3417
3457
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3418
3458
|
}
|
|
3419
|
-
function
|
|
3459
|
+
function hr(t) {
|
|
3420
3460
|
if (t == null)
|
|
3421
3461
|
return t;
|
|
3422
3462
|
if (typeof t != "object")
|
|
@@ -3438,7 +3478,7 @@ function ae(t) {
|
|
|
3438
3478
|
function D(t) {
|
|
3439
3479
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
3440
3480
|
}
|
|
3441
|
-
function
|
|
3481
|
+
function pr(t) {
|
|
3442
3482
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
3443
3483
|
if (!e || typeof e != "object")
|
|
3444
3484
|
return "";
|
|
@@ -3446,7 +3486,7 @@ function hr(t) {
|
|
|
3446
3486
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
3447
3487
|
}).filter(Boolean).join("") : "";
|
|
3448
3488
|
}
|
|
3449
|
-
function
|
|
3489
|
+
function Je(t, e) {
|
|
3450
3490
|
const s = es(t, e), n = Tr(
|
|
3451
3491
|
gr(
|
|
3452
3492
|
Rr(t, e),
|
|
@@ -3455,11 +3495,11 @@ function Xe(t, e) {
|
|
|
3455
3495
|
s
|
|
3456
3496
|
), r = n.findIndex((o) => o.id === s.id);
|
|
3457
3497
|
if (r === -1)
|
|
3458
|
-
return
|
|
3498
|
+
return Ze(
|
|
3459
3499
|
[...n, s]
|
|
3460
3500
|
);
|
|
3461
3501
|
const i = [...n];
|
|
3462
|
-
return i[r] = s,
|
|
3502
|
+
return i[r] = s, Ze(i);
|
|
3463
3503
|
}
|
|
3464
3504
|
function gr(t, e) {
|
|
3465
3505
|
const s = e.assistantDraftItemId;
|
|
@@ -3467,7 +3507,7 @@ function gr(t, e) {
|
|
|
3467
3507
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
3468
3508
|
) : t;
|
|
3469
3509
|
}
|
|
3470
|
-
function
|
|
3510
|
+
function ze(t, e, s) {
|
|
3471
3511
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3472
3512
|
}
|
|
3473
3513
|
function fr(t, e, s, n) {
|
|
@@ -3492,7 +3532,7 @@ function mr(t, e) {
|
|
|
3492
3532
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3493
3533
|
);
|
|
3494
3534
|
if (s === -1)
|
|
3495
|
-
return
|
|
3535
|
+
return Je(t, e);
|
|
3496
3536
|
const n = [...t];
|
|
3497
3537
|
return n[s] = {
|
|
3498
3538
|
...n[s],
|
|
@@ -3516,7 +3556,7 @@ function Ir(t) {
|
|
|
3516
3556
|
return !e || !s ? null : {
|
|
3517
3557
|
id: `transient-activity:${e}`,
|
|
3518
3558
|
role: "tool",
|
|
3519
|
-
content:
|
|
3559
|
+
content: Q(
|
|
3520
3560
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3521
3561
|
),
|
|
3522
3562
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3563,7 +3603,7 @@ function wr(t, e) {
|
|
|
3563
3603
|
return Number.isNaN(n) ? 0 : n;
|
|
3564
3604
|
}
|
|
3565
3605
|
function Zt(t) {
|
|
3566
|
-
const e =
|
|
3606
|
+
const e = V(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3567
3607
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3568
3608
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3569
3609
|
];
|
|
@@ -3574,7 +3614,7 @@ function Zt(t) {
|
|
|
3574
3614
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3575
3615
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3576
3616
|
...t.runId ? { runId: t.runId } : {},
|
|
3577
|
-
isOptimistic:
|
|
3617
|
+
isOptimistic: _e(t),
|
|
3578
3618
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3579
3619
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3580
3620
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
@@ -3584,14 +3624,14 @@ function es(t, e) {
|
|
|
3584
3624
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3585
3625
|
return e;
|
|
3586
3626
|
const s = t.find(
|
|
3587
|
-
(o) => o.role === "user" && (o.id === e.id ||
|
|
3627
|
+
(o) => o.role === "user" && (o.id === e.id || _e(o) && ts(o, e))
|
|
3588
3628
|
);
|
|
3589
3629
|
if (!s?.attachments?.length)
|
|
3590
3630
|
return e;
|
|
3591
3631
|
const n = e.attachments.map((o) => {
|
|
3592
3632
|
const a = Mr(s.attachments ?? [], o);
|
|
3593
3633
|
return a ? Ar(o, a) : o;
|
|
3594
|
-
}), r = { ...e, attachments: n }, i =
|
|
3634
|
+
}), r = { ...e, attachments: n }, i = V(e);
|
|
3595
3635
|
return i && Object.defineProperty(r, "clientMessageId", {
|
|
3596
3636
|
value: i,
|
|
3597
3637
|
enumerable: !1
|
|
@@ -3608,7 +3648,7 @@ function Rr(t, e) {
|
|
|
3608
3648
|
if (e.role !== "user")
|
|
3609
3649
|
return t;
|
|
3610
3650
|
const s = t.findIndex(
|
|
3611
|
-
(r) =>
|
|
3651
|
+
(r) => _e(r) && ts(r, e)
|
|
3612
3652
|
);
|
|
3613
3653
|
if (s === -1)
|
|
3614
3654
|
return t;
|
|
@@ -3616,13 +3656,13 @@ function Rr(t, e) {
|
|
|
3616
3656
|
return n.splice(s, 1), n;
|
|
3617
3657
|
}
|
|
3618
3658
|
function ts(t, e) {
|
|
3619
|
-
const s =
|
|
3659
|
+
const s = V(t), n = V(e);
|
|
3620
3660
|
return s && n ? s === n : t.content === e.content;
|
|
3621
3661
|
}
|
|
3622
|
-
function
|
|
3662
|
+
function _e(t) {
|
|
3623
3663
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3624
3664
|
}
|
|
3625
|
-
function
|
|
3665
|
+
function V(t) {
|
|
3626
3666
|
const e = t.clientMessageId;
|
|
3627
3667
|
if (e)
|
|
3628
3668
|
return e;
|
|
@@ -3637,7 +3677,7 @@ function Ut(t) {
|
|
|
3637
3677
|
return !1;
|
|
3638
3678
|
const s = t[e].id;
|
|
3639
3679
|
if (t.some(
|
|
3640
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3680
|
+
(r) => r.respondsToUserMessageId === s && Ae(r)
|
|
3641
3681
|
))
|
|
3642
3682
|
return !0;
|
|
3643
3683
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
@@ -3658,7 +3698,7 @@ function Ut(t) {
|
|
|
3658
3698
|
function Er(t, e, s) {
|
|
3659
3699
|
const n = new Set(
|
|
3660
3700
|
t.filter(
|
|
3661
|
-
(r) => r.role === "user" && e !== null &&
|
|
3701
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3662
3702
|
).map((r) => r.id)
|
|
3663
3703
|
);
|
|
3664
3704
|
return t.some((r, i) => {
|
|
@@ -3686,14 +3726,14 @@ function kr(t) {
|
|
|
3686
3726
|
}
|
|
3687
3727
|
function ss(t) {
|
|
3688
3728
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3689
|
-
if (t[e].role === "user" && !
|
|
3729
|
+
if (t[e].role === "user" && !_e(t[e]))
|
|
3690
3730
|
return e;
|
|
3691
3731
|
return null;
|
|
3692
3732
|
}
|
|
3693
|
-
function
|
|
3733
|
+
function Ae(t) {
|
|
3694
3734
|
return H(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3695
3735
|
}
|
|
3696
|
-
function
|
|
3736
|
+
function ee(t) {
|
|
3697
3737
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
3698
3738
|
const s = t[e];
|
|
3699
3739
|
if (!s || typeof s != "object")
|
|
@@ -3708,7 +3748,7 @@ function Z(t) {
|
|
|
3708
3748
|
return null;
|
|
3709
3749
|
}
|
|
3710
3750
|
function Cr(t) {
|
|
3711
|
-
const e =
|
|
3751
|
+
const e = ee(t);
|
|
3712
3752
|
if (e === null)
|
|
3713
3753
|
return null;
|
|
3714
3754
|
const n = U(t[e])?.page;
|
|
@@ -3723,14 +3763,14 @@ function U(t) {
|
|
|
3723
3763
|
const e = t.data;
|
|
3724
3764
|
return e && typeof e == "object" ? e : null;
|
|
3725
3765
|
}
|
|
3726
|
-
function
|
|
3766
|
+
function Re(t) {
|
|
3727
3767
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3728
3768
|
}
|
|
3729
3769
|
function vt(t) {
|
|
3730
3770
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3731
3771
|
}
|
|
3732
3772
|
function br(t, e) {
|
|
3733
|
-
const s =
|
|
3773
|
+
const s = ee(e);
|
|
3734
3774
|
if (s === null)
|
|
3735
3775
|
return !1;
|
|
3736
3776
|
const n = e[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -3738,11 +3778,11 @@ function br(t, e) {
|
|
|
3738
3778
|
return !1;
|
|
3739
3779
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3740
3780
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3741
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3742
|
-
) : t.slice(i + 1).some(
|
|
3781
|
+
(o) => o.respondsToUserMessageId === r && Ae(o)
|
|
3782
|
+
) : t.slice(i + 1).some(Ae);
|
|
3743
3783
|
}
|
|
3744
|
-
function
|
|
3745
|
-
const e =
|
|
3784
|
+
function Ye(t) {
|
|
3785
|
+
const e = ee(t);
|
|
3746
3786
|
if (e === null)
|
|
3747
3787
|
return null;
|
|
3748
3788
|
const s = t[e];
|
|
@@ -3755,7 +3795,7 @@ function Je(t) {
|
|
|
3755
3795
|
return typeof r == "string" ? r : null;
|
|
3756
3796
|
}
|
|
3757
3797
|
function _r(t) {
|
|
3758
|
-
const e =
|
|
3798
|
+
const e = ee(t);
|
|
3759
3799
|
if (e === null)
|
|
3760
3800
|
return null;
|
|
3761
3801
|
for (let s = t.length - 1; s > e; s -= 1) {
|
|
@@ -3769,13 +3809,13 @@ function _r(t) {
|
|
|
3769
3809
|
if (i.type === "message" && i.role === "assistant")
|
|
3770
3810
|
return null;
|
|
3771
3811
|
if (i.type === "run_error")
|
|
3772
|
-
return i.retryable !== !0 ? null :
|
|
3812
|
+
return i.retryable !== !0 ? null : Qe(t, i) ?? Ye(t);
|
|
3773
3813
|
if (i.type === "run_status")
|
|
3774
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3814
|
+
return i.status === "interrupted" && i.retryable === !0 ? Qe(t, i) ?? Ye(t) : null;
|
|
3775
3815
|
}
|
|
3776
3816
|
return null;
|
|
3777
3817
|
}
|
|
3778
|
-
function
|
|
3818
|
+
function Qe(t, e) {
|
|
3779
3819
|
if (typeof e.clientMessageId == "string")
|
|
3780
3820
|
return e.clientMessageId;
|
|
3781
3821
|
const s = L(e);
|
|
@@ -3801,7 +3841,7 @@ function Dt(t, e, s, n, r, i) {
|
|
|
3801
3841
|
if (!e || !vr(t))
|
|
3802
3842
|
return !1;
|
|
3803
3843
|
const o = t;
|
|
3804
|
-
if (
|
|
3844
|
+
if (Re(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3805
3845
|
return !1;
|
|
3806
3846
|
const a = L(o);
|
|
3807
3847
|
return n !== null ? a !== null ? a === n : r !== null && k(o) === r && i === n : r === null || k(o) === r;
|
|
@@ -3835,41 +3875,41 @@ function Dr(t) {
|
|
|
3835
3875
|
const e = t;
|
|
3836
3876
|
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";
|
|
3837
3877
|
}
|
|
3838
|
-
function
|
|
3839
|
-
return t.filter((e, s) =>
|
|
3878
|
+
function Ze(t) {
|
|
3879
|
+
return t.filter((e, s) => X(e) ? !Fr(t, s) && !rs(t, s) && !$r(t, s) && !jr(t, s) : Or(e) ? e.retryable === !0 && Hr(t, s) ? !1 : !Wr(t, s) : !0);
|
|
3840
3880
|
}
|
|
3841
|
-
function
|
|
3881
|
+
function Or(t) {
|
|
3842
3882
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3843
3883
|
}
|
|
3844
|
-
function
|
|
3884
|
+
function X(t) {
|
|
3845
3885
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3846
3886
|
}
|
|
3847
|
-
function
|
|
3887
|
+
function qr(t, e, s, n) {
|
|
3848
3888
|
const r = t.findIndex(
|
|
3849
|
-
(l, c) =>
|
|
3889
|
+
(l, c) => X(l) && !rs(t, c)
|
|
3850
3890
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3851
3891
|
(l) => l.role === "user" && l.id === o
|
|
3852
3892
|
) : null;
|
|
3853
3893
|
return {
|
|
3854
|
-
clientMessageId: a ?
|
|
3894
|
+
clientMessageId: a ? V(a) : o ? null : n,
|
|
3855
3895
|
respondsToUserMessageId: o,
|
|
3856
3896
|
runId: s ?? i?.runId ?? null
|
|
3857
3897
|
};
|
|
3858
3898
|
}
|
|
3859
|
-
function
|
|
3899
|
+
function we(t) {
|
|
3860
3900
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3861
3901
|
}
|
|
3862
3902
|
function Lr(t, e) {
|
|
3863
|
-
return H(e) ? "completed" :
|
|
3903
|
+
return H(e) ? "completed" : we(t) ? "stopped" : !Re(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
|
|
3864
3904
|
}
|
|
3865
|
-
function
|
|
3905
|
+
function Ot(t, e, s) {
|
|
3866
3906
|
const n = new Set(
|
|
3867
3907
|
t.filter(
|
|
3868
|
-
(r) => r.role === "user" && e !== null &&
|
|
3908
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3869
3909
|
).map((r) => r.id)
|
|
3870
3910
|
);
|
|
3871
3911
|
return t.filter(
|
|
3872
|
-
(r) => !
|
|
3912
|
+
(r) => !X(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3873
3913
|
);
|
|
3874
3914
|
}
|
|
3875
3915
|
function rs(t, e) {
|
|
@@ -3894,17 +3934,17 @@ function Nr(t, e, s) {
|
|
|
3894
3934
|
}
|
|
3895
3935
|
function xr(t, e) {
|
|
3896
3936
|
const s = [...t].reverse().find(
|
|
3897
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
3937
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && qt(n) && !Br(
|
|
3898
3938
|
t,
|
|
3899
3939
|
n.respondsToUserMessageId
|
|
3900
3940
|
)
|
|
3901
3941
|
)?.respondsToUserMessageId;
|
|
3902
3942
|
return s ? t.map(
|
|
3903
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3943
|
+
(n) => n.respondsToUserMessageId === s && qt(n) ? { ...n, steered: !0 } : n
|
|
3904
3944
|
) : t;
|
|
3905
3945
|
}
|
|
3906
|
-
function
|
|
3907
|
-
return t.role === "tool" ||
|
|
3946
|
+
function qt(t) {
|
|
3947
|
+
return t.role === "tool" || X(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3908
3948
|
}
|
|
3909
3949
|
function Br(t, e) {
|
|
3910
3950
|
return t.some(
|
|
@@ -3928,7 +3968,7 @@ function Hr(t, e) {
|
|
|
3928
3968
|
const r = t[n];
|
|
3929
3969
|
if (r.role === "user")
|
|
3930
3970
|
return !1;
|
|
3931
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3971
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || X(r)))
|
|
3932
3972
|
return !0;
|
|
3933
3973
|
}
|
|
3934
3974
|
return !1;
|
|
@@ -3948,7 +3988,7 @@ function jr(t, e) {
|
|
|
3948
3988
|
function Fr(t, e) {
|
|
3949
3989
|
const s = t[e];
|
|
3950
3990
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3951
|
-
if (
|
|
3991
|
+
if (X(t[n]) && ce(s, t[n]))
|
|
3952
3992
|
return !0;
|
|
3953
3993
|
return !1;
|
|
3954
3994
|
}
|
|
@@ -3993,24 +4033,24 @@ function Kr(t, e) {
|
|
|
3993
4033
|
}
|
|
3994
4034
|
function Gr(t) {
|
|
3995
4035
|
try {
|
|
3996
|
-
const e = window.localStorage.getItem(`${
|
|
4036
|
+
const e = window.localStorage.getItem(`${Xe}${t}`);
|
|
3997
4037
|
if (!e)
|
|
3998
4038
|
return [];
|
|
3999
4039
|
const s = JSON.parse(e);
|
|
4000
|
-
return Array.isArray(s) ? s.filter(
|
|
4040
|
+
return Array.isArray(s) ? s.filter(at) : [];
|
|
4001
4041
|
} catch {
|
|
4002
4042
|
return [];
|
|
4003
4043
|
}
|
|
4004
4044
|
}
|
|
4005
|
-
function
|
|
4045
|
+
function G(t, e) {
|
|
4006
4046
|
try {
|
|
4007
|
-
const s = e.filter(
|
|
4047
|
+
const s = e.filter(at);
|
|
4008
4048
|
if (s.length === 0) {
|
|
4009
|
-
window.localStorage.removeItem(`${
|
|
4049
|
+
window.localStorage.removeItem(`${Xe}${t}`);
|
|
4010
4050
|
return;
|
|
4011
4051
|
}
|
|
4012
4052
|
window.localStorage.setItem(
|
|
4013
|
-
`${
|
|
4053
|
+
`${Xe}${t}`,
|
|
4014
4054
|
JSON.stringify(s.slice(-25))
|
|
4015
4055
|
);
|
|
4016
4056
|
} catch {
|
|
@@ -4019,7 +4059,7 @@ function K(t, e) {
|
|
|
4019
4059
|
}
|
|
4020
4060
|
function os(t, e) {
|
|
4021
4061
|
try {
|
|
4022
|
-
const s = `${
|
|
4062
|
+
const s = `${be}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
4023
4063
|
...o,
|
|
4024
4064
|
storedAt: Date.now(),
|
|
4025
4065
|
unloadUrl: n,
|
|
@@ -4035,7 +4075,7 @@ function os(t, e) {
|
|
|
4035
4075
|
}
|
|
4036
4076
|
function Lt(t, e) {
|
|
4037
4077
|
try {
|
|
4038
|
-
if (window.sessionStorage.getItem(`${
|
|
4078
|
+
if (window.sessionStorage.getItem(`${be}${t}`) === null)
|
|
4039
4079
|
return;
|
|
4040
4080
|
} catch {
|
|
4041
4081
|
return;
|
|
@@ -4044,7 +4084,7 @@ function Lt(t, e) {
|
|
|
4044
4084
|
}
|
|
4045
4085
|
function Vr(t) {
|
|
4046
4086
|
try {
|
|
4047
|
-
const e = `${
|
|
4087
|
+
const e = `${be}${t}`, s = window.sessionStorage.getItem(e);
|
|
4048
4088
|
if (window.sessionStorage.removeItem(e), !s)
|
|
4049
4089
|
return [];
|
|
4050
4090
|
const n = JSON.parse(s);
|
|
@@ -4079,7 +4119,7 @@ function Jr(t) {
|
|
|
4079
4119
|
if (!t || typeof t != "object")
|
|
4080
4120
|
return !1;
|
|
4081
4121
|
const e = t, s = e.event;
|
|
4082
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
4122
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && at(s) && s.type === "tool.result";
|
|
4083
4123
|
}
|
|
4084
4124
|
function Yr(t, e) {
|
|
4085
4125
|
const s = new Set(
|
|
@@ -4092,12 +4132,12 @@ function Yr(t, e) {
|
|
|
4092
4132
|
}
|
|
4093
4133
|
function Qr(t) {
|
|
4094
4134
|
try {
|
|
4095
|
-
window.sessionStorage.removeItem(`${
|
|
4135
|
+
window.sessionStorage.removeItem(`${be}${t}`);
|
|
4096
4136
|
} catch {
|
|
4097
4137
|
return;
|
|
4098
4138
|
}
|
|
4099
4139
|
}
|
|
4100
|
-
function
|
|
4140
|
+
function at(t) {
|
|
4101
4141
|
if (!t || typeof t != "object")
|
|
4102
4142
|
return !1;
|
|
4103
4143
|
const e = t;
|
|
@@ -4126,19 +4166,19 @@ function ls(t, e) {
|
|
|
4126
4166
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
4127
4167
|
} : t;
|
|
4128
4168
|
}
|
|
4129
|
-
function
|
|
4169
|
+
function et(t) {
|
|
4130
4170
|
return t.type || ti(t.name) || "application/octet-stream";
|
|
4131
4171
|
}
|
|
4132
4172
|
function Zr(t) {
|
|
4133
4173
|
cs({
|
|
4134
4174
|
name: t.name,
|
|
4135
|
-
mimeType:
|
|
4175
|
+
mimeType: et(t),
|
|
4136
4176
|
sizeBytes: t.size
|
|
4137
4177
|
});
|
|
4138
4178
|
}
|
|
4139
4179
|
function cs(t) {
|
|
4140
4180
|
const e = ei(t.name), s = t.mimeType.trim().toLowerCase();
|
|
4141
|
-
if (!
|
|
4181
|
+
if (!pn.has(`${e}:${s}`))
|
|
4142
4182
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
4143
4183
|
if (t.sizeBytes <= 0 || t.sizeBytes >= jt)
|
|
4144
4184
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
@@ -4166,19 +4206,20 @@ function si(t) {
|
|
|
4166
4206
|
respondsToUserMessageId: typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : void 0,
|
|
4167
4207
|
...typeof e.runId == "string" ? { runId: e.runId } : {},
|
|
4168
4208
|
dataType: typeof e.dataType == "string" ? e.dataType : void 0,
|
|
4209
|
+
scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
|
|
4169
4210
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
4170
4211
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
4171
|
-
attachments: as(e.attachments)?.map(
|
|
4212
|
+
attachments: as(e.attachments)?.map(Ee),
|
|
4172
4213
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
4173
4214
|
};
|
|
4174
4215
|
}
|
|
4175
4216
|
function ni(t) {
|
|
4176
4217
|
return t.attachments?.length ? {
|
|
4177
4218
|
...t,
|
|
4178
|
-
attachments: t.attachments.map(
|
|
4219
|
+
attachments: t.attachments.map(Ee)
|
|
4179
4220
|
} : t;
|
|
4180
4221
|
}
|
|
4181
|
-
function
|
|
4222
|
+
function Ee(t) {
|
|
4182
4223
|
const {
|
|
4183
4224
|
dataUrl: e,
|
|
4184
4225
|
objectUrl: s,
|
|
@@ -4204,15 +4245,15 @@ function us(t) {
|
|
|
4204
4245
|
const e = {};
|
|
4205
4246
|
try {
|
|
4206
4247
|
new Headers(t).forEach((s, n) => {
|
|
4207
|
-
Object.keys(e).length <
|
|
4248
|
+
Object.keys(e).length < it && (e[n] = lt(n, s));
|
|
4208
4249
|
});
|
|
4209
4250
|
} catch {
|
|
4210
4251
|
return {};
|
|
4211
4252
|
}
|
|
4212
4253
|
return e;
|
|
4213
4254
|
}
|
|
4214
|
-
function
|
|
4215
|
-
return ms(t) ?
|
|
4255
|
+
function lt(t, e) {
|
|
4256
|
+
return ms(t) ? Pe : W(Ce(e), gn);
|
|
4216
4257
|
}
|
|
4217
4258
|
function ii(t, e) {
|
|
4218
4259
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
@@ -4247,7 +4288,7 @@ async function ai(t) {
|
|
|
4247
4288
|
const { done: l, value: c } = a;
|
|
4248
4289
|
if (l)
|
|
4249
4290
|
return W(i + r.decode());
|
|
4250
|
-
const d =
|
|
4291
|
+
const d = rt - o;
|
|
4251
4292
|
if (c.byteLength > d)
|
|
4252
4293
|
return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${W(i)}... [truncated]`;
|
|
4253
4294
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
@@ -4272,7 +4313,7 @@ function xt(t) {
|
|
|
4272
4313
|
return W(t);
|
|
4273
4314
|
}
|
|
4274
4315
|
function ci(t) {
|
|
4275
|
-
return
|
|
4316
|
+
return q({
|
|
4276
4317
|
...t,
|
|
4277
4318
|
requestBody: Bt(t.requestBody),
|
|
4278
4319
|
responseBody: Bt(t.responseBody)
|
|
@@ -4283,20 +4324,20 @@ function Bt(t) {
|
|
|
4283
4324
|
return t;
|
|
4284
4325
|
const e = t.trim();
|
|
4285
4326
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4286
|
-
return
|
|
4327
|
+
return Ce(t);
|
|
4287
4328
|
try {
|
|
4288
|
-
return JSON.stringify(
|
|
4329
|
+
return JSON.stringify(q(JSON.parse(t)));
|
|
4289
4330
|
} catch {
|
|
4290
|
-
return
|
|
4331
|
+
return Ce(t);
|
|
4291
4332
|
}
|
|
4292
4333
|
}
|
|
4293
4334
|
function ds(t) {
|
|
4294
4335
|
if (!t)
|
|
4295
4336
|
return !1;
|
|
4296
4337
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4297
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
4338
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= rt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4298
4339
|
}
|
|
4299
|
-
function
|
|
4340
|
+
function Y(t, e = {}, s) {
|
|
4300
4341
|
if (di(s))
|
|
4301
4342
|
return !0;
|
|
4302
4343
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
@@ -4313,7 +4354,7 @@ function J(t, e = {}, s) {
|
|
|
4313
4354
|
}
|
|
4314
4355
|
}
|
|
4315
4356
|
function ui(t, e) {
|
|
4316
|
-
if (
|
|
4357
|
+
if (Y(t))
|
|
4317
4358
|
return !0;
|
|
4318
4359
|
try {
|
|
4319
4360
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -4325,50 +4366,50 @@ function ui(t, e) {
|
|
|
4325
4366
|
function di(t) {
|
|
4326
4367
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4327
4368
|
}
|
|
4328
|
-
function
|
|
4369
|
+
function hi(t) {
|
|
4329
4370
|
const e = {};
|
|
4330
4371
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4331
4372
|
const n = s.indexOf(":");
|
|
4332
4373
|
if (n <= 0)
|
|
4333
4374
|
continue;
|
|
4334
|
-
if (Object.keys(e).length >=
|
|
4375
|
+
if (Object.keys(e).length >= it)
|
|
4335
4376
|
break;
|
|
4336
4377
|
const r = s.slice(0, n).trim();
|
|
4337
|
-
e[r] =
|
|
4378
|
+
e[r] = lt(r, s.slice(n + 1).trim());
|
|
4338
4379
|
}
|
|
4339
4380
|
return e;
|
|
4340
4381
|
}
|
|
4341
|
-
function W(t, e =
|
|
4382
|
+
function W(t, e = rt) {
|
|
4342
4383
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4343
4384
|
}
|
|
4344
|
-
function
|
|
4385
|
+
function Ke(t) {
|
|
4345
4386
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4346
4387
|
}
|
|
4347
|
-
class
|
|
4388
|
+
class Me extends Error {
|
|
4348
4389
|
constructor(e, s) {
|
|
4349
4390
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4350
4391
|
}
|
|
4351
4392
|
status;
|
|
4352
4393
|
}
|
|
4353
|
-
async function
|
|
4394
|
+
async function Ie(t, e) {
|
|
4354
4395
|
let s = null;
|
|
4355
|
-
for (let n = 0; n <
|
|
4396
|
+
for (let n = 0; n < Et; n += 1)
|
|
4356
4397
|
try {
|
|
4357
4398
|
return await t();
|
|
4358
4399
|
} catch (r) {
|
|
4359
|
-
if (s = r, n >=
|
|
4400
|
+
if (s = r, n >= Et - 1 || !gi(r))
|
|
4360
4401
|
throw r;
|
|
4361
|
-
await
|
|
4402
|
+
await pi(n);
|
|
4362
4403
|
}
|
|
4363
4404
|
throw s instanceof Error ? s : new Error(e);
|
|
4364
4405
|
}
|
|
4365
|
-
function
|
|
4406
|
+
function pi(t) {
|
|
4366
4407
|
return new Promise((e) => {
|
|
4367
|
-
window.setTimeout(e,
|
|
4408
|
+
window.setTimeout(e, hn[t] ?? 0);
|
|
4368
4409
|
});
|
|
4369
4410
|
}
|
|
4370
4411
|
function gi(t) {
|
|
4371
|
-
return t instanceof
|
|
4412
|
+
return t instanceof Me ? fi(t.status) : t instanceof TypeError;
|
|
4372
4413
|
}
|
|
4373
4414
|
function fi(t) {
|
|
4374
4415
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
@@ -4376,13 +4417,13 @@ function fi(t) {
|
|
|
4376
4417
|
function mi(t) {
|
|
4377
4418
|
return t === 401 || t === 403;
|
|
4378
4419
|
}
|
|
4379
|
-
const
|
|
4380
|
-
function
|
|
4381
|
-
return
|
|
4420
|
+
const Pe = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", yi = "[REDACTED_SIGNED_URL]", Ii = 20, Ti = /^(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, hs = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ps = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, gs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, fs = /\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, Si = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, wi = /\bhttps?:\/\/[^\s"'<>]+/gi, Mi = /[),.;\]]+$/;
|
|
4421
|
+
function q(t) {
|
|
4422
|
+
return ke(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4382
4423
|
}
|
|
4383
|
-
function
|
|
4424
|
+
function ke(t, e, s) {
|
|
4384
4425
|
if (typeof t == "string")
|
|
4385
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4426
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Ce(t);
|
|
4386
4427
|
if (t === null || typeof t != "object")
|
|
4387
4428
|
return t;
|
|
4388
4429
|
if (e >= Ii)
|
|
@@ -4390,10 +4431,10 @@ function Ee(t, e, s) {
|
|
|
4390
4431
|
if (s.has(t))
|
|
4391
4432
|
return "[REDACTED_CIRCULAR]";
|
|
4392
4433
|
if (s.add(t), Array.isArray(t))
|
|
4393
|
-
return t.map((r) =>
|
|
4434
|
+
return t.map((r) => ke(r, e + 1, s));
|
|
4394
4435
|
const n = {};
|
|
4395
4436
|
for (const [r, i] of Object.entries(t))
|
|
4396
|
-
r === "pageContent" ? n[r] = i : ms(r) ? n[r] =
|
|
4437
|
+
r === "pageContent" ? n[r] = i : ms(r) ? n[r] = Pe : n[r] = r.toLowerCase() === "url" ? Ai(i) : ke(i, e + 1, s);
|
|
4397
4438
|
return n;
|
|
4398
4439
|
}
|
|
4399
4440
|
function ms(t) {
|
|
@@ -4401,7 +4442,7 @@ function ms(t) {
|
|
|
4401
4442
|
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");
|
|
4402
4443
|
}
|
|
4403
4444
|
function Ai(t) {
|
|
4404
|
-
return typeof t == "string" ? ys(t) :
|
|
4445
|
+
return typeof t == "string" ? ys(t) : ke(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4405
4446
|
}
|
|
4406
4447
|
function ys(t) {
|
|
4407
4448
|
try {
|
|
@@ -4413,19 +4454,19 @@ function ys(t) {
|
|
|
4413
4454
|
return Ri(t);
|
|
4414
4455
|
}
|
|
4415
4456
|
}
|
|
4416
|
-
function
|
|
4417
|
-
return t.replace(Si, yi).replace(wi, Ei).replace(
|
|
4457
|
+
function Ce(t) {
|
|
4458
|
+
return t.replace(Si, yi).replace(wi, Ei).replace(hs, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(gs, $).replace(fs, (e, s) => `${s}: ${Pe}`);
|
|
4418
4459
|
}
|
|
4419
4460
|
function Ri(t) {
|
|
4420
|
-
return t.replace(
|
|
4461
|
+
return t.replace(hs, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(gs, $).replace(fs, (e, s) => `${s}: ${Pe}`);
|
|
4421
4462
|
}
|
|
4422
4463
|
function Ei(t) {
|
|
4423
4464
|
const e = t.match(Mi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4424
4465
|
return `${ys(s)}${e}`;
|
|
4425
4466
|
}
|
|
4426
4467
|
export {
|
|
4427
|
-
|
|
4428
|
-
|
|
4468
|
+
ft as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4469
|
+
Ve as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4429
4470
|
Xs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4430
4471
|
Vs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4431
4472
|
Js as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|