@pluno/product-agent-web 0.1.189 → 0.1.190
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 +5 -0
- package/dist/product-agent-sdk.js +880 -851
- package/dist/product-agent-widget.js +2758 -2723
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const e = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
1
|
+
const Ts = "pluno-product-agent-attachments";
|
|
2
|
+
const Ve = "files";
|
|
3
|
+
async function ws(t) {
|
|
4
|
+
const e = await st();
|
|
5
|
+
await Rs(e, "readwrite", (s) => s.put(t));
|
|
6
|
+
}
|
|
7
|
+
async function Ms(t, e) {
|
|
8
|
+
const s = await st();
|
|
9
|
+
await nt(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await rt(
|
|
11
11
|
n.get(t)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,28 +16,28 @@ async function ws(t, e) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const e = await
|
|
21
|
-
await
|
|
19
|
+
async function As(t = 864e5) {
|
|
20
|
+
const e = await st(), s = Date.now() - t;
|
|
21
|
+
await nt(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await rt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function st() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
|
|
28
|
-
const s = indexedDB.open(
|
|
28
|
+
const s = indexedDB.open(Ts, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(Ve, { keyPath: "attachmentId" });
|
|
31
31
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
32
32
|
}, s.onsuccess = () => t(s.result), s.onerror = () => e(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
36
|
-
return await
|
|
35
|
+
async function Rs(t, e, s) {
|
|
36
|
+
return await nt(t, e, async (n) => await rt(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function nt(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(Ve, e), o = i.objectStore(Ve);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
s(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -57,16 +57,16 @@ function st(t, e, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function rt(t) {
|
|
61
61
|
return new Promise((e, s) => {
|
|
62
62
|
t.onsuccess = () => e(t.result), t.onerror = () => s(t.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function Es(t) {
|
|
66
66
|
return t !== null && (typeof t == "object" || typeof t == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const n = Reflect.get(t, "pluno"), r =
|
|
68
|
+
function Ht(t, e, s) {
|
|
69
|
+
const n = Reflect.get(t, "pluno"), r = Es(n) ? n : {};
|
|
70
70
|
if (r !== n && !Reflect.set(t, "pluno", r))
|
|
71
71
|
return null;
|
|
72
72
|
const i = Object.getOwnPropertyDescriptor(r, e);
|
|
@@ -80,15 +80,15 @@ function Wt(t, e, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const ks = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function Cs(t, e) {
|
|
85
85
|
return e ? t.replace(
|
|
86
|
-
|
|
86
|
+
ks,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
|
|
88
88
|
) : t;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
91
|
-
function
|
|
90
|
+
const bs = "suggest_share_on_socials";
|
|
91
|
+
function _s(t) {
|
|
92
92
|
let e = t;
|
|
93
93
|
if (typeof t == "string")
|
|
94
94
|
try {
|
|
@@ -96,65 +96,65 @@ function bs(t) {
|
|
|
96
96
|
} catch {
|
|
97
97
|
return null;
|
|
98
98
|
}
|
|
99
|
-
const s =
|
|
99
|
+
const s = Ps(e);
|
|
100
100
|
return s ? typeof s.showSharePrompt == "boolean" ? s.showSharePrompt : s.ok === !0 && typeof s.message == "string" && s.message.includes("social-sharing prompt") ? !0 : null : null;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function Ps(t) {
|
|
103
103
|
return t && typeof t == "object" && !Array.isArray(t) ? t : null;
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
function
|
|
107
|
-
return (t.type === "function_call" || t.type === "tool_call") && t.name ===
|
|
105
|
+
const Us = "save_runtime_captured_skill";
|
|
106
|
+
function vs(t) {
|
|
107
|
+
return (t.type === "function_call" || t.type === "tool_call") && t.name === Us;
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function Ds(t, e, s) {
|
|
110
110
|
const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
|
|
111
111
|
n.flatMap(
|
|
112
112
|
({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
|
|
113
113
|
)
|
|
114
114
|
), i = n.filter(
|
|
115
|
-
({ identity: u }) => !(u.isTransient && u.activityKeys?.some((
|
|
116
|
-
), o = new Map(i.map(({ item: u, identity:
|
|
115
|
+
({ identity: u }) => !(u.isTransient && u.activityKeys?.some((p) => r.has(p)))
|
|
116
|
+
), o = new Map(i.map(({ item: u, identity: p }) => [p.id, u])), a = new Map(
|
|
117
117
|
i.flatMap(
|
|
118
|
-
({ item: u, identity:
|
|
118
|
+
({ item: u, identity: p }) => p.optimisticKey ? [[p.optimisticKey, u]] : []
|
|
119
119
|
)
|
|
120
120
|
), l = new Map(
|
|
121
121
|
i.flatMap(
|
|
122
|
-
({ item: u, identity:
|
|
122
|
+
({ item: u, identity: p }) => p.assistantDraftKey ? [[p.assistantDraftKey, u]] : []
|
|
123
123
|
)
|
|
124
124
|
), c = /* @__PURE__ */ new Map();
|
|
125
|
-
for (const { item: u, identity:
|
|
126
|
-
for (const g of
|
|
125
|
+
for (const { item: u, identity: p } of i)
|
|
126
|
+
for (const g of p.activityKeys ?? []) {
|
|
127
127
|
const y = c.get(g);
|
|
128
128
|
(!y || s(y).isTransient) && c.set(g, u);
|
|
129
129
|
}
|
|
130
|
-
const d = new Set(i.map(({ identity: u }) => u.id)),
|
|
130
|
+
const d = new Set(i.map(({ identity: u }) => u.id)), h = new Set(
|
|
131
131
|
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
132
132
|
), m = /* @__PURE__ */ new Set(), f = [];
|
|
133
133
|
for (const u of t) {
|
|
134
|
-
const
|
|
135
|
-
let g = o.get(
|
|
136
|
-
if (
|
|
134
|
+
const p = s(u);
|
|
135
|
+
let g = o.get(p.id);
|
|
136
|
+
if (p.isOptimistic && p.optimisticKey ? g = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? g = l.get(p.assistantDraftKey) : p.isActivity && (g = p.activityKeys?.map((M) => c.get(M)).find((M) => M !== void 0) ?? g), g && !m.has(g)) {
|
|
137
137
|
f.push(g), m.add(g);
|
|
138
138
|
continue;
|
|
139
139
|
}
|
|
140
|
-
const y =
|
|
141
|
-
(
|
|
140
|
+
const y = p.respondsToUserMessageId !== void 0 && d.has(p.respondsToUserMessageId) || p.runId !== void 0 && h.has(p.runId);
|
|
141
|
+
(p.isOptimistic || (p.isAssistantDraft || p.isActivity) && y) && f.push(u);
|
|
142
142
|
}
|
|
143
143
|
for (const { item: u } of i)
|
|
144
144
|
m.has(u) || f.push(u);
|
|
145
145
|
return f;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function Os(t, e, s, n) {
|
|
148
148
|
return t.filter((r) => {
|
|
149
149
|
const i = n(r);
|
|
150
150
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
const
|
|
154
|
-
let
|
|
155
|
-
const
|
|
156
|
-
async function
|
|
157
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
153
|
+
const xe = "pluno.productAgent.transportId", qs = "pluno.productAgent.transportIdentity", Be = "pluno.productAgent.transportIdentity.event", Ls = 50, Ns = globalThis.setTimeout.bind(globalThis);
|
|
154
|
+
let oe = null;
|
|
155
|
+
const Te = /* @__PURE__ */ new Set(), We = /* @__PURE__ */ new Map();
|
|
156
|
+
async function xs(t = $t()) {
|
|
157
|
+
const e = t.randomUUID(), s = t.storage.getItem(xe);
|
|
158
158
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
159
159
|
const o = t.channel.subscribe((l) => {
|
|
160
160
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -172,7 +172,7 @@ async function Ns(t = Ht()) {
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
if (!s)
|
|
175
|
-
t.storage.setItem(
|
|
175
|
+
t.storage.setItem(xe, n), r = !0;
|
|
176
176
|
else if (t.skipStoredIdentityCollisionCheck)
|
|
177
177
|
r = !0;
|
|
178
178
|
else
|
|
@@ -181,7 +181,7 @@ async function Ns(t = Ht()) {
|
|
|
181
181
|
r = !0;
|
|
182
182
|
break;
|
|
183
183
|
}
|
|
184
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
184
|
+
n = t.randomUUID(), t.storage.setItem(xe, n);
|
|
185
185
|
}
|
|
186
186
|
let a = !1;
|
|
187
187
|
return {
|
|
@@ -191,52 +191,52 @@ async function Ns(t = Ht()) {
|
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
async function
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
async function Bs(t = !1) {
|
|
195
|
+
oe || (oe = xs({
|
|
196
|
+
...$t(),
|
|
197
197
|
skipStoredIdentityCollisionCheck: t
|
|
198
|
-
}),
|
|
198
|
+
}), oe.then((r) => {
|
|
199
199
|
const i = (o) => {
|
|
200
|
-
o.persisted || (r.release(),
|
|
200
|
+
o.persisted || (r.release(), oe = null, Te.clear(), window.removeEventListener("pagehide", i));
|
|
201
201
|
};
|
|
202
202
|
window.addEventListener("pagehide", i);
|
|
203
203
|
}));
|
|
204
|
-
const e = await
|
|
205
|
-
|
|
204
|
+
const e = await oe, s = Ws();
|
|
205
|
+
Te.add(s);
|
|
206
206
|
let n = !1;
|
|
207
207
|
return {
|
|
208
208
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
209
209
|
transportId: s === 0 ? e.transportId : `${e.transportId}.${s}`,
|
|
210
210
|
release: () => {
|
|
211
|
-
n || (n = !0,
|
|
211
|
+
n || (n = !0, Te.delete(s));
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function Ws() {
|
|
216
216
|
let t = 0;
|
|
217
|
-
for (;
|
|
217
|
+
for (; Te.has(t); )
|
|
218
218
|
t += 1;
|
|
219
219
|
return t;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function $t() {
|
|
222
222
|
return {
|
|
223
|
-
storage:
|
|
224
|
-
channel:
|
|
223
|
+
storage: Hs(),
|
|
224
|
+
channel: $s(),
|
|
225
225
|
randomUUID: () => crypto.randomUUID(),
|
|
226
|
-
settle: () => new Promise((t) =>
|
|
226
|
+
settle: () => new Promise((t) => Ns(t, Ls))
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function Hs() {
|
|
230
230
|
return {
|
|
231
231
|
getItem: (t) => {
|
|
232
232
|
try {
|
|
233
|
-
return window.sessionStorage?.getItem(t) ??
|
|
233
|
+
return window.sessionStorage?.getItem(t) ?? We.get(t) ?? null;
|
|
234
234
|
} catch {
|
|
235
|
-
return
|
|
235
|
+
return We.get(t) ?? null;
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
setItem: (t, e) => {
|
|
239
|
-
|
|
239
|
+
We.set(t, e);
|
|
240
240
|
try {
|
|
241
241
|
window.sessionStorage?.setItem(t, e);
|
|
242
242
|
} catch {
|
|
@@ -244,9 +244,9 @@ function Ws() {
|
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function $s() {
|
|
248
248
|
if (typeof BroadcastChannel < "u") {
|
|
249
|
-
const t = new BroadcastChannel(
|
|
249
|
+
const t = new BroadcastChannel(qs);
|
|
250
250
|
return {
|
|
251
251
|
postMessage: (e) => t.postMessage(e),
|
|
252
252
|
subscribe: (e) => {
|
|
@@ -256,11 +256,11 @@ function Hs() {
|
|
|
256
256
|
close: () => t.close()
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
|
-
return
|
|
259
|
+
return Fs();
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function Fs() {
|
|
262
262
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
263
|
-
if (s.key !==
|
|
263
|
+
if (s.key !== Be || !s.newValue)
|
|
264
264
|
return;
|
|
265
265
|
const n = JSON.parse(s.newValue);
|
|
266
266
|
for (const r of t)
|
|
@@ -269,9 +269,9 @@ function $s() {
|
|
|
269
269
|
return window.addEventListener("storage", e), {
|
|
270
270
|
postMessage: (s) => {
|
|
271
271
|
window.localStorage.setItem(
|
|
272
|
-
|
|
272
|
+
Be,
|
|
273
273
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
274
|
-
), window.localStorage.removeItem(
|
|
274
|
+
), window.localStorage.removeItem(Be);
|
|
275
275
|
},
|
|
276
276
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
277
277
|
close: () => {
|
|
@@ -279,7 +279,7 @@ function $s() {
|
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
-
const
|
|
282
|
+
const Ft = "schedule_follow_up";
|
|
283
283
|
function js(t) {
|
|
284
284
|
let e = t;
|
|
285
285
|
if (typeof e == "string")
|
|
@@ -291,23 +291,23 @@ function js(t) {
|
|
|
291
291
|
if (!e || typeof e != "object")
|
|
292
292
|
return null;
|
|
293
293
|
const s = e;
|
|
294
|
-
return s.ok !== !0 || s.toolName !==
|
|
294
|
+
return s.ok !== !0 || s.toolName !== Ft || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : {
|
|
295
295
|
id: typeof s.taskId == "string" && s.taskId ? s.taskId : null,
|
|
296
296
|
dueAt: s.dueAt
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
|
-
const
|
|
299
|
+
const zs = [
|
|
300
300
|
{ value: "gpt-5.6-sol", label: "gpt-5.6-sol", price: "$$" },
|
|
301
301
|
{ value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5", price: "$$" },
|
|
302
302
|
{ value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash", price: "$" }
|
|
303
|
-
],
|
|
303
|
+
], Ks = [
|
|
304
304
|
{ value: "anthropic/claude-opus-5", label: "Claude Opus 5", price: "$$$" },
|
|
305
305
|
{ value: "gpt-5.6-terra", label: "gpt-5.6-terra", price: "$$" }
|
|
306
|
-
],
|
|
307
|
-
...
|
|
308
|
-
...
|
|
309
|
-
],
|
|
310
|
-
let
|
|
306
|
+
], Gs = [
|
|
307
|
+
...zs,
|
|
308
|
+
...Ks
|
|
309
|
+
], He = (t) => Gs.some((e) => e.value === t), Vs = globalThis.fetch.bind(globalThis), Xe = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Xs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Js = ".pluno-pa-widget__panel", Qs = ".pluno-pa-widget__timeline", ft = `${Xe}[data-pluno-sdk-preview-channel]`;
|
|
310
|
+
let Ys = 0;
|
|
311
311
|
function mt(t) {
|
|
312
312
|
const e = {};
|
|
313
313
|
for (const o of [
|
|
@@ -346,7 +346,7 @@ function mt(t) {
|
|
|
346
346
|
}
|
|
347
347
|
return e;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function $e(t, e, s) {
|
|
350
350
|
if (typeof window > "u")
|
|
351
351
|
return;
|
|
352
352
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -358,36 +358,36 @@ function He(t, e, s) {
|
|
|
358
358
|
source: "web_sdk",
|
|
359
359
|
category: t,
|
|
360
360
|
name: e,
|
|
361
|
-
sequence: ++
|
|
361
|
+
sequence: ++Ys,
|
|
362
362
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
363
363
|
monotonicMs: performance.now(),
|
|
364
364
|
data: s
|
|
365
365
|
};
|
|
366
366
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
367
367
|
}
|
|
368
|
-
class
|
|
368
|
+
class ge extends Error {
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function Zs(t) {
|
|
371
371
|
return t === 408 || t === 425 || t === 429 || t >= 500;
|
|
372
372
|
}
|
|
373
|
-
const
|
|
373
|
+
const en = "https://app.pluno.ai", tn = 2e4, sn = 1e4, nn = 1e4, rn = 1e4, on = 1e4, an = 3e3, ln = 3e4, cn = 1e3, yt = 3e4, It = 0.2, St = 6e4, Tt = 15e3, ae = 8, wt = "Browser connection was interrupted.", Mt = 15e3, un = "Pluno could not send this message. Try it again.", At = 2e3, dn = 1e3, hn = 100, Rt = 8e3, Et = 3, pn = [300, 1e3], jt = 50 * 1024 * 1024, gn = /* @__PURE__ */ new Set([
|
|
374
374
|
".jpeg:image/jpeg",
|
|
375
375
|
".jpg:image/jpeg",
|
|
376
376
|
".pdf:application/pdf",
|
|
377
377
|
".png:image/png",
|
|
378
378
|
".webp:image/webp"
|
|
379
|
-
]),
|
|
380
|
-
function
|
|
379
|
+
]), bi = ".pdf,.png,.jpg,.jpeg,.webp", it = 64e3, Fe = 4e3, ot = 30, fn = 2e3, mn = 1e3, zt = "Image is too large for model vision input.", yn = 100, Kt = "pluno.productAgent.state.", Je = "pluno.productAgent.pendingEvents.", _e = "pluno.productAgent.activeToolCalls.", In = 100;
|
|
380
|
+
function le(t, e = 0) {
|
|
381
381
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
382
382
|
return Math.max(e, s);
|
|
383
383
|
}
|
|
384
|
-
const
|
|
385
|
-
let
|
|
386
|
-
function
|
|
387
|
-
const s = Math.min(yt,
|
|
384
|
+
const we = /* @__PURE__ */ new Set();
|
|
385
|
+
let fe = null;
|
|
386
|
+
function Sn(t, e = Math.random) {
|
|
387
|
+
const s = Math.min(yt, cn * 2 ** t), n = 1 - It + e() * It * 2;
|
|
388
388
|
return Math.min(yt, Math.round(s * n));
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Tn(t, e, s) {
|
|
391
391
|
return new Promise((n, r) => {
|
|
392
392
|
const i = setTimeout(() => r(new Error(s)), e);
|
|
393
393
|
t.then(
|
|
@@ -400,19 +400,19 @@ function Sn(t, e, s) {
|
|
|
400
400
|
);
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
|
-
class
|
|
403
|
+
class Gt {
|
|
404
404
|
constructor(e, s) {
|
|
405
|
-
this.options = e, this.transportIdentity = s, this.personalModelSelectionOverride = e.productVariant === "personal" &&
|
|
405
|
+
this.options = e, this.transportIdentity = s, this.personalModelSelectionOverride = e.productVariant === "personal" && He(e.model) ? e.model : null, this.state = {
|
|
406
406
|
...this.state,
|
|
407
|
-
starterPrompts:
|
|
407
|
+
starterPrompts: Zn(e.initialStarterPrompts)
|
|
408
408
|
};
|
|
409
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
409
|
+
const n = e.restorePersistedState === !1 ? null : Gr(e.clientId, e.expectedPersistedSessionId);
|
|
410
410
|
n && (this.state = {
|
|
411
411
|
...this.state,
|
|
412
412
|
...n,
|
|
413
413
|
// Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
|
|
414
414
|
// activity is deliberately not restored here because it hydrates after the transcript is visible.
|
|
415
|
-
messages: n.messages.filter(
|
|
415
|
+
messages: n.messages.filter(os),
|
|
416
416
|
isLoadingSession: n.sessionId !== null,
|
|
417
417
|
status: "idle",
|
|
418
418
|
user: null,
|
|
@@ -427,9 +427,9 @@ class Kt {
|
|
|
427
427
|
taskStatus: null,
|
|
428
428
|
isRetrying: !1,
|
|
429
429
|
lastError: null
|
|
430
|
-
}), this.queuedClientEvents =
|
|
431
|
-
|
|
432
|
-
|
|
430
|
+
}), this.queuedClientEvents = Zr(
|
|
431
|
+
Xr(e.clientId),
|
|
432
|
+
Jr(e.clientId)
|
|
433
433
|
);
|
|
434
434
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
435
435
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
@@ -523,6 +523,7 @@ class Kt {
|
|
|
523
523
|
starterPromptsLoading: !1,
|
|
524
524
|
appearance: null,
|
|
525
525
|
messages: [],
|
|
526
|
+
activeScheduledFollowUps: null,
|
|
526
527
|
isLoadingSession: !1,
|
|
527
528
|
assistantDraft: "",
|
|
528
529
|
assistantDraftItemId: null,
|
|
@@ -539,18 +540,18 @@ class Kt {
|
|
|
539
540
|
lastErrorSecuritySettingsUrl: null
|
|
540
541
|
};
|
|
541
542
|
static async init(e) {
|
|
542
|
-
const s = e, n = await
|
|
543
|
+
const s = e, n = await Bs(
|
|
543
544
|
s.skipStoredTransportIdentityCollisionCheck === !0
|
|
544
|
-
), r = new
|
|
545
|
+
), r = new Gt({
|
|
545
546
|
...e,
|
|
546
|
-
backendUrl:
|
|
547
|
-
clientId: e.clientId ??
|
|
547
|
+
backendUrl: xn(e.backendUrl ?? en),
|
|
548
|
+
clientId: e.clientId ?? rr(),
|
|
548
549
|
productVariant: e.productVariant ?? "customer_embedded",
|
|
549
|
-
entrySurface:
|
|
550
|
+
entrySurface: Bn(e.entrySurface)
|
|
550
551
|
}, n);
|
|
551
552
|
try {
|
|
552
|
-
|
|
553
|
-
|
|
553
|
+
As().catch((i) => {
|
|
554
|
+
A("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
554
555
|
message: i instanceof Error ? i.message : String(i)
|
|
555
556
|
});
|
|
556
557
|
}), s.disableNetworkCapture || r.enableNetworkCapture(), r.startPageLifecycleRecovery(), r.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await r.connect();
|
|
@@ -575,7 +576,7 @@ class Kt {
|
|
|
575
576
|
const s = e.trim();
|
|
576
577
|
if (!s)
|
|
577
578
|
return;
|
|
578
|
-
const n = this.stagedProactiveSuggestionQuestionMessageId ?? `local-proactive-suggestion-edit-${
|
|
579
|
+
const n = this.stagedProactiveSuggestionQuestionMessageId ?? `local-proactive-suggestion-edit-${x()}`;
|
|
579
580
|
this.stagedProactiveSuggestionQuestionMessageId = n;
|
|
580
581
|
const r = {
|
|
581
582
|
id: n,
|
|
@@ -595,15 +596,15 @@ class Kt {
|
|
|
595
596
|
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
596
597
|
);
|
|
597
598
|
try {
|
|
598
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
599
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await Tn(this.options.tokenProvider(), nn, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
599
600
|
return;
|
|
600
601
|
if (!this.token && !this.options.webSocketFactory)
|
|
601
602
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
602
|
-
const s =
|
|
603
|
+
const s = $n(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
603
604
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
604
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (
|
|
605
|
-
},
|
|
606
|
-
this.socket !== n || (this.clearSocketConnectTimer(),
|
|
605
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (A("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
606
|
+
}, rn), n.addEventListener("open", () => {
|
|
607
|
+
this.socket !== n || (this.clearSocketConnectTimer(), A("web-sdk.agent", "Pluno socket opened", {
|
|
607
608
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
608
609
|
isThinking: this.state.isThinking
|
|
609
610
|
}), !(this.token ? this.sendNow({
|
|
@@ -613,19 +614,19 @@ class Kt {
|
|
|
613
614
|
transportId: this.transportIdentity.transportId,
|
|
614
615
|
pageUrl: location.href
|
|
615
616
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
616
|
-
this.socket === n && (
|
|
617
|
-
},
|
|
617
|
+
this.socket === n && (A("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
618
|
+
}, on));
|
|
618
619
|
}), n.addEventListener("message", (r) => {
|
|
619
|
-
this.socket === n && this.handleServerEvent(
|
|
620
|
+
this.socket === n && this.handleServerEvent(Qn(r.data));
|
|
620
621
|
}), n.addEventListener("sendfailure", (r) => {
|
|
621
622
|
if (this.socket !== n)
|
|
622
623
|
return;
|
|
623
|
-
const i =
|
|
624
|
+
const i = Yn(r?.detail?.data);
|
|
624
625
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
625
626
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
626
627
|
) && (this.queuedClientEvents.push(i), V(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();
|
|
627
628
|
}), n.addEventListener("close", (r) => {
|
|
628
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (
|
|
629
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (A("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
629
630
|
code: typeof r?.code == "number" ? r.code : null,
|
|
630
631
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
631
632
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -633,7 +634,7 @@ class Kt {
|
|
|
633
634
|
isThinking: this.state.isThinking
|
|
634
635
|
}), this.setReconnectingState(), this.scheduleReconnect()));
|
|
635
636
|
}), n.addEventListener("error", () => {
|
|
636
|
-
this.socket !== n || this.state.status === "closed" || (
|
|
637
|
+
this.socket !== n || this.state.status === "closed" || (A("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
637
638
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
638
639
|
isThinking: this.state.isThinking
|
|
639
640
|
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
@@ -656,15 +657,15 @@ class Kt {
|
|
|
656
657
|
this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
657
658
|
}
|
|
658
659
|
destroy() {
|
|
659
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
660
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), ei(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
|
|
660
661
|
for (const e of Object.values(this.listeners))
|
|
661
662
|
e?.clear();
|
|
662
663
|
}
|
|
663
664
|
warmup(e = "panel_open") {
|
|
664
|
-
const s =
|
|
665
|
+
const s = b(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
|
|
665
666
|
type: "runtime.warmup",
|
|
666
667
|
reason: e,
|
|
667
|
-
...e === "composer_input" ? { warmupId: r?.event.warmupId ??
|
|
668
|
+
...e === "composer_input" ? { warmupId: r?.event.warmupId ?? x() } : {},
|
|
668
669
|
entrySurface: this.options.entrySurface,
|
|
669
670
|
sessionId: this.state.sessionId ?? void 0,
|
|
670
671
|
page: s,
|
|
@@ -688,24 +689,24 @@ class Kt {
|
|
|
688
689
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
689
690
|
entrySurface: this.options.entrySurface,
|
|
690
691
|
...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
|
|
691
|
-
pageOrigin:
|
|
692
|
+
pageOrigin: b().origin
|
|
692
693
|
}
|
|
693
694
|
};
|
|
694
695
|
this.authenticatedSocket === this.socket && this.sendNow(n) || (this.pendingWidgetLifecycleEvents.push(n), this.pendingWidgetLifecycleEvents.length > 20 && this.pendingWidgetLifecycleEvents.splice(0, this.pendingWidgetLifecycleEvents.length - 20));
|
|
695
696
|
}
|
|
696
697
|
async sendMessage(e, s = {}) {
|
|
697
698
|
const n = e.trim(), r = s.attachments ?? [];
|
|
698
|
-
if (this.options.productVariant === "customer_embedded" && (r.forEach(
|
|
699
|
+
if (this.options.productVariant === "customer_embedded" && (r.forEach(us), r.reduce(
|
|
699
700
|
(T, N) => T + N.sizeBytes,
|
|
700
701
|
0
|
|
701
702
|
) > jt))
|
|
702
703
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
703
|
-
let i = r.map(
|
|
704
|
+
let i = r.map(ke);
|
|
704
705
|
if (!n && i.length === 0)
|
|
705
706
|
return null;
|
|
706
707
|
if (this.pendingClientMessageId)
|
|
707
708
|
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
708
|
-
const o =
|
|
709
|
+
const o = b(), a = s.clientMessageId ?? x(), l = s.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
|
|
709
710
|
(S) => S.id === this.stagedProactiveSuggestionQuestionMessageId
|
|
710
711
|
) ?? null : null, d = l ? {
|
|
711
712
|
id: `local-proactive-suggestion-question-${a}`,
|
|
@@ -713,13 +714,13 @@ class Kt {
|
|
|
713
714
|
phase: "final_answer",
|
|
714
715
|
content: l,
|
|
715
716
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
716
|
-
} : null,
|
|
717
|
+
} : null, h = {
|
|
717
718
|
id: `local-${a}`,
|
|
718
719
|
role: "user",
|
|
719
720
|
content: n,
|
|
720
721
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
721
722
|
...r.length > 0 ? { attachments: r } : {}
|
|
722
|
-
}, m = this.state.messages.some((S) => S.id ===
|
|
723
|
+
}, m = this.state.messages.some((S) => S.id === h.id || S.clientMessageId === a), f = this.state.isThinking, u = this.state.taskStatus, p = this.state.pendingMessageStatus, g = this.state.turnPhase, y = this.state.messages, M = m ? this.state.messages : [
|
|
723
724
|
...this.state.messages.map(
|
|
724
725
|
(S) => c && S.id === c.id ? {
|
|
725
726
|
...S,
|
|
@@ -727,7 +728,7 @@ class Kt {
|
|
|
727
728
|
} : S
|
|
728
729
|
),
|
|
729
730
|
...!c && d ? [d] : [],
|
|
730
|
-
|
|
731
|
+
h
|
|
731
732
|
], w = {
|
|
732
733
|
assistantDraft: this.state.assistantDraft,
|
|
733
734
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
@@ -737,7 +738,7 @@ class Kt {
|
|
|
737
738
|
lastError: this.state.lastError
|
|
738
739
|
};
|
|
739
740
|
this.setState({
|
|
740
|
-
messages:
|
|
741
|
+
messages: M,
|
|
741
742
|
...f ? {} : {
|
|
742
743
|
assistantDraft: "",
|
|
743
744
|
assistantDraftItemId: null,
|
|
@@ -751,7 +752,7 @@ class Kt {
|
|
|
751
752
|
taskStatus: "working",
|
|
752
753
|
isRetrying: !1,
|
|
753
754
|
lastError: null
|
|
754
|
-
}), m || (d && !c && this.emit("message", d), this.emit("message",
|
|
755
|
+
}), m || (d && !c && this.emit("message", d), this.emit("message", h));
|
|
755
756
|
try {
|
|
756
757
|
const S = [];
|
|
757
758
|
for (const T of i) {
|
|
@@ -769,34 +770,34 @@ class Kt {
|
|
|
769
770
|
throw this.setState({
|
|
770
771
|
...m ? {} : { messages: y },
|
|
771
772
|
...f ? {} : { ...w, isThinking: !1 },
|
|
772
|
-
pendingMessageStatus:
|
|
773
|
+
pendingMessageStatus: p,
|
|
773
774
|
turnPhase: g,
|
|
774
775
|
taskStatus: u
|
|
775
776
|
}), S;
|
|
776
777
|
}
|
|
777
778
|
this.retryableClientMessageId = null;
|
|
778
|
-
const
|
|
779
|
+
const D = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, U = {
|
|
779
780
|
type: "chat.user_message",
|
|
780
781
|
sessionId: this.state.sessionId ?? void 0,
|
|
781
782
|
clientMessageId: a,
|
|
782
783
|
initiatedBy: s.initiatedBy,
|
|
783
|
-
invocation:
|
|
784
|
+
invocation: Wn(s.invocation ?? s.initiatedBy),
|
|
784
785
|
entrySurface: this.options.entrySurface,
|
|
785
786
|
content: n,
|
|
786
787
|
proactiveSuggestionQuestion: s.proactiveSuggestionQuestion,
|
|
787
|
-
pageContent:
|
|
788
|
-
attachments: i.length > 0 ? i.map(
|
|
788
|
+
pageContent: D && at() || void 0,
|
|
789
|
+
attachments: i.length > 0 ? i.map(ke) : void 0,
|
|
789
790
|
page: o,
|
|
790
791
|
model: this.options.model,
|
|
791
792
|
metadata: kt(this.options.metadata)
|
|
792
793
|
};
|
|
793
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent =
|
|
794
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = U, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(U), this.schedulePendingDeliveryAck(a), a;
|
|
794
795
|
}
|
|
795
796
|
getModel() {
|
|
796
797
|
return this.options.model;
|
|
797
798
|
}
|
|
798
799
|
setModel(e) {
|
|
799
|
-
this.options.model = e, this.options.productVariant === "personal" &&
|
|
800
|
+
this.options.model = e, this.options.productVariant === "personal" && He(e) && (this.personalModelSelectionOverride = e);
|
|
800
801
|
}
|
|
801
802
|
retryLastMessage() {
|
|
802
803
|
const e = this.state.sessionId, s = this.retryableClientMessageId;
|
|
@@ -814,27 +815,27 @@ class Kt {
|
|
|
814
815
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = 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;
|
|
815
816
|
}
|
|
816
817
|
createLocalAttachment(e) {
|
|
817
|
-
this.options.productVariant === "customer_embedded" &&
|
|
818
|
-
const s =
|
|
818
|
+
this.options.productVariant === "customer_embedded" && ti(e);
|
|
819
|
+
const s = x(), n = {
|
|
819
820
|
id: s,
|
|
820
821
|
name: e.name || "attachment",
|
|
821
|
-
mimeType:
|
|
822
|
+
mimeType: tt(e),
|
|
822
823
|
sizeBytes: e.size
|
|
823
824
|
};
|
|
824
825
|
this.attachmentFiles.set(s, e);
|
|
825
826
|
const r = Date.now();
|
|
826
|
-
return
|
|
827
|
+
return ws({
|
|
827
828
|
attachmentId: s,
|
|
828
829
|
name: n.name,
|
|
829
830
|
mimeType: n.mimeType,
|
|
830
831
|
sizeBytes: n.sizeBytes,
|
|
831
832
|
blob: e,
|
|
832
|
-
origin:
|
|
833
|
+
origin: b().origin,
|
|
833
834
|
sessionId: this.state.sessionId ?? void 0,
|
|
834
835
|
createdAt: r,
|
|
835
836
|
lastUsedAt: r
|
|
836
837
|
}).catch((i) => {
|
|
837
|
-
|
|
838
|
+
A("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
838
839
|
attachmentId: s,
|
|
839
840
|
name: n.name,
|
|
840
841
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -852,7 +853,7 @@ class Kt {
|
|
|
852
853
|
file: e,
|
|
853
854
|
attachment: s
|
|
854
855
|
}) {
|
|
855
|
-
const n = this.state.sessionId, r =
|
|
856
|
+
const n = this.state.sessionId, r = tt(e), i = {
|
|
856
857
|
sessionId: n ?? void 0,
|
|
857
858
|
attachmentId: s.id,
|
|
858
859
|
clientId: this.options.clientId,
|
|
@@ -860,43 +861,43 @@ class Kt {
|
|
|
860
861
|
name: e.name || "attachment",
|
|
861
862
|
mimeType: r,
|
|
862
863
|
sizeBytes: e.size,
|
|
863
|
-
page:
|
|
864
|
+
page: b(),
|
|
864
865
|
model: this.options.model,
|
|
865
866
|
metadata: kt(this.options.metadata),
|
|
866
867
|
entrySurface: this.options.entrySurface
|
|
867
868
|
};
|
|
868
869
|
let o;
|
|
869
870
|
if (this.options.persistAttachmentUpload)
|
|
870
|
-
o = await
|
|
871
|
+
o = await Se(
|
|
871
872
|
() => this.options.persistAttachmentUpload(i, e),
|
|
872
873
|
"Failed to upload attachment"
|
|
873
874
|
);
|
|
874
875
|
else {
|
|
875
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
876
|
+
const l = this.options.prepareAttachmentUpload ? await Se(
|
|
876
877
|
() => this.options.prepareAttachmentUpload(i),
|
|
877
878
|
"Failed to prepare attachment upload"
|
|
878
879
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
879
|
-
await
|
|
880
|
+
await Se(async () => {
|
|
880
881
|
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
881
882
|
method: l.uploadMethod,
|
|
882
883
|
headers: l.uploadHeaders,
|
|
883
884
|
body: e
|
|
884
885
|
});
|
|
885
886
|
if (!c.ok)
|
|
886
|
-
throw new
|
|
887
|
+
throw new Ae("Failed to upload attachment", c.status);
|
|
887
888
|
return c;
|
|
888
889
|
}, "Failed to upload attachment"), o = l;
|
|
889
890
|
}
|
|
890
891
|
this.setState({ sessionId: o.sessionId });
|
|
891
|
-
const a =
|
|
892
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
892
|
+
const a = cs(o.attachment, this.options.backendUrl);
|
|
893
|
+
return this.updateAttachmentInState(s.id, a), s.id && Ms(s.id, {
|
|
893
894
|
sessionId: o.sessionId,
|
|
894
895
|
fileUrl: a.fileUrl,
|
|
895
896
|
sandboxPath: a.sandboxPath,
|
|
896
897
|
storageKey: a.storageKey,
|
|
897
898
|
lastUsedAt: Date.now()
|
|
898
899
|
}).catch((l) => {
|
|
899
|
-
|
|
900
|
+
A("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
900
901
|
attachmentId: s.id,
|
|
901
902
|
name: a.name,
|
|
902
903
|
message: l instanceof Error ? l.message : String(l)
|
|
@@ -916,18 +917,18 @@ class Kt {
|
|
|
916
917
|
}
|
|
917
918
|
async prepareEmbedAttachmentUpload(e) {
|
|
918
919
|
let s = !1;
|
|
919
|
-
return await
|
|
920
|
+
return await Se(async () => {
|
|
920
921
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
921
922
|
if (n.ok)
|
|
922
923
|
return await n.json();
|
|
923
|
-
if (
|
|
924
|
+
if (Ii(n.status) && this.options.tokenProvider && !s) {
|
|
924
925
|
s = !0;
|
|
925
926
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
926
927
|
if (r.ok)
|
|
927
928
|
return await r.json();
|
|
928
|
-
throw new
|
|
929
|
+
throw new Ae("Failed to prepare attachment upload", r.status);
|
|
929
930
|
}
|
|
930
|
-
throw new
|
|
931
|
+
throw new Ae("Failed to prepare attachment upload", n.status);
|
|
931
932
|
}, "Failed to prepare attachment upload");
|
|
932
933
|
}
|
|
933
934
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -945,7 +946,7 @@ class Kt {
|
|
|
945
946
|
if (!this.state.sessionId)
|
|
946
947
|
return;
|
|
947
948
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
948
|
-
const e =
|
|
949
|
+
const e = Nr(
|
|
949
950
|
this.state.messages,
|
|
950
951
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
951
952
|
this.state.assistantDraftRunId,
|
|
@@ -958,7 +959,7 @@ class Kt {
|
|
|
958
959
|
stoppedCausalSequence: null,
|
|
959
960
|
toolCallIds: new Set(
|
|
960
961
|
this.state.messages.filter(
|
|
961
|
-
(s) =>
|
|
962
|
+
(s) => Ke(
|
|
962
963
|
s,
|
|
963
964
|
e.respondsToUserMessageId,
|
|
964
965
|
e.runId
|
|
@@ -968,8 +969,8 @@ class Kt {
|
|
|
968
969
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
969
970
|
for (const [s, n] of this.activeBrowserToolCalls)
|
|
970
971
|
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
|
|
971
|
-
|
|
972
|
-
messages:
|
|
972
|
+
Nt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
973
|
+
messages: qt(
|
|
973
974
|
this.state.messages,
|
|
974
975
|
e.clientMessageId,
|
|
975
976
|
e.runId
|
|
@@ -989,11 +990,12 @@ class Kt {
|
|
|
989
990
|
type: "session.reset",
|
|
990
991
|
sessionId: this.state.sessionId ?? void 0,
|
|
991
992
|
warmupId: n ?? void 0,
|
|
992
|
-
page:
|
|
993
|
+
page: b()
|
|
993
994
|
}), this.setState({
|
|
994
995
|
sessionId: null,
|
|
995
996
|
starterPrompts: [...this.state.starterPrompts],
|
|
996
997
|
messages: [],
|
|
998
|
+
activeScheduledFollowUps: null,
|
|
997
999
|
isLoadingSession: !1,
|
|
998
1000
|
assistantDraft: "",
|
|
999
1001
|
assistantDraftItemId: null,
|
|
@@ -1008,7 +1010,7 @@ class Kt {
|
|
|
1008
1010
|
});
|
|
1009
1011
|
}
|
|
1010
1012
|
listSessions(e = {}) {
|
|
1011
|
-
const s =
|
|
1013
|
+
const s = x(), n = new Promise((i, o) => {
|
|
1012
1014
|
const a = window.setTimeout(() => {
|
|
1013
1015
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
1014
1016
|
}, Rt);
|
|
@@ -1016,7 +1018,7 @@ class Kt {
|
|
|
1016
1018
|
}), r = {
|
|
1017
1019
|
type: "sessions.list",
|
|
1018
1020
|
requestId: s,
|
|
1019
|
-
page:
|
|
1021
|
+
page: b(),
|
|
1020
1022
|
...e.cursor ? { cursor: e.cursor } : {},
|
|
1021
1023
|
...e.limit ? { limit: e.limit } : {},
|
|
1022
1024
|
...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
|
|
@@ -1030,26 +1032,27 @@ class Kt {
|
|
|
1030
1032
|
setSessionPinned(e, s) {
|
|
1031
1033
|
return this.sendSessionMutation(
|
|
1032
1034
|
this.pendingSessionPinRequests,
|
|
1033
|
-
{ type: "session.pin", requestId:
|
|
1035
|
+
{ type: "session.pin", requestId: x(), sessionId: e, pinned: s },
|
|
1034
1036
|
"Session pin did not respond in time"
|
|
1035
1037
|
);
|
|
1036
1038
|
}
|
|
1037
1039
|
renameSession(e, s) {
|
|
1038
1040
|
return this.sendSessionMutation(
|
|
1039
1041
|
this.pendingSessionRenameRequests,
|
|
1040
|
-
{ type: "session.rename", requestId:
|
|
1042
|
+
{ type: "session.rename", requestId: x(), sessionId: e, title: s },
|
|
1041
1043
|
"Session rename did not respond in time"
|
|
1042
1044
|
);
|
|
1043
1045
|
}
|
|
1044
1046
|
loadSession(e) {
|
|
1045
|
-
const s =
|
|
1047
|
+
const s = x(), n = this.activeComposerWarmupId;
|
|
1046
1048
|
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId !== e && this.rememberCurrentRunAsDetached(), this.detachedSessionIds.delete(e), this.deferredDetachedSessionEvents.delete(e), !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), n && this.send({
|
|
1047
1049
|
type: "session.reset",
|
|
1048
1050
|
warmupId: n,
|
|
1049
|
-
page:
|
|
1051
|
+
page: b()
|
|
1050
1052
|
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.options.productVariant === "personal" && this.state.sessionId !== e && (this.personalModelSelectionOverride = null, this.options.model = void 0), this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionActivityRequestId = null, this.setState({
|
|
1051
1053
|
sessionId: e,
|
|
1052
1054
|
messages: [],
|
|
1055
|
+
activeScheduledFollowUps: null,
|
|
1053
1056
|
isLoadingSession: !0,
|
|
1054
1057
|
assistantDraft: "",
|
|
1055
1058
|
assistantDraftItemId: null,
|
|
@@ -1066,7 +1069,7 @@ class Kt {
|
|
|
1066
1069
|
type: "session.load",
|
|
1067
1070
|
requestId: s,
|
|
1068
1071
|
sessionId: e,
|
|
1069
|
-
page:
|
|
1072
|
+
page: b()
|
|
1070
1073
|
});
|
|
1071
1074
|
}
|
|
1072
1075
|
canLoadSessionHistoryOverHttp() {
|
|
@@ -1089,7 +1092,8 @@ class Kt {
|
|
|
1089
1092
|
type: "conversation.state",
|
|
1090
1093
|
requestId: s,
|
|
1091
1094
|
session: r.session,
|
|
1092
|
-
items: r.items
|
|
1095
|
+
items: r.items,
|
|
1096
|
+
...r.activeScheduledFollowUps !== void 0 ? { activeScheduledFollowUps: r.activeScheduledFollowUps } : {}
|
|
1093
1097
|
});
|
|
1094
1098
|
for (const o of i)
|
|
1095
1099
|
this.handleServerEvent(o);
|
|
@@ -1099,21 +1103,21 @@ class Kt {
|
|
|
1099
1103
|
}
|
|
1100
1104
|
subscribeToSessionBeforeHistory(e) {
|
|
1101
1105
|
this.pendingSessionSubscription?.resolve(!1);
|
|
1102
|
-
const s =
|
|
1106
|
+
const s = x(), n = new Promise((r) => {
|
|
1103
1107
|
this.pendingSessionSubscription = { requestId: s, sessionId: e, resolve: r };
|
|
1104
1108
|
});
|
|
1105
1109
|
return this.send({
|
|
1106
1110
|
type: "session.load",
|
|
1107
1111
|
requestId: s,
|
|
1108
1112
|
sessionId: e,
|
|
1109
|
-
page:
|
|
1113
|
+
page: b(),
|
|
1110
1114
|
subscribeOnly: !0
|
|
1111
1115
|
}), n;
|
|
1112
1116
|
}
|
|
1113
1117
|
async autoLoadSessionActivity(e) {
|
|
1114
1118
|
let s = null;
|
|
1115
1119
|
do {
|
|
1116
|
-
const n =
|
|
1120
|
+
const n = x();
|
|
1117
1121
|
this.sessionActivityRequestId = n;
|
|
1118
1122
|
let r;
|
|
1119
1123
|
try {
|
|
@@ -1139,7 +1143,7 @@ class Kt {
|
|
|
1139
1143
|
try {
|
|
1140
1144
|
const o = this.options.token ?? await this.options.tokenProvider?.() ?? this.token;
|
|
1141
1145
|
if (!o)
|
|
1142
|
-
throw new
|
|
1146
|
+
throw new ge("Product Agent history requires authentication");
|
|
1143
1147
|
this.token = o;
|
|
1144
1148
|
const a = new URLSearchParams();
|
|
1145
1149
|
s === "activity" && a.set("limit", "200"), n && a.set("cursor", n);
|
|
@@ -1153,20 +1157,21 @@ class Kt {
|
|
|
1153
1157
|
});
|
|
1154
1158
|
if (!d.ok) {
|
|
1155
1159
|
const m = await d.text() || `History request failed (${d.status})`;
|
|
1156
|
-
throw
|
|
1160
|
+
throw Zs(d.status) ? new Error(m) : new ge(m);
|
|
1157
1161
|
}
|
|
1158
|
-
const
|
|
1159
|
-
if (!
|
|
1160
|
-
throw new
|
|
1162
|
+
const h = await d.json();
|
|
1163
|
+
if (!h?.session || !Array.isArray(h.items))
|
|
1164
|
+
throw new ge("Invalid Product Agent session history response");
|
|
1161
1165
|
return {
|
|
1162
|
-
session:
|
|
1163
|
-
items:
|
|
1164
|
-
nextCursor: typeof
|
|
1166
|
+
session: h.session,
|
|
1167
|
+
items: h.items,
|
|
1168
|
+
nextCursor: typeof h.nextCursor == "string" ? h.nextCursor : null,
|
|
1169
|
+
...Object.prototype.hasOwnProperty.call(h, "activeScheduledFollowUps") ? { activeScheduledFollowUps: h.activeScheduledFollowUps } : {}
|
|
1165
1170
|
};
|
|
1166
1171
|
} catch (o) {
|
|
1167
|
-
if (o instanceof
|
|
1172
|
+
if (o instanceof ge)
|
|
1168
1173
|
throw o;
|
|
1169
|
-
|
|
1174
|
+
A("web-sdk.history", "HTTP session history page failed; retrying", {
|
|
1170
1175
|
sessionId: e,
|
|
1171
1176
|
hasCursor: !!n,
|
|
1172
1177
|
retryDelayMs: i,
|
|
@@ -1180,7 +1185,7 @@ class Kt {
|
|
|
1180
1185
|
return;
|
|
1181
1186
|
const i = n instanceof Error ? n.message : String(n);
|
|
1182
1187
|
if (r) {
|
|
1183
|
-
this.sessionActivityRequestId = null,
|
|
1188
|
+
this.sessionActivityRequestId = null, A("web-sdk.history", "Background session activity hydration stopped", {
|
|
1184
1189
|
sessionId: s,
|
|
1185
1190
|
message: i
|
|
1186
1191
|
});
|
|
@@ -1192,7 +1197,7 @@ class Kt {
|
|
|
1192
1197
|
message: i,
|
|
1193
1198
|
requestId: e,
|
|
1194
1199
|
sessionId: s
|
|
1195
|
-
}),
|
|
1200
|
+
}), A("web-sdk.history", "HTTP session history page failed permanently", {
|
|
1196
1201
|
sessionId: s,
|
|
1197
1202
|
message: i
|
|
1198
1203
|
});
|
|
@@ -1216,9 +1221,9 @@ class Kt {
|
|
|
1216
1221
|
return !1;
|
|
1217
1222
|
const s = this.socket;
|
|
1218
1223
|
try {
|
|
1219
|
-
return s.send(JSON.stringify(e)),
|
|
1224
|
+
return s.send(JSON.stringify(e)), $e("client_event", e.type, mt(e)), !0;
|
|
1220
1225
|
} catch (n) {
|
|
1221
|
-
return
|
|
1226
|
+
return A("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1222
1227
|
message: n instanceof Error ? n.message : String(n),
|
|
1223
1228
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1224
1229
|
isThinking: this.state.isThinking
|
|
@@ -1250,7 +1255,7 @@ class Kt {
|
|
|
1250
1255
|
}
|
|
1251
1256
|
}));
|
|
1252
1257
|
} catch (r) {
|
|
1253
|
-
|
|
1258
|
+
A("web-sdk.agent", "Pluno health signal send failed", {
|
|
1254
1259
|
name: e,
|
|
1255
1260
|
message: r instanceof Error ? r.message : String(r)
|
|
1256
1261
|
});
|
|
@@ -1260,7 +1265,7 @@ class Kt {
|
|
|
1260
1265
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
1261
1266
|
return;
|
|
1262
1267
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
1263
|
-
const e =
|
|
1268
|
+
const e = Fn();
|
|
1264
1269
|
this.sendNow(
|
|
1265
1270
|
q({
|
|
1266
1271
|
type: "starter_prompts.page_context",
|
|
@@ -1277,7 +1282,7 @@ class Kt {
|
|
|
1277
1282
|
const e = location.href;
|
|
1278
1283
|
e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
1279
1284
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
1280
|
-
},
|
|
1285
|
+
}, In));
|
|
1281
1286
|
}
|
|
1282
1287
|
refreshStarterPromptsForCurrentUrl() {
|
|
1283
1288
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -1324,8 +1329,8 @@ class Kt {
|
|
|
1324
1329
|
return;
|
|
1325
1330
|
this.clearPendingWarmupAckTimer();
|
|
1326
1331
|
const s = Math.min(
|
|
1327
|
-
|
|
1328
|
-
|
|
1332
|
+
an * 2 ** e.retryAttempt,
|
|
1333
|
+
ln
|
|
1329
1334
|
);
|
|
1330
1335
|
e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
|
|
1331
1336
|
this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
|
|
@@ -1338,16 +1343,16 @@ class Kt {
|
|
|
1338
1343
|
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;
|
|
1339
1344
|
}
|
|
1340
1345
|
findStoppedTurnForEvent(e) {
|
|
1341
|
-
const s = e.type === "session.item" ?
|
|
1346
|
+
const s = e.type === "session.item" ? P(e.item) : null;
|
|
1342
1347
|
return this.findStoppedTurn(
|
|
1343
1348
|
G(e) ?? this.state.sessionId,
|
|
1344
1349
|
s ?? e
|
|
1345
1350
|
);
|
|
1346
1351
|
}
|
|
1347
1352
|
rememberDurablyStoppedTurn(e, s, n) {
|
|
1348
|
-
if (!e || !s || !
|
|
1353
|
+
if (!e || !s || !Me(s) || this.findStoppedTurn(e, s))
|
|
1349
1354
|
return;
|
|
1350
|
-
const r = L(s), i =
|
|
1355
|
+
const r = L(s), i = C(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1351
1356
|
this.stoppedTurns.push({
|
|
1352
1357
|
sessionId: e,
|
|
1353
1358
|
clientMessageId: o,
|
|
@@ -1357,7 +1362,7 @@ class Kt {
|
|
|
1357
1362
|
stoppedCausalSequence: v(s),
|
|
1358
1363
|
toolCallIds: new Set(
|
|
1359
1364
|
this.state.messages.filter(
|
|
1360
|
-
(a) =>
|
|
1365
|
+
(a) => Ke(a, r, i)
|
|
1361
1366
|
).map((a) => a.callId).filter((a) => typeof a == "string")
|
|
1362
1367
|
)
|
|
1363
1368
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
@@ -1367,26 +1372,26 @@ class Kt {
|
|
|
1367
1372
|
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1368
1373
|
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1369
1374
|
}
|
|
1370
|
-
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !
|
|
1375
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !Me(P(e.item)) : e.type !== "conversation.state" : !1;
|
|
1371
1376
|
}
|
|
1372
1377
|
filterStoppedSnapshotItems(e, s) {
|
|
1373
1378
|
return e.filter((n) => {
|
|
1374
|
-
const r =
|
|
1375
|
-
if (!i || r?.type === "message" && r.role === "user" ||
|
|
1379
|
+
const r = P(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1380
|
+
if (!i || r?.type === "message" && r.role === "user" || Me(r))
|
|
1376
1381
|
return !0;
|
|
1377
1382
|
if (i.stoppedCausalSequence !== null) {
|
|
1378
1383
|
const o = r ? v(r) : null;
|
|
1379
1384
|
return o === null || o <= i.stoppedCausalSequence;
|
|
1380
1385
|
}
|
|
1381
1386
|
if (i.stoppedAt) {
|
|
1382
|
-
const o =
|
|
1387
|
+
const o = R(n, "createdAt");
|
|
1383
1388
|
return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
|
|
1384
1389
|
}
|
|
1385
1390
|
return !1;
|
|
1386
1391
|
});
|
|
1387
1392
|
}
|
|
1388
1393
|
handleServerEvent(e) {
|
|
1389
|
-
if (
|
|
1394
|
+
if ($e("server_event", e.type, mt(e)), e.type === "session.subscribed") {
|
|
1390
1395
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1391
1396
|
if (s && n && s === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
|
|
1392
1397
|
const r = this.pendingSessionSubscription;
|
|
@@ -1399,14 +1404,14 @@ class Kt {
|
|
|
1399
1404
|
this.pendingSessionSubscription = null, s.resolve(!1), n && (this.sessionHistoryHydration = null, this.handleServerEvent({ ...e, requestId: n.requestId }));
|
|
1400
1405
|
return;
|
|
1401
1406
|
}
|
|
1402
|
-
if (this.sessionHistoryHydration &&
|
|
1407
|
+
if (this.sessionHistoryHydration && me(e) && G(e) === this.sessionHistoryHydration.sessionId) {
|
|
1403
1408
|
this.sessionHistoryHydration.bufferedEvents.push(e);
|
|
1404
1409
|
return;
|
|
1405
1410
|
}
|
|
1406
1411
|
if (e.type === "session.item" && this.rememberDurablyStoppedTurn(
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1412
|
+
R(e.item, "sessionId") ?? this.state.sessionId,
|
|
1413
|
+
P(e.item),
|
|
1414
|
+
R(e.item, "createdAt")
|
|
1410
1415
|
), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1411
1416
|
if (e.type === "run.ack" && typeof e.sessionId == "string" && typeof e.clientMessageId == "string" && this.detachedClientMessageIds.delete(e.clientMessageId) && e.sessionId !== this.state.sessionId) {
|
|
1412
1417
|
this.detachedSessionIds.add(e.sessionId), this.deferredDetachedSessionEvents.delete(e.sessionId);
|
|
@@ -1449,25 +1454,25 @@ class Kt {
|
|
|
1449
1454
|
this.activeResponseRunId = s, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
|
|
1450
1455
|
return;
|
|
1451
1456
|
}
|
|
1452
|
-
if (
|
|
1457
|
+
if (An(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
1453
1458
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
1454
|
-
const s =
|
|
1459
|
+
const s = ir(e.user);
|
|
1455
1460
|
this.authenticatedSocket !== this.socket && this.authenticatedUserId && s && s.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = s?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
1456
|
-
const n =
|
|
1457
|
-
|
|
1461
|
+
const n = er(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1462
|
+
A("web-sdk.agent", "Received auth.ok appearance", {
|
|
1458
1463
|
hasAppearance: r,
|
|
1459
1464
|
rawAppearance: e.appearance,
|
|
1460
1465
|
normalizedAppearance: n
|
|
1461
|
-
}), this.runtimeHelperJavascript =
|
|
1466
|
+
}), this.runtimeHelperJavascript = tr(e.runtimeHelpers)?.javascript ?? null;
|
|
1462
1467
|
const i = _t(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1463
1468
|
user: s,
|
|
1464
1469
|
status: "connected",
|
|
1465
1470
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1466
1471
|
};
|
|
1467
|
-
(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 && !
|
|
1472
|
+
(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 && !ye() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1468
1473
|
type: "page.upsert",
|
|
1469
1474
|
sessionId: this.state.sessionId,
|
|
1470
|
-
page:
|
|
1475
|
+
page: b(),
|
|
1471
1476
|
model: this.options.model
|
|
1472
1477
|
});
|
|
1473
1478
|
return;
|
|
@@ -1479,112 +1484,128 @@ class Kt {
|
|
|
1479
1484
|
});
|
|
1480
1485
|
return;
|
|
1481
1486
|
}
|
|
1487
|
+
if (e.type === "scheduled_follow_ups.updated") {
|
|
1488
|
+
typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
|
|
1489
|
+
activeScheduledFollowUps: Pt(
|
|
1490
|
+
e.activeScheduledFollowUps
|
|
1491
|
+
)
|
|
1492
|
+
});
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1482
1495
|
if (e.type === "conversation.state") {
|
|
1483
|
-
const s = Array.isArray(e.items) ? e.items : [], n =
|
|
1484
|
-
|
|
1496
|
+
const s = Array.isArray(e.items) ? e.items : [], n = Object.prototype.hasOwnProperty.call(
|
|
1497
|
+
e,
|
|
1498
|
+
"activeScheduledFollowUps"
|
|
1499
|
+
), r = R(e.session, "id") ?? this.state.sessionId, i = typeof e.requestId == "string" ? e.requestId : null, o = this.state.isLoadingSession && this.sessionLoadRequestId === null && i === null && r === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
|
|
1500
|
+
if (i && i !== this.sessionLoadRequestId || this.state.isLoadingSession && this.sessionLoadRequestId !== null && i === null || this.state.isLoadingSession && r !== this.state.sessionId)
|
|
1485
1501
|
return;
|
|
1486
|
-
this.updatePersonalModelFromSession(e.session),
|
|
1487
|
-
for (const
|
|
1502
|
+
this.updatePersonalModelFromSession(e.session), r === this.state.sessionId && this.clearSessionLoadRequest();
|
|
1503
|
+
for (const k of s)
|
|
1488
1504
|
this.rememberDurablyStoppedTurn(
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1505
|
+
r,
|
|
1506
|
+
P(k),
|
|
1507
|
+
R(k, "createdAt")
|
|
1492
1508
|
);
|
|
1493
|
-
const
|
|
1494
|
-
clientMessageId:
|
|
1495
|
-
respondsToUserMessageId:
|
|
1496
|
-
runId:
|
|
1497
|
-
}),
|
|
1498
|
-
|
|
1499
|
-
let
|
|
1509
|
+
const a = se(s), l = a === null ? null : s[a], c = P(l), d = this.findStoppedTurn(r, {
|
|
1510
|
+
clientMessageId: c?.clientMessageId,
|
|
1511
|
+
respondsToUserMessageId: R(l, "id"),
|
|
1512
|
+
runId: c?.runId
|
|
1513
|
+
}), h = this.filterStoppedSnapshotItems(s, r), m = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, f = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, u = e.isRetrying === !0, p = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1514
|
+
m && f && (this.pendingClientMessageId = f);
|
|
1515
|
+
let g = pr(
|
|
1500
1516
|
e.assistantDraft
|
|
1501
1517
|
);
|
|
1502
|
-
|
|
1503
|
-
respondsToUserMessageId:
|
|
1504
|
-
runId:
|
|
1505
|
-
}) && (
|
|
1506
|
-
const
|
|
1507
|
-
this.rememberUserMessageClientMessageIds(
|
|
1508
|
-
const
|
|
1509
|
-
if (
|
|
1510
|
-
const
|
|
1511
|
-
this.retryAttemptsByClientMessageId[
|
|
1512
|
-
this.retryAttemptsByClientMessageId[
|
|
1513
|
-
|
|
1518
|
+
g && this.findStoppedTurn(r, {
|
|
1519
|
+
respondsToUserMessageId: g.respondsToUserMessageId,
|
|
1520
|
+
runId: g.runId
|
|
1521
|
+
}) && (g = void 0);
|
|
1522
|
+
const y = g !== void 0;
|
|
1523
|
+
this.rememberUserMessageClientMessageIds(h);
|
|
1524
|
+
const M = Ur(h);
|
|
1525
|
+
if (M) {
|
|
1526
|
+
const k = vr(h, M);
|
|
1527
|
+
this.retryAttemptsByClientMessageId[M] = Math.max(
|
|
1528
|
+
this.retryAttemptsByClientMessageId[M] ?? 0,
|
|
1529
|
+
k
|
|
1514
1530
|
);
|
|
1515
1531
|
}
|
|
1516
|
-
const
|
|
1517
|
-
const O =
|
|
1518
|
-
return
|
|
1519
|
-
}),
|
|
1532
|
+
const w = h.filter((k) => {
|
|
1533
|
+
const O = P(k);
|
|
1534
|
+
return Dt(O) ? !1 : !O || !M || !Ee(O) ? !0 : Ze(h, O) !== M;
|
|
1535
|
+
}), U = Zt(
|
|
1520
1536
|
this.state.messages,
|
|
1521
|
-
|
|
1522
|
-
),
|
|
1523
|
-
(
|
|
1524
|
-
|
|
1525
|
-
S,
|
|
1537
|
+
Ut(w, this.options.backendUrl)
|
|
1538
|
+
), S = vt(U), T = y ? g?.content ?? "" : this.state.assistantDraft, N = y ? g?.itemId ?? null : this.state.assistantDraftItemId, _ = y ? g?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, ne = y ? g?.runId ?? null : this.state.assistantDraftRunId, $ = h.some(
|
|
1539
|
+
(k, O) => Ot(
|
|
1540
|
+
P(k),
|
|
1526
1541
|
T,
|
|
1527
1542
|
N,
|
|
1528
|
-
|
|
1529
|
-
|
|
1543
|
+
_,
|
|
1544
|
+
ne,
|
|
1545
|
+
Dr(h, O)
|
|
1530
1546
|
)
|
|
1531
|
-
),
|
|
1532
|
-
if (!
|
|
1547
|
+
), he = y ? g?.content ?? "" : this.state.assistantDraft, z = !!g?.content && !$, K = S && (!he || $), Q = br(U), Y = K && Q ? "completed" : d ? "stopped" : K ? "failed" : null;
|
|
1548
|
+
if (!S && Pr(this.state.messages, h))
|
|
1533
1549
|
return;
|
|
1534
|
-
this.lastUserMessagePageUrl =
|
|
1535
|
-
const
|
|
1536
|
-
if (this.latestRecoverableClientMessageId =
|
|
1537
|
-
sessionId:
|
|
1538
|
-
messages:
|
|
1550
|
+
this.lastUserMessagePageUrl = _r(h);
|
|
1551
|
+
const F = K || d ? null : Ye(h);
|
|
1552
|
+
if (this.latestRecoverableClientMessageId = F, Q && this.clearRetryTimers(), this.setState({
|
|
1553
|
+
sessionId: R(e.session, "id") ?? this.state.sessionId,
|
|
1554
|
+
messages: U,
|
|
1555
|
+
...n ? {
|
|
1556
|
+
activeScheduledFollowUps: Pt(
|
|
1557
|
+
e.activeScheduledFollowUps
|
|
1558
|
+
)
|
|
1559
|
+
} : {},
|
|
1539
1560
|
isLoadingSession: !1,
|
|
1540
|
-
...
|
|
1541
|
-
...
|
|
1542
|
-
isRetrying:
|
|
1543
|
-
...
|
|
1544
|
-
|
|
1561
|
+
...m ? { pendingMessageStatus: m } : {},
|
|
1562
|
+
...p ? { turnPhase: p } : {},
|
|
1563
|
+
isRetrying: u,
|
|
1564
|
+
...Y && this.state.taskStatus === "working" ? { taskStatus: Y } : {},
|
|
1565
|
+
...$ ? {
|
|
1545
1566
|
assistantDraft: "",
|
|
1546
1567
|
assistantDraftItemId: null,
|
|
1547
1568
|
assistantDraftPhase: null,
|
|
1548
1569
|
assistantDraftRespondsToUserMessageId: null,
|
|
1549
1570
|
assistantDraftRunId: null
|
|
1550
|
-
} :
|
|
1551
|
-
assistantDraft:
|
|
1552
|
-
assistantDraftItemId:
|
|
1553
|
-
assistantDraftPhase:
|
|
1554
|
-
assistantDraftRespondsToUserMessageId:
|
|
1555
|
-
assistantDraftRunId:
|
|
1571
|
+
} : y ? {
|
|
1572
|
+
assistantDraft: g?.content ?? "",
|
|
1573
|
+
assistantDraftItemId: g?.itemId ?? null,
|
|
1574
|
+
assistantDraftPhase: g?.phase ?? null,
|
|
1575
|
+
assistantDraftRespondsToUserMessageId: g?.respondsToUserMessageId ?? null,
|
|
1576
|
+
assistantDraftRunId: g?.runId ?? null
|
|
1556
1577
|
} : {},
|
|
1557
|
-
...
|
|
1578
|
+
...z ? {
|
|
1558
1579
|
isThinking: !0,
|
|
1559
1580
|
turnPhase: "thinking",
|
|
1560
1581
|
lastError: null
|
|
1561
|
-
} :
|
|
1582
|
+
} : K ? {
|
|
1562
1583
|
isThinking: !1,
|
|
1563
1584
|
status: "connected",
|
|
1564
1585
|
lastError: null,
|
|
1565
1586
|
lastErrorCode: null,
|
|
1566
1587
|
lastErrorSecuritySettingsUrl: null
|
|
1567
|
-
} :
|
|
1588
|
+
} : F ? {
|
|
1568
1589
|
isThinking: !0,
|
|
1569
|
-
turnPhase:
|
|
1590
|
+
turnPhase: p ?? this.state.turnPhase ?? "starting",
|
|
1570
1591
|
lastError: null
|
|
1571
1592
|
} : {}
|
|
1572
|
-
}),
|
|
1593
|
+
}), K)
|
|
1573
1594
|
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1574
|
-
else if (!
|
|
1575
|
-
if (
|
|
1576
|
-
this.activeClientMessageId =
|
|
1577
|
-
const
|
|
1578
|
-
this.activeResponseUserMessageId =
|
|
1595
|
+
else if (!d && (z || F)) {
|
|
1596
|
+
if (F) {
|
|
1597
|
+
this.activeClientMessageId = F;
|
|
1598
|
+
const k = se(h), O = k === null ? null : h[k];
|
|
1599
|
+
this.activeResponseUserMessageId = R(O, "id");
|
|
1579
1600
|
}
|
|
1580
1601
|
this.markThinkingProgress();
|
|
1581
1602
|
}
|
|
1582
|
-
if (
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1603
|
+
if (M) {
|
|
1604
|
+
const k = R(e.session, "id") ?? this.state.sessionId;
|
|
1605
|
+
k && this.retryAfterInterruptedRun(k, M);
|
|
1585
1606
|
}
|
|
1586
|
-
|
|
1587
|
-
this.autoLoadSessionActivity(
|
|
1607
|
+
o && r && window.setTimeout(() => {
|
|
1608
|
+
this.autoLoadSessionActivity(r);
|
|
1588
1609
|
}, 0);
|
|
1589
1610
|
return;
|
|
1590
1611
|
}
|
|
@@ -1592,19 +1613,19 @@ class Kt {
|
|
|
1592
1613
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1593
1614
|
if (!s || n !== this.state.sessionId)
|
|
1594
1615
|
return;
|
|
1595
|
-
const r =
|
|
1616
|
+
const r = Ut(
|
|
1596
1617
|
Array.isArray(e.items) ? e.items : [],
|
|
1597
1618
|
this.options.backendUrl
|
|
1598
1619
|
);
|
|
1599
1620
|
s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
1600
|
-
messages:
|
|
1621
|
+
messages: Mr(this.state.messages, r)
|
|
1601
1622
|
});
|
|
1602
1623
|
return;
|
|
1603
1624
|
}
|
|
1604
1625
|
if (e.type === "sessions.page") {
|
|
1605
1626
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1606
1627
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1607
|
-
sessions:
|
|
1628
|
+
sessions: or(e.sessions),
|
|
1608
1629
|
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1609
1630
|
}));
|
|
1610
1631
|
return;
|
|
@@ -1619,7 +1640,7 @@ class Kt {
|
|
|
1619
1640
|
}
|
|
1620
1641
|
if (e.type === "session.updated") {
|
|
1621
1642
|
this.clearRunAckResyncRetryTimer();
|
|
1622
|
-
const s =
|
|
1643
|
+
const s = R(e.session, "id");
|
|
1623
1644
|
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1624
1645
|
...this.pendingComposerWarmup.event,
|
|
1625
1646
|
sessionId: s
|
|
@@ -1630,10 +1651,10 @@ class Kt {
|
|
|
1630
1651
|
}
|
|
1631
1652
|
if (e.type === "session.item") {
|
|
1632
1653
|
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1633
|
-
const s =
|
|
1634
|
-
if (
|
|
1654
|
+
const s = P(e.item);
|
|
1655
|
+
if (Ee(s)) {
|
|
1635
1656
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1636
|
-
const r =
|
|
1657
|
+
const r = R(e.item, "sessionId") ?? this.state.sessionId, i = s ? L(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1637
1658
|
if (r && a) {
|
|
1638
1659
|
this.retryAfterInterruptedRun(r, a);
|
|
1639
1660
|
return;
|
|
@@ -1643,23 +1664,23 @@ class Kt {
|
|
|
1643
1664
|
return;
|
|
1644
1665
|
}
|
|
1645
1666
|
}
|
|
1646
|
-
if (
|
|
1667
|
+
if (Dt(s))
|
|
1647
1668
|
return;
|
|
1648
|
-
const n =
|
|
1669
|
+
const n = Yt(e.item, this.options.backendUrl);
|
|
1649
1670
|
if (n) {
|
|
1650
|
-
const r =
|
|
1651
|
-
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
1652
|
-
const o =
|
|
1671
|
+
const r = xr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1672
|
+
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), W(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), qr(s) && this.clearRunAckResyncRetryTimer();
|
|
1673
|
+
const o = Qe(this.state.messages, n), a = vt(o), l = Ot(
|
|
1653
1674
|
s,
|
|
1654
1675
|
this.state.assistantDraft,
|
|
1655
1676
|
this.state.assistantDraftItemId,
|
|
1656
1677
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
1657
1678
|
this.state.assistantDraftRunId,
|
|
1658
|
-
|
|
1679
|
+
rs(
|
|
1659
1680
|
o,
|
|
1660
|
-
o.findIndex((
|
|
1681
|
+
o.findIndex((h) => h.id === n.id)
|
|
1661
1682
|
)
|
|
1662
|
-
), c = a && (!this.state.assistantDraft || l), d =
|
|
1683
|
+
), c = a && (!this.state.assistantDraft || l), d = Re(n) && (c || W(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
1663
1684
|
this.setState({
|
|
1664
1685
|
messages: o,
|
|
1665
1686
|
...l ? {
|
|
@@ -1686,9 +1707,9 @@ class Kt {
|
|
|
1686
1707
|
}
|
|
1687
1708
|
if (e.type === "chat.assistant_delta") {
|
|
1688
1709
|
this.clearRunAckResyncRetryTimer();
|
|
1689
|
-
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((
|
|
1710
|
+
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((h) => h.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, d = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1690
1711
|
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = d), this.setState({
|
|
1691
|
-
messages:
|
|
1712
|
+
messages: Qe(this.state.messages, {
|
|
1692
1713
|
id: o,
|
|
1693
1714
|
role: "assistant",
|
|
1694
1715
|
content: i,
|
|
@@ -1717,9 +1738,9 @@ class Kt {
|
|
|
1717
1738
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null;
|
|
1718
1739
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1719
1740
|
return;
|
|
1720
|
-
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 =
|
|
1741
|
+
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 = Os(
|
|
1721
1742
|
this.state.messages.filter(
|
|
1722
|
-
(c) => c.dataType !== "assistant_draft" || !
|
|
1743
|
+
(c) => c.dataType !== "assistant_draft" || !Ke(
|
|
1723
1744
|
c,
|
|
1724
1745
|
n,
|
|
1725
1746
|
r
|
|
@@ -1727,11 +1748,11 @@ class Kt {
|
|
|
1727
1748
|
),
|
|
1728
1749
|
n,
|
|
1729
1750
|
r,
|
|
1730
|
-
|
|
1751
|
+
es
|
|
1731
1752
|
);
|
|
1732
1753
|
this.setState({
|
|
1733
1754
|
sessionId: s,
|
|
1734
|
-
messages:
|
|
1755
|
+
messages: yr(
|
|
1735
1756
|
l,
|
|
1736
1757
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
1737
1758
|
n,
|
|
@@ -1754,9 +1775,9 @@ class Kt {
|
|
|
1754
1775
|
if (s)
|
|
1755
1776
|
this.nonTranscriptToolCallIds.add(s);
|
|
1756
1777
|
else {
|
|
1757
|
-
const n =
|
|
1778
|
+
const n = Tr(e);
|
|
1758
1779
|
if (n) {
|
|
1759
|
-
const r =
|
|
1780
|
+
const r = Ir(
|
|
1760
1781
|
this.state.messages,
|
|
1761
1782
|
n
|
|
1762
1783
|
);
|
|
@@ -1817,20 +1838,20 @@ class Kt {
|
|
|
1817
1838
|
return;
|
|
1818
1839
|
}
|
|
1819
1840
|
o && r && i && (this.retryableClientMessageId = i);
|
|
1820
|
-
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l =
|
|
1841
|
+
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Hn(a.message);
|
|
1821
1842
|
l && console.error(l);
|
|
1822
|
-
const c = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null,
|
|
1843
|
+
const c = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null, h = qt(
|
|
1823
1844
|
this.state.messages,
|
|
1824
1845
|
c,
|
|
1825
1846
|
d
|
|
1826
|
-
), m =
|
|
1827
|
-
|
|
1847
|
+
), m = Cr(
|
|
1848
|
+
h,
|
|
1828
1849
|
c,
|
|
1829
1850
|
d
|
|
1830
1851
|
);
|
|
1831
1852
|
this.setState({
|
|
1832
1853
|
status: m ? "connected" : "error",
|
|
1833
|
-
messages:
|
|
1854
|
+
messages: h,
|
|
1834
1855
|
assistantDraft: "",
|
|
1835
1856
|
assistantDraftItemId: null,
|
|
1836
1857
|
assistantDraftPhase: null,
|
|
@@ -1852,22 +1873,22 @@ class Kt {
|
|
|
1852
1873
|
if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
|
|
1853
1874
|
return;
|
|
1854
1875
|
const s = e.metadata, n = s && typeof s == "object" ? s.model : void 0;
|
|
1855
|
-
this.options.model =
|
|
1876
|
+
this.options.model = He(n) ? n : "gpt-5.6-sol";
|
|
1856
1877
|
}
|
|
1857
1878
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1858
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1879
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !me(e))
|
|
1859
1880
|
return !1;
|
|
1860
1881
|
const s = G(e);
|
|
1861
1882
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1862
1883
|
}
|
|
1863
1884
|
shouldIgnoreDetachedSessionEvent(e) {
|
|
1864
|
-
if (this.options.keepRunsActiveOnSessionNavigation || !
|
|
1885
|
+
if (this.options.keepRunsActiveOnSessionNavigation || !me(e))
|
|
1865
1886
|
return !1;
|
|
1866
1887
|
const s = G(e);
|
|
1867
1888
|
return !!(s && this.detachedSessionIds.has(s));
|
|
1868
1889
|
}
|
|
1869
1890
|
shouldDeferDetachedSessionEvent(e) {
|
|
1870
|
-
if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !
|
|
1891
|
+
if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !me(e))
|
|
1871
1892
|
return !1;
|
|
1872
1893
|
const s = G(e);
|
|
1873
1894
|
if (!s || s === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(s))
|
|
@@ -1892,7 +1913,7 @@ class Kt {
|
|
|
1892
1913
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1893
1914
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1894
1915
|
return !1;
|
|
1895
|
-
if (
|
|
1916
|
+
if (ye())
|
|
1896
1917
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1897
1918
|
if (e.code === "run_still_active") {
|
|
1898
1919
|
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) {
|
|
@@ -1906,10 +1927,10 @@ class Kt {
|
|
|
1906
1927
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1907
1928
|
return !0;
|
|
1908
1929
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1909
|
-
if (i >=
|
|
1930
|
+
if (i >= ae)
|
|
1910
1931
|
return !1;
|
|
1911
1932
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1912
|
-
const o =
|
|
1933
|
+
const o = le(
|
|
1913
1934
|
i,
|
|
1914
1935
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1915
1936
|
);
|
|
@@ -1923,20 +1944,20 @@ class Kt {
|
|
|
1923
1944
|
}, o), !0;
|
|
1924
1945
|
}
|
|
1925
1946
|
retryAfterInterruptedRun(e, s) {
|
|
1926
|
-
if (
|
|
1947
|
+
if (ye()) {
|
|
1927
1948
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1928
1949
|
return;
|
|
1929
1950
|
}
|
|
1930
1951
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1931
1952
|
return;
|
|
1932
1953
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1933
|
-
if (n >=
|
|
1954
|
+
if (n >= ae) {
|
|
1934
1955
|
this.requestSessionRecoveryExhaustion(e, s);
|
|
1935
1956
|
return;
|
|
1936
1957
|
}
|
|
1937
1958
|
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(() => {
|
|
1938
1959
|
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 });
|
|
1939
|
-
},
|
|
1960
|
+
}, le(n));
|
|
1940
1961
|
}
|
|
1941
1962
|
requestSessionRecoveryExhaustion(e, s) {
|
|
1942
1963
|
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(Tt);
|
|
@@ -1948,10 +1969,10 @@ class Kt {
|
|
|
1948
1969
|
}
|
|
1949
1970
|
rememberUserMessageClientMessageIds(e) {
|
|
1950
1971
|
for (const s of e) {
|
|
1951
|
-
const n =
|
|
1972
|
+
const n = R(s, "id"), r = P(s);
|
|
1952
1973
|
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(
|
|
1953
1974
|
r.clientMessageId,
|
|
1954
|
-
|
|
1975
|
+
R(s, "sessionId") ?? this.state.sessionId,
|
|
1955
1976
|
n,
|
|
1956
1977
|
null
|
|
1957
1978
|
), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
|
|
@@ -2037,7 +2058,7 @@ class Kt {
|
|
|
2037
2058
|
}), this.markThinkingProgress();
|
|
2038
2059
|
}
|
|
2039
2060
|
schedulePendingDeliveryAck(e) {
|
|
2040
|
-
this.clearPendingDeliveryTimers(), !
|
|
2061
|
+
this.clearPendingDeliveryTimers(), !ye() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
2041
2062
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
2042
2063
|
}, Mt));
|
|
2043
2064
|
}
|
|
@@ -2045,13 +2066,13 @@ class Kt {
|
|
|
2045
2066
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
2046
2067
|
return;
|
|
2047
2068
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
2048
|
-
if (s >=
|
|
2069
|
+
if (s >= ae) {
|
|
2049
2070
|
this.failPendingDelivery(e);
|
|
2050
2071
|
return;
|
|
2051
2072
|
}
|
|
2052
2073
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
2053
2074
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
2054
|
-
},
|
|
2075
|
+
}, le(s, At));
|
|
2055
2076
|
}
|
|
2056
2077
|
failPendingDelivery(e) {
|
|
2057
2078
|
if (this.pendingClientMessageId !== e)
|
|
@@ -2063,7 +2084,7 @@ class Kt {
|
|
|
2063
2084
|
...this.state.isThinking ? {} : { turnPhase: null },
|
|
2064
2085
|
isRetrying: !1,
|
|
2065
2086
|
...this.state.isThinking ? {} : { taskStatus: "failed" },
|
|
2066
|
-
lastError:
|
|
2087
|
+
lastError: un,
|
|
2067
2088
|
lastErrorCode: "message_delivery_failed"
|
|
2068
2089
|
});
|
|
2069
2090
|
}
|
|
@@ -2078,7 +2099,7 @@ class Kt {
|
|
|
2078
2099
|
s,
|
|
2079
2100
|
typeof e.runId == "string" ? e.runId : null
|
|
2080
2101
|
), !(!this.state.isThinking || !s) && this.setState({
|
|
2081
|
-
messages:
|
|
2102
|
+
messages: Wr(
|
|
2082
2103
|
this.state.messages,
|
|
2083
2104
|
s
|
|
2084
2105
|
)
|
|
@@ -2090,7 +2111,7 @@ class Kt {
|
|
|
2090
2111
|
}, Mt);
|
|
2091
2112
|
}
|
|
2092
2113
|
recoverMissedRunAck(e) {
|
|
2093
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (
|
|
2114
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (A("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
2094
2115
|
sessionId: this.state.sessionId,
|
|
2095
2116
|
clientMessageId: e
|
|
2096
2117
|
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(e));
|
|
@@ -2098,12 +2119,12 @@ class Kt {
|
|
|
2098
2119
|
scheduleRunAckResyncRetry(e) {
|
|
2099
2120
|
this.clearRunAckResyncRetryTimer();
|
|
2100
2121
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
2101
|
-
s >=
|
|
2122
|
+
s >= ae || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
2102
2123
|
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({
|
|
2103
2124
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
2104
2125
|
isThinking: !0,
|
|
2105
2126
|
lastError: null
|
|
2106
|
-
}),
|
|
2127
|
+
}), A("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
2107
2128
|
sessionId: this.state.sessionId,
|
|
2108
2129
|
clientMessageId: e
|
|
2109
2130
|
}), this.state.sessionId ? this.send({
|
|
@@ -2112,7 +2133,7 @@ class Kt {
|
|
|
2112
2133
|
clientMessageId: e,
|
|
2113
2134
|
automatic: !0
|
|
2114
2135
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(St)));
|
|
2115
|
-
},
|
|
2136
|
+
}, le(s, At)));
|
|
2116
2137
|
}
|
|
2117
2138
|
clearRunAckResyncRetryTimer() {
|
|
2118
2139
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -2125,7 +2146,7 @@ class Kt {
|
|
|
2125
2146
|
return;
|
|
2126
2147
|
const e = this.activeClientMessageId;
|
|
2127
2148
|
if (!e) {
|
|
2128
|
-
|
|
2149
|
+
A("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
2129
2150
|
sessionId: this.state.sessionId
|
|
2130
2151
|
}), this.reportHealthSignal("run_recovery_exhausted", {
|
|
2131
2152
|
reason: "missing_client_message_id"
|
|
@@ -2141,8 +2162,8 @@ class Kt {
|
|
|
2141
2162
|
return;
|
|
2142
2163
|
}
|
|
2143
2164
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
2144
|
-
if (n >=
|
|
2145
|
-
|
|
2165
|
+
if (n >= ae) {
|
|
2166
|
+
A("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
2146
2167
|
sessionId: this.state.sessionId,
|
|
2147
2168
|
clientMessageId: e
|
|
2148
2169
|
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
@@ -2154,7 +2175,7 @@ class Kt {
|
|
|
2154
2175
|
return;
|
|
2155
2176
|
}
|
|
2156
2177
|
if (s < 1) {
|
|
2157
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1,
|
|
2178
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1, A("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
2158
2179
|
sessionId: this.state.sessionId,
|
|
2159
2180
|
clientMessageId: e,
|
|
2160
2181
|
resyncAttempts: s + 1
|
|
@@ -2165,7 +2186,7 @@ class Kt {
|
|
|
2165
2186
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
2166
2187
|
isThinking: !0,
|
|
2167
2188
|
lastError: null
|
|
2168
|
-
}),
|
|
2189
|
+
}), A("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
2169
2190
|
sessionId: this.state.sessionId,
|
|
2170
2191
|
clientMessageId: e,
|
|
2171
2192
|
retryAttempts: n + 1
|
|
@@ -2176,24 +2197,24 @@ class Kt {
|
|
|
2176
2197
|
clientMessageId: e,
|
|
2177
2198
|
automatic: !0
|
|
2178
2199
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
2179
|
-
},
|
|
2200
|
+
}, le(n)));
|
|
2180
2201
|
}
|
|
2181
2202
|
resyncThinkingSession() {
|
|
2182
2203
|
this.state.sessionId ? this.send({
|
|
2183
2204
|
type: "page.upsert",
|
|
2184
2205
|
sessionId: this.state.sessionId,
|
|
2185
|
-
page:
|
|
2206
|
+
page: b(),
|
|
2186
2207
|
model: this.options.model
|
|
2187
2208
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
2188
2209
|
}
|
|
2189
2210
|
async executeToolCall(e) {
|
|
2190
|
-
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 =
|
|
2211
|
+
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 = ee(
|
|
2191
2212
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
2192
2213
|
), o = e.rawInput;
|
|
2193
2214
|
if (!s || !n || !r)
|
|
2194
2215
|
return;
|
|
2195
2216
|
const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
2196
|
-
if (!a && !l || !
|
|
2217
|
+
if (!a && !l || !oi(o)) {
|
|
2197
2218
|
this.setToolMessageLoading(n, !1), this.send({
|
|
2198
2219
|
type: "tool.result",
|
|
2199
2220
|
sessionId: s,
|
|
@@ -2242,11 +2263,11 @@ class Kt {
|
|
|
2242
2263
|
let c = null, d;
|
|
2243
2264
|
c = await this.executeRuntimeHelper(), d = await Ct(
|
|
2244
2265
|
o,
|
|
2245
|
-
|
|
2246
|
-
).catch((
|
|
2266
|
+
Ln(e.runtimeContext, this.options.backendUrl)
|
|
2267
|
+
).catch((h) => ({
|
|
2247
2268
|
ok: !1,
|
|
2248
2269
|
exception: {
|
|
2249
|
-
message:
|
|
2270
|
+
message: h instanceof Error ? h.message : String(h)
|
|
2250
2271
|
}
|
|
2251
2272
|
})), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
2252
2273
|
type: "tool.result",
|
|
@@ -2255,11 +2276,11 @@ class Kt {
|
|
|
2255
2276
|
toolName: r,
|
|
2256
2277
|
summary: o.summary,
|
|
2257
2278
|
rawInput: q(o),
|
|
2258
|
-
rawOutput: q(
|
|
2259
|
-
}),
|
|
2279
|
+
rawOutput: q(sr(d, c))
|
|
2280
|
+
}), Nt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
2260
2281
|
}
|
|
2261
2282
|
setToolMessageLoading(e, s) {
|
|
2262
|
-
const n =
|
|
2283
|
+
const n = Sr(
|
|
2263
2284
|
this.state.messages,
|
|
2264
2285
|
e,
|
|
2265
2286
|
s
|
|
@@ -2270,17 +2291,17 @@ class Kt {
|
|
|
2270
2291
|
if (this.pageLifecycleCleanup)
|
|
2271
2292
|
return;
|
|
2272
2293
|
const e = () => {
|
|
2273
|
-
|
|
2294
|
+
as(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
2274
2295
|
};
|
|
2275
2296
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
2276
2297
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
2277
2298
|
};
|
|
2278
2299
|
}
|
|
2279
2300
|
installSessionBrowserApis() {
|
|
2280
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
2301
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = kn();
|
|
2281
2302
|
}
|
|
2282
2303
|
cleanupSessionBrowserApis() {
|
|
2283
|
-
this.sessionBrowserApisCleanup && (
|
|
2304
|
+
this.sessionBrowserApisCleanup && (On(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
2284
2305
|
}
|
|
2285
2306
|
async executeRuntimeHelper() {
|
|
2286
2307
|
if (!this.runtimeHelperJavascript?.trim())
|
|
@@ -2288,32 +2309,32 @@ class Kt {
|
|
|
2288
2309
|
const e = await Ct({
|
|
2289
2310
|
javascript: this.runtimeHelperJavascript
|
|
2290
2311
|
});
|
|
2291
|
-
return e.ok === !1 ?
|
|
2312
|
+
return e.ok === !1 ? nr(e) : null;
|
|
2292
2313
|
}
|
|
2293
2314
|
enableNetworkCapture() {
|
|
2294
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
2295
|
-
|
|
2315
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = wn((e) => {
|
|
2316
|
+
hi(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
2296
2317
|
}));
|
|
2297
2318
|
}
|
|
2298
2319
|
enqueueNetworkEvent(e) {
|
|
2299
|
-
this.queuedNetworkEvents.length >=
|
|
2320
|
+
this.queuedNetworkEvents.length >= hn || (this.queuedNetworkEvents.push(di(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
2300
2321
|
this.networkBatchTimer = null;
|
|
2301
2322
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
2302
2323
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
2303
2324
|
type: "network.batch",
|
|
2304
2325
|
sessionId: this.state.sessionId ?? void 0,
|
|
2305
|
-
page:
|
|
2326
|
+
page: b(),
|
|
2306
2327
|
events: s
|
|
2307
2328
|
});
|
|
2308
|
-
},
|
|
2329
|
+
}, dn)));
|
|
2309
2330
|
}
|
|
2310
2331
|
scheduleReconnect() {
|
|
2311
2332
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
2312
2333
|
return;
|
|
2313
|
-
const e =
|
|
2334
|
+
const e = Sn(this.reconnectAttempts);
|
|
2314
2335
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
2315
2336
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
2316
|
-
|
|
2337
|
+
A("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
2317
2338
|
message: s instanceof Error ? s.message : String(s),
|
|
2318
2339
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
2319
2340
|
isThinking: this.state.isThinking
|
|
@@ -2325,9 +2346,9 @@ class Kt {
|
|
|
2325
2346
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
2326
2347
|
const e = this.socket;
|
|
2327
2348
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
2328
|
-
this.socket === e && (
|
|
2329
|
-
},
|
|
2330
|
-
},
|
|
2349
|
+
this.socket === e && (A("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
2350
|
+
}, sn));
|
|
2351
|
+
}, tn);
|
|
2331
2352
|
}
|
|
2332
2353
|
stopHeartbeat() {
|
|
2333
2354
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -2365,7 +2386,7 @@ class Kt {
|
|
|
2365
2386
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2366
2387
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2367
2388
|
};
|
|
2368
|
-
this.state = o,
|
|
2389
|
+
this.state = o, Vr(this.options.clientId, this.state), this.emit("state", this.getState()), $e("state", this.state.status, {
|
|
2369
2390
|
status: this.state.status,
|
|
2370
2391
|
sessionId: this.state.sessionId,
|
|
2371
2392
|
messageCount: this.state.messages.length,
|
|
@@ -2388,13 +2409,13 @@ class Kt {
|
|
|
2388
2409
|
}
|
|
2389
2410
|
}
|
|
2390
2411
|
const je = /* @__PURE__ */ new WeakMap();
|
|
2391
|
-
function
|
|
2392
|
-
const e = window.__plunoProductAgentNetworkCapture ??
|
|
2412
|
+
function wn(t) {
|
|
2413
|
+
const e = window.__plunoProductAgentNetworkCapture ?? Mn();
|
|
2393
2414
|
return e.subscribers.add(t), () => {
|
|
2394
2415
|
e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
2395
2416
|
};
|
|
2396
2417
|
}
|
|
2397
|
-
function
|
|
2418
|
+
function Mn() {
|
|
2398
2419
|
const t = /* @__PURE__ */ new Set(), e = (m) => {
|
|
2399
2420
|
t.forEach((f) => {
|
|
2400
2421
|
try {
|
|
@@ -2403,7 +2424,7 @@ function wn() {
|
|
|
2403
2424
|
}
|
|
2404
2425
|
});
|
|
2405
2426
|
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, u) {
|
|
2406
|
-
const
|
|
2427
|
+
const p = Date.now();
|
|
2407
2428
|
let g;
|
|
2408
2429
|
try {
|
|
2409
2430
|
g = s.call(this, f, u);
|
|
@@ -2411,32 +2432,32 @@ function wn() {
|
|
|
2411
2432
|
throw y;
|
|
2412
2433
|
}
|
|
2413
2434
|
try {
|
|
2414
|
-
const y = f instanceof Request ? f : null,
|
|
2415
|
-
if (!
|
|
2416
|
-
const
|
|
2417
|
-
requestId:
|
|
2418
|
-
url:
|
|
2435
|
+
const y = f instanceof Request ? f : null, M = ai(f, y), w = ds(u?.headers ?? y?.headers);
|
|
2436
|
+
if (!Z(M, w, u?.body)) {
|
|
2437
|
+
const U = {
|
|
2438
|
+
requestId: Ge("fetch"),
|
|
2439
|
+
url: B(M, Fe),
|
|
2419
2440
|
method: (u?.method ?? y?.method ?? "GET").toUpperCase(),
|
|
2420
2441
|
requestHeaders: w,
|
|
2421
|
-
requestBody:
|
|
2442
|
+
requestBody: Bt(u?.body),
|
|
2422
2443
|
resourceType: "fetch",
|
|
2423
|
-
startedAt: new Date(
|
|
2444
|
+
startedAt: new Date(p).toISOString()
|
|
2424
2445
|
};
|
|
2425
2446
|
g.then(
|
|
2426
2447
|
(S) => {
|
|
2427
|
-
|
|
2448
|
+
li(S, U, p, e).catch(() => {
|
|
2428
2449
|
e({
|
|
2429
|
-
...
|
|
2450
|
+
...U,
|
|
2430
2451
|
responseStatus: S.status,
|
|
2431
|
-
durationMs: Date.now() -
|
|
2452
|
+
durationMs: Date.now() - p
|
|
2432
2453
|
});
|
|
2433
2454
|
});
|
|
2434
2455
|
},
|
|
2435
2456
|
(S) => {
|
|
2436
2457
|
e({
|
|
2437
|
-
...
|
|
2438
|
-
errorText:
|
|
2439
|
-
durationMs: Date.now() -
|
|
2458
|
+
...U,
|
|
2459
|
+
errorText: B(S instanceof Error ? S.message : String(S)),
|
|
2460
|
+
durationMs: Date.now() - p
|
|
2440
2461
|
});
|
|
2441
2462
|
}
|
|
2442
2463
|
);
|
|
@@ -2444,29 +2465,29 @@ function wn() {
|
|
|
2444
2465
|
} catch {
|
|
2445
2466
|
}
|
|
2446
2467
|
return g;
|
|
2447
|
-
}, a = function(f, u,
|
|
2448
|
-
const
|
|
2468
|
+
}, a = function(f, u, p, g, y) {
|
|
2469
|
+
const M = n.call(this, f, u, p ?? !0, g ?? void 0, y ?? void 0), w = typeof u == "string" ? u : u.toString();
|
|
2449
2470
|
return je.set(this, {
|
|
2450
|
-
requestId:
|
|
2471
|
+
requestId: Ge("xhr"),
|
|
2451
2472
|
method: String(f ?? "GET").toUpperCase(),
|
|
2452
|
-
url:
|
|
2473
|
+
url: B(w, Fe),
|
|
2453
2474
|
requestHeaders: {},
|
|
2454
2475
|
startedAtMs: Date.now(),
|
|
2455
2476
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2456
|
-
excluded:
|
|
2457
|
-
}),
|
|
2477
|
+
excluded: Z(w)
|
|
2478
|
+
}), M;
|
|
2458
2479
|
}, l = function(f, u) {
|
|
2459
|
-
const
|
|
2460
|
-
return g && Object.keys(g.requestHeaders).length <
|
|
2480
|
+
const p = r.call(this, f, u), g = je.get(this);
|
|
2481
|
+
return g && Object.keys(g.requestHeaders).length < ot && (g.requestHeaders[f] = ct(f, u), g.excluded = g.excluded || Z(g.url, g.requestHeaders)), p;
|
|
2461
2482
|
}, c = function(f) {
|
|
2462
2483
|
try {
|
|
2463
2484
|
const u = je.get(this);
|
|
2464
|
-
u && (u.excluded = u.excluded ||
|
|
2485
|
+
u && (u.excluded = u.excluded || Z(u.url, u.requestHeaders, f), u.requestBody = Bt(f), u.excluded || this.addEventListener(
|
|
2465
2486
|
"loadend",
|
|
2466
2487
|
() => {
|
|
2467
2488
|
queueMicrotask(() => {
|
|
2468
2489
|
try {
|
|
2469
|
-
const
|
|
2490
|
+
const p = gi(this.getAllResponseHeaders());
|
|
2470
2491
|
e({
|
|
2471
2492
|
requestId: u.requestId,
|
|
2472
2493
|
url: u.url,
|
|
@@ -2475,8 +2496,8 @@ function wn() {
|
|
|
2475
2496
|
requestBody: u.requestBody,
|
|
2476
2497
|
resourceType: "xhr",
|
|
2477
2498
|
responseStatus: this.status,
|
|
2478
|
-
responseHeaders:
|
|
2479
|
-
responseBody:
|
|
2499
|
+
responseHeaders: p,
|
|
2500
|
+
responseBody: ui(this, p),
|
|
2480
2501
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2481
2502
|
startedAt: u.startedAt,
|
|
2482
2503
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -2513,16 +2534,16 @@ function wn() {
|
|
|
2513
2534
|
d = new PerformanceObserver((m) => {
|
|
2514
2535
|
for (const f of m.getEntries()) {
|
|
2515
2536
|
const u = f;
|
|
2516
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
2537
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || Z(u.name))
|
|
2517
2538
|
continue;
|
|
2518
|
-
const
|
|
2539
|
+
const p = performance.timeOrigin + u.startTime;
|
|
2519
2540
|
e({
|
|
2520
|
-
requestId:
|
|
2521
|
-
url:
|
|
2541
|
+
requestId: Ge("resource"),
|
|
2542
|
+
url: B(u.name, Fe),
|
|
2522
2543
|
method: "GET",
|
|
2523
2544
|
resourceType: "resource",
|
|
2524
2545
|
responseStatus: u.responseStatus,
|
|
2525
|
-
startedAt: new Date(
|
|
2546
|
+
startedAt: new Date(p).toISOString(),
|
|
2526
2547
|
durationMs: u.duration
|
|
2527
2548
|
});
|
|
2528
2549
|
}
|
|
@@ -2533,7 +2554,7 @@ function wn() {
|
|
|
2533
2554
|
d.disconnect(), d = null;
|
|
2534
2555
|
}
|
|
2535
2556
|
}
|
|
2536
|
-
const
|
|
2557
|
+
const h = {
|
|
2537
2558
|
subscribers: t,
|
|
2538
2559
|
destroy: () => {
|
|
2539
2560
|
d?.disconnect();
|
|
@@ -2555,9 +2576,9 @@ function wn() {
|
|
|
2555
2576
|
}
|
|
2556
2577
|
}
|
|
2557
2578
|
};
|
|
2558
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
2579
|
+
return window.__plunoProductAgentNetworkCapture = h, h;
|
|
2559
2580
|
}
|
|
2560
|
-
function
|
|
2581
|
+
function A(t, e, s) {
|
|
2561
2582
|
if (typeof window > "u")
|
|
2562
2583
|
return;
|
|
2563
2584
|
const n = window, r = {
|
|
@@ -2572,11 +2593,11 @@ function kt(t) {
|
|
|
2572
2593
|
const e = typeof t == "function" ? t() : t;
|
|
2573
2594
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2574
2595
|
}
|
|
2575
|
-
function
|
|
2596
|
+
function An(t) {
|
|
2576
2597
|
return t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call";
|
|
2577
2598
|
}
|
|
2578
|
-
function
|
|
2579
|
-
return t.type === "run.steered" || t.type === "run.ack" || t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
|
|
2599
|
+
function me(t) {
|
|
2600
|
+
return t.type === "run.steered" || t.type === "run.ack" || t.type === "run.model_started" || t.type === "conversation.state" || t.type === "scheduled_follow_ups.updated" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
|
|
2580
2601
|
}
|
|
2581
2602
|
function G(t) {
|
|
2582
2603
|
if (typeof t.sessionId == "string")
|
|
@@ -2593,31 +2614,31 @@ function G(t) {
|
|
|
2593
2614
|
}
|
|
2594
2615
|
return null;
|
|
2595
2616
|
}
|
|
2596
|
-
const
|
|
2597
|
-
function
|
|
2617
|
+
const Rn = 5e3, En = 12e4;
|
|
2618
|
+
function kn() {
|
|
2598
2619
|
const t = [
|
|
2599
|
-
|
|
2600
|
-
|
|
2620
|
+
bn(),
|
|
2621
|
+
Cn()
|
|
2601
2622
|
].filter((e) => typeof e == "function");
|
|
2602
2623
|
return () => {
|
|
2603
2624
|
for (const e of t.reverse())
|
|
2604
2625
|
e();
|
|
2605
2626
|
};
|
|
2606
2627
|
}
|
|
2607
|
-
function kn() {
|
|
2608
|
-
return Wt(globalThis, "getPageSnapshot", async () => ot());
|
|
2609
|
-
}
|
|
2610
2628
|
function Cn() {
|
|
2611
|
-
return
|
|
2612
|
-
|
|
2629
|
+
return Ht(globalThis, "getPageSnapshot", async () => at());
|
|
2630
|
+
}
|
|
2631
|
+
function bn() {
|
|
2632
|
+
return Ht(globalThis, "pageImages", {
|
|
2633
|
+
inspectImage: async (e, s) => await _n(e, s)
|
|
2613
2634
|
});
|
|
2614
2635
|
}
|
|
2615
|
-
async function
|
|
2616
|
-
const s =
|
|
2636
|
+
async function _n(t, e = {}) {
|
|
2637
|
+
const s = Dn(e.name), n = await Pn(t);
|
|
2617
2638
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2618
2639
|
type: "pluno.pageImages.inspectImage",
|
|
2619
2640
|
imageAttached: !1,
|
|
2620
|
-
imageAttachmentError:
|
|
2641
|
+
imageAttachmentError: zt
|
|
2621
2642
|
} : {
|
|
2622
2643
|
type: "pluno.pageImages.inspectImage",
|
|
2623
2644
|
imageAttached: !0,
|
|
@@ -2631,15 +2652,15 @@ async function bn(t, e = {}) {
|
|
|
2631
2652
|
imageAttachmentError: n.error
|
|
2632
2653
|
};
|
|
2633
2654
|
}
|
|
2634
|
-
async function
|
|
2635
|
-
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error:
|
|
2655
|
+
async function Pn(t) {
|
|
2656
|
+
return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: zt } : {
|
|
2636
2657
|
ok: !0,
|
|
2637
2658
|
mimeType: t.type,
|
|
2638
2659
|
sizeBytes: t.size,
|
|
2639
|
-
dataUrl: await
|
|
2640
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
2660
|
+
dataUrl: await qn(t)
|
|
2661
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Un(t);
|
|
2641
2662
|
}
|
|
2642
|
-
function
|
|
2663
|
+
function Un(t) {
|
|
2643
2664
|
if (!t.startsWith("data:") || !t.includes(","))
|
|
2644
2665
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
2645
2666
|
const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -2650,7 +2671,7 @@ function Pn(t) {
|
|
|
2650
2671
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
2651
2672
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
2652
2673
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
2653
|
-
const o =
|
|
2674
|
+
const o = vn(i);
|
|
2654
2675
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
2655
2676
|
ok: !0,
|
|
2656
2677
|
mimeType: r,
|
|
@@ -2658,22 +2679,22 @@ function Pn(t) {
|
|
|
2658
2679
|
dataUrl: `data:${r};base64,${i}`
|
|
2659
2680
|
};
|
|
2660
2681
|
}
|
|
2661
|
-
function
|
|
2682
|
+
function vn(t) {
|
|
2662
2683
|
if (t.length === 0 || t.length % 4 !== 0)
|
|
2663
2684
|
return null;
|
|
2664
2685
|
const e = t.length - t.replace(/=+$/, "").length;
|
|
2665
2686
|
return e > 2 ? null : t.length / 4 * 3 - e;
|
|
2666
2687
|
}
|
|
2667
|
-
function
|
|
2688
|
+
function Dn(t) {
|
|
2668
2689
|
return (typeof t == "string" ? t.trim() : "") || "Page image";
|
|
2669
2690
|
}
|
|
2670
|
-
function
|
|
2691
|
+
function On(t) {
|
|
2671
2692
|
try {
|
|
2672
2693
|
t();
|
|
2673
2694
|
} catch {
|
|
2674
2695
|
}
|
|
2675
2696
|
}
|
|
2676
|
-
function
|
|
2697
|
+
function qn(t) {
|
|
2677
2698
|
return new Promise((e, s) => {
|
|
2678
2699
|
const n = new FileReader();
|
|
2679
2700
|
n.onload = () => {
|
|
@@ -2687,7 +2708,7 @@ function On(t) {
|
|
|
2687
2708
|
}
|
|
2688
2709
|
async function Ct(t, e) {
|
|
2689
2710
|
const s = Object.getPrototypeOf(async function() {
|
|
2690
|
-
}).constructor, n = t.timeoutMs ??
|
|
2711
|
+
}).constructor, n = t.timeoutMs ?? Rn, r = Date.now(), i = [];
|
|
2691
2712
|
let o;
|
|
2692
2713
|
const a = {
|
|
2693
2714
|
log: console.log,
|
|
@@ -2701,11 +2722,11 @@ async function Ct(t, e) {
|
|
|
2701
2722
|
try {
|
|
2702
2723
|
const c = /* @__PURE__ */ Symbol("execute_code_timeout"), d = await Promise.race([
|
|
2703
2724
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
2704
|
-
new Promise((
|
|
2705
|
-
o = window.setTimeout(() =>
|
|
2725
|
+
new Promise((h) => {
|
|
2726
|
+
o = window.setTimeout(() => h(c), n);
|
|
2706
2727
|
})
|
|
2707
2728
|
]);
|
|
2708
|
-
return d === c ?
|
|
2729
|
+
return d === c ? Nn(n) : {
|
|
2709
2730
|
ok: !0,
|
|
2710
2731
|
result: d,
|
|
2711
2732
|
console: i,
|
|
@@ -2734,7 +2755,7 @@ async function Ct(t, e) {
|
|
|
2734
2755
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2735
2756
|
}
|
|
2736
2757
|
}
|
|
2737
|
-
function
|
|
2758
|
+
function Ln(t, e) {
|
|
2738
2759
|
if (!t || typeof t != "object")
|
|
2739
2760
|
return;
|
|
2740
2761
|
const s = t.sandboxFilesToken;
|
|
@@ -2744,7 +2765,7 @@ function qn(t, e) {
|
|
|
2744
2765
|
const r = () => {
|
|
2745
2766
|
if (!n)
|
|
2746
2767
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
2747
|
-
}, i = async (a, l) => await
|
|
2768
|
+
}, i = async (a, l) => await Vs(`${e.replace(/\/$/, "")}${a}`, l);
|
|
2748
2769
|
return {
|
|
2749
2770
|
value: Object.freeze({
|
|
2750
2771
|
upload: async (a) => {
|
|
@@ -2767,8 +2788,8 @@ function qn(t, e) {
|
|
|
2767
2788
|
);
|
|
2768
2789
|
if (!l.ok)
|
|
2769
2790
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
2770
|
-
const c = await l.blob(),
|
|
2771
|
-
return new File([c],
|
|
2791
|
+
const c = await l.blob(), h = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
2792
|
+
return new File([c], h || a.split("/").pop() || "file", {
|
|
2772
2793
|
type: c.type
|
|
2773
2794
|
});
|
|
2774
2795
|
}
|
|
@@ -2778,7 +2799,7 @@ function qn(t, e) {
|
|
|
2778
2799
|
}
|
|
2779
2800
|
};
|
|
2780
2801
|
}
|
|
2781
|
-
function
|
|
2802
|
+
function Nn(t) {
|
|
2782
2803
|
return {
|
|
2783
2804
|
ok: !1,
|
|
2784
2805
|
exception: {
|
|
@@ -2792,10 +2813,10 @@ function Ln(t) {
|
|
|
2792
2813
|
}
|
|
2793
2814
|
};
|
|
2794
2815
|
}
|
|
2795
|
-
function
|
|
2816
|
+
function xn(t) {
|
|
2796
2817
|
return t.replace(/\/+$/, "");
|
|
2797
2818
|
}
|
|
2798
|
-
function
|
|
2819
|
+
function Bn(t) {
|
|
2799
2820
|
const e = {
|
|
2800
2821
|
sidepanel: "extension_sidepanel",
|
|
2801
2822
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -2807,18 +2828,18 @@ function xn(t) {
|
|
|
2807
2828
|
};
|
|
2808
2829
|
return t && t in e ? e[t] : t ?? "embedded_custom_ui";
|
|
2809
2830
|
}
|
|
2810
|
-
function
|
|
2831
|
+
function Wn(t) {
|
|
2811
2832
|
return t === "pluno" ? "scheduled_continuation" : t ?? "user";
|
|
2812
2833
|
}
|
|
2813
|
-
function
|
|
2834
|
+
function Hn(t, e = location.origin) {
|
|
2814
2835
|
return /origin (?:is not allowed|does not match browser origin)/i.test(t) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
|
|
2815
2836
|
}
|
|
2816
|
-
function
|
|
2837
|
+
function $n(t) {
|
|
2817
2838
|
const e = new URL("/api/product-agent/embed/ws", t);
|
|
2818
2839
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2819
2840
|
}
|
|
2820
|
-
function
|
|
2821
|
-
const t =
|
|
2841
|
+
function b() {
|
|
2842
|
+
const t = Qt();
|
|
2822
2843
|
return {
|
|
2823
2844
|
url: location.href,
|
|
2824
2845
|
title: document.title,
|
|
@@ -2826,21 +2847,21 @@ function _() {
|
|
|
2826
2847
|
...t ? { plunoProductAgentUi: t } : {}
|
|
2827
2848
|
};
|
|
2828
2849
|
}
|
|
2829
|
-
function
|
|
2850
|
+
function Fn() {
|
|
2830
2851
|
return {
|
|
2831
2852
|
pageUrl: location.href,
|
|
2832
2853
|
pageTitle: document.title,
|
|
2833
|
-
htmlContent:
|
|
2854
|
+
htmlContent: at()
|
|
2834
2855
|
};
|
|
2835
2856
|
}
|
|
2836
2857
|
function jn(t) {
|
|
2837
|
-
return
|
|
2838
|
-
|
|
2858
|
+
return we.add(t), fe || (fe = zn()), () => {
|
|
2859
|
+
we.delete(t), we.size === 0 && (fe?.(), fe = null);
|
|
2839
2860
|
};
|
|
2840
2861
|
}
|
|
2841
|
-
function
|
|
2862
|
+
function zn() {
|
|
2842
2863
|
const t = () => {
|
|
2843
|
-
for (const i of Array.from(
|
|
2864
|
+
for (const i of Array.from(we))
|
|
2844
2865
|
i();
|
|
2845
2866
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2846
2867
|
const o = e(...i);
|
|
@@ -2853,38 +2874,38 @@ function Fn() {
|
|
|
2853
2874
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2854
2875
|
};
|
|
2855
2876
|
}
|
|
2856
|
-
function
|
|
2857
|
-
return
|
|
2877
|
+
function ye() {
|
|
2878
|
+
return Qt()?.surface === "browser_extension_sdk_preview";
|
|
2858
2879
|
}
|
|
2859
|
-
function
|
|
2880
|
+
function at() {
|
|
2860
2881
|
if (!document.body)
|
|
2861
2882
|
return "";
|
|
2862
|
-
const t = [], e = [], s = (
|
|
2863
|
-
const y =
|
|
2864
|
-
!y || e.includes(y) || (t.push([
|
|
2883
|
+
const t = [], e = [], s = (p, g) => {
|
|
2884
|
+
const y = te(g);
|
|
2885
|
+
!y || e.includes(y) || (t.push([p, y]), e.push(y));
|
|
2865
2886
|
};
|
|
2866
2887
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2867
2888
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2868
|
-
(
|
|
2889
|
+
(p) => Vt(p) && !p.parentElement?.closest(n)
|
|
2869
2890
|
);
|
|
2870
|
-
for (const
|
|
2871
|
-
s("Active overlay",
|
|
2872
|
-
const i =
|
|
2873
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2874
|
-
const a = t.map(([
|
|
2891
|
+
for (const p of r.slice(0, 3))
|
|
2892
|
+
s("Active overlay", ze(ue(p), e));
|
|
2893
|
+
const i = Kn(), o = i ? ze(ue(i), e) : "";
|
|
2894
|
+
s("Main page content", o), s("Additional visible page text", ze(ue(document.body), e));
|
|
2895
|
+
const a = t.map(([p, g]) => `${p}:
|
|
2875
2896
|
${g}`).join(`
|
|
2876
2897
|
|
|
2877
|
-
`).trim().slice(0, 12e3), l =
|
|
2898
|
+
`).trim().slice(0, 12e3), l = Gn(r, i).trim(), c = `Simplified DOM outline:
|
|
2878
2899
|
`, d = `
|
|
2879
2900
|
|
|
2880
2901
|
Visible page text:
|
|
2881
|
-
`,
|
|
2902
|
+
`, h = 12e3 - c.length - d.length, m = Math.min(a.length, 7900), f = l.slice(0, h - m), u = a.slice(0, h - f.length);
|
|
2882
2903
|
return `${c}${f}${d}${u}`;
|
|
2883
2904
|
}
|
|
2884
|
-
function
|
|
2905
|
+
function ue(t) {
|
|
2885
2906
|
return t.innerText ?? t.textContent ?? "";
|
|
2886
2907
|
}
|
|
2887
|
-
function
|
|
2908
|
+
function te(t) {
|
|
2888
2909
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2889
2910
|
`).split(`
|
|
2890
2911
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2892,20 +2913,20 @@ function ee(t) {
|
|
|
2892
2913
|
|
|
2893
2914
|
`).trim();
|
|
2894
2915
|
}
|
|
2895
|
-
function
|
|
2896
|
-
let s =
|
|
2916
|
+
function ze(t, e) {
|
|
2917
|
+
let s = te(t);
|
|
2897
2918
|
for (const n of e)
|
|
2898
2919
|
s = s.replace(n, "");
|
|
2899
|
-
return
|
|
2920
|
+
return te(s);
|
|
2900
2921
|
}
|
|
2901
|
-
function
|
|
2922
|
+
function Vt(t) {
|
|
2902
2923
|
const e = window.getComputedStyle(t);
|
|
2903
2924
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2904
2925
|
}
|
|
2905
|
-
function
|
|
2906
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2926
|
+
function Kn() {
|
|
2927
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Vt).sort((t, e) => ue(e).length - ue(t).length)[0] ?? null;
|
|
2907
2928
|
}
|
|
2908
|
-
function
|
|
2929
|
+
function Gn(t, e) {
|
|
2909
2930
|
const s = /* @__PURE__ */ new Set([
|
|
2910
2931
|
"main",
|
|
2911
2932
|
"nav",
|
|
@@ -2985,77 +3006,77 @@ function Kn(t, e) {
|
|
|
2985
3006
|
"data-test",
|
|
2986
3007
|
"data-qa",
|
|
2987
3008
|
"data-cy"
|
|
2988
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets:
|
|
3009
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: h } = Vn(), m = new Set(t);
|
|
2989
3010
|
e && m.add(e);
|
|
2990
3011
|
let f = 0;
|
|
2991
3012
|
const u = (w) => {
|
|
2992
|
-
const
|
|
2993
|
-
return
|
|
2994
|
-
},
|
|
2995
|
-
const
|
|
2996
|
-
return `${w.tagName.toLowerCase()}|${u(w)}|${
|
|
2997
|
-
}, g = (w,
|
|
3013
|
+
const D = w.getAttribute("role");
|
|
3014
|
+
return D && !o.has(D) ? D : "";
|
|
3015
|
+
}, p = (w) => {
|
|
3016
|
+
const D = w.getAttribute("data-testid") || w.getAttribute("data-test") || w.getAttribute("data-qa") || w.getAttribute("data-cy") || "";
|
|
3017
|
+
return `${w.tagName.toLowerCase()}|${u(w)}|${D}`;
|
|
3018
|
+
}, g = (w, D, U) => {
|
|
2998
3019
|
const S = (T, N) => {
|
|
2999
|
-
const
|
|
3000
|
-
if (f >= 1e3 &&
|
|
3020
|
+
const _ = T.tagName.toLowerCase(), ne = window.getComputedStyle(T), $ = d.has(T);
|
|
3021
|
+
if (f >= 1e3 && !$ || U.has(T) || i.has(_) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ne.display === "none" || ne.visibility === "hidden")
|
|
3001
3022
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
3002
3023
|
f += 1;
|
|
3003
|
-
const
|
|
3004
|
-
for (const I of
|
|
3005
|
-
const
|
|
3006
|
-
|
|
3024
|
+
const he = u(T), z = Jt(T), K = a.has(he) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(_) || _ === "a" && T.hasAttribute("href"), Q = Array.from(T.children).filter((I) => I instanceof HTMLElement), re = /* @__PURE__ */ new Map();
|
|
3025
|
+
for (const I of Q) {
|
|
3026
|
+
const E = p(I);
|
|
3027
|
+
re.set(E, (re.get(E) ?? 0) + 1);
|
|
3007
3028
|
}
|
|
3008
|
-
const
|
|
3009
|
-
for (const I of
|
|
3010
|
-
const
|
|
3011
|
-
|
|
3029
|
+
const Y = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
|
|
3030
|
+
for (const I of Q) {
|
|
3031
|
+
const E = p(I), j = F.get(E) ?? 0;
|
|
3032
|
+
F.set(E, j + 1), (re.get(E) ?? 0) > 8 && j >= 6 && !d.has(I) && Y.set(E, (Y.get(E) ?? 0) + 1);
|
|
3012
3033
|
}
|
|
3013
|
-
const
|
|
3014
|
-
for (const I of
|
|
3015
|
-
const
|
|
3016
|
-
if (
|
|
3017
|
-
|
|
3034
|
+
const k = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Set(), ve = [], ut = [];
|
|
3035
|
+
for (const I of Q) {
|
|
3036
|
+
const E = p(I), j = re.get(E) ?? 0, pt = k.get(E) ?? 0;
|
|
3037
|
+
if (k.set(E, pt + 1), j > 8 && pt >= 6 && !d.has(I)) {
|
|
3038
|
+
O.has(E) || (ve.push([`… ${Y.get(E) ?? 0} similar siblings omitted`]), O.add(E));
|
|
3018
3039
|
continue;
|
|
3019
3040
|
}
|
|
3020
3041
|
const gt = S(I, N);
|
|
3021
|
-
ut.push(gt),
|
|
3042
|
+
ut.push(gt), ve.push(gt.lines);
|
|
3022
3043
|
}
|
|
3023
|
-
const
|
|
3044
|
+
const De = [];
|
|
3024
3045
|
if (T.shadowRoot)
|
|
3025
3046
|
for (const I of Array.from(T.shadowRoot.children))
|
|
3026
|
-
I instanceof HTMLElement &&
|
|
3027
|
-
const
|
|
3028
|
-
[
|
|
3029
|
-
).slice(0, 180),
|
|
3030
|
-
if (
|
|
3031
|
-
const I =
|
|
3032
|
-
|
|
3047
|
+
I instanceof HTMLElement && De.push(S(I, N + 1));
|
|
3048
|
+
const pe = [...ut, ...De], Oe = z.length > 0 || K || pe.some((I) => I.hasUsefulContent), dt = te(
|
|
3049
|
+
[z, ...pe.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
3050
|
+
).slice(0, 180), Ss = T.hasAttribute("contenteditable") && (z.length > 0 || !T.querySelector("[contenteditable]")), ht = c.some((I) => T.hasAttribute(I)) || !!he || Ss, qe = (T.getClientRects().length > 0 || ne.display === "contents") && (s.has(_) || ht || $) && (Oe || $) && (!r.has(_) || Oe || ht || $), Le = qe ? 1 : 0, ie = [];
|
|
3051
|
+
if (qe) {
|
|
3052
|
+
const I = pe.some((j) => j.containsTextElement), E = n.has(_) && !I ? dt : z;
|
|
3053
|
+
ie.push(Xt(T, l, o, E.slice(0, 180)));
|
|
3033
3054
|
}
|
|
3034
|
-
for (const I of
|
|
3035
|
-
|
|
3036
|
-
const
|
|
3037
|
-
if (
|
|
3038
|
-
const I =
|
|
3039
|
-
|
|
3040
|
-
const
|
|
3041
|
-
if (N < 2 && !
|
|
3042
|
-
const
|
|
3043
|
-
|
|
3055
|
+
for (const I of ve)
|
|
3056
|
+
ie.push(...Ie(I, Le));
|
|
3057
|
+
const Ne = De.flatMap((I) => I.lines);
|
|
3058
|
+
if (Ne.length > 0) {
|
|
3059
|
+
const I = Ne.slice(0, 20);
|
|
3060
|
+
Ne.length > I.length && I.push("… shadow DOM omitted");
|
|
3061
|
+
const E = _.includes("tooltip") || _.includes("popper") || _.includes("loader");
|
|
3062
|
+
if (N < 2 && !E) {
|
|
3063
|
+
const j = qe ? "#shadow-root" : `${_} #shadow-root`;
|
|
3064
|
+
ie.push(...Ie([j, ...Ie(I, 1)], Le));
|
|
3044
3065
|
} else
|
|
3045
|
-
|
|
3066
|
+
ie.push(...Ie(I, Le));
|
|
3046
3067
|
}
|
|
3047
3068
|
return {
|
|
3048
|
-
lines:
|
|
3049
|
-
hasUsefulContent:
|
|
3069
|
+
lines: ie,
|
|
3070
|
+
hasUsefulContent: Oe,
|
|
3050
3071
|
textPreview: dt,
|
|
3051
|
-
containsTextElement: n.has(
|
|
3072
|
+
containsTextElement: n.has(_) || pe.some((I) => I.containsTextElement)
|
|
3052
3073
|
};
|
|
3053
3074
|
};
|
|
3054
|
-
return [`--- ${
|
|
3075
|
+
return [`--- ${D} ---`, ...S(w, 0).lines].join(`
|
|
3055
3076
|
`);
|
|
3056
|
-
}, y = [],
|
|
3057
|
-
|
|
3058
|
-
${JSON.stringify(
|
|
3077
|
+
}, y = [], M = te(window.getSelection()?.toString() ?? "");
|
|
3078
|
+
M && y.push(`--- selected text ---
|
|
3079
|
+
${JSON.stringify(M)}`), h.length > 0 && y.push(Xn(h, s, l, o));
|
|
3059
3080
|
for (const w of t.slice(0, 3))
|
|
3060
3081
|
y.push(g(w, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
3061
3082
|
if (e && y.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -3066,11 +3087,11 @@ ${JSON.stringify(C)}`), p.length > 0 && y.push(Vn(p, s, l, o));
|
|
|
3066
3087
|
|
|
3067
3088
|
`);
|
|
3068
3089
|
}
|
|
3069
|
-
function
|
|
3090
|
+
function Xt(t, e, s, n) {
|
|
3070
3091
|
const r = t.tagName.toLowerCase();
|
|
3071
3092
|
let i = r;
|
|
3072
3093
|
const o = t.getAttribute("id");
|
|
3073
|
-
o &&
|
|
3094
|
+
o && Jn(o) && (i += `#${o}`);
|
|
3074
3095
|
for (const a of e) {
|
|
3075
3096
|
const l = t.getAttribute(a);
|
|
3076
3097
|
l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
|
|
@@ -3083,7 +3104,7 @@ function Vt(t, e, s, n) {
|
|
|
3083
3104
|
t.hasAttribute(a) && (i += `[${a}]`);
|
|
3084
3105
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
3085
3106
|
}
|
|
3086
|
-
function
|
|
3107
|
+
function Vn() {
|
|
3087
3108
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
|
|
3088
3109
|
if (!a)
|
|
3089
3110
|
return;
|
|
@@ -3092,11 +3113,11 @@ function Gn() {
|
|
|
3092
3113
|
return;
|
|
3093
3114
|
const d = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
3094
3115
|
d.add(l), e.set(a, d);
|
|
3095
|
-
let
|
|
3096
|
-
for (;
|
|
3097
|
-
t.add(
|
|
3098
|
-
const m =
|
|
3099
|
-
|
|
3116
|
+
let h = a;
|
|
3117
|
+
for (; h; ) {
|
|
3118
|
+
t.add(h);
|
|
3119
|
+
const m = h.getRootNode();
|
|
3120
|
+
h = h.parentElement ?? (m instanceof ShadowRoot && m.host instanceof HTMLElement ? m.host : null);
|
|
3100
3121
|
}
|
|
3101
3122
|
};
|
|
3102
3123
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -3116,8 +3137,8 @@ function Gn() {
|
|
|
3116
3137
|
for (let a = 0; a < o.length; a += 1) {
|
|
3117
3138
|
const l = o[a];
|
|
3118
3139
|
for (const [c, d] of i)
|
|
3119
|
-
for (const
|
|
3120
|
-
s(
|
|
3140
|
+
for (const h of Array.from(l.querySelectorAll(c)))
|
|
3141
|
+
s(h, d);
|
|
3121
3142
|
for (const c of Array.from(l.querySelectorAll("*")))
|
|
3122
3143
|
c.shadowRoot && o.push(c.shadowRoot);
|
|
3123
3144
|
}
|
|
@@ -3126,7 +3147,7 @@ function Gn() {
|
|
|
3126
3147
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
3127
3148
|
};
|
|
3128
3149
|
}
|
|
3129
|
-
function
|
|
3150
|
+
function Xn(t, e, s, n) {
|
|
3130
3151
|
const r = ["--- active/current elements ---"];
|
|
3131
3152
|
for (const i of t) {
|
|
3132
3153
|
const o = [];
|
|
@@ -3134,14 +3155,14 @@ function Vn(t, e, s, n) {
|
|
|
3134
3155
|
for (; a; ) {
|
|
3135
3156
|
const d = a.tagName.toLowerCase();
|
|
3136
3157
|
(a === i.element || e.has(d) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
3137
|
-
const
|
|
3138
|
-
a = a.parentElement ?? (
|
|
3158
|
+
const h = a.getRootNode();
|
|
3159
|
+
a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
|
|
3139
3160
|
}
|
|
3140
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d,
|
|
3161
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d, h) => Xt(
|
|
3141
3162
|
d,
|
|
3142
3163
|
s,
|
|
3143
3164
|
n,
|
|
3144
|
-
|
|
3165
|
+
h === l.length - 1 ? Jt(d).slice(0, 180) : ""
|
|
3145
3166
|
));
|
|
3146
3167
|
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
3147
3168
|
}
|
|
@@ -3151,23 +3172,23 @@ function Vn(t, e, s, n) {
|
|
|
3151
3172
|
function bt(t) {
|
|
3152
3173
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
3153
3174
|
}
|
|
3154
|
-
function
|
|
3175
|
+
function Ie(t, e) {
|
|
3155
3176
|
if (e === 0)
|
|
3156
3177
|
return t;
|
|
3157
3178
|
const s = " ".repeat(e);
|
|
3158
3179
|
return t.map((n) => `${s}${n}`);
|
|
3159
3180
|
}
|
|
3160
|
-
function
|
|
3161
|
-
return
|
|
3181
|
+
function Jt(t) {
|
|
3182
|
+
return te(
|
|
3162
3183
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
3163
3184
|
);
|
|
3164
3185
|
}
|
|
3165
|
-
function
|
|
3186
|
+
function Jn(t) {
|
|
3166
3187
|
return t.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(t) && !/[a-f0-9]{12,}/i.test(t) && !/:r[0-9a-z]+:/i.test(t);
|
|
3167
3188
|
}
|
|
3168
|
-
function
|
|
3189
|
+
function Qt() {
|
|
3169
3190
|
const t = document.querySelector(ft);
|
|
3170
|
-
if (!(t ?? document.querySelector(
|
|
3191
|
+
if (!(t ?? document.querySelector(Xe)))
|
|
3171
3192
|
return;
|
|
3172
3193
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
3173
3194
|
return {
|
|
@@ -3176,28 +3197,28 @@ function Jt() {
|
|
|
3176
3197
|
selectors: [
|
|
3177
3198
|
{
|
|
3178
3199
|
name: "widget_host",
|
|
3179
|
-
selector: s === "browser_extension_sdk_preview" ? ft :
|
|
3200
|
+
selector: s === "browser_extension_sdk_preview" ? ft : Xe,
|
|
3180
3201
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
3181
3202
|
},
|
|
3182
3203
|
{
|
|
3183
3204
|
name: "widget_root",
|
|
3184
|
-
selector:
|
|
3205
|
+
selector: Xs,
|
|
3185
3206
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
3186
3207
|
},
|
|
3187
3208
|
{
|
|
3188
3209
|
name: "widget_panel",
|
|
3189
|
-
selector:
|
|
3210
|
+
selector: Js,
|
|
3190
3211
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
3191
3212
|
},
|
|
3192
3213
|
{
|
|
3193
3214
|
name: "widget_timeline",
|
|
3194
|
-
selector:
|
|
3215
|
+
selector: Qs,
|
|
3195
3216
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
3196
3217
|
}
|
|
3197
3218
|
]
|
|
3198
3219
|
};
|
|
3199
3220
|
}
|
|
3200
|
-
function
|
|
3221
|
+
function Qn(t) {
|
|
3201
3222
|
try {
|
|
3202
3223
|
const e = JSON.parse(t);
|
|
3203
3224
|
return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
|
|
@@ -3205,7 +3226,7 @@ function Jn(t) {
|
|
|
3205
3226
|
return { type: "error", message: "Invalid server event" };
|
|
3206
3227
|
}
|
|
3207
3228
|
}
|
|
3208
|
-
function
|
|
3229
|
+
function Yn(t) {
|
|
3209
3230
|
if (typeof t != "string")
|
|
3210
3231
|
return null;
|
|
3211
3232
|
try {
|
|
@@ -3221,10 +3242,18 @@ function _t(t, e) {
|
|
|
3221
3242
|
const s = t[e];
|
|
3222
3243
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
3223
3244
|
}
|
|
3224
|
-
function
|
|
3225
|
-
return Array.isArray(t) ? t.
|
|
3245
|
+
function Pt(t) {
|
|
3246
|
+
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3247
|
+
if (!e || typeof e != "object")
|
|
3248
|
+
return [];
|
|
3249
|
+
const s = e;
|
|
3250
|
+
return typeof s.taskId != "string" || !s.taskId || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? [] : [{ taskId: s.taskId, dueAt: s.dueAt }];
|
|
3251
|
+
}) : [];
|
|
3226
3252
|
}
|
|
3227
3253
|
function Zn(t) {
|
|
3254
|
+
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
3255
|
+
}
|
|
3256
|
+
function er(t) {
|
|
3228
3257
|
if (!t || typeof t != "object")
|
|
3229
3258
|
return null;
|
|
3230
3259
|
const e = t, s = e.appearance, n = s && typeof s == "object" ? s : e, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -3235,13 +3264,13 @@ function Zn(t) {
|
|
|
3235
3264
|
...a !== null ? { scribbleStyle: a } : {}
|
|
3236
3265
|
};
|
|
3237
3266
|
}
|
|
3238
|
-
function
|
|
3267
|
+
function tr(t) {
|
|
3239
3268
|
if (!t || typeof t != "object")
|
|
3240
3269
|
return null;
|
|
3241
3270
|
const e = t.javascript;
|
|
3242
3271
|
return typeof e != "string" || !e.trim() ? null : { javascript: e };
|
|
3243
3272
|
}
|
|
3244
|
-
function
|
|
3273
|
+
function sr(t, e) {
|
|
3245
3274
|
return e ? t && typeof t == "object" ? {
|
|
3246
3275
|
...t,
|
|
3247
3276
|
helperError: e
|
|
@@ -3251,23 +3280,23 @@ function tr(t, e) {
|
|
|
3251
3280
|
helperError: e
|
|
3252
3281
|
} : t;
|
|
3253
3282
|
}
|
|
3254
|
-
function
|
|
3283
|
+
function nr(t) {
|
|
3255
3284
|
if (!t || typeof t != "object")
|
|
3256
3285
|
return t;
|
|
3257
3286
|
const e = t;
|
|
3258
3287
|
return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : t;
|
|
3259
3288
|
}
|
|
3260
|
-
function
|
|
3289
|
+
function rr() {
|
|
3261
3290
|
const t = "pluno.productAgent.clientId", e = window.localStorage.getItem(t);
|
|
3262
3291
|
if (e)
|
|
3263
3292
|
return e;
|
|
3264
3293
|
const s = crypto.randomUUID();
|
|
3265
3294
|
return window.localStorage.setItem(t, s), s;
|
|
3266
3295
|
}
|
|
3267
|
-
function
|
|
3296
|
+
function x() {
|
|
3268
3297
|
return crypto.randomUUID();
|
|
3269
3298
|
}
|
|
3270
|
-
function
|
|
3299
|
+
function ir(t) {
|
|
3271
3300
|
if (!t || typeof t != "object")
|
|
3272
3301
|
return null;
|
|
3273
3302
|
const e = t, s = typeof e.id == "string" ? e.id : null;
|
|
@@ -3278,22 +3307,22 @@ function rr(t) {
|
|
|
3278
3307
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
3279
3308
|
} : null;
|
|
3280
3309
|
}
|
|
3281
|
-
function
|
|
3282
|
-
return Array.isArray(t) ?
|
|
3283
|
-
t.map((s) =>
|
|
3310
|
+
function Ut(t, e) {
|
|
3311
|
+
return Array.isArray(t) ? et(
|
|
3312
|
+
t.map((s) => Yt(s, e)).filter((s) => s !== null)
|
|
3284
3313
|
) : [];
|
|
3285
3314
|
}
|
|
3286
|
-
function
|
|
3315
|
+
function or(t) {
|
|
3287
3316
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
3288
3317
|
if (!e || typeof e != "object")
|
|
3289
3318
|
return [];
|
|
3290
|
-
const s = e, n =
|
|
3319
|
+
const s = e, n = R(s, "id"), r = R(s, "createdAt"), i = R(s, "updatedAt"), o = R(s, "lastActiveAt");
|
|
3291
3320
|
return !n || !r || !i || !o ? [] : [
|
|
3292
3321
|
{
|
|
3293
3322
|
id: n,
|
|
3294
|
-
title:
|
|
3295
|
-
customTitle:
|
|
3296
|
-
firstUserMessage:
|
|
3323
|
+
title: R(s, "title"),
|
|
3324
|
+
customTitle: R(s, "customTitle"),
|
|
3325
|
+
firstUserMessage: R(s, "firstUserMessage"),
|
|
3297
3326
|
currentPage: s.currentPage ?? null,
|
|
3298
3327
|
createdAt: r,
|
|
3299
3328
|
updatedAt: i,
|
|
@@ -3304,29 +3333,29 @@ function ir(t) {
|
|
|
3304
3333
|
];
|
|
3305
3334
|
}) : [];
|
|
3306
3335
|
}
|
|
3307
|
-
function
|
|
3336
|
+
function Yt(t, e) {
|
|
3308
3337
|
if (!t || typeof t != "object")
|
|
3309
3338
|
return null;
|
|
3310
3339
|
const s = t, n = s.data;
|
|
3311
3340
|
if (!n || typeof n != "object")
|
|
3312
3341
|
return null;
|
|
3313
3342
|
const r = n;
|
|
3314
|
-
if (r.hiddenFromTranscript === !0 ||
|
|
3343
|
+
if (r.hiddenFromTranscript === !0 || vs(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
3315
3344
|
return null;
|
|
3316
3345
|
if (r.type === "message") {
|
|
3317
3346
|
const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
|
|
3318
3347
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3319
3348
|
role: i,
|
|
3320
3349
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
3321
|
-
content:
|
|
3322
|
-
|
|
3350
|
+
content: Cs(
|
|
3351
|
+
gr(r.content),
|
|
3323
3352
|
e
|
|
3324
3353
|
),
|
|
3325
3354
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3326
3355
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3327
3356
|
respondsToUserMessageId: L(r) ?? void 0,
|
|
3328
|
-
...
|
|
3329
|
-
attachments:
|
|
3357
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3358
|
+
attachments: ls(r.attachments, e)
|
|
3330
3359
|
};
|
|
3331
3360
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
3332
3361
|
value: r.id,
|
|
@@ -3340,7 +3369,7 @@ function Qt(t, e) {
|
|
|
3340
3369
|
}), o;
|
|
3341
3370
|
}
|
|
3342
3371
|
if (r.type === "function_call_output") {
|
|
3343
|
-
const i =
|
|
3372
|
+
const i = _s(r.output);
|
|
3344
3373
|
if (i !== null)
|
|
3345
3374
|
return {
|
|
3346
3375
|
id: String(s.id ?? crypto.randomUUID()),
|
|
@@ -3348,10 +3377,10 @@ function Qt(t, e) {
|
|
|
3348
3377
|
content: "",
|
|
3349
3378
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3350
3379
|
respondsToUserMessageId: L(r) ?? void 0,
|
|
3351
|
-
...
|
|
3380
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3352
3381
|
dataType: "function_call_output",
|
|
3353
|
-
toolName:
|
|
3354
|
-
callId:
|
|
3382
|
+
toolName: bs,
|
|
3383
|
+
callId: ce(r) ?? void 0,
|
|
3355
3384
|
sharePromptAllowed: i
|
|
3356
3385
|
};
|
|
3357
3386
|
const o = js(r.output);
|
|
@@ -3362,14 +3391,14 @@ function Qt(t, e) {
|
|
|
3362
3391
|
content: "",
|
|
3363
3392
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3364
3393
|
respondsToUserMessageId: L(r) ?? void 0,
|
|
3365
|
-
...
|
|
3394
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3366
3395
|
dataType: "scheduled_check_in",
|
|
3367
|
-
toolName:
|
|
3368
|
-
callId:
|
|
3396
|
+
toolName: Ft,
|
|
3397
|
+
callId: ce(r) ?? void 0,
|
|
3369
3398
|
scheduledCheckInId: o.id ?? void 0,
|
|
3370
3399
|
scheduledCheckInAt: o.dueAt
|
|
3371
3400
|
};
|
|
3372
|
-
const a =
|
|
3401
|
+
const a = lr(r.output), l = cr(r.output);
|
|
3373
3402
|
return a ? {
|
|
3374
3403
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3375
3404
|
role: "tool",
|
|
@@ -3377,10 +3406,10 @@ function Qt(t, e) {
|
|
|
3377
3406
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3378
3407
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3379
3408
|
respondsToUserMessageId: L(r) ?? void 0,
|
|
3380
|
-
...
|
|
3409
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3381
3410
|
dataType: "function_call_output",
|
|
3382
3411
|
toolName: "authenticate_pipedream_app",
|
|
3383
|
-
callId:
|
|
3412
|
+
callId: ce(r) ?? void 0,
|
|
3384
3413
|
integrationAuthRequest: a
|
|
3385
3414
|
} : l ? {
|
|
3386
3415
|
id: String(s.id ?? crypto.randomUUID()),
|
|
@@ -3389,33 +3418,33 @@ function Qt(t, e) {
|
|
|
3389
3418
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3390
3419
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3391
3420
|
respondsToUserMessageId: L(r) ?? void 0,
|
|
3392
|
-
...
|
|
3421
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3393
3422
|
dataType: "function_call_output",
|
|
3394
3423
|
toolName: "request_personal_channel_connection",
|
|
3395
|
-
callId:
|
|
3424
|
+
callId: ce(r) ?? void 0,
|
|
3396
3425
|
personalChannelConnectionRequest: l
|
|
3397
3426
|
} : null;
|
|
3398
3427
|
}
|
|
3399
3428
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
3400
3429
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3401
3430
|
role: "tool",
|
|
3402
|
-
content: r.type === "mcp_call" ?
|
|
3431
|
+
content: r.type === "mcp_call" ? ar(r) : dr(r),
|
|
3403
3432
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3404
3433
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3405
3434
|
respondsToUserMessageId: L(r) ?? void 0,
|
|
3406
|
-
...
|
|
3435
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3407
3436
|
dataType: String(r.type),
|
|
3408
3437
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
3409
|
-
callId:
|
|
3438
|
+
callId: ce(r) ?? void 0,
|
|
3410
3439
|
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
3411
3440
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
3412
3441
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3413
3442
|
role: "system",
|
|
3414
|
-
content:
|
|
3443
|
+
content: ur(r),
|
|
3415
3444
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3416
3445
|
...v(r) !== null ? { causalSequence: v(r) } : {},
|
|
3417
3446
|
respondsToUserMessageId: L(r) ?? void 0,
|
|
3418
|
-
...
|
|
3447
|
+
...C(r) ? { runId: C(r) } : {},
|
|
3419
3448
|
dataType: String(r.type),
|
|
3420
3449
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
3421
3450
|
...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
|
|
@@ -3423,11 +3452,11 @@ function Qt(t, e) {
|
|
|
3423
3452
|
...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
|
|
3424
3453
|
} : null;
|
|
3425
3454
|
}
|
|
3426
|
-
function
|
|
3455
|
+
function ar(t) {
|
|
3427
3456
|
const s = (typeof t.server_label == "string" ? t.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
3428
3457
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
3429
3458
|
}
|
|
3430
|
-
function
|
|
3459
|
+
function lr(t) {
|
|
3431
3460
|
if (typeof t != "string")
|
|
3432
3461
|
return null;
|
|
3433
3462
|
try {
|
|
@@ -3444,7 +3473,7 @@ function ar(t) {
|
|
|
3444
3473
|
return null;
|
|
3445
3474
|
}
|
|
3446
3475
|
}
|
|
3447
|
-
function
|
|
3476
|
+
function cr(t) {
|
|
3448
3477
|
if (typeof t != "string")
|
|
3449
3478
|
return null;
|
|
3450
3479
|
try {
|
|
@@ -3459,10 +3488,10 @@ function lr(t) {
|
|
|
3459
3488
|
return null;
|
|
3460
3489
|
}
|
|
3461
3490
|
}
|
|
3462
|
-
function
|
|
3491
|
+
function ur(t) {
|
|
3463
3492
|
return t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message : "";
|
|
3464
3493
|
}
|
|
3465
|
-
function
|
|
3494
|
+
function dr(t) {
|
|
3466
3495
|
if (t.type === "web_search_call") {
|
|
3467
3496
|
const e = t.action;
|
|
3468
3497
|
if (e && typeof e == "object") {
|
|
@@ -3474,26 +3503,26 @@ function ur(t) {
|
|
|
3474
3503
|
}
|
|
3475
3504
|
return "🔎 Searching the web";
|
|
3476
3505
|
}
|
|
3477
|
-
return
|
|
3506
|
+
return hr(t);
|
|
3478
3507
|
}
|
|
3479
|
-
function
|
|
3508
|
+
function hr(t) {
|
|
3480
3509
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3481
|
-
return
|
|
3510
|
+
return ee(t.summary);
|
|
3482
3511
|
if (typeof t.arguments == "string")
|
|
3483
3512
|
try {
|
|
3484
3513
|
const e = JSON.parse(t.arguments);
|
|
3485
3514
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
3486
|
-
return
|
|
3515
|
+
return ee(e.summary);
|
|
3487
3516
|
} catch {
|
|
3488
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3517
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? ee(t.name) : "🛠️ Run tool";
|
|
3489
3518
|
}
|
|
3490
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3519
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? ee(t.name) : "🛠️ Run tool";
|
|
3491
3520
|
}
|
|
3492
|
-
function
|
|
3521
|
+
function ee(t) {
|
|
3493
3522
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3494
3523
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3495
3524
|
}
|
|
3496
|
-
function
|
|
3525
|
+
function pr(t) {
|
|
3497
3526
|
if (t == null)
|
|
3498
3527
|
return t;
|
|
3499
3528
|
if (typeof t != "object")
|
|
@@ -3508,14 +3537,14 @@ function hr(t) {
|
|
|
3508
3537
|
runId: typeof e.runId == "string" ? e.runId : null
|
|
3509
3538
|
};
|
|
3510
3539
|
}
|
|
3511
|
-
function
|
|
3540
|
+
function ce(t) {
|
|
3512
3541
|
const e = t.callId ?? t.call_id;
|
|
3513
3542
|
return typeof e == "string" && e ? e : null;
|
|
3514
3543
|
}
|
|
3515
3544
|
function v(t) {
|
|
3516
3545
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
3517
3546
|
}
|
|
3518
|
-
function
|
|
3547
|
+
function gr(t) {
|
|
3519
3548
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
3520
3549
|
if (!e || typeof e != "object")
|
|
3521
3550
|
return "";
|
|
@@ -3523,11 +3552,11 @@ function pr(t) {
|
|
|
3523
3552
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
3524
3553
|
}).filter(Boolean).join("") : "";
|
|
3525
3554
|
}
|
|
3526
|
-
function
|
|
3527
|
-
const s =
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3555
|
+
function Qe(t, e) {
|
|
3556
|
+
const s = ts(t, e), n = wr(
|
|
3557
|
+
mr(
|
|
3558
|
+
kr(
|
|
3559
|
+
fr(t, e),
|
|
3531
3560
|
e
|
|
3532
3561
|
),
|
|
3533
3562
|
s
|
|
@@ -3535,13 +3564,13 @@ function Je(t, e) {
|
|
|
3535
3564
|
s
|
|
3536
3565
|
), r = n.findIndex((o) => o.id === s.id);
|
|
3537
3566
|
if (r === -1)
|
|
3538
|
-
return
|
|
3567
|
+
return et(
|
|
3539
3568
|
[...n, s]
|
|
3540
3569
|
);
|
|
3541
3570
|
const i = [...n];
|
|
3542
|
-
return i[r] = s,
|
|
3571
|
+
return i[r] = s, et(i);
|
|
3543
3572
|
}
|
|
3544
|
-
function
|
|
3573
|
+
function fr(t, e) {
|
|
3545
3574
|
const s = e.proactiveSuggestionClientMessageId;
|
|
3546
3575
|
if (!s)
|
|
3547
3576
|
return t;
|
|
@@ -3551,16 +3580,16 @@ function gr(t, e) {
|
|
|
3551
3580
|
const i = [...t];
|
|
3552
3581
|
return i[r] = e, i;
|
|
3553
3582
|
}
|
|
3554
|
-
function
|
|
3583
|
+
function mr(t, e) {
|
|
3555
3584
|
const s = e.assistantDraftItemId;
|
|
3556
3585
|
return s ? t.map(
|
|
3557
3586
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
3558
3587
|
) : t;
|
|
3559
3588
|
}
|
|
3560
|
-
function
|
|
3589
|
+
function Ke(t, e, s) {
|
|
3561
3590
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3562
3591
|
}
|
|
3563
|
-
function
|
|
3592
|
+
function yr(t, e, s, n) {
|
|
3564
3593
|
if (s === null) return t;
|
|
3565
3594
|
let r = -1;
|
|
3566
3595
|
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
@@ -3577,12 +3606,12 @@ function mr(t, e, s, n) {
|
|
|
3577
3606
|
respondsToUserMessageId: s
|
|
3578
3607
|
}, i;
|
|
3579
3608
|
}
|
|
3580
|
-
function
|
|
3609
|
+
function Ir(t, e) {
|
|
3581
3610
|
const s = t.findIndex(
|
|
3582
3611
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3583
3612
|
);
|
|
3584
3613
|
if (s === -1)
|
|
3585
|
-
return
|
|
3614
|
+
return Qe(t, e);
|
|
3586
3615
|
const n = [...t];
|
|
3587
3616
|
return n[s] = {
|
|
3588
3617
|
...n[s],
|
|
@@ -3594,19 +3623,19 @@ function yr(t, e) {
|
|
|
3594
3623
|
...n[s].runId ? {} : { runId: e.runId }
|
|
3595
3624
|
}, n;
|
|
3596
3625
|
}
|
|
3597
|
-
function
|
|
3626
|
+
function Sr(t, e, s) {
|
|
3598
3627
|
let n = !1;
|
|
3599
3628
|
const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
3600
3629
|
return n ? r : t;
|
|
3601
3630
|
}
|
|
3602
|
-
function
|
|
3631
|
+
function Tr(t) {
|
|
3603
3632
|
if (t.hiddenFromTranscript === !0)
|
|
3604
3633
|
return null;
|
|
3605
3634
|
const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
|
|
3606
3635
|
return !e || !s ? null : {
|
|
3607
3636
|
id: `transient-activity:${e}`,
|
|
3608
3637
|
role: "tool",
|
|
3609
|
-
content:
|
|
3638
|
+
content: ee(
|
|
3610
3639
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3611
3640
|
),
|
|
3612
3641
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3619,7 +3648,7 @@ function Sr(t) {
|
|
|
3619
3648
|
loading: !0
|
|
3620
3649
|
};
|
|
3621
3650
|
}
|
|
3622
|
-
function
|
|
3651
|
+
function wr(t, e) {
|
|
3623
3652
|
if (e.id.startsWith("transient-activity:"))
|
|
3624
3653
|
return t;
|
|
3625
3654
|
const s = e.toolName === "tab_lifecycle";
|
|
@@ -3628,31 +3657,31 @@ function Tr(t, e) {
|
|
|
3628
3657
|
const n = (i) => i.id === `transient-activity:${e.callId}` && i.callId === e.callId || s && i.id.startsWith("transient-activity:") && i.toolName === "browser_tabs" && !!i.runId && i.runId === e.runId, r = t.findIndex(n);
|
|
3629
3658
|
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
3630
3659
|
}
|
|
3631
|
-
function
|
|
3632
|
-
return
|
|
3660
|
+
function Zt(t, e) {
|
|
3661
|
+
return Ds(
|
|
3633
3662
|
t,
|
|
3634
3663
|
e.map(
|
|
3635
|
-
(s) =>
|
|
3664
|
+
(s) => ts(t, s)
|
|
3636
3665
|
),
|
|
3637
|
-
|
|
3666
|
+
es
|
|
3638
3667
|
);
|
|
3639
3668
|
}
|
|
3640
|
-
function
|
|
3669
|
+
function Mr(t, e) {
|
|
3641
3670
|
const s = new Map(t.map((n) => [n.id, n]));
|
|
3642
3671
|
for (const n of e)
|
|
3643
3672
|
s.set(n.id, n);
|
|
3644
|
-
return
|
|
3673
|
+
return Zt(
|
|
3645
3674
|
t,
|
|
3646
3675
|
[...s.values()]
|
|
3647
|
-
).sort(
|
|
3676
|
+
).sort(Ar);
|
|
3648
3677
|
}
|
|
3649
|
-
function
|
|
3678
|
+
function Ar(t, e) {
|
|
3650
3679
|
if ((t.respondsToUserMessageId !== void 0 && t.respondsToUserMessageId === e.respondsToUserMessageId || t.respondsToUserMessageId === void 0 && e.respondsToUserMessageId === void 0 && t.runId !== void 0 && t.runId === e.runId) && t.causalSequence !== void 0 && e.causalSequence !== void 0 && t.causalSequence !== e.causalSequence)
|
|
3651
3680
|
return t.causalSequence - e.causalSequence;
|
|
3652
3681
|
const n = Date.parse(t.createdAt) - Date.parse(e.createdAt);
|
|
3653
3682
|
return Number.isNaN(n) ? 0 : n;
|
|
3654
3683
|
}
|
|
3655
|
-
function
|
|
3684
|
+
function es(t) {
|
|
3656
3685
|
const e = X(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3657
3686
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3658
3687
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
@@ -3664,52 +3693,52 @@ function Zt(t) {
|
|
|
3664
3693
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3665
3694
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3666
3695
|
...t.runId ? { runId: t.runId } : {},
|
|
3667
|
-
isOptimistic:
|
|
3696
|
+
isOptimistic: Pe(t),
|
|
3668
3697
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3669
3698
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3670
3699
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3671
3700
|
};
|
|
3672
3701
|
}
|
|
3673
|
-
function
|
|
3702
|
+
function ts(t, e) {
|
|
3674
3703
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3675
3704
|
return e;
|
|
3676
3705
|
const s = t.find(
|
|
3677
|
-
(o) => o.role === "user" && (o.id === e.id ||
|
|
3706
|
+
(o) => o.role === "user" && (o.id === e.id || Pe(o) && ss(o, e))
|
|
3678
3707
|
);
|
|
3679
3708
|
if (!s?.attachments?.length)
|
|
3680
3709
|
return e;
|
|
3681
3710
|
const n = e.attachments.map((o) => {
|
|
3682
|
-
const a =
|
|
3683
|
-
return a ?
|
|
3711
|
+
const a = Rr(s.attachments ?? [], o);
|
|
3712
|
+
return a ? Er(o, a) : o;
|
|
3684
3713
|
}), r = { ...e, attachments: n }, i = X(e);
|
|
3685
3714
|
return i && Object.defineProperty(r, "clientMessageId", {
|
|
3686
3715
|
value: i,
|
|
3687
3716
|
enumerable: !1
|
|
3688
3717
|
}), r;
|
|
3689
3718
|
}
|
|
3690
|
-
function
|
|
3719
|
+
function Rr(t, e) {
|
|
3691
3720
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
3692
3721
|
}
|
|
3693
|
-
function
|
|
3722
|
+
function Er(t, e) {
|
|
3694
3723
|
const { previewUrl: s } = e;
|
|
3695
3724
|
return s ? { ...t, previewUrl: s } : t;
|
|
3696
3725
|
}
|
|
3697
|
-
function
|
|
3726
|
+
function kr(t, e) {
|
|
3698
3727
|
if (e.role !== "user")
|
|
3699
3728
|
return t;
|
|
3700
3729
|
const s = t.findIndex(
|
|
3701
|
-
(r) =>
|
|
3730
|
+
(r) => Pe(r) && ss(r, e)
|
|
3702
3731
|
);
|
|
3703
3732
|
if (s === -1)
|
|
3704
3733
|
return t;
|
|
3705
3734
|
const n = [...t];
|
|
3706
3735
|
return n.splice(s, 1), n;
|
|
3707
3736
|
}
|
|
3708
|
-
function
|
|
3737
|
+
function ss(t, e) {
|
|
3709
3738
|
const s = X(t), n = X(e);
|
|
3710
3739
|
return s && n ? s === n : t.content === e.content;
|
|
3711
3740
|
}
|
|
3712
|
-
function
|
|
3741
|
+
function Pe(t) {
|
|
3713
3742
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3714
3743
|
}
|
|
3715
3744
|
function X(t) {
|
|
@@ -3721,19 +3750,19 @@ function X(t) {
|
|
|
3721
3750
|
);
|
|
3722
3751
|
return n ? t.id.slice(n.length) : null;
|
|
3723
3752
|
}
|
|
3724
|
-
function
|
|
3725
|
-
const e =
|
|
3753
|
+
function vt(t) {
|
|
3754
|
+
const e = ns(t);
|
|
3726
3755
|
if (e === null)
|
|
3727
3756
|
return !1;
|
|
3728
3757
|
const s = t[e].id;
|
|
3729
3758
|
if (t.some(
|
|
3730
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3759
|
+
(r) => r.respondsToUserMessageId === s && Re(r)
|
|
3731
3760
|
))
|
|
3732
3761
|
return !0;
|
|
3733
3762
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
3734
3763
|
const i = t[r];
|
|
3735
3764
|
if (!i.respondsToUserMessageId) {
|
|
3736
|
-
if (
|
|
3765
|
+
if (W(i))
|
|
3737
3766
|
return !0;
|
|
3738
3767
|
if (i.role === "system") {
|
|
3739
3768
|
if (i.dataType === "run_error")
|
|
@@ -3745,7 +3774,7 @@ function Ut(t) {
|
|
|
3745
3774
|
}
|
|
3746
3775
|
return !1;
|
|
3747
3776
|
}
|
|
3748
|
-
function
|
|
3777
|
+
function Cr(t, e, s) {
|
|
3749
3778
|
const n = new Set(
|
|
3750
3779
|
t.filter(
|
|
3751
3780
|
(r) => r.role === "user" && e !== null && X(r) === e
|
|
@@ -3759,31 +3788,31 @@ function kr(t, e, s) {
|
|
|
3759
3788
|
if (s && r.runId === s) {
|
|
3760
3789
|
if (n.size === 0)
|
|
3761
3790
|
return !0;
|
|
3762
|
-
const o =
|
|
3791
|
+
const o = rs(t, i);
|
|
3763
3792
|
return !r.respondsToUserMessageId && o !== null && n.has(o);
|
|
3764
3793
|
}
|
|
3765
3794
|
return !1;
|
|
3766
3795
|
});
|
|
3767
3796
|
}
|
|
3768
|
-
function
|
|
3769
|
-
const e =
|
|
3797
|
+
function br(t) {
|
|
3798
|
+
const e = ns(t);
|
|
3770
3799
|
if (e === null)
|
|
3771
|
-
return t.some(
|
|
3800
|
+
return t.some(W);
|
|
3772
3801
|
const s = t[e].id;
|
|
3773
3802
|
return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
|
|
3774
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
3775
|
-
) : t.slice(e + 1).some(
|
|
3803
|
+
(n) => n.respondsToUserMessageId === s && W(n)
|
|
3804
|
+
) : t.slice(e + 1).some(W);
|
|
3776
3805
|
}
|
|
3777
|
-
function
|
|
3806
|
+
function ns(t) {
|
|
3778
3807
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3779
|
-
if (t[e].role === "user" && !
|
|
3808
|
+
if (t[e].role === "user" && !Pe(t[e]))
|
|
3780
3809
|
return e;
|
|
3781
3810
|
return null;
|
|
3782
3811
|
}
|
|
3783
|
-
function
|
|
3784
|
-
return
|
|
3812
|
+
function Re(t) {
|
|
3813
|
+
return W(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3785
3814
|
}
|
|
3786
|
-
function
|
|
3815
|
+
function se(t) {
|
|
3787
3816
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
3788
3817
|
const s = t[e];
|
|
3789
3818
|
if (!s || typeof s != "object")
|
|
@@ -3797,30 +3826,30 @@ function te(t) {
|
|
|
3797
3826
|
}
|
|
3798
3827
|
return null;
|
|
3799
3828
|
}
|
|
3800
|
-
function
|
|
3801
|
-
const e =
|
|
3829
|
+
function _r(t) {
|
|
3830
|
+
const e = se(t);
|
|
3802
3831
|
if (e === null)
|
|
3803
3832
|
return null;
|
|
3804
|
-
const n =
|
|
3833
|
+
const n = P(t[e])?.page;
|
|
3805
3834
|
if (!n || typeof n != "object")
|
|
3806
3835
|
return null;
|
|
3807
3836
|
const r = n.url;
|
|
3808
3837
|
return typeof r == "string" ? r : null;
|
|
3809
3838
|
}
|
|
3810
|
-
function
|
|
3839
|
+
function P(t) {
|
|
3811
3840
|
if (!t || typeof t != "object")
|
|
3812
3841
|
return null;
|
|
3813
3842
|
const e = t.data;
|
|
3814
3843
|
return e && typeof e == "object" ? e : null;
|
|
3815
3844
|
}
|
|
3816
|
-
function
|
|
3845
|
+
function Ee(t) {
|
|
3817
3846
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3818
3847
|
}
|
|
3819
|
-
function
|
|
3848
|
+
function Dt(t) {
|
|
3820
3849
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3821
3850
|
}
|
|
3822
|
-
function
|
|
3823
|
-
const s =
|
|
3851
|
+
function Pr(t, e) {
|
|
3852
|
+
const s = se(e);
|
|
3824
3853
|
if (s === null)
|
|
3825
3854
|
return !1;
|
|
3826
3855
|
const n = e[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -3828,11 +3857,11 @@ function _r(t, e) {
|
|
|
3828
3857
|
return !1;
|
|
3829
3858
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3830
3859
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3831
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3832
|
-
) : t.slice(i + 1).some(
|
|
3860
|
+
(o) => o.respondsToUserMessageId === r && Re(o)
|
|
3861
|
+
) : t.slice(i + 1).some(Re);
|
|
3833
3862
|
}
|
|
3834
|
-
function
|
|
3835
|
-
const e =
|
|
3863
|
+
function Ye(t) {
|
|
3864
|
+
const e = se(t);
|
|
3836
3865
|
if (e === null)
|
|
3837
3866
|
return null;
|
|
3838
3867
|
const s = t[e];
|
|
@@ -3844,8 +3873,8 @@ function Qe(t) {
|
|
|
3844
3873
|
const r = n.clientMessageId;
|
|
3845
3874
|
return typeof r == "string" ? r : null;
|
|
3846
3875
|
}
|
|
3847
|
-
function
|
|
3848
|
-
const e =
|
|
3876
|
+
function Ur(t) {
|
|
3877
|
+
const e = se(t);
|
|
3849
3878
|
if (e === null)
|
|
3850
3879
|
return null;
|
|
3851
3880
|
for (let s = t.length - 1; s > e; s -= 1) {
|
|
@@ -3859,22 +3888,22 @@ function Pr(t) {
|
|
|
3859
3888
|
if (i.type === "message" && i.role === "assistant")
|
|
3860
3889
|
return null;
|
|
3861
3890
|
if (i.type === "run_error")
|
|
3862
|
-
return i.retryable !== !0 ? null :
|
|
3891
|
+
return i.retryable !== !0 ? null : Ze(t, i) ?? Ye(t);
|
|
3863
3892
|
if (i.type === "run_status")
|
|
3864
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3893
|
+
return i.status === "interrupted" && i.retryable === !0 ? Ze(t, i) ?? Ye(t) : null;
|
|
3865
3894
|
}
|
|
3866
3895
|
return null;
|
|
3867
3896
|
}
|
|
3868
|
-
function
|
|
3897
|
+
function Ze(t, e) {
|
|
3869
3898
|
if (typeof e.clientMessageId == "string")
|
|
3870
3899
|
return e.clientMessageId;
|
|
3871
3900
|
const s = L(e);
|
|
3872
3901
|
if (!s)
|
|
3873
3902
|
return null;
|
|
3874
|
-
const n = t.find((i) =>
|
|
3903
|
+
const n = t.find((i) => R(i, "id") === s), r = P(n);
|
|
3875
3904
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
3876
3905
|
}
|
|
3877
|
-
function
|
|
3906
|
+
function vr(t, e) {
|
|
3878
3907
|
let s = 0;
|
|
3879
3908
|
for (const n of t) {
|
|
3880
3909
|
if (!n || typeof n != "object")
|
|
@@ -3887,56 +3916,56 @@ function Ur(t, e) {
|
|
|
3887
3916
|
}
|
|
3888
3917
|
return s;
|
|
3889
3918
|
}
|
|
3890
|
-
function
|
|
3891
|
-
if (!e || !
|
|
3919
|
+
function Ot(t, e, s, n, r, i) {
|
|
3920
|
+
if (!e || !Or(t))
|
|
3892
3921
|
return !1;
|
|
3893
3922
|
const o = t;
|
|
3894
|
-
if (
|
|
3923
|
+
if (Ee(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3895
3924
|
return !1;
|
|
3896
3925
|
const a = L(o);
|
|
3897
|
-
return n !== null ? a !== null ? a === n : r !== null &&
|
|
3926
|
+
return n !== null ? a !== null ? a === n : r !== null && C(o) === r && i === n : r === null || C(o) === r;
|
|
3898
3927
|
}
|
|
3899
|
-
function
|
|
3928
|
+
function Dr(t, e) {
|
|
3900
3929
|
for (let s = e - 1; s >= 0; s -= 1) {
|
|
3901
|
-
const n =
|
|
3930
|
+
const n = P(t[s]);
|
|
3902
3931
|
if (n?.type === "message" && n.role === "user")
|
|
3903
|
-
return
|
|
3932
|
+
return R(t[s], "id");
|
|
3904
3933
|
}
|
|
3905
3934
|
return null;
|
|
3906
3935
|
}
|
|
3907
|
-
function
|
|
3936
|
+
function rs(t, e) {
|
|
3908
3937
|
for (let s = e - 1; s >= 0; s -= 1)
|
|
3909
3938
|
if (t[s].role === "user")
|
|
3910
3939
|
return t[s].id;
|
|
3911
3940
|
return null;
|
|
3912
3941
|
}
|
|
3913
|
-
function
|
|
3942
|
+
function Or(t) {
|
|
3914
3943
|
if (!t || typeof t != "object")
|
|
3915
3944
|
return !1;
|
|
3916
3945
|
const e = t;
|
|
3917
3946
|
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");
|
|
3918
3947
|
}
|
|
3919
|
-
function
|
|
3948
|
+
function W(t) {
|
|
3920
3949
|
return t.role === "assistant" && t.phase !== "commentary";
|
|
3921
3950
|
}
|
|
3922
|
-
function
|
|
3951
|
+
function qr(t) {
|
|
3923
3952
|
if (!t || typeof t != "object")
|
|
3924
3953
|
return !1;
|
|
3925
3954
|
const e = t;
|
|
3926
3955
|
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";
|
|
3927
3956
|
}
|
|
3928
|
-
function
|
|
3929
|
-
return t.filter((e, s) => J(e) ? !
|
|
3957
|
+
function et(t) {
|
|
3958
|
+
return t.filter((e, s) => J(e) ? !Kr(t, s) && !is(t, s) && !jr(t, s) && !zr(t, s) : Lr(e) ? e.retryable === !0 && Fr(t, s) ? !1 : !$r(t, s) : !0);
|
|
3930
3959
|
}
|
|
3931
|
-
function
|
|
3960
|
+
function Lr(t) {
|
|
3932
3961
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3933
3962
|
}
|
|
3934
3963
|
function J(t) {
|
|
3935
3964
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3936
3965
|
}
|
|
3937
|
-
function
|
|
3966
|
+
function Nr(t, e, s, n) {
|
|
3938
3967
|
const r = t.findIndex(
|
|
3939
|
-
(l, c) => J(l) && !
|
|
3968
|
+
(l, c) => J(l) && !is(t, c)
|
|
3940
3969
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3941
3970
|
(l) => l.role === "user" && l.id === o
|
|
3942
3971
|
) : null;
|
|
@@ -3946,13 +3975,13 @@ function Lr(t, e, s, n) {
|
|
|
3946
3975
|
runId: s ?? i?.runId ?? null
|
|
3947
3976
|
};
|
|
3948
3977
|
}
|
|
3949
|
-
function
|
|
3978
|
+
function Me(t) {
|
|
3950
3979
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3951
3980
|
}
|
|
3952
|
-
function
|
|
3953
|
-
return
|
|
3981
|
+
function xr(t, e) {
|
|
3982
|
+
return W(e) ? "completed" : Me(t) ? "stopped" : !Ee(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
|
|
3954
3983
|
}
|
|
3955
|
-
function
|
|
3984
|
+
function qt(t, e, s) {
|
|
3956
3985
|
const n = new Set(
|
|
3957
3986
|
t.filter(
|
|
3958
3987
|
(r) => r.role === "user" && e !== null && X(r) === e
|
|
@@ -3962,18 +3991,18 @@ function Ot(t, e, s) {
|
|
|
3962
3991
|
(r) => !J(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3963
3992
|
);
|
|
3964
3993
|
}
|
|
3965
|
-
function
|
|
3994
|
+
function is(t, e) {
|
|
3966
3995
|
return t.some(
|
|
3967
|
-
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) &&
|
|
3996
|
+
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && Br(
|
|
3968
3997
|
t,
|
|
3969
3998
|
e,
|
|
3970
3999
|
n
|
|
3971
4000
|
)
|
|
3972
4001
|
);
|
|
3973
4002
|
}
|
|
3974
|
-
function
|
|
4003
|
+
function Br(t, e, s) {
|
|
3975
4004
|
const n = t[e], r = t[s];
|
|
3976
|
-
if (
|
|
4005
|
+
if (de(n, r))
|
|
3977
4006
|
return !0;
|
|
3978
4007
|
if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
|
|
3979
4008
|
return !1;
|
|
@@ -3982,35 +4011,35 @@ function xr(t, e, s) {
|
|
|
3982
4011
|
return t[i].id === n.respondsToUserMessageId;
|
|
3983
4012
|
return !1;
|
|
3984
4013
|
}
|
|
3985
|
-
function
|
|
4014
|
+
function Wr(t, e) {
|
|
3986
4015
|
const s = [...t].reverse().find(
|
|
3987
|
-
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e &&
|
|
4016
|
+
(n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Lt(n) && !Hr(
|
|
3988
4017
|
t,
|
|
3989
4018
|
n.respondsToUserMessageId
|
|
3990
4019
|
)
|
|
3991
4020
|
)?.respondsToUserMessageId;
|
|
3992
4021
|
return s ? t.map(
|
|
3993
|
-
(n) => n.respondsToUserMessageId === s &&
|
|
4022
|
+
(n) => n.respondsToUserMessageId === s && Lt(n) ? { ...n, steered: !0 } : n
|
|
3994
4023
|
) : t;
|
|
3995
4024
|
}
|
|
3996
|
-
function
|
|
4025
|
+
function Lt(t) {
|
|
3997
4026
|
return t.role === "tool" || J(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3998
4027
|
}
|
|
3999
|
-
function
|
|
4028
|
+
function Hr(t, e) {
|
|
4000
4029
|
return t.some(
|
|
4001
|
-
(s) => s.respondsToUserMessageId === e && (
|
|
4030
|
+
(s) => s.respondsToUserMessageId === e && (W(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
|
|
4002
4031
|
);
|
|
4003
4032
|
}
|
|
4004
|
-
function
|
|
4033
|
+
function $r(t, e) {
|
|
4005
4034
|
const s = t[e];
|
|
4006
4035
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
4007
4036
|
const r = t[n];
|
|
4008
|
-
if (r.role === "assistant" &&
|
|
4037
|
+
if (r.role === "assistant" && de(s, r))
|
|
4009
4038
|
return !0;
|
|
4010
4039
|
}
|
|
4011
4040
|
return !1;
|
|
4012
4041
|
}
|
|
4013
|
-
function
|
|
4042
|
+
function Fr(t, e) {
|
|
4014
4043
|
const s = t[e];
|
|
4015
4044
|
if (!s.respondsToUserMessageId)
|
|
4016
4045
|
return !1;
|
|
@@ -4026,37 +4055,37 @@ function $r(t, e) {
|
|
|
4026
4055
|
function jr(t, e) {
|
|
4027
4056
|
const s = t[e];
|
|
4028
4057
|
return t.some(
|
|
4029
|
-
(n, r) => r !== e && n.role === "assistant" &&
|
|
4058
|
+
(n, r) => r !== e && n.role === "assistant" && de(s, n)
|
|
4030
4059
|
);
|
|
4031
4060
|
}
|
|
4032
|
-
function
|
|
4061
|
+
function zr(t, e) {
|
|
4033
4062
|
const s = t[e];
|
|
4034
4063
|
return t.some(
|
|
4035
|
-
(n, r) => r !== e && n.role === "tool" &&
|
|
4064
|
+
(n, r) => r !== e && n.role === "tool" && de(s, n)
|
|
4036
4065
|
);
|
|
4037
4066
|
}
|
|
4038
|
-
function
|
|
4067
|
+
function Kr(t, e) {
|
|
4039
4068
|
const s = t[e];
|
|
4040
4069
|
for (let n = e + 1; n < t.length; n += 1)
|
|
4041
|
-
if (J(t[n]) &&
|
|
4070
|
+
if (J(t[n]) && de(s, t[n]))
|
|
4042
4071
|
return !0;
|
|
4043
4072
|
return !1;
|
|
4044
4073
|
}
|
|
4045
|
-
function
|
|
4074
|
+
function de(t, e) {
|
|
4046
4075
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
4047
4076
|
}
|
|
4048
|
-
function
|
|
4077
|
+
function R(t, e) {
|
|
4049
4078
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
4050
4079
|
}
|
|
4051
|
-
function
|
|
4080
|
+
function Gr(t, e) {
|
|
4052
4081
|
try {
|
|
4053
|
-
const s = window.localStorage.getItem(`${
|
|
4082
|
+
const s = window.localStorage.getItem(`${Kt}${t}`);
|
|
4054
4083
|
if (!s)
|
|
4055
4084
|
return null;
|
|
4056
4085
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
4057
4086
|
if (e !== void 0 && r !== e)
|
|
4058
4087
|
return null;
|
|
4059
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
4088
|
+
const i = Array.isArray(n.messages) ? n.messages.map(ri).filter((o) => !!o) : [];
|
|
4060
4089
|
return {
|
|
4061
4090
|
sessionId: r,
|
|
4062
4091
|
messages: i
|
|
@@ -4065,51 +4094,51 @@ function Kr(t, e) {
|
|
|
4065
4094
|
return null;
|
|
4066
4095
|
}
|
|
4067
4096
|
}
|
|
4068
|
-
function
|
|
4097
|
+
function os(t) {
|
|
4069
4098
|
return t.role === "user" || t.role === "assistant" || t.dataType === "run_status" || t.dataType === "run_error";
|
|
4070
4099
|
}
|
|
4071
|
-
function
|
|
4100
|
+
function Vr(t, e) {
|
|
4072
4101
|
try {
|
|
4073
4102
|
window.localStorage.setItem(
|
|
4074
|
-
`${
|
|
4103
|
+
`${Kt}${t}`,
|
|
4075
4104
|
JSON.stringify({
|
|
4076
4105
|
sessionId: e.sessionId,
|
|
4077
|
-
messages: e.messages.filter(
|
|
4106
|
+
messages: e.messages.filter(os).slice(-yn).map(ii)
|
|
4078
4107
|
})
|
|
4079
4108
|
);
|
|
4080
4109
|
} catch {
|
|
4081
4110
|
return;
|
|
4082
4111
|
}
|
|
4083
4112
|
}
|
|
4084
|
-
function
|
|
4113
|
+
function Xr(t) {
|
|
4085
4114
|
try {
|
|
4086
|
-
const e = window.localStorage.getItem(`${
|
|
4115
|
+
const e = window.localStorage.getItem(`${Je}${t}`);
|
|
4087
4116
|
if (!e)
|
|
4088
4117
|
return [];
|
|
4089
4118
|
const s = JSON.parse(e);
|
|
4090
|
-
return Array.isArray(s) ? s.filter(
|
|
4119
|
+
return Array.isArray(s) ? s.filter(lt) : [];
|
|
4091
4120
|
} catch {
|
|
4092
4121
|
return [];
|
|
4093
4122
|
}
|
|
4094
4123
|
}
|
|
4095
4124
|
function V(t, e) {
|
|
4096
4125
|
try {
|
|
4097
|
-
const s = e.filter(
|
|
4126
|
+
const s = e.filter(lt);
|
|
4098
4127
|
if (s.length === 0) {
|
|
4099
|
-
window.localStorage.removeItem(`${
|
|
4128
|
+
window.localStorage.removeItem(`${Je}${t}`);
|
|
4100
4129
|
return;
|
|
4101
4130
|
}
|
|
4102
4131
|
window.localStorage.setItem(
|
|
4103
|
-
`${
|
|
4132
|
+
`${Je}${t}`,
|
|
4104
4133
|
JSON.stringify(s.slice(-25))
|
|
4105
4134
|
);
|
|
4106
4135
|
} catch {
|
|
4107
4136
|
return;
|
|
4108
4137
|
}
|
|
4109
4138
|
}
|
|
4110
|
-
function
|
|
4139
|
+
function as(t, e) {
|
|
4111
4140
|
try {
|
|
4112
|
-
const s = `${
|
|
4141
|
+
const s = `${_e}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
4113
4142
|
...o,
|
|
4114
4143
|
storedAt: Date.now(),
|
|
4115
4144
|
unloadUrl: n,
|
|
@@ -4123,28 +4152,28 @@ function os(t, e) {
|
|
|
4123
4152
|
} catch {
|
|
4124
4153
|
}
|
|
4125
4154
|
}
|
|
4126
|
-
function
|
|
4155
|
+
function Nt(t, e) {
|
|
4127
4156
|
try {
|
|
4128
|
-
if (window.sessionStorage.getItem(`${
|
|
4157
|
+
if (window.sessionStorage.getItem(`${_e}${t}`) === null)
|
|
4129
4158
|
return;
|
|
4130
4159
|
} catch {
|
|
4131
4160
|
return;
|
|
4132
4161
|
}
|
|
4133
|
-
|
|
4162
|
+
as(t, e);
|
|
4134
4163
|
}
|
|
4135
|
-
function
|
|
4164
|
+
function Jr(t) {
|
|
4136
4165
|
try {
|
|
4137
|
-
const e = `${
|
|
4166
|
+
const e = `${_e}${t}`, s = window.sessionStorage.getItem(e);
|
|
4138
4167
|
if (window.sessionStorage.removeItem(e), !s)
|
|
4139
4168
|
return [];
|
|
4140
4169
|
const n = JSON.parse(s);
|
|
4141
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
4170
|
+
return Array.isArray(n) ? n.flatMap((r) => Yr(r) ? [{
|
|
4142
4171
|
...r.event,
|
|
4143
|
-
page:
|
|
4172
|
+
page: b(),
|
|
4144
4173
|
rawOutput: {
|
|
4145
4174
|
pageContextRestarted: !0,
|
|
4146
4175
|
outcome: "unknown",
|
|
4147
|
-
message:
|
|
4176
|
+
message: Qr(location.href),
|
|
4148
4177
|
currentUrl: location.href,
|
|
4149
4178
|
console: [],
|
|
4150
4179
|
metadata: {
|
|
@@ -4161,17 +4190,17 @@ function Xr(t) {
|
|
|
4161
4190
|
return [];
|
|
4162
4191
|
}
|
|
4163
4192
|
}
|
|
4164
|
-
function
|
|
4193
|
+
function Qr(t) {
|
|
4165
4194
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
4166
4195
|
Current URL: ${t}`;
|
|
4167
4196
|
}
|
|
4168
|
-
function
|
|
4197
|
+
function Yr(t) {
|
|
4169
4198
|
if (!t || typeof t != "object")
|
|
4170
4199
|
return !1;
|
|
4171
4200
|
const e = t, s = e.event;
|
|
4172
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
4201
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && lt(s) && s.type === "tool.result";
|
|
4173
4202
|
}
|
|
4174
|
-
function
|
|
4203
|
+
function Zr(t, e) {
|
|
4175
4204
|
const s = new Set(
|
|
4176
4205
|
t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
4177
4206
|
);
|
|
@@ -4180,26 +4209,26 @@ function Yr(t, e) {
|
|
|
4180
4209
|
...e.filter((n) => !s.has(n.callId))
|
|
4181
4210
|
];
|
|
4182
4211
|
}
|
|
4183
|
-
function
|
|
4212
|
+
function ei(t) {
|
|
4184
4213
|
try {
|
|
4185
|
-
window.sessionStorage.removeItem(`${
|
|
4214
|
+
window.sessionStorage.removeItem(`${_e}${t}`);
|
|
4186
4215
|
} catch {
|
|
4187
4216
|
return;
|
|
4188
4217
|
}
|
|
4189
4218
|
}
|
|
4190
|
-
function
|
|
4219
|
+
function lt(t) {
|
|
4191
4220
|
if (!t || typeof t != "object")
|
|
4192
4221
|
return !1;
|
|
4193
4222
|
const e = t;
|
|
4194
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
4223
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && xt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? xt(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
|
|
4195
4224
|
}
|
|
4196
|
-
function
|
|
4225
|
+
function xt(t) {
|
|
4197
4226
|
if (!t || typeof t != "object")
|
|
4198
4227
|
return !1;
|
|
4199
4228
|
const e = t;
|
|
4200
4229
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
4201
4230
|
}
|
|
4202
|
-
function
|
|
4231
|
+
function ls(t, e) {
|
|
4203
4232
|
if (!Array.isArray(t))
|
|
4204
4233
|
return;
|
|
4205
4234
|
const s = t.filter((r) => {
|
|
@@ -4207,41 +4236,41 @@ function as(t, e) {
|
|
|
4207
4236
|
return !1;
|
|
4208
4237
|
const i = r;
|
|
4209
4238
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
4210
|
-
}), n = e ? s.map((r) =>
|
|
4239
|
+
}), n = e ? s.map((r) => cs(r, e)) : s;
|
|
4211
4240
|
return n.length > 0 ? n : void 0;
|
|
4212
4241
|
}
|
|
4213
|
-
function
|
|
4242
|
+
function cs(t, e) {
|
|
4214
4243
|
return t.fileUrl?.startsWith("/") ? {
|
|
4215
4244
|
...t,
|
|
4216
4245
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
4217
4246
|
} : t;
|
|
4218
4247
|
}
|
|
4219
|
-
function
|
|
4220
|
-
return t.type ||
|
|
4248
|
+
function tt(t) {
|
|
4249
|
+
return t.type || ni(t.name) || "application/octet-stream";
|
|
4221
4250
|
}
|
|
4222
|
-
function
|
|
4223
|
-
|
|
4251
|
+
function ti(t) {
|
|
4252
|
+
us({
|
|
4224
4253
|
name: t.name,
|
|
4225
|
-
mimeType:
|
|
4254
|
+
mimeType: tt(t),
|
|
4226
4255
|
sizeBytes: t.size
|
|
4227
4256
|
});
|
|
4228
4257
|
}
|
|
4229
|
-
function
|
|
4230
|
-
const e =
|
|
4231
|
-
if (!
|
|
4258
|
+
function us(t) {
|
|
4259
|
+
const e = si(t.name), s = t.mimeType.trim().toLowerCase();
|
|
4260
|
+
if (!gn.has(`${e}:${s}`))
|
|
4232
4261
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
4233
4262
|
if (t.sizeBytes <= 0 || t.sizeBytes >= jt)
|
|
4234
4263
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
4235
4264
|
}
|
|
4236
|
-
function
|
|
4265
|
+
function si(t) {
|
|
4237
4266
|
const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
|
|
4238
4267
|
return s >= 0 ? e.slice(s) : "";
|
|
4239
4268
|
}
|
|
4240
|
-
function
|
|
4269
|
+
function ni(t) {
|
|
4241
4270
|
const e = t.toLowerCase();
|
|
4242
4271
|
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;
|
|
4243
4272
|
}
|
|
4244
|
-
function
|
|
4273
|
+
function ri(t) {
|
|
4245
4274
|
if (!t || typeof t != "object")
|
|
4246
4275
|
return null;
|
|
4247
4276
|
const e = t;
|
|
@@ -4259,17 +4288,17 @@ function ni(t) {
|
|
|
4259
4288
|
scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
|
|
4260
4289
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
4261
4290
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
4262
|
-
attachments:
|
|
4291
|
+
attachments: ls(e.attachments)?.map(ke),
|
|
4263
4292
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
4264
4293
|
};
|
|
4265
4294
|
}
|
|
4266
|
-
function
|
|
4295
|
+
function ii(t) {
|
|
4267
4296
|
return t.attachments?.length ? {
|
|
4268
4297
|
...t,
|
|
4269
|
-
attachments: t.attachments.map(
|
|
4298
|
+
attachments: t.attachments.map(ke)
|
|
4270
4299
|
} : t;
|
|
4271
4300
|
}
|
|
4272
|
-
function
|
|
4301
|
+
function ke(t) {
|
|
4273
4302
|
const {
|
|
4274
4303
|
dataUrl: e,
|
|
4275
4304
|
objectUrl: s,
|
|
@@ -4283,43 +4312,43 @@ function L(t) {
|
|
|
4283
4312
|
const e = t.respondsToUserMessageId;
|
|
4284
4313
|
return typeof e == "string" && e ? e : null;
|
|
4285
4314
|
}
|
|
4286
|
-
function
|
|
4315
|
+
function C(t) {
|
|
4287
4316
|
const e = t.runId;
|
|
4288
4317
|
return typeof e == "string" && e ? e : null;
|
|
4289
4318
|
}
|
|
4290
|
-
function
|
|
4319
|
+
function oi(t) {
|
|
4291
4320
|
const e = t?.timeoutMs;
|
|
4292
|
-
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 <=
|
|
4321
|
+
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 <= En);
|
|
4293
4322
|
}
|
|
4294
|
-
function
|
|
4323
|
+
function ds(t) {
|
|
4295
4324
|
const e = {};
|
|
4296
4325
|
try {
|
|
4297
4326
|
new Headers(t).forEach((s, n) => {
|
|
4298
|
-
Object.keys(e).length <
|
|
4327
|
+
Object.keys(e).length < ot && (e[n] = ct(n, s));
|
|
4299
4328
|
});
|
|
4300
4329
|
} catch {
|
|
4301
4330
|
return {};
|
|
4302
4331
|
}
|
|
4303
4332
|
return e;
|
|
4304
4333
|
}
|
|
4305
|
-
function
|
|
4306
|
-
return
|
|
4334
|
+
function ct(t, e) {
|
|
4335
|
+
return ys(t) ? Ue : B(be(e), fn);
|
|
4307
4336
|
}
|
|
4308
|
-
function
|
|
4337
|
+
function ai(t, e) {
|
|
4309
4338
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
4310
4339
|
}
|
|
4311
|
-
async function
|
|
4312
|
-
const r =
|
|
4340
|
+
async function li(t, e, s, n) {
|
|
4341
|
+
const r = ds(t.headers);
|
|
4313
4342
|
n({
|
|
4314
4343
|
...e,
|
|
4315
4344
|
responseStatus: t.status,
|
|
4316
4345
|
responseHeaders: r,
|
|
4317
|
-
responseBody: await
|
|
4346
|
+
responseBody: await ci(t),
|
|
4318
4347
|
durationMs: Date.now() - s
|
|
4319
4348
|
});
|
|
4320
4349
|
}
|
|
4321
|
-
async function
|
|
4322
|
-
if (!
|
|
4350
|
+
async function ci(t) {
|
|
4351
|
+
if (!hs(t.headers))
|
|
4323
4352
|
return;
|
|
4324
4353
|
let e = null, s = null;
|
|
4325
4354
|
try {
|
|
@@ -4328,7 +4357,7 @@ async function li(t) {
|
|
|
4328
4357
|
const n = new Promise((a) => {
|
|
4329
4358
|
s = window.setTimeout(() => {
|
|
4330
4359
|
e?.cancel(), a("timeout");
|
|
4331
|
-
},
|
|
4360
|
+
}, mn);
|
|
4332
4361
|
}), r = new TextDecoder();
|
|
4333
4362
|
let i = "", o = 0;
|
|
4334
4363
|
for (; ; ) {
|
|
@@ -4337,10 +4366,10 @@ async function li(t) {
|
|
|
4337
4366
|
return;
|
|
4338
4367
|
const { done: l, value: c } = a;
|
|
4339
4368
|
if (l)
|
|
4340
|
-
return
|
|
4341
|
-
const d =
|
|
4369
|
+
return B(i + r.decode());
|
|
4370
|
+
const d = it - o;
|
|
4342
4371
|
if (c.byteLength > d)
|
|
4343
|
-
return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${
|
|
4372
|
+
return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${B(i)}... [truncated]`;
|
|
4344
4373
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
4345
4374
|
}
|
|
4346
4375
|
} catch {
|
|
@@ -4350,45 +4379,45 @@ async function li(t) {
|
|
|
4350
4379
|
s !== null && window.clearTimeout(s);
|
|
4351
4380
|
}
|
|
4352
4381
|
}
|
|
4353
|
-
function
|
|
4354
|
-
if (
|
|
4382
|
+
function ui(t, e) {
|
|
4383
|
+
if (hs(new Headers(e)))
|
|
4355
4384
|
try {
|
|
4356
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
4385
|
+
return t.responseType === "" || t.responseType === "text" ? B(t.responseText ?? "") : void 0;
|
|
4357
4386
|
} catch {
|
|
4358
4387
|
return;
|
|
4359
4388
|
}
|
|
4360
4389
|
}
|
|
4361
|
-
function
|
|
4390
|
+
function Bt(t) {
|
|
4362
4391
|
if (typeof t == "string")
|
|
4363
|
-
return
|
|
4392
|
+
return B(t);
|
|
4364
4393
|
}
|
|
4365
|
-
function
|
|
4394
|
+
function di(t) {
|
|
4366
4395
|
return q({
|
|
4367
4396
|
...t,
|
|
4368
|
-
requestBody:
|
|
4369
|
-
responseBody:
|
|
4397
|
+
requestBody: Wt(t.requestBody),
|
|
4398
|
+
responseBody: Wt(t.responseBody)
|
|
4370
4399
|
});
|
|
4371
4400
|
}
|
|
4372
|
-
function
|
|
4401
|
+
function Wt(t) {
|
|
4373
4402
|
if (typeof t != "string")
|
|
4374
4403
|
return t;
|
|
4375
4404
|
const e = t.trim();
|
|
4376
4405
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4377
|
-
return
|
|
4406
|
+
return be(t);
|
|
4378
4407
|
try {
|
|
4379
4408
|
return JSON.stringify(q(JSON.parse(t)));
|
|
4380
4409
|
} catch {
|
|
4381
|
-
return
|
|
4410
|
+
return be(t);
|
|
4382
4411
|
}
|
|
4383
4412
|
}
|
|
4384
|
-
function
|
|
4413
|
+
function hs(t) {
|
|
4385
4414
|
if (!t)
|
|
4386
4415
|
return !1;
|
|
4387
4416
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4388
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
4417
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= it && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4389
4418
|
}
|
|
4390
|
-
function
|
|
4391
|
-
if (
|
|
4419
|
+
function Z(t, e = {}, s) {
|
|
4420
|
+
if (pi(s))
|
|
4392
4421
|
return !0;
|
|
4393
4422
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
4394
4423
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -4403,8 +4432,8 @@ function Y(t, e = {}, s) {
|
|
|
4403
4432
|
return !0;
|
|
4404
4433
|
}
|
|
4405
4434
|
}
|
|
4406
|
-
function
|
|
4407
|
-
if (
|
|
4435
|
+
function hi(t, e) {
|
|
4436
|
+
if (Z(t))
|
|
4408
4437
|
return !0;
|
|
4409
4438
|
try {
|
|
4410
4439
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -4413,117 +4442,117 @@ function di(t, e) {
|
|
|
4413
4442
|
return !0;
|
|
4414
4443
|
}
|
|
4415
4444
|
}
|
|
4416
|
-
function
|
|
4445
|
+
function pi(t) {
|
|
4417
4446
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4418
4447
|
}
|
|
4419
|
-
function
|
|
4448
|
+
function gi(t) {
|
|
4420
4449
|
const e = {};
|
|
4421
4450
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4422
4451
|
const n = s.indexOf(":");
|
|
4423
4452
|
if (n <= 0)
|
|
4424
4453
|
continue;
|
|
4425
|
-
if (Object.keys(e).length >=
|
|
4454
|
+
if (Object.keys(e).length >= ot)
|
|
4426
4455
|
break;
|
|
4427
4456
|
const r = s.slice(0, n).trim();
|
|
4428
|
-
e[r] =
|
|
4457
|
+
e[r] = ct(r, s.slice(n + 1).trim());
|
|
4429
4458
|
}
|
|
4430
4459
|
return e;
|
|
4431
4460
|
}
|
|
4432
|
-
function
|
|
4461
|
+
function B(t, e = it) {
|
|
4433
4462
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4434
4463
|
}
|
|
4435
|
-
function
|
|
4464
|
+
function Ge(t) {
|
|
4436
4465
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4437
4466
|
}
|
|
4438
|
-
class
|
|
4467
|
+
class Ae extends Error {
|
|
4439
4468
|
constructor(e, s) {
|
|
4440
4469
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4441
4470
|
}
|
|
4442
4471
|
status;
|
|
4443
4472
|
}
|
|
4444
|
-
async function
|
|
4473
|
+
async function Se(t, e) {
|
|
4445
4474
|
let s = null;
|
|
4446
4475
|
for (let n = 0; n < Et; n += 1)
|
|
4447
4476
|
try {
|
|
4448
4477
|
return await t();
|
|
4449
4478
|
} catch (r) {
|
|
4450
|
-
if (s = r, n >= Et - 1 || !
|
|
4479
|
+
if (s = r, n >= Et - 1 || !mi(r))
|
|
4451
4480
|
throw r;
|
|
4452
|
-
await
|
|
4481
|
+
await fi(n);
|
|
4453
4482
|
}
|
|
4454
4483
|
throw s instanceof Error ? s : new Error(e);
|
|
4455
4484
|
}
|
|
4456
|
-
function
|
|
4485
|
+
function fi(t) {
|
|
4457
4486
|
return new Promise((e) => {
|
|
4458
|
-
window.setTimeout(e,
|
|
4487
|
+
window.setTimeout(e, pn[t] ?? 0);
|
|
4459
4488
|
});
|
|
4460
4489
|
}
|
|
4461
|
-
function fi(t) {
|
|
4462
|
-
return t instanceof Me ? mi(t.status) : t instanceof TypeError;
|
|
4463
|
-
}
|
|
4464
4490
|
function mi(t) {
|
|
4465
|
-
return t
|
|
4491
|
+
return t instanceof Ae ? yi(t.status) : t instanceof TypeError;
|
|
4466
4492
|
}
|
|
4467
4493
|
function yi(t) {
|
|
4494
|
+
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
4495
|
+
}
|
|
4496
|
+
function Ii(t) {
|
|
4468
4497
|
return t === 401 || t === 403;
|
|
4469
4498
|
}
|
|
4470
|
-
const
|
|
4499
|
+
const Ue = "[REDACTED_SECRET]", H = "[REDACTED_TOKEN]", Si = "[REDACTED_SIGNED_URL]", Ti = 20, wi = /^(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, ps = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, gs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, fs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ms = /\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, Mi = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Ai = /\bhttps?:\/\/[^\s"'<>]+/gi, Ri = /[),.;\]]+$/;
|
|
4471
4500
|
function q(t) {
|
|
4472
|
-
return
|
|
4501
|
+
return Ce(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4473
4502
|
}
|
|
4474
|
-
function
|
|
4503
|
+
function Ce(t, e, s) {
|
|
4475
4504
|
if (typeof t == "string")
|
|
4476
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4505
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : be(t);
|
|
4477
4506
|
if (t === null || typeof t != "object")
|
|
4478
4507
|
return t;
|
|
4479
|
-
if (e >=
|
|
4508
|
+
if (e >= Ti)
|
|
4480
4509
|
return "[REDACTED_MAX_DEPTH]";
|
|
4481
4510
|
if (s.has(t))
|
|
4482
4511
|
return "[REDACTED_CIRCULAR]";
|
|
4483
4512
|
if (s.add(t), Array.isArray(t))
|
|
4484
|
-
return t.map((r) =>
|
|
4513
|
+
return t.map((r) => Ce(r, e + 1, s));
|
|
4485
4514
|
const n = {};
|
|
4486
4515
|
for (const [r, i] of Object.entries(t))
|
|
4487
|
-
r === "pageContent" ? n[r] = i :
|
|
4516
|
+
r === "pageContent" ? n[r] = i : ys(r) ? n[r] = Ue : n[r] = r.toLowerCase() === "url" ? Ei(i) : Ce(i, e + 1, s);
|
|
4488
4517
|
return n;
|
|
4489
4518
|
}
|
|
4490
|
-
function
|
|
4519
|
+
function ys(t) {
|
|
4491
4520
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
4492
4521
|
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");
|
|
4493
4522
|
}
|
|
4494
|
-
function
|
|
4495
|
-
return typeof t == "string" ?
|
|
4523
|
+
function Ei(t) {
|
|
4524
|
+
return typeof t == "string" ? Is(t) : Ce(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4496
4525
|
}
|
|
4497
|
-
function
|
|
4526
|
+
function Is(t) {
|
|
4498
4527
|
try {
|
|
4499
4528
|
const e = new URL(t, location.href);
|
|
4500
4529
|
for (const s of Array.from(e.searchParams.keys()))
|
|
4501
|
-
|
|
4502
|
-
return e.username && (e.username =
|
|
4530
|
+
wi.test(s) && e.searchParams.set(s, H);
|
|
4531
|
+
return e.username && (e.username = H), e.password && (e.password = H), e.toString();
|
|
4503
4532
|
} catch {
|
|
4504
|
-
return
|
|
4533
|
+
return ki(t);
|
|
4505
4534
|
}
|
|
4506
4535
|
}
|
|
4507
|
-
function
|
|
4508
|
-
return t.replace(
|
|
4509
|
-
}
|
|
4510
|
-
function Ei(t) {
|
|
4511
|
-
return t.replace(hs, `Bearer ${j}`).replace(ps, `Basic ${j}`).replace(gs, j).replace(fs, (e, s) => `${s}: ${Pe}`);
|
|
4536
|
+
function be(t) {
|
|
4537
|
+
return t.replace(Mi, Si).replace(Ai, Ci).replace(ps, `Bearer ${H}`).replace(gs, `Basic ${H}`).replace(fs, H).replace(ms, (e, s) => `${s}: ${Ue}`);
|
|
4512
4538
|
}
|
|
4513
4539
|
function ki(t) {
|
|
4514
|
-
|
|
4515
|
-
|
|
4540
|
+
return t.replace(ps, `Bearer ${H}`).replace(gs, `Basic ${H}`).replace(fs, H).replace(ms, (e, s) => `${s}: ${Ue}`);
|
|
4541
|
+
}
|
|
4542
|
+
function Ci(t) {
|
|
4543
|
+
const e = t.match(Ri)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4544
|
+
return `${Is(s)}${e}`;
|
|
4516
4545
|
}
|
|
4517
4546
|
export {
|
|
4518
4547
|
ft as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4548
|
+
Xe as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4549
|
+
Js as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4550
|
+
Xs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4551
|
+
Qs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
4552
|
+
bi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
4553
|
+
Gt as PlunoProductAgent,
|
|
4554
|
+
Sn as calculateReconnectDelay,
|
|
4555
|
+
Gt as default,
|
|
4556
|
+
Hn as getProductAgentOriginAccessErrorMessage,
|
|
4557
|
+
ti as validateProductAgentProviderInputFile
|
|
4529
4558
|
};
|