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