@pluno/product-agent-web 0.1.169 → 0.1.170
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 +2 -0
- package/dist/product-agent-sdk.js +588 -570
- package/dist/product-agent-widget.js +3209 -3118
- package/dist/taskPageTitle.d.ts +23 -0
- package/dist/turnStatusLabel.d.ts +3 -0
- package/dist/widget.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const gs = "pluno-product-agent-attachments";
|
|
2
|
-
const
|
|
2
|
+
const He = "files";
|
|
3
3
|
async function fs(t) {
|
|
4
4
|
const e = await Ve();
|
|
5
5
|
await Is(e, "readwrite", (s) => s.put(t));
|
|
@@ -27,7 +27,7 @@ function Ve() {
|
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
|
|
28
28
|
const s = indexedDB.open(gs, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(He, { keyPath: "attachmentId" });
|
|
31
31
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
32
32
|
}, s.onsuccess = () => t(s.result), s.onerror = () => e(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
@@ -37,17 +37,17 @@ async function Is(t, e, s) {
|
|
|
37
37
|
}
|
|
38
38
|
function Je(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(He, e), o = i.objectStore(He);
|
|
41
41
|
let a, l = !1;
|
|
42
|
-
s(o).then((
|
|
43
|
-
a =
|
|
44
|
-
}).catch((
|
|
42
|
+
s(o).then((u) => {
|
|
43
|
+
a = u;
|
|
44
|
+
}).catch((u) => {
|
|
45
45
|
l = !0;
|
|
46
46
|
try {
|
|
47
47
|
i.abort();
|
|
48
48
|
} catch {
|
|
49
49
|
}
|
|
50
|
-
r(
|
|
50
|
+
r(u);
|
|
51
51
|
}), i.oncomplete = () => {
|
|
52
52
|
l || n(a);
|
|
53
53
|
}, i.onerror = () => {
|
|
@@ -92,41 +92,41 @@ function As(t) {
|
|
|
92
92
|
return (t.type === "function_call" || t.type === "tool_call") && t.name === Ms;
|
|
93
93
|
}
|
|
94
94
|
function Rs(t, e, s) {
|
|
95
|
-
const n = e.map((
|
|
95
|
+
const n = e.map((c) => ({ item: c, identity: s(c) })), r = new Set(
|
|
96
96
|
n.flatMap(
|
|
97
|
-
({ identity:
|
|
97
|
+
({ identity: c }) => c.isActivity && !c.isTransient ? c.activityKeys ?? [] : []
|
|
98
98
|
)
|
|
99
99
|
), i = n.filter(
|
|
100
|
-
({ identity:
|
|
101
|
-
), o = new Map(i.map(({ item:
|
|
100
|
+
({ identity: c }) => !(c.isTransient && c.activityKeys?.some((d) => r.has(d)))
|
|
101
|
+
), o = new Map(i.map(({ item: c, identity: d }) => [d.id, c])), a = new Map(
|
|
102
102
|
i.flatMap(
|
|
103
|
-
({ item:
|
|
103
|
+
({ item: c, identity: d }) => d.optimisticKey ? [[d.optimisticKey, c]] : []
|
|
104
104
|
)
|
|
105
105
|
), l = new Map(
|
|
106
106
|
i.flatMap(
|
|
107
|
-
({ item:
|
|
107
|
+
({ item: c, identity: d }) => d.assistantDraftKey ? [[d.assistantDraftKey, c]] : []
|
|
108
108
|
)
|
|
109
|
-
),
|
|
110
|
-
for (const { item:
|
|
109
|
+
), u = /* @__PURE__ */ new Map();
|
|
110
|
+
for (const { item: c, identity: d } of i)
|
|
111
111
|
for (const g of d.activityKeys ?? []) {
|
|
112
|
-
const T =
|
|
113
|
-
(!T || s(T).isTransient) &&
|
|
112
|
+
const T = u.get(g);
|
|
113
|
+
(!T || s(T).isTransient) && u.set(g, c);
|
|
114
114
|
}
|
|
115
|
-
const h = new Set(i.map(({ identity:
|
|
116
|
-
i.flatMap(({ identity:
|
|
115
|
+
const h = new Set(i.map(({ identity: c }) => c.id)), p = new Set(
|
|
116
|
+
i.flatMap(({ identity: c }) => c.runId ? [c.runId] : [])
|
|
117
117
|
), I = /* @__PURE__ */ new Set(), f = [];
|
|
118
|
-
for (const
|
|
119
|
-
const d = s(
|
|
118
|
+
for (const c of t) {
|
|
119
|
+
const d = s(c);
|
|
120
120
|
let g = o.get(d.id);
|
|
121
|
-
if (d.isOptimistic && d.optimisticKey ? g = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? g = l.get(d.assistantDraftKey) : d.isActivity && (g = d.activityKeys?.map((
|
|
121
|
+
if (d.isOptimistic && d.optimisticKey ? g = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? g = l.get(d.assistantDraftKey) : d.isActivity && (g = d.activityKeys?.map((k) => u.get(k)).find((k) => k !== void 0) ?? g), g && !I.has(g)) {
|
|
122
122
|
f.push(g), I.add(g);
|
|
123
123
|
continue;
|
|
124
124
|
}
|
|
125
125
|
const T = d.respondsToUserMessageId !== void 0 && h.has(d.respondsToUserMessageId) || d.runId !== void 0 && p.has(d.runId);
|
|
126
|
-
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) && T) && f.push(
|
|
126
|
+
(d.isOptimistic || (d.isAssistantDraft || d.isActivity) && T) && f.push(c);
|
|
127
127
|
}
|
|
128
|
-
for (const { item:
|
|
129
|
-
I.has(
|
|
128
|
+
for (const { item: c } of i)
|
|
129
|
+
I.has(c) || f.push(c);
|
|
130
130
|
return f;
|
|
131
131
|
}
|
|
132
132
|
function Es(t, e, s, n) {
|
|
@@ -135,11 +135,11 @@ function Es(t, e, s, n) {
|
|
|
135
135
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
const
|
|
139
|
-
let
|
|
140
|
-
const
|
|
138
|
+
const De = "pluno.productAgent.transportId", ks = "pluno.productAgent.transportIdentity", ve = "pluno.productAgent.transportIdentity.event", Cs = 50, _s = globalThis.setTimeout.bind(globalThis);
|
|
139
|
+
let ne = null;
|
|
140
|
+
const fe = /* @__PURE__ */ new Set(), Oe = /* @__PURE__ */ new Map();
|
|
141
141
|
async function bs(t = xt()) {
|
|
142
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
142
|
+
const e = t.randomUUID(), s = t.storage.getItem(De);
|
|
143
143
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
144
144
|
const o = t.channel.subscribe((l) => {
|
|
145
145
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -157,14 +157,14 @@ async function bs(t = xt()) {
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
if (!s)
|
|
160
|
-
t.storage.setItem(
|
|
160
|
+
t.storage.setItem(De, n), r = !0;
|
|
161
161
|
else
|
|
162
162
|
for (; ; ) {
|
|
163
163
|
if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
|
|
164
164
|
r = !0;
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
167
|
+
n = t.randomUUID(), t.storage.setItem(De, n);
|
|
168
168
|
}
|
|
169
169
|
let a = !1;
|
|
170
170
|
return {
|
|
@@ -175,26 +175,26 @@ async function bs(t = xt()) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
async function Ps() {
|
|
178
|
-
|
|
178
|
+
ne || (ne = bs(xt()), ne.then((n) => {
|
|
179
179
|
const r = (i) => {
|
|
180
|
-
i.persisted || (n.release(),
|
|
180
|
+
i.persisted || (n.release(), ne = null, fe.clear(), window.removeEventListener("pagehide", r));
|
|
181
181
|
};
|
|
182
182
|
window.addEventListener("pagehide", r);
|
|
183
183
|
}));
|
|
184
|
-
const t = await
|
|
185
|
-
|
|
184
|
+
const t = await ne, e = Us();
|
|
185
|
+
fe.add(e);
|
|
186
186
|
let s = !1;
|
|
187
187
|
return {
|
|
188
188
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
189
189
|
transportId: e === 0 ? t.transportId : `${t.transportId}.${e}`,
|
|
190
190
|
release: () => {
|
|
191
|
-
s || (s = !0,
|
|
191
|
+
s || (s = !0, fe.delete(e));
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
function Us() {
|
|
196
196
|
let t = 0;
|
|
197
|
-
for (;
|
|
197
|
+
for (; fe.has(t); )
|
|
198
198
|
t += 1;
|
|
199
199
|
return t;
|
|
200
200
|
}
|
|
@@ -203,20 +203,20 @@ function xt() {
|
|
|
203
203
|
storage: Ds(),
|
|
204
204
|
channel: vs(),
|
|
205
205
|
randomUUID: () => crypto.randomUUID(),
|
|
206
|
-
settle: () => new Promise((t) => _s(t,
|
|
206
|
+
settle: () => new Promise((t) => _s(t, Cs))
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
function Ds() {
|
|
210
210
|
return {
|
|
211
211
|
getItem: (t) => {
|
|
212
212
|
try {
|
|
213
|
-
return window.sessionStorage?.getItem(t) ??
|
|
213
|
+
return window.sessionStorage?.getItem(t) ?? Oe.get(t) ?? null;
|
|
214
214
|
} catch {
|
|
215
|
-
return
|
|
215
|
+
return Oe.get(t) ?? null;
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
setItem: (t, e) => {
|
|
219
|
-
|
|
219
|
+
Oe.set(t, e);
|
|
220
220
|
try {
|
|
221
221
|
window.sessionStorage?.setItem(t, e);
|
|
222
222
|
} catch {
|
|
@@ -226,7 +226,7 @@ function Ds() {
|
|
|
226
226
|
}
|
|
227
227
|
function vs() {
|
|
228
228
|
if (typeof BroadcastChannel < "u") {
|
|
229
|
-
const t = new BroadcastChannel(
|
|
229
|
+
const t = new BroadcastChannel(ks);
|
|
230
230
|
return {
|
|
231
231
|
postMessage: (e) => t.postMessage(e),
|
|
232
232
|
subscribe: (e) => {
|
|
@@ -240,7 +240,7 @@ function vs() {
|
|
|
240
240
|
}
|
|
241
241
|
function Os() {
|
|
242
242
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
243
|
-
if (s.key !==
|
|
243
|
+
if (s.key !== ve || !s.newValue)
|
|
244
244
|
return;
|
|
245
245
|
const n = JSON.parse(s.newValue);
|
|
246
246
|
for (const r of t)
|
|
@@ -249,9 +249,9 @@ function Os() {
|
|
|
249
249
|
return window.addEventListener("storage", e), {
|
|
250
250
|
postMessage: (s) => {
|
|
251
251
|
window.localStorage.setItem(
|
|
252
|
-
|
|
252
|
+
ve,
|
|
253
253
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
254
|
-
), window.localStorage.removeItem(
|
|
254
|
+
), window.localStorage.removeItem(ve);
|
|
255
255
|
},
|
|
256
256
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
257
257
|
close: () => {
|
|
@@ -273,7 +273,7 @@ function qs(t) {
|
|
|
273
273
|
const s = e;
|
|
274
274
|
return s.ok !== !0 || s.toolName !== Bt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
275
275
|
}
|
|
276
|
-
const Ls = globalThis.fetch.bind(globalThis),
|
|
276
|
+
const Ls = globalThis.fetch.bind(globalThis), $e = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ns = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', xs = ".pluno-pa-widget__panel", Bs = ".pluno-pa-widget__timeline", ht = `${$e}[data-pluno-sdk-preview-channel]`;
|
|
277
277
|
let Ws = 0;
|
|
278
278
|
function pt(t) {
|
|
279
279
|
const e = {};
|
|
@@ -306,14 +306,14 @@ function pt(t) {
|
|
|
306
306
|
if (a && typeof a == "object") {
|
|
307
307
|
const l = a.composerPreload;
|
|
308
308
|
if (l && typeof l == "object") {
|
|
309
|
-
const
|
|
310
|
-
e.composerPreloaded = !0, typeof
|
|
309
|
+
const u = l.runId;
|
|
310
|
+
e.composerPreloaded = !0, typeof u == "string" && (e.preloadRunId = u);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
return e;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function qe(t, e, s) {
|
|
317
317
|
if (typeof window > "u")
|
|
318
318
|
return;
|
|
319
319
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -332,24 +332,24 @@ function ve(t, e, s) {
|
|
|
332
332
|
};
|
|
333
333
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
334
334
|
}
|
|
335
|
-
const Hs = "https://app.pluno.ai", $s = "gpt-5.6-terra", js = 2e4, Fs = 1e4, zs = 1e4, Ks = 1e4, Gs = 1e4, Xs = 3e3, Vs = 3e4, Js = 1e3, gt = 3e4, ft = 0.2, mt = 6e4, yt = 15e3,
|
|
335
|
+
const Hs = "https://app.pluno.ai", $s = "gpt-5.6-terra", js = 2e4, Fs = 1e4, zs = 1e4, Ks = 1e4, Gs = 1e4, Xs = 3e3, Vs = 3e4, Js = 1e3, gt = 3e4, ft = 0.2, mt = 6e4, yt = 15e3, re = 8, It = "Browser connection was interrupted.", Tt = 15e3, Ys = "Pluno could not send this message. Try it again.", St = 2e3, Qs = 1e3, Zs = 100, wt = 8e3, en = 8e3, Mt = 3, tn = [300, 1e3], Wt = 50 * 1024 * 1024, sn = /* @__PURE__ */ new Set([
|
|
336
336
|
".jpeg:image/jpeg",
|
|
337
337
|
".jpg:image/jpeg",
|
|
338
338
|
".pdf:application/pdf",
|
|
339
339
|
".png:image/png",
|
|
340
340
|
".webp:image/webp"
|
|
341
|
-
]),
|
|
342
|
-
function
|
|
341
|
+
]), yi = ".pdf,.png,.jpg,.jpeg,.webp", Qe = 64e3, Le = 4e3, Ze = 30, nn = 2e3, rn = 1e3, Ht = "Image is too large for model vision input.", on = 100, $t = "pluno.productAgent.state.", je = "pluno.productAgent.pendingEvents.", Ae = "pluno.productAgent.activeToolCalls.", an = 100;
|
|
342
|
+
function ie(t, e = 0) {
|
|
343
343
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
344
344
|
return Math.max(e, s);
|
|
345
345
|
}
|
|
346
|
-
const
|
|
347
|
-
let
|
|
346
|
+
const me = /* @__PURE__ */ new Set();
|
|
347
|
+
let ue = null;
|
|
348
348
|
function ln(t, e = Math.random) {
|
|
349
349
|
const s = Math.min(gt, Js * 2 ** t), n = 1 - ft + e() * ft * 2;
|
|
350
350
|
return Math.min(gt, Math.round(s * n));
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function un(t, e, s) {
|
|
353
353
|
return new Promise((n, r) => {
|
|
354
354
|
const i = setTimeout(() => r(new Error(s)), e);
|
|
355
355
|
t.then(
|
|
@@ -368,12 +368,12 @@ class jt {
|
|
|
368
368
|
...this.state,
|
|
369
369
|
starterPrompts: jn(e.initialStarterPrompts)
|
|
370
370
|
};
|
|
371
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
371
|
+
const n = e.restorePersistedState === !1 ? null : Lr(e.clientId, e.expectedPersistedSessionId);
|
|
372
372
|
n && (this.state = {
|
|
373
373
|
...this.state,
|
|
374
374
|
...n,
|
|
375
375
|
messages: n.messages.filter(
|
|
376
|
-
(i) => !
|
|
376
|
+
(i) => !F(i)
|
|
377
377
|
),
|
|
378
378
|
status: "idle",
|
|
379
379
|
user: null,
|
|
@@ -385,16 +385,17 @@ class jt {
|
|
|
385
385
|
pendingMessageStatus: null,
|
|
386
386
|
turnPhase: null,
|
|
387
387
|
isThinking: !1,
|
|
388
|
+
taskStatus: null,
|
|
388
389
|
isRetrying: !1,
|
|
389
390
|
lastError: null
|
|
390
|
-
}), this.queuedClientEvents =
|
|
391
|
-
|
|
392
|
-
|
|
391
|
+
}), this.queuedClientEvents = $r(
|
|
392
|
+
xr(e.clientId),
|
|
393
|
+
Br(e.clientId)
|
|
393
394
|
);
|
|
394
395
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
395
396
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
396
397
|
);
|
|
397
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"),
|
|
398
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), G(e.clientId, this.queuedClientEvents);
|
|
398
399
|
}
|
|
399
400
|
options;
|
|
400
401
|
listeners = {};
|
|
@@ -489,6 +490,7 @@ class jt {
|
|
|
489
490
|
pendingMessageStatus: null,
|
|
490
491
|
turnPhase: null,
|
|
491
492
|
isThinking: !1,
|
|
493
|
+
taskStatus: null,
|
|
492
494
|
isRetrying: !1,
|
|
493
495
|
lastError: null,
|
|
494
496
|
lastErrorCode: null,
|
|
@@ -535,7 +537,7 @@ class jt {
|
|
|
535
537
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
536
538
|
);
|
|
537
539
|
try {
|
|
538
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
540
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await un(this.options.tokenProvider(), zs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
539
541
|
return;
|
|
540
542
|
if (!this.token && !this.options.webSocketFactory)
|
|
541
543
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
@@ -563,7 +565,7 @@ class jt {
|
|
|
563
565
|
const i = $n(r?.detail?.data);
|
|
564
566
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
565
567
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
566
|
-
) && (this.queuedClientEvents.push(i),
|
|
568
|
+
) && (this.queuedClientEvents.push(i), G(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
|
|
567
569
|
}), n.addEventListener("close", (r) => {
|
|
568
570
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (A("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
569
571
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -596,15 +598,15 @@ class jt {
|
|
|
596
598
|
this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
597
599
|
}
|
|
598
600
|
destroy() {
|
|
599
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
601
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), jr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
600
602
|
for (const e of Object.values(this.listeners))
|
|
601
603
|
e?.clear();
|
|
602
604
|
}
|
|
603
605
|
warmup(e = "panel_open") {
|
|
604
|
-
const s =
|
|
606
|
+
const s = b(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
|
|
605
607
|
type: "runtime.warmup",
|
|
606
608
|
reason: e,
|
|
607
|
-
...e === "composer_input" ? { warmupId: r?.event.warmupId ??
|
|
609
|
+
...e === "composer_input" ? { warmupId: r?.event.warmupId ?? j() } : {},
|
|
608
610
|
entrySurface: this.options.entrySurface,
|
|
609
611
|
sessionId: this.state.sessionId ?? void 0,
|
|
610
612
|
page: s
|
|
@@ -620,7 +622,7 @@ class jt {
|
|
|
620
622
|
async sendMessage(e, s = {}) {
|
|
621
623
|
const n = e.trim(), r = s.attachments ?? [];
|
|
622
624
|
if (this.options.productVariant === "customer_embedded" && (r.forEach(rs), r.reduce(
|
|
623
|
-
(
|
|
625
|
+
(w, U) => w + U.sizeBytes,
|
|
624
626
|
0
|
|
625
627
|
) > Wt))
|
|
626
628
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
@@ -629,13 +631,13 @@ class jt {
|
|
|
629
631
|
return null;
|
|
630
632
|
if (this.pendingClientMessageId)
|
|
631
633
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
632
|
-
const o =
|
|
634
|
+
const o = b(), a = s.clientMessageId ?? j(), l = {
|
|
633
635
|
id: `local-${a}`,
|
|
634
636
|
role: "user",
|
|
635
637
|
content: n,
|
|
636
638
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
637
639
|
...r.length > 0 ? { attachments: r } : {}
|
|
638
|
-
},
|
|
640
|
+
}, u = this.state.messages.some((m) => m.id === l.id || m.clientMessageId === a), h = this.state.isThinking, p = this.state.taskStatus, I = this.state.pendingMessageStatus, f = this.state.turnPhase, c = this.state.messages, d = u ? this.state.messages : [...this.state.messages, l], g = {
|
|
639
641
|
assistantDraft: this.state.assistantDraft,
|
|
640
642
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
641
643
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -644,7 +646,7 @@ class jt {
|
|
|
644
646
|
lastError: this.state.lastError
|
|
645
647
|
};
|
|
646
648
|
this.setState({
|
|
647
|
-
messages:
|
|
649
|
+
messages: d,
|
|
648
650
|
...h ? {} : {
|
|
649
651
|
assistantDraft: "",
|
|
650
652
|
assistantDraftItemId: null,
|
|
@@ -653,34 +655,36 @@ class jt {
|
|
|
653
655
|
assistantDraftRunId: null
|
|
654
656
|
},
|
|
655
657
|
pendingMessageStatus: "sending",
|
|
656
|
-
turnPhase: h ?
|
|
658
|
+
turnPhase: h ? f : "sending",
|
|
657
659
|
isThinking: h,
|
|
660
|
+
taskStatus: "working",
|
|
658
661
|
isRetrying: !1,
|
|
659
662
|
lastError: null
|
|
660
|
-
}),
|
|
663
|
+
}), u || this.emit("message", l);
|
|
661
664
|
try {
|
|
662
|
-
const
|
|
663
|
-
for (const
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
666
|
-
|
|
665
|
+
const m = [];
|
|
666
|
+
for (const w of i) {
|
|
667
|
+
const U = w.id ? this.attachmentFiles.get(w.id) : void 0;
|
|
668
|
+
if (w.sandboxPath || w.storageKey) {
|
|
669
|
+
m.push(w);
|
|
667
670
|
continue;
|
|
668
671
|
}
|
|
669
|
-
if (!
|
|
670
|
-
throw new Error(`Attachment bytes are unavailable for ${
|
|
671
|
-
|
|
672
|
+
if (!U)
|
|
673
|
+
throw new Error(`Attachment bytes are unavailable for ${w.name}`);
|
|
674
|
+
m.push(await this.uploadAttachmentForMessage({ file: U, attachment: w }));
|
|
672
675
|
}
|
|
673
|
-
i =
|
|
674
|
-
} catch (
|
|
676
|
+
i = m;
|
|
677
|
+
} catch (m) {
|
|
675
678
|
throw this.setState({
|
|
676
|
-
...
|
|
677
|
-
...h ? {} : { ...
|
|
678
|
-
pendingMessageStatus:
|
|
679
|
-
turnPhase:
|
|
680
|
-
|
|
679
|
+
...u ? {} : { messages: c },
|
|
680
|
+
...h ? {} : { ...g, isThinking: !1 },
|
|
681
|
+
pendingMessageStatus: I,
|
|
682
|
+
turnPhase: f,
|
|
683
|
+
taskStatus: p
|
|
684
|
+
}), m;
|
|
681
685
|
}
|
|
682
686
|
this.retryableClientMessageId = null;
|
|
683
|
-
const
|
|
687
|
+
const T = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, k = {
|
|
684
688
|
type: "chat.user_message",
|
|
685
689
|
sessionId: this.state.sessionId ?? void 0,
|
|
686
690
|
clientMessageId: a,
|
|
@@ -688,13 +692,13 @@ class jt {
|
|
|
688
692
|
invocation: Pn(s.invocation ?? s.initiatedBy),
|
|
689
693
|
entrySurface: this.options.entrySurface,
|
|
690
694
|
content: n,
|
|
691
|
-
pageContent:
|
|
695
|
+
pageContent: T && et() || void 0,
|
|
692
696
|
attachments: i.length > 0 ? i : void 0,
|
|
693
697
|
page: o,
|
|
694
698
|
model: this.options.model,
|
|
695
699
|
metadata: At(this.options.metadata)
|
|
696
700
|
};
|
|
697
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent =
|
|
701
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = k, this.send(k), this.schedulePendingDeliveryAck(a), a;
|
|
698
702
|
}
|
|
699
703
|
retryLastMessage() {
|
|
700
704
|
const e = this.state.sessionId, s = this.retryableClientMessageId;
|
|
@@ -712,8 +716,8 @@ class jt {
|
|
|
712
716
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
|
|
713
717
|
}
|
|
714
718
|
createLocalAttachment(e) {
|
|
715
|
-
this.options.productVariant === "customer_embedded" &&
|
|
716
|
-
const s =
|
|
719
|
+
this.options.productVariant === "customer_embedded" && Fr(e);
|
|
720
|
+
const s = j(), n = {
|
|
717
721
|
id: s,
|
|
718
722
|
name: e.name || "attachment",
|
|
719
723
|
mimeType: Xe(e),
|
|
@@ -727,7 +731,7 @@ class jt {
|
|
|
727
731
|
mimeType: n.mimeType,
|
|
728
732
|
sizeBytes: n.sizeBytes,
|
|
729
733
|
blob: e,
|
|
730
|
-
origin:
|
|
734
|
+
origin: b().origin,
|
|
731
735
|
sessionId: this.state.sessionId ?? void 0,
|
|
732
736
|
createdAt: r,
|
|
733
737
|
lastUsedAt: r
|
|
@@ -758,31 +762,31 @@ class jt {
|
|
|
758
762
|
name: e.name || "attachment",
|
|
759
763
|
mimeType: r,
|
|
760
764
|
sizeBytes: e.size,
|
|
761
|
-
page:
|
|
765
|
+
page: b(),
|
|
762
766
|
model: this.options.model,
|
|
763
767
|
metadata: At(this.options.metadata),
|
|
764
768
|
entrySurface: this.options.entrySurface
|
|
765
769
|
};
|
|
766
770
|
let o;
|
|
767
771
|
if (this.options.persistAttachmentUpload)
|
|
768
|
-
o = await
|
|
772
|
+
o = await ge(
|
|
769
773
|
() => this.options.persistAttachmentUpload(i, e),
|
|
770
774
|
"Failed to upload attachment"
|
|
771
775
|
);
|
|
772
776
|
else {
|
|
773
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
777
|
+
const l = this.options.prepareAttachmentUpload ? await ge(
|
|
774
778
|
() => this.options.prepareAttachmentUpload(i),
|
|
775
779
|
"Failed to prepare attachment upload"
|
|
776
780
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
777
|
-
await
|
|
778
|
-
const
|
|
781
|
+
await ge(async () => {
|
|
782
|
+
const u = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
779
783
|
method: l.uploadMethod,
|
|
780
784
|
headers: l.uploadHeaders,
|
|
781
785
|
body: e
|
|
782
786
|
});
|
|
783
|
-
if (!
|
|
784
|
-
throw new
|
|
785
|
-
return
|
|
787
|
+
if (!u.ok)
|
|
788
|
+
throw new Ie("Failed to upload attachment", u.status);
|
|
789
|
+
return u;
|
|
786
790
|
}, "Failed to upload attachment"), o = l;
|
|
787
791
|
}
|
|
788
792
|
this.setState({ sessionId: o.sessionId });
|
|
@@ -814,18 +818,18 @@ class jt {
|
|
|
814
818
|
}
|
|
815
819
|
async prepareEmbedAttachmentUpload(e) {
|
|
816
820
|
let s = !1;
|
|
817
|
-
return await
|
|
821
|
+
return await ge(async () => {
|
|
818
822
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
819
823
|
if (n.ok)
|
|
820
824
|
return await n.json();
|
|
821
|
-
if (
|
|
825
|
+
if (ai(n.status) && this.options.tokenProvider && !s) {
|
|
822
826
|
s = !0;
|
|
823
827
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
824
828
|
if (r.ok)
|
|
825
829
|
return await r.json();
|
|
826
|
-
throw new
|
|
830
|
+
throw new Ie("Failed to prepare attachment upload", r.status);
|
|
827
831
|
}
|
|
828
|
-
throw new
|
|
832
|
+
throw new Ie("Failed to prepare attachment upload", n.status);
|
|
829
833
|
}, "Failed to prepare attachment upload");
|
|
830
834
|
}
|
|
831
835
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -843,7 +847,7 @@ class jt {
|
|
|
843
847
|
if (!this.state.sessionId)
|
|
844
848
|
return;
|
|
845
849
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
846
|
-
const e =
|
|
850
|
+
const e = kr(
|
|
847
851
|
this.state.messages,
|
|
848
852
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
849
853
|
this.state.assistantDraftRunId,
|
|
@@ -856,7 +860,7 @@ class jt {
|
|
|
856
860
|
stoppedCausalSequence: null,
|
|
857
861
|
toolCallIds: new Set(
|
|
858
862
|
this.state.messages.filter(
|
|
859
|
-
(s) =>
|
|
863
|
+
(s) => Be(
|
|
860
864
|
s,
|
|
861
865
|
e.respondsToUserMessageId,
|
|
862
866
|
e.runId
|
|
@@ -874,6 +878,7 @@ class jt {
|
|
|
874
878
|
),
|
|
875
879
|
pendingMessageStatus: null,
|
|
876
880
|
isThinking: !1,
|
|
881
|
+
...this.state.taskStatus === "working" ? { taskStatus: "stopped" } : {},
|
|
877
882
|
isRetrying: !1,
|
|
878
883
|
lastError: null,
|
|
879
884
|
lastErrorCode: null,
|
|
@@ -886,7 +891,7 @@ class jt {
|
|
|
886
891
|
type: "session.reset",
|
|
887
892
|
sessionId: this.state.sessionId ?? void 0,
|
|
888
893
|
warmupId: n ?? void 0,
|
|
889
|
-
page:
|
|
894
|
+
page: b()
|
|
890
895
|
}), this.setState({
|
|
891
896
|
sessionId: null,
|
|
892
897
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -901,12 +906,13 @@ class jt {
|
|
|
901
906
|
assistantDraftRunId: null,
|
|
902
907
|
pendingMessageStatus: null,
|
|
903
908
|
isThinking: !1,
|
|
909
|
+
taskStatus: null,
|
|
904
910
|
isRetrying: !1,
|
|
905
911
|
lastError: null
|
|
906
912
|
});
|
|
907
913
|
}
|
|
908
914
|
listSessions(e = {}) {
|
|
909
|
-
const s =
|
|
915
|
+
const s = j(), n = new Promise((i, o) => {
|
|
910
916
|
const a = window.setTimeout(() => {
|
|
911
917
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
912
918
|
}, wt);
|
|
@@ -914,7 +920,7 @@ class jt {
|
|
|
914
920
|
}), r = {
|
|
915
921
|
type: "sessions.list",
|
|
916
922
|
requestId: s,
|
|
917
|
-
page:
|
|
923
|
+
page: b(),
|
|
918
924
|
...e.cursor ? { cursor: e.cursor } : {},
|
|
919
925
|
...e.limit ? { limit: e.limit } : {},
|
|
920
926
|
...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
|
|
@@ -928,23 +934,23 @@ class jt {
|
|
|
928
934
|
setSessionPinned(e, s) {
|
|
929
935
|
return this.sendSessionMutation(
|
|
930
936
|
this.pendingSessionPinRequests,
|
|
931
|
-
{ type: "session.pin", requestId:
|
|
937
|
+
{ type: "session.pin", requestId: j(), sessionId: e, pinned: s },
|
|
932
938
|
"Session pin did not respond in time"
|
|
933
939
|
);
|
|
934
940
|
}
|
|
935
941
|
renameSession(e, s) {
|
|
936
942
|
return this.sendSessionMutation(
|
|
937
943
|
this.pendingSessionRenameRequests,
|
|
938
|
-
{ type: "session.rename", requestId:
|
|
944
|
+
{ type: "session.rename", requestId: j(), sessionId: e, title: s },
|
|
939
945
|
"Session rename did not respond in time"
|
|
940
946
|
);
|
|
941
947
|
}
|
|
942
948
|
loadSession(e) {
|
|
943
|
-
const s =
|
|
949
|
+
const s = j(), n = this.activeComposerWarmupId;
|
|
944
950
|
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), n && this.send({
|
|
945
951
|
type: "session.reset",
|
|
946
952
|
warmupId: n,
|
|
947
|
-
page:
|
|
953
|
+
page: b()
|
|
948
954
|
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionLoadRequestTimer = window.setTimeout(() => {
|
|
949
955
|
this.sessionLoadRequestId === s && (this.clearSessionLoadRequest(), this.setState({
|
|
950
956
|
isLoadingSession: !1,
|
|
@@ -963,6 +969,7 @@ class jt {
|
|
|
963
969
|
assistantDraftRunId: null,
|
|
964
970
|
pendingMessageStatus: null,
|
|
965
971
|
isThinking: !1,
|
|
972
|
+
taskStatus: null,
|
|
966
973
|
isRetrying: !1,
|
|
967
974
|
lastError: null,
|
|
968
975
|
lastErrorCode: null
|
|
@@ -970,26 +977,26 @@ class jt {
|
|
|
970
977
|
type: "session.load",
|
|
971
978
|
requestId: s,
|
|
972
979
|
sessionId: e,
|
|
973
|
-
page:
|
|
980
|
+
page: b()
|
|
974
981
|
});
|
|
975
982
|
}
|
|
976
983
|
loadOlderMessages() {
|
|
977
984
|
if (!this.state.sessionId || !this.sessionItemsCursor || this.state.isLoadingSession || this.state.isLoadingOlderMessages)
|
|
978
985
|
return;
|
|
979
|
-
const e =
|
|
986
|
+
const e = j();
|
|
980
987
|
this.sessionItemsRequestId = e, this.setState({ isLoadingOlderMessages: !0, lastError: null, lastErrorCode: null }), this.send({
|
|
981
988
|
type: "session.items.list",
|
|
982
989
|
requestId: e,
|
|
983
990
|
sessionId: this.state.sessionId,
|
|
984
991
|
cursor: this.sessionItemsCursor,
|
|
985
992
|
limit: 50,
|
|
986
|
-
page:
|
|
993
|
+
page: b()
|
|
987
994
|
});
|
|
988
995
|
}
|
|
989
996
|
send(e) {
|
|
990
|
-
this.sendNow(
|
|
997
|
+
this.sendNow(q(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
991
998
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
992
|
-
) || this.queuedClientEvents.push(e),
|
|
999
|
+
) || this.queuedClientEvents.push(e), G(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
993
1000
|
status: "reconnecting",
|
|
994
1001
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
995
1002
|
}), this.scheduleReconnect());
|
|
@@ -1005,7 +1012,7 @@ class jt {
|
|
|
1005
1012
|
return !1;
|
|
1006
1013
|
const s = this.socket;
|
|
1007
1014
|
try {
|
|
1008
|
-
return s.send(JSON.stringify(e)),
|
|
1015
|
+
return s.send(JSON.stringify(e)), qe("client_event", e.type, pt(e)), !0;
|
|
1009
1016
|
} catch (n) {
|
|
1010
1017
|
return A("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1011
1018
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -1051,7 +1058,7 @@ class jt {
|
|
|
1051
1058
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
1052
1059
|
const e = vn();
|
|
1053
1060
|
this.sendNow(
|
|
1054
|
-
|
|
1061
|
+
q({
|
|
1055
1062
|
type: "starter_prompts.page_context",
|
|
1056
1063
|
pageUrl: e.pageUrl,
|
|
1057
1064
|
pageTitle: e.pageTitle,
|
|
@@ -1081,18 +1088,18 @@ class jt {
|
|
|
1081
1088
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
1082
1089
|
return;
|
|
1083
1090
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
1084
|
-
|
|
1091
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1085
1092
|
for (let s = 0; s < e.length; s += 1) {
|
|
1086
1093
|
const n = e[s];
|
|
1087
|
-
if (!this.sendNow(
|
|
1088
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1094
|
+
if (!this.sendNow(q(n))) {
|
|
1095
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), G(this.options.clientId, this.queuedClientEvents);
|
|
1089
1096
|
return;
|
|
1090
1097
|
}
|
|
1091
|
-
|
|
1098
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1092
1099
|
}
|
|
1093
1100
|
}
|
|
1094
1101
|
resetForAuthenticationScopeChange() {
|
|
1095
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
1102
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], G(this.options.clientId, this.queuedClientEvents), this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear();
|
|
1096
1103
|
}
|
|
1097
1104
|
flushPendingPassiveWarmup() {
|
|
1098
1105
|
!this.pendingPassiveWarmupEvent || !this.sendNow(this.pendingPassiveWarmupEvent) || (this.pendingPassiveWarmupEvent = null);
|
|
@@ -1117,16 +1124,16 @@ class jt {
|
|
|
1117
1124
|
return [...this.stoppedTurns].reverse().find((o) => o.sessionId !== e ? !1 : r && o.respondsToUserMessageId ? r === o.respondsToUserMessageId : n && o.clientMessageId ? n === o.clientMessageId : !!(i && o.runId && i === o.runId)) ?? null;
|
|
1118
1125
|
}
|
|
1119
1126
|
findStoppedTurnForEvent(e) {
|
|
1120
|
-
const s = e.type === "session.item" ?
|
|
1127
|
+
const s = e.type === "session.item" ? P(e.item) : null;
|
|
1121
1128
|
return this.findStoppedTurn(
|
|
1122
1129
|
ce(e) ?? this.state.sessionId,
|
|
1123
1130
|
s ?? e
|
|
1124
1131
|
);
|
|
1125
1132
|
}
|
|
1126
1133
|
rememberDurablyStoppedTurn(e, s, n) {
|
|
1127
|
-
if (!e || !s || !
|
|
1134
|
+
if (!e || !s || !ye(s) || this.findStoppedTurn(e, s))
|
|
1128
1135
|
return;
|
|
1129
|
-
const r =
|
|
1136
|
+
const r = N(s), i = _(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1130
1137
|
this.stoppedTurns.push({
|
|
1131
1138
|
sessionId: e,
|
|
1132
1139
|
clientMessageId: o,
|
|
@@ -1136,7 +1143,7 @@ class jt {
|
|
|
1136
1143
|
stoppedCausalSequence: v(s),
|
|
1137
1144
|
toolCallIds: new Set(
|
|
1138
1145
|
this.state.messages.filter(
|
|
1139
|
-
(a) =>
|
|
1146
|
+
(a) => Be(a, r, i)
|
|
1140
1147
|
).map((a) => a.callId).filter((a) => typeof a == "string")
|
|
1141
1148
|
)
|
|
1142
1149
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
@@ -1146,29 +1153,29 @@ class jt {
|
|
|
1146
1153
|
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1147
1154
|
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1148
1155
|
}
|
|
1149
|
-
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !
|
|
1156
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !ye(P(e.item)) : e.type !== "conversation.state" : !1;
|
|
1150
1157
|
}
|
|
1151
1158
|
filterStoppedSnapshotItems(e, s) {
|
|
1152
1159
|
return e.filter((n) => {
|
|
1153
|
-
const r =
|
|
1154
|
-
if (!i || r?.type === "message" && r.role === "user" ||
|
|
1160
|
+
const r = P(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1161
|
+
if (!i || r?.type === "message" && r.role === "user" || ye(r))
|
|
1155
1162
|
return !0;
|
|
1156
1163
|
if (i.stoppedCausalSequence !== null) {
|
|
1157
1164
|
const o = r ? v(r) : null;
|
|
1158
1165
|
return o === null || o <= i.stoppedCausalSequence;
|
|
1159
1166
|
}
|
|
1160
1167
|
if (i.stoppedAt) {
|
|
1161
|
-
const o =
|
|
1168
|
+
const o = S(n, "createdAt");
|
|
1162
1169
|
return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
|
|
1163
1170
|
}
|
|
1164
1171
|
return !1;
|
|
1165
1172
|
});
|
|
1166
1173
|
}
|
|
1167
1174
|
handleServerEvent(e) {
|
|
1168
|
-
if (
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1175
|
+
if (qe("server_event", e.type, pt(e)), e.type === "session.item" && this.rememberDurablyStoppedTurn(
|
|
1176
|
+
S(e.item, "sessionId") ?? this.state.sessionId,
|
|
1177
|
+
P(e.item),
|
|
1178
|
+
S(e.item, "createdAt")
|
|
1172
1179
|
), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1173
1180
|
if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
|
|
1174
1181
|
this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
|
|
@@ -1214,86 +1221,86 @@ class jt {
|
|
|
1214
1221
|
rawAppearance: e.appearance,
|
|
1215
1222
|
normalizedAppearance: n
|
|
1216
1223
|
}), this.runtimeHelperJavascript = zn(e.runtimeHelpers)?.javascript ?? null;
|
|
1217
|
-
const i =
|
|
1224
|
+
const i = kt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1218
1225
|
user: s,
|
|
1219
1226
|
status: "connected",
|
|
1220
1227
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1221
1228
|
};
|
|
1222
|
-
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !
|
|
1229
|
+
(o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !de() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1223
1230
|
type: "page.upsert",
|
|
1224
1231
|
sessionId: this.state.sessionId,
|
|
1225
|
-
page:
|
|
1232
|
+
page: b(),
|
|
1226
1233
|
model: this.options.model
|
|
1227
1234
|
});
|
|
1228
1235
|
return;
|
|
1229
1236
|
}
|
|
1230
1237
|
if (e.type === "starterPrompts.updated") {
|
|
1231
1238
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1232
|
-
starterPrompts:
|
|
1239
|
+
starterPrompts: kt(e, "starterPrompts"),
|
|
1233
1240
|
starterPromptsLoading: !1
|
|
1234
1241
|
});
|
|
1235
1242
|
return;
|
|
1236
1243
|
}
|
|
1237
1244
|
if (e.type === "conversation.state") {
|
|
1238
|
-
const s = Array.isArray(e.items) ? e.items : [], n =
|
|
1245
|
+
const s = Array.isArray(e.items) ? e.items : [], n = S(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null;
|
|
1239
1246
|
if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && n !== this.state.sessionId)
|
|
1240
1247
|
return;
|
|
1241
1248
|
n === this.state.sessionId && (this.clearSessionLoadRequest(), !this.hasLoadedOlderSessionItems && this.sessionItemsRequestId === null && (this.sessionItemsCursor = typeof e.itemsNextCursor == "string" ? e.itemsNextCursor : null));
|
|
1242
1249
|
for (const E of s)
|
|
1243
1250
|
this.rememberDurablyStoppedTurn(
|
|
1244
1251
|
n,
|
|
1245
|
-
|
|
1246
|
-
|
|
1252
|
+
P(E),
|
|
1253
|
+
S(E, "createdAt")
|
|
1247
1254
|
);
|
|
1248
|
-
const i =
|
|
1255
|
+
const i = Z(s), o = i === null ? null : s[i], a = P(o), l = this.findStoppedTurn(n, {
|
|
1249
1256
|
clientMessageId: a?.clientMessageId,
|
|
1250
|
-
respondsToUserMessageId:
|
|
1257
|
+
respondsToUserMessageId: S(o, "id"),
|
|
1251
1258
|
runId: a?.runId
|
|
1252
|
-
}),
|
|
1259
|
+
}), u = this.filterStoppedSnapshotItems(s, n), h = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, p = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, I = e.isRetrying === !0, f = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1253
1260
|
h && p && (this.pendingClientMessageId = p);
|
|
1254
|
-
let
|
|
1261
|
+
let c = nr(
|
|
1255
1262
|
e.assistantDraft
|
|
1256
1263
|
);
|
|
1257
|
-
|
|
1258
|
-
respondsToUserMessageId:
|
|
1259
|
-
runId:
|
|
1260
|
-
}) && (
|
|
1261
|
-
const d =
|
|
1262
|
-
this.rememberUserMessageClientMessageIds(
|
|
1263
|
-
const g = Sr(
|
|
1264
|
+
c && this.findStoppedTurn(n, {
|
|
1265
|
+
respondsToUserMessageId: c.respondsToUserMessageId,
|
|
1266
|
+
runId: c.runId
|
|
1267
|
+
}) && (c = void 0);
|
|
1268
|
+
const d = c !== void 0;
|
|
1269
|
+
this.rememberUserMessageClientMessageIds(u);
|
|
1270
|
+
const g = Sr(u);
|
|
1264
1271
|
if (g) {
|
|
1265
|
-
const E = wr(
|
|
1272
|
+
const E = wr(u, g);
|
|
1266
1273
|
this.retryAttemptsByClientMessageId[g] = Math.max(
|
|
1267
1274
|
this.retryAttemptsByClientMessageId[g] ?? 0,
|
|
1268
1275
|
E
|
|
1269
1276
|
);
|
|
1270
1277
|
}
|
|
1271
|
-
const T =
|
|
1272
|
-
const
|
|
1273
|
-
return bt(
|
|
1274
|
-
}),
|
|
1278
|
+
const T = u.filter((E) => {
|
|
1279
|
+
const O = P(E);
|
|
1280
|
+
return bt(O) ? !1 : !O || !g || !Se(O) ? !0 : Ke(u, O) !== g;
|
|
1281
|
+
}), k = dr(
|
|
1275
1282
|
this.state.messages,
|
|
1276
|
-
|
|
1283
|
+
Ct(T, this.options.backendUrl)
|
|
1277
1284
|
), m = this.hasLoadedOlderSessionItems ? hr(
|
|
1278
1285
|
this.state.messages,
|
|
1279
|
-
|
|
1286
|
+
k,
|
|
1280
1287
|
this.loadedOlderSessionItemIds
|
|
1281
|
-
) :
|
|
1282
|
-
(E,
|
|
1283
|
-
|
|
1284
|
-
|
|
1288
|
+
) : k, w = _t(m), U = d ? c?.content ?? "" : this.state.assistantDraft, D = d ? c?.itemId ?? null : this.state.assistantDraftItemId, R = d ? c?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, ee = d ? c?.runId ?? null : this.state.assistantDraftRunId, C = u.some(
|
|
1289
|
+
(E, O) => Pt(
|
|
1290
|
+
P(E),
|
|
1291
|
+
U,
|
|
1285
1292
|
D,
|
|
1286
1293
|
R,
|
|
1287
|
-
|
|
1288
|
-
Mr(
|
|
1294
|
+
ee,
|
|
1295
|
+
Mr(u, O)
|
|
1289
1296
|
)
|
|
1290
|
-
),
|
|
1291
|
-
if (!
|
|
1297
|
+
), te = d ? c?.content ?? "" : this.state.assistantDraft, z = !!c?.content && !C, H = w && (!te || C), K = yr(m), X = H && K ? "completed" : l ? "stopped" : H ? "failed" : null;
|
|
1298
|
+
if (!w && Tr(this.state.messages, u))
|
|
1292
1299
|
return;
|
|
1293
|
-
this.lastUserMessagePageUrl = Ir(
|
|
1294
|
-
const
|
|
1295
|
-
if (this.latestRecoverableClientMessageId =
|
|
1296
|
-
sessionId:
|
|
1300
|
+
this.lastUserMessagePageUrl = Ir(u);
|
|
1301
|
+
const L = H || l ? null : ze(u);
|
|
1302
|
+
if (this.latestRecoverableClientMessageId = L, K && this.clearRetryTimers(), this.setState({
|
|
1303
|
+
sessionId: S(e.session, "id") ?? this.state.sessionId,
|
|
1297
1304
|
messages: m,
|
|
1298
1305
|
isLoadingSession: !1,
|
|
1299
1306
|
isLoadingOlderMessages: this.sessionItemsRequestId !== null,
|
|
@@ -1301,46 +1308,47 @@ class jt {
|
|
|
1301
1308
|
...h ? { pendingMessageStatus: h } : {},
|
|
1302
1309
|
...f ? { turnPhase: f } : {},
|
|
1303
1310
|
isRetrying: I,
|
|
1304
|
-
...
|
|
1311
|
+
...X && this.state.taskStatus === "working" ? { taskStatus: X } : {},
|
|
1312
|
+
...C ? {
|
|
1305
1313
|
assistantDraft: "",
|
|
1306
1314
|
assistantDraftItemId: null,
|
|
1307
1315
|
assistantDraftPhase: null,
|
|
1308
1316
|
assistantDraftRespondsToUserMessageId: null,
|
|
1309
1317
|
assistantDraftRunId: null
|
|
1310
1318
|
} : d ? {
|
|
1311
|
-
assistantDraft:
|
|
1312
|
-
assistantDraftItemId:
|
|
1313
|
-
assistantDraftPhase:
|
|
1314
|
-
assistantDraftRespondsToUserMessageId:
|
|
1315
|
-
assistantDraftRunId:
|
|
1319
|
+
assistantDraft: c?.content ?? "",
|
|
1320
|
+
assistantDraftItemId: c?.itemId ?? null,
|
|
1321
|
+
assistantDraftPhase: c?.phase ?? null,
|
|
1322
|
+
assistantDraftRespondsToUserMessageId: c?.respondsToUserMessageId ?? null,
|
|
1323
|
+
assistantDraftRunId: c?.runId ?? null
|
|
1316
1324
|
} : {},
|
|
1317
|
-
...
|
|
1325
|
+
...z ? {
|
|
1318
1326
|
isThinking: !0,
|
|
1319
1327
|
turnPhase: "thinking",
|
|
1320
1328
|
lastError: null
|
|
1321
|
-
} :
|
|
1329
|
+
} : H ? {
|
|
1322
1330
|
isThinking: !1,
|
|
1323
1331
|
status: "connected",
|
|
1324
1332
|
lastError: null,
|
|
1325
1333
|
lastErrorCode: null,
|
|
1326
1334
|
lastErrorSecuritySettingsUrl: null
|
|
1327
|
-
} :
|
|
1335
|
+
} : L ? {
|
|
1328
1336
|
isThinking: !0,
|
|
1329
1337
|
turnPhase: f ?? this.state.turnPhase ?? "starting",
|
|
1330
1338
|
lastError: null
|
|
1331
1339
|
} : {}
|
|
1332
|
-
}),
|
|
1340
|
+
}), H)
|
|
1333
1341
|
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1334
|
-
else if (!l && (
|
|
1335
|
-
if (
|
|
1336
|
-
this.activeClientMessageId =
|
|
1337
|
-
const E =
|
|
1338
|
-
this.activeResponseUserMessageId =
|
|
1342
|
+
else if (!l && (z || L)) {
|
|
1343
|
+
if (L) {
|
|
1344
|
+
this.activeClientMessageId = L;
|
|
1345
|
+
const E = Z(u), O = E === null ? null : u[E];
|
|
1346
|
+
this.activeResponseUserMessageId = S(O, "id");
|
|
1339
1347
|
}
|
|
1340
1348
|
this.markThinkingProgress();
|
|
1341
1349
|
}
|
|
1342
1350
|
if (g) {
|
|
1343
|
-
const E =
|
|
1351
|
+
const E = S(e.session, "id") ?? this.state.sessionId;
|
|
1344
1352
|
E && this.retryAfterInterruptedRun(E, g);
|
|
1345
1353
|
}
|
|
1346
1354
|
return;
|
|
@@ -1349,7 +1357,7 @@ class jt {
|
|
|
1349
1357
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1350
1358
|
if (!s || s !== this.sessionItemsRequestId || n !== this.state.sessionId)
|
|
1351
1359
|
return;
|
|
1352
|
-
const r =
|
|
1360
|
+
const r = Ct(
|
|
1353
1361
|
Array.isArray(e.items) ? e.items : [],
|
|
1354
1362
|
this.options.backendUrl
|
|
1355
1363
|
), i = new Set(r.map((o) => o.id));
|
|
@@ -1380,7 +1388,7 @@ class jt {
|
|
|
1380
1388
|
}
|
|
1381
1389
|
if (e.type === "session.updated") {
|
|
1382
1390
|
this.clearRunAckResyncRetryTimer();
|
|
1383
|
-
const s =
|
|
1391
|
+
const s = S(e.session, "id");
|
|
1384
1392
|
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1385
1393
|
...this.pendingComposerWarmup.event,
|
|
1386
1394
|
sessionId: s
|
|
@@ -1391,10 +1399,10 @@ class jt {
|
|
|
1391
1399
|
}
|
|
1392
1400
|
if (e.type === "session.item") {
|
|
1393
1401
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1394
|
-
const s =
|
|
1395
|
-
if (
|
|
1402
|
+
const s = P(e.item);
|
|
1403
|
+
if (Se(s)) {
|
|
1396
1404
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1397
|
-
const r =
|
|
1405
|
+
const r = S(e.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1398
1406
|
if (r && a) {
|
|
1399
1407
|
this.retryAfterInterruptedRun(r, a);
|
|
1400
1408
|
return;
|
|
@@ -1408,12 +1416,10 @@ class jt {
|
|
|
1408
1416
|
return;
|
|
1409
1417
|
const n = Xt(e.item, this.options.backendUrl);
|
|
1410
1418
|
if (n) {
|
|
1411
|
-
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1412
|
-
n.callId &&
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1415
|
-
const o = je(this.state.messages, n), a = _t(o), l = Pt(
|
|
1416
|
-
i,
|
|
1419
|
+
const r = Cr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1420
|
+
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), B(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Rr(s) && this.clearRunAckResyncRetryTimer();
|
|
1421
|
+
const o = Fe(this.state.messages, n), a = _t(o), l = Pt(
|
|
1422
|
+
s,
|
|
1417
1423
|
this.state.assistantDraft,
|
|
1418
1424
|
this.state.assistantDraftItemId,
|
|
1419
1425
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
@@ -1422,7 +1428,7 @@ class jt {
|
|
|
1422
1428
|
o,
|
|
1423
1429
|
o.findIndex((p) => p.id === n.id)
|
|
1424
1430
|
)
|
|
1425
|
-
),
|
|
1431
|
+
), u = a && (!this.state.assistantDraft || l), h = Te(n) && (u || B(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
1426
1432
|
this.setState({
|
|
1427
1433
|
messages: o,
|
|
1428
1434
|
...l ? {
|
|
@@ -1432,8 +1438,9 @@ class jt {
|
|
|
1432
1438
|
assistantDraftRespondsToUserMessageId: null,
|
|
1433
1439
|
assistantDraftRunId: null
|
|
1434
1440
|
} : {},
|
|
1435
|
-
...
|
|
1441
|
+
...u ? {
|
|
1436
1442
|
isThinking: !1,
|
|
1443
|
+
...r && this.state.taskStatus === "working" ? { taskStatus: r } : {},
|
|
1437
1444
|
isRetrying: !1
|
|
1438
1445
|
} : {},
|
|
1439
1446
|
...h && !this.failedUserMessageEvent ? {
|
|
@@ -1442,15 +1449,15 @@ class jt {
|
|
|
1442
1449
|
lastErrorCode: null,
|
|
1443
1450
|
lastErrorSecuritySettingsUrl: null
|
|
1444
1451
|
} : {}
|
|
1445
|
-
}),
|
|
1452
|
+
}), u && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
1446
1453
|
}
|
|
1447
1454
|
return;
|
|
1448
1455
|
}
|
|
1449
1456
|
if (e.type === "chat.assistant_delta") {
|
|
1450
1457
|
this.clearRunAckResyncRetryTimer();
|
|
1451
|
-
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((p) => p.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase,
|
|
1452
|
-
this.activeClientMessageId && (this.activeResponseUserMessageId =
|
|
1453
|
-
messages:
|
|
1458
|
+
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((p) => p.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, u = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1459
|
+
this.activeClientMessageId && (this.activeResponseUserMessageId = u, this.activeResponseRunId = h), this.setState({
|
|
1460
|
+
messages: Fe(this.state.messages, {
|
|
1454
1461
|
id: o,
|
|
1455
1462
|
role: "assistant",
|
|
1456
1463
|
content: i,
|
|
@@ -1458,15 +1465,16 @@ class jt {
|
|
|
1458
1465
|
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1459
1466
|
dataType: "assistant_draft",
|
|
1460
1467
|
...l ? { phase: l } : {},
|
|
1461
|
-
...
|
|
1468
|
+
...u ? { respondsToUserMessageId: u } : {},
|
|
1462
1469
|
...h ? { runId: h } : {}
|
|
1463
1470
|
}),
|
|
1464
1471
|
assistantDraft: i,
|
|
1465
1472
|
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1466
1473
|
assistantDraftPhase: l,
|
|
1467
|
-
assistantDraftRespondsToUserMessageId:
|
|
1474
|
+
assistantDraftRespondsToUserMessageId: u,
|
|
1468
1475
|
assistantDraftRunId: h,
|
|
1469
1476
|
isThinking: !0,
|
|
1477
|
+
taskStatus: "working",
|
|
1470
1478
|
isRetrying: !1
|
|
1471
1479
|
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1472
1480
|
return;
|
|
@@ -1480,8 +1488,8 @@ class jt {
|
|
|
1480
1488
|
return;
|
|
1481
1489
|
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = Es(
|
|
1482
1490
|
this.state.messages.filter(
|
|
1483
|
-
(
|
|
1484
|
-
|
|
1491
|
+
(u) => u.dataType !== "assistant_draft" || !Be(
|
|
1492
|
+
u,
|
|
1485
1493
|
n,
|
|
1486
1494
|
r
|
|
1487
1495
|
)
|
|
@@ -1504,6 +1512,7 @@ class jt {
|
|
|
1504
1512
|
assistantDraftRespondsToUserMessageId: null,
|
|
1505
1513
|
assistantDraftRunId: null,
|
|
1506
1514
|
isThinking: a ? !1 : this.state.isThinking,
|
|
1515
|
+
...a && this.state.taskStatus === "working" ? { taskStatus: "completed" } : {},
|
|
1507
1516
|
isRetrying: a ? !1 : this.state.isRetrying
|
|
1508
1517
|
}), a && this.clearThinkingWatchdog();
|
|
1509
1518
|
return;
|
|
@@ -1514,7 +1523,7 @@ class jt {
|
|
|
1514
1523
|
if (s)
|
|
1515
1524
|
this.nonTranscriptToolCallIds.add(s);
|
|
1516
1525
|
else {
|
|
1517
|
-
const n =
|
|
1526
|
+
const n = ur(e);
|
|
1518
1527
|
if (n) {
|
|
1519
1528
|
const r = ar(
|
|
1520
1529
|
this.state.messages,
|
|
@@ -1586,13 +1595,13 @@ class jt {
|
|
|
1586
1595
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1587
1596
|
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Un(a.message);
|
|
1588
1597
|
l && console.error(l);
|
|
1589
|
-
const
|
|
1598
|
+
const u = i ?? this.activeClientMessageId, h = typeof e.runId == "string" ? e.runId : null, p = Ut(
|
|
1590
1599
|
this.state.messages,
|
|
1591
|
-
|
|
1600
|
+
u,
|
|
1592
1601
|
h
|
|
1593
1602
|
), I = mr(
|
|
1594
1603
|
p,
|
|
1595
|
-
|
|
1604
|
+
u,
|
|
1596
1605
|
h
|
|
1597
1606
|
);
|
|
1598
1607
|
this.setState({
|
|
@@ -1604,6 +1613,7 @@ class jt {
|
|
|
1604
1613
|
assistantDraftRespondsToUserMessageId: null,
|
|
1605
1614
|
assistantDraftRunId: null,
|
|
1606
1615
|
isThinking: !1,
|
|
1616
|
+
...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
|
|
1607
1617
|
isRetrying: !1,
|
|
1608
1618
|
lastError: I ? null : a.message,
|
|
1609
1619
|
lastErrorCode: I ? null : typeof e.code == "string" ? e.code : null,
|
|
@@ -1626,7 +1636,7 @@ class jt {
|
|
|
1626
1636
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1627
1637
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1628
1638
|
return !1;
|
|
1629
|
-
if (
|
|
1639
|
+
if (de())
|
|
1630
1640
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1631
1641
|
if (e.code === "run_still_active") {
|
|
1632
1642
|
if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
|
|
@@ -1640,10 +1650,10 @@ class jt {
|
|
|
1640
1650
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1641
1651
|
return !0;
|
|
1642
1652
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1643
|
-
if (i >=
|
|
1653
|
+
if (i >= re)
|
|
1644
1654
|
return !1;
|
|
1645
1655
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1646
|
-
const o =
|
|
1656
|
+
const o = ie(
|
|
1647
1657
|
i,
|
|
1648
1658
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1649
1659
|
);
|
|
@@ -1657,20 +1667,20 @@ class jt {
|
|
|
1657
1667
|
}, o), !0;
|
|
1658
1668
|
}
|
|
1659
1669
|
retryAfterInterruptedRun(e, s) {
|
|
1660
|
-
if (
|
|
1670
|
+
if (de()) {
|
|
1661
1671
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1662
1672
|
return;
|
|
1663
1673
|
}
|
|
1664
1674
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1665
1675
|
return;
|
|
1666
1676
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1667
|
-
if (n >=
|
|
1677
|
+
if (n >= re) {
|
|
1668
1678
|
this.requestSessionRecoveryExhaustion(e, s);
|
|
1669
1679
|
return;
|
|
1670
1680
|
}
|
|
1671
1681
|
this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
|
|
1672
1682
|
delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 });
|
|
1673
|
-
},
|
|
1683
|
+
}, ie(n));
|
|
1674
1684
|
}
|
|
1675
1685
|
requestSessionRecoveryExhaustion(e, s) {
|
|
1676
1686
|
this.retryableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.recoveryExhaustionRequestedClientMessageIds.has(s) ? this.resyncThinkingSession() : (this.recoveryExhaustionRequestedClientMessageIds.add(s), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 })), this.scheduleThinkingWatchdog(yt);
|
|
@@ -1682,10 +1692,10 @@ class jt {
|
|
|
1682
1692
|
}
|
|
1683
1693
|
rememberUserMessageClientMessageIds(e) {
|
|
1684
1694
|
for (const s of e) {
|
|
1685
|
-
const n =
|
|
1695
|
+
const n = S(s, "id"), r = P(s);
|
|
1686
1696
|
n && r?.type === "message" && r.role === "user" && r.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof r.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId), r.clientMessageId === this.pendingClientMessageId && this.promotePendingDelivery(
|
|
1687
1697
|
r.clientMessageId,
|
|
1688
|
-
|
|
1698
|
+
S(s, "sessionId") ?? this.state.sessionId,
|
|
1689
1699
|
n,
|
|
1690
1700
|
null
|
|
1691
1701
|
), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
|
|
@@ -1770,7 +1780,7 @@ class jt {
|
|
|
1770
1780
|
}), this.markThinkingProgress();
|
|
1771
1781
|
}
|
|
1772
1782
|
schedulePendingDeliveryAck(e) {
|
|
1773
|
-
this.clearPendingDeliveryTimers(), !
|
|
1783
|
+
this.clearPendingDeliveryTimers(), !de() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
1774
1784
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
1775
1785
|
}, Tt));
|
|
1776
1786
|
}
|
|
@@ -1778,13 +1788,13 @@ class jt {
|
|
|
1778
1788
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
1779
1789
|
return;
|
|
1780
1790
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1781
|
-
if (s >=
|
|
1791
|
+
if (s >= re) {
|
|
1782
1792
|
this.failPendingDelivery(e);
|
|
1783
1793
|
return;
|
|
1784
1794
|
}
|
|
1785
1795
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
1786
1796
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
1787
|
-
},
|
|
1797
|
+
}, ie(s, St));
|
|
1788
1798
|
}
|
|
1789
1799
|
failPendingDelivery(e) {
|
|
1790
1800
|
if (this.pendingClientMessageId !== e)
|
|
@@ -1795,6 +1805,7 @@ class jt {
|
|
|
1795
1805
|
// A failed follow-up delivery must not hide an older acknowledged response that is still active.
|
|
1796
1806
|
...this.state.isThinking ? {} : { turnPhase: null },
|
|
1797
1807
|
isRetrying: !1,
|
|
1808
|
+
...this.state.isThinking ? {} : { taskStatus: "failed" },
|
|
1798
1809
|
lastError: Ys,
|
|
1799
1810
|
lastErrorCode: "message_delivery_failed"
|
|
1800
1811
|
});
|
|
@@ -1810,7 +1821,7 @@ class jt {
|
|
|
1810
1821
|
s,
|
|
1811
1822
|
typeof e.runId == "string" ? e.runId : null
|
|
1812
1823
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
1813
|
-
messages:
|
|
1824
|
+
messages: br(
|
|
1814
1825
|
this.state.messages,
|
|
1815
1826
|
s
|
|
1816
1827
|
)
|
|
@@ -1830,7 +1841,7 @@ class jt {
|
|
|
1830
1841
|
scheduleRunAckResyncRetry(e) {
|
|
1831
1842
|
this.clearRunAckResyncRetryTimer();
|
|
1832
1843
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1833
|
-
s >=
|
|
1844
|
+
s >= re || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
1834
1845
|
this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[e] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || this.latestRecoverableClientMessageId !== e || (this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({
|
|
1835
1846
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1836
1847
|
isThinking: !0,
|
|
@@ -1844,7 +1855,7 @@ class jt {
|
|
|
1844
1855
|
clientMessageId: e,
|
|
1845
1856
|
automatic: !0
|
|
1846
1857
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(mt)));
|
|
1847
|
-
},
|
|
1858
|
+
}, ie(s, St)));
|
|
1848
1859
|
}
|
|
1849
1860
|
clearRunAckResyncRetryTimer() {
|
|
1850
1861
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -1863,21 +1874,23 @@ class jt {
|
|
|
1863
1874
|
reason: "missing_client_message_id"
|
|
1864
1875
|
}), this.setState({
|
|
1865
1876
|
messages: this.state.messages.filter(
|
|
1866
|
-
(r) => !
|
|
1877
|
+
(r) => !F(r)
|
|
1867
1878
|
),
|
|
1868
1879
|
isThinking: !1,
|
|
1880
|
+
taskStatus: "failed",
|
|
1869
1881
|
lastError: It,
|
|
1870
1882
|
lastErrorCode: "run_recovery_exhausted"
|
|
1871
1883
|
}), this.clearThinkingWatchdog();
|
|
1872
1884
|
return;
|
|
1873
1885
|
}
|
|
1874
1886
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1875
|
-
if (n >=
|
|
1887
|
+
if (n >= re) {
|
|
1876
1888
|
A("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1877
1889
|
sessionId: this.state.sessionId,
|
|
1878
1890
|
clientMessageId: e
|
|
1879
1891
|
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
1880
1892
|
isThinking: !1,
|
|
1893
|
+
taskStatus: "failed",
|
|
1881
1894
|
lastError: It,
|
|
1882
1895
|
lastErrorCode: "connection_failed"
|
|
1883
1896
|
}), this.clearThinkingWatchdog());
|
|
@@ -1906,32 +1919,32 @@ class jt {
|
|
|
1906
1919
|
clientMessageId: e,
|
|
1907
1920
|
automatic: !0
|
|
1908
1921
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
1909
|
-
},
|
|
1922
|
+
}, ie(n)));
|
|
1910
1923
|
}
|
|
1911
1924
|
resyncThinkingSession() {
|
|
1912
1925
|
this.state.sessionId ? this.send({
|
|
1913
1926
|
type: "page.upsert",
|
|
1914
1927
|
sessionId: this.state.sessionId,
|
|
1915
|
-
page:
|
|
1928
|
+
page: b(),
|
|
1916
1929
|
model: this.options.model
|
|
1917
1930
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1918
1931
|
}
|
|
1919
1932
|
async executeToolCall(e) {
|
|
1920
|
-
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i =
|
|
1933
|
+
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i = J(
|
|
1921
1934
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
1922
1935
|
), o = e.rawInput;
|
|
1923
1936
|
if (!s || !n || !r)
|
|
1924
1937
|
return;
|
|
1925
1938
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1926
|
-
if (!a && !l || !
|
|
1939
|
+
if (!a && !l || !Vr(o)) {
|
|
1927
1940
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1928
1941
|
type: "tool.result",
|
|
1929
1942
|
sessionId: s,
|
|
1930
1943
|
callId: n,
|
|
1931
1944
|
toolName: r,
|
|
1932
1945
|
summary: i,
|
|
1933
|
-
rawInput:
|
|
1934
|
-
rawOutput:
|
|
1946
|
+
rawInput: q(o),
|
|
1947
|
+
rawOutput: q({
|
|
1935
1948
|
ok: !1,
|
|
1936
1949
|
toolName: r,
|
|
1937
1950
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -1946,7 +1959,7 @@ class jt {
|
|
|
1946
1959
|
callId: n,
|
|
1947
1960
|
toolName: r,
|
|
1948
1961
|
summary: i,
|
|
1949
|
-
rawInput:
|
|
1962
|
+
rawInput: q(o),
|
|
1950
1963
|
rawOutput: {
|
|
1951
1964
|
ok: !1,
|
|
1952
1965
|
toolName: r,
|
|
@@ -1962,17 +1975,17 @@ class jt {
|
|
|
1962
1975
|
callId: n,
|
|
1963
1976
|
toolName: r,
|
|
1964
1977
|
summary: i,
|
|
1965
|
-
rawInput:
|
|
1978
|
+
rawInput: q(o),
|
|
1966
1979
|
rawOutput: null
|
|
1967
1980
|
},
|
|
1968
1981
|
startedAtMs: Date.now(),
|
|
1969
1982
|
startedAtUrl: location.href,
|
|
1970
1983
|
startedAtOrigin: location.origin
|
|
1971
1984
|
}), this.installSessionBrowserApis();
|
|
1972
|
-
let
|
|
1973
|
-
|
|
1985
|
+
let u = null, h;
|
|
1986
|
+
u = await this.executeRuntimeHelper(), h = await Rt(
|
|
1974
1987
|
o,
|
|
1975
|
-
|
|
1988
|
+
kn(e.runtimeContext, this.options.backendUrl)
|
|
1976
1989
|
).catch((p) => ({
|
|
1977
1990
|
ok: !1,
|
|
1978
1991
|
exception: {
|
|
@@ -1984,8 +1997,8 @@ class jt {
|
|
|
1984
1997
|
callId: n,
|
|
1985
1998
|
toolName: r,
|
|
1986
1999
|
summary: o.summary,
|
|
1987
|
-
rawInput:
|
|
1988
|
-
rawOutput:
|
|
2000
|
+
rawInput: q(o),
|
|
2001
|
+
rawOutput: q(Kn(h, u))
|
|
1989
2002
|
}), vt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
1990
2003
|
}
|
|
1991
2004
|
setToolMessageLoading(e, s) {
|
|
@@ -2021,18 +2034,18 @@ class jt {
|
|
|
2021
2034
|
return e.ok === !1 ? Gn(e) : null;
|
|
2022
2035
|
}
|
|
2023
2036
|
enableNetworkCapture() {
|
|
2024
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
2025
|
-
|
|
2037
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = cn((e) => {
|
|
2038
|
+
ti(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
2026
2039
|
}));
|
|
2027
2040
|
}
|
|
2028
2041
|
enqueueNetworkEvent(e) {
|
|
2029
|
-
this.queuedNetworkEvents.length >= Zs || (this.queuedNetworkEvents.push(
|
|
2042
|
+
this.queuedNetworkEvents.length >= Zs || (this.queuedNetworkEvents.push(ei(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
2030
2043
|
this.networkBatchTimer = null;
|
|
2031
2044
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
2032
2045
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
2033
2046
|
type: "network.batch",
|
|
2034
2047
|
sessionId: this.state.sessionId ?? void 0,
|
|
2035
|
-
page:
|
|
2048
|
+
page: b(),
|
|
2036
2049
|
events: s
|
|
2037
2050
|
});
|
|
2038
2051
|
}, Qs)));
|
|
@@ -2087,19 +2100,21 @@ class jt {
|
|
|
2087
2100
|
const s = e.isThinking ?? this.state.isThinking, n = e.pendingMessageStatus !== void 0 ? e.pendingMessageStatus : this.state.pendingMessageStatus;
|
|
2088
2101
|
let r = e.turnPhase !== void 0 ? e.turnPhase : this.state.turnPhase;
|
|
2089
2102
|
e.turnPhase === void 0 && (e.isThinking === !1 ? r = n ? "sending" : null : s && r === null ? r = "starting" : !s && n && r === null && (r = "sending"));
|
|
2090
|
-
const i = {
|
|
2103
|
+
const i = e.taskStatus !== void 0 ? e.taskStatus : s || n !== null ? "working" : this.state.taskStatus, o = {
|
|
2091
2104
|
...this.state,
|
|
2092
2105
|
...e,
|
|
2093
2106
|
turnPhase: r,
|
|
2107
|
+
taskStatus: i,
|
|
2094
2108
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2095
2109
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2096
2110
|
};
|
|
2097
|
-
this.state =
|
|
2111
|
+
this.state = o, Nr(this.options.clientId, this.state), this.emit("state", this.getState()), qe("state", this.state.status, {
|
|
2098
2112
|
status: this.state.status,
|
|
2099
2113
|
sessionId: this.state.sessionId,
|
|
2100
2114
|
messageCount: this.state.messages.length,
|
|
2101
2115
|
assistantDraftLength: this.state.assistantDraft.length,
|
|
2102
2116
|
isThinking: this.state.isThinking,
|
|
2117
|
+
taskStatus: this.state.taskStatus,
|
|
2103
2118
|
turnPhase: this.state.turnPhase,
|
|
2104
2119
|
hasError: this.state.lastError !== null
|
|
2105
2120
|
});
|
|
@@ -2115,8 +2130,8 @@ class jt {
|
|
|
2115
2130
|
this.listeners[e]?.forEach((r) => r(s));
|
|
2116
2131
|
}
|
|
2117
2132
|
}
|
|
2118
|
-
const
|
|
2119
|
-
function
|
|
2133
|
+
const Ne = /* @__PURE__ */ new WeakMap();
|
|
2134
|
+
function cn(t) {
|
|
2120
2135
|
const e = window.__plunoProductAgentNetworkCapture ?? dn();
|
|
2121
2136
|
return e.subscribers.add(t), () => {
|
|
2122
2137
|
e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
@@ -2130,31 +2145,31 @@ function dn() {
|
|
|
2130
2145
|
} catch {
|
|
2131
2146
|
}
|
|
2132
2147
|
});
|
|
2133
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f,
|
|
2148
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, c) {
|
|
2134
2149
|
const d = Date.now();
|
|
2135
2150
|
let g;
|
|
2136
2151
|
try {
|
|
2137
|
-
g = s.call(this, f,
|
|
2152
|
+
g = s.call(this, f, c);
|
|
2138
2153
|
} catch (T) {
|
|
2139
2154
|
throw T;
|
|
2140
2155
|
}
|
|
2141
2156
|
try {
|
|
2142
|
-
const T = f instanceof Request ? f : null,
|
|
2143
|
-
if (!
|
|
2144
|
-
const
|
|
2145
|
-
requestId:
|
|
2146
|
-
url:
|
|
2147
|
-
method: (
|
|
2157
|
+
const T = f instanceof Request ? f : null, k = Jr(f, T), m = is(c?.headers ?? T?.headers);
|
|
2158
|
+
if (!V(k, m, c?.body)) {
|
|
2159
|
+
const U = {
|
|
2160
|
+
requestId: We("fetch"),
|
|
2161
|
+
url: x(k, Le),
|
|
2162
|
+
method: (c?.method ?? T?.method ?? "GET").toUpperCase(),
|
|
2148
2163
|
requestHeaders: m,
|
|
2149
|
-
requestBody: qt(
|
|
2164
|
+
requestBody: qt(c?.body),
|
|
2150
2165
|
resourceType: "fetch",
|
|
2151
2166
|
startedAt: new Date(d).toISOString()
|
|
2152
2167
|
};
|
|
2153
2168
|
g.then(
|
|
2154
2169
|
(D) => {
|
|
2155
|
-
|
|
2170
|
+
Yr(D, U, d, e).catch(() => {
|
|
2156
2171
|
e({
|
|
2157
|
-
|
|
2172
|
+
...U,
|
|
2158
2173
|
responseStatus: D.status,
|
|
2159
2174
|
durationMs: Date.now() - d
|
|
2160
2175
|
});
|
|
@@ -2162,8 +2177,8 @@ function dn() {
|
|
|
2162
2177
|
},
|
|
2163
2178
|
(D) => {
|
|
2164
2179
|
e({
|
|
2165
|
-
|
|
2166
|
-
errorText:
|
|
2180
|
+
...U,
|
|
2181
|
+
errorText: x(D instanceof Error ? D.message : String(D)),
|
|
2167
2182
|
durationMs: Date.now() - d
|
|
2168
2183
|
});
|
|
2169
2184
|
}
|
|
@@ -2172,42 +2187,42 @@ function dn() {
|
|
|
2172
2187
|
} catch {
|
|
2173
2188
|
}
|
|
2174
2189
|
return g;
|
|
2175
|
-
}, a = function(f,
|
|
2176
|
-
const
|
|
2177
|
-
return
|
|
2178
|
-
requestId:
|
|
2190
|
+
}, a = function(f, c, d, g, T) {
|
|
2191
|
+
const k = n.call(this, f, c, d ?? !0, g ?? void 0, T ?? void 0), m = typeof c == "string" ? c : c.toString();
|
|
2192
|
+
return Ne.set(this, {
|
|
2193
|
+
requestId: We("xhr"),
|
|
2179
2194
|
method: String(f ?? "GET").toUpperCase(),
|
|
2180
|
-
url:
|
|
2195
|
+
url: x(m, Le),
|
|
2181
2196
|
requestHeaders: {},
|
|
2182
2197
|
startedAtMs: Date.now(),
|
|
2183
2198
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2184
|
-
excluded:
|
|
2185
|
-
}),
|
|
2186
|
-
}, l = function(f,
|
|
2187
|
-
const d = r.call(this, f,
|
|
2188
|
-
return g && Object.keys(g.requestHeaders).length < Ze && (g.requestHeaders[f] = nt(f,
|
|
2189
|
-
},
|
|
2199
|
+
excluded: V(m)
|
|
2200
|
+
}), k;
|
|
2201
|
+
}, l = function(f, c) {
|
|
2202
|
+
const d = r.call(this, f, c), g = Ne.get(this);
|
|
2203
|
+
return g && Object.keys(g.requestHeaders).length < Ze && (g.requestHeaders[f] = nt(f, c), g.excluded = g.excluded || V(g.url, g.requestHeaders)), d;
|
|
2204
|
+
}, u = function(f) {
|
|
2190
2205
|
try {
|
|
2191
|
-
const
|
|
2192
|
-
|
|
2206
|
+
const c = Ne.get(this);
|
|
2207
|
+
c && (c.excluded = c.excluded || V(c.url, c.requestHeaders, f), c.requestBody = qt(f), c.excluded || this.addEventListener(
|
|
2193
2208
|
"loadend",
|
|
2194
2209
|
() => {
|
|
2195
2210
|
queueMicrotask(() => {
|
|
2196
2211
|
try {
|
|
2197
|
-
const d =
|
|
2212
|
+
const d = ni(this.getAllResponseHeaders());
|
|
2198
2213
|
e({
|
|
2199
|
-
requestId:
|
|
2200
|
-
url:
|
|
2201
|
-
method:
|
|
2202
|
-
requestHeaders:
|
|
2203
|
-
requestBody:
|
|
2214
|
+
requestId: c.requestId,
|
|
2215
|
+
url: c.url,
|
|
2216
|
+
method: c.method,
|
|
2217
|
+
requestHeaders: c.requestHeaders,
|
|
2218
|
+
requestBody: c.requestBody,
|
|
2204
2219
|
resourceType: "xhr",
|
|
2205
2220
|
responseStatus: this.status,
|
|
2206
2221
|
responseHeaders: d,
|
|
2207
|
-
responseBody:
|
|
2222
|
+
responseBody: Zr(this, d),
|
|
2208
2223
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2209
|
-
startedAt:
|
|
2210
|
-
durationMs: Date.now() -
|
|
2224
|
+
startedAt: c.startedAt,
|
|
2225
|
+
durationMs: Date.now() - c.startedAtMs
|
|
2211
2226
|
});
|
|
2212
2227
|
} catch {
|
|
2213
2228
|
return;
|
|
@@ -2233,25 +2248,25 @@ function dn() {
|
|
|
2233
2248
|
} catch {
|
|
2234
2249
|
}
|
|
2235
2250
|
try {
|
|
2236
|
-
XMLHttpRequest.prototype.send =
|
|
2251
|
+
XMLHttpRequest.prototype.send = u;
|
|
2237
2252
|
} catch {
|
|
2238
2253
|
}
|
|
2239
2254
|
let h = null;
|
|
2240
2255
|
if (typeof PerformanceObserver < "u") {
|
|
2241
2256
|
h = new PerformanceObserver((I) => {
|
|
2242
2257
|
for (const f of I.getEntries()) {
|
|
2243
|
-
const
|
|
2244
|
-
if (
|
|
2258
|
+
const c = f;
|
|
2259
|
+
if (c.initiatorType === "fetch" || c.initiatorType === "xmlhttprequest" || V(c.name))
|
|
2245
2260
|
continue;
|
|
2246
|
-
const d = performance.timeOrigin +
|
|
2261
|
+
const d = performance.timeOrigin + c.startTime;
|
|
2247
2262
|
e({
|
|
2248
|
-
requestId:
|
|
2249
|
-
url:
|
|
2263
|
+
requestId: We("resource"),
|
|
2264
|
+
url: x(c.name, Le),
|
|
2250
2265
|
method: "GET",
|
|
2251
2266
|
resourceType: "resource",
|
|
2252
|
-
responseStatus:
|
|
2267
|
+
responseStatus: c.responseStatus,
|
|
2253
2268
|
startedAt: new Date(d).toISOString(),
|
|
2254
|
-
durationMs:
|
|
2269
|
+
durationMs: c.duration
|
|
2255
2270
|
});
|
|
2256
2271
|
}
|
|
2257
2272
|
});
|
|
@@ -2278,7 +2293,7 @@ function dn() {
|
|
|
2278
2293
|
} catch {
|
|
2279
2294
|
}
|
|
2280
2295
|
try {
|
|
2281
|
-
XMLHttpRequest.prototype.send ===
|
|
2296
|
+
XMLHttpRequest.prototype.send === u && (XMLHttpRequest.prototype.send = i);
|
|
2282
2297
|
} catch {
|
|
2283
2298
|
}
|
|
2284
2299
|
}
|
|
@@ -2422,18 +2437,18 @@ async function Rt(t, e) {
|
|
|
2422
2437
|
info: console.info,
|
|
2423
2438
|
warn: console.warn,
|
|
2424
2439
|
error: console.error
|
|
2425
|
-
}, l = (
|
|
2426
|
-
i.push({ level:
|
|
2440
|
+
}, l = (u) => (...h) => {
|
|
2441
|
+
i.push({ level: u, args: h }), a[u](...h);
|
|
2427
2442
|
};
|
|
2428
2443
|
console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error");
|
|
2429
2444
|
try {
|
|
2430
|
-
const
|
|
2445
|
+
const u = /* @__PURE__ */ Symbol("execute_code_timeout"), h = await Promise.race([
|
|
2431
2446
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
2432
2447
|
new Promise((p) => {
|
|
2433
|
-
o = window.setTimeout(() => p(
|
|
2448
|
+
o = window.setTimeout(() => p(u), n);
|
|
2434
2449
|
})
|
|
2435
2450
|
]);
|
|
2436
|
-
return h ===
|
|
2451
|
+
return h === u ? Cn(n) : {
|
|
2437
2452
|
ok: !0,
|
|
2438
2453
|
result: h,
|
|
2439
2454
|
console: i,
|
|
@@ -2443,14 +2458,14 @@ async function Rt(t, e) {
|
|
|
2443
2458
|
origin: location.origin
|
|
2444
2459
|
}
|
|
2445
2460
|
};
|
|
2446
|
-
} catch (
|
|
2461
|
+
} catch (u) {
|
|
2447
2462
|
return {
|
|
2448
2463
|
ok: !1,
|
|
2449
2464
|
console: i,
|
|
2450
2465
|
exception: {
|
|
2451
|
-
name:
|
|
2452
|
-
message:
|
|
2453
|
-
stack:
|
|
2466
|
+
name: u instanceof Error ? u.name : "Error",
|
|
2467
|
+
message: u instanceof Error ? u.message : String(u),
|
|
2468
|
+
stack: u instanceof Error ? u.stack : void 0
|
|
2454
2469
|
},
|
|
2455
2470
|
metadata: {
|
|
2456
2471
|
durationMs: Date.now() - r,
|
|
@@ -2462,7 +2477,7 @@ async function Rt(t, e) {
|
|
|
2462
2477
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2463
2478
|
}
|
|
2464
2479
|
}
|
|
2465
|
-
function
|
|
2480
|
+
function kn(t, e) {
|
|
2466
2481
|
if (!t || typeof t != "object")
|
|
2467
2482
|
return;
|
|
2468
2483
|
const s = t.sandboxFilesToken;
|
|
@@ -2478,7 +2493,7 @@ function Cn(t, e) {
|
|
|
2478
2493
|
upload: async (a) => {
|
|
2479
2494
|
if (r(), !(a instanceof Blob))
|
|
2480
2495
|
throw new TypeError("sandboxFiles.upload expects a File or Blob");
|
|
2481
|
-
const l = a instanceof File && a.name ? a.name : "file",
|
|
2496
|
+
const l = a instanceof File && a.name ? a.name : "file", u = `?name=${encodeURIComponent(l)}&size_bytes=${a.size}`, h = await i(`/api/product-agent/attachments/sandbox-files${u}`, {
|
|
2482
2497
|
method: "PUT",
|
|
2483
2498
|
headers: { Authorization: `Bearer ${s}` },
|
|
2484
2499
|
body: a
|
|
@@ -2495,9 +2510,9 @@ function Cn(t, e) {
|
|
|
2495
2510
|
);
|
|
2496
2511
|
if (!l.ok)
|
|
2497
2512
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
2498
|
-
const
|
|
2499
|
-
return new File([
|
|
2500
|
-
type:
|
|
2513
|
+
const u = await l.blob(), p = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
2514
|
+
return new File([u], p || a.split("/").pop() || "file", {
|
|
2515
|
+
type: u.type
|
|
2501
2516
|
});
|
|
2502
2517
|
}
|
|
2503
2518
|
}),
|
|
@@ -2506,7 +2521,7 @@ function Cn(t, e) {
|
|
|
2506
2521
|
}
|
|
2507
2522
|
};
|
|
2508
2523
|
}
|
|
2509
|
-
function
|
|
2524
|
+
function Cn(t) {
|
|
2510
2525
|
return {
|
|
2511
2526
|
ok: !1,
|
|
2512
2527
|
exception: {
|
|
@@ -2545,7 +2560,7 @@ function Dn(t) {
|
|
|
2545
2560
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2546
2561
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2547
2562
|
}
|
|
2548
|
-
function
|
|
2563
|
+
function b() {
|
|
2549
2564
|
const t = Gt();
|
|
2550
2565
|
return {
|
|
2551
2566
|
url: location.href,
|
|
@@ -2562,13 +2577,13 @@ function vn() {
|
|
|
2562
2577
|
};
|
|
2563
2578
|
}
|
|
2564
2579
|
function On(t) {
|
|
2565
|
-
return
|
|
2566
|
-
|
|
2580
|
+
return me.add(t), ue || (ue = qn()), () => {
|
|
2581
|
+
me.delete(t), me.size === 0 && (ue?.(), ue = null);
|
|
2567
2582
|
};
|
|
2568
2583
|
}
|
|
2569
2584
|
function qn() {
|
|
2570
2585
|
const t = () => {
|
|
2571
|
-
for (const i of Array.from(
|
|
2586
|
+
for (const i of Array.from(me))
|
|
2572
2587
|
i();
|
|
2573
2588
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2574
2589
|
const o = e(...i);
|
|
@@ -2581,14 +2596,14 @@ function qn() {
|
|
|
2581
2596
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2582
2597
|
};
|
|
2583
2598
|
}
|
|
2584
|
-
function
|
|
2599
|
+
function de() {
|
|
2585
2600
|
return Gt()?.surface === "browser_extension_sdk_preview";
|
|
2586
2601
|
}
|
|
2587
2602
|
function et() {
|
|
2588
2603
|
if (!document.body)
|
|
2589
2604
|
return "";
|
|
2590
2605
|
const t = [], e = [], s = (d, g) => {
|
|
2591
|
-
const T =
|
|
2606
|
+
const T = Y(g);
|
|
2592
2607
|
!T || e.includes(T) || (t.push([d, T]), e.push(T));
|
|
2593
2608
|
};
|
|
2594
2609
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
@@ -2596,23 +2611,23 @@ function et() {
|
|
|
2596
2611
|
(d) => Ft(d) && !d.parentElement?.closest(n)
|
|
2597
2612
|
);
|
|
2598
2613
|
for (const d of r.slice(0, 3))
|
|
2599
|
-
s("Active overlay",
|
|
2600
|
-
const i = Ln(), o = i ?
|
|
2601
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2614
|
+
s("Active overlay", xe(oe(d), e));
|
|
2615
|
+
const i = Ln(), o = i ? xe(oe(i), e) : "";
|
|
2616
|
+
s("Main page content", o), s("Additional visible page text", xe(oe(document.body), e));
|
|
2602
2617
|
const a = t.map(([d, g]) => `${d}:
|
|
2603
2618
|
${g}`).join(`
|
|
2604
2619
|
|
|
2605
|
-
`).trim().slice(0, 12e3), l = Nn(r, i).trim(),
|
|
2620
|
+
`).trim().slice(0, 12e3), l = Nn(r, i).trim(), u = `Simplified DOM outline:
|
|
2606
2621
|
`, h = `
|
|
2607
2622
|
|
|
2608
2623
|
Visible page text:
|
|
2609
|
-
`, p = 12e3 -
|
|
2610
|
-
return `${
|
|
2624
|
+
`, p = 12e3 - u.length - h.length, I = Math.min(a.length, 7900), f = l.slice(0, p - I), c = a.slice(0, p - f.length);
|
|
2625
|
+
return `${u}${f}${h}${c}`;
|
|
2611
2626
|
}
|
|
2612
|
-
function
|
|
2627
|
+
function oe(t) {
|
|
2613
2628
|
return t.innerText ?? t.textContent ?? "";
|
|
2614
2629
|
}
|
|
2615
|
-
function
|
|
2630
|
+
function Y(t) {
|
|
2616
2631
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2617
2632
|
`).split(`
|
|
2618
2633
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2620,18 +2635,18 @@ function J(t) {
|
|
|
2620
2635
|
|
|
2621
2636
|
`).trim();
|
|
2622
2637
|
}
|
|
2623
|
-
function
|
|
2624
|
-
let s =
|
|
2638
|
+
function xe(t, e) {
|
|
2639
|
+
let s = Y(t);
|
|
2625
2640
|
for (const n of e)
|
|
2626
2641
|
s = s.replace(n, "");
|
|
2627
|
-
return
|
|
2642
|
+
return Y(s);
|
|
2628
2643
|
}
|
|
2629
2644
|
function Ft(t) {
|
|
2630
2645
|
const e = window.getComputedStyle(t);
|
|
2631
2646
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2632
2647
|
}
|
|
2633
2648
|
function Ln() {
|
|
2634
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ft).sort((t, e) =>
|
|
2649
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ft).sort((t, e) => oe(e).length - oe(t).length)[0] ?? null;
|
|
2635
2650
|
}
|
|
2636
2651
|
function Nn(t, e) {
|
|
2637
2652
|
const s = /* @__PURE__ */ new Set([
|
|
@@ -2713,77 +2728,77 @@ function Nn(t, e) {
|
|
|
2713
2728
|
"data-test",
|
|
2714
2729
|
"data-qa",
|
|
2715
2730
|
"data-cy"
|
|
2716
|
-
],
|
|
2731
|
+
], u = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: p } = xn(), I = new Set(t);
|
|
2717
2732
|
e && I.add(e);
|
|
2718
2733
|
let f = 0;
|
|
2719
|
-
const
|
|
2720
|
-
const
|
|
2721
|
-
return
|
|
2734
|
+
const c = (m) => {
|
|
2735
|
+
const w = m.getAttribute("role");
|
|
2736
|
+
return w && !o.has(w) ? w : "";
|
|
2722
2737
|
}, d = (m) => {
|
|
2723
|
-
const
|
|
2724
|
-
return `${m.tagName.toLowerCase()}|${
|
|
2725
|
-
}, g = (m,
|
|
2726
|
-
const D = (R,
|
|
2727
|
-
const
|
|
2728
|
-
if (f >= 1e3 && !
|
|
2738
|
+
const w = m.getAttribute("data-testid") || m.getAttribute("data-test") || m.getAttribute("data-qa") || m.getAttribute("data-cy") || "";
|
|
2739
|
+
return `${m.tagName.toLowerCase()}|${c(m)}|${w}`;
|
|
2740
|
+
}, g = (m, w, U) => {
|
|
2741
|
+
const D = (R, ee) => {
|
|
2742
|
+
const C = R.tagName.toLowerCase(), te = window.getComputedStyle(R), z = h.has(R);
|
|
2743
|
+
if (f >= 1e3 && !z || U.has(R) || i.has(C) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || te.display === "none" || te.visibility === "hidden")
|
|
2729
2744
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2730
2745
|
f += 1;
|
|
2731
|
-
const
|
|
2732
|
-
for (const y of
|
|
2746
|
+
const H = c(R), K = Kt(R), rt = a.has(H) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(C) || C === "a" && R.hasAttribute("href"), X = Array.from(R.children).filter((y) => y instanceof HTMLElement), L = /* @__PURE__ */ new Map();
|
|
2747
|
+
for (const y of X) {
|
|
2733
2748
|
const M = d(y);
|
|
2734
|
-
|
|
2749
|
+
L.set(M, (L.get(M) ?? 0) + 1);
|
|
2735
2750
|
}
|
|
2736
|
-
const
|
|
2737
|
-
for (const y of
|
|
2738
|
-
const M = d(y),
|
|
2739
|
-
|
|
2751
|
+
const E = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map();
|
|
2752
|
+
for (const y of X) {
|
|
2753
|
+
const M = d(y), $ = O.get(M) ?? 0;
|
|
2754
|
+
O.set(M, $ + 1), (L.get(M) ?? 0) > 8 && $ >= 6 && !h.has(y) && E.set(M, (E.get(M) ?? 0) + 1);
|
|
2740
2755
|
}
|
|
2741
|
-
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(),
|
|
2742
|
-
for (const y of
|
|
2743
|
-
const M = d(y),
|
|
2744
|
-
if (it.set(M,
|
|
2745
|
-
ot.has(M) || (
|
|
2756
|
+
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(), ke = [], at = [];
|
|
2757
|
+
for (const y of X) {
|
|
2758
|
+
const M = d(y), $ = L.get(M) ?? 0, ct = it.get(M) ?? 0;
|
|
2759
|
+
if (it.set(M, ct + 1), $ > 8 && ct >= 6 && !h.has(y)) {
|
|
2760
|
+
ot.has(M) || (ke.push([`… ${E.get(M) ?? 0} similar siblings omitted`]), ot.add(M));
|
|
2746
2761
|
continue;
|
|
2747
2762
|
}
|
|
2748
|
-
const dt = D(y,
|
|
2749
|
-
at.push(dt),
|
|
2763
|
+
const dt = D(y, ee);
|
|
2764
|
+
at.push(dt), ke.push(dt.lines);
|
|
2750
2765
|
}
|
|
2751
|
-
const
|
|
2766
|
+
const Ce = [];
|
|
2752
2767
|
if (R.shadowRoot)
|
|
2753
2768
|
for (const y of Array.from(R.shadowRoot.children))
|
|
2754
|
-
y instanceof HTMLElement &&
|
|
2755
|
-
const
|
|
2756
|
-
[
|
|
2757
|
-
).slice(0, 180), ps = R.hasAttribute("contenteditable") && (
|
|
2758
|
-
if (
|
|
2759
|
-
const y =
|
|
2760
|
-
|
|
2769
|
+
y instanceof HTMLElement && Ce.push(D(y, ee + 1));
|
|
2770
|
+
const le = [...at, ...Ce], _e = K.length > 0 || rt || le.some((y) => y.hasUsefulContent), lt = Y(
|
|
2771
|
+
[K, ...le.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2772
|
+
).slice(0, 180), ps = R.hasAttribute("contenteditable") && (K.length > 0 || !R.querySelector("[contenteditable]")), ut = u.some((y) => R.hasAttribute(y)) || !!H || ps, be = (R.getClientRects().length > 0 || te.display === "contents") && (s.has(C) || ut || z) && (_e || z) && (!r.has(C) || _e || ut || z), Pe = be ? 1 : 0, se = [];
|
|
2773
|
+
if (be) {
|
|
2774
|
+
const y = le.some(($) => $.containsTextElement), M = n.has(C) && !y ? lt : K;
|
|
2775
|
+
se.push(zt(R, l, o, M.slice(0, 180)));
|
|
2761
2776
|
}
|
|
2762
|
-
for (const y of
|
|
2763
|
-
|
|
2764
|
-
const
|
|
2765
|
-
if (
|
|
2766
|
-
const y =
|
|
2767
|
-
|
|
2768
|
-
const M =
|
|
2769
|
-
if (
|
|
2770
|
-
const
|
|
2771
|
-
|
|
2777
|
+
for (const y of ke)
|
|
2778
|
+
se.push(...he(y, Pe));
|
|
2779
|
+
const Ue = Ce.flatMap((y) => y.lines);
|
|
2780
|
+
if (Ue.length > 0) {
|
|
2781
|
+
const y = Ue.slice(0, 20);
|
|
2782
|
+
Ue.length > y.length && y.push("… shadow DOM omitted");
|
|
2783
|
+
const M = C.includes("tooltip") || C.includes("popper") || C.includes("loader");
|
|
2784
|
+
if (ee < 2 && !M) {
|
|
2785
|
+
const $ = be ? "#shadow-root" : `${C} #shadow-root`;
|
|
2786
|
+
se.push(...he([$, ...he(y, 1)], Pe));
|
|
2772
2787
|
} else
|
|
2773
|
-
|
|
2788
|
+
se.push(...he(y, Pe));
|
|
2774
2789
|
}
|
|
2775
2790
|
return {
|
|
2776
|
-
lines:
|
|
2777
|
-
hasUsefulContent:
|
|
2791
|
+
lines: se,
|
|
2792
|
+
hasUsefulContent: _e,
|
|
2778
2793
|
textPreview: lt,
|
|
2779
|
-
containsTextElement: n.has(
|
|
2794
|
+
containsTextElement: n.has(C) || le.some((y) => y.containsTextElement)
|
|
2780
2795
|
};
|
|
2781
2796
|
};
|
|
2782
|
-
return [`--- ${
|
|
2797
|
+
return [`--- ${w} ---`, ...D(m, 0).lines].join(`
|
|
2783
2798
|
`);
|
|
2784
|
-
}, T = [],
|
|
2785
|
-
|
|
2786
|
-
${JSON.stringify(
|
|
2799
|
+
}, T = [], k = Y(window.getSelection()?.toString() ?? "");
|
|
2800
|
+
k && T.push(`--- selected text ---
|
|
2801
|
+
${JSON.stringify(k)}`), p.length > 0 && T.push(Bn(p, s, l, o));
|
|
2787
2802
|
for (const m of t.slice(0, 3))
|
|
2788
2803
|
T.push(g(m, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2789
2804
|
if (e && T.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2815,8 +2830,8 @@ function xn() {
|
|
|
2815
2830
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
|
|
2816
2831
|
if (!a)
|
|
2817
2832
|
return;
|
|
2818
|
-
const
|
|
2819
|
-
if (
|
|
2833
|
+
const u = window.getComputedStyle(a);
|
|
2834
|
+
if (u.display === "none" || u.visibility === "hidden")
|
|
2820
2835
|
return;
|
|
2821
2836
|
const h = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
2822
2837
|
h.add(l), e.set(a, h);
|
|
@@ -2843,11 +2858,11 @@ function xn() {
|
|
|
2843
2858
|
], o = [document];
|
|
2844
2859
|
for (let a = 0; a < o.length; a += 1) {
|
|
2845
2860
|
const l = o[a];
|
|
2846
|
-
for (const [
|
|
2847
|
-
for (const p of Array.from(l.querySelectorAll(
|
|
2861
|
+
for (const [u, h] of i)
|
|
2862
|
+
for (const p of Array.from(l.querySelectorAll(u)))
|
|
2848
2863
|
s(p, h);
|
|
2849
|
-
for (const
|
|
2850
|
-
|
|
2864
|
+
for (const u of Array.from(l.querySelectorAll("*")))
|
|
2865
|
+
u.shadowRoot && o.push(u.shadowRoot);
|
|
2851
2866
|
}
|
|
2852
2867
|
return {
|
|
2853
2868
|
priorityElements: t,
|
|
@@ -2865,13 +2880,13 @@ function Bn(t, e, s, n) {
|
|
|
2865
2880
|
const p = a.getRootNode();
|
|
2866
2881
|
a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
|
|
2867
2882
|
}
|
|
2868
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o,
|
|
2883
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, u = l.map((h, p) => zt(
|
|
2869
2884
|
h,
|
|
2870
2885
|
s,
|
|
2871
2886
|
n,
|
|
2872
2887
|
p === l.length - 1 ? Kt(h).slice(0, 180) : ""
|
|
2873
2888
|
));
|
|
2874
|
-
o.length > l.length &&
|
|
2889
|
+
o.length > l.length && u.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${u.join(" > ")}`);
|
|
2875
2890
|
}
|
|
2876
2891
|
return r.join(`
|
|
2877
2892
|
`);
|
|
@@ -2879,14 +2894,14 @@ function Bn(t, e, s, n) {
|
|
|
2879
2894
|
function Et(t) {
|
|
2880
2895
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
2881
2896
|
}
|
|
2882
|
-
function
|
|
2897
|
+
function he(t, e) {
|
|
2883
2898
|
if (e === 0)
|
|
2884
2899
|
return t;
|
|
2885
2900
|
const s = " ".repeat(e);
|
|
2886
2901
|
return t.map((n) => `${s}${n}`);
|
|
2887
2902
|
}
|
|
2888
2903
|
function Kt(t) {
|
|
2889
|
-
return
|
|
2904
|
+
return Y(
|
|
2890
2905
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
2891
2906
|
);
|
|
2892
2907
|
}
|
|
@@ -2895,7 +2910,7 @@ function Wn(t) {
|
|
|
2895
2910
|
}
|
|
2896
2911
|
function Gt() {
|
|
2897
2912
|
const t = document.querySelector(ht);
|
|
2898
|
-
if (!(t ?? document.querySelector(
|
|
2913
|
+
if (!(t ?? document.querySelector($e)))
|
|
2899
2914
|
return;
|
|
2900
2915
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2901
2916
|
return {
|
|
@@ -2904,7 +2919,7 @@ function Gt() {
|
|
|
2904
2919
|
selectors: [
|
|
2905
2920
|
{
|
|
2906
2921
|
name: "widget_host",
|
|
2907
|
-
selector: s === "browser_extension_sdk_preview" ? ht :
|
|
2922
|
+
selector: s === "browser_extension_sdk_preview" ? ht : $e,
|
|
2908
2923
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2909
2924
|
},
|
|
2910
2925
|
{
|
|
@@ -2943,7 +2958,7 @@ function $n(t) {
|
|
|
2943
2958
|
return null;
|
|
2944
2959
|
}
|
|
2945
2960
|
}
|
|
2946
|
-
function
|
|
2961
|
+
function kt(t, e) {
|
|
2947
2962
|
if (!t || typeof t != "object")
|
|
2948
2963
|
return [];
|
|
2949
2964
|
const s = t[e];
|
|
@@ -2992,7 +3007,7 @@ function Xn() {
|
|
|
2992
3007
|
const s = crypto.randomUUID();
|
|
2993
3008
|
return window.localStorage.setItem(t, s), s;
|
|
2994
3009
|
}
|
|
2995
|
-
function
|
|
3010
|
+
function j() {
|
|
2996
3011
|
return crypto.randomUUID();
|
|
2997
3012
|
}
|
|
2998
3013
|
function Vn(t) {
|
|
@@ -3006,7 +3021,7 @@ function Vn(t) {
|
|
|
3006
3021
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
3007
3022
|
} : null;
|
|
3008
3023
|
}
|
|
3009
|
-
function
|
|
3024
|
+
function Ct(t, e) {
|
|
3010
3025
|
return Array.isArray(t) ? Ge(
|
|
3011
3026
|
t.map((s) => Xt(s, e)).filter((s) => s !== null)
|
|
3012
3027
|
) : [];
|
|
@@ -3015,13 +3030,13 @@ function Jn(t) {
|
|
|
3015
3030
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3016
3031
|
if (!e || typeof e != "object")
|
|
3017
3032
|
return [];
|
|
3018
|
-
const s = e, n =
|
|
3033
|
+
const s = e, n = S(s, "id"), r = S(s, "createdAt"), i = S(s, "updatedAt"), o = S(s, "lastActiveAt");
|
|
3019
3034
|
return !n || !r || !i || !o ? [] : [
|
|
3020
3035
|
{
|
|
3021
3036
|
id: n,
|
|
3022
|
-
title:
|
|
3023
|
-
customTitle:
|
|
3024
|
-
firstUserMessage:
|
|
3037
|
+
title: S(s, "title"),
|
|
3038
|
+
customTitle: S(s, "customTitle"),
|
|
3039
|
+
firstUserMessage: S(s, "firstUserMessage"),
|
|
3025
3040
|
currentPage: s.currentPage ?? null,
|
|
3026
3041
|
createdAt: r,
|
|
3027
3042
|
updatedAt: i,
|
|
@@ -3052,7 +3067,7 @@ function Xt(t, e) {
|
|
|
3052
3067
|
),
|
|
3053
3068
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3054
3069
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3055
|
-
respondsToUserMessageId:
|
|
3070
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3056
3071
|
..._(r) ? { runId: _(r) } : {},
|
|
3057
3072
|
attachments: ss(r.attachments, e)
|
|
3058
3073
|
};
|
|
@@ -3072,11 +3087,11 @@ function Xt(t, e) {
|
|
|
3072
3087
|
role: "tool",
|
|
3073
3088
|
content: "",
|
|
3074
3089
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3075
|
-
respondsToUserMessageId:
|
|
3090
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3076
3091
|
..._(r) ? { runId: _(r) } : {},
|
|
3077
3092
|
dataType: "scheduled_check_in",
|
|
3078
3093
|
toolName: Bt,
|
|
3079
|
-
callId:
|
|
3094
|
+
callId: pe(r) ?? void 0,
|
|
3080
3095
|
scheduledCheckInAt: i
|
|
3081
3096
|
};
|
|
3082
3097
|
const o = Qn(r.output), a = Zn(r.output);
|
|
@@ -3086,11 +3101,11 @@ function Xt(t, e) {
|
|
|
3086
3101
|
content: `Connect ${o.appName} to continue`,
|
|
3087
3102
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3088
3103
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3089
|
-
respondsToUserMessageId:
|
|
3104
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3090
3105
|
..._(r) ? { runId: _(r) } : {},
|
|
3091
3106
|
dataType: "function_call_output",
|
|
3092
3107
|
toolName: "authenticate_pipedream_app",
|
|
3093
|
-
callId:
|
|
3108
|
+
callId: pe(r) ?? void 0,
|
|
3094
3109
|
integrationAuthRequest: o
|
|
3095
3110
|
} : a ? {
|
|
3096
3111
|
id: String(s.id ?? crypto.randomUUID()),
|
|
@@ -3098,11 +3113,11 @@ function Xt(t, e) {
|
|
|
3098
3113
|
content: "Connect WhatsApp to continue",
|
|
3099
3114
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3100
3115
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3101
|
-
respondsToUserMessageId:
|
|
3116
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3102
3117
|
..._(r) ? { runId: _(r) } : {},
|
|
3103
3118
|
dataType: "function_call_output",
|
|
3104
3119
|
toolName: "request_personal_channel_connection",
|
|
3105
|
-
callId:
|
|
3120
|
+
callId: pe(r) ?? void 0,
|
|
3106
3121
|
personalChannelConnectionRequest: a
|
|
3107
3122
|
} : null;
|
|
3108
3123
|
}
|
|
@@ -3112,11 +3127,11 @@ function Xt(t, e) {
|
|
|
3112
3127
|
content: r.type === "mcp_call" ? Yn(r) : tr(r),
|
|
3113
3128
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3114
3129
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3115
|
-
respondsToUserMessageId:
|
|
3130
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3116
3131
|
..._(r) ? { runId: _(r) } : {},
|
|
3117
3132
|
dataType: String(r.type),
|
|
3118
3133
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
3119
|
-
callId:
|
|
3134
|
+
callId: pe(r) ?? void 0,
|
|
3120
3135
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
3121
3136
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
3122
3137
|
id: String(s.id ?? crypto.randomUUID()),
|
|
@@ -3124,7 +3139,7 @@ function Xt(t, e) {
|
|
|
3124
3139
|
content: er(r),
|
|
3125
3140
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3126
3141
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3127
|
-
respondsToUserMessageId:
|
|
3142
|
+
respondsToUserMessageId: N(r) ?? void 0,
|
|
3128
3143
|
..._(r) ? { runId: _(r) } : {},
|
|
3129
3144
|
dataType: String(r.type),
|
|
3130
3145
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -3188,18 +3203,18 @@ function tr(t) {
|
|
|
3188
3203
|
}
|
|
3189
3204
|
function sr(t) {
|
|
3190
3205
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3191
|
-
return
|
|
3206
|
+
return J(t.summary);
|
|
3192
3207
|
if (typeof t.arguments == "string")
|
|
3193
3208
|
try {
|
|
3194
3209
|
const e = JSON.parse(t.arguments);
|
|
3195
3210
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
3196
|
-
return
|
|
3211
|
+
return J(e.summary);
|
|
3197
3212
|
} catch {
|
|
3198
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3213
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? J(t.name) : "🛠️ Run tool";
|
|
3199
3214
|
}
|
|
3200
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3215
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? J(t.name) : "🛠️ Run tool";
|
|
3201
3216
|
}
|
|
3202
|
-
function
|
|
3217
|
+
function J(t) {
|
|
3203
3218
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3204
3219
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3205
3220
|
}
|
|
@@ -3218,7 +3233,7 @@ function nr(t) {
|
|
|
3218
3233
|
runId: typeof e.runId == "string" ? e.runId : null
|
|
3219
3234
|
};
|
|
3220
3235
|
}
|
|
3221
|
-
function
|
|
3236
|
+
function pe(t) {
|
|
3222
3237
|
const e = t.callId ?? t.call_id;
|
|
3223
3238
|
return typeof e == "string" && e ? e : null;
|
|
3224
3239
|
}
|
|
@@ -3233,8 +3248,8 @@ function rr(t) {
|
|
|
3233
3248
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
3234
3249
|
}).filter(Boolean).join("") : "";
|
|
3235
3250
|
}
|
|
3236
|
-
function
|
|
3237
|
-
const s = Jt(t, e), n =
|
|
3251
|
+
function Fe(t, e) {
|
|
3252
|
+
const s = Jt(t, e), n = cr(
|
|
3238
3253
|
ir(
|
|
3239
3254
|
fr(t, e),
|
|
3240
3255
|
s
|
|
@@ -3254,7 +3269,7 @@ function ir(t, e) {
|
|
|
3254
3269
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
3255
3270
|
) : t;
|
|
3256
3271
|
}
|
|
3257
|
-
function
|
|
3272
|
+
function Be(t, e, s) {
|
|
3258
3273
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3259
3274
|
}
|
|
3260
3275
|
function or(t, e, s, n) {
|
|
@@ -3279,7 +3294,7 @@ function ar(t, e) {
|
|
|
3279
3294
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3280
3295
|
);
|
|
3281
3296
|
if (s === -1)
|
|
3282
|
-
return
|
|
3297
|
+
return Fe(t, e);
|
|
3283
3298
|
const n = [...t];
|
|
3284
3299
|
return n[s] = {
|
|
3285
3300
|
...n[s],
|
|
@@ -3296,14 +3311,14 @@ function lr(t, e, s) {
|
|
|
3296
3311
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
3297
3312
|
return n ? r : t;
|
|
3298
3313
|
}
|
|
3299
|
-
function
|
|
3314
|
+
function ur(t) {
|
|
3300
3315
|
if (t.hiddenFromTranscript === !0)
|
|
3301
3316
|
return null;
|
|
3302
3317
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
3303
3318
|
return !e || !s ? null : {
|
|
3304
3319
|
id: `transient-activity:${e}`,
|
|
3305
3320
|
role: "tool",
|
|
3306
|
-
content:
|
|
3321
|
+
content: J(
|
|
3307
3322
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3308
3323
|
),
|
|
3309
3324
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3316,7 +3331,7 @@ function cr(t) {
|
|
|
3316
3331
|
loading: !0
|
|
3317
3332
|
};
|
|
3318
3333
|
}
|
|
3319
|
-
function
|
|
3334
|
+
function cr(t, e) {
|
|
3320
3335
|
if (e.id.startsWith("transient-activity:"))
|
|
3321
3336
|
return t;
|
|
3322
3337
|
const s = e.toolName === "tab_lifecycle";
|
|
@@ -3342,7 +3357,7 @@ function hr(t, e, s) {
|
|
|
3342
3357
|
];
|
|
3343
3358
|
}
|
|
3344
3359
|
function Vt(t) {
|
|
3345
|
-
const e =
|
|
3360
|
+
const e = Q(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3346
3361
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3347
3362
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3348
3363
|
];
|
|
@@ -3353,7 +3368,7 @@ function Vt(t) {
|
|
|
3353
3368
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3354
3369
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3355
3370
|
...t.runId ? { runId: t.runId } : {},
|
|
3356
|
-
isOptimistic:
|
|
3371
|
+
isOptimistic: Re(t),
|
|
3357
3372
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3358
3373
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3359
3374
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
@@ -3363,7 +3378,7 @@ function Jt(t, e) {
|
|
|
3363
3378
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3364
3379
|
return e;
|
|
3365
3380
|
const s = t.find(
|
|
3366
|
-
(r) => r.role === "user" && (r.id === e.id ||
|
|
3381
|
+
(r) => r.role === "user" && (r.id === e.id || Re(r) && Yt(r, e))
|
|
3367
3382
|
);
|
|
3368
3383
|
if (!s?.attachments?.length)
|
|
3369
3384
|
return e;
|
|
@@ -3384,7 +3399,7 @@ function fr(t, e) {
|
|
|
3384
3399
|
if (e.role !== "user")
|
|
3385
3400
|
return t;
|
|
3386
3401
|
const s = t.findIndex(
|
|
3387
|
-
(r) =>
|
|
3402
|
+
(r) => Re(r) && Yt(r, e)
|
|
3388
3403
|
);
|
|
3389
3404
|
if (s === -1)
|
|
3390
3405
|
return t;
|
|
@@ -3392,13 +3407,13 @@ function fr(t, e) {
|
|
|
3392
3407
|
return n.splice(s, 1), n;
|
|
3393
3408
|
}
|
|
3394
3409
|
function Yt(t, e) {
|
|
3395
|
-
const s =
|
|
3410
|
+
const s = Q(t), n = Q(e);
|
|
3396
3411
|
return s && n ? s === n : t.content === e.content;
|
|
3397
3412
|
}
|
|
3398
|
-
function
|
|
3413
|
+
function Re(t) {
|
|
3399
3414
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3400
3415
|
}
|
|
3401
|
-
function
|
|
3416
|
+
function Q(t) {
|
|
3402
3417
|
const e = t.clientMessageId;
|
|
3403
3418
|
if (e)
|
|
3404
3419
|
return e;
|
|
@@ -3413,13 +3428,13 @@ function _t(t) {
|
|
|
3413
3428
|
return !1;
|
|
3414
3429
|
const s = t[e].id;
|
|
3415
3430
|
if (t.some(
|
|
3416
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3431
|
+
(r) => r.respondsToUserMessageId === s && Te(r)
|
|
3417
3432
|
))
|
|
3418
3433
|
return !0;
|
|
3419
3434
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3420
3435
|
const i = t[r];
|
|
3421
3436
|
if (!i.respondsToUserMessageId) {
|
|
3422
|
-
if (
|
|
3437
|
+
if (B(i))
|
|
3423
3438
|
return !0;
|
|
3424
3439
|
if (i.role === "system") {
|
|
3425
3440
|
if (i.dataType === "run_error")
|
|
@@ -3434,7 +3449,7 @@ function _t(t) {
|
|
|
3434
3449
|
function mr(t, e, s) {
|
|
3435
3450
|
const n = new Set(
|
|
3436
3451
|
t.filter(
|
|
3437
|
-
(r) => r.role === "user" && e !== null &&
|
|
3452
|
+
(r) => r.role === "user" && e !== null && Q(r) === e
|
|
3438
3453
|
).map((r) => r.id)
|
|
3439
3454
|
);
|
|
3440
3455
|
return t.some((r, i) => {
|
|
@@ -3454,22 +3469,22 @@ function mr(t, e, s) {
|
|
|
3454
3469
|
function yr(t) {
|
|
3455
3470
|
const e = Qt(t);
|
|
3456
3471
|
if (e === null)
|
|
3457
|
-
return t.some(
|
|
3472
|
+
return t.some(B);
|
|
3458
3473
|
const s = t[e].id;
|
|
3459
3474
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3460
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3461
|
-
) : t.slice(e + 1).some(
|
|
3475
|
+
(n) => n.respondsToUserMessageId === s && B(n)
|
|
3476
|
+
) : t.slice(e + 1).some(B);
|
|
3462
3477
|
}
|
|
3463
3478
|
function Qt(t) {
|
|
3464
3479
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3465
|
-
if (t[e].role === "user" && !
|
|
3480
|
+
if (t[e].role === "user" && !Re(t[e]))
|
|
3466
3481
|
return e;
|
|
3467
3482
|
return null;
|
|
3468
3483
|
}
|
|
3469
|
-
function
|
|
3470
|
-
return
|
|
3484
|
+
function Te(t) {
|
|
3485
|
+
return B(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3471
3486
|
}
|
|
3472
|
-
function
|
|
3487
|
+
function Z(t) {
|
|
3473
3488
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
3474
3489
|
const s = t[e];
|
|
3475
3490
|
if (!s || typeof s != "object")
|
|
@@ -3484,29 +3499,29 @@ function Q(t) {
|
|
|
3484
3499
|
return null;
|
|
3485
3500
|
}
|
|
3486
3501
|
function Ir(t) {
|
|
3487
|
-
const e =
|
|
3502
|
+
const e = Z(t);
|
|
3488
3503
|
if (e === null)
|
|
3489
3504
|
return null;
|
|
3490
|
-
const n =
|
|
3505
|
+
const n = P(t[e])?.page;
|
|
3491
3506
|
if (!n || typeof n != "object")
|
|
3492
3507
|
return null;
|
|
3493
3508
|
const r = n.url;
|
|
3494
3509
|
return typeof r == "string" ? r : null;
|
|
3495
3510
|
}
|
|
3496
|
-
function
|
|
3511
|
+
function P(t) {
|
|
3497
3512
|
if (!t || typeof t != "object")
|
|
3498
3513
|
return null;
|
|
3499
3514
|
const e = t.data;
|
|
3500
3515
|
return e && typeof e == "object" ? e : null;
|
|
3501
3516
|
}
|
|
3502
|
-
function
|
|
3517
|
+
function Se(t) {
|
|
3503
3518
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3504
3519
|
}
|
|
3505
3520
|
function bt(t) {
|
|
3506
3521
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3507
3522
|
}
|
|
3508
3523
|
function Tr(t, e) {
|
|
3509
|
-
const s =
|
|
3524
|
+
const s = Z(e);
|
|
3510
3525
|
if (s === null)
|
|
3511
3526
|
return !1;
|
|
3512
3527
|
const n = e[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -3514,11 +3529,11 @@ function Tr(t, e) {
|
|
|
3514
3529
|
return !1;
|
|
3515
3530
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3516
3531
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3517
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3518
|
-
) : t.slice(i + 1).some(
|
|
3532
|
+
(o) => o.respondsToUserMessageId === r && Te(o)
|
|
3533
|
+
) : t.slice(i + 1).some(Te);
|
|
3519
3534
|
}
|
|
3520
3535
|
function ze(t) {
|
|
3521
|
-
const e =
|
|
3536
|
+
const e = Z(t);
|
|
3522
3537
|
if (e === null)
|
|
3523
3538
|
return null;
|
|
3524
3539
|
const s = t[e];
|
|
@@ -3531,7 +3546,7 @@ function ze(t) {
|
|
|
3531
3546
|
return typeof r == "string" ? r : null;
|
|
3532
3547
|
}
|
|
3533
3548
|
function Sr(t) {
|
|
3534
|
-
const e =
|
|
3549
|
+
const e = Z(t);
|
|
3535
3550
|
if (e === null)
|
|
3536
3551
|
return null;
|
|
3537
3552
|
for (let s = t.length - 1; s > e; s -= 1) {
|
|
@@ -3554,10 +3569,10 @@ function Sr(t) {
|
|
|
3554
3569
|
function Ke(t, e) {
|
|
3555
3570
|
if (typeof e.clientMessageId == "string")
|
|
3556
3571
|
return e.clientMessageId;
|
|
3557
|
-
const s =
|
|
3572
|
+
const s = N(e);
|
|
3558
3573
|
if (!s)
|
|
3559
3574
|
return null;
|
|
3560
|
-
const n = t.find((i) =>
|
|
3575
|
+
const n = t.find((i) => S(i, "id") === s), r = P(n);
|
|
3561
3576
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3562
3577
|
}
|
|
3563
3578
|
function wr(t, e) {
|
|
@@ -3577,16 +3592,16 @@ function Pt(t, e, s, n, r, i) {
|
|
|
3577
3592
|
if (!e || !Ar(t))
|
|
3578
3593
|
return !1;
|
|
3579
3594
|
const o = t;
|
|
3580
|
-
if (
|
|
3595
|
+
if (Se(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3581
3596
|
return !1;
|
|
3582
|
-
const a =
|
|
3597
|
+
const a = N(o);
|
|
3583
3598
|
return n !== null ? a !== null ? a === n : r !== null && _(o) === r && i === n : r === null || _(o) === r;
|
|
3584
3599
|
}
|
|
3585
3600
|
function Mr(t, e) {
|
|
3586
3601
|
for (let s = e - 1; s >= 0; s -= 1) {
|
|
3587
|
-
const n =
|
|
3602
|
+
const n = P(t[s]);
|
|
3588
3603
|
if (n?.type === "message" && n.role === "user")
|
|
3589
|
-
return
|
|
3604
|
+
return S(t[s], "id");
|
|
3590
3605
|
}
|
|
3591
3606
|
return null;
|
|
3592
3607
|
}
|
|
@@ -3602,7 +3617,7 @@ function Ar(t) {
|
|
|
3602
3617
|
const e = t;
|
|
3603
3618
|
return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
|
|
3604
3619
|
}
|
|
3605
|
-
function
|
|
3620
|
+
function B(t) {
|
|
3606
3621
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3607
3622
|
}
|
|
3608
3623
|
function Rr(t) {
|
|
@@ -3612,51 +3627,54 @@ function Rr(t) {
|
|
|
3612
3627
|
return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
|
|
3613
3628
|
}
|
|
3614
3629
|
function Ge(t) {
|
|
3615
|
-
return t.filter((e, s) =>
|
|
3630
|
+
return t.filter((e, s) => F(e) ? !qr(t, s) && !es(t, s) && !vr(t, s) && !Or(t, s) : Er(e) ? e.retryable === !0 && Dr(t, s) ? !1 : !Ur(t, s) : !0);
|
|
3616
3631
|
}
|
|
3617
3632
|
function Er(t) {
|
|
3618
3633
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3619
3634
|
}
|
|
3620
|
-
function
|
|
3635
|
+
function F(t) {
|
|
3621
3636
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3622
3637
|
}
|
|
3623
|
-
function
|
|
3638
|
+
function kr(t, e, s, n) {
|
|
3624
3639
|
const r = t.findIndex(
|
|
3625
|
-
(l,
|
|
3640
|
+
(l, u) => F(l) && !es(t, u)
|
|
3626
3641
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3627
3642
|
(l) => l.role === "user" && l.id === o
|
|
3628
3643
|
) : null;
|
|
3629
3644
|
return {
|
|
3630
|
-
clientMessageId: a ?
|
|
3645
|
+
clientMessageId: a ? Q(a) : o ? null : n,
|
|
3631
3646
|
respondsToUserMessageId: o,
|
|
3632
3647
|
runId: s ?? i?.runId ?? null
|
|
3633
3648
|
};
|
|
3634
3649
|
}
|
|
3635
|
-
function
|
|
3650
|
+
function ye(t) {
|
|
3636
3651
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3637
3652
|
}
|
|
3653
|
+
function Cr(t, e) {
|
|
3654
|
+
return B(e) ? "completed" : ye(t) ? "stopped" : !Se(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
|
|
3655
|
+
}
|
|
3638
3656
|
function Ut(t, e, s) {
|
|
3639
3657
|
const n = new Set(
|
|
3640
3658
|
t.filter(
|
|
3641
|
-
(r) => r.role === "user" && e !== null &&
|
|
3659
|
+
(r) => r.role === "user" && e !== null && Q(r) === e
|
|
3642
3660
|
).map((r) => r.id)
|
|
3643
3661
|
);
|
|
3644
3662
|
return t.filter(
|
|
3645
|
-
(r) => !
|
|
3663
|
+
(r) => !F(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3646
3664
|
);
|
|
3647
3665
|
}
|
|
3648
3666
|
function es(t, e) {
|
|
3649
3667
|
return t.some(
|
|
3650
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
3668
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && _r(
|
|
3651
3669
|
t,
|
|
3652
3670
|
e,
|
|
3653
3671
|
n
|
|
3654
3672
|
)
|
|
3655
3673
|
);
|
|
3656
3674
|
}
|
|
3657
|
-
function
|
|
3675
|
+
function _r(t, e, s) {
|
|
3658
3676
|
const n = t[e], r = t[s];
|
|
3659
|
-
if (
|
|
3677
|
+
if (ae(n, r))
|
|
3660
3678
|
return !0;
|
|
3661
3679
|
if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
|
|
3662
3680
|
return !1;
|
|
@@ -3665,9 +3683,9 @@ function kr(t, e, s) {
|
|
|
3665
3683
|
return t[i].id === n.respondsToUserMessageId;
|
|
3666
3684
|
return !1;
|
|
3667
3685
|
}
|
|
3668
|
-
function
|
|
3686
|
+
function br(t, e) {
|
|
3669
3687
|
const s = [...t].reverse().find(
|
|
3670
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Dt(n) && !
|
|
3688
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Dt(n) && !Pr(
|
|
3671
3689
|
t,
|
|
3672
3690
|
n.respondsToUserMessageId
|
|
3673
3691
|
)
|
|
@@ -3677,23 +3695,23 @@ function _r(t, e) {
|
|
|
3677
3695
|
) : t;
|
|
3678
3696
|
}
|
|
3679
3697
|
function Dt(t) {
|
|
3680
|
-
return t.role === "tool" ||
|
|
3698
|
+
return t.role === "tool" || F(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3681
3699
|
}
|
|
3682
|
-
function
|
|
3700
|
+
function Pr(t, e) {
|
|
3683
3701
|
return t.some(
|
|
3684
|
-
(s) => s.respondsToUserMessageId === e && (
|
|
3702
|
+
(s) => s.respondsToUserMessageId === e && (B(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
3685
3703
|
);
|
|
3686
3704
|
}
|
|
3687
|
-
function
|
|
3705
|
+
function Ur(t, e) {
|
|
3688
3706
|
const s = t[e];
|
|
3689
3707
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
3690
3708
|
const r = t[n];
|
|
3691
|
-
if (r.role === "assistant" &&
|
|
3709
|
+
if (r.role === "assistant" && ae(s, r))
|
|
3692
3710
|
return !0;
|
|
3693
3711
|
}
|
|
3694
3712
|
return !1;
|
|
3695
3713
|
}
|
|
3696
|
-
function
|
|
3714
|
+
function Dr(t, e) {
|
|
3697
3715
|
const s = t[e];
|
|
3698
3716
|
if (!s.respondsToUserMessageId)
|
|
3699
3717
|
return !1;
|
|
@@ -3701,37 +3719,37 @@ function Ur(t, e) {
|
|
|
3701
3719
|
const r = t[n];
|
|
3702
3720
|
if (r.role === "user")
|
|
3703
3721
|
return !1;
|
|
3704
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3722
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || F(r)))
|
|
3705
3723
|
return !0;
|
|
3706
3724
|
}
|
|
3707
3725
|
return !1;
|
|
3708
3726
|
}
|
|
3709
|
-
function
|
|
3727
|
+
function vr(t, e) {
|
|
3710
3728
|
const s = t[e];
|
|
3711
3729
|
return t.some(
|
|
3712
|
-
(n, r) => r !== e && n.role === "assistant" &&
|
|
3730
|
+
(n, r) => r !== e && n.role === "assistant" && ae(s, n)
|
|
3713
3731
|
);
|
|
3714
3732
|
}
|
|
3715
|
-
function
|
|
3733
|
+
function Or(t, e) {
|
|
3716
3734
|
const s = t[e];
|
|
3717
3735
|
return t.some(
|
|
3718
|
-
(n, r) => r !== e && n.role === "tool" &&
|
|
3736
|
+
(n, r) => r !== e && n.role === "tool" && ae(s, n)
|
|
3719
3737
|
);
|
|
3720
3738
|
}
|
|
3721
|
-
function
|
|
3739
|
+
function qr(t, e) {
|
|
3722
3740
|
const s = t[e];
|
|
3723
3741
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3724
|
-
if (
|
|
3742
|
+
if (F(t[n]) && ae(s, t[n]))
|
|
3725
3743
|
return !0;
|
|
3726
3744
|
return !1;
|
|
3727
3745
|
}
|
|
3728
|
-
function
|
|
3746
|
+
function ae(t, e) {
|
|
3729
3747
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
3730
3748
|
}
|
|
3731
|
-
function
|
|
3749
|
+
function S(t, e) {
|
|
3732
3750
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
3733
3751
|
}
|
|
3734
|
-
function
|
|
3752
|
+
function Lr(t, e) {
|
|
3735
3753
|
try {
|
|
3736
3754
|
const s = window.localStorage.getItem(`${$t}${t}`);
|
|
3737
3755
|
if (!s)
|
|
@@ -3739,7 +3757,7 @@ function qr(t, e) {
|
|
|
3739
3757
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
3740
3758
|
if (e !== void 0 && r !== e)
|
|
3741
3759
|
return null;
|
|
3742
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
3760
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Gr).filter((o) => !!o) : [];
|
|
3743
3761
|
return {
|
|
3744
3762
|
sessionId: r,
|
|
3745
3763
|
messages: i
|
|
@@ -3748,22 +3766,22 @@ function qr(t, e) {
|
|
|
3748
3766
|
return null;
|
|
3749
3767
|
}
|
|
3750
3768
|
}
|
|
3751
|
-
function
|
|
3769
|
+
function Nr(t, e) {
|
|
3752
3770
|
try {
|
|
3753
3771
|
window.localStorage.setItem(
|
|
3754
3772
|
`${$t}${t}`,
|
|
3755
3773
|
JSON.stringify({
|
|
3756
3774
|
sessionId: e.sessionId,
|
|
3757
|
-
messages: e.messages.slice(-on).map(
|
|
3775
|
+
messages: e.messages.slice(-on).map(Xr)
|
|
3758
3776
|
})
|
|
3759
3777
|
);
|
|
3760
3778
|
} catch {
|
|
3761
3779
|
return;
|
|
3762
3780
|
}
|
|
3763
3781
|
}
|
|
3764
|
-
function
|
|
3782
|
+
function xr(t) {
|
|
3765
3783
|
try {
|
|
3766
|
-
const e = window.localStorage.getItem(`${
|
|
3784
|
+
const e = window.localStorage.getItem(`${je}${t}`);
|
|
3767
3785
|
if (!e)
|
|
3768
3786
|
return [];
|
|
3769
3787
|
const s = JSON.parse(e);
|
|
@@ -3772,15 +3790,15 @@ function Nr(t) {
|
|
|
3772
3790
|
return [];
|
|
3773
3791
|
}
|
|
3774
3792
|
}
|
|
3775
|
-
function
|
|
3793
|
+
function G(t, e) {
|
|
3776
3794
|
try {
|
|
3777
3795
|
const s = e.filter(tt);
|
|
3778
3796
|
if (s.length === 0) {
|
|
3779
|
-
window.localStorage.removeItem(`${
|
|
3797
|
+
window.localStorage.removeItem(`${je}${t}`);
|
|
3780
3798
|
return;
|
|
3781
3799
|
}
|
|
3782
3800
|
window.localStorage.setItem(
|
|
3783
|
-
`${
|
|
3801
|
+
`${je}${t}`,
|
|
3784
3802
|
JSON.stringify(s.slice(-25))
|
|
3785
3803
|
);
|
|
3786
3804
|
} catch {
|
|
@@ -3789,7 +3807,7 @@ function z(t, e) {
|
|
|
3789
3807
|
}
|
|
3790
3808
|
function ts(t, e) {
|
|
3791
3809
|
try {
|
|
3792
|
-
const s = `${
|
|
3810
|
+
const s = `${Ae}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
3793
3811
|
...o,
|
|
3794
3812
|
storedAt: Date.now(),
|
|
3795
3813
|
unloadUrl: n,
|
|
@@ -3805,26 +3823,26 @@ function ts(t, e) {
|
|
|
3805
3823
|
}
|
|
3806
3824
|
function vt(t, e) {
|
|
3807
3825
|
try {
|
|
3808
|
-
if (window.sessionStorage.getItem(`${
|
|
3826
|
+
if (window.sessionStorage.getItem(`${Ae}${t}`) === null)
|
|
3809
3827
|
return;
|
|
3810
3828
|
} catch {
|
|
3811
3829
|
return;
|
|
3812
3830
|
}
|
|
3813
3831
|
ts(t, e);
|
|
3814
3832
|
}
|
|
3815
|
-
function
|
|
3833
|
+
function Br(t) {
|
|
3816
3834
|
try {
|
|
3817
|
-
const e = `${
|
|
3835
|
+
const e = `${Ae}${t}`, s = window.sessionStorage.getItem(e);
|
|
3818
3836
|
if (window.sessionStorage.removeItem(e), !s)
|
|
3819
3837
|
return [];
|
|
3820
3838
|
const n = JSON.parse(s);
|
|
3821
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
3839
|
+
return Array.isArray(n) ? n.flatMap((r) => Hr(r) ? [{
|
|
3822
3840
|
...r.event,
|
|
3823
|
-
page:
|
|
3841
|
+
page: b(),
|
|
3824
3842
|
rawOutput: {
|
|
3825
3843
|
pageContextRestarted: !0,
|
|
3826
3844
|
outcome: "unknown",
|
|
3827
|
-
message:
|
|
3845
|
+
message: Wr(location.href),
|
|
3828
3846
|
currentUrl: location.href,
|
|
3829
3847
|
console: [],
|
|
3830
3848
|
metadata: {
|
|
@@ -3841,17 +3859,17 @@ function xr(t) {
|
|
|
3841
3859
|
return [];
|
|
3842
3860
|
}
|
|
3843
3861
|
}
|
|
3844
|
-
function
|
|
3862
|
+
function Wr(t) {
|
|
3845
3863
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
3846
3864
|
Current URL: ${t}`;
|
|
3847
3865
|
}
|
|
3848
|
-
function
|
|
3866
|
+
function Hr(t) {
|
|
3849
3867
|
if (!t || typeof t != "object")
|
|
3850
3868
|
return !1;
|
|
3851
3869
|
const e = t, s = e.event;
|
|
3852
3870
|
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && tt(s) && s.type === "tool.result";
|
|
3853
3871
|
}
|
|
3854
|
-
function
|
|
3872
|
+
function $r(t, e) {
|
|
3855
3873
|
const s = new Set(
|
|
3856
3874
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
3857
3875
|
);
|
|
@@ -3860,9 +3878,9 @@ function Hr(t, e) {
|
|
|
3860
3878
|
...e.filter((n) => !s.has(n.callId))
|
|
3861
3879
|
];
|
|
3862
3880
|
}
|
|
3863
|
-
function
|
|
3881
|
+
function jr(t) {
|
|
3864
3882
|
try {
|
|
3865
|
-
window.sessionStorage.removeItem(`${
|
|
3883
|
+
window.sessionStorage.removeItem(`${Ae}${t}`);
|
|
3866
3884
|
} catch {
|
|
3867
3885
|
return;
|
|
3868
3886
|
}
|
|
@@ -3897,9 +3915,9 @@ function ns(t, e) {
|
|
|
3897
3915
|
} : t;
|
|
3898
3916
|
}
|
|
3899
3917
|
function Xe(t) {
|
|
3900
|
-
return t.type ||
|
|
3918
|
+
return t.type || Kr(t.name) || "application/octet-stream";
|
|
3901
3919
|
}
|
|
3902
|
-
function
|
|
3920
|
+
function Fr(t) {
|
|
3903
3921
|
rs({
|
|
3904
3922
|
name: t.name,
|
|
3905
3923
|
mimeType: Xe(t),
|
|
@@ -3907,21 +3925,21 @@ function jr(t) {
|
|
|
3907
3925
|
});
|
|
3908
3926
|
}
|
|
3909
3927
|
function rs(t) {
|
|
3910
|
-
const e =
|
|
3928
|
+
const e = zr(t.name), s = t.mimeType.trim().toLowerCase();
|
|
3911
3929
|
if (!sn.has(`${e}:${s}`))
|
|
3912
3930
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
3913
3931
|
if (t.sizeBytes <= 0 || t.sizeBytes >= Wt)
|
|
3914
3932
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
3915
3933
|
}
|
|
3916
|
-
function
|
|
3934
|
+
function zr(t) {
|
|
3917
3935
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
3918
3936
|
return s >= 0 ? e.slice(s) : "";
|
|
3919
3937
|
}
|
|
3920
|
-
function
|
|
3938
|
+
function Kr(t) {
|
|
3921
3939
|
const e = t.toLowerCase();
|
|
3922
3940
|
return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
|
|
3923
3941
|
}
|
|
3924
|
-
function
|
|
3942
|
+
function Gr(t) {
|
|
3925
3943
|
if (!t || typeof t != "object")
|
|
3926
3944
|
return null;
|
|
3927
3945
|
const e = t;
|
|
@@ -3942,7 +3960,7 @@ function Kr(t) {
|
|
|
3942
3960
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
3943
3961
|
};
|
|
3944
3962
|
}
|
|
3945
|
-
function
|
|
3963
|
+
function Xr(t) {
|
|
3946
3964
|
return t.attachments?.length ? {
|
|
3947
3965
|
...t,
|
|
3948
3966
|
attachments: t.attachments.map(st)
|
|
@@ -3957,7 +3975,7 @@ function st(t) {
|
|
|
3957
3975
|
} = t;
|
|
3958
3976
|
return r;
|
|
3959
3977
|
}
|
|
3960
|
-
function
|
|
3978
|
+
function N(t) {
|
|
3961
3979
|
const e = t.respondsToUserMessageId;
|
|
3962
3980
|
return typeof e == "string" && e ? e : null;
|
|
3963
3981
|
}
|
|
@@ -3965,7 +3983,7 @@ function _(t) {
|
|
|
3965
3983
|
const e = t.runId;
|
|
3966
3984
|
return typeof e == "string" && e ? e : null;
|
|
3967
3985
|
}
|
|
3968
|
-
function
|
|
3986
|
+
function Vr(t) {
|
|
3969
3987
|
const e = t?.timeoutMs;
|
|
3970
3988
|
return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= fn);
|
|
3971
3989
|
}
|
|
@@ -3981,22 +3999,22 @@ function is(t) {
|
|
|
3981
3999
|
return e;
|
|
3982
4000
|
}
|
|
3983
4001
|
function nt(t, e) {
|
|
3984
|
-
return ds(t) ?
|
|
4002
|
+
return ds(t) ? Ee : x(Me(e), nn);
|
|
3985
4003
|
}
|
|
3986
|
-
function
|
|
4004
|
+
function Jr(t, e) {
|
|
3987
4005
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
3988
4006
|
}
|
|
3989
|
-
async function
|
|
4007
|
+
async function Yr(t, e, s, n) {
|
|
3990
4008
|
const r = is(t.headers);
|
|
3991
4009
|
n({
|
|
3992
4010
|
...e,
|
|
3993
4011
|
responseStatus: t.status,
|
|
3994
4012
|
responseHeaders: r,
|
|
3995
|
-
responseBody: await
|
|
4013
|
+
responseBody: await Qr(t),
|
|
3996
4014
|
durationMs: Date.now() - s
|
|
3997
4015
|
});
|
|
3998
4016
|
}
|
|
3999
|
-
async function
|
|
4017
|
+
async function Qr(t) {
|
|
4000
4018
|
if (!os(t.headers))
|
|
4001
4019
|
return;
|
|
4002
4020
|
let e = null, s = null;
|
|
@@ -4013,13 +4031,13 @@ async function Yr(t) {
|
|
|
4013
4031
|
const a = await Promise.race([e.read(), n]);
|
|
4014
4032
|
if (a === "timeout")
|
|
4015
4033
|
return;
|
|
4016
|
-
const { done: l, value:
|
|
4034
|
+
const { done: l, value: u } = a;
|
|
4017
4035
|
if (l)
|
|
4018
|
-
return
|
|
4036
|
+
return x(i + r.decode());
|
|
4019
4037
|
const h = Qe - o;
|
|
4020
|
-
if (
|
|
4021
|
-
return i += r.decode(
|
|
4022
|
-
o +=
|
|
4038
|
+
if (u.byteLength > h)
|
|
4039
|
+
return i += r.decode(u.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${x(i)}... [truncated]`;
|
|
4040
|
+
o += u.byteLength, i += r.decode(u, { stream: !0 });
|
|
4023
4041
|
}
|
|
4024
4042
|
} catch {
|
|
4025
4043
|
e?.cancel();
|
|
@@ -4028,20 +4046,20 @@ async function Yr(t) {
|
|
|
4028
4046
|
s !== null && window.clearTimeout(s);
|
|
4029
4047
|
}
|
|
4030
4048
|
}
|
|
4031
|
-
function
|
|
4049
|
+
function Zr(t, e) {
|
|
4032
4050
|
if (os(new Headers(e)))
|
|
4033
4051
|
try {
|
|
4034
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
4052
|
+
return t.responseType === "" || t.responseType === "text" ? x(t.responseText ?? "") : void 0;
|
|
4035
4053
|
} catch {
|
|
4036
4054
|
return;
|
|
4037
4055
|
}
|
|
4038
4056
|
}
|
|
4039
4057
|
function qt(t) {
|
|
4040
4058
|
if (typeof t == "string")
|
|
4041
|
-
return
|
|
4059
|
+
return x(t);
|
|
4042
4060
|
}
|
|
4043
|
-
function
|
|
4044
|
-
return
|
|
4061
|
+
function ei(t) {
|
|
4062
|
+
return q({
|
|
4045
4063
|
...t,
|
|
4046
4064
|
requestBody: Lt(t.requestBody),
|
|
4047
4065
|
responseBody: Lt(t.responseBody)
|
|
@@ -4052,11 +4070,11 @@ function Lt(t) {
|
|
|
4052
4070
|
return t;
|
|
4053
4071
|
const e = t.trim();
|
|
4054
4072
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4055
|
-
return
|
|
4073
|
+
return Me(t);
|
|
4056
4074
|
try {
|
|
4057
|
-
return JSON.stringify(
|
|
4075
|
+
return JSON.stringify(q(JSON.parse(t)));
|
|
4058
4076
|
} catch {
|
|
4059
|
-
return
|
|
4077
|
+
return Me(t);
|
|
4060
4078
|
}
|
|
4061
4079
|
}
|
|
4062
4080
|
function os(t) {
|
|
@@ -4065,8 +4083,8 @@ function os(t) {
|
|
|
4065
4083
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4066
4084
|
return s !== null && Number.isInteger(n) && n >= 0 && n <= Qe && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4067
4085
|
}
|
|
4068
|
-
function
|
|
4069
|
-
if (
|
|
4086
|
+
function V(t, e = {}, s) {
|
|
4087
|
+
if (si(s))
|
|
4070
4088
|
return !0;
|
|
4071
4089
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
4072
4090
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -4081,8 +4099,8 @@ function X(t, e = {}, s) {
|
|
|
4081
4099
|
return !0;
|
|
4082
4100
|
}
|
|
4083
4101
|
}
|
|
4084
|
-
function
|
|
4085
|
-
if (
|
|
4102
|
+
function ti(t, e) {
|
|
4103
|
+
if (V(t))
|
|
4086
4104
|
return !0;
|
|
4087
4105
|
try {
|
|
4088
4106
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -4091,10 +4109,10 @@ function ei(t, e) {
|
|
|
4091
4109
|
return !0;
|
|
4092
4110
|
}
|
|
4093
4111
|
}
|
|
4094
|
-
function
|
|
4112
|
+
function si(t) {
|
|
4095
4113
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4096
4114
|
}
|
|
4097
|
-
function
|
|
4115
|
+
function ni(t) {
|
|
4098
4116
|
const e = {};
|
|
4099
4117
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4100
4118
|
const n = s.indexOf(":");
|
|
@@ -4107,101 +4125,101 @@ function si(t) {
|
|
|
4107
4125
|
}
|
|
4108
4126
|
return e;
|
|
4109
4127
|
}
|
|
4110
|
-
function
|
|
4128
|
+
function x(t, e = Qe) {
|
|
4111
4129
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4112
4130
|
}
|
|
4113
|
-
function
|
|
4131
|
+
function We(t) {
|
|
4114
4132
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4115
4133
|
}
|
|
4116
|
-
class
|
|
4134
|
+
class Ie extends Error {
|
|
4117
4135
|
constructor(e, s) {
|
|
4118
4136
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4119
4137
|
}
|
|
4120
4138
|
status;
|
|
4121
4139
|
}
|
|
4122
|
-
async function
|
|
4140
|
+
async function ge(t, e) {
|
|
4123
4141
|
let s = null;
|
|
4124
4142
|
for (let n = 0; n < Mt; n += 1)
|
|
4125
4143
|
try {
|
|
4126
4144
|
return await t();
|
|
4127
4145
|
} catch (r) {
|
|
4128
|
-
if (s = r, n >= Mt - 1 || !
|
|
4146
|
+
if (s = r, n >= Mt - 1 || !ii(r))
|
|
4129
4147
|
throw r;
|
|
4130
|
-
await
|
|
4148
|
+
await ri(n);
|
|
4131
4149
|
}
|
|
4132
4150
|
throw s instanceof Error ? s : new Error(e);
|
|
4133
4151
|
}
|
|
4134
|
-
function
|
|
4152
|
+
function ri(t) {
|
|
4135
4153
|
return new Promise((e) => {
|
|
4136
4154
|
window.setTimeout(e, tn[t] ?? 0);
|
|
4137
4155
|
});
|
|
4138
4156
|
}
|
|
4139
|
-
function ri(t) {
|
|
4140
|
-
return t instanceof me ? ii(t.status) : t instanceof TypeError;
|
|
4141
|
-
}
|
|
4142
4157
|
function ii(t) {
|
|
4143
|
-
return t
|
|
4158
|
+
return t instanceof Ie ? oi(t.status) : t instanceof TypeError;
|
|
4144
4159
|
}
|
|
4145
4160
|
function oi(t) {
|
|
4161
|
+
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
4162
|
+
}
|
|
4163
|
+
function ai(t) {
|
|
4146
4164
|
return t === 401 || t === 403;
|
|
4147
4165
|
}
|
|
4148
|
-
const
|
|
4149
|
-
function
|
|
4150
|
-
return
|
|
4166
|
+
const Ee = "[REDACTED_SECRET]", W = "[REDACTED_TOKEN]", li = "[REDACTED_SIGNED_URL]", ui = 20, ci = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, as = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ls = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, us = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, cs = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, di = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, hi = /\bhttps?:\/\/[^\s"'<>]+/gi, pi = /[),.;\]]+$/;
|
|
4167
|
+
function q(t) {
|
|
4168
|
+
return we(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4151
4169
|
}
|
|
4152
|
-
function
|
|
4170
|
+
function we(t, e, s) {
|
|
4153
4171
|
if (typeof t == "string")
|
|
4154
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4172
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Me(t);
|
|
4155
4173
|
if (t === null || typeof t != "object")
|
|
4156
4174
|
return t;
|
|
4157
|
-
if (e >=
|
|
4175
|
+
if (e >= ui)
|
|
4158
4176
|
return "[REDACTED_MAX_DEPTH]";
|
|
4159
4177
|
if (s.has(t))
|
|
4160
4178
|
return "[REDACTED_CIRCULAR]";
|
|
4161
4179
|
if (s.add(t), Array.isArray(t))
|
|
4162
|
-
return t.map((r) =>
|
|
4180
|
+
return t.map((r) => we(r, e + 1, s));
|
|
4163
4181
|
const n = {};
|
|
4164
4182
|
for (const [r, i] of Object.entries(t))
|
|
4165
|
-
r === "pageContent" ? n[r] = i : ds(r) ? n[r] =
|
|
4183
|
+
r === "pageContent" ? n[r] = i : ds(r) ? n[r] = Ee : n[r] = r.toLowerCase() === "url" ? gi(i) : we(i, e + 1, s);
|
|
4166
4184
|
return n;
|
|
4167
4185
|
}
|
|
4168
4186
|
function ds(t) {
|
|
4169
4187
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
4170
4188
|
return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
|
|
4171
4189
|
}
|
|
4172
|
-
function
|
|
4173
|
-
return typeof t == "string" ? hs(t) :
|
|
4190
|
+
function gi(t) {
|
|
4191
|
+
return typeof t == "string" ? hs(t) : we(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4174
4192
|
}
|
|
4175
4193
|
function hs(t) {
|
|
4176
4194
|
try {
|
|
4177
4195
|
const e = new URL(t, location.href);
|
|
4178
4196
|
for (const s of Array.from(e.searchParams.keys()))
|
|
4179
|
-
ci.test(s) && e.searchParams.set(s,
|
|
4180
|
-
return e.username && (e.username =
|
|
4197
|
+
ci.test(s) && e.searchParams.set(s, W);
|
|
4198
|
+
return e.username && (e.username = W), e.password && (e.password = W), e.toString();
|
|
4181
4199
|
} catch {
|
|
4182
|
-
return
|
|
4200
|
+
return fi(t);
|
|
4183
4201
|
}
|
|
4184
4202
|
}
|
|
4185
|
-
function
|
|
4186
|
-
return t.replace(
|
|
4187
|
-
}
|
|
4188
|
-
function gi(t) {
|
|
4189
|
-
return t.replace(as, `Bearer ${N}`).replace(ls, `Basic ${N}`).replace(cs, N).replace(us, (e, s) => `${s}: ${Me}`);
|
|
4203
|
+
function Me(t) {
|
|
4204
|
+
return t.replace(di, li).replace(hi, mi).replace(as, `Bearer ${W}`).replace(ls, `Basic ${W}`).replace(us, W).replace(cs, (e, s) => `${s}: ${Ee}`);
|
|
4190
4205
|
}
|
|
4191
4206
|
function fi(t) {
|
|
4192
|
-
|
|
4207
|
+
return t.replace(as, `Bearer ${W}`).replace(ls, `Basic ${W}`).replace(us, W).replace(cs, (e, s) => `${s}: ${Ee}`);
|
|
4208
|
+
}
|
|
4209
|
+
function mi(t) {
|
|
4210
|
+
const e = t.match(pi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4193
4211
|
return `${hs(s)}${e}`;
|
|
4194
4212
|
}
|
|
4195
4213
|
export {
|
|
4196
4214
|
ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4197
|
-
|
|
4215
|
+
$e as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4198
4216
|
xs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4199
4217
|
Ns as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4200
4218
|
Bs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
4201
|
-
|
|
4219
|
+
yi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
4202
4220
|
jt as PlunoProductAgent,
|
|
4203
4221
|
ln as calculateReconnectDelay,
|
|
4204
4222
|
jt as default,
|
|
4205
4223
|
Un as getProductAgentOriginAccessErrorMessage,
|
|
4206
|
-
|
|
4224
|
+
Fr as validateProductAgentProviderInputFile
|
|
4207
4225
|
};
|