@pluno/product-agent-web 0.1.169 → 0.1.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -0
- package/dist/product-agent-sdk.js +517 -473
- package/dist/product-agent-widget.js +3304 -3185
- package/dist/taskPageTitle.d.ts +23 -0
- package/dist/turnStatusLabel.d.ts +3 -0
- package/dist/widget.d.ts +6 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const gs = "pluno-product-agent-attachments";
|
|
2
|
-
const
|
|
2
|
+
const He = "files";
|
|
3
3
|
async function fs(t) {
|
|
4
4
|
const e = await Ve();
|
|
5
5
|
await Is(e, "readwrite", (s) => s.put(t));
|
|
@@ -27,7 +27,7 @@ function Ve() {
|
|
|
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(gs, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(He, { 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
|
});
|
|
@@ -37,7 +37,7 @@ async function Is(t, e, s) {
|
|
|
37
37
|
}
|
|
38
38
|
function Je(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(He, e), o = i.objectStore(He);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
s(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -118,7 +118,7 @@ function Rs(t, e, s) {
|
|
|
118
118
|
for (const u of t) {
|
|
119
119
|
const d = s(u);
|
|
120
120
|
let g = o.get(d.id);
|
|
121
|
-
if (d.isOptimistic && d.optimisticKey ? g = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? g = l.get(d.assistantDraftKey) : d.isActivity && (g = d.activityKeys?.map((
|
|
121
|
+
if (d.isOptimistic && d.optimisticKey ? g = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? g = l.get(d.assistantDraftKey) : d.isActivity && (g = d.activityKeys?.map((k) => c.get(k)).find((k) => k !== void 0) ?? g), g && !I.has(g)) {
|
|
122
122
|
f.push(g), I.add(g);
|
|
123
123
|
continue;
|
|
124
124
|
}
|
|
@@ -135,11 +135,11 @@ function Es(t, e, s, n) {
|
|
|
135
135
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
const
|
|
139
|
-
let
|
|
140
|
-
const
|
|
138
|
+
const De = "pluno.productAgent.transportId", ks = "pluno.productAgent.transportIdentity", ve = "pluno.productAgent.transportIdentity.event", Cs = 50, _s = globalThis.setTimeout.bind(globalThis);
|
|
139
|
+
let ne = null;
|
|
140
|
+
const fe = /* @__PURE__ */ new Set(), Oe = /* @__PURE__ */ new Map();
|
|
141
141
|
async function bs(t = xt()) {
|
|
142
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
142
|
+
const e = t.randomUUID(), s = t.storage.getItem(De);
|
|
143
143
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
144
144
|
const o = t.channel.subscribe((l) => {
|
|
145
145
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -157,14 +157,14 @@ async function bs(t = xt()) {
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
if (!s)
|
|
160
|
-
t.storage.setItem(
|
|
160
|
+
t.storage.setItem(De, n), r = !0;
|
|
161
161
|
else
|
|
162
162
|
for (; ; ) {
|
|
163
163
|
if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
|
|
164
164
|
r = !0;
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
167
|
+
n = t.randomUUID(), t.storage.setItem(De, n);
|
|
168
168
|
}
|
|
169
169
|
let a = !1;
|
|
170
170
|
return {
|
|
@@ -175,26 +175,26 @@ async function bs(t = xt()) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
async function Ps() {
|
|
178
|
-
|
|
178
|
+
ne || (ne = bs(xt()), ne.then((n) => {
|
|
179
179
|
const r = (i) => {
|
|
180
|
-
i.persisted || (n.release(),
|
|
180
|
+
i.persisted || (n.release(), ne = null, fe.clear(), window.removeEventListener("pagehide", r));
|
|
181
181
|
};
|
|
182
182
|
window.addEventListener("pagehide", r);
|
|
183
183
|
}));
|
|
184
|
-
const t = await
|
|
185
|
-
|
|
184
|
+
const t = await ne, e = Us();
|
|
185
|
+
fe.add(e);
|
|
186
186
|
let s = !1;
|
|
187
187
|
return {
|
|
188
188
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
189
189
|
transportId: e === 0 ? t.transportId : `${t.transportId}.${e}`,
|
|
190
190
|
release: () => {
|
|
191
|
-
s || (s = !0,
|
|
191
|
+
s || (s = !0, fe.delete(e));
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
function Us() {
|
|
196
196
|
let t = 0;
|
|
197
|
-
for (;
|
|
197
|
+
for (; fe.has(t); )
|
|
198
198
|
t += 1;
|
|
199
199
|
return t;
|
|
200
200
|
}
|
|
@@ -203,20 +203,20 @@ function xt() {
|
|
|
203
203
|
storage: Ds(),
|
|
204
204
|
channel: vs(),
|
|
205
205
|
randomUUID: () => crypto.randomUUID(),
|
|
206
|
-
settle: () => new Promise((t) => _s(t,
|
|
206
|
+
settle: () => new Promise((t) => _s(t, Cs))
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
function Ds() {
|
|
210
210
|
return {
|
|
211
211
|
getItem: (t) => {
|
|
212
212
|
try {
|
|
213
|
-
return window.sessionStorage?.getItem(t) ??
|
|
213
|
+
return window.sessionStorage?.getItem(t) ?? Oe.get(t) ?? null;
|
|
214
214
|
} catch {
|
|
215
|
-
return
|
|
215
|
+
return Oe.get(t) ?? null;
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
setItem: (t, e) => {
|
|
219
|
-
|
|
219
|
+
Oe.set(t, e);
|
|
220
220
|
try {
|
|
221
221
|
window.sessionStorage?.setItem(t, e);
|
|
222
222
|
} catch {
|
|
@@ -226,7 +226,7 @@ function Ds() {
|
|
|
226
226
|
}
|
|
227
227
|
function vs() {
|
|
228
228
|
if (typeof BroadcastChannel < "u") {
|
|
229
|
-
const t = new BroadcastChannel(
|
|
229
|
+
const t = new BroadcastChannel(ks);
|
|
230
230
|
return {
|
|
231
231
|
postMessage: (e) => t.postMessage(e),
|
|
232
232
|
subscribe: (e) => {
|
|
@@ -240,7 +240,7 @@ function vs() {
|
|
|
240
240
|
}
|
|
241
241
|
function Os() {
|
|
242
242
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
243
|
-
if (s.key !==
|
|
243
|
+
if (s.key !== ve || !s.newValue)
|
|
244
244
|
return;
|
|
245
245
|
const n = JSON.parse(s.newValue);
|
|
246
246
|
for (const r of t)
|
|
@@ -249,9 +249,9 @@ function Os() {
|
|
|
249
249
|
return window.addEventListener("storage", e), {
|
|
250
250
|
postMessage: (s) => {
|
|
251
251
|
window.localStorage.setItem(
|
|
252
|
-
|
|
252
|
+
ve,
|
|
253
253
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
254
|
-
), window.localStorage.removeItem(
|
|
254
|
+
), window.localStorage.removeItem(ve);
|
|
255
255
|
},
|
|
256
256
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
257
257
|
close: () => {
|
|
@@ -260,7 +260,7 @@ function Os() {
|
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
const Bt = "schedule_follow_up";
|
|
263
|
-
function
|
|
263
|
+
function Ls(t) {
|
|
264
264
|
let e = t;
|
|
265
265
|
if (typeof e == "string")
|
|
266
266
|
try {
|
|
@@ -273,7 +273,7 @@ function qs(t) {
|
|
|
273
273
|
const s = e;
|
|
274
274
|
return s.ok !== !0 || s.toolName !== Bt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
275
275
|
}
|
|
276
|
-
const
|
|
276
|
+
const qs = globalThis.fetch.bind(globalThis), $e = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ns = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', xs = ".pluno-pa-widget__panel", Bs = ".pluno-pa-widget__timeline", ht = `${$e}[data-pluno-sdk-preview-channel]`;
|
|
277
277
|
let Ws = 0;
|
|
278
278
|
function pt(t) {
|
|
279
279
|
const e = {};
|
|
@@ -313,7 +313,7 @@ function pt(t) {
|
|
|
313
313
|
}
|
|
314
314
|
return e;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function Le(t, e, s) {
|
|
317
317
|
if (typeof window > "u")
|
|
318
318
|
return;
|
|
319
319
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -332,19 +332,19 @@ function ve(t, e, s) {
|
|
|
332
332
|
};
|
|
333
333
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
334
334
|
}
|
|
335
|
-
const Hs = "https://app.pluno.ai", $s = "gpt-5.6-terra", js = 2e4, Fs = 1e4, zs = 1e4, Ks = 1e4, Gs = 1e4, Xs = 3e3, Vs = 3e4, Js = 1e3, gt = 3e4, ft = 0.2, mt = 6e4, yt = 15e3,
|
|
335
|
+
const Hs = "https://app.pluno.ai", $s = "gpt-5.6-terra", js = 2e4, Fs = 1e4, zs = 1e4, Ks = 1e4, Gs = 1e4, Xs = 3e3, Vs = 3e4, Js = 1e3, gt = 3e4, ft = 0.2, mt = 6e4, yt = 15e3, re = 8, It = "Browser connection was interrupted.", Tt = 15e3, Ys = "Pluno could not send this message. Try it again.", St = 2e3, Qs = 1e3, Zs = 100, wt = 8e3, en = 8e3, Mt = 3, tn = [300, 1e3], Wt = 50 * 1024 * 1024, sn = /* @__PURE__ */ new Set([
|
|
336
336
|
".jpeg:image/jpeg",
|
|
337
337
|
".jpg:image/jpeg",
|
|
338
338
|
".pdf:application/pdf",
|
|
339
339
|
".png:image/png",
|
|
340
340
|
".webp:image/webp"
|
|
341
|
-
]),
|
|
342
|
-
function
|
|
341
|
+
]), yi = ".pdf,.png,.jpg,.jpeg,.webp", Qe = 64e3, qe = 4e3, Ze = 30, nn = 2e3, rn = 1e3, Ht = "Image is too large for model vision input.", on = 100, $t = "pluno.productAgent.state.", je = "pluno.productAgent.pendingEvents.", Ae = "pluno.productAgent.activeToolCalls.", an = 100;
|
|
342
|
+
function ie(t, e = 0) {
|
|
343
343
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
344
344
|
return Math.max(e, s);
|
|
345
345
|
}
|
|
346
|
-
const
|
|
347
|
-
let
|
|
346
|
+
const me = /* @__PURE__ */ new Set();
|
|
347
|
+
let ce = null;
|
|
348
348
|
function ln(t, e = Math.random) {
|
|
349
349
|
const s = Math.min(gt, Js * 2 ** t), n = 1 - ft + e() * ft * 2;
|
|
350
350
|
return Math.min(gt, Math.round(s * n));
|
|
@@ -373,7 +373,7 @@ class jt {
|
|
|
373
373
|
...this.state,
|
|
374
374
|
...n,
|
|
375
375
|
messages: n.messages.filter(
|
|
376
|
-
(i) => !
|
|
376
|
+
(i) => !F(i)
|
|
377
377
|
),
|
|
378
378
|
status: "idle",
|
|
379
379
|
user: null,
|
|
@@ -385,16 +385,17 @@ class jt {
|
|
|
385
385
|
pendingMessageStatus: null,
|
|
386
386
|
turnPhase: null,
|
|
387
387
|
isThinking: !1,
|
|
388
|
+
taskStatus: null,
|
|
388
389
|
isRetrying: !1,
|
|
389
390
|
lastError: null
|
|
390
|
-
}), this.queuedClientEvents =
|
|
391
|
-
|
|
392
|
-
|
|
391
|
+
}), this.queuedClientEvents = $r(
|
|
392
|
+
xr(e.clientId),
|
|
393
|
+
Br(e.clientId)
|
|
393
394
|
);
|
|
394
395
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
395
396
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
396
397
|
);
|
|
397
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"),
|
|
398
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), G(e.clientId, this.queuedClientEvents);
|
|
398
399
|
}
|
|
399
400
|
options;
|
|
400
401
|
listeners = {};
|
|
@@ -414,6 +415,7 @@ class jt {
|
|
|
414
415
|
networkBatchTimer = null;
|
|
415
416
|
queuedNetworkEvents = [];
|
|
416
417
|
queuedClientEvents = [];
|
|
418
|
+
pendingWidgetLifecycleEvents = [];
|
|
417
419
|
pendingPassiveWarmupEvent = null;
|
|
418
420
|
pendingComposerWarmup = null;
|
|
419
421
|
activeComposerWarmupId = null;
|
|
@@ -489,6 +491,7 @@ class jt {
|
|
|
489
491
|
pendingMessageStatus: null,
|
|
490
492
|
turnPhase: null,
|
|
491
493
|
isThinking: !1,
|
|
494
|
+
taskStatus: null,
|
|
492
495
|
isRetrying: !1,
|
|
493
496
|
lastError: null,
|
|
494
497
|
lastErrorCode: null,
|
|
@@ -563,7 +566,7 @@ class jt {
|
|
|
563
566
|
const i = $n(r?.detail?.data);
|
|
564
567
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
565
568
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
566
|
-
) && (this.queuedClientEvents.push(i),
|
|
569
|
+
) && (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();
|
|
567
570
|
}), n.addEventListener("close", (r) => {
|
|
568
571
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (A("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
569
572
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -593,18 +596,18 @@ class jt {
|
|
|
593
596
|
}
|
|
594
597
|
}
|
|
595
598
|
disconnect() {
|
|
596
|
-
this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
599
|
+
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;
|
|
597
600
|
}
|
|
598
601
|
destroy() {
|
|
599
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
602
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), jr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
600
603
|
for (const e of Object.values(this.listeners))
|
|
601
604
|
e?.clear();
|
|
602
605
|
}
|
|
603
606
|
warmup(e = "panel_open") {
|
|
604
|
-
const s =
|
|
607
|
+
const s = b(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
|
|
605
608
|
type: "runtime.warmup",
|
|
606
609
|
reason: e,
|
|
607
|
-
...e === "composer_input" ? { warmupId: r?.event.warmupId ??
|
|
610
|
+
...e === "composer_input" ? { warmupId: r?.event.warmupId ?? j() } : {},
|
|
608
611
|
entrySurface: this.options.entrySurface,
|
|
609
612
|
sessionId: this.state.sessionId ?? void 0,
|
|
610
613
|
page: s
|
|
@@ -617,10 +620,25 @@ class jt {
|
|
|
617
620
|
r || (this.clearPendingComposerWarmup(), this.pendingComposerWarmup = { event: i, scope: n, retryAttempt: 0, acknowledged: !1 }, this.activeComposerWarmupId = i.warmupId ?? null, this.activeComposerWarmupScope = n), this.flushPendingComposerWarmup();
|
|
618
621
|
} else this.sendNow(i) || (this.pendingPassiveWarmupEvent = i);
|
|
619
622
|
}
|
|
623
|
+
recordWidgetLifecycle(e, s) {
|
|
624
|
+
const n = {
|
|
625
|
+
type: "runtime.widget_lifecycle",
|
|
626
|
+
event: {
|
|
627
|
+
id: crypto.randomUUID(),
|
|
628
|
+
action: e,
|
|
629
|
+
trigger: s,
|
|
630
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
631
|
+
entrySurface: this.options.entrySurface,
|
|
632
|
+
...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
|
|
633
|
+
pageOrigin: b().origin
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
this.authenticatedSocket === this.socket && this.sendNow(n) || (this.pendingWidgetLifecycleEvents.push(n), this.pendingWidgetLifecycleEvents.length > 20 && this.pendingWidgetLifecycleEvents.splice(0, this.pendingWidgetLifecycleEvents.length - 20));
|
|
637
|
+
}
|
|
620
638
|
async sendMessage(e, s = {}) {
|
|
621
639
|
const n = e.trim(), r = s.attachments ?? [];
|
|
622
640
|
if (this.options.productVariant === "customer_embedded" && (r.forEach(rs), r.reduce(
|
|
623
|
-
(
|
|
641
|
+
(w, U) => w + U.sizeBytes,
|
|
624
642
|
0
|
|
625
643
|
) > Wt))
|
|
626
644
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
@@ -629,13 +647,13 @@ class jt {
|
|
|
629
647
|
return null;
|
|
630
648
|
if (this.pendingClientMessageId)
|
|
631
649
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
632
|
-
const o =
|
|
650
|
+
const o = b(), a = s.clientMessageId ?? j(), l = {
|
|
633
651
|
id: `local-${a}`,
|
|
634
652
|
role: "user",
|
|
635
653
|
content: n,
|
|
636
654
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
637
655
|
...r.length > 0 ? { attachments: r } : {}
|
|
638
|
-
}, c = this.state.messages.some((
|
|
656
|
+
}, c = this.state.messages.some((m) => m.id === l.id || m.clientMessageId === a), h = this.state.isThinking, p = this.state.taskStatus, I = this.state.pendingMessageStatus, f = this.state.turnPhase, u = this.state.messages, d = c ? this.state.messages : [...this.state.messages, l], g = {
|
|
639
657
|
assistantDraft: this.state.assistantDraft,
|
|
640
658
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
641
659
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -644,7 +662,7 @@ class jt {
|
|
|
644
662
|
lastError: this.state.lastError
|
|
645
663
|
};
|
|
646
664
|
this.setState({
|
|
647
|
-
messages:
|
|
665
|
+
messages: d,
|
|
648
666
|
...h ? {} : {
|
|
649
667
|
assistantDraft: "",
|
|
650
668
|
assistantDraftItemId: null,
|
|
@@ -653,34 +671,36 @@ class jt {
|
|
|
653
671
|
assistantDraftRunId: null
|
|
654
672
|
},
|
|
655
673
|
pendingMessageStatus: "sending",
|
|
656
|
-
turnPhase: h ?
|
|
674
|
+
turnPhase: h ? f : "sending",
|
|
657
675
|
isThinking: h,
|
|
676
|
+
taskStatus: "working",
|
|
658
677
|
isRetrying: !1,
|
|
659
678
|
lastError: null
|
|
660
679
|
}), c || this.emit("message", l);
|
|
661
680
|
try {
|
|
662
|
-
const
|
|
663
|
-
for (const
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
|
|
681
|
+
const m = [];
|
|
682
|
+
for (const w of i) {
|
|
683
|
+
const U = w.id ? this.attachmentFiles.get(w.id) : void 0;
|
|
684
|
+
if (w.sandboxPath || w.storageKey) {
|
|
685
|
+
m.push(w);
|
|
667
686
|
continue;
|
|
668
687
|
}
|
|
669
|
-
if (!
|
|
670
|
-
throw new Error(`Attachment bytes are unavailable for ${
|
|
671
|
-
|
|
688
|
+
if (!U)
|
|
689
|
+
throw new Error(`Attachment bytes are unavailable for ${w.name}`);
|
|
690
|
+
m.push(await this.uploadAttachmentForMessage({ file: U, attachment: w }));
|
|
672
691
|
}
|
|
673
|
-
i =
|
|
674
|
-
} catch (
|
|
692
|
+
i = m;
|
|
693
|
+
} catch (m) {
|
|
675
694
|
throw this.setState({
|
|
676
|
-
...c ? {} : { messages:
|
|
677
|
-
...h ? {} : { ...
|
|
678
|
-
pendingMessageStatus:
|
|
679
|
-
turnPhase:
|
|
680
|
-
|
|
695
|
+
...c ? {} : { messages: u },
|
|
696
|
+
...h ? {} : { ...g, isThinking: !1 },
|
|
697
|
+
pendingMessageStatus: I,
|
|
698
|
+
turnPhase: f,
|
|
699
|
+
taskStatus: p
|
|
700
|
+
}), m;
|
|
681
701
|
}
|
|
682
702
|
this.retryableClientMessageId = null;
|
|
683
|
-
const
|
|
703
|
+
const T = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, k = {
|
|
684
704
|
type: "chat.user_message",
|
|
685
705
|
sessionId: this.state.sessionId ?? void 0,
|
|
686
706
|
clientMessageId: a,
|
|
@@ -688,13 +708,13 @@ class jt {
|
|
|
688
708
|
invocation: Pn(s.invocation ?? s.initiatedBy),
|
|
689
709
|
entrySurface: this.options.entrySurface,
|
|
690
710
|
content: n,
|
|
691
|
-
pageContent:
|
|
711
|
+
pageContent: T && et() || void 0,
|
|
692
712
|
attachments: i.length > 0 ? i : void 0,
|
|
693
713
|
page: o,
|
|
694
714
|
model: this.options.model,
|
|
695
715
|
metadata: At(this.options.metadata)
|
|
696
716
|
};
|
|
697
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent =
|
|
717
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = k, this.send(k), this.schedulePendingDeliveryAck(a), a;
|
|
698
718
|
}
|
|
699
719
|
retryLastMessage() {
|
|
700
720
|
const e = this.state.sessionId, s = this.retryableClientMessageId;
|
|
@@ -712,8 +732,8 @@ class jt {
|
|
|
712
732
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
|
|
713
733
|
}
|
|
714
734
|
createLocalAttachment(e) {
|
|
715
|
-
this.options.productVariant === "customer_embedded" &&
|
|
716
|
-
const s =
|
|
735
|
+
this.options.productVariant === "customer_embedded" && Fr(e);
|
|
736
|
+
const s = j(), n = {
|
|
717
737
|
id: s,
|
|
718
738
|
name: e.name || "attachment",
|
|
719
739
|
mimeType: Xe(e),
|
|
@@ -727,7 +747,7 @@ class jt {
|
|
|
727
747
|
mimeType: n.mimeType,
|
|
728
748
|
sizeBytes: n.sizeBytes,
|
|
729
749
|
blob: e,
|
|
730
|
-
origin:
|
|
750
|
+
origin: b().origin,
|
|
731
751
|
sessionId: this.state.sessionId ?? void 0,
|
|
732
752
|
createdAt: r,
|
|
733
753
|
lastUsedAt: r
|
|
@@ -758,30 +778,30 @@ class jt {
|
|
|
758
778
|
name: e.name || "attachment",
|
|
759
779
|
mimeType: r,
|
|
760
780
|
sizeBytes: e.size,
|
|
761
|
-
page:
|
|
781
|
+
page: b(),
|
|
762
782
|
model: this.options.model,
|
|
763
783
|
metadata: At(this.options.metadata),
|
|
764
784
|
entrySurface: this.options.entrySurface
|
|
765
785
|
};
|
|
766
786
|
let o;
|
|
767
787
|
if (this.options.persistAttachmentUpload)
|
|
768
|
-
o = await
|
|
788
|
+
o = await ge(
|
|
769
789
|
() => this.options.persistAttachmentUpload(i, e),
|
|
770
790
|
"Failed to upload attachment"
|
|
771
791
|
);
|
|
772
792
|
else {
|
|
773
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
793
|
+
const l = this.options.prepareAttachmentUpload ? await ge(
|
|
774
794
|
() => this.options.prepareAttachmentUpload(i),
|
|
775
795
|
"Failed to prepare attachment upload"
|
|
776
796
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
777
|
-
await
|
|
797
|
+
await ge(async () => {
|
|
778
798
|
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
779
799
|
method: l.uploadMethod,
|
|
780
800
|
headers: l.uploadHeaders,
|
|
781
801
|
body: e
|
|
782
802
|
});
|
|
783
803
|
if (!c.ok)
|
|
784
|
-
throw new
|
|
804
|
+
throw new Ie("Failed to upload attachment", c.status);
|
|
785
805
|
return c;
|
|
786
806
|
}, "Failed to upload attachment"), o = l;
|
|
787
807
|
}
|
|
@@ -814,18 +834,18 @@ class jt {
|
|
|
814
834
|
}
|
|
815
835
|
async prepareEmbedAttachmentUpload(e) {
|
|
816
836
|
let s = !1;
|
|
817
|
-
return await
|
|
837
|
+
return await ge(async () => {
|
|
818
838
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
819
839
|
if (n.ok)
|
|
820
840
|
return await n.json();
|
|
821
|
-
if (
|
|
841
|
+
if (ai(n.status) && this.options.tokenProvider && !s) {
|
|
822
842
|
s = !0;
|
|
823
843
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
824
844
|
if (r.ok)
|
|
825
845
|
return await r.json();
|
|
826
|
-
throw new
|
|
846
|
+
throw new Ie("Failed to prepare attachment upload", r.status);
|
|
827
847
|
}
|
|
828
|
-
throw new
|
|
848
|
+
throw new Ie("Failed to prepare attachment upload", n.status);
|
|
829
849
|
}, "Failed to prepare attachment upload");
|
|
830
850
|
}
|
|
831
851
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -843,7 +863,7 @@ class jt {
|
|
|
843
863
|
if (!this.state.sessionId)
|
|
844
864
|
return;
|
|
845
865
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
846
|
-
const e =
|
|
866
|
+
const e = kr(
|
|
847
867
|
this.state.messages,
|
|
848
868
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
849
869
|
this.state.assistantDraftRunId,
|
|
@@ -856,7 +876,7 @@ class jt {
|
|
|
856
876
|
stoppedCausalSequence: null,
|
|
857
877
|
toolCallIds: new Set(
|
|
858
878
|
this.state.messages.filter(
|
|
859
|
-
(s) =>
|
|
879
|
+
(s) => Be(
|
|
860
880
|
s,
|
|
861
881
|
e.respondsToUserMessageId,
|
|
862
882
|
e.runId
|
|
@@ -874,6 +894,7 @@ class jt {
|
|
|
874
894
|
),
|
|
875
895
|
pendingMessageStatus: null,
|
|
876
896
|
isThinking: !1,
|
|
897
|
+
...this.state.taskStatus === "working" ? { taskStatus: "stopped" } : {},
|
|
877
898
|
isRetrying: !1,
|
|
878
899
|
lastError: null,
|
|
879
900
|
lastErrorCode: null,
|
|
@@ -886,7 +907,7 @@ class jt {
|
|
|
886
907
|
type: "session.reset",
|
|
887
908
|
sessionId: this.state.sessionId ?? void 0,
|
|
888
909
|
warmupId: n ?? void 0,
|
|
889
|
-
page:
|
|
910
|
+
page: b()
|
|
890
911
|
}), this.setState({
|
|
891
912
|
sessionId: null,
|
|
892
913
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -901,12 +922,13 @@ class jt {
|
|
|
901
922
|
assistantDraftRunId: null,
|
|
902
923
|
pendingMessageStatus: null,
|
|
903
924
|
isThinking: !1,
|
|
925
|
+
taskStatus: null,
|
|
904
926
|
isRetrying: !1,
|
|
905
927
|
lastError: null
|
|
906
928
|
});
|
|
907
929
|
}
|
|
908
930
|
listSessions(e = {}) {
|
|
909
|
-
const s =
|
|
931
|
+
const s = j(), n = new Promise((i, o) => {
|
|
910
932
|
const a = window.setTimeout(() => {
|
|
911
933
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
912
934
|
}, wt);
|
|
@@ -914,7 +936,7 @@ class jt {
|
|
|
914
936
|
}), r = {
|
|
915
937
|
type: "sessions.list",
|
|
916
938
|
requestId: s,
|
|
917
|
-
page:
|
|
939
|
+
page: b(),
|
|
918
940
|
...e.cursor ? { cursor: e.cursor } : {},
|
|
919
941
|
...e.limit ? { limit: e.limit } : {},
|
|
920
942
|
...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
|
|
@@ -928,23 +950,23 @@ class jt {
|
|
|
928
950
|
setSessionPinned(e, s) {
|
|
929
951
|
return this.sendSessionMutation(
|
|
930
952
|
this.pendingSessionPinRequests,
|
|
931
|
-
{ type: "session.pin", requestId:
|
|
953
|
+
{ type: "session.pin", requestId: j(), sessionId: e, pinned: s },
|
|
932
954
|
"Session pin did not respond in time"
|
|
933
955
|
);
|
|
934
956
|
}
|
|
935
957
|
renameSession(e, s) {
|
|
936
958
|
return this.sendSessionMutation(
|
|
937
959
|
this.pendingSessionRenameRequests,
|
|
938
|
-
{ type: "session.rename", requestId:
|
|
960
|
+
{ type: "session.rename", requestId: j(), sessionId: e, title: s },
|
|
939
961
|
"Session rename did not respond in time"
|
|
940
962
|
);
|
|
941
963
|
}
|
|
942
964
|
loadSession(e) {
|
|
943
|
-
const s =
|
|
965
|
+
const s = j(), n = this.activeComposerWarmupId;
|
|
944
966
|
!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({
|
|
945
967
|
type: "session.reset",
|
|
946
968
|
warmupId: n,
|
|
947
|
-
page:
|
|
969
|
+
page: b()
|
|
948
970
|
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionLoadRequestTimer = window.setTimeout(() => {
|
|
949
971
|
this.sessionLoadRequestId === s && (this.clearSessionLoadRequest(), this.setState({
|
|
950
972
|
isLoadingSession: !1,
|
|
@@ -963,6 +985,7 @@ class jt {
|
|
|
963
985
|
assistantDraftRunId: null,
|
|
964
986
|
pendingMessageStatus: null,
|
|
965
987
|
isThinking: !1,
|
|
988
|
+
taskStatus: null,
|
|
966
989
|
isRetrying: !1,
|
|
967
990
|
lastError: null,
|
|
968
991
|
lastErrorCode: null
|
|
@@ -970,26 +993,26 @@ class jt {
|
|
|
970
993
|
type: "session.load",
|
|
971
994
|
requestId: s,
|
|
972
995
|
sessionId: e,
|
|
973
|
-
page:
|
|
996
|
+
page: b()
|
|
974
997
|
});
|
|
975
998
|
}
|
|
976
999
|
loadOlderMessages() {
|
|
977
1000
|
if (!this.state.sessionId || !this.sessionItemsCursor || this.state.isLoadingSession || this.state.isLoadingOlderMessages)
|
|
978
1001
|
return;
|
|
979
|
-
const e =
|
|
1002
|
+
const e = j();
|
|
980
1003
|
this.sessionItemsRequestId = e, this.setState({ isLoadingOlderMessages: !0, lastError: null, lastErrorCode: null }), this.send({
|
|
981
1004
|
type: "session.items.list",
|
|
982
1005
|
requestId: e,
|
|
983
1006
|
sessionId: this.state.sessionId,
|
|
984
1007
|
cursor: this.sessionItemsCursor,
|
|
985
1008
|
limit: 50,
|
|
986
|
-
page:
|
|
1009
|
+
page: b()
|
|
987
1010
|
});
|
|
988
1011
|
}
|
|
989
1012
|
send(e) {
|
|
990
|
-
this.sendNow(
|
|
1013
|
+
this.sendNow(L(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
991
1014
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
992
|
-
) || this.queuedClientEvents.push(e),
|
|
1015
|
+
) || this.queuedClientEvents.push(e), G(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
993
1016
|
status: "reconnecting",
|
|
994
1017
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
995
1018
|
}), this.scheduleReconnect());
|
|
@@ -1005,7 +1028,7 @@ class jt {
|
|
|
1005
1028
|
return !1;
|
|
1006
1029
|
const s = this.socket;
|
|
1007
1030
|
try {
|
|
1008
|
-
return s.send(JSON.stringify(e)),
|
|
1031
|
+
return s.send(JSON.stringify(e)), Le("client_event", e.type, pt(e)), !0;
|
|
1009
1032
|
} catch (n) {
|
|
1010
1033
|
return A("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1011
1034
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -1051,7 +1074,7 @@ class jt {
|
|
|
1051
1074
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
1052
1075
|
const e = vn();
|
|
1053
1076
|
this.sendNow(
|
|
1054
|
-
|
|
1077
|
+
L({
|
|
1055
1078
|
type: "starter_prompts.page_context",
|
|
1056
1079
|
pageUrl: e.pageUrl,
|
|
1057
1080
|
pageTitle: e.pageTitle,
|
|
@@ -1081,18 +1104,28 @@ class jt {
|
|
|
1081
1104
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
1082
1105
|
return;
|
|
1083
1106
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
1084
|
-
|
|
1107
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1085
1108
|
for (let s = 0; s < e.length; s += 1) {
|
|
1086
1109
|
const n = e[s];
|
|
1087
|
-
if (!this.sendNow(
|
|
1088
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1110
|
+
if (!this.sendNow(L(n))) {
|
|
1111
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), G(this.options.clientId, this.queuedClientEvents);
|
|
1089
1112
|
return;
|
|
1090
1113
|
}
|
|
1091
|
-
|
|
1114
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1092
1115
|
}
|
|
1093
1116
|
}
|
|
1094
1117
|
resetForAuthenticationScopeChange() {
|
|
1095
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
1118
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], G(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear();
|
|
1119
|
+
}
|
|
1120
|
+
flushPendingWidgetLifecycleEvents() {
|
|
1121
|
+
if (this.authenticatedSocket !== this.socket || this.socket?.readyState !== WebSocket.OPEN || this.pendingWidgetLifecycleEvents.length === 0)
|
|
1122
|
+
return;
|
|
1123
|
+
const e = this.pendingWidgetLifecycleEvents.splice(0, this.pendingWidgetLifecycleEvents.length);
|
|
1124
|
+
for (let s = 0; s < e.length; s += 1)
|
|
1125
|
+
if (!this.sendNow(e[s])) {
|
|
1126
|
+
this.pendingWidgetLifecycleEvents.unshift(...e.slice(s));
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1096
1129
|
}
|
|
1097
1130
|
flushPendingPassiveWarmup() {
|
|
1098
1131
|
!this.pendingPassiveWarmupEvent || !this.sendNow(this.pendingPassiveWarmupEvent) || (this.pendingPassiveWarmupEvent = null);
|
|
@@ -1117,16 +1150,16 @@ class jt {
|
|
|
1117
1150
|
return [...this.stoppedTurns].reverse().find((o) => o.sessionId !== e ? !1 : r && o.respondsToUserMessageId ? r === o.respondsToUserMessageId : n && o.clientMessageId ? n === o.clientMessageId : !!(i && o.runId && i === o.runId)) ?? null;
|
|
1118
1151
|
}
|
|
1119
1152
|
findStoppedTurnForEvent(e) {
|
|
1120
|
-
const s = e.type === "session.item" ?
|
|
1153
|
+
const s = e.type === "session.item" ? P(e.item) : null;
|
|
1121
1154
|
return this.findStoppedTurn(
|
|
1122
|
-
|
|
1155
|
+
ue(e) ?? this.state.sessionId,
|
|
1123
1156
|
s ?? e
|
|
1124
1157
|
);
|
|
1125
1158
|
}
|
|
1126
1159
|
rememberDurablyStoppedTurn(e, s, n) {
|
|
1127
|
-
if (!e || !s || !
|
|
1160
|
+
if (!e || !s || !ye(s) || this.findStoppedTurn(e, s))
|
|
1128
1161
|
return;
|
|
1129
|
-
const r =
|
|
1162
|
+
const r = N(s), i = _(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1130
1163
|
this.stoppedTurns.push({
|
|
1131
1164
|
sessionId: e,
|
|
1132
1165
|
clientMessageId: o,
|
|
@@ -1136,7 +1169,7 @@ class jt {
|
|
|
1136
1169
|
stoppedCausalSequence: v(s),
|
|
1137
1170
|
toolCallIds: new Set(
|
|
1138
1171
|
this.state.messages.filter(
|
|
1139
|
-
(a) =>
|
|
1172
|
+
(a) => Be(a, r, i)
|
|
1140
1173
|
).map((a) => a.callId).filter((a) => typeof a == "string")
|
|
1141
1174
|
)
|
|
1142
1175
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
@@ -1146,29 +1179,29 @@ class jt {
|
|
|
1146
1179
|
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1147
1180
|
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1148
1181
|
}
|
|
1149
|
-
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !
|
|
1182
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !ye(P(e.item)) : e.type !== "conversation.state" : !1;
|
|
1150
1183
|
}
|
|
1151
1184
|
filterStoppedSnapshotItems(e, s) {
|
|
1152
1185
|
return e.filter((n) => {
|
|
1153
|
-
const r =
|
|
1154
|
-
if (!i || r?.type === "message" && r.role === "user" ||
|
|
1186
|
+
const r = P(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1187
|
+
if (!i || r?.type === "message" && r.role === "user" || ye(r))
|
|
1155
1188
|
return !0;
|
|
1156
1189
|
if (i.stoppedCausalSequence !== null) {
|
|
1157
1190
|
const o = r ? v(r) : null;
|
|
1158
1191
|
return o === null || o <= i.stoppedCausalSequence;
|
|
1159
1192
|
}
|
|
1160
1193
|
if (i.stoppedAt) {
|
|
1161
|
-
const o =
|
|
1194
|
+
const o = S(n, "createdAt");
|
|
1162
1195
|
return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
|
|
1163
1196
|
}
|
|
1164
1197
|
return !1;
|
|
1165
1198
|
});
|
|
1166
1199
|
}
|
|
1167
1200
|
handleServerEvent(e) {
|
|
1168
|
-
if (
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1201
|
+
if (Le("server_event", e.type, pt(e)), e.type === "session.item" && this.rememberDurablyStoppedTurn(
|
|
1202
|
+
S(e.item, "sessionId") ?? this.state.sessionId,
|
|
1203
|
+
P(e.item),
|
|
1204
|
+
S(e.item, "createdAt")
|
|
1172
1205
|
), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1173
1206
|
if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
|
|
1174
1207
|
this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
|
|
@@ -1177,12 +1210,12 @@ class jt {
|
|
|
1177
1210
|
if (e.type === "run.ack") {
|
|
1178
1211
|
if (this.shouldIgnoreStoppedTurnEvent(e))
|
|
1179
1212
|
return;
|
|
1180
|
-
const s =
|
|
1213
|
+
const s = ue(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1181
1214
|
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);
|
|
1182
1215
|
return;
|
|
1183
1216
|
}
|
|
1184
1217
|
if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
1185
|
-
const s =
|
|
1218
|
+
const s = ue(e);
|
|
1186
1219
|
if (s) {
|
|
1187
1220
|
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1188
1221
|
return;
|
|
@@ -1207,47 +1240,47 @@ class jt {
|
|
|
1207
1240
|
if (hn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
1208
1241
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
1209
1242
|
const s = Vn(e.user);
|
|
1210
|
-
this.authenticatedSocket !== this.socket && this.authenticatedUserId && s && s.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = s?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
1243
|
+
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();
|
|
1211
1244
|
const n = Fn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1212
1245
|
A("web-sdk.agent", "Received auth.ok appearance", {
|
|
1213
1246
|
hasAppearance: r,
|
|
1214
1247
|
rawAppearance: e.appearance,
|
|
1215
1248
|
normalizedAppearance: n
|
|
1216
1249
|
}), this.runtimeHelperJavascript = zn(e.runtimeHelpers)?.javascript ?? null;
|
|
1217
|
-
const i =
|
|
1250
|
+
const i = kt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1218
1251
|
user: s,
|
|
1219
1252
|
status: "connected",
|
|
1220
1253
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1221
1254
|
};
|
|
1222
|
-
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !
|
|
1255
|
+
(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 && !de() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1223
1256
|
type: "page.upsert",
|
|
1224
1257
|
sessionId: this.state.sessionId,
|
|
1225
|
-
page:
|
|
1258
|
+
page: b(),
|
|
1226
1259
|
model: this.options.model
|
|
1227
1260
|
});
|
|
1228
1261
|
return;
|
|
1229
1262
|
}
|
|
1230
1263
|
if (e.type === "starterPrompts.updated") {
|
|
1231
1264
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1232
|
-
starterPrompts:
|
|
1265
|
+
starterPrompts: kt(e, "starterPrompts"),
|
|
1233
1266
|
starterPromptsLoading: !1
|
|
1234
1267
|
});
|
|
1235
1268
|
return;
|
|
1236
1269
|
}
|
|
1237
1270
|
if (e.type === "conversation.state") {
|
|
1238
|
-
const s = Array.isArray(e.items) ? e.items : [], n =
|
|
1271
|
+
const s = Array.isArray(e.items) ? e.items : [], n = S(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null;
|
|
1239
1272
|
if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && n !== this.state.sessionId)
|
|
1240
1273
|
return;
|
|
1241
1274
|
n === this.state.sessionId && (this.clearSessionLoadRequest(), !this.hasLoadedOlderSessionItems && this.sessionItemsRequestId === null && (this.sessionItemsCursor = typeof e.itemsNextCursor == "string" ? e.itemsNextCursor : null));
|
|
1242
1275
|
for (const E of s)
|
|
1243
1276
|
this.rememberDurablyStoppedTurn(
|
|
1244
1277
|
n,
|
|
1245
|
-
|
|
1246
|
-
|
|
1278
|
+
P(E),
|
|
1279
|
+
S(E, "createdAt")
|
|
1247
1280
|
);
|
|
1248
|
-
const i =
|
|
1281
|
+
const i = Z(s), o = i === null ? null : s[i], a = P(o), l = this.findStoppedTurn(n, {
|
|
1249
1282
|
clientMessageId: a?.clientMessageId,
|
|
1250
|
-
respondsToUserMessageId:
|
|
1283
|
+
respondsToUserMessageId: S(o, "id"),
|
|
1251
1284
|
runId: a?.runId
|
|
1252
1285
|
}), c = this.filterStoppedSnapshotItems(s, n), h = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, p = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, I = e.isRetrying === !0, f = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1253
1286
|
h && p && (this.pendingClientMessageId = p);
|
|
@@ -1269,31 +1302,31 @@ class jt {
|
|
|
1269
1302
|
);
|
|
1270
1303
|
}
|
|
1271
1304
|
const T = c.filter((E) => {
|
|
1272
|
-
const
|
|
1273
|
-
return bt(
|
|
1274
|
-
}),
|
|
1305
|
+
const O = P(E);
|
|
1306
|
+
return bt(O) ? !1 : !O || !g || !Se(O) ? !0 : Ke(c, O) !== g;
|
|
1307
|
+
}), k = dr(
|
|
1275
1308
|
this.state.messages,
|
|
1276
|
-
|
|
1309
|
+
Ct(T, this.options.backendUrl)
|
|
1277
1310
|
), m = this.hasLoadedOlderSessionItems ? hr(
|
|
1278
1311
|
this.state.messages,
|
|
1279
|
-
|
|
1312
|
+
k,
|
|
1280
1313
|
this.loadedOlderSessionItemIds
|
|
1281
|
-
) :
|
|
1282
|
-
(E,
|
|
1283
|
-
|
|
1284
|
-
|
|
1314
|
+
) : k, w = _t(m), U = d ? u?.content ?? "" : this.state.assistantDraft, D = d ? u?.itemId ?? null : this.state.assistantDraftItemId, R = d ? u?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, ee = d ? u?.runId ?? null : this.state.assistantDraftRunId, C = c.some(
|
|
1315
|
+
(E, O) => Pt(
|
|
1316
|
+
P(E),
|
|
1317
|
+
U,
|
|
1285
1318
|
D,
|
|
1286
1319
|
R,
|
|
1287
|
-
|
|
1288
|
-
Mr(c,
|
|
1320
|
+
ee,
|
|
1321
|
+
Mr(c, O)
|
|
1289
1322
|
)
|
|
1290
|
-
),
|
|
1291
|
-
if (!
|
|
1323
|
+
), te = d ? u?.content ?? "" : this.state.assistantDraft, z = !!u?.content && !C, H = w && (!te || C), K = yr(m), X = H && K ? "completed" : l ? "stopped" : H ? "failed" : null;
|
|
1324
|
+
if (!w && Tr(this.state.messages, c))
|
|
1292
1325
|
return;
|
|
1293
1326
|
this.lastUserMessagePageUrl = Ir(c);
|
|
1294
|
-
const
|
|
1295
|
-
if (this.latestRecoverableClientMessageId =
|
|
1296
|
-
sessionId:
|
|
1327
|
+
const q = H || l ? null : ze(c);
|
|
1328
|
+
if (this.latestRecoverableClientMessageId = q, K && this.clearRetryTimers(), this.setState({
|
|
1329
|
+
sessionId: S(e.session, "id") ?? this.state.sessionId,
|
|
1297
1330
|
messages: m,
|
|
1298
1331
|
isLoadingSession: !1,
|
|
1299
1332
|
isLoadingOlderMessages: this.sessionItemsRequestId !== null,
|
|
@@ -1301,7 +1334,8 @@ class jt {
|
|
|
1301
1334
|
...h ? { pendingMessageStatus: h } : {},
|
|
1302
1335
|
...f ? { turnPhase: f } : {},
|
|
1303
1336
|
isRetrying: I,
|
|
1304
|
-
...
|
|
1337
|
+
...X && this.state.taskStatus === "working" ? { taskStatus: X } : {},
|
|
1338
|
+
...C ? {
|
|
1305
1339
|
assistantDraft: "",
|
|
1306
1340
|
assistantDraftItemId: null,
|
|
1307
1341
|
assistantDraftPhase: null,
|
|
@@ -1314,33 +1348,33 @@ class jt {
|
|
|
1314
1348
|
assistantDraftRespondsToUserMessageId: u?.respondsToUserMessageId ?? null,
|
|
1315
1349
|
assistantDraftRunId: u?.runId ?? null
|
|
1316
1350
|
} : {},
|
|
1317
|
-
...
|
|
1351
|
+
...z ? {
|
|
1318
1352
|
isThinking: !0,
|
|
1319
1353
|
turnPhase: "thinking",
|
|
1320
1354
|
lastError: null
|
|
1321
|
-
} :
|
|
1355
|
+
} : H ? {
|
|
1322
1356
|
isThinking: !1,
|
|
1323
1357
|
status: "connected",
|
|
1324
1358
|
lastError: null,
|
|
1325
1359
|
lastErrorCode: null,
|
|
1326
1360
|
lastErrorSecuritySettingsUrl: null
|
|
1327
|
-
} :
|
|
1361
|
+
} : q ? {
|
|
1328
1362
|
isThinking: !0,
|
|
1329
1363
|
turnPhase: f ?? this.state.turnPhase ?? "starting",
|
|
1330
1364
|
lastError: null
|
|
1331
1365
|
} : {}
|
|
1332
|
-
}),
|
|
1366
|
+
}), H)
|
|
1333
1367
|
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1334
|
-
else if (!l && (
|
|
1335
|
-
if (
|
|
1336
|
-
this.activeClientMessageId =
|
|
1337
|
-
const E =
|
|
1338
|
-
this.activeResponseUserMessageId =
|
|
1368
|
+
else if (!l && (z || q)) {
|
|
1369
|
+
if (q) {
|
|
1370
|
+
this.activeClientMessageId = q;
|
|
1371
|
+
const E = Z(c), O = E === null ? null : c[E];
|
|
1372
|
+
this.activeResponseUserMessageId = S(O, "id");
|
|
1339
1373
|
}
|
|
1340
1374
|
this.markThinkingProgress();
|
|
1341
1375
|
}
|
|
1342
1376
|
if (g) {
|
|
1343
|
-
const E =
|
|
1377
|
+
const E = S(e.session, "id") ?? this.state.sessionId;
|
|
1344
1378
|
E && this.retryAfterInterruptedRun(E, g);
|
|
1345
1379
|
}
|
|
1346
1380
|
return;
|
|
@@ -1349,7 +1383,7 @@ class jt {
|
|
|
1349
1383
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1350
1384
|
if (!s || s !== this.sessionItemsRequestId || n !== this.state.sessionId)
|
|
1351
1385
|
return;
|
|
1352
|
-
const r =
|
|
1386
|
+
const r = Ct(
|
|
1353
1387
|
Array.isArray(e.items) ? e.items : [],
|
|
1354
1388
|
this.options.backendUrl
|
|
1355
1389
|
), i = new Set(r.map((o) => o.id));
|
|
@@ -1380,7 +1414,7 @@ class jt {
|
|
|
1380
1414
|
}
|
|
1381
1415
|
if (e.type === "session.updated") {
|
|
1382
1416
|
this.clearRunAckResyncRetryTimer();
|
|
1383
|
-
const s =
|
|
1417
|
+
const s = S(e.session, "id");
|
|
1384
1418
|
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1385
1419
|
...this.pendingComposerWarmup.event,
|
|
1386
1420
|
sessionId: s
|
|
@@ -1391,10 +1425,10 @@ class jt {
|
|
|
1391
1425
|
}
|
|
1392
1426
|
if (e.type === "session.item") {
|
|
1393
1427
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1394
|
-
const s =
|
|
1395
|
-
if (
|
|
1428
|
+
const s = P(e.item);
|
|
1429
|
+
if (Se(s)) {
|
|
1396
1430
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1397
|
-
const r =
|
|
1431
|
+
const r = S(e.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1398
1432
|
if (r && a) {
|
|
1399
1433
|
this.retryAfterInterruptedRun(r, a);
|
|
1400
1434
|
return;
|
|
@@ -1408,12 +1442,10 @@ class jt {
|
|
|
1408
1442
|
return;
|
|
1409
1443
|
const n = Xt(e.item, this.options.backendUrl);
|
|
1410
1444
|
if (n) {
|
|
1411
|
-
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1412
|
-
n.callId &&
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1415
|
-
const o = je(this.state.messages, n), a = _t(o), l = Pt(
|
|
1416
|
-
i,
|
|
1445
|
+
const r = Cr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1446
|
+
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), B(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Rr(s) && this.clearRunAckResyncRetryTimer();
|
|
1447
|
+
const o = Fe(this.state.messages, n), a = _t(o), l = Pt(
|
|
1448
|
+
s,
|
|
1417
1449
|
this.state.assistantDraft,
|
|
1418
1450
|
this.state.assistantDraftItemId,
|
|
1419
1451
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
@@ -1422,7 +1454,7 @@ class jt {
|
|
|
1422
1454
|
o,
|
|
1423
1455
|
o.findIndex((p) => p.id === n.id)
|
|
1424
1456
|
)
|
|
1425
|
-
), c = a && (!this.state.assistantDraft || l), h =
|
|
1457
|
+
), c = a && (!this.state.assistantDraft || l), h = Te(n) && (c || B(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
1426
1458
|
this.setState({
|
|
1427
1459
|
messages: o,
|
|
1428
1460
|
...l ? {
|
|
@@ -1434,6 +1466,7 @@ class jt {
|
|
|
1434
1466
|
} : {},
|
|
1435
1467
|
...c ? {
|
|
1436
1468
|
isThinking: !1,
|
|
1469
|
+
...r && this.state.taskStatus === "working" ? { taskStatus: r } : {},
|
|
1437
1470
|
isRetrying: !1
|
|
1438
1471
|
} : {},
|
|
1439
1472
|
...h && !this.failedUserMessageEvent ? {
|
|
@@ -1450,7 +1483,7 @@ class jt {
|
|
|
1450
1483
|
this.clearRunAckResyncRetryTimer();
|
|
1451
1484
|
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((p) => p.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1452
1485
|
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = h), this.setState({
|
|
1453
|
-
messages:
|
|
1486
|
+
messages: Fe(this.state.messages, {
|
|
1454
1487
|
id: o,
|
|
1455
1488
|
role: "assistant",
|
|
1456
1489
|
content: i,
|
|
@@ -1467,6 +1500,7 @@ class jt {
|
|
|
1467
1500
|
assistantDraftRespondsToUserMessageId: c,
|
|
1468
1501
|
assistantDraftRunId: h,
|
|
1469
1502
|
isThinking: !0,
|
|
1503
|
+
taskStatus: "working",
|
|
1470
1504
|
isRetrying: !1
|
|
1471
1505
|
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1472
1506
|
return;
|
|
@@ -1480,7 +1514,7 @@ class jt {
|
|
|
1480
1514
|
return;
|
|
1481
1515
|
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = Es(
|
|
1482
1516
|
this.state.messages.filter(
|
|
1483
|
-
(c) => c.dataType !== "assistant_draft" || !
|
|
1517
|
+
(c) => c.dataType !== "assistant_draft" || !Be(
|
|
1484
1518
|
c,
|
|
1485
1519
|
n,
|
|
1486
1520
|
r
|
|
@@ -1504,6 +1538,7 @@ class jt {
|
|
|
1504
1538
|
assistantDraftRespondsToUserMessageId: null,
|
|
1505
1539
|
assistantDraftRunId: null,
|
|
1506
1540
|
isThinking: a ? !1 : this.state.isThinking,
|
|
1541
|
+
...a && this.state.taskStatus === "working" ? { taskStatus: "completed" } : {},
|
|
1507
1542
|
isRetrying: a ? !1 : this.state.isRetrying
|
|
1508
1543
|
}), a && this.clearThinkingWatchdog();
|
|
1509
1544
|
return;
|
|
@@ -1604,6 +1639,7 @@ class jt {
|
|
|
1604
1639
|
assistantDraftRespondsToUserMessageId: null,
|
|
1605
1640
|
assistantDraftRunId: null,
|
|
1606
1641
|
isThinking: !1,
|
|
1642
|
+
...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
|
|
1607
1643
|
isRetrying: !1,
|
|
1608
1644
|
lastError: I ? null : a.message,
|
|
1609
1645
|
lastErrorCode: I ? null : typeof e.code == "string" ? e.code : null,
|
|
@@ -1616,7 +1652,7 @@ class jt {
|
|
|
1616
1652
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1617
1653
|
if (!this.options.keepRunsActiveOnSessionNavigation || !pn(e))
|
|
1618
1654
|
return !1;
|
|
1619
|
-
const s =
|
|
1655
|
+
const s = ue(e);
|
|
1620
1656
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1621
1657
|
}
|
|
1622
1658
|
rememberCurrentRunAsBackground() {
|
|
@@ -1626,7 +1662,7 @@ class jt {
|
|
|
1626
1662
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1627
1663
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1628
1664
|
return !1;
|
|
1629
|
-
if (
|
|
1665
|
+
if (de())
|
|
1630
1666
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1631
1667
|
if (e.code === "run_still_active") {
|
|
1632
1668
|
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) {
|
|
@@ -1640,10 +1676,10 @@ class jt {
|
|
|
1640
1676
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1641
1677
|
return !0;
|
|
1642
1678
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1643
|
-
if (i >=
|
|
1679
|
+
if (i >= re)
|
|
1644
1680
|
return !1;
|
|
1645
1681
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1646
|
-
const o =
|
|
1682
|
+
const o = ie(
|
|
1647
1683
|
i,
|
|
1648
1684
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1649
1685
|
);
|
|
@@ -1657,20 +1693,20 @@ class jt {
|
|
|
1657
1693
|
}, o), !0;
|
|
1658
1694
|
}
|
|
1659
1695
|
retryAfterInterruptedRun(e, s) {
|
|
1660
|
-
if (
|
|
1696
|
+
if (de()) {
|
|
1661
1697
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1662
1698
|
return;
|
|
1663
1699
|
}
|
|
1664
1700
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1665
1701
|
return;
|
|
1666
1702
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1667
|
-
if (n >=
|
|
1703
|
+
if (n >= re) {
|
|
1668
1704
|
this.requestSessionRecoveryExhaustion(e, s);
|
|
1669
1705
|
return;
|
|
1670
1706
|
}
|
|
1671
1707
|
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(() => {
|
|
1672
1708
|
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 });
|
|
1673
|
-
},
|
|
1709
|
+
}, ie(n));
|
|
1674
1710
|
}
|
|
1675
1711
|
requestSessionRecoveryExhaustion(e, s) {
|
|
1676
1712
|
this.retryableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.recoveryExhaustionRequestedClientMessageIds.has(s) ? this.resyncThinkingSession() : (this.recoveryExhaustionRequestedClientMessageIds.add(s), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 })), this.scheduleThinkingWatchdog(yt);
|
|
@@ -1682,10 +1718,10 @@ class jt {
|
|
|
1682
1718
|
}
|
|
1683
1719
|
rememberUserMessageClientMessageIds(e) {
|
|
1684
1720
|
for (const s of e) {
|
|
1685
|
-
const n =
|
|
1721
|
+
const n = S(s, "id"), r = P(s);
|
|
1686
1722
|
n && r?.type === "message" && r.role === "user" && r.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof r.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId), r.clientMessageId === this.pendingClientMessageId && this.promotePendingDelivery(
|
|
1687
1723
|
r.clientMessageId,
|
|
1688
|
-
|
|
1724
|
+
S(s, "sessionId") ?? this.state.sessionId,
|
|
1689
1725
|
n,
|
|
1690
1726
|
null
|
|
1691
1727
|
), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
|
|
@@ -1770,7 +1806,7 @@ class jt {
|
|
|
1770
1806
|
}), this.markThinkingProgress();
|
|
1771
1807
|
}
|
|
1772
1808
|
schedulePendingDeliveryAck(e) {
|
|
1773
|
-
this.clearPendingDeliveryTimers(), !
|
|
1809
|
+
this.clearPendingDeliveryTimers(), !de() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
1774
1810
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
1775
1811
|
}, Tt));
|
|
1776
1812
|
}
|
|
@@ -1778,13 +1814,13 @@ class jt {
|
|
|
1778
1814
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
1779
1815
|
return;
|
|
1780
1816
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1781
|
-
if (s >=
|
|
1817
|
+
if (s >= re) {
|
|
1782
1818
|
this.failPendingDelivery(e);
|
|
1783
1819
|
return;
|
|
1784
1820
|
}
|
|
1785
1821
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
1786
1822
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
1787
|
-
},
|
|
1823
|
+
}, ie(s, St));
|
|
1788
1824
|
}
|
|
1789
1825
|
failPendingDelivery(e) {
|
|
1790
1826
|
if (this.pendingClientMessageId !== e)
|
|
@@ -1795,6 +1831,7 @@ class jt {
|
|
|
1795
1831
|
// A failed follow-up delivery must not hide an older acknowledged response that is still active.
|
|
1796
1832
|
...this.state.isThinking ? {} : { turnPhase: null },
|
|
1797
1833
|
isRetrying: !1,
|
|
1834
|
+
...this.state.isThinking ? {} : { taskStatus: "failed" },
|
|
1798
1835
|
lastError: Ys,
|
|
1799
1836
|
lastErrorCode: "message_delivery_failed"
|
|
1800
1837
|
});
|
|
@@ -1810,7 +1847,7 @@ class jt {
|
|
|
1810
1847
|
s,
|
|
1811
1848
|
typeof e.runId == "string" ? e.runId : null
|
|
1812
1849
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
1813
|
-
messages:
|
|
1850
|
+
messages: br(
|
|
1814
1851
|
this.state.messages,
|
|
1815
1852
|
s
|
|
1816
1853
|
)
|
|
@@ -1830,7 +1867,7 @@ class jt {
|
|
|
1830
1867
|
scheduleRunAckResyncRetry(e) {
|
|
1831
1868
|
this.clearRunAckResyncRetryTimer();
|
|
1832
1869
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1833
|
-
s >=
|
|
1870
|
+
s >= re || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1834
1871
|
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({
|
|
1835
1872
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1836
1873
|
isThinking: !0,
|
|
@@ -1844,7 +1881,7 @@ class jt {
|
|
|
1844
1881
|
clientMessageId: e,
|
|
1845
1882
|
automatic: !0
|
|
1846
1883
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(mt)));
|
|
1847
|
-
},
|
|
1884
|
+
}, ie(s, St)));
|
|
1848
1885
|
}
|
|
1849
1886
|
clearRunAckResyncRetryTimer() {
|
|
1850
1887
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1863,21 +1900,23 @@ class jt {
|
|
|
1863
1900
|
reason: "missing_client_message_id"
|
|
1864
1901
|
}), this.setState({
|
|
1865
1902
|
messages: this.state.messages.filter(
|
|
1866
|
-
(r) => !
|
|
1903
|
+
(r) => !F(r)
|
|
1867
1904
|
),
|
|
1868
1905
|
isThinking: !1,
|
|
1906
|
+
taskStatus: "failed",
|
|
1869
1907
|
lastError: It,
|
|
1870
1908
|
lastErrorCode: "run_recovery_exhausted"
|
|
1871
1909
|
}), this.clearThinkingWatchdog();
|
|
1872
1910
|
return;
|
|
1873
1911
|
}
|
|
1874
1912
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1875
|
-
if (n >=
|
|
1913
|
+
if (n >= re) {
|
|
1876
1914
|
A("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1877
1915
|
sessionId: this.state.sessionId,
|
|
1878
1916
|
clientMessageId: e
|
|
1879
1917
|
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
1880
1918
|
isThinking: !1,
|
|
1919
|
+
taskStatus: "failed",
|
|
1881
1920
|
lastError: It,
|
|
1882
1921
|
lastErrorCode: "connection_failed"
|
|
1883
1922
|
}), this.clearThinkingWatchdog());
|
|
@@ -1906,32 +1945,32 @@ class jt {
|
|
|
1906
1945
|
clientMessageId: e,
|
|
1907
1946
|
automatic: !0
|
|
1908
1947
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1909
|
-
},
|
|
1948
|
+
}, ie(n)));
|
|
1910
1949
|
}
|
|
1911
1950
|
resyncThinkingSession() {
|
|
1912
1951
|
this.state.sessionId ? this.send({
|
|
1913
1952
|
type: "page.upsert",
|
|
1914
1953
|
sessionId: this.state.sessionId,
|
|
1915
|
-
page:
|
|
1954
|
+
page: b(),
|
|
1916
1955
|
model: this.options.model
|
|
1917
1956
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1918
1957
|
}
|
|
1919
1958
|
async executeToolCall(e) {
|
|
1920
|
-
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i =
|
|
1959
|
+
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 = J(
|
|
1921
1960
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
1922
1961
|
), o = e.rawInput;
|
|
1923
1962
|
if (!s || !n || !r)
|
|
1924
1963
|
return;
|
|
1925
1964
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1926
|
-
if (!a && !l || !
|
|
1965
|
+
if (!a && !l || !Vr(o)) {
|
|
1927
1966
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1928
1967
|
type: "tool.result",
|
|
1929
1968
|
sessionId: s,
|
|
1930
1969
|
callId: n,
|
|
1931
1970
|
toolName: r,
|
|
1932
1971
|
summary: i,
|
|
1933
|
-
rawInput:
|
|
1934
|
-
rawOutput:
|
|
1972
|
+
rawInput: L(o),
|
|
1973
|
+
rawOutput: L({
|
|
1935
1974
|
ok: !1,
|
|
1936
1975
|
toolName: r,
|
|
1937
1976
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -1946,7 +1985,7 @@ class jt {
|
|
|
1946
1985
|
callId: n,
|
|
1947
1986
|
toolName: r,
|
|
1948
1987
|
summary: i,
|
|
1949
|
-
rawInput:
|
|
1988
|
+
rawInput: L(o),
|
|
1950
1989
|
rawOutput: {
|
|
1951
1990
|
ok: !1,
|
|
1952
1991
|
toolName: r,
|
|
@@ -1962,7 +2001,7 @@ class jt {
|
|
|
1962
2001
|
callId: n,
|
|
1963
2002
|
toolName: r,
|
|
1964
2003
|
summary: i,
|
|
1965
|
-
rawInput:
|
|
2004
|
+
rawInput: L(o),
|
|
1966
2005
|
rawOutput: null
|
|
1967
2006
|
},
|
|
1968
2007
|
startedAtMs: Date.now(),
|
|
@@ -1972,7 +2011,7 @@ class jt {
|
|
|
1972
2011
|
let c = null, h;
|
|
1973
2012
|
c = await this.executeRuntimeHelper(), h = await Rt(
|
|
1974
2013
|
o,
|
|
1975
|
-
|
|
2014
|
+
kn(e.runtimeContext, this.options.backendUrl)
|
|
1976
2015
|
).catch((p) => ({
|
|
1977
2016
|
ok: !1,
|
|
1978
2017
|
exception: {
|
|
@@ -1984,8 +2023,8 @@ class jt {
|
|
|
1984
2023
|
callId: n,
|
|
1985
2024
|
toolName: r,
|
|
1986
2025
|
summary: o.summary,
|
|
1987
|
-
rawInput:
|
|
1988
|
-
rawOutput:
|
|
2026
|
+
rawInput: L(o),
|
|
2027
|
+
rawOutput: L(Kn(h, c))
|
|
1989
2028
|
}), vt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
1990
2029
|
}
|
|
1991
2030
|
setToolMessageLoading(e, s) {
|
|
@@ -2022,17 +2061,17 @@ class jt {
|
|
|
2022
2061
|
}
|
|
2023
2062
|
enableNetworkCapture() {
|
|
2024
2063
|
this.networkCaptureCleanup || (this.networkCaptureCleanup = un((e) => {
|
|
2025
|
-
|
|
2064
|
+
ti(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
2026
2065
|
}));
|
|
2027
2066
|
}
|
|
2028
2067
|
enqueueNetworkEvent(e) {
|
|
2029
|
-
this.queuedNetworkEvents.length >= Zs || (this.queuedNetworkEvents.push(
|
|
2068
|
+
this.queuedNetworkEvents.length >= Zs || (this.queuedNetworkEvents.push(ei(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
2030
2069
|
this.networkBatchTimer = null;
|
|
2031
2070
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
2032
2071
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
2033
2072
|
type: "network.batch",
|
|
2034
2073
|
sessionId: this.state.sessionId ?? void 0,
|
|
2035
|
-
page:
|
|
2074
|
+
page: b(),
|
|
2036
2075
|
events: s
|
|
2037
2076
|
});
|
|
2038
2077
|
}, Qs)));
|
|
@@ -2087,19 +2126,21 @@ class jt {
|
|
|
2087
2126
|
const s = e.isThinking ?? this.state.isThinking, n = e.pendingMessageStatus !== void 0 ? e.pendingMessageStatus : this.state.pendingMessageStatus;
|
|
2088
2127
|
let r = e.turnPhase !== void 0 ? e.turnPhase : this.state.turnPhase;
|
|
2089
2128
|
e.turnPhase === void 0 && (e.isThinking === !1 ? r = n ? "sending" : null : s && r === null ? r = "starting" : !s && n && r === null && (r = "sending"));
|
|
2090
|
-
const i = {
|
|
2129
|
+
const i = e.taskStatus !== void 0 ? e.taskStatus : s || n !== null ? "working" : this.state.taskStatus, o = {
|
|
2091
2130
|
...this.state,
|
|
2092
2131
|
...e,
|
|
2093
2132
|
turnPhase: r,
|
|
2133
|
+
taskStatus: i,
|
|
2094
2134
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2095
2135
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2096
2136
|
};
|
|
2097
|
-
this.state =
|
|
2137
|
+
this.state = o, Nr(this.options.clientId, this.state), this.emit("state", this.getState()), Le("state", this.state.status, {
|
|
2098
2138
|
status: this.state.status,
|
|
2099
2139
|
sessionId: this.state.sessionId,
|
|
2100
2140
|
messageCount: this.state.messages.length,
|
|
2101
2141
|
assistantDraftLength: this.state.assistantDraft.length,
|
|
2102
2142
|
isThinking: this.state.isThinking,
|
|
2143
|
+
taskStatus: this.state.taskStatus,
|
|
2103
2144
|
turnPhase: this.state.turnPhase,
|
|
2104
2145
|
hasError: this.state.lastError !== null
|
|
2105
2146
|
});
|
|
@@ -2115,7 +2156,7 @@ class jt {
|
|
|
2115
2156
|
this.listeners[e]?.forEach((r) => r(s));
|
|
2116
2157
|
}
|
|
2117
2158
|
}
|
|
2118
|
-
const
|
|
2159
|
+
const Ne = /* @__PURE__ */ new WeakMap();
|
|
2119
2160
|
function un(t) {
|
|
2120
2161
|
const e = window.__plunoProductAgentNetworkCapture ?? dn();
|
|
2121
2162
|
return e.subscribers.add(t), () => {
|
|
@@ -2139,22 +2180,22 @@ function dn() {
|
|
|
2139
2180
|
throw T;
|
|
2140
2181
|
}
|
|
2141
2182
|
try {
|
|
2142
|
-
const T = f instanceof Request ? f : null,
|
|
2143
|
-
if (!
|
|
2144
|
-
const
|
|
2145
|
-
requestId:
|
|
2146
|
-
url:
|
|
2183
|
+
const T = f instanceof Request ? f : null, k = Jr(f, T), m = is(u?.headers ?? T?.headers);
|
|
2184
|
+
if (!V(k, m, u?.body)) {
|
|
2185
|
+
const U = {
|
|
2186
|
+
requestId: We("fetch"),
|
|
2187
|
+
url: x(k, qe),
|
|
2147
2188
|
method: (u?.method ?? T?.method ?? "GET").toUpperCase(),
|
|
2148
2189
|
requestHeaders: m,
|
|
2149
|
-
requestBody:
|
|
2190
|
+
requestBody: Lt(u?.body),
|
|
2150
2191
|
resourceType: "fetch",
|
|
2151
2192
|
startedAt: new Date(d).toISOString()
|
|
2152
2193
|
};
|
|
2153
2194
|
g.then(
|
|
2154
2195
|
(D) => {
|
|
2155
|
-
|
|
2196
|
+
Yr(D, U, d, e).catch(() => {
|
|
2156
2197
|
e({
|
|
2157
|
-
|
|
2198
|
+
...U,
|
|
2158
2199
|
responseStatus: D.status,
|
|
2159
2200
|
durationMs: Date.now() - d
|
|
2160
2201
|
});
|
|
@@ -2162,8 +2203,8 @@ function dn() {
|
|
|
2162
2203
|
},
|
|
2163
2204
|
(D) => {
|
|
2164
2205
|
e({
|
|
2165
|
-
|
|
2166
|
-
errorText:
|
|
2206
|
+
...U,
|
|
2207
|
+
errorText: x(D instanceof Error ? D.message : String(D)),
|
|
2167
2208
|
durationMs: Date.now() - d
|
|
2168
2209
|
});
|
|
2169
2210
|
}
|
|
@@ -2173,28 +2214,28 @@ function dn() {
|
|
|
2173
2214
|
}
|
|
2174
2215
|
return g;
|
|
2175
2216
|
}, a = function(f, u, d, g, T) {
|
|
2176
|
-
const
|
|
2177
|
-
return
|
|
2178
|
-
requestId:
|
|
2217
|
+
const k = n.call(this, f, u, d ?? !0, g ?? void 0, T ?? void 0), m = typeof u == "string" ? u : u.toString();
|
|
2218
|
+
return Ne.set(this, {
|
|
2219
|
+
requestId: We("xhr"),
|
|
2179
2220
|
method: String(f ?? "GET").toUpperCase(),
|
|
2180
|
-
url:
|
|
2221
|
+
url: x(m, qe),
|
|
2181
2222
|
requestHeaders: {},
|
|
2182
2223
|
startedAtMs: Date.now(),
|
|
2183
2224
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2184
|
-
excluded:
|
|
2185
|
-
}),
|
|
2225
|
+
excluded: V(m)
|
|
2226
|
+
}), k;
|
|
2186
2227
|
}, l = function(f, u) {
|
|
2187
|
-
const d = r.call(this, f, u), g =
|
|
2188
|
-
return g && Object.keys(g.requestHeaders).length < Ze && (g.requestHeaders[f] = nt(f, u), g.excluded = g.excluded ||
|
|
2228
|
+
const d = r.call(this, f, u), g = Ne.get(this);
|
|
2229
|
+
return g && Object.keys(g.requestHeaders).length < Ze && (g.requestHeaders[f] = nt(f, u), g.excluded = g.excluded || V(g.url, g.requestHeaders)), d;
|
|
2189
2230
|
}, c = function(f) {
|
|
2190
2231
|
try {
|
|
2191
|
-
const u =
|
|
2192
|
-
u && (u.excluded = u.excluded ||
|
|
2232
|
+
const u = Ne.get(this);
|
|
2233
|
+
u && (u.excluded = u.excluded || V(u.url, u.requestHeaders, f), u.requestBody = Lt(f), u.excluded || this.addEventListener(
|
|
2193
2234
|
"loadend",
|
|
2194
2235
|
() => {
|
|
2195
2236
|
queueMicrotask(() => {
|
|
2196
2237
|
try {
|
|
2197
|
-
const d =
|
|
2238
|
+
const d = ni(this.getAllResponseHeaders());
|
|
2198
2239
|
e({
|
|
2199
2240
|
requestId: u.requestId,
|
|
2200
2241
|
url: u.url,
|
|
@@ -2204,7 +2245,7 @@ function dn() {
|
|
|
2204
2245
|
resourceType: "xhr",
|
|
2205
2246
|
responseStatus: this.status,
|
|
2206
2247
|
responseHeaders: d,
|
|
2207
|
-
responseBody:
|
|
2248
|
+
responseBody: Zr(this, d),
|
|
2208
2249
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2209
2250
|
startedAt: u.startedAt,
|
|
2210
2251
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -2241,12 +2282,12 @@ function dn() {
|
|
|
2241
2282
|
h = new PerformanceObserver((I) => {
|
|
2242
2283
|
for (const f of I.getEntries()) {
|
|
2243
2284
|
const u = f;
|
|
2244
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
2285
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || V(u.name))
|
|
2245
2286
|
continue;
|
|
2246
2287
|
const d = performance.timeOrigin + u.startTime;
|
|
2247
2288
|
e({
|
|
2248
|
-
requestId:
|
|
2249
|
-
url:
|
|
2289
|
+
requestId: We("resource"),
|
|
2290
|
+
url: x(u.name, qe),
|
|
2250
2291
|
method: "GET",
|
|
2251
2292
|
resourceType: "resource",
|
|
2252
2293
|
responseStatus: u.responseStatus,
|
|
@@ -2306,7 +2347,7 @@ function hn(t) {
|
|
|
2306
2347
|
function pn(t) {
|
|
2307
2348
|
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";
|
|
2308
2349
|
}
|
|
2309
|
-
function
|
|
2350
|
+
function ue(t) {
|
|
2310
2351
|
if (typeof t.sessionId == "string")
|
|
2311
2352
|
return t.sessionId;
|
|
2312
2353
|
if (t.session && typeof t.session == "object") {
|
|
@@ -2433,7 +2474,7 @@ async function Rt(t, e) {
|
|
|
2433
2474
|
o = window.setTimeout(() => p(c), n);
|
|
2434
2475
|
})
|
|
2435
2476
|
]);
|
|
2436
|
-
return h === c ?
|
|
2477
|
+
return h === c ? Cn(n) : {
|
|
2437
2478
|
ok: !0,
|
|
2438
2479
|
result: h,
|
|
2439
2480
|
console: i,
|
|
@@ -2462,7 +2503,7 @@ async function Rt(t, e) {
|
|
|
2462
2503
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2463
2504
|
}
|
|
2464
2505
|
}
|
|
2465
|
-
function
|
|
2506
|
+
function kn(t, e) {
|
|
2466
2507
|
if (!t || typeof t != "object")
|
|
2467
2508
|
return;
|
|
2468
2509
|
const s = t.sandboxFilesToken;
|
|
@@ -2472,7 +2513,7 @@ function Cn(t, e) {
|
|
|
2472
2513
|
const r = () => {
|
|
2473
2514
|
if (!n)
|
|
2474
2515
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2475
|
-
}, i = async (a, l) => await
|
|
2516
|
+
}, i = async (a, l) => await qs(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2476
2517
|
return {
|
|
2477
2518
|
value: Object.freeze({
|
|
2478
2519
|
upload: async (a) => {
|
|
@@ -2506,7 +2547,7 @@ function Cn(t, e) {
|
|
|
2506
2547
|
}
|
|
2507
2548
|
};
|
|
2508
2549
|
}
|
|
2509
|
-
function
|
|
2550
|
+
function Cn(t) {
|
|
2510
2551
|
return {
|
|
2511
2552
|
ok: !1,
|
|
2512
2553
|
exception: {
|
|
@@ -2545,7 +2586,7 @@ function Dn(t) {
|
|
|
2545
2586
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2546
2587
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2547
2588
|
}
|
|
2548
|
-
function
|
|
2589
|
+
function b() {
|
|
2549
2590
|
const t = Gt();
|
|
2550
2591
|
return {
|
|
2551
2592
|
url: location.href,
|
|
@@ -2562,13 +2603,13 @@ function vn() {
|
|
|
2562
2603
|
};
|
|
2563
2604
|
}
|
|
2564
2605
|
function On(t) {
|
|
2565
|
-
return
|
|
2566
|
-
|
|
2606
|
+
return me.add(t), ce || (ce = Ln()), () => {
|
|
2607
|
+
me.delete(t), me.size === 0 && (ce?.(), ce = null);
|
|
2567
2608
|
};
|
|
2568
2609
|
}
|
|
2569
|
-
function
|
|
2610
|
+
function Ln() {
|
|
2570
2611
|
const t = () => {
|
|
2571
|
-
for (const i of Array.from(
|
|
2612
|
+
for (const i of Array.from(me))
|
|
2572
2613
|
i();
|
|
2573
2614
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2574
2615
|
const o = e(...i);
|
|
@@ -2581,14 +2622,14 @@ function qn() {
|
|
|
2581
2622
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2582
2623
|
};
|
|
2583
2624
|
}
|
|
2584
|
-
function
|
|
2625
|
+
function de() {
|
|
2585
2626
|
return Gt()?.surface === "browser_extension_sdk_preview";
|
|
2586
2627
|
}
|
|
2587
2628
|
function et() {
|
|
2588
2629
|
if (!document.body)
|
|
2589
2630
|
return "";
|
|
2590
2631
|
const t = [], e = [], s = (d, g) => {
|
|
2591
|
-
const T =
|
|
2632
|
+
const T = Y(g);
|
|
2592
2633
|
!T || e.includes(T) || (t.push([d, T]), e.push(T));
|
|
2593
2634
|
};
|
|
2594
2635
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
@@ -2596,9 +2637,9 @@ function et() {
|
|
|
2596
2637
|
(d) => Ft(d) && !d.parentElement?.closest(n)
|
|
2597
2638
|
);
|
|
2598
2639
|
for (const d of r.slice(0, 3))
|
|
2599
|
-
s("Active overlay",
|
|
2600
|
-
const i =
|
|
2601
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2640
|
+
s("Active overlay", xe(oe(d), e));
|
|
2641
|
+
const i = qn(), o = i ? xe(oe(i), e) : "";
|
|
2642
|
+
s("Main page content", o), s("Additional visible page text", xe(oe(document.body), e));
|
|
2602
2643
|
const a = t.map(([d, g]) => `${d}:
|
|
2603
2644
|
${g}`).join(`
|
|
2604
2645
|
|
|
@@ -2609,10 +2650,10 @@ Visible page text:
|
|
|
2609
2650
|
`, p = 12e3 - c.length - h.length, I = Math.min(a.length, 7900), f = l.slice(0, p - I), u = a.slice(0, p - f.length);
|
|
2610
2651
|
return `${c}${f}${h}${u}`;
|
|
2611
2652
|
}
|
|
2612
|
-
function
|
|
2653
|
+
function oe(t) {
|
|
2613
2654
|
return t.innerText ?? t.textContent ?? "";
|
|
2614
2655
|
}
|
|
2615
|
-
function
|
|
2656
|
+
function Y(t) {
|
|
2616
2657
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2617
2658
|
`).split(`
|
|
2618
2659
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2620,18 +2661,18 @@ function J(t) {
|
|
|
2620
2661
|
|
|
2621
2662
|
`).trim();
|
|
2622
2663
|
}
|
|
2623
|
-
function
|
|
2624
|
-
let s =
|
|
2664
|
+
function xe(t, e) {
|
|
2665
|
+
let s = Y(t);
|
|
2625
2666
|
for (const n of e)
|
|
2626
2667
|
s = s.replace(n, "");
|
|
2627
|
-
return
|
|
2668
|
+
return Y(s);
|
|
2628
2669
|
}
|
|
2629
2670
|
function Ft(t) {
|
|
2630
2671
|
const e = window.getComputedStyle(t);
|
|
2631
2672
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2632
2673
|
}
|
|
2633
|
-
function
|
|
2634
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ft).sort((t, e) =>
|
|
2674
|
+
function qn() {
|
|
2675
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ft).sort((t, e) => oe(e).length - oe(t).length)[0] ?? null;
|
|
2635
2676
|
}
|
|
2636
2677
|
function Nn(t, e) {
|
|
2637
2678
|
const s = /* @__PURE__ */ new Set([
|
|
@@ -2717,73 +2758,73 @@ function Nn(t, e) {
|
|
|
2717
2758
|
e && I.add(e);
|
|
2718
2759
|
let f = 0;
|
|
2719
2760
|
const u = (m) => {
|
|
2720
|
-
const
|
|
2721
|
-
return
|
|
2761
|
+
const w = m.getAttribute("role");
|
|
2762
|
+
return w && !o.has(w) ? w : "";
|
|
2722
2763
|
}, d = (m) => {
|
|
2723
|
-
const
|
|
2724
|
-
return `${m.tagName.toLowerCase()}|${u(m)}|${
|
|
2725
|
-
}, g = (m,
|
|
2726
|
-
const D = (R,
|
|
2727
|
-
const
|
|
2728
|
-
if (f >= 1e3 && !
|
|
2764
|
+
const w = m.getAttribute("data-testid") || m.getAttribute("data-test") || m.getAttribute("data-qa") || m.getAttribute("data-cy") || "";
|
|
2765
|
+
return `${m.tagName.toLowerCase()}|${u(m)}|${w}`;
|
|
2766
|
+
}, g = (m, w, U) => {
|
|
2767
|
+
const D = (R, ee) => {
|
|
2768
|
+
const C = R.tagName.toLowerCase(), te = window.getComputedStyle(R), z = h.has(R);
|
|
2769
|
+
if (f >= 1e3 && !z || U.has(R) || i.has(C) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || te.display === "none" || te.visibility === "hidden")
|
|
2729
2770
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2730
2771
|
f += 1;
|
|
2731
|
-
const
|
|
2732
|
-
for (const y of
|
|
2772
|
+
const H = u(R), K = Kt(R), rt = a.has(H) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(C) || C === "a" && R.hasAttribute("href"), X = Array.from(R.children).filter((y) => y instanceof HTMLElement), q = /* @__PURE__ */ new Map();
|
|
2773
|
+
for (const y of X) {
|
|
2733
2774
|
const M = d(y);
|
|
2734
|
-
|
|
2775
|
+
q.set(M, (q.get(M) ?? 0) + 1);
|
|
2735
2776
|
}
|
|
2736
|
-
const
|
|
2737
|
-
for (const y of
|
|
2738
|
-
const M = d(y),
|
|
2739
|
-
|
|
2777
|
+
const E = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map();
|
|
2778
|
+
for (const y of X) {
|
|
2779
|
+
const M = d(y), $ = O.get(M) ?? 0;
|
|
2780
|
+
O.set(M, $ + 1), (q.get(M) ?? 0) > 8 && $ >= 6 && !h.has(y) && E.set(M, (E.get(M) ?? 0) + 1);
|
|
2740
2781
|
}
|
|
2741
|
-
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(),
|
|
2742
|
-
for (const y of
|
|
2743
|
-
const M = d(y),
|
|
2744
|
-
if (it.set(M, ut + 1),
|
|
2745
|
-
ot.has(M) || (
|
|
2782
|
+
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(), ke = [], at = [];
|
|
2783
|
+
for (const y of X) {
|
|
2784
|
+
const M = d(y), $ = q.get(M) ?? 0, ut = it.get(M) ?? 0;
|
|
2785
|
+
if (it.set(M, ut + 1), $ > 8 && ut >= 6 && !h.has(y)) {
|
|
2786
|
+
ot.has(M) || (ke.push([`… ${E.get(M) ?? 0} similar siblings omitted`]), ot.add(M));
|
|
2746
2787
|
continue;
|
|
2747
2788
|
}
|
|
2748
|
-
const dt = D(y,
|
|
2749
|
-
at.push(dt),
|
|
2789
|
+
const dt = D(y, ee);
|
|
2790
|
+
at.push(dt), ke.push(dt.lines);
|
|
2750
2791
|
}
|
|
2751
|
-
const
|
|
2792
|
+
const Ce = [];
|
|
2752
2793
|
if (R.shadowRoot)
|
|
2753
2794
|
for (const y of Array.from(R.shadowRoot.children))
|
|
2754
|
-
y instanceof HTMLElement &&
|
|
2755
|
-
const
|
|
2756
|
-
[
|
|
2757
|
-
).slice(0, 180), ps = R.hasAttribute("contenteditable") && (
|
|
2758
|
-
if (
|
|
2759
|
-
const y =
|
|
2760
|
-
|
|
2795
|
+
y instanceof HTMLElement && Ce.push(D(y, ee + 1));
|
|
2796
|
+
const le = [...at, ...Ce], _e = K.length > 0 || rt || le.some((y) => y.hasUsefulContent), lt = Y(
|
|
2797
|
+
[K, ...le.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2798
|
+
).slice(0, 180), ps = R.hasAttribute("contenteditable") && (K.length > 0 || !R.querySelector("[contenteditable]")), ct = c.some((y) => R.hasAttribute(y)) || !!H || ps, be = (R.getClientRects().length > 0 || te.display === "contents") && (s.has(C) || ct || z) && (_e || z) && (!r.has(C) || _e || ct || z), Pe = be ? 1 : 0, se = [];
|
|
2799
|
+
if (be) {
|
|
2800
|
+
const y = le.some(($) => $.containsTextElement), M = n.has(C) && !y ? lt : K;
|
|
2801
|
+
se.push(zt(R, l, o, M.slice(0, 180)));
|
|
2761
2802
|
}
|
|
2762
|
-
for (const y of
|
|
2763
|
-
|
|
2764
|
-
const
|
|
2765
|
-
if (
|
|
2766
|
-
const y =
|
|
2767
|
-
|
|
2768
|
-
const M =
|
|
2769
|
-
if (
|
|
2770
|
-
const
|
|
2771
|
-
|
|
2803
|
+
for (const y of ke)
|
|
2804
|
+
se.push(...he(y, Pe));
|
|
2805
|
+
const Ue = Ce.flatMap((y) => y.lines);
|
|
2806
|
+
if (Ue.length > 0) {
|
|
2807
|
+
const y = Ue.slice(0, 20);
|
|
2808
|
+
Ue.length > y.length && y.push("… shadow DOM omitted");
|
|
2809
|
+
const M = C.includes("tooltip") || C.includes("popper") || C.includes("loader");
|
|
2810
|
+
if (ee < 2 && !M) {
|
|
2811
|
+
const $ = be ? "#shadow-root" : `${C} #shadow-root`;
|
|
2812
|
+
se.push(...he([$, ...he(y, 1)], Pe));
|
|
2772
2813
|
} else
|
|
2773
|
-
|
|
2814
|
+
se.push(...he(y, Pe));
|
|
2774
2815
|
}
|
|
2775
2816
|
return {
|
|
2776
|
-
lines:
|
|
2777
|
-
hasUsefulContent:
|
|
2817
|
+
lines: se,
|
|
2818
|
+
hasUsefulContent: _e,
|
|
2778
2819
|
textPreview: lt,
|
|
2779
|
-
containsTextElement: n.has(
|
|
2820
|
+
containsTextElement: n.has(C) || le.some((y) => y.containsTextElement)
|
|
2780
2821
|
};
|
|
2781
2822
|
};
|
|
2782
|
-
return [`--- ${
|
|
2823
|
+
return [`--- ${w} ---`, ...D(m, 0).lines].join(`
|
|
2783
2824
|
`);
|
|
2784
|
-
}, T = [],
|
|
2785
|
-
|
|
2786
|
-
${JSON.stringify(
|
|
2825
|
+
}, T = [], k = Y(window.getSelection()?.toString() ?? "");
|
|
2826
|
+
k && T.push(`--- selected text ---
|
|
2827
|
+
${JSON.stringify(k)}`), p.length > 0 && T.push(Bn(p, s, l, o));
|
|
2787
2828
|
for (const m of t.slice(0, 3))
|
|
2788
2829
|
T.push(g(m, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2789
2830
|
if (e && T.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2879,14 +2920,14 @@ function Bn(t, e, s, n) {
|
|
|
2879
2920
|
function Et(t) {
|
|
2880
2921
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
2881
2922
|
}
|
|
2882
|
-
function
|
|
2923
|
+
function he(t, e) {
|
|
2883
2924
|
if (e === 0)
|
|
2884
2925
|
return t;
|
|
2885
2926
|
const s = " ".repeat(e);
|
|
2886
2927
|
return t.map((n) => `${s}${n}`);
|
|
2887
2928
|
}
|
|
2888
2929
|
function Kt(t) {
|
|
2889
|
-
return
|
|
2930
|
+
return Y(
|
|
2890
2931
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
2891
2932
|
);
|
|
2892
2933
|
}
|
|
@@ -2895,7 +2936,7 @@ function Wn(t) {
|
|
|
2895
2936
|
}
|
|
2896
2937
|
function Gt() {
|
|
2897
2938
|
const t = document.querySelector(ht);
|
|
2898
|
-
if (!(t ?? document.querySelector(
|
|
2939
|
+
if (!(t ?? document.querySelector($e)))
|
|
2899
2940
|
return;
|
|
2900
2941
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2901
2942
|
return {
|
|
@@ -2904,7 +2945,7 @@ function Gt() {
|
|
|
2904
2945
|
selectors: [
|
|
2905
2946
|
{
|
|
2906
2947
|
name: "widget_host",
|
|
2907
|
-
selector: s === "browser_extension_sdk_preview" ? ht :
|
|
2948
|
+
selector: s === "browser_extension_sdk_preview" ? ht : $e,
|
|
2908
2949
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2909
2950
|
},
|
|
2910
2951
|
{
|
|
@@ -2943,7 +2984,7 @@ function $n(t) {
|
|
|
2943
2984
|
return null;
|
|
2944
2985
|
}
|
|
2945
2986
|
}
|
|
2946
|
-
function
|
|
2987
|
+
function kt(t, e) {
|
|
2947
2988
|
if (!t || typeof t != "object")
|
|
2948
2989
|
return [];
|
|
2949
2990
|
const s = t[e];
|
|
@@ -2992,7 +3033,7 @@ function Xn() {
|
|
|
2992
3033
|
const s = crypto.randomUUID();
|
|
2993
3034
|
return window.localStorage.setItem(t, s), s;
|
|
2994
3035
|
}
|
|
2995
|
-
function
|
|
3036
|
+
function j() {
|
|
2996
3037
|
return crypto.randomUUID();
|
|
2997
3038
|
}
|
|
2998
3039
|
function Vn(t) {
|
|
@@ -3006,7 +3047,7 @@ function Vn(t) {
|
|
|
3006
3047
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
3007
3048
|
} : null;
|
|
3008
3049
|
}
|
|
3009
|
-
function
|
|
3050
|
+
function Ct(t, e) {
|
|
3010
3051
|
return Array.isArray(t) ? Ge(
|
|
3011
3052
|
t.map((s) => Xt(s, e)).filter((s) => s !== null)
|
|
3012
3053
|
) : [];
|
|
@@ -3015,13 +3056,13 @@ function Jn(t) {
|
|
|
3015
3056
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3016
3057
|
if (!e || typeof e != "object")
|
|
3017
3058
|
return [];
|
|
3018
|
-
const s = e, n =
|
|
3059
|
+
const s = e, n = S(s, "id"), r = S(s, "createdAt"), i = S(s, "updatedAt"), o = S(s, "lastActiveAt");
|
|
3019
3060
|
return !n || !r || !i || !o ? [] : [
|
|
3020
3061
|
{
|
|
3021
3062
|
id: n,
|
|
3022
|
-
title:
|
|
3023
|
-
customTitle:
|
|
3024
|
-
firstUserMessage:
|
|
3063
|
+
title: S(s, "title"),
|
|
3064
|
+
customTitle: S(s, "customTitle"),
|
|
3065
|
+
firstUserMessage: S(s, "firstUserMessage"),
|
|
3025
3066
|
currentPage: s.currentPage ?? null,
|
|
3026
3067
|
createdAt: r,
|
|
3027
3068
|
updatedAt: i,
|
|
@@ -3052,7 +3093,7 @@ function Xt(t, e) {
|
|
|
3052
3093
|
),
|
|
3053
3094
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3054
3095
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3055
|
-
respondsToUserMessageId:
|
|
3096
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3056
3097
|
..._(r) ? { runId: _(r) } : {},
|
|
3057
3098
|
attachments: ss(r.attachments, e)
|
|
3058
3099
|
};
|
|
@@ -3065,18 +3106,18 @@ function Xt(t, e) {
|
|
|
3065
3106
|
}), o;
|
|
3066
3107
|
}
|
|
3067
3108
|
if (r.type === "function_call_output") {
|
|
3068
|
-
const i =
|
|
3109
|
+
const i = Ls(r.output);
|
|
3069
3110
|
if (i)
|
|
3070
3111
|
return {
|
|
3071
3112
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3072
3113
|
role: "tool",
|
|
3073
3114
|
content: "",
|
|
3074
3115
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3075
|
-
respondsToUserMessageId:
|
|
3116
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3076
3117
|
..._(r) ? { runId: _(r) } : {},
|
|
3077
3118
|
dataType: "scheduled_check_in",
|
|
3078
3119
|
toolName: Bt,
|
|
3079
|
-
callId:
|
|
3120
|
+
callId: pe(r) ?? void 0,
|
|
3080
3121
|
scheduledCheckInAt: i
|
|
3081
3122
|
};
|
|
3082
3123
|
const o = Qn(r.output), a = Zn(r.output);
|
|
@@ -3086,11 +3127,11 @@ function Xt(t, e) {
|
|
|
3086
3127
|
content: `Connect ${o.appName} to continue`,
|
|
3087
3128
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3088
3129
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3089
|
-
respondsToUserMessageId:
|
|
3130
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3090
3131
|
..._(r) ? { runId: _(r) } : {},
|
|
3091
3132
|
dataType: "function_call_output",
|
|
3092
3133
|
toolName: "authenticate_pipedream_app",
|
|
3093
|
-
callId:
|
|
3134
|
+
callId: pe(r) ?? void 0,
|
|
3094
3135
|
integrationAuthRequest: o
|
|
3095
3136
|
} : a ? {
|
|
3096
3137
|
id: String(s.id ?? crypto.randomUUID()),
|
|
@@ -3098,11 +3139,11 @@ function Xt(t, e) {
|
|
|
3098
3139
|
content: "Connect WhatsApp to continue",
|
|
3099
3140
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3100
3141
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3101
|
-
respondsToUserMessageId:
|
|
3142
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3102
3143
|
..._(r) ? { runId: _(r) } : {},
|
|
3103
3144
|
dataType: "function_call_output",
|
|
3104
3145
|
toolName: "request_personal_channel_connection",
|
|
3105
|
-
callId:
|
|
3146
|
+
callId: pe(r) ?? void 0,
|
|
3106
3147
|
personalChannelConnectionRequest: a
|
|
3107
3148
|
} : null;
|
|
3108
3149
|
}
|
|
@@ -3112,11 +3153,11 @@ function Xt(t, e) {
|
|
|
3112
3153
|
content: r.type === "mcp_call" ? Yn(r) : tr(r),
|
|
3113
3154
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3114
3155
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3115
|
-
respondsToUserMessageId:
|
|
3156
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3116
3157
|
..._(r) ? { runId: _(r) } : {},
|
|
3117
3158
|
dataType: String(r.type),
|
|
3118
3159
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
3119
|
-
callId:
|
|
3160
|
+
callId: pe(r) ?? void 0,
|
|
3120
3161
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
3121
3162
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
3122
3163
|
id: String(s.id ?? crypto.randomUUID()),
|
|
@@ -3124,7 +3165,7 @@ function Xt(t, e) {
|
|
|
3124
3165
|
content: er(r),
|
|
3125
3166
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3126
3167
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3127
|
-
respondsToUserMessageId:
|
|
3168
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3128
3169
|
..._(r) ? { runId: _(r) } : {},
|
|
3129
3170
|
dataType: String(r.type),
|
|
3130
3171
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -3188,18 +3229,18 @@ function tr(t) {
|
|
|
3188
3229
|
}
|
|
3189
3230
|
function sr(t) {
|
|
3190
3231
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3191
|
-
return
|
|
3232
|
+
return J(t.summary);
|
|
3192
3233
|
if (typeof t.arguments == "string")
|
|
3193
3234
|
try {
|
|
3194
3235
|
const e = JSON.parse(t.arguments);
|
|
3195
3236
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
3196
|
-
return
|
|
3237
|
+
return J(e.summary);
|
|
3197
3238
|
} catch {
|
|
3198
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3239
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? J(t.name) : "🛠️ Run tool";
|
|
3199
3240
|
}
|
|
3200
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3241
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? J(t.name) : "🛠️ Run tool";
|
|
3201
3242
|
}
|
|
3202
|
-
function
|
|
3243
|
+
function J(t) {
|
|
3203
3244
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3204
3245
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3205
3246
|
}
|
|
@@ -3218,7 +3259,7 @@ function nr(t) {
|
|
|
3218
3259
|
runId: typeof e.runId == "string" ? e.runId : null
|
|
3219
3260
|
};
|
|
3220
3261
|
}
|
|
3221
|
-
function
|
|
3262
|
+
function pe(t) {
|
|
3222
3263
|
const e = t.callId ?? t.call_id;
|
|
3223
3264
|
return typeof e == "string" && e ? e : null;
|
|
3224
3265
|
}
|
|
@@ -3233,7 +3274,7 @@ function rr(t) {
|
|
|
3233
3274
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
3234
3275
|
}).filter(Boolean).join("") : "";
|
|
3235
3276
|
}
|
|
3236
|
-
function
|
|
3277
|
+
function Fe(t, e) {
|
|
3237
3278
|
const s = Jt(t, e), n = ur(
|
|
3238
3279
|
ir(
|
|
3239
3280
|
fr(t, e),
|
|
@@ -3254,7 +3295,7 @@ function ir(t, e) {
|
|
|
3254
3295
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
3255
3296
|
) : t;
|
|
3256
3297
|
}
|
|
3257
|
-
function
|
|
3298
|
+
function Be(t, e, s) {
|
|
3258
3299
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3259
3300
|
}
|
|
3260
3301
|
function or(t, e, s, n) {
|
|
@@ -3279,7 +3320,7 @@ function ar(t, e) {
|
|
|
3279
3320
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3280
3321
|
);
|
|
3281
3322
|
if (s === -1)
|
|
3282
|
-
return
|
|
3323
|
+
return Fe(t, e);
|
|
3283
3324
|
const n = [...t];
|
|
3284
3325
|
return n[s] = {
|
|
3285
3326
|
...n[s],
|
|
@@ -3303,7 +3344,7 @@ function cr(t) {
|
|
|
3303
3344
|
return !e || !s ? null : {
|
|
3304
3345
|
id: `transient-activity:${e}`,
|
|
3305
3346
|
role: "tool",
|
|
3306
|
-
content:
|
|
3347
|
+
content: J(
|
|
3307
3348
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3308
3349
|
),
|
|
3309
3350
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3342,7 +3383,7 @@ function hr(t, e, s) {
|
|
|
3342
3383
|
];
|
|
3343
3384
|
}
|
|
3344
3385
|
function Vt(t) {
|
|
3345
|
-
const e =
|
|
3386
|
+
const e = Q(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3346
3387
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3347
3388
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3348
3389
|
];
|
|
@@ -3353,7 +3394,7 @@ function Vt(t) {
|
|
|
3353
3394
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3354
3395
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3355
3396
|
...t.runId ? { runId: t.runId } : {},
|
|
3356
|
-
isOptimistic:
|
|
3397
|
+
isOptimistic: Re(t),
|
|
3357
3398
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3358
3399
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3359
3400
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
@@ -3363,7 +3404,7 @@ function Jt(t, e) {
|
|
|
3363
3404
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3364
3405
|
return e;
|
|
3365
3406
|
const s = t.find(
|
|
3366
|
-
(r) => r.role === "user" && (r.id === e.id ||
|
|
3407
|
+
(r) => r.role === "user" && (r.id === e.id || Re(r) && Yt(r, e))
|
|
3367
3408
|
);
|
|
3368
3409
|
if (!s?.attachments?.length)
|
|
3369
3410
|
return e;
|
|
@@ -3384,7 +3425,7 @@ function fr(t, e) {
|
|
|
3384
3425
|
if (e.role !== "user")
|
|
3385
3426
|
return t;
|
|
3386
3427
|
const s = t.findIndex(
|
|
3387
|
-
(r) =>
|
|
3428
|
+
(r) => Re(r) && Yt(r, e)
|
|
3388
3429
|
);
|
|
3389
3430
|
if (s === -1)
|
|
3390
3431
|
return t;
|
|
@@ -3392,13 +3433,13 @@ function fr(t, e) {
|
|
|
3392
3433
|
return n.splice(s, 1), n;
|
|
3393
3434
|
}
|
|
3394
3435
|
function Yt(t, e) {
|
|
3395
|
-
const s =
|
|
3436
|
+
const s = Q(t), n = Q(e);
|
|
3396
3437
|
return s && n ? s === n : t.content === e.content;
|
|
3397
3438
|
}
|
|
3398
|
-
function
|
|
3439
|
+
function Re(t) {
|
|
3399
3440
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3400
3441
|
}
|
|
3401
|
-
function
|
|
3442
|
+
function Q(t) {
|
|
3402
3443
|
const e = t.clientMessageId;
|
|
3403
3444
|
if (e)
|
|
3404
3445
|
return e;
|
|
@@ -3413,13 +3454,13 @@ function _t(t) {
|
|
|
3413
3454
|
return !1;
|
|
3414
3455
|
const s = t[e].id;
|
|
3415
3456
|
if (t.some(
|
|
3416
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3457
|
+
(r) => r.respondsToUserMessageId === s && Te(r)
|
|
3417
3458
|
))
|
|
3418
3459
|
return !0;
|
|
3419
3460
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3420
3461
|
const i = t[r];
|
|
3421
3462
|
if (!i.respondsToUserMessageId) {
|
|
3422
|
-
if (
|
|
3463
|
+
if (B(i))
|
|
3423
3464
|
return !0;
|
|
3424
3465
|
if (i.role === "system") {
|
|
3425
3466
|
if (i.dataType === "run_error")
|
|
@@ -3434,7 +3475,7 @@ function _t(t) {
|
|
|
3434
3475
|
function mr(t, e, s) {
|
|
3435
3476
|
const n = new Set(
|
|
3436
3477
|
t.filter(
|
|
3437
|
-
(r) => r.role === "user" && e !== null &&
|
|
3478
|
+
(r) => r.role === "user" && e !== null && Q(r) === e
|
|
3438
3479
|
).map((r) => r.id)
|
|
3439
3480
|
);
|
|
3440
3481
|
return t.some((r, i) => {
|
|
@@ -3454,22 +3495,22 @@ function mr(t, e, s) {
|
|
|
3454
3495
|
function yr(t) {
|
|
3455
3496
|
const e = Qt(t);
|
|
3456
3497
|
if (e === null)
|
|
3457
|
-
return t.some(
|
|
3498
|
+
return t.some(B);
|
|
3458
3499
|
const s = t[e].id;
|
|
3459
3500
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3460
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3461
|
-
) : t.slice(e + 1).some(
|
|
3501
|
+
(n) => n.respondsToUserMessageId === s && B(n)
|
|
3502
|
+
) : t.slice(e + 1).some(B);
|
|
3462
3503
|
}
|
|
3463
3504
|
function Qt(t) {
|
|
3464
3505
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3465
|
-
if (t[e].role === "user" && !
|
|
3506
|
+
if (t[e].role === "user" && !Re(t[e]))
|
|
3466
3507
|
return e;
|
|
3467
3508
|
return null;
|
|
3468
3509
|
}
|
|
3469
|
-
function
|
|
3470
|
-
return
|
|
3510
|
+
function Te(t) {
|
|
3511
|
+
return B(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3471
3512
|
}
|
|
3472
|
-
function
|
|
3513
|
+
function Z(t) {
|
|
3473
3514
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
3474
3515
|
const s = t[e];
|
|
3475
3516
|
if (!s || typeof s != "object")
|
|
@@ -3484,29 +3525,29 @@ function Q(t) {
|
|
|
3484
3525
|
return null;
|
|
3485
3526
|
}
|
|
3486
3527
|
function Ir(t) {
|
|
3487
|
-
const e =
|
|
3528
|
+
const e = Z(t);
|
|
3488
3529
|
if (e === null)
|
|
3489
3530
|
return null;
|
|
3490
|
-
const n =
|
|
3531
|
+
const n = P(t[e])?.page;
|
|
3491
3532
|
if (!n || typeof n != "object")
|
|
3492
3533
|
return null;
|
|
3493
3534
|
const r = n.url;
|
|
3494
3535
|
return typeof r == "string" ? r : null;
|
|
3495
3536
|
}
|
|
3496
|
-
function
|
|
3537
|
+
function P(t) {
|
|
3497
3538
|
if (!t || typeof t != "object")
|
|
3498
3539
|
return null;
|
|
3499
3540
|
const e = t.data;
|
|
3500
3541
|
return e && typeof e == "object" ? e : null;
|
|
3501
3542
|
}
|
|
3502
|
-
function
|
|
3543
|
+
function Se(t) {
|
|
3503
3544
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3504
3545
|
}
|
|
3505
3546
|
function bt(t) {
|
|
3506
3547
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3507
3548
|
}
|
|
3508
3549
|
function Tr(t, e) {
|
|
3509
|
-
const s =
|
|
3550
|
+
const s = Z(e);
|
|
3510
3551
|
if (s === null)
|
|
3511
3552
|
return !1;
|
|
3512
3553
|
const n = e[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -3514,11 +3555,11 @@ function Tr(t, e) {
|
|
|
3514
3555
|
return !1;
|
|
3515
3556
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3516
3557
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3517
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3518
|
-
) : t.slice(i + 1).some(
|
|
3558
|
+
(o) => o.respondsToUserMessageId === r && Te(o)
|
|
3559
|
+
) : t.slice(i + 1).some(Te);
|
|
3519
3560
|
}
|
|
3520
3561
|
function ze(t) {
|
|
3521
|
-
const e =
|
|
3562
|
+
const e = Z(t);
|
|
3522
3563
|
if (e === null)
|
|
3523
3564
|
return null;
|
|
3524
3565
|
const s = t[e];
|
|
@@ -3531,7 +3572,7 @@ function ze(t) {
|
|
|
3531
3572
|
return typeof r == "string" ? r : null;
|
|
3532
3573
|
}
|
|
3533
3574
|
function Sr(t) {
|
|
3534
|
-
const e =
|
|
3575
|
+
const e = Z(t);
|
|
3535
3576
|
if (e === null)
|
|
3536
3577
|
return null;
|
|
3537
3578
|
for (let s = t.length - 1; s > e; s -= 1) {
|
|
@@ -3554,10 +3595,10 @@ function Sr(t) {
|
|
|
3554
3595
|
function Ke(t, e) {
|
|
3555
3596
|
if (typeof e.clientMessageId == "string")
|
|
3556
3597
|
return e.clientMessageId;
|
|
3557
|
-
const s =
|
|
3598
|
+
const s = N(e);
|
|
3558
3599
|
if (!s)
|
|
3559
3600
|
return null;
|
|
3560
|
-
const n = t.find((i) =>
|
|
3601
|
+
const n = t.find((i) => S(i, "id") === s), r = P(n);
|
|
3561
3602
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3562
3603
|
}
|
|
3563
3604
|
function wr(t, e) {
|
|
@@ -3577,16 +3618,16 @@ function Pt(t, e, s, n, r, i) {
|
|
|
3577
3618
|
if (!e || !Ar(t))
|
|
3578
3619
|
return !1;
|
|
3579
3620
|
const o = t;
|
|
3580
|
-
if (
|
|
3621
|
+
if (Se(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3581
3622
|
return !1;
|
|
3582
|
-
const a =
|
|
3623
|
+
const a = N(o);
|
|
3583
3624
|
return n !== null ? a !== null ? a === n : r !== null && _(o) === r && i === n : r === null || _(o) === r;
|
|
3584
3625
|
}
|
|
3585
3626
|
function Mr(t, e) {
|
|
3586
3627
|
for (let s = e - 1; s >= 0; s -= 1) {
|
|
3587
|
-
const n =
|
|
3628
|
+
const n = P(t[s]);
|
|
3588
3629
|
if (n?.type === "message" && n.role === "user")
|
|
3589
|
-
return
|
|
3630
|
+
return S(t[s], "id");
|
|
3590
3631
|
}
|
|
3591
3632
|
return null;
|
|
3592
3633
|
}
|
|
@@ -3602,7 +3643,7 @@ function Ar(t) {
|
|
|
3602
3643
|
const e = t;
|
|
3603
3644
|
return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
|
|
3604
3645
|
}
|
|
3605
|
-
function
|
|
3646
|
+
function B(t) {
|
|
3606
3647
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3607
3648
|
}
|
|
3608
3649
|
function Rr(t) {
|
|
@@ -3612,51 +3653,54 @@ function Rr(t) {
|
|
|
3612
3653
|
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";
|
|
3613
3654
|
}
|
|
3614
3655
|
function Ge(t) {
|
|
3615
|
-
return t.filter((e, s) =>
|
|
3656
|
+
return t.filter((e, s) => F(e) ? !Lr(t, s) && !es(t, s) && !vr(t, s) && !Or(t, s) : Er(e) ? e.retryable === !0 && Dr(t, s) ? !1 : !Ur(t, s) : !0);
|
|
3616
3657
|
}
|
|
3617
3658
|
function Er(t) {
|
|
3618
3659
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3619
3660
|
}
|
|
3620
|
-
function
|
|
3661
|
+
function F(t) {
|
|
3621
3662
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3622
3663
|
}
|
|
3623
|
-
function
|
|
3664
|
+
function kr(t, e, s, n) {
|
|
3624
3665
|
const r = t.findIndex(
|
|
3625
|
-
(l, c) =>
|
|
3666
|
+
(l, c) => F(l) && !es(t, c)
|
|
3626
3667
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3627
3668
|
(l) => l.role === "user" && l.id === o
|
|
3628
3669
|
) : null;
|
|
3629
3670
|
return {
|
|
3630
|
-
clientMessageId: a ?
|
|
3671
|
+
clientMessageId: a ? Q(a) : o ? null : n,
|
|
3631
3672
|
respondsToUserMessageId: o,
|
|
3632
3673
|
runId: s ?? i?.runId ?? null
|
|
3633
3674
|
};
|
|
3634
3675
|
}
|
|
3635
|
-
function
|
|
3676
|
+
function ye(t) {
|
|
3636
3677
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3637
3678
|
}
|
|
3679
|
+
function Cr(t, e) {
|
|
3680
|
+
return B(e) ? "completed" : ye(t) ? "stopped" : !Se(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
|
|
3681
|
+
}
|
|
3638
3682
|
function Ut(t, e, s) {
|
|
3639
3683
|
const n = new Set(
|
|
3640
3684
|
t.filter(
|
|
3641
|
-
(r) => r.role === "user" && e !== null &&
|
|
3685
|
+
(r) => r.role === "user" && e !== null && Q(r) === e
|
|
3642
3686
|
).map((r) => r.id)
|
|
3643
3687
|
);
|
|
3644
3688
|
return t.filter(
|
|
3645
|
-
(r) => !
|
|
3689
|
+
(r) => !F(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3646
3690
|
);
|
|
3647
3691
|
}
|
|
3648
3692
|
function es(t, e) {
|
|
3649
3693
|
return t.some(
|
|
3650
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
3694
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && _r(
|
|
3651
3695
|
t,
|
|
3652
3696
|
e,
|
|
3653
3697
|
n
|
|
3654
3698
|
)
|
|
3655
3699
|
);
|
|
3656
3700
|
}
|
|
3657
|
-
function
|
|
3701
|
+
function _r(t, e, s) {
|
|
3658
3702
|
const n = t[e], r = t[s];
|
|
3659
|
-
if (
|
|
3703
|
+
if (ae(n, r))
|
|
3660
3704
|
return !0;
|
|
3661
3705
|
if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
|
|
3662
3706
|
return !1;
|
|
@@ -3665,9 +3709,9 @@ function kr(t, e, s) {
|
|
|
3665
3709
|
return t[i].id === n.respondsToUserMessageId;
|
|
3666
3710
|
return !1;
|
|
3667
3711
|
}
|
|
3668
|
-
function
|
|
3712
|
+
function br(t, e) {
|
|
3669
3713
|
const s = [...t].reverse().find(
|
|
3670
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Dt(n) && !
|
|
3714
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Dt(n) && !Pr(
|
|
3671
3715
|
t,
|
|
3672
3716
|
n.respondsToUserMessageId
|
|
3673
3717
|
)
|
|
@@ -3677,23 +3721,23 @@ function _r(t, e) {
|
|
|
3677
3721
|
) : t;
|
|
3678
3722
|
}
|
|
3679
3723
|
function Dt(t) {
|
|
3680
|
-
return t.role === "tool" ||
|
|
3724
|
+
return t.role === "tool" || F(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3681
3725
|
}
|
|
3682
|
-
function
|
|
3726
|
+
function Pr(t, e) {
|
|
3683
3727
|
return t.some(
|
|
3684
|
-
(s) => s.respondsToUserMessageId === e && (
|
|
3728
|
+
(s) => s.respondsToUserMessageId === e && (B(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3685
3729
|
);
|
|
3686
3730
|
}
|
|
3687
|
-
function
|
|
3731
|
+
function Ur(t, e) {
|
|
3688
3732
|
const s = t[e];
|
|
3689
3733
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
3690
3734
|
const r = t[n];
|
|
3691
|
-
if (r.role === "assistant" &&
|
|
3735
|
+
if (r.role === "assistant" && ae(s, r))
|
|
3692
3736
|
return !0;
|
|
3693
3737
|
}
|
|
3694
3738
|
return !1;
|
|
3695
3739
|
}
|
|
3696
|
-
function
|
|
3740
|
+
function Dr(t, e) {
|
|
3697
3741
|
const s = t[e];
|
|
3698
3742
|
if (!s.respondsToUserMessageId)
|
|
3699
3743
|
return !1;
|
|
@@ -3701,34 +3745,34 @@ function Ur(t, e) {
|
|
|
3701
3745
|
const r = t[n];
|
|
3702
3746
|
if (r.role === "user")
|
|
3703
3747
|
return !1;
|
|
3704
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3748
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || F(r)))
|
|
3705
3749
|
return !0;
|
|
3706
3750
|
}
|
|
3707
3751
|
return !1;
|
|
3708
3752
|
}
|
|
3709
|
-
function
|
|
3753
|
+
function vr(t, e) {
|
|
3710
3754
|
const s = t[e];
|
|
3711
3755
|
return t.some(
|
|
3712
|
-
(n, r) => r !== e && n.role === "assistant" &&
|
|
3756
|
+
(n, r) => r !== e && n.role === "assistant" && ae(s, n)
|
|
3713
3757
|
);
|
|
3714
3758
|
}
|
|
3715
|
-
function
|
|
3759
|
+
function Or(t, e) {
|
|
3716
3760
|
const s = t[e];
|
|
3717
3761
|
return t.some(
|
|
3718
|
-
(n, r) => r !== e && n.role === "tool" &&
|
|
3762
|
+
(n, r) => r !== e && n.role === "tool" && ae(s, n)
|
|
3719
3763
|
);
|
|
3720
3764
|
}
|
|
3721
|
-
function
|
|
3765
|
+
function Lr(t, e) {
|
|
3722
3766
|
const s = t[e];
|
|
3723
3767
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3724
|
-
if (
|
|
3768
|
+
if (F(t[n]) && ae(s, t[n]))
|
|
3725
3769
|
return !0;
|
|
3726
3770
|
return !1;
|
|
3727
3771
|
}
|
|
3728
|
-
function
|
|
3772
|
+
function ae(t, e) {
|
|
3729
3773
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
3730
3774
|
}
|
|
3731
|
-
function
|
|
3775
|
+
function S(t, e) {
|
|
3732
3776
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
3733
3777
|
}
|
|
3734
3778
|
function qr(t, e) {
|
|
@@ -3739,7 +3783,7 @@ function qr(t, e) {
|
|
|
3739
3783
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3740
3784
|
if (e !== void 0 && r !== e)
|
|
3741
3785
|
return null;
|
|
3742
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3786
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Gr).filter((o) => !!o) : [];
|
|
3743
3787
|
return {
|
|
3744
3788
|
sessionId: r,
|
|
3745
3789
|
messages: i
|
|
@@ -3748,22 +3792,22 @@ function qr(t, e) {
|
|
|
3748
3792
|
return null;
|
|
3749
3793
|
}
|
|
3750
3794
|
}
|
|
3751
|
-
function
|
|
3795
|
+
function Nr(t, e) {
|
|
3752
3796
|
try {
|
|
3753
3797
|
window.localStorage.setItem(
|
|
3754
3798
|
`${$t}${t}`,
|
|
3755
3799
|
JSON.stringify({
|
|
3756
3800
|
sessionId: e.sessionId,
|
|
3757
|
-
messages: e.messages.slice(-on).map(
|
|
3801
|
+
messages: e.messages.slice(-on).map(Xr)
|
|
3758
3802
|
})
|
|
3759
3803
|
);
|
|
3760
3804
|
} catch {
|
|
3761
3805
|
return;
|
|
3762
3806
|
}
|
|
3763
3807
|
}
|
|
3764
|
-
function
|
|
3808
|
+
function xr(t) {
|
|
3765
3809
|
try {
|
|
3766
|
-
const e = window.localStorage.getItem(`${
|
|
3810
|
+
const e = window.localStorage.getItem(`${je}${t}`);
|
|
3767
3811
|
if (!e)
|
|
3768
3812
|
return [];
|
|
3769
3813
|
const s = JSON.parse(e);
|
|
@@ -3772,15 +3816,15 @@ function Nr(t) {
|
|
|
3772
3816
|
return [];
|
|
3773
3817
|
}
|
|
3774
3818
|
}
|
|
3775
|
-
function
|
|
3819
|
+
function G(t, e) {
|
|
3776
3820
|
try {
|
|
3777
3821
|
const s = e.filter(tt);
|
|
3778
3822
|
if (s.length === 0) {
|
|
3779
|
-
window.localStorage.removeItem(`${
|
|
3823
|
+
window.localStorage.removeItem(`${je}${t}`);
|
|
3780
3824
|
return;
|
|
3781
3825
|
}
|
|
3782
3826
|
window.localStorage.setItem(
|
|
3783
|
-
`${
|
|
3827
|
+
`${je}${t}`,
|
|
3784
3828
|
JSON.stringify(s.slice(-25))
|
|
3785
3829
|
);
|
|
3786
3830
|
} catch {
|
|
@@ -3789,7 +3833,7 @@ function z(t, e) {
|
|
|
3789
3833
|
}
|
|
3790
3834
|
function ts(t, e) {
|
|
3791
3835
|
try {
|
|
3792
|
-
const s = `${
|
|
3836
|
+
const s = `${Ae}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
3793
3837
|
...o,
|
|
3794
3838
|
storedAt: Date.now(),
|
|
3795
3839
|
unloadUrl: n,
|
|
@@ -3805,26 +3849,26 @@ function ts(t, e) {
|
|
|
3805
3849
|
}
|
|
3806
3850
|
function vt(t, e) {
|
|
3807
3851
|
try {
|
|
3808
|
-
if (window.sessionStorage.getItem(`${
|
|
3852
|
+
if (window.sessionStorage.getItem(`${Ae}${t}`) === null)
|
|
3809
3853
|
return;
|
|
3810
3854
|
} catch {
|
|
3811
3855
|
return;
|
|
3812
3856
|
}
|
|
3813
3857
|
ts(t, e);
|
|
3814
3858
|
}
|
|
3815
|
-
function
|
|
3859
|
+
function Br(t) {
|
|
3816
3860
|
try {
|
|
3817
|
-
const e = `${
|
|
3861
|
+
const e = `${Ae}${t}`, s = window.sessionStorage.getItem(e);
|
|
3818
3862
|
if (window.sessionStorage.removeItem(e), !s)
|
|
3819
3863
|
return [];
|
|
3820
3864
|
const n = JSON.parse(s);
|
|
3821
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3865
|
+
return Array.isArray(n) ? n.flatMap((r) => Hr(r) ? [{
|
|
3822
3866
|
...r.event,
|
|
3823
|
-
page:
|
|
3867
|
+
page: b(),
|
|
3824
3868
|
rawOutput: {
|
|
3825
3869
|
pageContextRestarted: !0,
|
|
3826
3870
|
outcome: "unknown",
|
|
3827
|
-
message:
|
|
3871
|
+
message: Wr(location.href),
|
|
3828
3872
|
currentUrl: location.href,
|
|
3829
3873
|
console: [],
|
|
3830
3874
|
metadata: {
|
|
@@ -3841,17 +3885,17 @@ function xr(t) {
|
|
|
3841
3885
|
return [];
|
|
3842
3886
|
}
|
|
3843
3887
|
}
|
|
3844
|
-
function
|
|
3888
|
+
function Wr(t) {
|
|
3845
3889
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3846
3890
|
Current URL: ${t}`;
|
|
3847
3891
|
}
|
|
3848
|
-
function
|
|
3892
|
+
function Hr(t) {
|
|
3849
3893
|
if (!t || typeof t != "object")
|
|
3850
3894
|
return !1;
|
|
3851
3895
|
const e = t, s = e.event;
|
|
3852
3896
|
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && tt(s) && s.type === "tool.result";
|
|
3853
3897
|
}
|
|
3854
|
-
function
|
|
3898
|
+
function $r(t, e) {
|
|
3855
3899
|
const s = new Set(
|
|
3856
3900
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3857
3901
|
);
|
|
@@ -3860,9 +3904,9 @@ function Hr(t, e) {
|
|
|
3860
3904
|
...e.filter((n) => !s.has(n.callId))
|
|
3861
3905
|
];
|
|
3862
3906
|
}
|
|
3863
|
-
function
|
|
3907
|
+
function jr(t) {
|
|
3864
3908
|
try {
|
|
3865
|
-
window.sessionStorage.removeItem(`${
|
|
3909
|
+
window.sessionStorage.removeItem(`${Ae}${t}`);
|
|
3866
3910
|
} catch {
|
|
3867
3911
|
return;
|
|
3868
3912
|
}
|
|
@@ -3897,9 +3941,9 @@ function ns(t, e) {
|
|
|
3897
3941
|
} : t;
|
|
3898
3942
|
}
|
|
3899
3943
|
function Xe(t) {
|
|
3900
|
-
return t.type ||
|
|
3944
|
+
return t.type || Kr(t.name) || "application/octet-stream";
|
|
3901
3945
|
}
|
|
3902
|
-
function
|
|
3946
|
+
function Fr(t) {
|
|
3903
3947
|
rs({
|
|
3904
3948
|
name: t.name,
|
|
3905
3949
|
mimeType: Xe(t),
|
|
@@ -3907,21 +3951,21 @@ function jr(t) {
|
|
|
3907
3951
|
});
|
|
3908
3952
|
}
|
|
3909
3953
|
function rs(t) {
|
|
3910
|
-
const e =
|
|
3954
|
+
const e = zr(t.name), s = t.mimeType.trim().toLowerCase();
|
|
3911
3955
|
if (!sn.has(`${e}:${s}`))
|
|
3912
3956
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
3913
3957
|
if (t.sizeBytes <= 0 || t.sizeBytes >= Wt)
|
|
3914
3958
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
3915
3959
|
}
|
|
3916
|
-
function
|
|
3960
|
+
function zr(t) {
|
|
3917
3961
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
3918
3962
|
return s >= 0 ? e.slice(s) : "";
|
|
3919
3963
|
}
|
|
3920
|
-
function
|
|
3964
|
+
function Kr(t) {
|
|
3921
3965
|
const e = t.toLowerCase();
|
|
3922
3966
|
return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
|
|
3923
3967
|
}
|
|
3924
|
-
function
|
|
3968
|
+
function Gr(t) {
|
|
3925
3969
|
if (!t || typeof t != "object")
|
|
3926
3970
|
return null;
|
|
3927
3971
|
const e = t;
|
|
@@ -3942,7 +3986,7 @@ function Kr(t) {
|
|
|
3942
3986
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
3943
3987
|
};
|
|
3944
3988
|
}
|
|
3945
|
-
function
|
|
3989
|
+
function Xr(t) {
|
|
3946
3990
|
return t.attachments?.length ? {
|
|
3947
3991
|
...t,
|
|
3948
3992
|
attachments: t.attachments.map(st)
|
|
@@ -3957,7 +4001,7 @@ function st(t) {
|
|
|
3957
4001
|
} = t;
|
|
3958
4002
|
return r;
|
|
3959
4003
|
}
|
|
3960
|
-
function
|
|
4004
|
+
function N(t) {
|
|
3961
4005
|
const e = t.respondsToUserMessageId;
|
|
3962
4006
|
return typeof e == "string" && e ? e : null;
|
|
3963
4007
|
}
|
|
@@ -3965,7 +4009,7 @@ function _(t) {
|
|
|
3965
4009
|
const e = t.runId;
|
|
3966
4010
|
return typeof e == "string" && e ? e : null;
|
|
3967
4011
|
}
|
|
3968
|
-
function
|
|
4012
|
+
function Vr(t) {
|
|
3969
4013
|
const e = t?.timeoutMs;
|
|
3970
4014
|
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= fn);
|
|
3971
4015
|
}
|
|
@@ -3981,22 +4025,22 @@ function is(t) {
|
|
|
3981
4025
|
return e;
|
|
3982
4026
|
}
|
|
3983
4027
|
function nt(t, e) {
|
|
3984
|
-
return ds(t) ?
|
|
4028
|
+
return ds(t) ? Ee : x(Me(e), nn);
|
|
3985
4029
|
}
|
|
3986
|
-
function
|
|
4030
|
+
function Jr(t, e) {
|
|
3987
4031
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
3988
4032
|
}
|
|
3989
|
-
async function
|
|
4033
|
+
async function Yr(t, e, s, n) {
|
|
3990
4034
|
const r = is(t.headers);
|
|
3991
4035
|
n({
|
|
3992
4036
|
...e,
|
|
3993
4037
|
responseStatus: t.status,
|
|
3994
4038
|
responseHeaders: r,
|
|
3995
|
-
responseBody: await
|
|
4039
|
+
responseBody: await Qr(t),
|
|
3996
4040
|
durationMs: Date.now() - s
|
|
3997
4041
|
});
|
|
3998
4042
|
}
|
|
3999
|
-
async function
|
|
4043
|
+
async function Qr(t) {
|
|
4000
4044
|
if (!os(t.headers))
|
|
4001
4045
|
return;
|
|
4002
4046
|
let e = null, s = null;
|
|
@@ -4015,10 +4059,10 @@ async function Yr(t) {
|
|
|
4015
4059
|
return;
|
|
4016
4060
|
const { done: l, value: c } = a;
|
|
4017
4061
|
if (l)
|
|
4018
|
-
return
|
|
4062
|
+
return x(i + r.decode());
|
|
4019
4063
|
const h = Qe - o;
|
|
4020
4064
|
if (c.byteLength > h)
|
|
4021
|
-
return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${
|
|
4065
|
+
return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${x(i)}... [truncated]`;
|
|
4022
4066
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
4023
4067
|
}
|
|
4024
4068
|
} catch {
|
|
@@ -4028,35 +4072,35 @@ async function Yr(t) {
|
|
|
4028
4072
|
s !== null && window.clearTimeout(s);
|
|
4029
4073
|
}
|
|
4030
4074
|
}
|
|
4031
|
-
function
|
|
4075
|
+
function Zr(t, e) {
|
|
4032
4076
|
if (os(new Headers(e)))
|
|
4033
4077
|
try {
|
|
4034
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
4078
|
+
return t.responseType === "" || t.responseType === "text" ? x(t.responseText ?? "") : void 0;
|
|
4035
4079
|
} catch {
|
|
4036
4080
|
return;
|
|
4037
4081
|
}
|
|
4038
4082
|
}
|
|
4039
|
-
function
|
|
4083
|
+
function Lt(t) {
|
|
4040
4084
|
if (typeof t == "string")
|
|
4041
|
-
return
|
|
4085
|
+
return x(t);
|
|
4042
4086
|
}
|
|
4043
|
-
function
|
|
4044
|
-
return
|
|
4087
|
+
function ei(t) {
|
|
4088
|
+
return L({
|
|
4045
4089
|
...t,
|
|
4046
|
-
requestBody:
|
|
4047
|
-
responseBody:
|
|
4090
|
+
requestBody: qt(t.requestBody),
|
|
4091
|
+
responseBody: qt(t.responseBody)
|
|
4048
4092
|
});
|
|
4049
4093
|
}
|
|
4050
|
-
function
|
|
4094
|
+
function qt(t) {
|
|
4051
4095
|
if (typeof t != "string")
|
|
4052
4096
|
return t;
|
|
4053
4097
|
const e = t.trim();
|
|
4054
4098
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4055
|
-
return
|
|
4099
|
+
return Me(t);
|
|
4056
4100
|
try {
|
|
4057
|
-
return JSON.stringify(
|
|
4101
|
+
return JSON.stringify(L(JSON.parse(t)));
|
|
4058
4102
|
} catch {
|
|
4059
|
-
return
|
|
4103
|
+
return Me(t);
|
|
4060
4104
|
}
|
|
4061
4105
|
}
|
|
4062
4106
|
function os(t) {
|
|
@@ -4065,8 +4109,8 @@ function os(t) {
|
|
|
4065
4109
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4066
4110
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= Qe && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4067
4111
|
}
|
|
4068
|
-
function
|
|
4069
|
-
if (
|
|
4112
|
+
function V(t, e = {}, s) {
|
|
4113
|
+
if (si(s))
|
|
4070
4114
|
return !0;
|
|
4071
4115
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
4072
4116
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -4081,8 +4125,8 @@ function X(t, e = {}, s) {
|
|
|
4081
4125
|
return !0;
|
|
4082
4126
|
}
|
|
4083
4127
|
}
|
|
4084
|
-
function
|
|
4085
|
-
if (
|
|
4128
|
+
function ti(t, e) {
|
|
4129
|
+
if (V(t))
|
|
4086
4130
|
return !0;
|
|
4087
4131
|
try {
|
|
4088
4132
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -4091,10 +4135,10 @@ function ei(t, e) {
|
|
|
4091
4135
|
return !0;
|
|
4092
4136
|
}
|
|
4093
4137
|
}
|
|
4094
|
-
function
|
|
4138
|
+
function si(t) {
|
|
4095
4139
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4096
4140
|
}
|
|
4097
|
-
function
|
|
4141
|
+
function ni(t) {
|
|
4098
4142
|
const e = {};
|
|
4099
4143
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4100
4144
|
const n = s.indexOf(":");
|
|
@@ -4107,101 +4151,101 @@ function si(t) {
|
|
|
4107
4151
|
}
|
|
4108
4152
|
return e;
|
|
4109
4153
|
}
|
|
4110
|
-
function
|
|
4154
|
+
function x(t, e = Qe) {
|
|
4111
4155
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4112
4156
|
}
|
|
4113
|
-
function
|
|
4157
|
+
function We(t) {
|
|
4114
4158
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4115
4159
|
}
|
|
4116
|
-
class
|
|
4160
|
+
class Ie extends Error {
|
|
4117
4161
|
constructor(e, s) {
|
|
4118
4162
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4119
4163
|
}
|
|
4120
4164
|
status;
|
|
4121
4165
|
}
|
|
4122
|
-
async function
|
|
4166
|
+
async function ge(t, e) {
|
|
4123
4167
|
let s = null;
|
|
4124
4168
|
for (let n = 0; n < Mt; n += 1)
|
|
4125
4169
|
try {
|
|
4126
4170
|
return await t();
|
|
4127
4171
|
} catch (r) {
|
|
4128
|
-
if (s = r, n >= Mt - 1 || !
|
|
4172
|
+
if (s = r, n >= Mt - 1 || !ii(r))
|
|
4129
4173
|
throw r;
|
|
4130
|
-
await
|
|
4174
|
+
await ri(n);
|
|
4131
4175
|
}
|
|
4132
4176
|
throw s instanceof Error ? s : new Error(e);
|
|
4133
4177
|
}
|
|
4134
|
-
function
|
|
4178
|
+
function ri(t) {
|
|
4135
4179
|
return new Promise((e) => {
|
|
4136
4180
|
window.setTimeout(e, tn[t] ?? 0);
|
|
4137
4181
|
});
|
|
4138
4182
|
}
|
|
4139
|
-
function ri(t) {
|
|
4140
|
-
return t instanceof me ? ii(t.status) : t instanceof TypeError;
|
|
4141
|
-
}
|
|
4142
4183
|
function ii(t) {
|
|
4143
|
-
return t
|
|
4184
|
+
return t instanceof Ie ? oi(t.status) : t instanceof TypeError;
|
|
4144
4185
|
}
|
|
4145
4186
|
function oi(t) {
|
|
4187
|
+
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
4188
|
+
}
|
|
4189
|
+
function ai(t) {
|
|
4146
4190
|
return t === 401 || t === 403;
|
|
4147
4191
|
}
|
|
4148
|
-
const
|
|
4149
|
-
function
|
|
4150
|
-
return
|
|
4192
|
+
const Ee = "[REDACTED_SECRET]", W = "[REDACTED_TOKEN]", li = "[REDACTED_SIGNED_URL]", ci = 20, ui = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, as = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ls = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, cs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, us = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, di = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, hi = /\bhttps?:\/\/[^\s"'<>]+/gi, pi = /[),.;\]]+$/;
|
|
4193
|
+
function L(t) {
|
|
4194
|
+
return we(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4151
4195
|
}
|
|
4152
|
-
function
|
|
4196
|
+
function we(t, e, s) {
|
|
4153
4197
|
if (typeof t == "string")
|
|
4154
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4198
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Me(t);
|
|
4155
4199
|
if (t === null || typeof t != "object")
|
|
4156
4200
|
return t;
|
|
4157
|
-
if (e >=
|
|
4201
|
+
if (e >= ci)
|
|
4158
4202
|
return "[REDACTED_MAX_DEPTH]";
|
|
4159
4203
|
if (s.has(t))
|
|
4160
4204
|
return "[REDACTED_CIRCULAR]";
|
|
4161
4205
|
if (s.add(t), Array.isArray(t))
|
|
4162
|
-
return t.map((r) =>
|
|
4206
|
+
return t.map((r) => we(r, e + 1, s));
|
|
4163
4207
|
const n = {};
|
|
4164
4208
|
for (const [r, i] of Object.entries(t))
|
|
4165
|
-
r === "pageContent" ? n[r] = i : ds(r) ? n[r] =
|
|
4209
|
+
r === "pageContent" ? n[r] = i : ds(r) ? n[r] = Ee : n[r] = r.toLowerCase() === "url" ? gi(i) : we(i, e + 1, s);
|
|
4166
4210
|
return n;
|
|
4167
4211
|
}
|
|
4168
4212
|
function ds(t) {
|
|
4169
4213
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
4170
4214
|
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");
|
|
4171
4215
|
}
|
|
4172
|
-
function
|
|
4173
|
-
return typeof t == "string" ? hs(t) :
|
|
4216
|
+
function gi(t) {
|
|
4217
|
+
return typeof t == "string" ? hs(t) : we(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4174
4218
|
}
|
|
4175
4219
|
function hs(t) {
|
|
4176
4220
|
try {
|
|
4177
4221
|
const e = new URL(t, location.href);
|
|
4178
4222
|
for (const s of Array.from(e.searchParams.keys()))
|
|
4179
|
-
|
|
4180
|
-
return e.username && (e.username =
|
|
4223
|
+
ui.test(s) && e.searchParams.set(s, W);
|
|
4224
|
+
return e.username && (e.username = W), e.password && (e.password = W), e.toString();
|
|
4181
4225
|
} catch {
|
|
4182
|
-
return
|
|
4226
|
+
return fi(t);
|
|
4183
4227
|
}
|
|
4184
4228
|
}
|
|
4185
|
-
function
|
|
4186
|
-
return t.replace(
|
|
4187
|
-
}
|
|
4188
|
-
function gi(t) {
|
|
4189
|
-
return t.replace(as, `Bearer ${N}`).replace(ls, `Basic ${N}`).replace(cs, N).replace(us, (e, s) => `${s}: ${Me}`);
|
|
4229
|
+
function Me(t) {
|
|
4230
|
+
return t.replace(di, li).replace(hi, mi).replace(as, `Bearer ${W}`).replace(ls, `Basic ${W}`).replace(cs, W).replace(us, (e, s) => `${s}: ${Ee}`);
|
|
4190
4231
|
}
|
|
4191
4232
|
function fi(t) {
|
|
4192
|
-
|
|
4233
|
+
return t.replace(as, `Bearer ${W}`).replace(ls, `Basic ${W}`).replace(cs, W).replace(us, (e, s) => `${s}: ${Ee}`);
|
|
4234
|
+
}
|
|
4235
|
+
function mi(t) {
|
|
4236
|
+
const e = t.match(pi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4193
4237
|
return `${hs(s)}${e}`;
|
|
4194
4238
|
}
|
|
4195
4239
|
export {
|
|
4196
4240
|
ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4197
|
-
|
|
4241
|
+
$e as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4198
4242
|
xs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4199
4243
|
Ns as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4200
4244
|
Bs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
4201
|
-
|
|
4245
|
+
yi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
4202
4246
|
jt as PlunoProductAgent,
|
|
4203
4247
|
ln as calculateReconnectDelay,
|
|
4204
4248
|
jt as default,
|
|
4205
4249
|
Un as getProductAgentOriginAccessErrorMessage,
|
|
4206
|
-
|
|
4250
|
+
Fr as validateProductAgentProviderInputFile
|
|
4207
4251
|
};
|