@pluno/product-agent-web 0.1.161 → 0.1.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -2
- package/dist/product-agent-sdk.js +799 -749
- package/dist/product-agent-widget.js +1575 -1523
- package/package.json +1 -1
|
@@ -62,11 +62,11 @@ function Xe(t) {
|
|
|
62
62
|
t.onsuccess = () => e(t.result), t.onerror = () => s(t.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function ps(t) {
|
|
66
66
|
return t !== null && (typeof t == "object" || typeof t == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const n = Reflect.get(t, "pluno"), r =
|
|
68
|
+
function Pt(t, e, s) {
|
|
69
|
+
const n = Reflect.get(t, "pluno"), r = ps(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(t, "pluno", r))
|
|
71
71
|
return null;
|
|
72
72
|
const i = Object.getOwnPropertyDescriptor(r, e);
|
|
@@ -80,10 +80,10 @@ function Ut(t, e, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const hs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
84
|
function gs(t, e) {
|
|
85
85
|
return e ? t.replace(
|
|
86
|
-
|
|
86
|
+
hs,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
|
|
88
88
|
) : t;
|
|
89
89
|
}
|
|
@@ -108,7 +108,7 @@ function fs(t, e, s) {
|
|
|
108
108
|
const m = c.get(g);
|
|
109
109
|
(!m || s(m).isTransient) && c.set(g, u);
|
|
110
110
|
}
|
|
111
|
-
const
|
|
111
|
+
const p = new Set(i.map(({ identity: u }) => u.id)), h = new Set(
|
|
112
112
|
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
113
113
|
), w = /* @__PURE__ */ new Set(), y = [];
|
|
114
114
|
for (const u of t) {
|
|
@@ -118,7 +118,7 @@ function fs(t, e, s) {
|
|
|
118
118
|
y.push(g), w.add(g);
|
|
119
119
|
continue;
|
|
120
120
|
}
|
|
121
|
-
const m = d.respondsToUserMessageId !== void 0 &&
|
|
121
|
+
const m = d.respondsToUserMessageId !== void 0 && p.has(d.respondsToUserMessageId) || d.runId !== void 0 && h.has(d.runId);
|
|
122
122
|
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) && m) && y.push(u);
|
|
123
123
|
}
|
|
124
124
|
for (const { item: u } of i)
|
|
@@ -131,11 +131,11 @@ function ms(t, e, s, n) {
|
|
|
131
131
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
let
|
|
134
|
+
const Ce = "pluno.productAgent.transportId", ys = "pluno.productAgent.transportIdentity", be = "pluno.productAgent.transportIdentity.event", Is = 50, Ts = globalThis.setTimeout.bind(globalThis);
|
|
135
|
+
let K = null;
|
|
136
136
|
const le = /* @__PURE__ */ new Set(), _e = /* @__PURE__ */ new Map();
|
|
137
|
-
async function ws(t =
|
|
138
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
137
|
+
async function ws(t = Ut()) {
|
|
138
|
+
const e = t.randomUUID(), s = t.storage.getItem(Ce);
|
|
139
139
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
140
140
|
const o = t.channel.subscribe((l) => {
|
|
141
141
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -153,14 +153,14 @@ async function ws(t = Pt()) {
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
if (!s)
|
|
156
|
-
t.storage.setItem(
|
|
156
|
+
t.storage.setItem(Ce, n), r = !0;
|
|
157
157
|
else
|
|
158
158
|
for (; ; ) {
|
|
159
159
|
if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
|
|
160
160
|
r = !0;
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
163
|
+
n = t.randomUUID(), t.storage.setItem(Ce, n);
|
|
164
164
|
}
|
|
165
165
|
let a = !1;
|
|
166
166
|
return {
|
|
@@ -171,13 +171,13 @@ async function ws(t = Pt()) {
|
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
async function Ss() {
|
|
174
|
-
|
|
174
|
+
K || (K = ws(Ut()), K.then((n) => {
|
|
175
175
|
const r = (i) => {
|
|
176
|
-
i.persisted || (n.release(),
|
|
176
|
+
i.persisted || (n.release(), K = null, le.clear(), window.removeEventListener("pagehide", r));
|
|
177
177
|
};
|
|
178
178
|
window.addEventListener("pagehide", r);
|
|
179
179
|
}));
|
|
180
|
-
const t = await
|
|
180
|
+
const t = await K, e = Ms();
|
|
181
181
|
le.add(e);
|
|
182
182
|
let s = !1;
|
|
183
183
|
return {
|
|
@@ -194,7 +194,7 @@ function Ms() {
|
|
|
194
194
|
t += 1;
|
|
195
195
|
return t;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function Ut() {
|
|
198
198
|
return {
|
|
199
199
|
storage: As(),
|
|
200
200
|
channel: Rs(),
|
|
@@ -236,7 +236,7 @@ function Rs() {
|
|
|
236
236
|
}
|
|
237
237
|
function Es() {
|
|
238
238
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
239
|
-
if (s.key !==
|
|
239
|
+
if (s.key !== be || !s.newValue)
|
|
240
240
|
return;
|
|
241
241
|
const n = JSON.parse(s.newValue);
|
|
242
242
|
for (const r of t)
|
|
@@ -245,9 +245,9 @@ function Es() {
|
|
|
245
245
|
return window.addEventListener("storage", e), {
|
|
246
246
|
postMessage: (s) => {
|
|
247
247
|
window.localStorage.setItem(
|
|
248
|
-
|
|
248
|
+
be,
|
|
249
249
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
250
|
-
), window.localStorage.removeItem(
|
|
250
|
+
), window.localStorage.removeItem(be);
|
|
251
251
|
},
|
|
252
252
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
253
253
|
close: () => {
|
|
@@ -256,7 +256,7 @@ function Es() {
|
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
const Dt = "schedule_follow_up";
|
|
259
|
-
function
|
|
259
|
+
function Cs(t) {
|
|
260
260
|
let e = t;
|
|
261
261
|
if (typeof e == "string")
|
|
262
262
|
try {
|
|
@@ -269,8 +269,8 @@ function bs(t) {
|
|
|
269
269
|
const s = e;
|
|
270
270
|
return s.ok !== !0 || s.toolName !== Dt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
271
271
|
}
|
|
272
|
-
const
|
|
273
|
-
let
|
|
272
|
+
const bs = globalThis.fetch.bind(globalThis), Le = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', _s = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ks = ".pluno-pa-widget__panel", Ps = ".pluno-pa-widget__timeline", ut = `${Le}[data-pluno-sdk-preview-channel]`;
|
|
273
|
+
let Us = 0;
|
|
274
274
|
function dt(t) {
|
|
275
275
|
const e = {};
|
|
276
276
|
for (const o of [
|
|
@@ -278,6 +278,7 @@ function dt(t) {
|
|
|
278
278
|
"requestId",
|
|
279
279
|
"clientMessageId",
|
|
280
280
|
"sessionId",
|
|
281
|
+
"warmupId",
|
|
281
282
|
"runId",
|
|
282
283
|
"itemId",
|
|
283
284
|
"reason",
|
|
@@ -320,31 +321,31 @@ function ke(t, e, s) {
|
|
|
320
321
|
source: "web_sdk",
|
|
321
322
|
category: t,
|
|
322
323
|
name: e,
|
|
323
|
-
sequence: ++
|
|
324
|
+
sequence: ++Us,
|
|
324
325
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
325
326
|
monotonicMs: performance.now(),
|
|
326
327
|
data: s
|
|
327
328
|
};
|
|
328
329
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
329
330
|
}
|
|
330
|
-
const Ds = "https://app.pluno.ai", vs = "gpt-5.6-terra",
|
|
331
|
+
const Ds = "https://app.pluno.ai", vs = "gpt-5.6-terra", Ns = 2e4, Os = 1e4, xs = 1e4, Ls = 1e4, qs = 1e4, Bs = 3e3, Ws = 3e4, Hs = 1e3, pt = 3e4, ht = 0.2, gt = 6e4, $s = 15e3, G = 8, js = "Pluno could not finish this message. Try it again.", Fs = "Browser connection was interrupted.", ft = 15e3, zs = "Pluno could not send this message. Try it again.", mt = 2e3, Ks = 1e3, Gs = 100, yt = 8e3, It = 3, Xs = [300, 1e3], vt = 50 * 1024 * 1024, Vs = /* @__PURE__ */ new Set([
|
|
331
332
|
".jpeg:image/jpeg",
|
|
332
333
|
".jpg:image/jpeg",
|
|
333
334
|
".pdf:application/pdf",
|
|
334
335
|
".png:image/png",
|
|
335
336
|
".webp:image/webp"
|
|
336
|
-
]),
|
|
337
|
-
function
|
|
337
|
+
]), li = ".pdf,.png,.jpg,.jpeg,.webp", Ve = 64e3, Pe = 4e3, Je = 30, Js = 2e3, Ys = 1e3, Nt = "Image is too large for model vision input.", Qs = 100, Ot = "pluno.productAgent.state.", qe = "pluno.productAgent.pendingEvents.", he = "pluno.productAgent.activeToolCalls.", Zs = 100;
|
|
338
|
+
function X(t, e = 0) {
|
|
338
339
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
339
340
|
return Math.max(e, s);
|
|
340
341
|
}
|
|
341
342
|
const ce = /* @__PURE__ */ new Set();
|
|
342
343
|
let ne = null;
|
|
343
|
-
function
|
|
344
|
-
const s = Math.min(
|
|
345
|
-
return Math.min(
|
|
344
|
+
function en(t, e = Math.random) {
|
|
345
|
+
const s = Math.min(pt, Hs * 2 ** t), n = 1 - ht + e() * ht * 2;
|
|
346
|
+
return Math.min(pt, Math.round(s * n));
|
|
346
347
|
}
|
|
347
|
-
function
|
|
348
|
+
function tn(t, e, s) {
|
|
348
349
|
return new Promise((n, r) => {
|
|
349
350
|
const i = setTimeout(() => r(new Error(s)), e);
|
|
350
351
|
t.then(
|
|
@@ -361,9 +362,9 @@ class xt {
|
|
|
361
362
|
constructor(e, s) {
|
|
362
363
|
this.options = e, this.transportIdentity = s, this.state = {
|
|
363
364
|
...this.state,
|
|
364
|
-
starterPrompts:
|
|
365
|
+
starterPrompts: xn(e.initialStarterPrompts)
|
|
365
366
|
};
|
|
366
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
367
|
+
const n = e.restorePersistedState === !1 ? null : Cr(e.clientId, e.expectedPersistedSessionId);
|
|
367
368
|
n && (this.state = {
|
|
368
369
|
...this.state,
|
|
369
370
|
...n,
|
|
@@ -378,14 +379,14 @@ class xt {
|
|
|
378
379
|
isThinking: !1,
|
|
379
380
|
isRetrying: !1,
|
|
380
381
|
lastError: null
|
|
381
|
-
}), this.queuedClientEvents =
|
|
382
|
-
|
|
383
|
-
|
|
382
|
+
}), this.queuedClientEvents = vr(
|
|
383
|
+
_r(e.clientId),
|
|
384
|
+
Pr(e.clientId)
|
|
384
385
|
);
|
|
385
386
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
386
387
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
387
388
|
);
|
|
388
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting"),
|
|
389
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting"), q(e.clientId, this.queuedClientEvents);
|
|
389
390
|
}
|
|
390
391
|
options;
|
|
391
392
|
listeners = {};
|
|
@@ -403,7 +404,11 @@ class xt {
|
|
|
403
404
|
networkBatchTimer = null;
|
|
404
405
|
queuedNetworkEvents = [];
|
|
405
406
|
queuedClientEvents = [];
|
|
406
|
-
|
|
407
|
+
pendingPassiveWarmupEvent = null;
|
|
408
|
+
pendingComposerWarmup = null;
|
|
409
|
+
activeComposerWarmupId = null;
|
|
410
|
+
activeComposerWarmupScope = null;
|
|
411
|
+
pendingWarmupAckTimer = null;
|
|
407
412
|
pendingSessionHistoryRequests = /* @__PURE__ */ new Map();
|
|
408
413
|
pendingSessionPinRequests = /* @__PURE__ */ new Map();
|
|
409
414
|
pendingSessionRenameRequests = /* @__PURE__ */ new Map();
|
|
@@ -470,11 +475,11 @@ class xt {
|
|
|
470
475
|
static async init(e) {
|
|
471
476
|
const s = await Ss(), n = new xt({
|
|
472
477
|
...e,
|
|
473
|
-
backendUrl:
|
|
474
|
-
clientId: e.clientId ??
|
|
478
|
+
backendUrl: Sn(e.backendUrl ?? Ds),
|
|
479
|
+
clientId: e.clientId ?? Hn(),
|
|
475
480
|
model: e.model ?? vs,
|
|
476
481
|
productVariant: e.productVariant ?? "customer_embedded",
|
|
477
|
-
entrySurface:
|
|
482
|
+
entrySurface: Mn(e.entrySurface)
|
|
478
483
|
}, s);
|
|
479
484
|
try {
|
|
480
485
|
us().catch((r) => {
|
|
@@ -508,11 +513,11 @@ class xt {
|
|
|
508
513
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
509
514
|
);
|
|
510
515
|
try {
|
|
511
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
516
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await tn(this.options.tokenProvider(), xs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
512
517
|
return;
|
|
513
518
|
if (!this.token && !this.options.webSocketFactory)
|
|
514
519
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
515
|
-
const s =
|
|
520
|
+
const s = En(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
516
521
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
517
522
|
this.socket === n && n.readyState === WebSocket.CONNECTING && (M("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
518
523
|
}, Ls), n.addEventListener("open", () => {
|
|
@@ -529,14 +534,14 @@ class xt {
|
|
|
529
534
|
this.socket === n && (M("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
530
535
|
}, qs));
|
|
531
536
|
}), n.addEventListener("message", (r) => {
|
|
532
|
-
this.socket === n && this.handleServerEvent(
|
|
537
|
+
this.socket === n && this.handleServerEvent(Nn(r.data));
|
|
533
538
|
}), n.addEventListener("sendfailure", (r) => {
|
|
534
539
|
if (this.socket !== n)
|
|
535
540
|
return;
|
|
536
|
-
const i =
|
|
541
|
+
const i = On(r?.detail?.data);
|
|
537
542
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
538
543
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
539
|
-
) && (this.queuedClientEvents.push(i),
|
|
544
|
+
) && (this.queuedClientEvents.push(i), q(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();
|
|
540
545
|
}), n.addEventListener("close", (r) => {
|
|
541
546
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), M("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
542
547
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -566,22 +571,29 @@ class xt {
|
|
|
566
571
|
}
|
|
567
572
|
}
|
|
568
573
|
disconnect() {
|
|
569
|
-
this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.
|
|
574
|
+
this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
570
575
|
}
|
|
571
576
|
destroy() {
|
|
572
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
577
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Nr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
573
578
|
for (const e of Object.values(this.listeners))
|
|
574
579
|
e?.clear();
|
|
575
580
|
}
|
|
576
581
|
warmup(e = "panel_open") {
|
|
577
|
-
const s = {
|
|
582
|
+
const s = C(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
|
|
578
583
|
type: "runtime.warmup",
|
|
579
584
|
reason: e,
|
|
585
|
+
...e === "composer_input" ? { warmupId: r?.event.warmupId ?? L() } : {},
|
|
580
586
|
entrySurface: this.options.entrySurface,
|
|
581
587
|
sessionId: this.state.sessionId ?? void 0,
|
|
582
|
-
page:
|
|
588
|
+
page: s
|
|
583
589
|
};
|
|
584
|
-
|
|
590
|
+
if (e === "composer_input") {
|
|
591
|
+
if (this.options.productVariant === "customer_embedded") {
|
|
592
|
+
this.sendNow(i) || (this.pendingPassiveWarmupEvent = i);
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
r || (this.clearPendingComposerWarmup(), this.pendingComposerWarmup = { event: i, scope: n, retryAttempt: 0, acknowledged: !1 }, this.activeComposerWarmupId = i.warmupId ?? null, this.activeComposerWarmupScope = n), this.flushPendingComposerWarmup();
|
|
596
|
+
} else this.sendNow(i) || (this.pendingPassiveWarmupEvent = i);
|
|
585
597
|
}
|
|
586
598
|
async sendMessage(e, s = {}) {
|
|
587
599
|
const n = e.trim(), r = s.attachments ?? [];
|
|
@@ -595,13 +607,13 @@ class xt {
|
|
|
595
607
|
return null;
|
|
596
608
|
if (this.pendingClientMessageId)
|
|
597
609
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
598
|
-
const o = C(), a = s.clientMessageId ??
|
|
610
|
+
const o = C(), a = s.clientMessageId ?? L(), l = {
|
|
599
611
|
id: `local-${a}`,
|
|
600
612
|
role: "user",
|
|
601
613
|
content: n,
|
|
602
614
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
603
615
|
...r.length > 0 ? { attachments: r } : {}
|
|
604
|
-
}, c = this.state.messages.some((m) => m.id === l.id || m.clientMessageId === a),
|
|
616
|
+
}, c = this.state.messages.some((m) => m.id === l.id || m.clientMessageId === a), p = this.state.isThinking, h = this.state.pendingMessageStatus, w = this.state.messages, y = c ? this.state.messages : [...this.state.messages, l], u = {
|
|
605
617
|
assistantDraft: this.state.assistantDraft,
|
|
606
618
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
607
619
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -611,7 +623,7 @@ class xt {
|
|
|
611
623
|
};
|
|
612
624
|
this.setState({
|
|
613
625
|
messages: y,
|
|
614
|
-
...
|
|
626
|
+
...p ? {} : {
|
|
615
627
|
assistantDraft: "",
|
|
616
628
|
assistantDraftItemId: null,
|
|
617
629
|
assistantDraftPhase: null,
|
|
@@ -619,7 +631,7 @@ class xt {
|
|
|
619
631
|
assistantDraftRunId: null
|
|
620
632
|
},
|
|
621
633
|
pendingMessageStatus: "sending",
|
|
622
|
-
isThinking:
|
|
634
|
+
isThinking: p,
|
|
623
635
|
isRetrying: !1,
|
|
624
636
|
lastError: null
|
|
625
637
|
}), c || this.emit("message", l);
|
|
@@ -639,8 +651,8 @@ class xt {
|
|
|
639
651
|
} catch (m) {
|
|
640
652
|
throw this.setState({
|
|
641
653
|
...c ? {} : { messages: w },
|
|
642
|
-
...
|
|
643
|
-
pendingMessageStatus:
|
|
654
|
+
...p ? {} : { ...u, isThinking: !1 },
|
|
655
|
+
pendingMessageStatus: h
|
|
644
656
|
}), m;
|
|
645
657
|
}
|
|
646
658
|
this.retryableClientMessageId = null;
|
|
@@ -649,7 +661,7 @@ class xt {
|
|
|
649
661
|
sessionId: this.state.sessionId ?? void 0,
|
|
650
662
|
clientMessageId: a,
|
|
651
663
|
initiatedBy: s.initiatedBy,
|
|
652
|
-
invocation:
|
|
664
|
+
invocation: An(s.invocation ?? s.initiatedBy),
|
|
653
665
|
entrySurface: this.options.entrySurface,
|
|
654
666
|
content: n,
|
|
655
667
|
pageContent: d && Ye() || void 0,
|
|
@@ -676,8 +688,8 @@ class xt {
|
|
|
676
688
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(s), this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
|
|
677
689
|
}
|
|
678
690
|
createLocalAttachment(e) {
|
|
679
|
-
this.options.productVariant === "customer_embedded" &&
|
|
680
|
-
const s =
|
|
691
|
+
this.options.productVariant === "customer_embedded" && Or(e);
|
|
692
|
+
const s = L(), n = {
|
|
681
693
|
id: s,
|
|
682
694
|
name: e.name || "attachment",
|
|
683
695
|
mimeType: ze(e),
|
|
@@ -782,7 +794,7 @@ class xt {
|
|
|
782
794
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
783
795
|
if (n.ok)
|
|
784
796
|
return await n.json();
|
|
785
|
-
if (
|
|
797
|
+
if (Qr(n.status) && this.options.tokenProvider && !s) {
|
|
786
798
|
s = !0;
|
|
787
799
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
788
800
|
if (r.ok)
|
|
@@ -807,7 +819,7 @@ class xt {
|
|
|
807
819
|
if (!this.state.sessionId)
|
|
808
820
|
return;
|
|
809
821
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
810
|
-
const e =
|
|
822
|
+
const e = yr(
|
|
811
823
|
this.state.messages,
|
|
812
824
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
813
825
|
this.state.assistantDraftRunId,
|
|
@@ -824,10 +836,11 @@ class xt {
|
|
|
824
836
|
}), this.clearThinkingWatchdog();
|
|
825
837
|
}
|
|
826
838
|
startNewSession(e = {}) {
|
|
827
|
-
const s = e.notifyTransport !== !1;
|
|
828
|
-
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((
|
|
839
|
+
const s = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
|
|
840
|
+
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
|
|
829
841
|
type: "session.reset",
|
|
830
842
|
sessionId: this.state.sessionId ?? void 0,
|
|
843
|
+
warmupId: n ?? void 0,
|
|
831
844
|
page: C()
|
|
832
845
|
}), this.setState({
|
|
833
846
|
sessionId: null,
|
|
@@ -845,7 +858,7 @@ class xt {
|
|
|
845
858
|
});
|
|
846
859
|
}
|
|
847
860
|
listSessions(e = {}) {
|
|
848
|
-
const s =
|
|
861
|
+
const s = L(), n = new Promise((i, o) => {
|
|
849
862
|
const a = window.setTimeout(() => {
|
|
850
863
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
851
864
|
}, yt);
|
|
@@ -867,19 +880,24 @@ class xt {
|
|
|
867
880
|
setSessionPinned(e, s) {
|
|
868
881
|
return this.sendSessionMutation(
|
|
869
882
|
this.pendingSessionPinRequests,
|
|
870
|
-
{ type: "session.pin", requestId:
|
|
883
|
+
{ type: "session.pin", requestId: L(), sessionId: e, pinned: s },
|
|
871
884
|
"Session pin did not respond in time"
|
|
872
885
|
);
|
|
873
886
|
}
|
|
874
887
|
renameSession(e, s) {
|
|
875
888
|
return this.sendSessionMutation(
|
|
876
889
|
this.pendingSessionRenameRequests,
|
|
877
|
-
{ type: "session.rename", requestId:
|
|
890
|
+
{ type: "session.rename", requestId: L(), sessionId: e, title: s },
|
|
878
891
|
"Session rename did not respond in time"
|
|
879
892
|
);
|
|
880
893
|
}
|
|
881
894
|
loadSession(e) {
|
|
882
|
-
|
|
895
|
+
const s = this.activeComposerWarmupId;
|
|
896
|
+
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), s && this.send({
|
|
897
|
+
type: "session.reset",
|
|
898
|
+
warmupId: s,
|
|
899
|
+
page: C()
|
|
900
|
+
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.setState({
|
|
883
901
|
sessionId: e,
|
|
884
902
|
assistantDraft: "",
|
|
885
903
|
assistantDraftItemId: null,
|
|
@@ -900,7 +918,7 @@ class xt {
|
|
|
900
918
|
send(e) {
|
|
901
919
|
this.sendNow(k(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
902
920
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
903
|
-
) || this.queuedClientEvents.push(e),
|
|
921
|
+
) || this.queuedClientEvents.push(e), q(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
904
922
|
status: "reconnecting",
|
|
905
923
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
906
924
|
}), this.scheduleReconnect());
|
|
@@ -952,7 +970,7 @@ class xt {
|
|
|
952
970
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
953
971
|
return;
|
|
954
972
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
955
|
-
const e =
|
|
973
|
+
const e = Cn();
|
|
956
974
|
this.sendNow(
|
|
957
975
|
k({
|
|
958
976
|
type: "starter_prompts.page_context",
|
|
@@ -963,13 +981,13 @@ class xt {
|
|
|
963
981
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
964
982
|
}
|
|
965
983
|
startStarterPromptUrlWatcher() {
|
|
966
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
984
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = bn(() => this.handleStarterPromptUrlChange()));
|
|
967
985
|
}
|
|
968
986
|
handleStarterPromptUrlChange() {
|
|
969
987
|
const e = location.href;
|
|
970
|
-
e !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
988
|
+
e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
971
989
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
972
|
-
},
|
|
990
|
+
}, Zs));
|
|
973
991
|
}
|
|
974
992
|
refreshStarterPromptsForCurrentUrl() {
|
|
975
993
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -984,367 +1002,393 @@ class xt {
|
|
|
984
1002
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
985
1003
|
return;
|
|
986
1004
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
987
|
-
|
|
1005
|
+
q(this.options.clientId, this.queuedClientEvents);
|
|
988
1006
|
for (let s = 0; s < e.length; s += 1) {
|
|
989
1007
|
const n = e[s];
|
|
990
1008
|
if (!this.sendNow(k(n))) {
|
|
991
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1009
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), q(this.options.clientId, this.queuedClientEvents);
|
|
992
1010
|
return;
|
|
993
1011
|
}
|
|
994
|
-
|
|
1012
|
+
q(this.options.clientId, this.queuedClientEvents);
|
|
995
1013
|
}
|
|
996
1014
|
}
|
|
997
|
-
|
|
998
|
-
!this.
|
|
1015
|
+
flushPendingPassiveWarmup() {
|
|
1016
|
+
!this.pendingPassiveWarmupEvent || !this.sendNow(this.pendingPassiveWarmupEvent) || (this.pendingPassiveWarmupEvent = null);
|
|
999
1017
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
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);
|
|
1018
|
+
flushPendingComposerWarmup() {
|
|
1019
|
+
const e = this.pendingComposerWarmup;
|
|
1020
|
+
if (!e || e.acknowledged || !this.sendNow(e.event))
|
|
1004
1021
|
return;
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1022
|
+
this.clearPendingWarmupAckTimer();
|
|
1023
|
+
const s = Math.min(
|
|
1024
|
+
Bs * 2 ** e.retryAttempt,
|
|
1025
|
+
Ws
|
|
1026
|
+
);
|
|
1027
|
+
e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
|
|
1028
|
+
this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
|
|
1029
|
+
}, s);
|
|
1030
|
+
}
|
|
1031
|
+
handleServerEvent(e) {
|
|
1032
|
+
if (ke("server_event", e.type, dt(e)), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1033
|
+
if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
|
|
1034
|
+
this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
|
|
1016
1035
|
return;
|
|
1017
1036
|
}
|
|
1018
|
-
if (e.type === "
|
|
1019
|
-
|
|
1037
|
+
if (e.type === "run.ack") {
|
|
1038
|
+
const s = De(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1039
|
+
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);
|
|
1020
1040
|
return;
|
|
1021
1041
|
}
|
|
1022
|
-
if (
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
normalizedAppearance: s
|
|
1029
|
-
}), this.runtimeHelperJavascript = xn(e.runtimeHelpers)?.javascript ?? null;
|
|
1030
|
-
const r = Mt(e, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), o = e.starterPromptsLoading === !0, a = {
|
|
1031
|
-
user: Hn(e.user),
|
|
1032
|
-
status: "connected",
|
|
1033
|
-
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1034
|
-
};
|
|
1035
|
-
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !re() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1036
|
-
type: "page.upsert",
|
|
1037
|
-
sessionId: this.state.sessionId,
|
|
1038
|
-
page: C(),
|
|
1039
|
-
model: this.options.model
|
|
1040
|
-
});
|
|
1041
|
-
return;
|
|
1042
|
-
}
|
|
1043
|
-
if (e.type === "starterPrompts.updated") {
|
|
1044
|
-
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1045
|
-
starterPrompts: Mt(e, "starterPrompts"),
|
|
1046
|
-
starterPromptsLoading: !1
|
|
1047
|
-
});
|
|
1048
|
-
return;
|
|
1042
|
+
if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
1043
|
+
const s = De(e);
|
|
1044
|
+
if (s) {
|
|
1045
|
+
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1049
1048
|
}
|
|
1050
|
-
if (e
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
e.assistantDraft
|
|
1055
|
-
), a = o !== void 0;
|
|
1056
|
-
this.rememberUserMessageClientMessageIds(s);
|
|
1057
|
-
const l = ur(s);
|
|
1058
|
-
if (l) {
|
|
1059
|
-
const f = dr(s, l);
|
|
1060
|
-
this.retryAttemptsByClientMessageId[l] = Math.max(
|
|
1061
|
-
this.retryAttemptsByClientMessageId[l] ?? 0,
|
|
1062
|
-
f
|
|
1063
|
-
);
|
|
1049
|
+
if (!this.shouldIgnoreBackgroundSessionEvent(e)) {
|
|
1050
|
+
if (e.type === "run.steered") {
|
|
1051
|
+
this.handleRunSteered(e);
|
|
1052
|
+
return;
|
|
1064
1053
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
return Rt(R) ? !1 : !R || !l || !We(R) ? !0 : Fe(s, R) !== l;
|
|
1068
|
-
}), h = nr(
|
|
1069
|
-
this.state.messages,
|
|
1070
|
-
Wn(c, this.options.backendUrl)
|
|
1071
|
-
), p = At(h), w = !a && s.some(
|
|
1072
|
-
(f) => Et(
|
|
1073
|
-
H(f),
|
|
1074
|
-
this.state.assistantDraft,
|
|
1075
|
-
this.state.assistantDraftItemId,
|
|
1076
|
-
this.state.assistantDraftRespondsToUserMessageId,
|
|
1077
|
-
this.state.assistantDraftRunId
|
|
1078
|
-
)
|
|
1079
|
-
), y = a ? o?.content ?? "" : this.state.assistantDraft, u = !!o?.content, d = p && (!y || w), g = ar(h), m = d && g;
|
|
1080
|
-
if (!p && cr(this.state.messages, s))
|
|
1054
|
+
if (e.type === "runtime.pong") {
|
|
1055
|
+
this.clearHeartbeatAckTimer();
|
|
1081
1056
|
return;
|
|
1082
|
-
this.lastUserMessagePageUrl = lr(s);
|
|
1083
|
-
const T = d ? null : je(s);
|
|
1084
|
-
if (this.latestRecoverableClientMessageId = T, g && this.clearRetryTimers(), this.setState({
|
|
1085
|
-
sessionId: E(e.session, "id") ?? this.state.sessionId,
|
|
1086
|
-
messages: h,
|
|
1087
|
-
...n ? { pendingMessageStatus: n } : {},
|
|
1088
|
-
isRetrying: i,
|
|
1089
|
-
...a ? {
|
|
1090
|
-
assistantDraft: o?.content ?? "",
|
|
1091
|
-
assistantDraftItemId: o?.itemId ?? null,
|
|
1092
|
-
assistantDraftPhase: o?.phase ?? null,
|
|
1093
|
-
assistantDraftRespondsToUserMessageId: o?.respondsToUserMessageId ?? null,
|
|
1094
|
-
assistantDraftRunId: o?.runId ?? null
|
|
1095
|
-
} : w ? {
|
|
1096
|
-
assistantDraft: "",
|
|
1097
|
-
assistantDraftItemId: null,
|
|
1098
|
-
assistantDraftPhase: null,
|
|
1099
|
-
assistantDraftRespondsToUserMessageId: null,
|
|
1100
|
-
assistantDraftRunId: null
|
|
1101
|
-
} : {},
|
|
1102
|
-
...u ? {
|
|
1103
|
-
isThinking: !0,
|
|
1104
|
-
lastError: null
|
|
1105
|
-
} : d ? {
|
|
1106
|
-
isThinking: !1,
|
|
1107
|
-
...m ? {
|
|
1108
|
-
status: "connected",
|
|
1109
|
-
lastError: null,
|
|
1110
|
-
lastErrorCode: null,
|
|
1111
|
-
lastErrorSecuritySettingsUrl: null
|
|
1112
|
-
} : {}
|
|
1113
|
-
} : T ? {
|
|
1114
|
-
isThinking: !0,
|
|
1115
|
-
lastError: null
|
|
1116
|
-
} : {}
|
|
1117
|
-
}), d)
|
|
1118
|
-
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1119
|
-
else if (u || T) {
|
|
1120
|
-
if (T) {
|
|
1121
|
-
this.activeClientMessageId = T;
|
|
1122
|
-
const f = Y(s), R = f === null ? null : s[f];
|
|
1123
|
-
this.activeResponseUserMessageId = E(R, "id");
|
|
1124
|
-
}
|
|
1125
|
-
this.markThinkingProgress();
|
|
1126
1057
|
}
|
|
1127
|
-
if (
|
|
1128
|
-
|
|
1129
|
-
|
|
1058
|
+
if (rn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
1059
|
+
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
1060
|
+
const s = Ln(e), n = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1061
|
+
M("web-sdk.agent", "Received auth.ok appearance", {
|
|
1062
|
+
hasAppearance: n,
|
|
1063
|
+
rawAppearance: e.appearance,
|
|
1064
|
+
normalizedAppearance: s
|
|
1065
|
+
}), this.runtimeHelperJavascript = qn(e.runtimeHelpers)?.javascript ?? null;
|
|
1066
|
+
const r = Mt(e, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), o = e.starterPromptsLoading === !0, a = {
|
|
1067
|
+
user: $n(e.user),
|
|
1068
|
+
status: "connected",
|
|
1069
|
+
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1070
|
+
};
|
|
1071
|
+
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !re() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1072
|
+
type: "page.upsert",
|
|
1073
|
+
sessionId: this.state.sessionId,
|
|
1074
|
+
page: C(),
|
|
1075
|
+
model: this.options.model
|
|
1076
|
+
});
|
|
1077
|
+
return;
|
|
1130
1078
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
}
|
|
1153
|
-
if (e.type === "session.item") {
|
|
1154
|
-
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1155
|
-
const s = H(e.item);
|
|
1156
|
-
if (We(s)) {
|
|
1157
|
-
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1158
|
-
const r = E(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);
|
|
1159
|
-
if (r && a) {
|
|
1160
|
-
this.retryAfterInterruptedRun(r, a);
|
|
1161
|
-
return;
|
|
1079
|
+
if (e.type === "starterPrompts.updated") {
|
|
1080
|
+
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1081
|
+
starterPrompts: Mt(e, "starterPrompts"),
|
|
1082
|
+
starterPromptsLoading: !1
|
|
1083
|
+
});
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
if (e.type === "conversation.state") {
|
|
1087
|
+
const s = Array.isArray(e.items) ? e.items : [], n = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, r = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, i = e.isRetrying === !0;
|
|
1088
|
+
n && r && (this.pendingClientMessageId = r);
|
|
1089
|
+
const o = Jn(
|
|
1090
|
+
e.assistantDraft
|
|
1091
|
+
), a = o !== void 0;
|
|
1092
|
+
this.rememberUserMessageClientMessageIds(s);
|
|
1093
|
+
const l = pr(s);
|
|
1094
|
+
if (l) {
|
|
1095
|
+
const f = hr(s, l);
|
|
1096
|
+
this.retryAttemptsByClientMessageId[l] = Math.max(
|
|
1097
|
+
this.retryAttemptsByClientMessageId[l] ?? 0,
|
|
1098
|
+
f
|
|
1099
|
+
);
|
|
1162
1100
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1101
|
+
const c = s.filter((f) => {
|
|
1102
|
+
const R = H(f);
|
|
1103
|
+
return Rt(R) ? !1 : !R || !l || !He(R) ? !0 : je(s, R) !== l;
|
|
1104
|
+
}), p = ir(
|
|
1105
|
+
this.state.messages,
|
|
1106
|
+
jn(c, this.options.backendUrl)
|
|
1107
|
+
), h = At(p), w = !a && s.some(
|
|
1108
|
+
(f) => Et(
|
|
1109
|
+
H(f),
|
|
1110
|
+
this.state.assistantDraft,
|
|
1111
|
+
this.state.assistantDraftItemId,
|
|
1112
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
1113
|
+
this.state.assistantDraftRunId
|
|
1114
|
+
)
|
|
1115
|
+
), y = a ? o?.content ?? "" : this.state.assistantDraft, u = !!o?.content, d = h && (!y || w), g = cr(p), m = d && g;
|
|
1116
|
+
if (!h && dr(this.state.messages, s))
|
|
1165
1117
|
return;
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
this.state.assistantDraftRespondsToUserMessageId,
|
|
1181
|
-
this.state.assistantDraftRunId
|
|
1182
|
-
), c = a && (!this.state.assistantDraft || l), h = x(n) && (c || !this.state.isThinking && this.activeClientMessageId === null);
|
|
1183
|
-
this.setState({
|
|
1184
|
-
messages: o,
|
|
1185
|
-
...l ? {
|
|
1118
|
+
this.lastUserMessagePageUrl = ur(s);
|
|
1119
|
+
const T = d ? null : $e(s);
|
|
1120
|
+
if (this.latestRecoverableClientMessageId = T, g && this.clearRetryTimers(), this.setState({
|
|
1121
|
+
sessionId: E(e.session, "id") ?? this.state.sessionId,
|
|
1122
|
+
messages: p,
|
|
1123
|
+
...n ? { pendingMessageStatus: n } : {},
|
|
1124
|
+
isRetrying: i,
|
|
1125
|
+
...a ? {
|
|
1126
|
+
assistantDraft: o?.content ?? "",
|
|
1127
|
+
assistantDraftItemId: o?.itemId ?? null,
|
|
1128
|
+
assistantDraftPhase: o?.phase ?? null,
|
|
1129
|
+
assistantDraftRespondsToUserMessageId: o?.respondsToUserMessageId ?? null,
|
|
1130
|
+
assistantDraftRunId: o?.runId ?? null
|
|
1131
|
+
} : w ? {
|
|
1186
1132
|
assistantDraft: "",
|
|
1187
1133
|
assistantDraftItemId: null,
|
|
1188
1134
|
assistantDraftPhase: null,
|
|
1189
1135
|
assistantDraftRespondsToUserMessageId: null,
|
|
1190
1136
|
assistantDraftRunId: null
|
|
1191
1137
|
} : {},
|
|
1192
|
-
...
|
|
1138
|
+
...u ? {
|
|
1139
|
+
isThinking: !0,
|
|
1140
|
+
lastError: null
|
|
1141
|
+
} : d ? {
|
|
1193
1142
|
isThinking: !1,
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1143
|
+
...m ? {
|
|
1144
|
+
status: "connected",
|
|
1145
|
+
lastError: null,
|
|
1146
|
+
lastErrorCode: null,
|
|
1147
|
+
lastErrorSecuritySettingsUrl: null
|
|
1148
|
+
} : {}
|
|
1149
|
+
} : T ? {
|
|
1150
|
+
isThinking: !0,
|
|
1151
|
+
lastError: null
|
|
1201
1152
|
} : {}
|
|
1202
|
-
}),
|
|
1153
|
+
}), d)
|
|
1154
|
+
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1155
|
+
else if (u || T) {
|
|
1156
|
+
if (T) {
|
|
1157
|
+
this.activeClientMessageId = T;
|
|
1158
|
+
const f = Y(s), R = f === null ? null : s[f];
|
|
1159
|
+
this.activeResponseUserMessageId = E(R, "id");
|
|
1160
|
+
}
|
|
1161
|
+
this.markThinkingProgress();
|
|
1162
|
+
}
|
|
1163
|
+
if (l) {
|
|
1164
|
+
const f = E(e.session, "id") ?? this.state.sessionId;
|
|
1165
|
+
f && this.retryAfterInterruptedRun(f, l);
|
|
1166
|
+
}
|
|
1167
|
+
return;
|
|
1203
1168
|
}
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
messages: Be(this.state.messages, {
|
|
1211
|
-
id: o,
|
|
1212
|
-
role: "assistant",
|
|
1213
|
-
content: i,
|
|
1214
|
-
createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1215
|
-
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1216
|
-
dataType: "assistant_draft",
|
|
1217
|
-
...l ? { phase: l } : {},
|
|
1218
|
-
...c ? { respondsToUserMessageId: c } : {},
|
|
1219
|
-
...h ? { runId: h } : {}
|
|
1220
|
-
}),
|
|
1221
|
-
assistantDraft: i,
|
|
1222
|
-
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1223
|
-
assistantDraftPhase: l,
|
|
1224
|
-
assistantDraftRespondsToUserMessageId: c,
|
|
1225
|
-
assistantDraftRunId: h,
|
|
1226
|
-
isThinking: !0,
|
|
1227
|
-
isRetrying: !1
|
|
1228
|
-
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1229
|
-
return;
|
|
1230
|
-
}
|
|
1231
|
-
if (e.type === "chat.assistant_done") {
|
|
1232
|
-
if (typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(e.runId))
|
|
1169
|
+
if (e.type === "sessions.page") {
|
|
1170
|
+
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1171
|
+
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1172
|
+
sessions: Fn(e.sessions),
|
|
1173
|
+
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1174
|
+
}));
|
|
1233
1175
|
return;
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1176
|
+
}
|
|
1177
|
+
if (e.type === "session.pin.updated") {
|
|
1178
|
+
this.resolvePendingSessionMutation(this.pendingSessionPinRequests, e);
|
|
1237
1179
|
return;
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
)
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
)
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
this.nonTranscriptToolCallIds.add(s);
|
|
1273
|
-
else {
|
|
1274
|
-
const n = tr(e);
|
|
1180
|
+
}
|
|
1181
|
+
if (e.type === "session.rename.updated") {
|
|
1182
|
+
this.resolvePendingSessionMutation(this.pendingSessionRenameRequests, e);
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
if (e.type === "session.updated") {
|
|
1186
|
+
this.clearRunAckResyncRetryTimer();
|
|
1187
|
+
const s = E(e.session, "id");
|
|
1188
|
+
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1189
|
+
...this.pendingComposerWarmup.event,
|
|
1190
|
+
sessionId: s
|
|
1191
|
+
}, this.pendingComposerWarmup.scope = `${s}:${this.pendingComposerWarmup.event.page.url}`), this.setState({ sessionId: s ?? this.state.sessionId });
|
|
1192
|
+
const n = e.session && typeof e.session == "object" ? e.session.metadata : null;
|
|
1193
|
+
typeof e.warmupId == "string" && e.warmupId === this.activeComposerWarmupId && n && typeof n == "object" && n.composerPreload && this.clearPendingComposerWarmup();
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
if (e.type === "session.item") {
|
|
1197
|
+
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1198
|
+
const s = H(e.item);
|
|
1199
|
+
if (He(s)) {
|
|
1200
|
+
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1201
|
+
const r = E(e.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1202
|
+
if (r && a) {
|
|
1203
|
+
this.retryAfterInterruptedRun(r, a);
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
if (r && i) {
|
|
1207
|
+
this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
if (Rt(s))
|
|
1212
|
+
return;
|
|
1213
|
+
const n = Ht(e.item, this.options.backendUrl);
|
|
1275
1214
|
if (n) {
|
|
1276
|
-
const r =
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
);
|
|
1215
|
+
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1216
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), x(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
1217
|
+
const i = e.item.data;
|
|
1218
|
+
fr(i) && this.clearRunAckResyncRetryTimer();
|
|
1219
|
+
const o = Be(this.state.messages, n), a = At(o), l = Et(
|
|
1220
|
+
i,
|
|
1221
|
+
this.state.assistantDraft,
|
|
1222
|
+
this.state.assistantDraftItemId,
|
|
1223
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
1224
|
+
this.state.assistantDraftRunId
|
|
1225
|
+
), c = a && (!this.state.assistantDraft || l), p = x(n) && (c || !this.state.isThinking && this.activeClientMessageId === null);
|
|
1280
1226
|
this.setState({
|
|
1281
|
-
messages:
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1227
|
+
messages: o,
|
|
1228
|
+
...l ? {
|
|
1229
|
+
assistantDraft: "",
|
|
1230
|
+
assistantDraftItemId: null,
|
|
1231
|
+
assistantDraftPhase: null,
|
|
1232
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1233
|
+
assistantDraftRunId: null
|
|
1234
|
+
} : {},
|
|
1235
|
+
...c ? {
|
|
1236
|
+
isThinking: !1,
|
|
1237
|
+
isRetrying: !1
|
|
1238
|
+
} : {},
|
|
1239
|
+
...p ? {
|
|
1240
|
+
status: "connected",
|
|
1241
|
+
lastError: null,
|
|
1242
|
+
lastErrorCode: null,
|
|
1243
|
+
lastErrorSecuritySettingsUrl: null
|
|
1244
|
+
} : {}
|
|
1245
|
+
}), c && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
1289
1246
|
}
|
|
1290
|
-
}
|
|
1291
|
-
this.executeToolCall(e);
|
|
1292
|
-
return;
|
|
1293
|
-
}
|
|
1294
|
-
if (e.type === "tool.status") {
|
|
1295
|
-
const s = typeof e.callId == "string" ? e.callId : null;
|
|
1296
|
-
if (!s)
|
|
1297
1247
|
return;
|
|
1298
|
-
|
|
1299
|
-
if (
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
(
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1248
|
+
}
|
|
1249
|
+
if (e.type === "chat.assistant_delta") {
|
|
1250
|
+
this.clearRunAckResyncRetryTimer();
|
|
1251
|
+
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((h) => h.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, p = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1252
|
+
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = p), this.setState({
|
|
1253
|
+
messages: Be(this.state.messages, {
|
|
1254
|
+
id: o,
|
|
1255
|
+
role: "assistant",
|
|
1256
|
+
content: i,
|
|
1257
|
+
createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1258
|
+
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1259
|
+
dataType: "assistant_draft",
|
|
1260
|
+
...l ? { phase: l } : {},
|
|
1261
|
+
...c ? { respondsToUserMessageId: c } : {},
|
|
1262
|
+
...p ? { runId: p } : {}
|
|
1263
|
+
}),
|
|
1264
|
+
assistantDraft: i,
|
|
1265
|
+
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1266
|
+
assistantDraftPhase: l,
|
|
1267
|
+
assistantDraftRespondsToUserMessageId: c,
|
|
1268
|
+
assistantDraftRunId: p,
|
|
1269
|
+
isThinking: !0,
|
|
1270
|
+
isRetrying: !1
|
|
1271
|
+
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1310
1272
|
return;
|
|
1311
1273
|
}
|
|
1312
|
-
if (
|
|
1274
|
+
if (e.type === "chat.assistant_done") {
|
|
1275
|
+
if (typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(e.runId))
|
|
1276
|
+
return;
|
|
1277
|
+
this.retryableClientMessageId = null;
|
|
1278
|
+
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null;
|
|
1279
|
+
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1280
|
+
return;
|
|
1281
|
+
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = ms(
|
|
1282
|
+
this.state.messages.filter(
|
|
1283
|
+
(c) => c.dataType !== "assistant_draft" || !Zn(
|
|
1284
|
+
c,
|
|
1285
|
+
n,
|
|
1286
|
+
r
|
|
1287
|
+
)
|
|
1288
|
+
),
|
|
1289
|
+
n,
|
|
1290
|
+
r,
|
|
1291
|
+
$t
|
|
1292
|
+
);
|
|
1293
|
+
this.setState({
|
|
1294
|
+
sessionId: s,
|
|
1295
|
+
messages: er(
|
|
1296
|
+
l,
|
|
1297
|
+
typeof e.responseId == "string" ? e.responseId : null,
|
|
1298
|
+
n,
|
|
1299
|
+
r
|
|
1300
|
+
),
|
|
1301
|
+
assistantDraft: "",
|
|
1302
|
+
assistantDraftItemId: null,
|
|
1303
|
+
assistantDraftPhase: null,
|
|
1304
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1305
|
+
assistantDraftRunId: null,
|
|
1306
|
+
isThinking: a ? !1 : this.state.isThinking,
|
|
1307
|
+
isRetrying: a ? !1 : this.state.isRetrying
|
|
1308
|
+
}), a && this.clearThinkingWatchdog();
|
|
1313
1309
|
return;
|
|
1314
|
-
|
|
1315
|
-
if (e.
|
|
1316
|
-
this.
|
|
1310
|
+
}
|
|
1311
|
+
if (e.type === "tool.call") {
|
|
1312
|
+
this.clearRunAckResyncRetryTimer();
|
|
1313
|
+
const s = e.hiddenFromTranscript === !0 && typeof e.callId == "string" ? e.callId : null;
|
|
1314
|
+
if (s)
|
|
1315
|
+
this.nonTranscriptToolCallIds.add(s);
|
|
1316
|
+
else {
|
|
1317
|
+
const n = nr(e);
|
|
1318
|
+
if (n) {
|
|
1319
|
+
const r = tr(
|
|
1320
|
+
this.state.messages,
|
|
1321
|
+
n
|
|
1322
|
+
);
|
|
1323
|
+
this.setState({
|
|
1324
|
+
messages: r,
|
|
1325
|
+
isThinking: !0
|
|
1326
|
+
}), this.emit(
|
|
1327
|
+
"message",
|
|
1328
|
+
r.find(
|
|
1329
|
+
(i) => i.callId === n.callId
|
|
1330
|
+
) ?? n
|
|
1331
|
+
);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
this.executeToolCall(e);
|
|
1317
1335
|
return;
|
|
1318
1336
|
}
|
|
1319
|
-
if (
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1337
|
+
if (e.type === "tool.status") {
|
|
1338
|
+
const s = typeof e.callId == "string" ? e.callId : null;
|
|
1339
|
+
if (!s)
|
|
1340
|
+
return;
|
|
1341
|
+
const n = e.status === "queued" || e.status === "running";
|
|
1342
|
+
if (this.nonTranscriptToolCallIds.has(s) || n && this.terminalToolCallIds.has(s))
|
|
1343
|
+
return;
|
|
1344
|
+
n || this.terminalToolCallIds.add(s), this.state.messages.some(
|
|
1345
|
+
(i) => i.callId === s
|
|
1346
|
+
) ? this.setToolMessageLoading(s, n) : this.pendingToolLoadingByCallId.set(s, n);
|
|
1326
1347
|
return;
|
|
1327
1348
|
}
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1349
|
+
if (e.type === "error") {
|
|
1350
|
+
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1351
|
+
if (s && n) {
|
|
1352
|
+
window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof e.message == "string" ? e.message : "Pluno error"));
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
if (this.rejectPendingSessionMutation(this.pendingSessionPinRequests, e) || this.rejectPendingSessionMutation(this.pendingSessionRenameRequests, e))
|
|
1356
|
+
return;
|
|
1357
|
+
const r = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, i = typeof e.clientMessageId == "string" ? e.clientMessageId : null, o = e.retryable === !0 || e.code === "transient_model_error";
|
|
1358
|
+
if (e.code === "message_delivery_failed" && i && i === this.pendingClientMessageId) {
|
|
1359
|
+
this.failPendingDelivery(i);
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
if (i && i === this.pendingClientMessageId && this.promotePendingDelivery(
|
|
1363
|
+
i,
|
|
1364
|
+
r,
|
|
1365
|
+
typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null,
|
|
1334
1366
|
typeof e.runId == "string" ? e.runId : null
|
|
1335
|
-
),
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1367
|
+
), this.retryAfterRetryableError(e)) {
|
|
1368
|
+
e.code !== "run_still_active" && typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(e.runId);
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
o && r && i && (this.retryableClientMessageId = i);
|
|
1372
|
+
const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l = Rn(a.message);
|
|
1373
|
+
l && console.error(l), this.setState({
|
|
1374
|
+
messages: oe(
|
|
1375
|
+
this.state.messages,
|
|
1376
|
+
i ?? this.activeClientMessageId,
|
|
1377
|
+
typeof e.runId == "string" ? e.runId : null
|
|
1378
|
+
),
|
|
1379
|
+
status: "error",
|
|
1380
|
+
isThinking: !1,
|
|
1381
|
+
isRetrying: !1,
|
|
1382
|
+
lastError: a.message,
|
|
1383
|
+
lastErrorCode: typeof e.code == "string" ? e.code : null,
|
|
1384
|
+
lastErrorSecuritySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
|
|
1385
|
+
}), this.clearThinkingWatchdog(), this.emit("error", a);
|
|
1386
|
+
}
|
|
1343
1387
|
}
|
|
1344
1388
|
}
|
|
1345
1389
|
}
|
|
1346
1390
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1347
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1391
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !on(e))
|
|
1348
1392
|
return !1;
|
|
1349
1393
|
const s = De(e);
|
|
1350
1394
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
@@ -1370,10 +1414,10 @@ class xt {
|
|
|
1370
1414
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1371
1415
|
return !0;
|
|
1372
1416
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1373
|
-
if (i >=
|
|
1417
|
+
if (i >= G)
|
|
1374
1418
|
return !1;
|
|
1375
1419
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1376
|
-
const o =
|
|
1420
|
+
const o = X(
|
|
1377
1421
|
i,
|
|
1378
1422
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1379
1423
|
);
|
|
@@ -1394,7 +1438,7 @@ class xt {
|
|
|
1394
1438
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1395
1439
|
return;
|
|
1396
1440
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1397
|
-
if (n >=
|
|
1441
|
+
if (n >= G) {
|
|
1398
1442
|
this.reportHealthSignal("run_recovery_exhausted", {
|
|
1399
1443
|
clientMessageId: s,
|
|
1400
1444
|
retryAttempts: n,
|
|
@@ -1414,7 +1458,7 @@ class xt {
|
|
|
1414
1458
|
}
|
|
1415
1459
|
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(() => {
|
|
1416
1460
|
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 });
|
|
1417
|
-
},
|
|
1461
|
+
}, X(n));
|
|
1418
1462
|
}
|
|
1419
1463
|
clearRetryTimers() {
|
|
1420
1464
|
for (const e of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1515,13 +1559,13 @@ class xt {
|
|
|
1515
1559
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
1516
1560
|
return;
|
|
1517
1561
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1518
|
-
if (s >=
|
|
1562
|
+
if (s >= G) {
|
|
1519
1563
|
this.failPendingDelivery(e);
|
|
1520
1564
|
return;
|
|
1521
1565
|
}
|
|
1522
1566
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
1523
1567
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
1524
|
-
},
|
|
1568
|
+
}, X(s, mt));
|
|
1525
1569
|
}
|
|
1526
1570
|
failPendingDelivery(e) {
|
|
1527
1571
|
if (this.pendingClientMessageId !== e)
|
|
@@ -1530,7 +1574,7 @@ class xt {
|
|
|
1530
1574
|
this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = s, this.retryableClientMessageId = e, this.setState({
|
|
1531
1575
|
pendingMessageStatus: null,
|
|
1532
1576
|
isRetrying: !1,
|
|
1533
|
-
lastError:
|
|
1577
|
+
lastError: zs,
|
|
1534
1578
|
lastErrorCode: "message_delivery_failed"
|
|
1535
1579
|
});
|
|
1536
1580
|
}
|
|
@@ -1545,7 +1589,7 @@ class xt {
|
|
|
1545
1589
|
s,
|
|
1546
1590
|
typeof e.runId == "string" ? e.runId : null
|
|
1547
1591
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
1548
|
-
messages:
|
|
1592
|
+
messages: Tr(
|
|
1549
1593
|
this.state.messages,
|
|
1550
1594
|
s
|
|
1551
1595
|
)
|
|
@@ -1565,7 +1609,7 @@ class xt {
|
|
|
1565
1609
|
scheduleRunAckResyncRetry(e) {
|
|
1566
1610
|
this.clearRunAckResyncRetryTimer();
|
|
1567
1611
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1568
|
-
s >=
|
|
1612
|
+
s >= G || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1569
1613
|
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({
|
|
1570
1614
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1571
1615
|
isThinking: !0,
|
|
@@ -1579,7 +1623,7 @@ class xt {
|
|
|
1579
1623
|
clientMessageId: e,
|
|
1580
1624
|
automatic: !0
|
|
1581
1625
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(gt)));
|
|
1582
|
-
},
|
|
1626
|
+
}, X(s, mt)));
|
|
1583
1627
|
}
|
|
1584
1628
|
clearRunAckResyncRetryTimer() {
|
|
1585
1629
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1604,7 +1648,7 @@ class xt {
|
|
|
1604
1648
|
return;
|
|
1605
1649
|
}
|
|
1606
1650
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1607
|
-
if (n >=
|
|
1651
|
+
if (n >= G) {
|
|
1608
1652
|
M("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1609
1653
|
sessionId: this.state.sessionId,
|
|
1610
1654
|
clientMessageId: e
|
|
@@ -1629,7 +1673,7 @@ class xt {
|
|
|
1629
1673
|
sessionId: this.state.sessionId,
|
|
1630
1674
|
clientMessageId: e,
|
|
1631
1675
|
resyncAttempts: s + 1
|
|
1632
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1676
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog($s);
|
|
1633
1677
|
return;
|
|
1634
1678
|
}
|
|
1635
1679
|
this.setState({
|
|
@@ -1647,7 +1691,7 @@ class xt {
|
|
|
1647
1691
|
clientMessageId: e,
|
|
1648
1692
|
automatic: !0
|
|
1649
1693
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1650
|
-
},
|
|
1694
|
+
}, X(n)));
|
|
1651
1695
|
}
|
|
1652
1696
|
resyncThinkingSession() {
|
|
1653
1697
|
this.state.sessionId ? this.send({
|
|
@@ -1658,13 +1702,13 @@ class xt {
|
|
|
1658
1702
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1659
1703
|
}
|
|
1660
1704
|
async executeToolCall(e) {
|
|
1661
|
-
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 =
|
|
1705
|
+
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i = W(
|
|
1662
1706
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
1663
1707
|
), o = e.rawInput;
|
|
1664
1708
|
if (!s || !n || !r)
|
|
1665
1709
|
return;
|
|
1666
1710
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1667
|
-
if (!a && !l || !
|
|
1711
|
+
if (!a && !l || !Wr(o)) {
|
|
1668
1712
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1669
1713
|
type: "tool.result",
|
|
1670
1714
|
sessionId: s,
|
|
@@ -1710,14 +1754,14 @@ class xt {
|
|
|
1710
1754
|
startedAtUrl: location.href,
|
|
1711
1755
|
startedAtOrigin: location.origin
|
|
1712
1756
|
}), this.installSessionBrowserApis();
|
|
1713
|
-
let c = null,
|
|
1714
|
-
c = await this.executeRuntimeHelper(),
|
|
1757
|
+
let c = null, p;
|
|
1758
|
+
c = await this.executeRuntimeHelper(), p = await wt(
|
|
1715
1759
|
o,
|
|
1716
|
-
|
|
1717
|
-
).catch((
|
|
1760
|
+
Tn(e.runtimeContext, this.options.backendUrl)
|
|
1761
|
+
).catch((h) => ({
|
|
1718
1762
|
ok: !1,
|
|
1719
1763
|
exception: {
|
|
1720
|
-
message:
|
|
1764
|
+
message: h instanceof Error ? h.message : String(h)
|
|
1721
1765
|
}
|
|
1722
1766
|
})), this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
1723
1767
|
type: "tool.result",
|
|
@@ -1726,11 +1770,11 @@ class xt {
|
|
|
1726
1770
|
toolName: r,
|
|
1727
1771
|
summary: o.summary,
|
|
1728
1772
|
rawInput: k(o),
|
|
1729
|
-
rawOutput: k(
|
|
1730
|
-
}),
|
|
1773
|
+
rawOutput: k(Bn(p, c))
|
|
1774
|
+
}), kr(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1731
1775
|
}
|
|
1732
1776
|
setToolMessageLoading(e, s) {
|
|
1733
|
-
const n =
|
|
1777
|
+
const n = sr(
|
|
1734
1778
|
this.state.messages,
|
|
1735
1779
|
e,
|
|
1736
1780
|
s
|
|
@@ -1748,10 +1792,10 @@ class xt {
|
|
|
1748
1792
|
};
|
|
1749
1793
|
}
|
|
1750
1794
|
installSessionBrowserApis() {
|
|
1751
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
1795
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = cn();
|
|
1752
1796
|
}
|
|
1753
1797
|
cleanupSessionBrowserApis() {
|
|
1754
|
-
this.sessionBrowserApisCleanup && (
|
|
1798
|
+
this.sessionBrowserApisCleanup && (yn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
1755
1799
|
}
|
|
1756
1800
|
async executeRuntimeHelper() {
|
|
1757
1801
|
if (!this.runtimeHelperJavascript?.trim())
|
|
@@ -1759,15 +1803,15 @@ class xt {
|
|
|
1759
1803
|
const e = await wt({
|
|
1760
1804
|
javascript: this.runtimeHelperJavascript
|
|
1761
1805
|
});
|
|
1762
|
-
return e.ok === !1 ?
|
|
1806
|
+
return e.ok === !1 ? Wn(e) : null;
|
|
1763
1807
|
}
|
|
1764
1808
|
enableNetworkCapture() {
|
|
1765
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1766
|
-
|
|
1809
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = sn((e) => {
|
|
1810
|
+
Kr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
1767
1811
|
}));
|
|
1768
1812
|
}
|
|
1769
1813
|
enqueueNetworkEvent(e) {
|
|
1770
|
-
this.queuedNetworkEvents.length >=
|
|
1814
|
+
this.queuedNetworkEvents.length >= Gs || (this.queuedNetworkEvents.push(zr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1771
1815
|
this.networkBatchTimer = null;
|
|
1772
1816
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1773
1817
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -1776,12 +1820,12 @@ class xt {
|
|
|
1776
1820
|
page: C(),
|
|
1777
1821
|
events: s
|
|
1778
1822
|
});
|
|
1779
|
-
},
|
|
1823
|
+
}, Ks)));
|
|
1780
1824
|
}
|
|
1781
1825
|
scheduleReconnect() {
|
|
1782
1826
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1783
1827
|
return;
|
|
1784
|
-
const e =
|
|
1828
|
+
const e = en(this.reconnectAttempts);
|
|
1785
1829
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1786
1830
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1787
1831
|
M("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1797,8 +1841,8 @@ class xt {
|
|
|
1797
1841
|
const e = this.socket;
|
|
1798
1842
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1799
1843
|
this.socket === e && (M("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
1800
|
-
},
|
|
1801
|
-
},
|
|
1844
|
+
}, Os));
|
|
1845
|
+
}, Ns);
|
|
1802
1846
|
}
|
|
1803
1847
|
stopHeartbeat() {
|
|
1804
1848
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1806,6 +1850,12 @@ class xt {
|
|
|
1806
1850
|
clearHeartbeatAckTimer() {
|
|
1807
1851
|
this.heartbeatAckTimer !== null && (window.clearTimeout(this.heartbeatAckTimer), this.heartbeatAckTimer = null);
|
|
1808
1852
|
}
|
|
1853
|
+
clearPendingWarmupAckTimer() {
|
|
1854
|
+
this.pendingWarmupAckTimer !== null && (window.clearTimeout(this.pendingWarmupAckTimer), this.pendingWarmupAckTimer = null);
|
|
1855
|
+
}
|
|
1856
|
+
clearPendingComposerWarmup() {
|
|
1857
|
+
this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null;
|
|
1858
|
+
}
|
|
1809
1859
|
clearSocketConnectTimer() {
|
|
1810
1860
|
this.socketConnectTimer !== null && (window.clearTimeout(this.socketConnectTimer), this.socketConnectTimer = null);
|
|
1811
1861
|
}
|
|
@@ -1824,7 +1874,7 @@ class xt {
|
|
|
1824
1874
|
...e,
|
|
1825
1875
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1826
1876
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1827
|
-
},
|
|
1877
|
+
}, br(this.options.clientId, this.state), this.emit("state", this.getState()), ke("state", this.state.status, {
|
|
1828
1878
|
status: this.state.status,
|
|
1829
1879
|
sessionId: this.state.sessionId,
|
|
1830
1880
|
messageCount: this.state.messages.length,
|
|
@@ -1844,20 +1894,20 @@ class xt {
|
|
|
1844
1894
|
this.state.isThinking && this.activeClientMessageId ? this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId) : this.pendingClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.pendingClientMessageId);
|
|
1845
1895
|
}
|
|
1846
1896
|
getRunRecoveryExhaustedErrorMessage(e) {
|
|
1847
|
-
return e && this.browserConnectionInterruptedClientMessageIds.has(e) ?
|
|
1897
|
+
return e && this.browserConnectionInterruptedClientMessageIds.has(e) ? Fs : js;
|
|
1848
1898
|
}
|
|
1849
1899
|
emit(e, s) {
|
|
1850
1900
|
this.listeners[e]?.forEach((r) => r(s));
|
|
1851
1901
|
}
|
|
1852
1902
|
}
|
|
1853
|
-
const
|
|
1854
|
-
function
|
|
1855
|
-
const e = window.__plunoProductAgentNetworkCapture ??
|
|
1903
|
+
const Ue = /* @__PURE__ */ new WeakMap();
|
|
1904
|
+
function sn(t) {
|
|
1905
|
+
const e = window.__plunoProductAgentNetworkCapture ?? nn();
|
|
1856
1906
|
return e.subscribers.add(t), () => {
|
|
1857
1907
|
e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
1858
1908
|
};
|
|
1859
1909
|
}
|
|
1860
|
-
function
|
|
1910
|
+
function nn() {
|
|
1861
1911
|
const t = /* @__PURE__ */ new Set(), e = (w) => {
|
|
1862
1912
|
t.forEach((y) => {
|
|
1863
1913
|
try {
|
|
@@ -1874,11 +1924,11 @@ function tn() {
|
|
|
1874
1924
|
throw m;
|
|
1875
1925
|
}
|
|
1876
1926
|
try {
|
|
1877
|
-
const m = y instanceof Request ? y : null, T =
|
|
1878
|
-
if (!
|
|
1927
|
+
const m = y instanceof Request ? y : null, T = Hr(y, m), f = Yt(u?.headers ?? m?.headers);
|
|
1928
|
+
if (!B(T, f, u?.body)) {
|
|
1879
1929
|
const F = {
|
|
1880
|
-
requestId:
|
|
1881
|
-
url:
|
|
1930
|
+
requestId: Oe("fetch"),
|
|
1931
|
+
url: U(T, Pe),
|
|
1882
1932
|
method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
1883
1933
|
requestHeaders: f,
|
|
1884
1934
|
requestBody: _t(u?.body),
|
|
@@ -1886,19 +1936,19 @@ function tn() {
|
|
|
1886
1936
|
startedAt: new Date(d).toISOString()
|
|
1887
1937
|
};
|
|
1888
1938
|
g.then(
|
|
1889
|
-
(
|
|
1890
|
-
|
|
1939
|
+
(P) => {
|
|
1940
|
+
$r(P, F, d, e).catch(() => {
|
|
1891
1941
|
e({
|
|
1892
1942
|
...F,
|
|
1893
|
-
responseStatus:
|
|
1943
|
+
responseStatus: P.status,
|
|
1894
1944
|
durationMs: Date.now() - d
|
|
1895
1945
|
});
|
|
1896
1946
|
});
|
|
1897
1947
|
},
|
|
1898
|
-
(
|
|
1948
|
+
(P) => {
|
|
1899
1949
|
e({
|
|
1900
1950
|
...F,
|
|
1901
|
-
errorText: P
|
|
1951
|
+
errorText: U(P instanceof Error ? P.message : String(P)),
|
|
1902
1952
|
durationMs: Date.now() - d
|
|
1903
1953
|
});
|
|
1904
1954
|
}
|
|
@@ -1909,27 +1959,27 @@ function tn() {
|
|
|
1909
1959
|
return g;
|
|
1910
1960
|
}, a = function(y, u, d, g, m) {
|
|
1911
1961
|
const T = n.call(this, y, u, d ?? !0, g ?? void 0, m ?? void 0), f = typeof u == "string" ? u : u.toString();
|
|
1912
|
-
return
|
|
1913
|
-
requestId:
|
|
1962
|
+
return Ue.set(this, {
|
|
1963
|
+
requestId: Oe("xhr"),
|
|
1914
1964
|
method: String(y ?? "GET").toUpperCase(),
|
|
1915
|
-
url:
|
|
1965
|
+
url: U(f, Pe),
|
|
1916
1966
|
requestHeaders: {},
|
|
1917
1967
|
startedAtMs: Date.now(),
|
|
1918
1968
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1919
|
-
excluded:
|
|
1969
|
+
excluded: B(f)
|
|
1920
1970
|
}), T;
|
|
1921
1971
|
}, l = function(y, u) {
|
|
1922
|
-
const d = r.call(this, y, u), g =
|
|
1923
|
-
return g && Object.keys(g.requestHeaders).length < Je && (g.requestHeaders[y] = et(y, u), g.excluded = g.excluded ||
|
|
1972
|
+
const d = r.call(this, y, u), g = Ue.get(this);
|
|
1973
|
+
return g && Object.keys(g.requestHeaders).length < Je && (g.requestHeaders[y] = et(y, u), g.excluded = g.excluded || B(g.url, g.requestHeaders)), d;
|
|
1924
1974
|
}, c = function(y) {
|
|
1925
1975
|
try {
|
|
1926
|
-
const u =
|
|
1927
|
-
u && (u.excluded = u.excluded ||
|
|
1976
|
+
const u = Ue.get(this);
|
|
1977
|
+
u && (u.excluded = u.excluded || B(u.url, u.requestHeaders, y), u.requestBody = _t(y), u.excluded || this.addEventListener(
|
|
1928
1978
|
"loadend",
|
|
1929
1979
|
() => {
|
|
1930
1980
|
queueMicrotask(() => {
|
|
1931
1981
|
try {
|
|
1932
|
-
const d =
|
|
1982
|
+
const d = Xr(this.getAllResponseHeaders());
|
|
1933
1983
|
e({
|
|
1934
1984
|
requestId: u.requestId,
|
|
1935
1985
|
url: u.url,
|
|
@@ -1939,7 +1989,7 @@ function tn() {
|
|
|
1939
1989
|
resourceType: "xhr",
|
|
1940
1990
|
responseStatus: this.status,
|
|
1941
1991
|
responseHeaders: d,
|
|
1942
|
-
responseBody:
|
|
1992
|
+
responseBody: Fr(this, d),
|
|
1943
1993
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1944
1994
|
startedAt: u.startedAt,
|
|
1945
1995
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -1971,17 +2021,17 @@ function tn() {
|
|
|
1971
2021
|
XMLHttpRequest.prototype.send = c;
|
|
1972
2022
|
} catch {
|
|
1973
2023
|
}
|
|
1974
|
-
let
|
|
2024
|
+
let p = null;
|
|
1975
2025
|
if (typeof PerformanceObserver < "u") {
|
|
1976
|
-
|
|
2026
|
+
p = new PerformanceObserver((w) => {
|
|
1977
2027
|
for (const y of w.getEntries()) {
|
|
1978
2028
|
const u = y;
|
|
1979
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
2029
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || B(u.name))
|
|
1980
2030
|
continue;
|
|
1981
2031
|
const d = performance.timeOrigin + u.startTime;
|
|
1982
2032
|
e({
|
|
1983
|
-
requestId:
|
|
1984
|
-
url:
|
|
2033
|
+
requestId: Oe("resource"),
|
|
2034
|
+
url: U(u.name, Pe),
|
|
1985
2035
|
method: "GET",
|
|
1986
2036
|
resourceType: "resource",
|
|
1987
2037
|
responseStatus: u.responseStatus,
|
|
@@ -1991,15 +2041,15 @@ function tn() {
|
|
|
1991
2041
|
}
|
|
1992
2042
|
});
|
|
1993
2043
|
try {
|
|
1994
|
-
|
|
2044
|
+
p.observe({ type: "resource", buffered: !0 });
|
|
1995
2045
|
} catch {
|
|
1996
|
-
|
|
2046
|
+
p.disconnect(), p = null;
|
|
1997
2047
|
}
|
|
1998
2048
|
}
|
|
1999
|
-
const
|
|
2049
|
+
const h = {
|
|
2000
2050
|
subscribers: t,
|
|
2001
2051
|
destroy: () => {
|
|
2002
|
-
|
|
2052
|
+
p?.disconnect();
|
|
2003
2053
|
try {
|
|
2004
2054
|
window.fetch === o && (window.fetch = s);
|
|
2005
2055
|
} catch {
|
|
@@ -2018,7 +2068,7 @@ function tn() {
|
|
|
2018
2068
|
}
|
|
2019
2069
|
}
|
|
2020
2070
|
};
|
|
2021
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
2071
|
+
return window.__plunoProductAgentNetworkCapture = h, h;
|
|
2022
2072
|
}
|
|
2023
2073
|
function M(t, e, s) {
|
|
2024
2074
|
if (typeof window > "u")
|
|
@@ -2035,10 +2085,10 @@ function Tt(t) {
|
|
|
2035
2085
|
const e = typeof t == "function" ? t() : t;
|
|
2036
2086
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2037
2087
|
}
|
|
2038
|
-
function
|
|
2088
|
+
function rn(t) {
|
|
2039
2089
|
return t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call";
|
|
2040
2090
|
}
|
|
2041
|
-
function
|
|
2091
|
+
function on(t) {
|
|
2042
2092
|
return t.type === "run.steered" || t.type === "run.ack" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
|
|
2043
2093
|
}
|
|
2044
2094
|
function De(t) {
|
|
@@ -2056,31 +2106,31 @@ function De(t) {
|
|
|
2056
2106
|
}
|
|
2057
2107
|
return null;
|
|
2058
2108
|
}
|
|
2059
|
-
const
|
|
2060
|
-
function
|
|
2109
|
+
const an = 5e3, ln = 12e4;
|
|
2110
|
+
function cn() {
|
|
2061
2111
|
const t = [
|
|
2062
|
-
|
|
2063
|
-
|
|
2112
|
+
dn(),
|
|
2113
|
+
un()
|
|
2064
2114
|
].filter((e) => typeof e == "function");
|
|
2065
2115
|
return () => {
|
|
2066
2116
|
for (const e of t.reverse())
|
|
2067
2117
|
e();
|
|
2068
2118
|
};
|
|
2069
2119
|
}
|
|
2070
|
-
function
|
|
2071
|
-
return
|
|
2120
|
+
function un() {
|
|
2121
|
+
return Pt(globalThis, "getPageSnapshot", async () => Ye());
|
|
2072
2122
|
}
|
|
2073
|
-
function
|
|
2074
|
-
return
|
|
2075
|
-
inspectImage: async (e, s) => await
|
|
2123
|
+
function dn() {
|
|
2124
|
+
return Pt(globalThis, "pageImages", {
|
|
2125
|
+
inspectImage: async (e, s) => await pn(e, s)
|
|
2076
2126
|
});
|
|
2077
2127
|
}
|
|
2078
|
-
async function
|
|
2079
|
-
const s =
|
|
2128
|
+
async function pn(t, e = {}) {
|
|
2129
|
+
const s = mn(e.name), n = await hn(t);
|
|
2080
2130
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2081
2131
|
type: "pluno.pageImages.inspectImage",
|
|
2082
2132
|
imageAttached: !1,
|
|
2083
|
-
imageAttachmentError:
|
|
2133
|
+
imageAttachmentError: Nt
|
|
2084
2134
|
} : {
|
|
2085
2135
|
type: "pluno.pageImages.inspectImage",
|
|
2086
2136
|
imageAttached: !0,
|
|
@@ -2094,15 +2144,15 @@ async function un(t, e = {}) {
|
|
|
2094
2144
|
imageAttachmentError: n.error
|
|
2095
2145
|
};
|
|
2096
2146
|
}
|
|
2097
|
-
async function
|
|
2098
|
-
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error:
|
|
2147
|
+
async function hn(t) {
|
|
2148
|
+
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: Nt } : {
|
|
2099
2149
|
ok: !0,
|
|
2100
2150
|
mimeType: t.type,
|
|
2101
2151
|
sizeBytes: t.size,
|
|
2102
|
-
dataUrl: await
|
|
2103
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
2152
|
+
dataUrl: await In(t)
|
|
2153
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : gn(t);
|
|
2104
2154
|
}
|
|
2105
|
-
function
|
|
2155
|
+
function gn(t) {
|
|
2106
2156
|
if (!t.startsWith("data:") || !t.includes(","))
|
|
2107
2157
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
2108
2158
|
const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -2113,7 +2163,7 @@ function hn(t) {
|
|
|
2113
2163
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
2114
2164
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
2115
2165
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
2116
|
-
const o =
|
|
2166
|
+
const o = fn(i);
|
|
2117
2167
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
2118
2168
|
ok: !0,
|
|
2119
2169
|
mimeType: r,
|
|
@@ -2121,22 +2171,22 @@ function hn(t) {
|
|
|
2121
2171
|
dataUrl: `data:${r};base64,${i}`
|
|
2122
2172
|
};
|
|
2123
2173
|
}
|
|
2124
|
-
function
|
|
2174
|
+
function fn(t) {
|
|
2125
2175
|
if (t.length === 0 || t.length % 4 !== 0)
|
|
2126
2176
|
return null;
|
|
2127
2177
|
const e = t.length - t.replace(/=+$/, "").length;
|
|
2128
2178
|
return e > 2 ? null : t.length / 4 * 3 - e;
|
|
2129
2179
|
}
|
|
2130
|
-
function
|
|
2180
|
+
function mn(t) {
|
|
2131
2181
|
return (typeof t == "string" ? t.trim() : "") || "Page image";
|
|
2132
2182
|
}
|
|
2133
|
-
function
|
|
2183
|
+
function yn(t) {
|
|
2134
2184
|
try {
|
|
2135
2185
|
t();
|
|
2136
2186
|
} catch {
|
|
2137
2187
|
}
|
|
2138
2188
|
}
|
|
2139
|
-
function
|
|
2189
|
+
function In(t) {
|
|
2140
2190
|
return new Promise((e, s) => {
|
|
2141
2191
|
const n = new FileReader();
|
|
2142
2192
|
n.onload = () => {
|
|
@@ -2150,27 +2200,27 @@ function mn(t) {
|
|
|
2150
2200
|
}
|
|
2151
2201
|
async function wt(t, e) {
|
|
2152
2202
|
const s = Object.getPrototypeOf(async function() {
|
|
2153
|
-
}).constructor, n = t.timeoutMs ??
|
|
2203
|
+
}).constructor, n = t.timeoutMs ?? an, r = Date.now(), i = [];
|
|
2154
2204
|
let o;
|
|
2155
2205
|
const a = {
|
|
2156
2206
|
log: console.log,
|
|
2157
2207
|
info: console.info,
|
|
2158
2208
|
warn: console.warn,
|
|
2159
2209
|
error: console.error
|
|
2160
|
-
}, l = (c) => (...
|
|
2161
|
-
i.push({ level: c, args:
|
|
2210
|
+
}, l = (c) => (...p) => {
|
|
2211
|
+
i.push({ level: c, args: p }), a[c](...p);
|
|
2162
2212
|
};
|
|
2163
2213
|
console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error");
|
|
2164
2214
|
try {
|
|
2165
|
-
const c = /* @__PURE__ */ Symbol("execute_code_timeout"),
|
|
2215
|
+
const c = /* @__PURE__ */ Symbol("execute_code_timeout"), p = await Promise.race([
|
|
2166
2216
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
2167
|
-
new Promise((
|
|
2168
|
-
o = window.setTimeout(() =>
|
|
2217
|
+
new Promise((h) => {
|
|
2218
|
+
o = window.setTimeout(() => h(c), n);
|
|
2169
2219
|
})
|
|
2170
2220
|
]);
|
|
2171
|
-
return
|
|
2221
|
+
return p === c ? wn(n) : {
|
|
2172
2222
|
ok: !0,
|
|
2173
|
-
result:
|
|
2223
|
+
result: p,
|
|
2174
2224
|
console: i,
|
|
2175
2225
|
metadata: {
|
|
2176
2226
|
durationMs: Date.now() - r,
|
|
@@ -2197,7 +2247,7 @@ async function wt(t, e) {
|
|
|
2197
2247
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2198
2248
|
}
|
|
2199
2249
|
}
|
|
2200
|
-
function
|
|
2250
|
+
function Tn(t, e) {
|
|
2201
2251
|
if (!t || typeof t != "object")
|
|
2202
2252
|
return;
|
|
2203
2253
|
const s = t.sandboxFilesToken;
|
|
@@ -2207,20 +2257,20 @@ function yn(t, e) {
|
|
|
2207
2257
|
const r = () => {
|
|
2208
2258
|
if (!n)
|
|
2209
2259
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2210
|
-
}, i = async (a, l) => await
|
|
2260
|
+
}, i = async (a, l) => await bs(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2211
2261
|
return {
|
|
2212
2262
|
value: Object.freeze({
|
|
2213
2263
|
upload: async (a) => {
|
|
2214
2264
|
if (r(), !(a instanceof Blob))
|
|
2215
2265
|
throw new TypeError("sandboxFiles.upload expects a File or Blob");
|
|
2216
|
-
const l = a instanceof File && a.name ? a.name : "file", c = `?name=${encodeURIComponent(l)}&size_bytes=${a.size}`,
|
|
2266
|
+
const l = a instanceof File && a.name ? a.name : "file", c = `?name=${encodeURIComponent(l)}&size_bytes=${a.size}`, p = await i(`/api/product-agent/attachments/sandbox-files${c}`, {
|
|
2217
2267
|
method: "PUT",
|
|
2218
2268
|
headers: { Authorization: `Bearer ${s}` },
|
|
2219
2269
|
body: a
|
|
2220
2270
|
});
|
|
2221
|
-
if (!
|
|
2222
|
-
throw new Error(`sandboxFiles.upload failed (${
|
|
2223
|
-
return String((await
|
|
2271
|
+
if (!p.ok)
|
|
2272
|
+
throw new Error(`sandboxFiles.upload failed (${p.status})`);
|
|
2273
|
+
return String((await p.json()).path);
|
|
2224
2274
|
},
|
|
2225
2275
|
download: async (a) => {
|
|
2226
2276
|
r();
|
|
@@ -2230,8 +2280,8 @@ function yn(t, e) {
|
|
|
2230
2280
|
);
|
|
2231
2281
|
if (!l.ok)
|
|
2232
2282
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
2233
|
-
const c = await l.blob(),
|
|
2234
|
-
return new File([c],
|
|
2283
|
+
const c = await l.blob(), h = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
2284
|
+
return new File([c], h || a.split("/").pop() || "file", {
|
|
2235
2285
|
type: c.type
|
|
2236
2286
|
});
|
|
2237
2287
|
}
|
|
@@ -2241,7 +2291,7 @@ function yn(t, e) {
|
|
|
2241
2291
|
}
|
|
2242
2292
|
};
|
|
2243
2293
|
}
|
|
2244
|
-
function
|
|
2294
|
+
function wn(t) {
|
|
2245
2295
|
return {
|
|
2246
2296
|
ok: !1,
|
|
2247
2297
|
exception: {
|
|
@@ -2255,10 +2305,10 @@ function In(t) {
|
|
|
2255
2305
|
}
|
|
2256
2306
|
};
|
|
2257
2307
|
}
|
|
2258
|
-
function
|
|
2308
|
+
function Sn(t) {
|
|
2259
2309
|
return t.replace(/\/+$/, "");
|
|
2260
2310
|
}
|
|
2261
|
-
function
|
|
2311
|
+
function Mn(t) {
|
|
2262
2312
|
const e = {
|
|
2263
2313
|
sidepanel: "extension_sidepanel",
|
|
2264
2314
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2270,18 +2320,18 @@ function wn(t) {
|
|
|
2270
2320
|
};
|
|
2271
2321
|
return t && t in e ? e[t] : t ?? "embedded_custom_ui";
|
|
2272
2322
|
}
|
|
2273
|
-
function
|
|
2323
|
+
function An(t) {
|
|
2274
2324
|
return t === "pluno" ? "scheduled_continuation" : t ?? "user";
|
|
2275
2325
|
}
|
|
2276
|
-
function
|
|
2326
|
+
function Rn(t, e = location.origin) {
|
|
2277
2327
|
return /origin (?:is not allowed|does not match browser origin)/i.test(t) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
|
|
2278
2328
|
}
|
|
2279
|
-
function
|
|
2329
|
+
function En(t) {
|
|
2280
2330
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2281
2331
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2282
2332
|
}
|
|
2283
2333
|
function C() {
|
|
2284
|
-
const t =
|
|
2334
|
+
const t = Wt();
|
|
2285
2335
|
return {
|
|
2286
2336
|
url: location.href,
|
|
2287
2337
|
title: document.title,
|
|
@@ -2289,19 +2339,19 @@ function C() {
|
|
|
2289
2339
|
...t ? { plunoProductAgentUi: t } : {}
|
|
2290
2340
|
};
|
|
2291
2341
|
}
|
|
2292
|
-
function
|
|
2342
|
+
function Cn() {
|
|
2293
2343
|
return {
|
|
2294
2344
|
pageUrl: location.href,
|
|
2295
2345
|
pageTitle: document.title,
|
|
2296
2346
|
htmlContent: Ye()
|
|
2297
2347
|
};
|
|
2298
2348
|
}
|
|
2299
|
-
function
|
|
2300
|
-
return ce.add(t), ne || (ne =
|
|
2349
|
+
function bn(t) {
|
|
2350
|
+
return ce.add(t), ne || (ne = _n()), () => {
|
|
2301
2351
|
ce.delete(t), ce.size === 0 && (ne?.(), ne = null);
|
|
2302
2352
|
};
|
|
2303
2353
|
}
|
|
2304
|
-
function
|
|
2354
|
+
function _n() {
|
|
2305
2355
|
const t = () => {
|
|
2306
2356
|
for (const i of Array.from(ce))
|
|
2307
2357
|
i();
|
|
@@ -2317,13 +2367,13 @@ function bn() {
|
|
|
2317
2367
|
};
|
|
2318
2368
|
}
|
|
2319
2369
|
function re() {
|
|
2320
|
-
return
|
|
2370
|
+
return Wt()?.surface === "browser_extension_sdk_preview";
|
|
2321
2371
|
}
|
|
2322
2372
|
function Ye() {
|
|
2323
2373
|
if (!document.body)
|
|
2324
2374
|
return "";
|
|
2325
2375
|
const t = [], e = [], s = (d, g) => {
|
|
2326
|
-
const m =
|
|
2376
|
+
const m = $(g);
|
|
2327
2377
|
!m || e.includes(m) || (t.push([d, m]), e.push(m));
|
|
2328
2378
|
};
|
|
2329
2379
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
@@ -2332,22 +2382,22 @@ function Ye() {
|
|
|
2332
2382
|
);
|
|
2333
2383
|
for (const d of r.slice(0, 3))
|
|
2334
2384
|
s("Active overlay", ve(V(d), e));
|
|
2335
|
-
const i =
|
|
2385
|
+
const i = kn(), o = i ? ve(V(i), e) : "";
|
|
2336
2386
|
s("Main page content", o), s("Additional visible page text", ve(V(document.body), e));
|
|
2337
2387
|
const a = t.map(([d, g]) => `${d}:
|
|
2338
2388
|
${g}`).join(`
|
|
2339
2389
|
|
|
2340
|
-
`).trim().slice(0, 12e3), l =
|
|
2341
|
-
`,
|
|
2390
|
+
`).trim().slice(0, 12e3), l = Pn(r, i).trim(), c = `Simplified DOM outline:
|
|
2391
|
+
`, p = `
|
|
2342
2392
|
|
|
2343
2393
|
Visible page text:
|
|
2344
|
-
`,
|
|
2345
|
-
return `${c}${y}${
|
|
2394
|
+
`, h = 12e3 - c.length - p.length, w = Math.min(a.length, 7900), y = l.slice(0, h - w), u = a.slice(0, h - y.length);
|
|
2395
|
+
return `${c}${y}${p}${u}`;
|
|
2346
2396
|
}
|
|
2347
2397
|
function V(t) {
|
|
2348
2398
|
return t.innerText ?? t.textContent ?? "";
|
|
2349
2399
|
}
|
|
2350
|
-
function
|
|
2400
|
+
function $(t) {
|
|
2351
2401
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2352
2402
|
`).split(`
|
|
2353
2403
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2356,19 +2406,19 @@ function W(t) {
|
|
|
2356
2406
|
`).trim();
|
|
2357
2407
|
}
|
|
2358
2408
|
function ve(t, e) {
|
|
2359
|
-
let s =
|
|
2409
|
+
let s = $(t);
|
|
2360
2410
|
for (const n of e)
|
|
2361
2411
|
s = s.replace(n, "");
|
|
2362
|
-
return
|
|
2412
|
+
return $(s);
|
|
2363
2413
|
}
|
|
2364
2414
|
function Lt(t) {
|
|
2365
2415
|
const e = window.getComputedStyle(t);
|
|
2366
2416
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2367
2417
|
}
|
|
2368
|
-
function
|
|
2418
|
+
function kn() {
|
|
2369
2419
|
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Lt).sort((t, e) => V(e).length - V(t).length)[0] ?? null;
|
|
2370
2420
|
}
|
|
2371
|
-
function
|
|
2421
|
+
function Pn(t, e) {
|
|
2372
2422
|
const s = /* @__PURE__ */ new Set([
|
|
2373
2423
|
"main",
|
|
2374
2424
|
"nav",
|
|
@@ -2448,7 +2498,7 @@ function _n(t, e) {
|
|
|
2448
2498
|
"data-test",
|
|
2449
2499
|
"data-qa",
|
|
2450
2500
|
"data-cy"
|
|
2451
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements:
|
|
2501
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: p, priorityTargets: h } = Un(), w = new Set(t);
|
|
2452
2502
|
e && w.add(e);
|
|
2453
2503
|
let y = 0;
|
|
2454
2504
|
const u = (f) => {
|
|
@@ -2458,8 +2508,8 @@ function _n(t, e) {
|
|
|
2458
2508
|
const R = f.getAttribute("data-testid") || f.getAttribute("data-test") || f.getAttribute("data-qa") || f.getAttribute("data-cy") || "";
|
|
2459
2509
|
return `${f.tagName.toLowerCase()}|${u(f)}|${R}`;
|
|
2460
2510
|
}, g = (f, R, F) => {
|
|
2461
|
-
const
|
|
2462
|
-
const b = A.tagName.toLowerCase(), ye = window.getComputedStyle(A), Z =
|
|
2511
|
+
const P = (A, me) => {
|
|
2512
|
+
const b = A.tagName.toLowerCase(), ye = window.getComputedStyle(A), Z = p.has(A);
|
|
2463
2513
|
if (y >= 1e3 && !Z || F.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ye.display === "none" || ye.visibility === "hidden")
|
|
2464
2514
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2465
2515
|
y += 1;
|
|
@@ -2471,31 +2521,31 @@ function _n(t, e) {
|
|
|
2471
2521
|
const Te = /* @__PURE__ */ new Map(), st = /* @__PURE__ */ new Map();
|
|
2472
2522
|
for (const I of Ie) {
|
|
2473
2523
|
const S = d(I), v = st.get(S) ?? 0;
|
|
2474
|
-
st.set(S, v + 1), (te.get(S) ?? 0) > 8 && v >= 6 && !
|
|
2524
|
+
st.set(S, v + 1), (te.get(S) ?? 0) > 8 && v >= 6 && !p.has(I) && Te.set(S, (Te.get(S) ?? 0) + 1);
|
|
2475
2525
|
}
|
|
2476
2526
|
const nt = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Set(), we = [], it = [];
|
|
2477
2527
|
for (const I of Ie) {
|
|
2478
2528
|
const S = d(I), v = te.get(S) ?? 0, lt = nt.get(S) ?? 0;
|
|
2479
|
-
if (nt.set(S, lt + 1), v > 8 && lt >= 6 && !
|
|
2529
|
+
if (nt.set(S, lt + 1), v > 8 && lt >= 6 && !p.has(I)) {
|
|
2480
2530
|
rt.has(S) || (we.push([`… ${Te.get(S) ?? 0} similar siblings omitted`]), rt.add(S));
|
|
2481
2531
|
continue;
|
|
2482
2532
|
}
|
|
2483
|
-
const ct =
|
|
2533
|
+
const ct = P(I, me);
|
|
2484
2534
|
it.push(ct), we.push(ct.lines);
|
|
2485
2535
|
}
|
|
2486
2536
|
const Se = [];
|
|
2487
2537
|
if (A.shadowRoot)
|
|
2488
2538
|
for (const I of Array.from(A.shadowRoot.children))
|
|
2489
|
-
I instanceof HTMLElement && Se.push(
|
|
2490
|
-
const se = [...it, ...Se], Me = ee.length > 0 || is || se.some((I) => I.hasUsefulContent), ot =
|
|
2539
|
+
I instanceof HTMLElement && Se.push(P(I, me + 1));
|
|
2540
|
+
const se = [...it, ...Se], Me = ee.length > 0 || is || se.some((I) => I.hasUsefulContent), ot = $(
|
|
2491
2541
|
[ee, ...se.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
2492
|
-
).slice(0, 180), os = A.hasAttribute("contenteditable") && (ee.length > 0 || !A.querySelector("[contenteditable]")), at = c.some((I) => A.hasAttribute(I)) || !!tt || os, Ae = (A.getClientRects().length > 0 || ye.display === "contents") && (s.has(b) || at || Z) && (Me || Z) && (!r.has(b) || Me || at || Z), Re = Ae ? 1 : 0,
|
|
2542
|
+
).slice(0, 180), os = A.hasAttribute("contenteditable") && (ee.length > 0 || !A.querySelector("[contenteditable]")), at = c.some((I) => A.hasAttribute(I)) || !!tt || os, Ae = (A.getClientRects().length > 0 || ye.display === "contents") && (s.has(b) || at || Z) && (Me || Z) && (!r.has(b) || Me || at || Z), Re = Ae ? 1 : 0, z = [];
|
|
2493
2543
|
if (Ae) {
|
|
2494
2544
|
const I = se.some((v) => v.containsTextElement), S = n.has(b) && !I ? ot : ee;
|
|
2495
|
-
|
|
2545
|
+
z.push(qt(A, l, o, S.slice(0, 180)));
|
|
2496
2546
|
}
|
|
2497
2547
|
for (const I of we)
|
|
2498
|
-
|
|
2548
|
+
z.push(...ie(I, Re));
|
|
2499
2549
|
const Ee = Se.flatMap((I) => I.lines);
|
|
2500
2550
|
if (Ee.length > 0) {
|
|
2501
2551
|
const I = Ee.slice(0, 20);
|
|
@@ -2503,22 +2553,22 @@ function _n(t, e) {
|
|
|
2503
2553
|
const S = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
|
|
2504
2554
|
if (me < 2 && !S) {
|
|
2505
2555
|
const v = Ae ? "#shadow-root" : `${b} #shadow-root`;
|
|
2506
|
-
|
|
2556
|
+
z.push(...ie([v, ...ie(I, 1)], Re));
|
|
2507
2557
|
} else
|
|
2508
|
-
|
|
2558
|
+
z.push(...ie(I, Re));
|
|
2509
2559
|
}
|
|
2510
2560
|
return {
|
|
2511
|
-
lines:
|
|
2561
|
+
lines: z,
|
|
2512
2562
|
hasUsefulContent: Me,
|
|
2513
2563
|
textPreview: ot,
|
|
2514
2564
|
containsTextElement: n.has(b) || se.some((I) => I.containsTextElement)
|
|
2515
2565
|
};
|
|
2516
2566
|
};
|
|
2517
|
-
return [`--- ${R} ---`, ...
|
|
2567
|
+
return [`--- ${R} ---`, ...P(f, 0).lines].join(`
|
|
2518
2568
|
`);
|
|
2519
|
-
}, m = [], T =
|
|
2569
|
+
}, m = [], T = $(window.getSelection()?.toString() ?? "");
|
|
2520
2570
|
T && m.push(`--- selected text ---
|
|
2521
|
-
${JSON.stringify(T)}`),
|
|
2571
|
+
${JSON.stringify(T)}`), h.length > 0 && m.push(Dn(h, s, l, o));
|
|
2522
2572
|
for (const f of t.slice(0, 3))
|
|
2523
2573
|
m.push(g(f, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2524
2574
|
if (e && m.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2533,7 +2583,7 @@ function qt(t, e, s, n) {
|
|
|
2533
2583
|
const r = t.tagName.toLowerCase();
|
|
2534
2584
|
let i = r;
|
|
2535
2585
|
const o = t.getAttribute("id");
|
|
2536
|
-
o &&
|
|
2586
|
+
o && vn(o) && (i += `#${o}`);
|
|
2537
2587
|
for (const a of e) {
|
|
2538
2588
|
const l = t.getAttribute(a);
|
|
2539
2589
|
l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
|
|
@@ -2546,20 +2596,20 @@ function qt(t, e, s, n) {
|
|
|
2546
2596
|
t.hasAttribute(a) && (i += `[${a}]`);
|
|
2547
2597
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2548
2598
|
}
|
|
2549
|
-
function
|
|
2599
|
+
function Un() {
|
|
2550
2600
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
|
|
2551
2601
|
if (!a)
|
|
2552
2602
|
return;
|
|
2553
2603
|
const c = window.getComputedStyle(a);
|
|
2554
2604
|
if (c.display === "none" || c.visibility === "hidden")
|
|
2555
2605
|
return;
|
|
2556
|
-
const
|
|
2557
|
-
|
|
2558
|
-
let
|
|
2559
|
-
for (;
|
|
2560
|
-
t.add(
|
|
2561
|
-
const w =
|
|
2562
|
-
|
|
2606
|
+
const p = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
2607
|
+
p.add(l), e.set(a, p);
|
|
2608
|
+
let h = a;
|
|
2609
|
+
for (; h; ) {
|
|
2610
|
+
t.add(h);
|
|
2611
|
+
const w = h.getRootNode();
|
|
2612
|
+
h = h.parentElement ?? (w instanceof ShadowRoot && w.host instanceof HTMLElement ? w.host : null);
|
|
2563
2613
|
}
|
|
2564
2614
|
};
|
|
2565
2615
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -2578,9 +2628,9 @@ function kn() {
|
|
|
2578
2628
|
], o = [document];
|
|
2579
2629
|
for (let a = 0; a < o.length; a += 1) {
|
|
2580
2630
|
const l = o[a];
|
|
2581
|
-
for (const [c,
|
|
2582
|
-
for (const
|
|
2583
|
-
s(
|
|
2631
|
+
for (const [c, p] of i)
|
|
2632
|
+
for (const h of Array.from(l.querySelectorAll(c)))
|
|
2633
|
+
s(h, p);
|
|
2584
2634
|
for (const c of Array.from(l.querySelectorAll("*")))
|
|
2585
2635
|
c.shadowRoot && o.push(c.shadowRoot);
|
|
2586
2636
|
}
|
|
@@ -2589,22 +2639,22 @@ function kn() {
|
|
|
2589
2639
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
2590
2640
|
};
|
|
2591
2641
|
}
|
|
2592
|
-
function
|
|
2642
|
+
function Dn(t, e, s, n) {
|
|
2593
2643
|
const r = ["--- active/current elements ---"];
|
|
2594
2644
|
for (const i of t) {
|
|
2595
2645
|
const o = [];
|
|
2596
2646
|
let a = i.element;
|
|
2597
2647
|
for (; a; ) {
|
|
2598
|
-
const
|
|
2599
|
-
(a === i.element || e.has(
|
|
2600
|
-
const
|
|
2601
|
-
a = a.parentElement ?? (
|
|
2648
|
+
const p = a.tagName.toLowerCase();
|
|
2649
|
+
(a === i.element || e.has(p) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
2650
|
+
const h = a.getRootNode();
|
|
2651
|
+
a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
|
|
2602
2652
|
}
|
|
2603
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((
|
|
2604
|
-
|
|
2653
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((p, h) => qt(
|
|
2654
|
+
p,
|
|
2605
2655
|
s,
|
|
2606
2656
|
n,
|
|
2607
|
-
|
|
2657
|
+
h === l.length - 1 ? Bt(p).slice(0, 180) : ""
|
|
2608
2658
|
));
|
|
2609
2659
|
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
2610
2660
|
}
|
|
@@ -2621,14 +2671,14 @@ function ie(t, e) {
|
|
|
2621
2671
|
return t.map((n) => `${s}${n}`);
|
|
2622
2672
|
}
|
|
2623
2673
|
function Bt(t) {
|
|
2624
|
-
return
|
|
2674
|
+
return $(
|
|
2625
2675
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
2626
2676
|
);
|
|
2627
2677
|
}
|
|
2628
|
-
function
|
|
2678
|
+
function vn(t) {
|
|
2629
2679
|
return t.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(t) && !/[a-f0-9]{12,}/i.test(t) && !/:r[0-9a-z]+:/i.test(t);
|
|
2630
2680
|
}
|
|
2631
|
-
function
|
|
2681
|
+
function Wt() {
|
|
2632
2682
|
const t = document.querySelector(ut);
|
|
2633
2683
|
if (!(t ?? document.querySelector(Le)))
|
|
2634
2684
|
return;
|
|
@@ -2654,13 +2704,13 @@ function Ht() {
|
|
|
2654
2704
|
},
|
|
2655
2705
|
{
|
|
2656
2706
|
name: "widget_timeline",
|
|
2657
|
-
selector:
|
|
2707
|
+
selector: Ps,
|
|
2658
2708
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2659
2709
|
}
|
|
2660
2710
|
]
|
|
2661
2711
|
};
|
|
2662
2712
|
}
|
|
2663
|
-
function
|
|
2713
|
+
function Nn(t) {
|
|
2664
2714
|
try {
|
|
2665
2715
|
const e = JSON.parse(t);
|
|
2666
2716
|
return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
|
|
@@ -2668,7 +2718,7 @@ function Dn(t) {
|
|
|
2668
2718
|
return { type: "error", message: "Invalid server event" };
|
|
2669
2719
|
}
|
|
2670
2720
|
}
|
|
2671
|
-
function
|
|
2721
|
+
function On(t) {
|
|
2672
2722
|
if (typeof t != "string")
|
|
2673
2723
|
return null;
|
|
2674
2724
|
try {
|
|
@@ -2684,10 +2734,10 @@ function Mt(t, e) {
|
|
|
2684
2734
|
const s = t[e];
|
|
2685
2735
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2686
2736
|
}
|
|
2687
|
-
function
|
|
2737
|
+
function xn(t) {
|
|
2688
2738
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
2689
2739
|
}
|
|
2690
|
-
function
|
|
2740
|
+
function Ln(t) {
|
|
2691
2741
|
if (!t || typeof t != "object")
|
|
2692
2742
|
return null;
|
|
2693
2743
|
const e = t, s = e.appearance, n = s && typeof s == "object" ? s : e, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -2698,13 +2748,13 @@ function Nn(t) {
|
|
|
2698
2748
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2699
2749
|
};
|
|
2700
2750
|
}
|
|
2701
|
-
function
|
|
2751
|
+
function qn(t) {
|
|
2702
2752
|
if (!t || typeof t != "object")
|
|
2703
2753
|
return null;
|
|
2704
2754
|
const e = t.javascript;
|
|
2705
2755
|
return typeof e != "string" || !e.trim() ? null : { javascript: e };
|
|
2706
2756
|
}
|
|
2707
|
-
function
|
|
2757
|
+
function Bn(t, e) {
|
|
2708
2758
|
return e ? t && typeof t == "object" ? {
|
|
2709
2759
|
...t,
|
|
2710
2760
|
helperError: e
|
|
@@ -2714,23 +2764,23 @@ function Ln(t, e) {
|
|
|
2714
2764
|
helperError: e
|
|
2715
2765
|
} : t;
|
|
2716
2766
|
}
|
|
2717
|
-
function
|
|
2767
|
+
function Wn(t) {
|
|
2718
2768
|
if (!t || typeof t != "object")
|
|
2719
2769
|
return t;
|
|
2720
2770
|
const e = t;
|
|
2721
2771
|
return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : t;
|
|
2722
2772
|
}
|
|
2723
|
-
function
|
|
2773
|
+
function Hn() {
|
|
2724
2774
|
const t = "pluno.productAgent.clientId", e = window.localStorage.getItem(t);
|
|
2725
2775
|
if (e)
|
|
2726
2776
|
return e;
|
|
2727
2777
|
const s = crypto.randomUUID();
|
|
2728
2778
|
return window.localStorage.setItem(t, s), s;
|
|
2729
2779
|
}
|
|
2730
|
-
function
|
|
2780
|
+
function L() {
|
|
2731
2781
|
return crypto.randomUUID();
|
|
2732
2782
|
}
|
|
2733
|
-
function
|
|
2783
|
+
function $n(t) {
|
|
2734
2784
|
if (!t || typeof t != "object")
|
|
2735
2785
|
return null;
|
|
2736
2786
|
const e = t, s = typeof e.id == "string" ? e.id : null;
|
|
@@ -2741,12 +2791,12 @@ function Hn(t) {
|
|
|
2741
2791
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
2742
2792
|
} : null;
|
|
2743
2793
|
}
|
|
2744
|
-
function
|
|
2745
|
-
return Array.isArray(t) ?
|
|
2746
|
-
t.map((s) =>
|
|
2794
|
+
function jn(t, e) {
|
|
2795
|
+
return Array.isArray(t) ? Fe(
|
|
2796
|
+
t.map((s) => Ht(s, e)).filter((s) => s !== null)
|
|
2747
2797
|
) : [];
|
|
2748
2798
|
}
|
|
2749
|
-
function
|
|
2799
|
+
function Fn(t) {
|
|
2750
2800
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
2751
2801
|
if (!e || typeof e != "object")
|
|
2752
2802
|
return [];
|
|
@@ -2767,7 +2817,7 @@ function jn(t) {
|
|
|
2767
2817
|
];
|
|
2768
2818
|
}) : [];
|
|
2769
2819
|
}
|
|
2770
|
-
function
|
|
2820
|
+
function Ht(t, e) {
|
|
2771
2821
|
if (!t || typeof t != "object")
|
|
2772
2822
|
return null;
|
|
2773
2823
|
const s = t, n = s.data;
|
|
@@ -2782,12 +2832,12 @@ function Wt(t, e) {
|
|
|
2782
2832
|
role: i,
|
|
2783
2833
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2784
2834
|
content: gs(
|
|
2785
|
-
|
|
2835
|
+
Yn(r.content),
|
|
2786
2836
|
e
|
|
2787
2837
|
),
|
|
2788
2838
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2789
|
-
...
|
|
2790
|
-
respondsToUserMessageId:
|
|
2839
|
+
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2840
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2791
2841
|
..._(r) ? { runId: _(r) } : {},
|
|
2792
2842
|
attachments: Xt(r.attachments, e)
|
|
2793
2843
|
};
|
|
@@ -2800,54 +2850,54 @@ function Wt(t, e) {
|
|
|
2800
2850
|
}), o;
|
|
2801
2851
|
}
|
|
2802
2852
|
if (r.type === "function_call_output") {
|
|
2803
|
-
const i =
|
|
2853
|
+
const i = Cs(r.output);
|
|
2804
2854
|
if (i)
|
|
2805
2855
|
return {
|
|
2806
2856
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2807
2857
|
role: "tool",
|
|
2808
2858
|
content: "",
|
|
2809
2859
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2810
|
-
respondsToUserMessageId:
|
|
2860
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2811
2861
|
..._(r) ? { runId: _(r) } : {},
|
|
2812
2862
|
dataType: "scheduled_check_in",
|
|
2813
2863
|
toolName: Dt,
|
|
2814
|
-
callId:
|
|
2864
|
+
callId: Ne(r) ?? void 0,
|
|
2815
2865
|
scheduledCheckInAt: i
|
|
2816
2866
|
};
|
|
2817
|
-
const o =
|
|
2867
|
+
const o = Kn(r.output);
|
|
2818
2868
|
return o ? {
|
|
2819
2869
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2820
2870
|
role: "tool",
|
|
2821
2871
|
content: `Connect ${o.appName} to continue`,
|
|
2822
2872
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2823
|
-
...
|
|
2824
|
-
respondsToUserMessageId:
|
|
2873
|
+
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2874
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2825
2875
|
..._(r) ? { runId: _(r) } : {},
|
|
2826
2876
|
dataType: "function_call_output",
|
|
2827
2877
|
toolName: "authenticate_pipedream_app",
|
|
2828
|
-
callId:
|
|
2878
|
+
callId: Ne(r) ?? void 0,
|
|
2829
2879
|
integrationAuthRequest: o
|
|
2830
2880
|
} : null;
|
|
2831
2881
|
}
|
|
2832
2882
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2833
2883
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2834
2884
|
role: "tool",
|
|
2835
|
-
content: r.type === "mcp_call" ?
|
|
2885
|
+
content: r.type === "mcp_call" ? zn(r) : Xn(r),
|
|
2836
2886
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2837
|
-
...
|
|
2838
|
-
respondsToUserMessageId:
|
|
2887
|
+
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2888
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2839
2889
|
..._(r) ? { runId: _(r) } : {},
|
|
2840
2890
|
dataType: String(r.type),
|
|
2841
2891
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2842
|
-
callId:
|
|
2892
|
+
callId: Ne(r) ?? void 0,
|
|
2843
2893
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
2844
2894
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2845
2895
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2846
2896
|
role: "system",
|
|
2847
|
-
content:
|
|
2897
|
+
content: Gn(r),
|
|
2848
2898
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2849
|
-
...
|
|
2850
|
-
respondsToUserMessageId:
|
|
2899
|
+
...N(r) !== null ? { causalSequence: N(r) } : {},
|
|
2900
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
2851
2901
|
..._(r) ? { runId: _(r) } : {},
|
|
2852
2902
|
dataType: String(r.type),
|
|
2853
2903
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -2856,11 +2906,11 @@ function Wt(t, e) {
|
|
|
2856
2906
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
2857
2907
|
} : null;
|
|
2858
2908
|
}
|
|
2859
|
-
function
|
|
2909
|
+
function zn(t) {
|
|
2860
2910
|
const s = (typeof t.server_label == "string" ? t.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
2861
2911
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2862
2912
|
}
|
|
2863
|
-
function
|
|
2913
|
+
function Kn(t) {
|
|
2864
2914
|
if (typeof t != "string")
|
|
2865
2915
|
return null;
|
|
2866
2916
|
try {
|
|
@@ -2877,10 +2927,10 @@ function $n(t) {
|
|
|
2877
2927
|
return null;
|
|
2878
2928
|
}
|
|
2879
2929
|
}
|
|
2880
|
-
function
|
|
2930
|
+
function Gn(t) {
|
|
2881
2931
|
return t.type === "run_status" && t.status === "stopped" ? "Run stopped by user" : t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message.replace(/Product Agent/g, "Pluno") : t.type === "run_status" && t.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
|
|
2882
2932
|
}
|
|
2883
|
-
function
|
|
2933
|
+
function Xn(t) {
|
|
2884
2934
|
if (t.type === "web_search_call") {
|
|
2885
2935
|
const e = t.action;
|
|
2886
2936
|
if (e && typeof e == "object") {
|
|
@@ -2892,26 +2942,26 @@ function Kn(t) {
|
|
|
2892
2942
|
}
|
|
2893
2943
|
return "🔎 Searching the web";
|
|
2894
2944
|
}
|
|
2895
|
-
return
|
|
2945
|
+
return Vn(t);
|
|
2896
2946
|
}
|
|
2897
|
-
function
|
|
2947
|
+
function Vn(t) {
|
|
2898
2948
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
2899
|
-
return
|
|
2949
|
+
return W(t.summary);
|
|
2900
2950
|
if (typeof t.arguments == "string")
|
|
2901
2951
|
try {
|
|
2902
2952
|
const e = JSON.parse(t.arguments);
|
|
2903
2953
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2904
|
-
return
|
|
2954
|
+
return W(e.summary);
|
|
2905
2955
|
} catch {
|
|
2906
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
2956
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? W(t.name) : "🛠️ Run tool";
|
|
2907
2957
|
}
|
|
2908
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
2958
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? W(t.name) : "🛠️ Run tool";
|
|
2909
2959
|
}
|
|
2910
|
-
function
|
|
2960
|
+
function W(t) {
|
|
2911
2961
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
2912
2962
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
2913
2963
|
}
|
|
2914
|
-
function
|
|
2964
|
+
function Jn(t) {
|
|
2915
2965
|
if (t == null)
|
|
2916
2966
|
return t;
|
|
2917
2967
|
if (typeof t != "object")
|
|
@@ -2926,14 +2976,14 @@ function Xn(t) {
|
|
|
2926
2976
|
runId: typeof e.runId == "string" ? e.runId : null
|
|
2927
2977
|
};
|
|
2928
2978
|
}
|
|
2929
|
-
function
|
|
2979
|
+
function Ne(t) {
|
|
2930
2980
|
const e = t.callId ?? t.call_id;
|
|
2931
2981
|
return typeof e == "string" && e ? e : null;
|
|
2932
2982
|
}
|
|
2933
|
-
function
|
|
2983
|
+
function N(t) {
|
|
2934
2984
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
2935
2985
|
}
|
|
2936
|
-
function
|
|
2986
|
+
function Yn(t) {
|
|
2937
2987
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
2938
2988
|
if (!e || typeof e != "object")
|
|
2939
2989
|
return "";
|
|
@@ -2942,30 +2992,30 @@ function Vn(t) {
|
|
|
2942
2992
|
}).filter(Boolean).join("") : "";
|
|
2943
2993
|
}
|
|
2944
2994
|
function Be(t, e) {
|
|
2945
|
-
const s =
|
|
2946
|
-
|
|
2947
|
-
|
|
2995
|
+
const s = jt(t, e), n = rr(
|
|
2996
|
+
Qn(
|
|
2997
|
+
lr(t, e),
|
|
2948
2998
|
s
|
|
2949
2999
|
),
|
|
2950
3000
|
s
|
|
2951
3001
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2952
3002
|
if (r === -1)
|
|
2953
|
-
return
|
|
3003
|
+
return Fe(
|
|
2954
3004
|
[...n, s]
|
|
2955
3005
|
);
|
|
2956
3006
|
const i = [...n];
|
|
2957
|
-
return i[r] = s,
|
|
3007
|
+
return i[r] = s, Fe(i);
|
|
2958
3008
|
}
|
|
2959
|
-
function
|
|
3009
|
+
function Qn(t, e) {
|
|
2960
3010
|
const s = e.assistantDraftItemId;
|
|
2961
3011
|
return s ? t.map(
|
|
2962
3012
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
2963
3013
|
) : t;
|
|
2964
3014
|
}
|
|
2965
|
-
function
|
|
3015
|
+
function Zn(t, e, s) {
|
|
2966
3016
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
2967
3017
|
}
|
|
2968
|
-
function
|
|
3018
|
+
function er(t, e, s, n) {
|
|
2969
3019
|
if (s === null) return t;
|
|
2970
3020
|
let r = -1;
|
|
2971
3021
|
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
@@ -2982,7 +3032,7 @@ function Qn(t, e, s, n) {
|
|
|
2982
3032
|
respondsToUserMessageId: s
|
|
2983
3033
|
}, i;
|
|
2984
3034
|
}
|
|
2985
|
-
function
|
|
3035
|
+
function tr(t, e) {
|
|
2986
3036
|
const s = t.findIndex(
|
|
2987
3037
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
2988
3038
|
);
|
|
@@ -2999,19 +3049,19 @@ function Zn(t, e) {
|
|
|
2999
3049
|
...n[s].runId ? {} : { runId: e.runId }
|
|
3000
3050
|
}, n;
|
|
3001
3051
|
}
|
|
3002
|
-
function
|
|
3052
|
+
function sr(t, e, s) {
|
|
3003
3053
|
let n = !1;
|
|
3004
3054
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
3005
3055
|
return n ? r : t;
|
|
3006
3056
|
}
|
|
3007
|
-
function
|
|
3057
|
+
function nr(t) {
|
|
3008
3058
|
if (t.hiddenFromTranscript === !0)
|
|
3009
3059
|
return null;
|
|
3010
3060
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
3011
3061
|
return !e || !s ? null : {
|
|
3012
3062
|
id: `transient-activity:${e}`,
|
|
3013
3063
|
role: "tool",
|
|
3014
|
-
content:
|
|
3064
|
+
content: W(
|
|
3015
3065
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3016
3066
|
),
|
|
3017
3067
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3024,7 +3074,7 @@ function tr(t) {
|
|
|
3024
3074
|
loading: !0
|
|
3025
3075
|
};
|
|
3026
3076
|
}
|
|
3027
|
-
function
|
|
3077
|
+
function rr(t, e) {
|
|
3028
3078
|
if (e.id.startsWith("transient-activity:"))
|
|
3029
3079
|
return t;
|
|
3030
3080
|
const s = e.toolName === "tab_lifecycle";
|
|
@@ -3033,16 +3083,16 @@ function sr(t, e) {
|
|
|
3033
3083
|
const n = (i) => i.id === `transient-activity:${e.callId}` && i.callId === e.callId || s && i.id.startsWith("transient-activity:") && i.toolName === "browser_tabs" && !!i.runId && i.runId === e.runId, r = t.findIndex(n);
|
|
3034
3084
|
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
3035
3085
|
}
|
|
3036
|
-
function
|
|
3086
|
+
function ir(t, e) {
|
|
3037
3087
|
return fs(
|
|
3038
3088
|
t,
|
|
3039
3089
|
e.map(
|
|
3040
|
-
(s) =>
|
|
3090
|
+
(s) => jt(t, s)
|
|
3041
3091
|
),
|
|
3042
|
-
|
|
3092
|
+
$t
|
|
3043
3093
|
);
|
|
3044
3094
|
}
|
|
3045
|
-
function
|
|
3095
|
+
function $t(t) {
|
|
3046
3096
|
const e = J(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3047
3097
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3048
3098
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
@@ -3060,39 +3110,39 @@ function jt(t) {
|
|
|
3060
3110
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3061
3111
|
};
|
|
3062
3112
|
}
|
|
3063
|
-
function
|
|
3113
|
+
function jt(t, e) {
|
|
3064
3114
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3065
3115
|
return e;
|
|
3066
3116
|
const s = t.find(
|
|
3067
|
-
(r) => r.role === "user" && (r.id === e.id || ge(r) &&
|
|
3117
|
+
(r) => r.role === "user" && (r.id === e.id || ge(r) && Ft(r, e))
|
|
3068
3118
|
);
|
|
3069
3119
|
if (!s?.attachments?.length)
|
|
3070
3120
|
return e;
|
|
3071
3121
|
const n = e.attachments.map((r) => {
|
|
3072
|
-
const i =
|
|
3073
|
-
return i ?
|
|
3122
|
+
const i = or(s.attachments ?? [], r);
|
|
3123
|
+
return i ? ar(r, i) : r;
|
|
3074
3124
|
});
|
|
3075
3125
|
return { ...e, attachments: n };
|
|
3076
3126
|
}
|
|
3077
|
-
function
|
|
3127
|
+
function or(t, e) {
|
|
3078
3128
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
3079
3129
|
}
|
|
3080
|
-
function
|
|
3130
|
+
function ar(t, e) {
|
|
3081
3131
|
const { previewUrl: s } = e;
|
|
3082
3132
|
return s ? { ...t, previewUrl: s } : t;
|
|
3083
3133
|
}
|
|
3084
|
-
function
|
|
3134
|
+
function lr(t, e) {
|
|
3085
3135
|
if (e.role !== "user")
|
|
3086
3136
|
return t;
|
|
3087
3137
|
const s = t.findIndex(
|
|
3088
|
-
(r) => ge(r) &&
|
|
3138
|
+
(r) => ge(r) && Ft(r, e)
|
|
3089
3139
|
);
|
|
3090
3140
|
if (s === -1)
|
|
3091
3141
|
return t;
|
|
3092
3142
|
const n = [...t];
|
|
3093
3143
|
return n.splice(s, 1), n;
|
|
3094
3144
|
}
|
|
3095
|
-
function
|
|
3145
|
+
function Ft(t, e) {
|
|
3096
3146
|
const s = J(t), n = J(e);
|
|
3097
3147
|
return s && n ? s === n : t.content === e.content;
|
|
3098
3148
|
}
|
|
@@ -3113,7 +3163,7 @@ function At(t) {
|
|
|
3113
3163
|
if (e === null)
|
|
3114
3164
|
return !1;
|
|
3115
3165
|
const s = t[e].id, n = t.some(
|
|
3116
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3166
|
+
(r) => r.respondsToUserMessageId === s && We(r)
|
|
3117
3167
|
);
|
|
3118
3168
|
if (t.some((r) => r.respondsToUserMessageId === s))
|
|
3119
3169
|
return n;
|
|
@@ -3130,7 +3180,7 @@ function At(t) {
|
|
|
3130
3180
|
}
|
|
3131
3181
|
return !1;
|
|
3132
3182
|
}
|
|
3133
|
-
function
|
|
3183
|
+
function cr(t) {
|
|
3134
3184
|
const e = zt(t);
|
|
3135
3185
|
if (e === null)
|
|
3136
3186
|
return t.some(x);
|
|
@@ -3145,7 +3195,7 @@ function zt(t) {
|
|
|
3145
3195
|
return e;
|
|
3146
3196
|
return null;
|
|
3147
3197
|
}
|
|
3148
|
-
function
|
|
3198
|
+
function We(t) {
|
|
3149
3199
|
return x(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3150
3200
|
}
|
|
3151
3201
|
function Y(t) {
|
|
@@ -3162,7 +3212,7 @@ function Y(t) {
|
|
|
3162
3212
|
}
|
|
3163
3213
|
return null;
|
|
3164
3214
|
}
|
|
3165
|
-
function
|
|
3215
|
+
function ur(t) {
|
|
3166
3216
|
const e = Y(t);
|
|
3167
3217
|
if (e === null)
|
|
3168
3218
|
return null;
|
|
@@ -3178,13 +3228,13 @@ function H(t) {
|
|
|
3178
3228
|
const e = t.data;
|
|
3179
3229
|
return e && typeof e == "object" ? e : null;
|
|
3180
3230
|
}
|
|
3181
|
-
function
|
|
3231
|
+
function He(t) {
|
|
3182
3232
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3183
3233
|
}
|
|
3184
3234
|
function Rt(t) {
|
|
3185
3235
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3186
3236
|
}
|
|
3187
|
-
function
|
|
3237
|
+
function dr(t, e) {
|
|
3188
3238
|
const s = Y(e);
|
|
3189
3239
|
if (s === null)
|
|
3190
3240
|
return !1;
|
|
@@ -3193,10 +3243,10 @@ function cr(t, e) {
|
|
|
3193
3243
|
return !1;
|
|
3194
3244
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3195
3245
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3196
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3197
|
-
) : t.slice(i + 1).some(
|
|
3246
|
+
(o) => o.respondsToUserMessageId === r && We(o)
|
|
3247
|
+
) : t.slice(i + 1).some(We);
|
|
3198
3248
|
}
|
|
3199
|
-
function
|
|
3249
|
+
function $e(t) {
|
|
3200
3250
|
const e = Y(t);
|
|
3201
3251
|
if (e === null)
|
|
3202
3252
|
return null;
|
|
@@ -3209,7 +3259,7 @@ function je(t) {
|
|
|
3209
3259
|
const r = n.clientMessageId;
|
|
3210
3260
|
return typeof r == "string" ? r : null;
|
|
3211
3261
|
}
|
|
3212
|
-
function
|
|
3262
|
+
function pr(t) {
|
|
3213
3263
|
const e = Y(t);
|
|
3214
3264
|
if (e === null)
|
|
3215
3265
|
return null;
|
|
@@ -3224,22 +3274,22 @@ function ur(t) {
|
|
|
3224
3274
|
if (i.type === "message" && i.role === "assistant")
|
|
3225
3275
|
return null;
|
|
3226
3276
|
if (i.type === "run_error")
|
|
3227
|
-
return i.retryable !== !0 ? null :
|
|
3277
|
+
return i.retryable !== !0 ? null : je(t, i) ?? $e(t);
|
|
3228
3278
|
if (i.type === "run_status")
|
|
3229
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3279
|
+
return i.status === "interrupted" && i.retryable === !0 ? je(t, i) ?? $e(t) : null;
|
|
3230
3280
|
}
|
|
3231
3281
|
return null;
|
|
3232
3282
|
}
|
|
3233
|
-
function
|
|
3283
|
+
function je(t, e) {
|
|
3234
3284
|
if (typeof e.clientMessageId == "string")
|
|
3235
3285
|
return e.clientMessageId;
|
|
3236
|
-
const s =
|
|
3286
|
+
const s = O(e);
|
|
3237
3287
|
if (!s)
|
|
3238
3288
|
return null;
|
|
3239
3289
|
const n = t.find((i) => E(i, "id") === s), r = H(n);
|
|
3240
3290
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3241
3291
|
}
|
|
3242
|
-
function
|
|
3292
|
+
function hr(t, e) {
|
|
3243
3293
|
let s = 0;
|
|
3244
3294
|
for (const n of t) {
|
|
3245
3295
|
if (!n || typeof n != "object")
|
|
@@ -3253,12 +3303,12 @@ function dr(t, e) {
|
|
|
3253
3303
|
return s;
|
|
3254
3304
|
}
|
|
3255
3305
|
function Et(t, e, s, n, r) {
|
|
3256
|
-
if (!e || !
|
|
3306
|
+
if (!e || !gr(t))
|
|
3257
3307
|
return !1;
|
|
3258
3308
|
const i = t;
|
|
3259
|
-
return !(
|
|
3309
|
+
return !(He(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && _(i) !== r));
|
|
3260
3310
|
}
|
|
3261
|
-
function
|
|
3311
|
+
function gr(t) {
|
|
3262
3312
|
if (!t || typeof t != "object")
|
|
3263
3313
|
return !1;
|
|
3264
3314
|
const e = t;
|
|
@@ -3267,22 +3317,22 @@ function hr(t) {
|
|
|
3267
3317
|
function x(t) {
|
|
3268
3318
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3269
3319
|
}
|
|
3270
|
-
function
|
|
3320
|
+
function fr(t) {
|
|
3271
3321
|
if (!t || typeof t != "object")
|
|
3272
3322
|
return !1;
|
|
3273
3323
|
const e = t;
|
|
3274
3324
|
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";
|
|
3275
3325
|
}
|
|
3276
|
-
function
|
|
3277
|
-
return t.filter((e, s) => j(e) ? !
|
|
3326
|
+
function Fe(t) {
|
|
3327
|
+
return t.filter((e, s) => j(e) ? !Er(t, s) && !Kt(t, s) && !Ar(t, s) && !Rr(t, s) : mr(e) ? e.retryable === !0 && Mr(t, s) ? !1 : !Sr(t, s) : !0);
|
|
3278
3328
|
}
|
|
3279
|
-
function
|
|
3329
|
+
function mr(t) {
|
|
3280
3330
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3281
3331
|
}
|
|
3282
3332
|
function j(t) {
|
|
3283
3333
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3284
3334
|
}
|
|
3285
|
-
function
|
|
3335
|
+
function yr(t, e, s, n) {
|
|
3286
3336
|
const r = t.findIndex(
|
|
3287
3337
|
(l, c) => j(l) && !Kt(t, c)
|
|
3288
3338
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
@@ -3305,14 +3355,14 @@ function oe(t, e, s) {
|
|
|
3305
3355
|
}
|
|
3306
3356
|
function Kt(t, e) {
|
|
3307
3357
|
return t.some(
|
|
3308
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
3358
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && Ir(
|
|
3309
3359
|
t,
|
|
3310
3360
|
e,
|
|
3311
3361
|
n
|
|
3312
3362
|
)
|
|
3313
3363
|
);
|
|
3314
3364
|
}
|
|
3315
|
-
function
|
|
3365
|
+
function Ir(t, e, s) {
|
|
3316
3366
|
const n = t[e], r = t[s];
|
|
3317
3367
|
if (Q(n, r))
|
|
3318
3368
|
return !0;
|
|
@@ -3323,26 +3373,26 @@ function mr(t, e, s) {
|
|
|
3323
3373
|
return t[i].id === n.respondsToUserMessageId;
|
|
3324
3374
|
return !1;
|
|
3325
3375
|
}
|
|
3326
|
-
function
|
|
3376
|
+
function Tr(t, e) {
|
|
3327
3377
|
const s = [...t].reverse().find(
|
|
3328
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
3378
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Ct(n) && !wr(
|
|
3329
3379
|
t,
|
|
3330
3380
|
n.respondsToUserMessageId
|
|
3331
3381
|
)
|
|
3332
3382
|
)?.respondsToUserMessageId;
|
|
3333
3383
|
return s ? t.map(
|
|
3334
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3384
|
+
(n) => n.respondsToUserMessageId === s && Ct(n) ? { ...n, steered: !0 } : n
|
|
3335
3385
|
) : t;
|
|
3336
3386
|
}
|
|
3337
|
-
function
|
|
3387
|
+
function Ct(t) {
|
|
3338
3388
|
return t.role === "tool" || j(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3339
3389
|
}
|
|
3340
|
-
function
|
|
3390
|
+
function wr(t, e) {
|
|
3341
3391
|
return t.some(
|
|
3342
3392
|
(s) => s.respondsToUserMessageId === e && (x(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3343
3393
|
);
|
|
3344
3394
|
}
|
|
3345
|
-
function
|
|
3395
|
+
function Sr(t, e) {
|
|
3346
3396
|
const s = t[e];
|
|
3347
3397
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
3348
3398
|
const r = t[n];
|
|
@@ -3351,7 +3401,7 @@ function Tr(t, e) {
|
|
|
3351
3401
|
}
|
|
3352
3402
|
return !1;
|
|
3353
3403
|
}
|
|
3354
|
-
function
|
|
3404
|
+
function Mr(t, e) {
|
|
3355
3405
|
const s = t[e];
|
|
3356
3406
|
if (!s.respondsToUserMessageId)
|
|
3357
3407
|
return !1;
|
|
@@ -3364,19 +3414,19 @@ function wr(t, e) {
|
|
|
3364
3414
|
}
|
|
3365
3415
|
return !1;
|
|
3366
3416
|
}
|
|
3367
|
-
function
|
|
3417
|
+
function Ar(t, e) {
|
|
3368
3418
|
const s = t[e];
|
|
3369
3419
|
return t.some(
|
|
3370
3420
|
(n, r) => r !== e && n.role === "assistant" && Q(s, n)
|
|
3371
3421
|
);
|
|
3372
3422
|
}
|
|
3373
|
-
function
|
|
3423
|
+
function Rr(t, e) {
|
|
3374
3424
|
const s = t[e];
|
|
3375
3425
|
return t.some(
|
|
3376
3426
|
(n, r) => r !== e && n.role === "tool" && Q(s, n)
|
|
3377
3427
|
);
|
|
3378
3428
|
}
|
|
3379
|
-
function
|
|
3429
|
+
function Er(t, e) {
|
|
3380
3430
|
const s = t[e];
|
|
3381
3431
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3382
3432
|
if (j(t[n]) && Q(s, t[n]))
|
|
@@ -3389,15 +3439,15 @@ function Q(t, e) {
|
|
|
3389
3439
|
function E(t, e) {
|
|
3390
3440
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
3391
3441
|
}
|
|
3392
|
-
function
|
|
3442
|
+
function Cr(t, e) {
|
|
3393
3443
|
try {
|
|
3394
|
-
const s = window.localStorage.getItem(`${
|
|
3444
|
+
const s = window.localStorage.getItem(`${Ot}${t}`);
|
|
3395
3445
|
if (!s)
|
|
3396
3446
|
return null;
|
|
3397
3447
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3398
3448
|
if (e !== void 0 && r !== e)
|
|
3399
3449
|
return null;
|
|
3400
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3450
|
+
const i = Array.isArray(n.messages) ? n.messages.map(qr).filter((o) => !!o) : [];
|
|
3401
3451
|
return {
|
|
3402
3452
|
sessionId: r,
|
|
3403
3453
|
messages: i
|
|
@@ -3406,20 +3456,20 @@ function Rr(t, e) {
|
|
|
3406
3456
|
return null;
|
|
3407
3457
|
}
|
|
3408
3458
|
}
|
|
3409
|
-
function
|
|
3459
|
+
function br(t, e) {
|
|
3410
3460
|
try {
|
|
3411
3461
|
window.localStorage.setItem(
|
|
3412
|
-
`${
|
|
3462
|
+
`${Ot}${t}`,
|
|
3413
3463
|
JSON.stringify({
|
|
3414
3464
|
sessionId: e.sessionId,
|
|
3415
|
-
messages: e.messages.slice(-
|
|
3465
|
+
messages: e.messages.slice(-Qs).map(Br)
|
|
3416
3466
|
})
|
|
3417
3467
|
);
|
|
3418
3468
|
} catch {
|
|
3419
3469
|
return;
|
|
3420
3470
|
}
|
|
3421
3471
|
}
|
|
3422
|
-
function
|
|
3472
|
+
function _r(t) {
|
|
3423
3473
|
try {
|
|
3424
3474
|
const e = window.localStorage.getItem(`${qe}${t}`);
|
|
3425
3475
|
if (!e)
|
|
@@ -3430,7 +3480,7 @@ function br(t) {
|
|
|
3430
3480
|
return [];
|
|
3431
3481
|
}
|
|
3432
3482
|
}
|
|
3433
|
-
function
|
|
3483
|
+
function q(t, e) {
|
|
3434
3484
|
try {
|
|
3435
3485
|
const s = e.filter(Qe);
|
|
3436
3486
|
if (s.length === 0) {
|
|
@@ -3447,7 +3497,7 @@ function L(t, e) {
|
|
|
3447
3497
|
}
|
|
3448
3498
|
function Gt(t, e) {
|
|
3449
3499
|
try {
|
|
3450
|
-
const s = `${
|
|
3500
|
+
const s = `${he}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
3451
3501
|
...o,
|
|
3452
3502
|
storedAt: Date.now(),
|
|
3453
3503
|
unloadUrl: n,
|
|
@@ -3461,28 +3511,28 @@ function Gt(t, e) {
|
|
|
3461
3511
|
} catch {
|
|
3462
3512
|
}
|
|
3463
3513
|
}
|
|
3464
|
-
function
|
|
3514
|
+
function kr(t, e) {
|
|
3465
3515
|
try {
|
|
3466
|
-
if (window.sessionStorage.getItem(`${
|
|
3516
|
+
if (window.sessionStorage.getItem(`${he}${t}`) === null)
|
|
3467
3517
|
return;
|
|
3468
3518
|
} catch {
|
|
3469
3519
|
return;
|
|
3470
3520
|
}
|
|
3471
3521
|
Gt(t, e);
|
|
3472
3522
|
}
|
|
3473
|
-
function
|
|
3523
|
+
function Pr(t) {
|
|
3474
3524
|
try {
|
|
3475
|
-
const e = `${
|
|
3525
|
+
const e = `${he}${t}`, s = window.sessionStorage.getItem(e);
|
|
3476
3526
|
if (window.sessionStorage.removeItem(e), !s)
|
|
3477
3527
|
return [];
|
|
3478
3528
|
const n = JSON.parse(s);
|
|
3479
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3529
|
+
return Array.isArray(n) ? n.flatMap((r) => Dr(r) ? [{
|
|
3480
3530
|
...r.event,
|
|
3481
3531
|
page: C(),
|
|
3482
3532
|
rawOutput: {
|
|
3483
3533
|
pageContextRestarted: !0,
|
|
3484
3534
|
outcome: "unknown",
|
|
3485
|
-
message:
|
|
3535
|
+
message: Ur(location.href),
|
|
3486
3536
|
currentUrl: location.href,
|
|
3487
3537
|
console: [],
|
|
3488
3538
|
metadata: {
|
|
@@ -3499,17 +3549,17 @@ function _r(t) {
|
|
|
3499
3549
|
return [];
|
|
3500
3550
|
}
|
|
3501
3551
|
}
|
|
3502
|
-
function
|
|
3552
|
+
function Ur(t) {
|
|
3503
3553
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3504
3554
|
Current URL: ${t}`;
|
|
3505
3555
|
}
|
|
3506
|
-
function
|
|
3556
|
+
function Dr(t) {
|
|
3507
3557
|
if (!t || typeof t != "object")
|
|
3508
3558
|
return !1;
|
|
3509
3559
|
const e = t, s = e.event;
|
|
3510
3560
|
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && Qe(s) && s.type === "tool.result";
|
|
3511
3561
|
}
|
|
3512
|
-
function
|
|
3562
|
+
function vr(t, e) {
|
|
3513
3563
|
const s = new Set(
|
|
3514
3564
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3515
3565
|
);
|
|
@@ -3518,9 +3568,9 @@ function Pr(t, e) {
|
|
|
3518
3568
|
...e.filter((n) => !s.has(n.callId))
|
|
3519
3569
|
];
|
|
3520
3570
|
}
|
|
3521
|
-
function
|
|
3571
|
+
function Nr(t) {
|
|
3522
3572
|
try {
|
|
3523
|
-
window.sessionStorage.removeItem(`${
|
|
3573
|
+
window.sessionStorage.removeItem(`${he}${t}`);
|
|
3524
3574
|
} catch {
|
|
3525
3575
|
return;
|
|
3526
3576
|
}
|
|
@@ -3529,9 +3579,9 @@ function Qe(t) {
|
|
|
3529
3579
|
if (!t || typeof t != "object")
|
|
3530
3580
|
return !1;
|
|
3531
3581
|
const e = t;
|
|
3532
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
3582
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && bt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? bt(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
|
|
3533
3583
|
}
|
|
3534
|
-
function
|
|
3584
|
+
function bt(t) {
|
|
3535
3585
|
if (!t || typeof t != "object")
|
|
3536
3586
|
return !1;
|
|
3537
3587
|
const e = t;
|
|
@@ -3555,9 +3605,9 @@ function Vt(t, e) {
|
|
|
3555
3605
|
} : t;
|
|
3556
3606
|
}
|
|
3557
3607
|
function ze(t) {
|
|
3558
|
-
return t.type ||
|
|
3608
|
+
return t.type || Lr(t.name) || "application/octet-stream";
|
|
3559
3609
|
}
|
|
3560
|
-
function
|
|
3610
|
+
function Or(t) {
|
|
3561
3611
|
Jt({
|
|
3562
3612
|
name: t.name,
|
|
3563
3613
|
mimeType: ze(t),
|
|
@@ -3565,21 +3615,21 @@ function vr(t) {
|
|
|
3565
3615
|
});
|
|
3566
3616
|
}
|
|
3567
3617
|
function Jt(t) {
|
|
3568
|
-
const e =
|
|
3569
|
-
if (!
|
|
3618
|
+
const e = xr(t.name), s = t.mimeType.trim().toLowerCase();
|
|
3619
|
+
if (!Vs.has(`${e}:${s}`))
|
|
3570
3620
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
3571
3621
|
if (t.sizeBytes <= 0 || t.sizeBytes >= vt)
|
|
3572
3622
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
3573
3623
|
}
|
|
3574
|
-
function
|
|
3624
|
+
function xr(t) {
|
|
3575
3625
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
3576
3626
|
return s >= 0 ? e.slice(s) : "";
|
|
3577
3627
|
}
|
|
3578
|
-
function
|
|
3628
|
+
function Lr(t) {
|
|
3579
3629
|
const e = t.toLowerCase();
|
|
3580
3630
|
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;
|
|
3581
3631
|
}
|
|
3582
|
-
function
|
|
3632
|
+
function qr(t) {
|
|
3583
3633
|
if (!t || typeof t != "object")
|
|
3584
3634
|
return null;
|
|
3585
3635
|
const e = t;
|
|
@@ -3600,7 +3650,7 @@ function xr(t) {
|
|
|
3600
3650
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
3601
3651
|
};
|
|
3602
3652
|
}
|
|
3603
|
-
function
|
|
3653
|
+
function Br(t) {
|
|
3604
3654
|
return t.attachments?.length ? {
|
|
3605
3655
|
...t,
|
|
3606
3656
|
attachments: t.attachments.map(Ze)
|
|
@@ -3615,7 +3665,7 @@ function Ze(t) {
|
|
|
3615
3665
|
} = t;
|
|
3616
3666
|
return r;
|
|
3617
3667
|
}
|
|
3618
|
-
function
|
|
3668
|
+
function O(t) {
|
|
3619
3669
|
const e = t.respondsToUserMessageId;
|
|
3620
3670
|
return typeof e == "string" && e ? e : null;
|
|
3621
3671
|
}
|
|
@@ -3623,9 +3673,9 @@ function _(t) {
|
|
|
3623
3673
|
const e = t.runId;
|
|
3624
3674
|
return typeof e == "string" && e ? e : null;
|
|
3625
3675
|
}
|
|
3626
|
-
function
|
|
3676
|
+
function Wr(t) {
|
|
3627
3677
|
const e = t?.timeoutMs;
|
|
3628
|
-
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 <=
|
|
3678
|
+
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= ln);
|
|
3629
3679
|
}
|
|
3630
3680
|
function Yt(t) {
|
|
3631
3681
|
const e = {};
|
|
@@ -3639,22 +3689,22 @@ function Yt(t) {
|
|
|
3639
3689
|
return e;
|
|
3640
3690
|
}
|
|
3641
3691
|
function et(t, e) {
|
|
3642
|
-
return ns(t) ? fe :
|
|
3692
|
+
return ns(t) ? fe : U(pe(e), Js);
|
|
3643
3693
|
}
|
|
3644
|
-
function
|
|
3694
|
+
function Hr(t, e) {
|
|
3645
3695
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
3646
3696
|
}
|
|
3647
|
-
async function
|
|
3697
|
+
async function $r(t, e, s, n) {
|
|
3648
3698
|
const r = Yt(t.headers);
|
|
3649
3699
|
n({
|
|
3650
3700
|
...e,
|
|
3651
3701
|
responseStatus: t.status,
|
|
3652
3702
|
responseHeaders: r,
|
|
3653
|
-
responseBody: await
|
|
3703
|
+
responseBody: await jr(t),
|
|
3654
3704
|
durationMs: Date.now() - s
|
|
3655
3705
|
});
|
|
3656
3706
|
}
|
|
3657
|
-
async function
|
|
3707
|
+
async function jr(t) {
|
|
3658
3708
|
if (!Qt(t.headers))
|
|
3659
3709
|
return;
|
|
3660
3710
|
let e = null, s = null;
|
|
@@ -3664,7 +3714,7 @@ async function Wr(t) {
|
|
|
3664
3714
|
const n = new Promise((a) => {
|
|
3665
3715
|
s = window.setTimeout(() => {
|
|
3666
3716
|
e?.cancel(), a("timeout");
|
|
3667
|
-
},
|
|
3717
|
+
}, Ys);
|
|
3668
3718
|
}), r = new TextDecoder();
|
|
3669
3719
|
let i = "", o = 0;
|
|
3670
3720
|
for (; ; ) {
|
|
@@ -3673,10 +3723,10 @@ async function Wr(t) {
|
|
|
3673
3723
|
return;
|
|
3674
3724
|
const { done: l, value: c } = a;
|
|
3675
3725
|
if (l)
|
|
3676
|
-
return
|
|
3677
|
-
const
|
|
3678
|
-
if (c.byteLength >
|
|
3679
|
-
return i += r.decode(c.subarray(0, Math.max(
|
|
3726
|
+
return U(i + r.decode());
|
|
3727
|
+
const p = Ve - o;
|
|
3728
|
+
if (c.byteLength > p)
|
|
3729
|
+
return i += r.decode(c.subarray(0, Math.max(p, 0)), { stream: !0 }), e.cancel(), `${U(i)}... [truncated]`;
|
|
3680
3730
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
3681
3731
|
}
|
|
3682
3732
|
} catch {
|
|
@@ -3686,19 +3736,19 @@ async function Wr(t) {
|
|
|
3686
3736
|
s !== null && window.clearTimeout(s);
|
|
3687
3737
|
}
|
|
3688
3738
|
}
|
|
3689
|
-
function
|
|
3739
|
+
function Fr(t, e) {
|
|
3690
3740
|
if (Qt(new Headers(e)))
|
|
3691
3741
|
try {
|
|
3692
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
3742
|
+
return t.responseType === "" || t.responseType === "text" ? U(t.responseText ?? "") : void 0;
|
|
3693
3743
|
} catch {
|
|
3694
3744
|
return;
|
|
3695
3745
|
}
|
|
3696
3746
|
}
|
|
3697
3747
|
function _t(t) {
|
|
3698
3748
|
if (typeof t == "string")
|
|
3699
|
-
return
|
|
3749
|
+
return U(t);
|
|
3700
3750
|
}
|
|
3701
|
-
function
|
|
3751
|
+
function zr(t) {
|
|
3702
3752
|
return k({
|
|
3703
3753
|
...t,
|
|
3704
3754
|
requestBody: kt(t.requestBody),
|
|
@@ -3710,11 +3760,11 @@ function kt(t) {
|
|
|
3710
3760
|
return t;
|
|
3711
3761
|
const e = t.trim();
|
|
3712
3762
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
3713
|
-
return
|
|
3763
|
+
return pe(t);
|
|
3714
3764
|
try {
|
|
3715
3765
|
return JSON.stringify(k(JSON.parse(t)));
|
|
3716
3766
|
} catch {
|
|
3717
|
-
return
|
|
3767
|
+
return pe(t);
|
|
3718
3768
|
}
|
|
3719
3769
|
}
|
|
3720
3770
|
function Qt(t) {
|
|
@@ -3723,8 +3773,8 @@ function Qt(t) {
|
|
|
3723
3773
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
3724
3774
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= Ve && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
3725
3775
|
}
|
|
3726
|
-
function
|
|
3727
|
-
if (
|
|
3776
|
+
function B(t, e = {}, s) {
|
|
3777
|
+
if (Gr(s))
|
|
3728
3778
|
return !0;
|
|
3729
3779
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3730
3780
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3739,8 +3789,8 @@ function q(t, e = {}, s) {
|
|
|
3739
3789
|
return !0;
|
|
3740
3790
|
}
|
|
3741
3791
|
}
|
|
3742
|
-
function
|
|
3743
|
-
if (
|
|
3792
|
+
function Kr(t, e) {
|
|
3793
|
+
if (B(t))
|
|
3744
3794
|
return !0;
|
|
3745
3795
|
try {
|
|
3746
3796
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -3749,10 +3799,10 @@ function $r(t, e) {
|
|
|
3749
3799
|
return !0;
|
|
3750
3800
|
}
|
|
3751
3801
|
}
|
|
3752
|
-
function
|
|
3802
|
+
function Gr(t) {
|
|
3753
3803
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
3754
3804
|
}
|
|
3755
|
-
function
|
|
3805
|
+
function Xr(t) {
|
|
3756
3806
|
const e = {};
|
|
3757
3807
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
3758
3808
|
const n = s.indexOf(":");
|
|
@@ -3765,10 +3815,10 @@ function Kr(t) {
|
|
|
3765
3815
|
}
|
|
3766
3816
|
return e;
|
|
3767
3817
|
}
|
|
3768
|
-
function
|
|
3818
|
+
function U(t, e = Ve) {
|
|
3769
3819
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
3770
3820
|
}
|
|
3771
|
-
function
|
|
3821
|
+
function Oe(t) {
|
|
3772
3822
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3773
3823
|
}
|
|
3774
3824
|
class ue extends Error {
|
|
@@ -3783,36 +3833,36 @@ async function ae(t, e) {
|
|
|
3783
3833
|
try {
|
|
3784
3834
|
return await t();
|
|
3785
3835
|
} catch (r) {
|
|
3786
|
-
if (s = r, n >= It - 1 || !
|
|
3836
|
+
if (s = r, n >= It - 1 || !Jr(r))
|
|
3787
3837
|
throw r;
|
|
3788
|
-
await
|
|
3838
|
+
await Vr(n);
|
|
3789
3839
|
}
|
|
3790
3840
|
throw s instanceof Error ? s : new Error(e);
|
|
3791
3841
|
}
|
|
3792
|
-
function
|
|
3842
|
+
function Vr(t) {
|
|
3793
3843
|
return new Promise((e) => {
|
|
3794
|
-
window.setTimeout(e,
|
|
3844
|
+
window.setTimeout(e, Xs[t] ?? 0);
|
|
3795
3845
|
});
|
|
3796
3846
|
}
|
|
3797
|
-
function
|
|
3798
|
-
return t instanceof ue ?
|
|
3847
|
+
function Jr(t) {
|
|
3848
|
+
return t instanceof ue ? Yr(t.status) : t instanceof TypeError;
|
|
3799
3849
|
}
|
|
3800
|
-
function
|
|
3850
|
+
function Yr(t) {
|
|
3801
3851
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
3802
3852
|
}
|
|
3803
|
-
function
|
|
3853
|
+
function Qr(t) {
|
|
3804
3854
|
return t === 401 || t === 403;
|
|
3805
3855
|
}
|
|
3806
|
-
const fe = "[REDACTED_SECRET]", D = "[REDACTED_TOKEN]",
|
|
3856
|
+
const fe = "[REDACTED_SECRET]", D = "[REDACTED_TOKEN]", Zr = "[REDACTED_SIGNED_URL]", ei = 20, ti = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Zt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, es = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ts = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ss = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, si = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, ni = /\bhttps?:\/\/[^\s"'<>]+/gi, ri = /[),.;\]]+$/;
|
|
3807
3857
|
function k(t) {
|
|
3808
3858
|
return de(t, 0, /* @__PURE__ */ new WeakSet());
|
|
3809
3859
|
}
|
|
3810
3860
|
function de(t, e, s) {
|
|
3811
3861
|
if (typeof t == "string")
|
|
3812
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
3862
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : pe(t);
|
|
3813
3863
|
if (t === null || typeof t != "object")
|
|
3814
3864
|
return t;
|
|
3815
|
-
if (e >=
|
|
3865
|
+
if (e >= ei)
|
|
3816
3866
|
return "[REDACTED_MAX_DEPTH]";
|
|
3817
3867
|
if (s.has(t))
|
|
3818
3868
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -3820,34 +3870,34 @@ function de(t, e, s) {
|
|
|
3820
3870
|
return t.map((r) => de(r, e + 1, s));
|
|
3821
3871
|
const n = {};
|
|
3822
3872
|
for (const [r, i] of Object.entries(t))
|
|
3823
|
-
r === "pageContent" ? n[r] = i : ns(r) ? n[r] = fe : n[r] = r.toLowerCase() === "url" ?
|
|
3873
|
+
r === "pageContent" ? n[r] = i : ns(r) ? n[r] = fe : n[r] = r.toLowerCase() === "url" ? ii(i) : de(i, e + 1, s);
|
|
3824
3874
|
return n;
|
|
3825
3875
|
}
|
|
3826
3876
|
function ns(t) {
|
|
3827
3877
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3828
3878
|
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");
|
|
3829
3879
|
}
|
|
3830
|
-
function
|
|
3880
|
+
function ii(t) {
|
|
3831
3881
|
return typeof t == "string" ? rs(t) : de(t, 0, /* @__PURE__ */ new WeakSet());
|
|
3832
3882
|
}
|
|
3833
3883
|
function rs(t) {
|
|
3834
3884
|
try {
|
|
3835
3885
|
const e = new URL(t, location.href);
|
|
3836
3886
|
for (const s of Array.from(e.searchParams.keys()))
|
|
3837
|
-
|
|
3887
|
+
ti.test(s) && e.searchParams.set(s, D);
|
|
3838
3888
|
return e.username && (e.username = D), e.password && (e.password = D), e.toString();
|
|
3839
3889
|
} catch {
|
|
3840
|
-
return
|
|
3890
|
+
return oi(t);
|
|
3841
3891
|
}
|
|
3842
3892
|
}
|
|
3843
|
-
function
|
|
3844
|
-
return t.replace(
|
|
3893
|
+
function pe(t) {
|
|
3894
|
+
return t.replace(si, Zr).replace(ni, ai).replace(Zt, `Bearer ${D}`).replace(es, `Basic ${D}`).replace(ts, D).replace(ss, (e, s) => `${s}: ${fe}`);
|
|
3845
3895
|
}
|
|
3846
|
-
function
|
|
3896
|
+
function oi(t) {
|
|
3847
3897
|
return t.replace(Zt, `Bearer ${D}`).replace(es, `Basic ${D}`).replace(ts, D).replace(ss, (e, s) => `${s}: ${fe}`);
|
|
3848
3898
|
}
|
|
3849
|
-
function
|
|
3850
|
-
const e = t.match(
|
|
3899
|
+
function ai(t) {
|
|
3900
|
+
const e = t.match(ri)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
3851
3901
|
return `${rs(s)}${e}`;
|
|
3852
3902
|
}
|
|
3853
3903
|
export {
|
|
@@ -3855,11 +3905,11 @@ export {
|
|
|
3855
3905
|
Le as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3856
3906
|
ks as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3857
3907
|
_s as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3858
|
-
|
|
3859
|
-
|
|
3908
|
+
Ps as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3909
|
+
li as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
3860
3910
|
xt as PlunoProductAgent,
|
|
3861
|
-
|
|
3911
|
+
en as calculateReconnectDelay,
|
|
3862
3912
|
xt as default,
|
|
3863
|
-
|
|
3864
|
-
|
|
3913
|
+
Rn as getProductAgentOriginAccessErrorMessage,
|
|
3914
|
+
Or as validateProductAgentProviderInputFile
|
|
3865
3915
|
};
|