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