@pluno/product-agent-web 0.1.184 → 0.1.186
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -0
- package/dist/product-agent-sdk.js +931 -894
- package/dist/product-agent-widget.js +1440 -1403
- 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 Ge = "files";
|
|
3
|
+
async function Ss(t) {
|
|
4
|
+
const e = await tt();
|
|
5
|
+
await As(e, "readwrite", (s) => s.put(t));
|
|
6
|
+
}
|
|
7
|
+
async function ws(t, e) {
|
|
8
|
+
const s = await tt();
|
|
9
|
+
await st(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await nt(
|
|
11
11
|
n.get(t)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -16,28 +16,28 @@ async function Ss(t, e) {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
const e = await
|
|
21
|
-
await
|
|
19
|
+
async function Ms(t = 864e5) {
|
|
20
|
+
const e = await tt(), s = Date.now() - t;
|
|
21
|
+
await st(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await nt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function tt() {
|
|
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(Ge, { 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 As(t, e, s) {
|
|
36
|
+
return await st(t, e, async (n) => await nt(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function st(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction(Ge, e), o = i.objectStore(Ge);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
s(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -57,16 +57,16 @@ function et(t, e, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function nt(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 Rs(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 Wt(t, e, s) {
|
|
69
|
+
const n = Reflect.get(t, "pluno"), r = Rs(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 Bt(t, e, s) {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
function
|
|
83
|
+
const Es = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
+
function ks(t, e) {
|
|
85
85
|
return e ? t.replace(
|
|
86
|
-
|
|
86
|
+
Es,
|
|
87
87
|
(s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
|
|
88
88
|
) : t;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
91
|
-
function
|
|
90
|
+
const Cs = "suggest_share_on_socials";
|
|
91
|
+
function bs(t) {
|
|
92
92
|
let e = t;
|
|
93
93
|
if (typeof t == "string")
|
|
94
94
|
try {
|
|
@@ -96,65 +96,65 @@ function Cs(t) {
|
|
|
96
96
|
} catch {
|
|
97
97
|
return null;
|
|
98
98
|
}
|
|
99
|
-
const s =
|
|
99
|
+
const s = _s(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 _s(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 Ps = "save_runtime_captured_skill";
|
|
106
|
+
function Us(t) {
|
|
107
|
+
return (t.type === "function_call" || t.type === "tool_call") && t.name === Ps;
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function vs(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((h) => r.has(h)))
|
|
116
|
+
), o = new Map(i.map(({ item: u, identity: h }) => [h.id, u])), a = new Map(
|
|
117
117
|
i.flatMap(
|
|
118
|
-
({ item: u, identity:
|
|
118
|
+
({ item: u, identity: h }) => h.optimisticKey ? [[h.optimisticKey, u]] : []
|
|
119
119
|
)
|
|
120
120
|
), l = new Map(
|
|
121
121
|
i.flatMap(
|
|
122
|
-
({ item: u, identity:
|
|
122
|
+
({ item: u, identity: h }) => h.assistantDraftKey ? [[h.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: h } of i)
|
|
126
|
+
for (const g of h.activityKeys ?? []) {
|
|
127
127
|
const m = c.get(g);
|
|
128
128
|
(!m || s(m).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)), p = new Set(
|
|
131
131
|
i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
|
|
132
132
|
), y = /* @__PURE__ */ new Set(), f = [];
|
|
133
133
|
for (const u of t) {
|
|
134
|
-
const
|
|
135
|
-
let g = o.get(
|
|
136
|
-
if (
|
|
134
|
+
const h = s(u);
|
|
135
|
+
let g = o.get(h.id);
|
|
136
|
+
if (h.isOptimistic && h.optimisticKey ? g = a.get(h.optimisticKey) : h.isAssistantDraft && h.assistantDraftKey ? g = l.get(h.assistantDraftKey) : h.isActivity && (g = h.activityKeys?.map((C) => c.get(C)).find((C) => C !== void 0) ?? g), g && !y.has(g)) {
|
|
137
137
|
f.push(g), y.add(g);
|
|
138
138
|
continue;
|
|
139
139
|
}
|
|
140
|
-
const m =
|
|
141
|
-
(
|
|
140
|
+
const m = h.respondsToUserMessageId !== void 0 && d.has(h.respondsToUserMessageId) || h.runId !== void 0 && p.has(h.runId);
|
|
141
|
+
(h.isOptimistic || (h.isAssistantDraft || h.isActivity) && m) && f.push(u);
|
|
142
142
|
}
|
|
143
143
|
for (const { item: u } of i)
|
|
144
144
|
y.has(u) || f.push(u);
|
|
145
145
|
return f;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function Ds(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 Ne = "pluno.productAgent.transportId", Os = "pluno.productAgent.transportIdentity", xe = "pluno.productAgent.transportIdentity.event", qs = 50, Ls = globalThis.setTimeout.bind(globalThis);
|
|
154
|
+
let re = null;
|
|
155
|
+
const Te = /* @__PURE__ */ new Set(), Be = /* @__PURE__ */ new Map();
|
|
156
|
+
async function Ns(t = Ht()) {
|
|
157
|
+
const e = t.randomUUID(), s = t.storage.getItem(Ne);
|
|
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 Os(t = Wt()) {
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
if (!s)
|
|
175
|
-
t.storage.setItem(
|
|
175
|
+
t.storage.setItem(Ne, n), r = !0;
|
|
176
176
|
else if (t.skipStoredIdentityCollisionCheck)
|
|
177
177
|
r = !0;
|
|
178
178
|
else
|
|
@@ -181,7 +181,7 @@ async function Os(t = Wt()) {
|
|
|
181
181
|
r = !0;
|
|
182
182
|
break;
|
|
183
183
|
}
|
|
184
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
184
|
+
n = t.randomUUID(), t.storage.setItem(Ne, n);
|
|
185
185
|
}
|
|
186
186
|
let a = !1;
|
|
187
187
|
return {
|
|
@@ -191,52 +191,52 @@ async function Os(t = Wt()) {
|
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
-
async function
|
|
195
|
-
|
|
196
|
-
...
|
|
194
|
+
async function xs(t = !1) {
|
|
195
|
+
re || (re = Ns({
|
|
196
|
+
...Ht(),
|
|
197
197
|
skipStoredIdentityCollisionCheck: t
|
|
198
|
-
}),
|
|
198
|
+
}), re.then((r) => {
|
|
199
199
|
const i = (o) => {
|
|
200
|
-
o.persisted || (r.release(),
|
|
200
|
+
o.persisted || (r.release(), re = 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 re, s = Bs();
|
|
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 Bs() {
|
|
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 Ht() {
|
|
222
222
|
return {
|
|
223
|
-
storage:
|
|
224
|
-
channel:
|
|
223
|
+
storage: Ws(),
|
|
224
|
+
channel: Hs(),
|
|
225
225
|
randomUUID: () => crypto.randomUUID(),
|
|
226
226
|
settle: () => new Promise((t) => Ls(t, qs))
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function Ws() {
|
|
230
230
|
return {
|
|
231
231
|
getItem: (t) => {
|
|
232
232
|
try {
|
|
233
|
-
return window.sessionStorage?.getItem(t) ??
|
|
233
|
+
return window.sessionStorage?.getItem(t) ?? Be.get(t) ?? null;
|
|
234
234
|
} catch {
|
|
235
|
-
return
|
|
235
|
+
return Be.get(t) ?? null;
|
|
236
236
|
}
|
|
237
237
|
},
|
|
238
238
|
setItem: (t, e) => {
|
|
239
|
-
|
|
239
|
+
Be.set(t, e);
|
|
240
240
|
try {
|
|
241
241
|
window.sessionStorage?.setItem(t, e);
|
|
242
242
|
} catch {
|
|
@@ -244,9 +244,9 @@ function Bs() {
|
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function Hs() {
|
|
248
248
|
if (typeof BroadcastChannel < "u") {
|
|
249
|
-
const t = new BroadcastChannel(
|
|
249
|
+
const t = new BroadcastChannel(Os);
|
|
250
250
|
return {
|
|
251
251
|
postMessage: (e) => t.postMessage(e),
|
|
252
252
|
subscribe: (e) => {
|
|
@@ -256,11 +256,11 @@ function Ws() {
|
|
|
256
256
|
close: () => t.close()
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
|
-
return
|
|
259
|
+
return $s();
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function $s() {
|
|
262
262
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
263
|
-
if (s.key !==
|
|
263
|
+
if (s.key !== xe || !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 Hs() {
|
|
|
269
269
|
return window.addEventListener("storage", e), {
|
|
270
270
|
postMessage: (s) => {
|
|
271
271
|
window.localStorage.setItem(
|
|
272
|
-
|
|
272
|
+
xe,
|
|
273
273
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
274
|
-
), window.localStorage.removeItem(
|
|
274
|
+
), window.localStorage.removeItem(xe);
|
|
275
275
|
},
|
|
276
276
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
277
277
|
close: () => {
|
|
@@ -279,8 +279,8 @@ function Hs() {
|
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
function
|
|
282
|
+
const $t = "schedule_follow_up";
|
|
283
|
+
function js(t) {
|
|
284
284
|
let e = t;
|
|
285
285
|
if (typeof e == "string")
|
|
286
286
|
try {
|
|
@@ -291,21 +291,21 @@ function $s(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 !== $t || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
295
295
|
}
|
|
296
|
-
const
|
|
296
|
+
const Fs = [
|
|
297
297
|
{ value: "gpt-5.6-sol", label: "gpt-5.6-sol" },
|
|
298
298
|
{ value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5" },
|
|
299
299
|
{ value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash" }
|
|
300
|
-
],
|
|
300
|
+
], zs = [
|
|
301
301
|
{ value: "anthropic/claude-opus-5", label: "Claude Opus 5" },
|
|
302
302
|
{ value: "gpt-5.6-terra", label: "gpt-5.6-terra" }
|
|
303
|
-
],
|
|
304
|
-
...
|
|
305
|
-
...
|
|
306
|
-
],
|
|
303
|
+
], Ks = [
|
|
304
|
+
...Fs,
|
|
305
|
+
...zs
|
|
306
|
+
], We = (t) => Ks.some((e) => e.value === t), Gs = globalThis.fetch.bind(globalThis), Ve = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Vs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Xs = ".pluno-pa-widget__panel", Js = ".pluno-pa-widget__timeline", ft = `${Ve}[data-pluno-sdk-preview-channel]`;
|
|
307
307
|
let Ys = 0;
|
|
308
|
-
function
|
|
308
|
+
function mt(t) {
|
|
309
309
|
const e = {};
|
|
310
310
|
for (const o of [
|
|
311
311
|
"type",
|
|
@@ -343,7 +343,7 @@ function gt(t) {
|
|
|
343
343
|
}
|
|
344
344
|
return e;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function He(t, e, s) {
|
|
347
347
|
if (typeof window > "u")
|
|
348
348
|
return;
|
|
349
349
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -362,27 +362,27 @@ function Be(t, e, s) {
|
|
|
362
362
|
};
|
|
363
363
|
window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
|
|
364
364
|
}
|
|
365
|
-
class
|
|
365
|
+
class pe extends Error {
|
|
366
366
|
}
|
|
367
367
|
function Qs(t) {
|
|
368
368
|
return t === 408 || t === 425 || t === 429 || t >= 500;
|
|
369
369
|
}
|
|
370
|
-
const Zs = "https://app.pluno.ai", en = 2e4, tn = 1e4, sn = 1e4, nn = 1e4, rn = 1e4, on = 3e3, an = 3e4, ln = 1e3,
|
|
370
|
+
const Zs = "https://app.pluno.ai", en = 2e4, tn = 1e4, sn = 1e4, nn = 1e4, rn = 1e4, on = 3e3, an = 3e4, ln = 1e3, yt = 3e4, It = 0.2, Tt = 6e4, St = 15e3, ie = 8, wt = "Browser connection was interrupted.", Mt = 15e3, cn = "Pluno could not send this message. Try it again.", At = 2e3, un = 1e3, dn = 100, Rt = 8e3, Et = 3, hn = [300, 1e3], jt = 50 * 1024 * 1024, pn = /* @__PURE__ */ new Set([
|
|
371
371
|
".jpeg:image/jpeg",
|
|
372
372
|
".jpg:image/jpeg",
|
|
373
373
|
".pdf:application/pdf",
|
|
374
374
|
".png:image/png",
|
|
375
375
|
".webp:image/webp"
|
|
376
|
-
]), ki = ".pdf,.png,.jpg,.jpeg,.webp",
|
|
377
|
-
function
|
|
376
|
+
]), ki = ".pdf,.png,.jpg,.jpeg,.webp", rt = 64e3, $e = 4e3, it = 30, gn = 2e3, fn = 1e3, Ft = "Image is too large for model vision input.", mn = 100, zt = "pluno.productAgent.state.", Xe = "pluno.productAgent.pendingEvents.", be = "pluno.productAgent.activeToolCalls.", yn = 100;
|
|
377
|
+
function oe(t, e = 0) {
|
|
378
378
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
379
379
|
return Math.max(e, s);
|
|
380
380
|
}
|
|
381
|
-
const
|
|
381
|
+
const Se = /* @__PURE__ */ new Set();
|
|
382
382
|
let ge = null;
|
|
383
383
|
function In(t, e = Math.random) {
|
|
384
|
-
const s = Math.min(
|
|
385
|
-
return Math.min(
|
|
384
|
+
const s = Math.min(yt, ln * 2 ** t), n = 1 - It + e() * It * 2;
|
|
385
|
+
return Math.min(yt, Math.round(s * n));
|
|
386
386
|
}
|
|
387
387
|
function Tn(t, e, s) {
|
|
388
388
|
return new Promise((n, r) => {
|
|
@@ -397,9 +397,9 @@ function Tn(t, e, s) {
|
|
|
397
397
|
);
|
|
398
398
|
});
|
|
399
399
|
}
|
|
400
|
-
class
|
|
400
|
+
class Kt {
|
|
401
401
|
constructor(e, s) {
|
|
402
|
-
this.options = e, this.transportIdentity = s, this.state = {
|
|
402
|
+
this.options = e, this.transportIdentity = s, this.personalModelSelectionOverride = e.productVariant === "personal" && We(e.model) ? e.model : null, this.state = {
|
|
403
403
|
...this.state,
|
|
404
404
|
starterPrompts: Qn(e.initialStarterPrompts)
|
|
405
405
|
};
|
|
@@ -409,7 +409,7 @@ class zt {
|
|
|
409
409
|
...n,
|
|
410
410
|
// Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
|
|
411
411
|
// activity is deliberately not restored here because it hydrates after the transcript is visible.
|
|
412
|
-
messages: n.messages.filter(
|
|
412
|
+
messages: n.messages.filter(is),
|
|
413
413
|
isLoadingSession: n.sessionId !== null,
|
|
414
414
|
status: "idle",
|
|
415
415
|
user: null,
|
|
@@ -431,7 +431,7 @@ class zt {
|
|
|
431
431
|
const r = [...this.queuedClientEvents].reverse().find(
|
|
432
432
|
(i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
|
|
433
433
|
);
|
|
434
|
-
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"),
|
|
434
|
+
r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), G(e.clientId, this.queuedClientEvents);
|
|
435
435
|
}
|
|
436
436
|
options;
|
|
437
437
|
listeners = {};
|
|
@@ -474,6 +474,9 @@ class zt {
|
|
|
474
474
|
backgroundSessionIds = /* @__PURE__ */ new Set();
|
|
475
475
|
backgroundClientMessageIds = /* @__PURE__ */ new Set();
|
|
476
476
|
deferredSessionUpdatedSessionIds = /* @__PURE__ */ new Set();
|
|
477
|
+
detachedSessionIds = /* @__PURE__ */ new Set();
|
|
478
|
+
detachedClientMessageIds = /* @__PURE__ */ new Set();
|
|
479
|
+
deferredDetachedSessionEvents = /* @__PURE__ */ new Map();
|
|
477
480
|
// The backend closes a retryable failed run with assistant_done; that paired event is recovery control flow,
|
|
478
481
|
// not successful completion of the user turn.
|
|
479
482
|
retryableFailureRunIdsAwaitingDone = /* @__PURE__ */ new Set();
|
|
@@ -485,6 +488,7 @@ class zt {
|
|
|
485
488
|
pendingClientMessageId = null;
|
|
486
489
|
pendingUserMessageEvent = null;
|
|
487
490
|
failedUserMessageEvent = null;
|
|
491
|
+
personalModelSelectionOverride = null;
|
|
488
492
|
activeClientMessageId = null;
|
|
489
493
|
activeResponseUserMessageId = null;
|
|
490
494
|
activeResponseRunId = null;
|
|
@@ -531,9 +535,9 @@ class zt {
|
|
|
531
535
|
lastErrorSecuritySettingsUrl: null
|
|
532
536
|
};
|
|
533
537
|
static async init(e) {
|
|
534
|
-
const s = e, n = await
|
|
538
|
+
const s = e, n = await xs(
|
|
535
539
|
s.skipStoredTransportIdentityCollisionCheck === !0
|
|
536
|
-
), r = new
|
|
540
|
+
), r = new Kt({
|
|
537
541
|
...e,
|
|
538
542
|
backendUrl: Nn(e.backendUrl ?? Zs),
|
|
539
543
|
clientId: e.clientId ?? nr(),
|
|
@@ -541,7 +545,7 @@ class zt {
|
|
|
541
545
|
entrySurface: xn(e.entrySurface)
|
|
542
546
|
}, n);
|
|
543
547
|
try {
|
|
544
|
-
|
|
548
|
+
Ms().catch((i) => {
|
|
545
549
|
w("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
546
550
|
message: i instanceof Error ? i.message : String(i)
|
|
547
551
|
});
|
|
@@ -600,7 +604,7 @@ class zt {
|
|
|
600
604
|
const i = Yn(r?.detail?.data);
|
|
601
605
|
i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
602
606
|
(o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
|
|
603
|
-
) && (this.queuedClientEvents.push(i),
|
|
607
|
+
) && (this.queuedClientEvents.push(i), G(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
|
|
604
608
|
}), n.addEventListener("close", (r) => {
|
|
605
609
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (w("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
606
610
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -633,7 +637,7 @@ class zt {
|
|
|
633
637
|
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;
|
|
634
638
|
}
|
|
635
639
|
destroy() {
|
|
636
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Qr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
640
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Qr(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();
|
|
637
641
|
for (const e of Object.values(this.listeners))
|
|
638
642
|
e?.clear();
|
|
639
643
|
}
|
|
@@ -672,12 +676,12 @@ class zt {
|
|
|
672
676
|
}
|
|
673
677
|
async sendMessage(e, s = {}) {
|
|
674
678
|
const n = e.trim(), r = s.attachments ?? [];
|
|
675
|
-
if (this.options.productVariant === "customer_embedded" && (r.forEach(
|
|
679
|
+
if (this.options.productVariant === "customer_embedded" && (r.forEach(cs), r.reduce(
|
|
676
680
|
(S, _) => S + _.sizeBytes,
|
|
677
681
|
0
|
|
678
|
-
) >
|
|
682
|
+
) > jt))
|
|
679
683
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
680
|
-
let i = r.map(
|
|
684
|
+
let i = r.map(Ee);
|
|
681
685
|
if (!n && i.length === 0)
|
|
682
686
|
return null;
|
|
683
687
|
if (this.pendingClientMessageId)
|
|
@@ -688,7 +692,7 @@ class zt {
|
|
|
688
692
|
content: n,
|
|
689
693
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
690
694
|
...r.length > 0 ? { attachments: r } : {}
|
|
691
|
-
}, c = this.state.messages.some((T) => T.id === l.id || T.clientMessageId === a), d = this.state.isThinking,
|
|
695
|
+
}, c = this.state.messages.some((T) => T.id === l.id || T.clientMessageId === a), d = this.state.isThinking, p = this.state.taskStatus, y = this.state.pendingMessageStatus, f = this.state.turnPhase, u = this.state.messages, h = c ? this.state.messages : [...this.state.messages, l], g = {
|
|
692
696
|
assistantDraft: this.state.assistantDraft,
|
|
693
697
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
694
698
|
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
@@ -697,7 +701,7 @@ class zt {
|
|
|
697
701
|
lastError: this.state.lastError
|
|
698
702
|
};
|
|
699
703
|
this.setState({
|
|
700
|
-
messages:
|
|
704
|
+
messages: h,
|
|
701
705
|
...d ? {} : {
|
|
702
706
|
assistantDraft: "",
|
|
703
707
|
assistantDraftItemId: null,
|
|
@@ -731,7 +735,7 @@ class zt {
|
|
|
731
735
|
...d ? {} : { ...g, isThinking: !1 },
|
|
732
736
|
pendingMessageStatus: y,
|
|
733
737
|
turnPhase: f,
|
|
734
|
-
taskStatus:
|
|
738
|
+
taskStatus: p
|
|
735
739
|
}), T;
|
|
736
740
|
}
|
|
737
741
|
this.retryableClientMessageId = null;
|
|
@@ -743,11 +747,11 @@ class zt {
|
|
|
743
747
|
invocation: Bn(s.invocation ?? s.initiatedBy),
|
|
744
748
|
entrySurface: this.options.entrySurface,
|
|
745
749
|
content: n,
|
|
746
|
-
pageContent: m &&
|
|
747
|
-
attachments: i.length > 0 ? i.map(
|
|
750
|
+
pageContent: m && ot() || void 0,
|
|
751
|
+
attachments: i.length > 0 ? i.map(Ee) : void 0,
|
|
748
752
|
page: o,
|
|
749
753
|
model: this.options.model,
|
|
750
|
-
metadata:
|
|
754
|
+
metadata: kt(this.options.metadata)
|
|
751
755
|
};
|
|
752
756
|
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = C, this.send(C), this.schedulePendingDeliveryAck(a), a;
|
|
753
757
|
}
|
|
@@ -755,7 +759,7 @@ class zt {
|
|
|
755
759
|
return this.options.model;
|
|
756
760
|
}
|
|
757
761
|
setModel(e) {
|
|
758
|
-
this.options.model = e;
|
|
762
|
+
this.options.model = e, this.options.productVariant === "personal" && We(e) && (this.personalModelSelectionOverride = e);
|
|
759
763
|
}
|
|
760
764
|
retryLastMessage() {
|
|
761
765
|
const e = this.state.sessionId, s = this.retryableClientMessageId;
|
|
@@ -777,12 +781,12 @@ class zt {
|
|
|
777
781
|
const s = B(), n = {
|
|
778
782
|
id: s,
|
|
779
783
|
name: e.name || "attachment",
|
|
780
|
-
mimeType:
|
|
784
|
+
mimeType: et(e),
|
|
781
785
|
sizeBytes: e.size
|
|
782
786
|
};
|
|
783
787
|
this.attachmentFiles.set(s, e);
|
|
784
788
|
const r = Date.now();
|
|
785
|
-
return
|
|
789
|
+
return Ss({
|
|
786
790
|
attachmentId: s,
|
|
787
791
|
name: n.name,
|
|
788
792
|
mimeType: n.mimeType,
|
|
@@ -811,7 +815,7 @@ class zt {
|
|
|
811
815
|
file: e,
|
|
812
816
|
attachment: s
|
|
813
817
|
}) {
|
|
814
|
-
const n = this.state.sessionId, r =
|
|
818
|
+
const n = this.state.sessionId, r = et(e), i = {
|
|
815
819
|
sessionId: n ?? void 0,
|
|
816
820
|
attachmentId: s.id,
|
|
817
821
|
clientId: this.options.clientId,
|
|
@@ -821,34 +825,34 @@ class zt {
|
|
|
821
825
|
sizeBytes: e.size,
|
|
822
826
|
page: b(),
|
|
823
827
|
model: this.options.model,
|
|
824
|
-
metadata:
|
|
828
|
+
metadata: kt(this.options.metadata),
|
|
825
829
|
entrySurface: this.options.entrySurface
|
|
826
830
|
};
|
|
827
831
|
let o;
|
|
828
832
|
if (this.options.persistAttachmentUpload)
|
|
829
|
-
o = await
|
|
833
|
+
o = await Ie(
|
|
830
834
|
() => this.options.persistAttachmentUpload(i, e),
|
|
831
835
|
"Failed to upload attachment"
|
|
832
836
|
);
|
|
833
837
|
else {
|
|
834
|
-
const l = this.options.prepareAttachmentUpload ? await
|
|
838
|
+
const l = this.options.prepareAttachmentUpload ? await Ie(
|
|
835
839
|
() => this.options.prepareAttachmentUpload(i),
|
|
836
840
|
"Failed to prepare attachment upload"
|
|
837
841
|
) : await this.prepareEmbedAttachmentUpload(i);
|
|
838
|
-
await
|
|
842
|
+
await Ie(async () => {
|
|
839
843
|
const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
|
|
840
844
|
method: l.uploadMethod,
|
|
841
845
|
headers: l.uploadHeaders,
|
|
842
846
|
body: e
|
|
843
847
|
});
|
|
844
848
|
if (!c.ok)
|
|
845
|
-
throw new
|
|
849
|
+
throw new Me("Failed to upload attachment", c.status);
|
|
846
850
|
return c;
|
|
847
851
|
}, "Failed to upload attachment"), o = l;
|
|
848
852
|
}
|
|
849
853
|
this.setState({ sessionId: o.sessionId });
|
|
850
|
-
const a =
|
|
851
|
-
return this.updateAttachmentInState(s.id, a), s.id &&
|
|
854
|
+
const a = ls(o.attachment, this.options.backendUrl);
|
|
855
|
+
return this.updateAttachmentInState(s.id, a), s.id && ws(s.id, {
|
|
852
856
|
sessionId: o.sessionId,
|
|
853
857
|
fileUrl: a.fileUrl,
|
|
854
858
|
sandboxPath: a.sandboxPath,
|
|
@@ -875,7 +879,7 @@ class zt {
|
|
|
875
879
|
}
|
|
876
880
|
async prepareEmbedAttachmentUpload(e) {
|
|
877
881
|
let s = !1;
|
|
878
|
-
return await
|
|
882
|
+
return await Ie(async () => {
|
|
879
883
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
880
884
|
if (n.ok)
|
|
881
885
|
return await n.json();
|
|
@@ -884,9 +888,9 @@ class zt {
|
|
|
884
888
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
885
889
|
if (r.ok)
|
|
886
890
|
return await r.json();
|
|
887
|
-
throw new
|
|
891
|
+
throw new Me("Failed to prepare attachment upload", r.status);
|
|
888
892
|
}
|
|
889
|
-
throw new
|
|
893
|
+
throw new Me("Failed to prepare attachment upload", n.status);
|
|
890
894
|
}, "Failed to prepare attachment upload");
|
|
891
895
|
}
|
|
892
896
|
async fetchEmbedAttachmentUpload(e) {
|
|
@@ -904,7 +908,7 @@ class zt {
|
|
|
904
908
|
if (!this.state.sessionId)
|
|
905
909
|
return;
|
|
906
910
|
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
907
|
-
const e =
|
|
911
|
+
const e = qr(
|
|
908
912
|
this.state.messages,
|
|
909
913
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
910
914
|
this.state.assistantDraftRunId,
|
|
@@ -917,7 +921,7 @@ class zt {
|
|
|
917
921
|
stoppedCausalSequence: null,
|
|
918
922
|
toolCallIds: new Set(
|
|
919
923
|
this.state.messages.filter(
|
|
920
|
-
(s) =>
|
|
924
|
+
(s) => ze(
|
|
921
925
|
s,
|
|
922
926
|
e.respondsToUserMessageId,
|
|
923
927
|
e.runId
|
|
@@ -928,7 +932,7 @@ class zt {
|
|
|
928
932
|
for (const [s, n] of this.activeBrowserToolCalls)
|
|
929
933
|
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
|
|
930
934
|
Lt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
931
|
-
messages:
|
|
935
|
+
messages: Ot(
|
|
932
936
|
this.state.messages,
|
|
933
937
|
e.clientMessageId,
|
|
934
938
|
e.runId
|
|
@@ -944,7 +948,7 @@ class zt {
|
|
|
944
948
|
}
|
|
945
949
|
startNewSession(e = {}) {
|
|
946
950
|
const s = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
|
|
947
|
-
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.options.model = void 0), s && this.send({
|
|
951
|
+
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.personalModelSelectionOverride = null, this.options.model = void 0), s && this.send({
|
|
948
952
|
type: "session.reset",
|
|
949
953
|
sessionId: this.state.sessionId ?? void 0,
|
|
950
954
|
warmupId: n ?? void 0,
|
|
@@ -970,7 +974,7 @@ class zt {
|
|
|
970
974
|
const s = B(), n = new Promise((i, o) => {
|
|
971
975
|
const a = window.setTimeout(() => {
|
|
972
976
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
973
|
-
},
|
|
977
|
+
}, Rt);
|
|
974
978
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
975
979
|
}), r = {
|
|
976
980
|
type: "sessions.list",
|
|
@@ -1002,11 +1006,11 @@ class zt {
|
|
|
1002
1006
|
}
|
|
1003
1007
|
loadSession(e) {
|
|
1004
1008
|
const s = B(), n = this.activeComposerWarmupId;
|
|
1005
|
-
!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({
|
|
1009
|
+
!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({
|
|
1006
1010
|
type: "session.reset",
|
|
1007
1011
|
warmupId: n,
|
|
1008
1012
|
page: b()
|
|
1009
|
-
}), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionActivityRequestId = null, this.setState({
|
|
1013
|
+
}), 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({
|
|
1010
1014
|
sessionId: e,
|
|
1011
1015
|
messages: [],
|
|
1012
1016
|
isLoadingSession: !0,
|
|
@@ -1098,7 +1102,7 @@ class zt {
|
|
|
1098
1102
|
try {
|
|
1099
1103
|
const o = this.options.token ?? await this.options.tokenProvider?.() ?? this.token;
|
|
1100
1104
|
if (!o)
|
|
1101
|
-
throw new
|
|
1105
|
+
throw new pe("Product Agent history requires authentication");
|
|
1102
1106
|
this.token = o;
|
|
1103
1107
|
const a = new URLSearchParams();
|
|
1104
1108
|
s === "activity" && a.set("limit", "200"), n && a.set("cursor", n);
|
|
@@ -1112,18 +1116,18 @@ class zt {
|
|
|
1112
1116
|
});
|
|
1113
1117
|
if (!d.ok) {
|
|
1114
1118
|
const y = await d.text() || `History request failed (${d.status})`;
|
|
1115
|
-
throw Qs(d.status) ? new Error(y) : new
|
|
1119
|
+
throw Qs(d.status) ? new Error(y) : new pe(y);
|
|
1116
1120
|
}
|
|
1117
|
-
const
|
|
1118
|
-
if (!
|
|
1119
|
-
throw new
|
|
1121
|
+
const p = await d.json();
|
|
1122
|
+
if (!p?.session || !Array.isArray(p.items))
|
|
1123
|
+
throw new pe("Invalid Product Agent session history response");
|
|
1120
1124
|
return {
|
|
1121
|
-
session:
|
|
1122
|
-
items:
|
|
1123
|
-
nextCursor: typeof
|
|
1125
|
+
session: p.session,
|
|
1126
|
+
items: p.items,
|
|
1127
|
+
nextCursor: typeof p.nextCursor == "string" ? p.nextCursor : null
|
|
1124
1128
|
};
|
|
1125
1129
|
} catch (o) {
|
|
1126
|
-
if (o instanceof
|
|
1130
|
+
if (o instanceof pe)
|
|
1127
1131
|
throw o;
|
|
1128
1132
|
w("web-sdk.history", "HTTP session history page failed; retrying", {
|
|
1129
1133
|
sessionId: e,
|
|
@@ -1157,9 +1161,9 @@ class zt {
|
|
|
1157
1161
|
});
|
|
1158
1162
|
}
|
|
1159
1163
|
send(e) {
|
|
1160
|
-
this.sendNow(
|
|
1164
|
+
this.sendNow(q(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
1161
1165
|
(r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
|
|
1162
|
-
) || this.queuedClientEvents.push(e),
|
|
1166
|
+
) || this.queuedClientEvents.push(e), G(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
1163
1167
|
status: "reconnecting",
|
|
1164
1168
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
1165
1169
|
}), this.scheduleReconnect());
|
|
@@ -1175,7 +1179,7 @@ class zt {
|
|
|
1175
1179
|
return !1;
|
|
1176
1180
|
const s = this.socket;
|
|
1177
1181
|
try {
|
|
1178
|
-
return s.send(JSON.stringify(e)),
|
|
1182
|
+
return s.send(JSON.stringify(e)), He("client_event", e.type, mt(e)), !0;
|
|
1179
1183
|
} catch (n) {
|
|
1180
1184
|
return w("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1181
1185
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -1221,7 +1225,7 @@ class zt {
|
|
|
1221
1225
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
1222
1226
|
const e = $n();
|
|
1223
1227
|
this.sendNow(
|
|
1224
|
-
|
|
1228
|
+
q({
|
|
1225
1229
|
type: "starter_prompts.page_context",
|
|
1226
1230
|
pageUrl: e.pageUrl,
|
|
1227
1231
|
pageTitle: e.pageTitle,
|
|
@@ -1251,18 +1255,18 @@ class zt {
|
|
|
1251
1255
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
1252
1256
|
return;
|
|
1253
1257
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
1254
|
-
|
|
1258
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1255
1259
|
for (let s = 0; s < e.length; s += 1) {
|
|
1256
1260
|
const n = e[s];
|
|
1257
|
-
if (!this.sendNow(
|
|
1258
|
-
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)),
|
|
1261
|
+
if (!this.sendNow(q(n))) {
|
|
1262
|
+
this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), G(this.options.clientId, this.queuedClientEvents);
|
|
1259
1263
|
return;
|
|
1260
1264
|
}
|
|
1261
|
-
|
|
1265
|
+
G(this.options.clientId, this.queuedClientEvents);
|
|
1262
1266
|
}
|
|
1263
1267
|
}
|
|
1264
1268
|
resetForAuthenticationScopeChange() {
|
|
1265
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
1269
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], G(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
|
|
1266
1270
|
}
|
|
1267
1271
|
flushPendingWidgetLifecycleEvents() {
|
|
1268
1272
|
if (this.authenticatedSocket !== this.socket || this.socket?.readyState !== WebSocket.OPEN || this.pendingWidgetLifecycleEvents.length === 0)
|
|
@@ -1299,14 +1303,14 @@ class zt {
|
|
|
1299
1303
|
findStoppedTurnForEvent(e) {
|
|
1300
1304
|
const s = e.type === "session.item" ? U(e.item) : null;
|
|
1301
1305
|
return this.findStoppedTurn(
|
|
1302
|
-
|
|
1306
|
+
K(e) ?? this.state.sessionId,
|
|
1303
1307
|
s ?? e
|
|
1304
1308
|
);
|
|
1305
1309
|
}
|
|
1306
1310
|
rememberDurablyStoppedTurn(e, s, n) {
|
|
1307
|
-
if (!e || !s || !
|
|
1311
|
+
if (!e || !s || !we(s) || this.findStoppedTurn(e, s))
|
|
1308
1312
|
return;
|
|
1309
|
-
const r =
|
|
1313
|
+
const r = L(s), i = k(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
|
|
1310
1314
|
this.stoppedTurns.push({
|
|
1311
1315
|
sessionId: e,
|
|
1312
1316
|
clientMessageId: o,
|
|
@@ -1316,7 +1320,7 @@ class zt {
|
|
|
1316
1320
|
stoppedCausalSequence: D(s),
|
|
1317
1321
|
toolCallIds: new Set(
|
|
1318
1322
|
this.state.messages.filter(
|
|
1319
|
-
(a) =>
|
|
1323
|
+
(a) => ze(a, r, i)
|
|
1320
1324
|
).map((a) => a.callId).filter((a) => typeof a == "string")
|
|
1321
1325
|
)
|
|
1322
1326
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
@@ -1326,12 +1330,12 @@ class zt {
|
|
|
1326
1330
|
const n = typeof e.callId == "string" ? e.callId : null;
|
|
1327
1331
|
return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
|
|
1328
1332
|
}
|
|
1329
|
-
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !
|
|
1333
|
+
return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !we(U(e.item)) : e.type !== "conversation.state" : !1;
|
|
1330
1334
|
}
|
|
1331
1335
|
filterStoppedSnapshotItems(e, s) {
|
|
1332
1336
|
return e.filter((n) => {
|
|
1333
1337
|
const r = U(n), i = r ? this.findStoppedTurn(s, r) : null;
|
|
1334
|
-
if (!i || r?.type === "message" && r.role === "user" ||
|
|
1338
|
+
if (!i || r?.type === "message" && r.role === "user" || we(r))
|
|
1335
1339
|
return !0;
|
|
1336
1340
|
if (i.stoppedCausalSequence !== null) {
|
|
1337
1341
|
const o = r ? D(r) : null;
|
|
@@ -1345,7 +1349,7 @@ class zt {
|
|
|
1345
1349
|
});
|
|
1346
1350
|
}
|
|
1347
1351
|
handleServerEvent(e) {
|
|
1348
|
-
if (
|
|
1352
|
+
if (He("server_event", e.type, mt(e)), e.type === "session.subscribed") {
|
|
1349
1353
|
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1350
1354
|
if (s && n && s === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
|
|
1351
1355
|
const r = this.pendingSessionSubscription;
|
|
@@ -1358,7 +1362,7 @@ class zt {
|
|
|
1358
1362
|
this.pendingSessionSubscription = null, s.resolve(!1), n && (this.sessionHistoryHydration = null, this.handleServerEvent({ ...e, requestId: n.requestId }));
|
|
1359
1363
|
return;
|
|
1360
1364
|
}
|
|
1361
|
-
if (this.sessionHistoryHydration &&
|
|
1365
|
+
if (this.sessionHistoryHydration && fe(e) && K(e) === this.sessionHistoryHydration.sessionId) {
|
|
1362
1366
|
this.sessionHistoryHydration.bufferedEvents.push(e);
|
|
1363
1367
|
return;
|
|
1364
1368
|
}
|
|
@@ -1367,450 +1371,483 @@ class zt {
|
|
|
1367
1371
|
U(e.item),
|
|
1368
1372
|
M(e.item, "createdAt")
|
|
1369
1373
|
), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
|
|
1370
|
-
if (e.type === "
|
|
1371
|
-
this.
|
|
1372
|
-
return;
|
|
1373
|
-
}
|
|
1374
|
-
if (e.type === "run.ack") {
|
|
1375
|
-
if (this.shouldIgnoreStoppedTurnEvent(e))
|
|
1376
|
-
return;
|
|
1377
|
-
const s = oe(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1378
|
-
s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && (n === this.activeClientMessageId || n === this.pendingClientMessageId) && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(e);
|
|
1374
|
+
if (e.type === "run.ack" && typeof e.sessionId == "string" && typeof e.clientMessageId == "string" && this.detachedClientMessageIds.delete(e.clientMessageId) && e.sessionId !== this.state.sessionId) {
|
|
1375
|
+
this.detachedSessionIds.add(e.sessionId), this.deferredDetachedSessionEvents.delete(e.sessionId);
|
|
1379
1376
|
return;
|
|
1380
1377
|
}
|
|
1381
|
-
if (
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1378
|
+
if (!this.shouldDeferDetachedSessionEvent(e) && !this.shouldIgnoreDetachedSessionEvent(e)) {
|
|
1379
|
+
if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
|
|
1380
|
+
this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
|
|
1385
1381
|
return;
|
|
1386
1382
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
if (e.type === "run.steered") {
|
|
1390
|
-
this.handleRunSteered(e);
|
|
1391
|
-
return;
|
|
1392
|
-
}
|
|
1393
|
-
if (e.type === "runtime.pong") {
|
|
1394
|
-
this.clearHeartbeatAckTimer();
|
|
1395
|
-
return;
|
|
1396
|
-
}
|
|
1397
|
-
if (e.type === "run.model_started") {
|
|
1398
|
-
const s = typeof e.runId == "string" ? e.runId : null;
|
|
1399
|
-
if (!this.state.isThinking || !s || this.activeResponseRunId && this.activeResponseRunId !== s)
|
|
1383
|
+
if (e.type === "run.ack") {
|
|
1384
|
+
if (this.shouldIgnoreStoppedTurnEvent(e))
|
|
1400
1385
|
return;
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
1406
|
-
const s = rr(e.user);
|
|
1407
|
-
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();
|
|
1408
|
-
const n = Zn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1409
|
-
w("web-sdk.agent", "Received auth.ok appearance", {
|
|
1410
|
-
hasAppearance: r,
|
|
1411
|
-
rawAppearance: e.appearance,
|
|
1412
|
-
normalizedAppearance: n
|
|
1413
|
-
}), this.runtimeHelperJavascript = er(e.runtimeHelpers)?.javascript ?? null;
|
|
1414
|
-
const i = bt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1415
|
-
user: s,
|
|
1416
|
-
status: "connected",
|
|
1417
|
-
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1418
|
-
};
|
|
1419
|
-
(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 && !fe() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1420
|
-
type: "page.upsert",
|
|
1421
|
-
sessionId: this.state.sessionId,
|
|
1422
|
-
page: b(),
|
|
1423
|
-
model: this.options.model
|
|
1424
|
-
});
|
|
1386
|
+
const s = K(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null, r = s ? this.deferredDetachedSessionEvents.get(s) ?? [] : [];
|
|
1387
|
+
s && this.deferredDetachedSessionEvents.delete(s), s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && (n === this.activeClientMessageId || n === this.pendingClientMessageId) && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(e);
|
|
1388
|
+
for (const i of r)
|
|
1389
|
+
this.handleServerEvent(i);
|
|
1425
1390
|
return;
|
|
1426
1391
|
}
|
|
1427
|
-
if (e.type === "
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1392
|
+
if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
|
|
1393
|
+
const s = K(e);
|
|
1394
|
+
if (s) {
|
|
1395
|
+
this.deferredSessionUpdatedSessionIds.add(s);
|
|
1396
|
+
return;
|
|
1397
|
+
}
|
|
1433
1398
|
}
|
|
1434
|
-
if (e
|
|
1435
|
-
|
|
1436
|
-
|
|
1399
|
+
if (!this.shouldIgnoreBackgroundSessionEvent(e) && !this.shouldIgnoreStoppedTurnEvent(e)) {
|
|
1400
|
+
if (e.type === "run.steered") {
|
|
1401
|
+
this.handleRunSteered(e);
|
|
1437
1402
|
return;
|
|
1438
|
-
this.updatePersonalModelFromSession(e.session), n === this.state.sessionId && this.clearSessionLoadRequest();
|
|
1439
|
-
for (const E of s)
|
|
1440
|
-
this.rememberDurablyStoppedTurn(
|
|
1441
|
-
n,
|
|
1442
|
-
U(E),
|
|
1443
|
-
M(E, "createdAt")
|
|
1444
|
-
);
|
|
1445
|
-
const o = Z(s), a = o === null ? null : s[o], l = U(a), c = this.findStoppedTurn(n, {
|
|
1446
|
-
clientMessageId: l?.clientMessageId,
|
|
1447
|
-
respondsToUserMessageId: M(a, "id"),
|
|
1448
|
-
runId: l?.runId
|
|
1449
|
-
}), d = this.filterStoppedSnapshotItems(s, n), h = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, y = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, f = e.isRetrying === !0, u = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1450
|
-
h && y && (this.pendingClientMessageId = y);
|
|
1451
|
-
let p = pr(
|
|
1452
|
-
e.assistantDraft
|
|
1453
|
-
);
|
|
1454
|
-
p && this.findStoppedTurn(n, {
|
|
1455
|
-
respondsToUserMessageId: p.respondsToUserMessageId,
|
|
1456
|
-
runId: p.runId
|
|
1457
|
-
}) && (p = void 0);
|
|
1458
|
-
const g = p !== void 0;
|
|
1459
|
-
this.rememberUserMessageClientMessageIds(d);
|
|
1460
|
-
const m = _r(d);
|
|
1461
|
-
if (m) {
|
|
1462
|
-
const E = Pr(d, m);
|
|
1463
|
-
this.retryAttemptsByClientMessageId[m] = Math.max(
|
|
1464
|
-
this.retryAttemptsByClientMessageId[m] ?? 0,
|
|
1465
|
-
E
|
|
1466
|
-
);
|
|
1467
1403
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
return Ut(q) ? !1 : !q || !m || !Ae(q) ? !0 : Je(d, q) !== m;
|
|
1471
|
-
}), S = Yt(
|
|
1472
|
-
this.state.messages,
|
|
1473
|
-
_t(C, this.options.backendUrl)
|
|
1474
|
-
), _ = Pt(S), v = g ? p?.content ?? "" : this.state.assistantDraft, R = g ? p?.itemId ?? null : this.state.assistantDraftItemId, ee = g ? p?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, P = g ? p?.runId ?? null : this.state.assistantDraftRunId, F = d.some(
|
|
1475
|
-
(E, q) => vt(
|
|
1476
|
-
U(E),
|
|
1477
|
-
v,
|
|
1478
|
-
R,
|
|
1479
|
-
ee,
|
|
1480
|
-
P,
|
|
1481
|
-
Ur(d, q)
|
|
1482
|
-
)
|
|
1483
|
-
), X = g ? p?.content ?? "" : this.state.assistantDraft, te = !!p?.content && !F, N = _ && (!X || F), ue = kr(S), z = N && ue ? "completed" : c ? "stopped" : N ? "failed" : null;
|
|
1484
|
-
if (!_ && br(this.state.messages, d))
|
|
1404
|
+
if (e.type === "runtime.pong") {
|
|
1405
|
+
this.clearHeartbeatAckTimer();
|
|
1485
1406
|
return;
|
|
1486
|
-
this.lastUserMessagePageUrl = Cr(d);
|
|
1487
|
-
const x = N || c ? null : Xe(d);
|
|
1488
|
-
if (this.latestRecoverableClientMessageId = x, ue && this.clearRetryTimers(), this.setState({
|
|
1489
|
-
sessionId: M(e.session, "id") ?? this.state.sessionId,
|
|
1490
|
-
messages: S,
|
|
1491
|
-
isLoadingSession: !1,
|
|
1492
|
-
...h ? { pendingMessageStatus: h } : {},
|
|
1493
|
-
...u ? { turnPhase: u } : {},
|
|
1494
|
-
isRetrying: f,
|
|
1495
|
-
...z && this.state.taskStatus === "working" ? { taskStatus: z } : {},
|
|
1496
|
-
...F ? {
|
|
1497
|
-
assistantDraft: "",
|
|
1498
|
-
assistantDraftItemId: null,
|
|
1499
|
-
assistantDraftPhase: null,
|
|
1500
|
-
assistantDraftRespondsToUserMessageId: null,
|
|
1501
|
-
assistantDraftRunId: null
|
|
1502
|
-
} : g ? {
|
|
1503
|
-
assistantDraft: p?.content ?? "",
|
|
1504
|
-
assistantDraftItemId: p?.itemId ?? null,
|
|
1505
|
-
assistantDraftPhase: p?.phase ?? null,
|
|
1506
|
-
assistantDraftRespondsToUserMessageId: p?.respondsToUserMessageId ?? null,
|
|
1507
|
-
assistantDraftRunId: p?.runId ?? null
|
|
1508
|
-
} : {},
|
|
1509
|
-
...te ? {
|
|
1510
|
-
isThinking: !0,
|
|
1511
|
-
turnPhase: "thinking",
|
|
1512
|
-
lastError: null
|
|
1513
|
-
} : N ? {
|
|
1514
|
-
isThinking: !1,
|
|
1515
|
-
status: "connected",
|
|
1516
|
-
lastError: null,
|
|
1517
|
-
lastErrorCode: null,
|
|
1518
|
-
lastErrorSecuritySettingsUrl: null
|
|
1519
|
-
} : x ? {
|
|
1520
|
-
isThinking: !0,
|
|
1521
|
-
turnPhase: u ?? this.state.turnPhase ?? "starting",
|
|
1522
|
-
lastError: null
|
|
1523
|
-
} : {}
|
|
1524
|
-
}), N)
|
|
1525
|
-
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1526
|
-
else if (!c && (te || x)) {
|
|
1527
|
-
if (x) {
|
|
1528
|
-
this.activeClientMessageId = x;
|
|
1529
|
-
const E = Z(d), q = E === null ? null : d[E];
|
|
1530
|
-
this.activeResponseUserMessageId = M(q, "id");
|
|
1531
|
-
}
|
|
1532
|
-
this.markThinkingProgress();
|
|
1533
1407
|
}
|
|
1534
|
-
if (
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1408
|
+
if (e.type === "run.model_started") {
|
|
1409
|
+
const s = typeof e.runId == "string" ? e.runId : null;
|
|
1410
|
+
if (!this.state.isThinking || !s || this.activeResponseRunId && this.activeResponseRunId !== s)
|
|
1411
|
+
return;
|
|
1412
|
+
this.activeResponseRunId = s, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
|
|
1413
|
+
return;
|
|
1537
1414
|
}
|
|
1538
|
-
|
|
1539
|
-
this.
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1415
|
+
if (Mn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
1416
|
+
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
1417
|
+
const s = rr(e.user);
|
|
1418
|
+
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();
|
|
1419
|
+
const n = Zn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
1420
|
+
w("web-sdk.agent", "Received auth.ok appearance", {
|
|
1421
|
+
hasAppearance: r,
|
|
1422
|
+
rawAppearance: e.appearance,
|
|
1423
|
+
normalizedAppearance: n
|
|
1424
|
+
}), this.runtimeHelperJavascript = er(e.runtimeHelpers)?.javascript ?? null;
|
|
1425
|
+
const i = _t(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
1426
|
+
user: s,
|
|
1427
|
+
status: "connected",
|
|
1428
|
+
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
1429
|
+
};
|
|
1430
|
+
(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 && !me() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
1431
|
+
type: "page.upsert",
|
|
1432
|
+
sessionId: this.state.sessionId,
|
|
1433
|
+
page: b(),
|
|
1434
|
+
model: this.options.model
|
|
1435
|
+
});
|
|
1546
1436
|
return;
|
|
1547
|
-
const r = _t(
|
|
1548
|
-
Array.isArray(e.items) ? e.items : [],
|
|
1549
|
-
this.options.backendUrl
|
|
1550
|
-
);
|
|
1551
|
-
s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
1552
|
-
messages: Sr(this.state.messages, r)
|
|
1553
|
-
});
|
|
1554
|
-
return;
|
|
1555
|
-
}
|
|
1556
|
-
if (e.type === "sessions.page") {
|
|
1557
|
-
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1558
|
-
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1559
|
-
sessions: ir(e.sessions),
|
|
1560
|
-
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1561
|
-
}));
|
|
1562
|
-
return;
|
|
1563
|
-
}
|
|
1564
|
-
if (e.type === "session.pin.updated") {
|
|
1565
|
-
this.resolvePendingSessionMutation(this.pendingSessionPinRequests, e);
|
|
1566
|
-
return;
|
|
1567
|
-
}
|
|
1568
|
-
if (e.type === "session.rename.updated") {
|
|
1569
|
-
this.resolvePendingSessionMutation(this.pendingSessionRenameRequests, e);
|
|
1570
|
-
return;
|
|
1571
|
-
}
|
|
1572
|
-
if (e.type === "session.updated") {
|
|
1573
|
-
this.clearRunAckResyncRetryTimer();
|
|
1574
|
-
const s = M(e.session, "id");
|
|
1575
|
-
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1576
|
-
...this.pendingComposerWarmup.event,
|
|
1577
|
-
sessionId: s
|
|
1578
|
-
}, this.pendingComposerWarmup.scope = `${s}:${this.pendingComposerWarmup.event.page.url}`), this.setState({ sessionId: s ?? this.state.sessionId }), this.updatePersonalModelFromSession(e.session);
|
|
1579
|
-
const n = e.session && typeof e.session == "object" ? e.session.metadata : null;
|
|
1580
|
-
typeof e.warmupId == "string" && e.warmupId === this.activeComposerWarmupId && n && typeof n == "object" && n.composerPreload && this.clearPendingComposerWarmup();
|
|
1581
|
-
return;
|
|
1582
|
-
}
|
|
1583
|
-
if (e.type === "session.item") {
|
|
1584
|
-
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1585
|
-
const s = U(e.item);
|
|
1586
|
-
if (Ae(s)) {
|
|
1587
|
-
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1588
|
-
const r = M(e.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
1589
|
-
if (r && a) {
|
|
1590
|
-
this.retryAfterInterruptedRun(r, a);
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
if (r && i) {
|
|
1594
|
-
this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
|
|
1595
|
-
return;
|
|
1596
|
-
}
|
|
1597
1437
|
}
|
|
1598
|
-
if (
|
|
1438
|
+
if (e.type === "starterPrompts.updated") {
|
|
1439
|
+
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
1440
|
+
starterPrompts: _t(e, "starterPrompts"),
|
|
1441
|
+
starterPromptsLoading: !1
|
|
1442
|
+
});
|
|
1599
1443
|
return;
|
|
1600
|
-
|
|
1601
|
-
if (
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
this.
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1444
|
+
}
|
|
1445
|
+
if (e.type === "conversation.state") {
|
|
1446
|
+
const s = Array.isArray(e.items) ? e.items : [], n = M(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null, i = this.state.isLoadingSession && this.sessionLoadRequestId === null && r === null && n === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
|
|
1447
|
+
if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && this.sessionLoadRequestId !== null && r === null || this.state.isLoadingSession && n !== this.state.sessionId)
|
|
1448
|
+
return;
|
|
1449
|
+
this.updatePersonalModelFromSession(e.session), n === this.state.sessionId && this.clearSessionLoadRequest();
|
|
1450
|
+
for (const E of s)
|
|
1451
|
+
this.rememberDurablyStoppedTurn(
|
|
1452
|
+
n,
|
|
1453
|
+
U(E),
|
|
1454
|
+
M(E, "createdAt")
|
|
1455
|
+
);
|
|
1456
|
+
const o = ee(s), a = o === null ? null : s[o], l = U(a), c = this.findStoppedTurn(n, {
|
|
1457
|
+
clientMessageId: l?.clientMessageId,
|
|
1458
|
+
respondsToUserMessageId: M(a, "id"),
|
|
1459
|
+
runId: l?.runId
|
|
1460
|
+
}), d = this.filterStoppedSnapshotItems(s, n), p = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, y = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, f = e.isRetrying === !0, u = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
1461
|
+
p && y && (this.pendingClientMessageId = y);
|
|
1462
|
+
let h = hr(
|
|
1463
|
+
e.assistantDraft
|
|
1464
|
+
);
|
|
1465
|
+
h && this.findStoppedTurn(n, {
|
|
1466
|
+
respondsToUserMessageId: h.respondsToUserMessageId,
|
|
1467
|
+
runId: h.runId
|
|
1468
|
+
}) && (h = void 0);
|
|
1469
|
+
const g = h !== void 0;
|
|
1470
|
+
this.rememberUserMessageClientMessageIds(d);
|
|
1471
|
+
const m = _r(d);
|
|
1472
|
+
if (m) {
|
|
1473
|
+
const E = Pr(d, m);
|
|
1474
|
+
this.retryAttemptsByClientMessageId[m] = Math.max(
|
|
1475
|
+
this.retryAttemptsByClientMessageId[m] ?? 0,
|
|
1476
|
+
E
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
const C = d.filter((E) => {
|
|
1480
|
+
const O = U(E);
|
|
1481
|
+
return vt(O) ? !1 : !O || !m || !Re(O) ? !0 : Qe(d, O) !== m;
|
|
1482
|
+
}), S = Qt(
|
|
1483
|
+
this.state.messages,
|
|
1484
|
+
Pt(C, this.options.backendUrl)
|
|
1485
|
+
), _ = Ut(S), v = g ? h?.content ?? "" : this.state.assistantDraft, R = g ? h?.itemId ?? null : this.state.assistantDraftItemId, te = g ? h?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, P = g ? h?.runId ?? null : this.state.assistantDraftRunId, F = d.some(
|
|
1486
|
+
(E, O) => Dt(
|
|
1487
|
+
U(E),
|
|
1488
|
+
v,
|
|
1489
|
+
R,
|
|
1490
|
+
te,
|
|
1491
|
+
P,
|
|
1492
|
+
Ur(d, O)
|
|
1613
1493
|
)
|
|
1614
|
-
),
|
|
1615
|
-
this.
|
|
1616
|
-
|
|
1617
|
-
|
|
1494
|
+
), J = g ? h?.content ?? "" : this.state.assistantDraft, se = !!h?.content && !F, N = _ && (!J || F), ue = kr(S), z = N && ue ? "completed" : c ? "stopped" : N ? "failed" : null;
|
|
1495
|
+
if (!_ && br(this.state.messages, d))
|
|
1496
|
+
return;
|
|
1497
|
+
this.lastUserMessagePageUrl = Cr(d);
|
|
1498
|
+
const x = N || c ? null : Ye(d);
|
|
1499
|
+
if (this.latestRecoverableClientMessageId = x, ue && this.clearRetryTimers(), this.setState({
|
|
1500
|
+
sessionId: M(e.session, "id") ?? this.state.sessionId,
|
|
1501
|
+
messages: S,
|
|
1502
|
+
isLoadingSession: !1,
|
|
1503
|
+
...p ? { pendingMessageStatus: p } : {},
|
|
1504
|
+
...u ? { turnPhase: u } : {},
|
|
1505
|
+
isRetrying: f,
|
|
1506
|
+
...z && this.state.taskStatus === "working" ? { taskStatus: z } : {},
|
|
1507
|
+
...F ? {
|
|
1618
1508
|
assistantDraft: "",
|
|
1619
1509
|
assistantDraftItemId: null,
|
|
1620
1510
|
assistantDraftPhase: null,
|
|
1621
1511
|
assistantDraftRespondsToUserMessageId: null,
|
|
1622
1512
|
assistantDraftRunId: null
|
|
1513
|
+
} : g ? {
|
|
1514
|
+
assistantDraft: h?.content ?? "",
|
|
1515
|
+
assistantDraftItemId: h?.itemId ?? null,
|
|
1516
|
+
assistantDraftPhase: h?.phase ?? null,
|
|
1517
|
+
assistantDraftRespondsToUserMessageId: h?.respondsToUserMessageId ?? null,
|
|
1518
|
+
assistantDraftRunId: h?.runId ?? null
|
|
1623
1519
|
} : {},
|
|
1624
|
-
...
|
|
1520
|
+
...se ? {
|
|
1521
|
+
isThinking: !0,
|
|
1522
|
+
turnPhase: "thinking",
|
|
1523
|
+
lastError: null
|
|
1524
|
+
} : N ? {
|
|
1625
1525
|
isThinking: !1,
|
|
1626
|
-
...r && this.state.taskStatus === "working" ? { taskStatus: r } : {},
|
|
1627
|
-
isRetrying: !1
|
|
1628
|
-
} : {},
|
|
1629
|
-
...d && !this.failedUserMessageEvent ? {
|
|
1630
1526
|
status: "connected",
|
|
1631
1527
|
lastError: null,
|
|
1632
1528
|
lastErrorCode: null,
|
|
1633
1529
|
lastErrorSecuritySettingsUrl: null
|
|
1530
|
+
} : x ? {
|
|
1531
|
+
isThinking: !0,
|
|
1532
|
+
turnPhase: u ?? this.state.turnPhase ?? "starting",
|
|
1533
|
+
lastError: null
|
|
1634
1534
|
} : {}
|
|
1635
|
-
}),
|
|
1535
|
+
}), N)
|
|
1536
|
+
this.retryableClientMessageId = null, this.clearThinkingWatchdog();
|
|
1537
|
+
else if (!c && (se || x)) {
|
|
1538
|
+
if (x) {
|
|
1539
|
+
this.activeClientMessageId = x;
|
|
1540
|
+
const E = ee(d), O = E === null ? null : d[E];
|
|
1541
|
+
this.activeResponseUserMessageId = M(O, "id");
|
|
1542
|
+
}
|
|
1543
|
+
this.markThinkingProgress();
|
|
1544
|
+
}
|
|
1545
|
+
if (m) {
|
|
1546
|
+
const E = M(e.session, "id") ?? this.state.sessionId;
|
|
1547
|
+
E && this.retryAfterInterruptedRun(E, m);
|
|
1548
|
+
}
|
|
1549
|
+
i && n && window.setTimeout(() => {
|
|
1550
|
+
this.autoLoadSessionActivity(n);
|
|
1551
|
+
}, 0);
|
|
1552
|
+
return;
|
|
1636
1553
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1649
|
-
dataType: "assistant_draft",
|
|
1650
|
-
...l ? { phase: l } : {},
|
|
1651
|
-
...c ? { respondsToUserMessageId: c } : {},
|
|
1652
|
-
...d ? { runId: d } : {}
|
|
1653
|
-
}),
|
|
1654
|
-
assistantDraft: i,
|
|
1655
|
-
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1656
|
-
assistantDraftPhase: l,
|
|
1657
|
-
assistantDraftRespondsToUserMessageId: c,
|
|
1658
|
-
assistantDraftRunId: d,
|
|
1659
|
-
isThinking: !0,
|
|
1660
|
-
taskStatus: "working",
|
|
1661
|
-
isRetrying: !1
|
|
1662
|
-
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1663
|
-
return;
|
|
1664
|
-
}
|
|
1665
|
-
if (e.type === "chat.assistant_done") {
|
|
1666
|
-
if (typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(e.runId))
|
|
1554
|
+
if (e.type === "session.activity.page") {
|
|
1555
|
+
const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
1556
|
+
if (!s || n !== this.state.sessionId)
|
|
1557
|
+
return;
|
|
1558
|
+
const r = Pt(
|
|
1559
|
+
Array.isArray(e.items) ? e.items : [],
|
|
1560
|
+
this.options.backendUrl
|
|
1561
|
+
);
|
|
1562
|
+
s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
1563
|
+
messages: Sr(this.state.messages, r)
|
|
1564
|
+
});
|
|
1667
1565
|
return;
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1566
|
+
}
|
|
1567
|
+
if (e.type === "sessions.page") {
|
|
1568
|
+
const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1569
|
+
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
1570
|
+
sessions: ir(e.sessions),
|
|
1571
|
+
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
1572
|
+
}));
|
|
1671
1573
|
return;
|
|
1672
|
-
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 = vs(
|
|
1673
|
-
this.state.messages.filter(
|
|
1674
|
-
(c) => c.dataType !== "assistant_draft" || !je(
|
|
1675
|
-
c,
|
|
1676
|
-
n,
|
|
1677
|
-
r
|
|
1678
|
-
)
|
|
1679
|
-
),
|
|
1680
|
-
n,
|
|
1681
|
-
r,
|
|
1682
|
-
Qt
|
|
1683
|
-
);
|
|
1684
|
-
this.setState({
|
|
1685
|
-
sessionId: s,
|
|
1686
|
-
messages: fr(
|
|
1687
|
-
l,
|
|
1688
|
-
typeof e.responseId == "string" ? e.responseId : null,
|
|
1689
|
-
n,
|
|
1690
|
-
r
|
|
1691
|
-
),
|
|
1692
|
-
assistantDraft: "",
|
|
1693
|
-
assistantDraftItemId: null,
|
|
1694
|
-
assistantDraftPhase: null,
|
|
1695
|
-
assistantDraftRespondsToUserMessageId: null,
|
|
1696
|
-
assistantDraftRunId: null,
|
|
1697
|
-
isThinking: a ? !1 : this.state.isThinking,
|
|
1698
|
-
...a && this.state.taskStatus === "working" ? { taskStatus: "completed" } : {},
|
|
1699
|
-
isRetrying: a ? !1 : this.state.isRetrying
|
|
1700
|
-
}), a && this.clearThinkingWatchdog();
|
|
1701
|
-
return;
|
|
1702
|
-
}
|
|
1703
|
-
if (e.type === "tool.call") {
|
|
1704
|
-
this.clearRunAckResyncRetryTimer();
|
|
1705
|
-
const s = e.hiddenFromTranscript === !0 && typeof e.callId == "string" ? e.callId : null;
|
|
1706
|
-
if (s)
|
|
1707
|
-
this.nonTranscriptToolCallIds.add(s);
|
|
1708
|
-
else {
|
|
1709
|
-
const n = Ir(e);
|
|
1710
|
-
if (n) {
|
|
1711
|
-
const r = mr(
|
|
1712
|
-
this.state.messages,
|
|
1713
|
-
n
|
|
1714
|
-
);
|
|
1715
|
-
this.setState({
|
|
1716
|
-
messages: r,
|
|
1717
|
-
isThinking: !0
|
|
1718
|
-
}), this.emit(
|
|
1719
|
-
"message",
|
|
1720
|
-
r.find(
|
|
1721
|
-
(i) => i.callId === n.callId
|
|
1722
|
-
) ?? n
|
|
1723
|
-
);
|
|
1724
|
-
}
|
|
1725
1574
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
}
|
|
1729
|
-
if (e.type === "tool.status") {
|
|
1730
|
-
const s = typeof e.callId == "string" ? e.callId : null;
|
|
1731
|
-
if (!s)
|
|
1575
|
+
if (e.type === "session.pin.updated") {
|
|
1576
|
+
this.resolvePendingSessionMutation(this.pendingSessionPinRequests, e);
|
|
1732
1577
|
return;
|
|
1733
|
-
|
|
1734
|
-
if (
|
|
1578
|
+
}
|
|
1579
|
+
if (e.type === "session.rename.updated") {
|
|
1580
|
+
this.resolvePendingSessionMutation(this.pendingSessionRenameRequests, e);
|
|
1735
1581
|
return;
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
lastError: typeof e.message == "string" ? e.message : "Could not load this chat."
|
|
1747
|
-
});
|
|
1582
|
+
}
|
|
1583
|
+
if (e.type === "session.updated") {
|
|
1584
|
+
this.clearRunAckResyncRetryTimer();
|
|
1585
|
+
const s = M(e.session, "id");
|
|
1586
|
+
s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
|
|
1587
|
+
...this.pendingComposerWarmup.event,
|
|
1588
|
+
sessionId: s
|
|
1589
|
+
}, this.pendingComposerWarmup.scope = `${s}:${this.pendingComposerWarmup.event.page.url}`), this.setState({ sessionId: s ?? this.state.sessionId }), this.updatePersonalModelFromSession(e.session);
|
|
1590
|
+
const n = e.session && typeof e.session == "object" ? e.session.metadata : null;
|
|
1591
|
+
typeof e.warmupId == "string" && e.warmupId === this.activeComposerWarmupId && n && typeof n == "object" && n.composerPreload && this.clearPendingComposerWarmup();
|
|
1748
1592
|
return;
|
|
1749
1593
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1594
|
+
if (e.type === "session.item") {
|
|
1595
|
+
this.rememberUserMessageClientMessageIds([e.item]);
|
|
1596
|
+
const s = U(e.item);
|
|
1597
|
+
if (Re(s)) {
|
|
1598
|
+
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
1599
|
+
const r = M(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);
|
|
1600
|
+
if (r && a) {
|
|
1601
|
+
this.retryAfterInterruptedRun(r, a);
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
if (r && i) {
|
|
1605
|
+
this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
if (vt(s))
|
|
1610
|
+
return;
|
|
1611
|
+
const n = Yt(e.item, this.options.backendUrl);
|
|
1612
|
+
if (n) {
|
|
1613
|
+
const r = Lr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1614
|
+
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), H(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Dr(s) && this.clearRunAckResyncRetryTimer();
|
|
1615
|
+
const o = Je(this.state.messages, n), a = Ut(o), l = Dt(
|
|
1616
|
+
s,
|
|
1617
|
+
this.state.assistantDraft,
|
|
1618
|
+
this.state.assistantDraftItemId,
|
|
1619
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
1620
|
+
this.state.assistantDraftRunId,
|
|
1621
|
+
ns(
|
|
1622
|
+
o,
|
|
1623
|
+
o.findIndex((p) => p.id === n.id)
|
|
1624
|
+
)
|
|
1625
|
+
), c = a && (!this.state.assistantDraft || l), d = Ae(n) && (c || H(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
1626
|
+
this.setState({
|
|
1627
|
+
messages: o,
|
|
1628
|
+
...l ? {
|
|
1629
|
+
assistantDraft: "",
|
|
1630
|
+
assistantDraftItemId: null,
|
|
1631
|
+
assistantDraftPhase: null,
|
|
1632
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1633
|
+
assistantDraftRunId: null
|
|
1634
|
+
} : {},
|
|
1635
|
+
...c ? {
|
|
1636
|
+
isThinking: !1,
|
|
1637
|
+
...r && this.state.taskStatus === "working" ? { taskStatus: r } : {},
|
|
1638
|
+
isRetrying: !1
|
|
1639
|
+
} : {},
|
|
1640
|
+
...d && !this.failedUserMessageEvent ? {
|
|
1641
|
+
status: "connected",
|
|
1642
|
+
lastError: null,
|
|
1643
|
+
lastErrorCode: null,
|
|
1644
|
+
lastErrorSecuritySettingsUrl: null
|
|
1645
|
+
} : {}
|
|
1646
|
+
}), c && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
1647
|
+
}
|
|
1753
1648
|
return;
|
|
1754
1649
|
}
|
|
1755
|
-
if (
|
|
1650
|
+
if (e.type === "chat.assistant_delta") {
|
|
1651
|
+
this.clearRunAckResyncRetryTimer();
|
|
1652
|
+
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((p) => p.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, d = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1653
|
+
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = d), this.setState({
|
|
1654
|
+
messages: Je(this.state.messages, {
|
|
1655
|
+
id: o,
|
|
1656
|
+
role: "assistant",
|
|
1657
|
+
content: i,
|
|
1658
|
+
createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1659
|
+
...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
|
|
1660
|
+
dataType: "assistant_draft",
|
|
1661
|
+
...l ? { phase: l } : {},
|
|
1662
|
+
...c ? { respondsToUserMessageId: c } : {},
|
|
1663
|
+
...d ? { runId: d } : {}
|
|
1664
|
+
}),
|
|
1665
|
+
assistantDraft: i,
|
|
1666
|
+
assistantDraftItemId: n ?? this.state.assistantDraftItemId,
|
|
1667
|
+
assistantDraftPhase: l,
|
|
1668
|
+
assistantDraftRespondsToUserMessageId: c,
|
|
1669
|
+
assistantDraftRunId: d,
|
|
1670
|
+
isThinking: !0,
|
|
1671
|
+
taskStatus: "working",
|
|
1672
|
+
isRetrying: !1
|
|
1673
|
+
}), this.markThinkingProgress(), this.emit("delta", s);
|
|
1756
1674
|
return;
|
|
1757
|
-
|
|
1758
|
-
if (e.
|
|
1759
|
-
this.
|
|
1675
|
+
}
|
|
1676
|
+
if (e.type === "chat.assistant_done") {
|
|
1677
|
+
if (typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(e.runId))
|
|
1678
|
+
return;
|
|
1679
|
+
this.retryableClientMessageId = null;
|
|
1680
|
+
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;
|
|
1681
|
+
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
|
|
1682
|
+
return;
|
|
1683
|
+
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 = Ds(
|
|
1684
|
+
this.state.messages.filter(
|
|
1685
|
+
(c) => c.dataType !== "assistant_draft" || !ze(
|
|
1686
|
+
c,
|
|
1687
|
+
n,
|
|
1688
|
+
r
|
|
1689
|
+
)
|
|
1690
|
+
),
|
|
1691
|
+
n,
|
|
1692
|
+
r,
|
|
1693
|
+
Zt
|
|
1694
|
+
);
|
|
1695
|
+
this.setState({
|
|
1696
|
+
sessionId: s,
|
|
1697
|
+
messages: fr(
|
|
1698
|
+
l,
|
|
1699
|
+
typeof e.responseId == "string" ? e.responseId : null,
|
|
1700
|
+
n,
|
|
1701
|
+
r
|
|
1702
|
+
),
|
|
1703
|
+
assistantDraft: "",
|
|
1704
|
+
assistantDraftItemId: null,
|
|
1705
|
+
assistantDraftPhase: null,
|
|
1706
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1707
|
+
assistantDraftRunId: null,
|
|
1708
|
+
isThinking: a ? !1 : this.state.isThinking,
|
|
1709
|
+
...a && this.state.taskStatus === "working" ? { taskStatus: "completed" } : {},
|
|
1710
|
+
isRetrying: a ? !1 : this.state.isRetrying
|
|
1711
|
+
}), a && this.clearThinkingWatchdog();
|
|
1712
|
+
return;
|
|
1713
|
+
}
|
|
1714
|
+
if (e.type === "tool.call") {
|
|
1715
|
+
this.clearRunAckResyncRetryTimer();
|
|
1716
|
+
const s = e.hiddenFromTranscript === !0 && typeof e.callId == "string" ? e.callId : null;
|
|
1717
|
+
if (s)
|
|
1718
|
+
this.nonTranscriptToolCallIds.add(s);
|
|
1719
|
+
else {
|
|
1720
|
+
const n = Ir(e);
|
|
1721
|
+
if (n) {
|
|
1722
|
+
const r = mr(
|
|
1723
|
+
this.state.messages,
|
|
1724
|
+
n
|
|
1725
|
+
);
|
|
1726
|
+
this.setState({
|
|
1727
|
+
messages: r,
|
|
1728
|
+
isThinking: !0
|
|
1729
|
+
}), this.emit(
|
|
1730
|
+
"message",
|
|
1731
|
+
r.find(
|
|
1732
|
+
(i) => i.callId === n.callId
|
|
1733
|
+
) ?? n
|
|
1734
|
+
);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
this.executeToolCall(e);
|
|
1760
1738
|
return;
|
|
1761
1739
|
}
|
|
1762
|
-
if (
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1740
|
+
if (e.type === "tool.status") {
|
|
1741
|
+
const s = typeof e.callId == "string" ? e.callId : null;
|
|
1742
|
+
if (!s)
|
|
1743
|
+
return;
|
|
1744
|
+
const n = e.status === "queued" || e.status === "running";
|
|
1745
|
+
if (this.nonTranscriptToolCallIds.has(s) || n && this.terminalToolCallIds.has(s))
|
|
1746
|
+
return;
|
|
1747
|
+
n || this.terminalToolCallIds.add(s), this.state.messages.some(
|
|
1748
|
+
(i) => i.callId === s
|
|
1749
|
+
) ? this.setToolMessageLoading(s, n) : this.pendingToolLoadingByCallId.set(s, n);
|
|
1769
1750
|
return;
|
|
1770
1751
|
}
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1752
|
+
if (e.type === "error") {
|
|
1753
|
+
const s = typeof e.requestId == "string" ? e.requestId : null;
|
|
1754
|
+
if (s && s === this.sessionLoadRequestId) {
|
|
1755
|
+
this.clearSessionLoadRequest(), this.setState({
|
|
1756
|
+
isLoadingSession: !1,
|
|
1757
|
+
lastError: typeof e.message == "string" ? e.message : "Could not load this chat."
|
|
1758
|
+
});
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
const n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
1762
|
+
if (s && n) {
|
|
1763
|
+
window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof e.message == "string" ? e.message : "Pluno error"));
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
if (this.rejectPendingSessionMutation(this.pendingSessionPinRequests, e) || this.rejectPendingSessionMutation(this.pendingSessionRenameRequests, e))
|
|
1767
|
+
return;
|
|
1768
|
+
const r = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, i = typeof e.clientMessageId == "string" ? e.clientMessageId : null, o = e.retryable === !0 || e.code === "transient_model_error";
|
|
1769
|
+
if (e.code === "message_delivery_failed" && i && i === this.pendingClientMessageId) {
|
|
1770
|
+
this.failPendingDelivery(i);
|
|
1771
|
+
return;
|
|
1772
|
+
}
|
|
1773
|
+
if (i && i === this.pendingClientMessageId && this.promotePendingDelivery(
|
|
1774
|
+
i,
|
|
1775
|
+
r,
|
|
1776
|
+
typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null,
|
|
1777
|
+
typeof e.runId == "string" ? e.runId : null
|
|
1778
|
+
), this.retryAfterRetryableError(e)) {
|
|
1779
|
+
e.code !== "run_still_active" && typeof e.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(e.runId);
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
o && r && i && (this.retryableClientMessageId = i);
|
|
1783
|
+
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Wn(a.message);
|
|
1784
|
+
l && console.error(l);
|
|
1785
|
+
const c = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null, p = Ot(
|
|
1786
|
+
this.state.messages,
|
|
1787
|
+
c,
|
|
1788
|
+
d
|
|
1789
|
+
), y = Er(
|
|
1790
|
+
p,
|
|
1791
|
+
c,
|
|
1792
|
+
d
|
|
1793
|
+
);
|
|
1794
|
+
this.setState({
|
|
1795
|
+
status: y ? "connected" : "error",
|
|
1796
|
+
messages: p,
|
|
1797
|
+
assistantDraft: "",
|
|
1798
|
+
assistantDraftItemId: null,
|
|
1799
|
+
assistantDraftPhase: null,
|
|
1800
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
1801
|
+
assistantDraftRunId: null,
|
|
1802
|
+
isThinking: !1,
|
|
1803
|
+
...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
|
|
1804
|
+
isRetrying: !1,
|
|
1805
|
+
lastError: y ? null : a.message,
|
|
1806
|
+
lastErrorCode: y ? null : typeof e.code == "string" ? e.code : null,
|
|
1807
|
+
lastErrorSecuritySettingsUrl: y ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
|
|
1808
|
+
}), this.clearThinkingWatchdog(), this.emit("error", a);
|
|
1809
|
+
}
|
|
1798
1810
|
}
|
|
1799
1811
|
}
|
|
1800
1812
|
}
|
|
1801
1813
|
}
|
|
1802
1814
|
updatePersonalModelFromSession(e) {
|
|
1803
|
-
if (this.options.productVariant !== "personal" || !e || typeof e != "object")
|
|
1815
|
+
if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
|
|
1804
1816
|
return;
|
|
1805
1817
|
const s = e.metadata, n = s && typeof s == "object" ? s.model : void 0;
|
|
1806
|
-
this.options.model =
|
|
1818
|
+
this.options.model = We(n) ? n : "gpt-5.6-sol";
|
|
1807
1819
|
}
|
|
1808
1820
|
shouldIgnoreBackgroundSessionEvent(e) {
|
|
1809
|
-
if (!this.options.keepRunsActiveOnSessionNavigation || !
|
|
1821
|
+
if (!this.options.keepRunsActiveOnSessionNavigation || !fe(e))
|
|
1810
1822
|
return !1;
|
|
1811
|
-
const s =
|
|
1823
|
+
const s = K(e);
|
|
1812
1824
|
return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
|
|
1813
1825
|
}
|
|
1826
|
+
shouldIgnoreDetachedSessionEvent(e) {
|
|
1827
|
+
if (this.options.keepRunsActiveOnSessionNavigation || !fe(e))
|
|
1828
|
+
return !1;
|
|
1829
|
+
const s = K(e);
|
|
1830
|
+
return !!(s && this.detachedSessionIds.has(s));
|
|
1831
|
+
}
|
|
1832
|
+
shouldDeferDetachedSessionEvent(e) {
|
|
1833
|
+
if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !fe(e))
|
|
1834
|
+
return !1;
|
|
1835
|
+
const s = K(e);
|
|
1836
|
+
if (!s || s === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(s))
|
|
1837
|
+
return !1;
|
|
1838
|
+
const n = this.deferredDetachedSessionEvents.get(s) ?? [];
|
|
1839
|
+
return n.push(e), this.deferredDetachedSessionEvents.set(s, n.slice(-20)), !0;
|
|
1840
|
+
}
|
|
1841
|
+
rememberCurrentRunAsDetached() {
|
|
1842
|
+
if (this.options.keepRunsActiveOnSessionNavigation)
|
|
1843
|
+
return;
|
|
1844
|
+
if (this.state.sessionId) {
|
|
1845
|
+
this.detachedSessionIds.add(this.state.sessionId);
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
const e = this.pendingClientMessageId ?? this.activeClientMessageId;
|
|
1849
|
+
e && this.detachedClientMessageIds.add(e);
|
|
1850
|
+
}
|
|
1814
1851
|
rememberCurrentRunAsBackground() {
|
|
1815
1852
|
this.options.keepRunsActiveOnSessionNavigation && (this.state.sessionId ? this.backgroundSessionIds.add(this.state.sessionId) : this.state.isThinking && this.activeClientMessageId ? this.backgroundClientMessageIds.add(this.activeClientMessageId) : this.pendingClientMessageId && this.backgroundClientMessageIds.add(this.pendingClientMessageId));
|
|
1816
1853
|
}
|
|
@@ -1818,7 +1855,7 @@ class zt {
|
|
|
1818
1855
|
const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
1819
1856
|
if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
|
|
1820
1857
|
return !1;
|
|
1821
|
-
if (
|
|
1858
|
+
if (me())
|
|
1822
1859
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
1823
1860
|
if (e.code === "run_still_active") {
|
|
1824
1861
|
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) {
|
|
@@ -1832,10 +1869,10 @@ class zt {
|
|
|
1832
1869
|
if (this.retryTimersByClientMessageId[n] !== void 0)
|
|
1833
1870
|
return !0;
|
|
1834
1871
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
1835
|
-
if (i >=
|
|
1872
|
+
if (i >= ie)
|
|
1836
1873
|
return !1;
|
|
1837
1874
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
1838
|
-
const o =
|
|
1875
|
+
const o = oe(
|
|
1839
1876
|
i,
|
|
1840
1877
|
typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
|
|
1841
1878
|
);
|
|
@@ -1849,23 +1886,23 @@ class zt {
|
|
|
1849
1886
|
}, o), !0;
|
|
1850
1887
|
}
|
|
1851
1888
|
retryAfterInterruptedRun(e, s) {
|
|
1852
|
-
if (
|
|
1889
|
+
if (me()) {
|
|
1853
1890
|
this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
|
|
1854
1891
|
return;
|
|
1855
1892
|
}
|
|
1856
1893
|
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
1857
1894
|
return;
|
|
1858
1895
|
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
1859
|
-
if (n >=
|
|
1896
|
+
if (n >= ie) {
|
|
1860
1897
|
this.requestSessionRecoveryExhaustion(e, s);
|
|
1861
1898
|
return;
|
|
1862
1899
|
}
|
|
1863
1900
|
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(() => {
|
|
1864
1901
|
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 });
|
|
1865
|
-
},
|
|
1902
|
+
}, oe(n));
|
|
1866
1903
|
}
|
|
1867
1904
|
requestSessionRecoveryExhaustion(e, s) {
|
|
1868
|
-
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(
|
|
1905
|
+
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(St);
|
|
1869
1906
|
}
|
|
1870
1907
|
clearRetryTimers() {
|
|
1871
1908
|
for (const e of Object.values(this.retryTimersByClientMessageId))
|
|
@@ -1896,7 +1933,7 @@ class zt {
|
|
|
1896
1933
|
const r = new Promise((i, o) => {
|
|
1897
1934
|
const a = window.setTimeout(() => {
|
|
1898
1935
|
e.delete(s.requestId), o(new Error(n));
|
|
1899
|
-
},
|
|
1936
|
+
}, Rt);
|
|
1900
1937
|
e.set(s.requestId, { resolve: i, reject: o, timeout: a });
|
|
1901
1938
|
});
|
|
1902
1939
|
if (!this.sendNow(s)) {
|
|
@@ -1919,7 +1956,7 @@ class zt {
|
|
|
1919
1956
|
e.clear();
|
|
1920
1957
|
}
|
|
1921
1958
|
markThinkingProgress() {
|
|
1922
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1959
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Tt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1923
1960
|
}
|
|
1924
1961
|
scheduleThinkingWatchdog(e) {
|
|
1925
1962
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1963,21 +2000,21 @@ class zt {
|
|
|
1963
2000
|
}), this.markThinkingProgress();
|
|
1964
2001
|
}
|
|
1965
2002
|
schedulePendingDeliveryAck(e) {
|
|
1966
|
-
this.clearPendingDeliveryTimers(), !
|
|
2003
|
+
this.clearPendingDeliveryTimers(), !me() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
1967
2004
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
1968
|
-
},
|
|
2005
|
+
}, Mt));
|
|
1969
2006
|
}
|
|
1970
2007
|
retryPendingDelivery(e) {
|
|
1971
2008
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
1972
2009
|
return;
|
|
1973
2010
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
1974
|
-
if (s >=
|
|
2011
|
+
if (s >= ie) {
|
|
1975
2012
|
this.failPendingDelivery(e);
|
|
1976
2013
|
return;
|
|
1977
2014
|
}
|
|
1978
2015
|
s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
1979
2016
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
1980
|
-
},
|
|
2017
|
+
}, oe(s, At));
|
|
1981
2018
|
}
|
|
1982
2019
|
failPendingDelivery(e) {
|
|
1983
2020
|
if (this.pendingClientMessageId !== e)
|
|
@@ -2013,7 +2050,7 @@ class zt {
|
|
|
2013
2050
|
scheduleRunAckWatchdog(e) {
|
|
2014
2051
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
2015
2052
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
2016
|
-
},
|
|
2053
|
+
}, Mt);
|
|
2017
2054
|
}
|
|
2018
2055
|
recoverMissedRunAck(e) {
|
|
2019
2056
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (w("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -2024,7 +2061,7 @@ class zt {
|
|
|
2024
2061
|
scheduleRunAckResyncRetry(e) {
|
|
2025
2062
|
this.clearRunAckResyncRetryTimer();
|
|
2026
2063
|
const s = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
2027
|
-
s >=
|
|
2064
|
+
s >= ie || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
2028
2065
|
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({
|
|
2029
2066
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
2030
2067
|
isThinking: !0,
|
|
@@ -2037,8 +2074,8 @@ class zt {
|
|
|
2037
2074
|
sessionId: this.state.sessionId,
|
|
2038
2075
|
clientMessageId: e,
|
|
2039
2076
|
automatic: !0
|
|
2040
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
2041
|
-
},
|
|
2077
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(Tt)));
|
|
2078
|
+
}, oe(s, At)));
|
|
2042
2079
|
}
|
|
2043
2080
|
clearRunAckResyncRetryTimer() {
|
|
2044
2081
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -2057,24 +2094,24 @@ class zt {
|
|
|
2057
2094
|
reason: "missing_client_message_id"
|
|
2058
2095
|
}), this.setState({
|
|
2059
2096
|
messages: this.state.messages.filter(
|
|
2060
|
-
(r) => !
|
|
2097
|
+
(r) => !X(r)
|
|
2061
2098
|
),
|
|
2062
2099
|
isThinking: !1,
|
|
2063
2100
|
taskStatus: "failed",
|
|
2064
|
-
lastError:
|
|
2101
|
+
lastError: wt,
|
|
2065
2102
|
lastErrorCode: "run_recovery_exhausted"
|
|
2066
2103
|
}), this.clearThinkingWatchdog();
|
|
2067
2104
|
return;
|
|
2068
2105
|
}
|
|
2069
2106
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
2070
|
-
if (n >=
|
|
2107
|
+
if (n >= ie) {
|
|
2071
2108
|
w("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
2072
2109
|
sessionId: this.state.sessionId,
|
|
2073
2110
|
clientMessageId: e
|
|
2074
2111
|
}), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
|
|
2075
2112
|
isThinking: !1,
|
|
2076
2113
|
taskStatus: "failed",
|
|
2077
|
-
lastError:
|
|
2114
|
+
lastError: wt,
|
|
2078
2115
|
lastErrorCode: "connection_failed"
|
|
2079
2116
|
}), this.clearThinkingWatchdog());
|
|
2080
2117
|
return;
|
|
@@ -2084,7 +2121,7 @@ class zt {
|
|
|
2084
2121
|
sessionId: this.state.sessionId,
|
|
2085
2122
|
clientMessageId: e,
|
|
2086
2123
|
resyncAttempts: s + 1
|
|
2087
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
2124
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(St);
|
|
2088
2125
|
return;
|
|
2089
2126
|
}
|
|
2090
2127
|
this.setState({
|
|
@@ -2102,7 +2139,7 @@ class zt {
|
|
|
2102
2139
|
clientMessageId: e,
|
|
2103
2140
|
automatic: !0
|
|
2104
2141
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
2105
|
-
},
|
|
2142
|
+
}, oe(n)));
|
|
2106
2143
|
}
|
|
2107
2144
|
resyncThinkingSession() {
|
|
2108
2145
|
this.state.sessionId ? this.send({
|
|
@@ -2113,7 +2150,7 @@ class zt {
|
|
|
2113
2150
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
2114
2151
|
}
|
|
2115
2152
|
async executeToolCall(e) {
|
|
2116
|
-
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 =
|
|
2153
|
+
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 = Q(
|
|
2117
2154
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
2118
2155
|
), o = e.rawInput;
|
|
2119
2156
|
if (!s || !n || !r)
|
|
@@ -2126,8 +2163,8 @@ class zt {
|
|
|
2126
2163
|
callId: n,
|
|
2127
2164
|
toolName: r,
|
|
2128
2165
|
summary: i,
|
|
2129
|
-
rawInput:
|
|
2130
|
-
rawOutput:
|
|
2166
|
+
rawInput: q(o),
|
|
2167
|
+
rawOutput: q({
|
|
2131
2168
|
ok: !1,
|
|
2132
2169
|
toolName: r,
|
|
2133
2170
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -2142,7 +2179,7 @@ class zt {
|
|
|
2142
2179
|
callId: n,
|
|
2143
2180
|
toolName: r,
|
|
2144
2181
|
summary: i,
|
|
2145
|
-
rawInput:
|
|
2182
|
+
rawInput: q(o),
|
|
2146
2183
|
rawOutput: {
|
|
2147
2184
|
ok: !1,
|
|
2148
2185
|
toolName: r,
|
|
@@ -2158,7 +2195,7 @@ class zt {
|
|
|
2158
2195
|
callId: n,
|
|
2159
2196
|
toolName: r,
|
|
2160
2197
|
summary: i,
|
|
2161
|
-
rawInput:
|
|
2198
|
+
rawInput: q(o),
|
|
2162
2199
|
rawOutput: null
|
|
2163
2200
|
},
|
|
2164
2201
|
startedAtMs: Date.now(),
|
|
@@ -2166,13 +2203,13 @@ class zt {
|
|
|
2166
2203
|
startedAtOrigin: location.origin
|
|
2167
2204
|
}), this.installSessionBrowserApis();
|
|
2168
2205
|
let c = null, d;
|
|
2169
|
-
c = await this.executeRuntimeHelper(), d = await
|
|
2206
|
+
c = await this.executeRuntimeHelper(), d = await Ct(
|
|
2170
2207
|
o,
|
|
2171
|
-
|
|
2172
|
-
).catch((
|
|
2208
|
+
qn(e.runtimeContext, this.options.backendUrl)
|
|
2209
|
+
).catch((p) => ({
|
|
2173
2210
|
ok: !1,
|
|
2174
2211
|
exception: {
|
|
2175
|
-
message:
|
|
2212
|
+
message: p instanceof Error ? p.message : String(p)
|
|
2176
2213
|
}
|
|
2177
2214
|
})), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
2178
2215
|
type: "tool.result",
|
|
@@ -2180,8 +2217,8 @@ class zt {
|
|
|
2180
2217
|
callId: n,
|
|
2181
2218
|
toolName: r,
|
|
2182
2219
|
summary: o.summary,
|
|
2183
|
-
rawInput:
|
|
2184
|
-
rawOutput:
|
|
2220
|
+
rawInput: q(o),
|
|
2221
|
+
rawOutput: q(tr(d, c))
|
|
2185
2222
|
}), Lt(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
2186
2223
|
}
|
|
2187
2224
|
setToolMessageLoading(e, s) {
|
|
@@ -2196,7 +2233,7 @@ class zt {
|
|
|
2196
2233
|
if (this.pageLifecycleCleanup)
|
|
2197
2234
|
return;
|
|
2198
2235
|
const e = () => {
|
|
2199
|
-
|
|
2236
|
+
os(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
2200
2237
|
};
|
|
2201
2238
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
2202
2239
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
@@ -2211,7 +2248,7 @@ class zt {
|
|
|
2211
2248
|
async executeRuntimeHelper() {
|
|
2212
2249
|
if (!this.runtimeHelperJavascript?.trim())
|
|
2213
2250
|
return null;
|
|
2214
|
-
const e = await
|
|
2251
|
+
const e = await Ct({
|
|
2215
2252
|
javascript: this.runtimeHelperJavascript
|
|
2216
2253
|
});
|
|
2217
2254
|
return e.ok === !1 ? sr(e) : null;
|
|
@@ -2291,7 +2328,7 @@ class zt {
|
|
|
2291
2328
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2292
2329
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2293
2330
|
};
|
|
2294
|
-
this.state = o, Kr(this.options.clientId, this.state), this.emit("state", this.getState()),
|
|
2331
|
+
this.state = o, Kr(this.options.clientId, this.state), this.emit("state", this.getState()), He("state", this.state.status, {
|
|
2295
2332
|
status: this.state.status,
|
|
2296
2333
|
sessionId: this.state.sessionId,
|
|
2297
2334
|
messageCount: this.state.messages.length,
|
|
@@ -2313,7 +2350,7 @@ class zt {
|
|
|
2313
2350
|
this.listeners[e]?.forEach((r) => r(s));
|
|
2314
2351
|
}
|
|
2315
2352
|
}
|
|
2316
|
-
const
|
|
2353
|
+
const je = /* @__PURE__ */ new WeakMap();
|
|
2317
2354
|
function Sn(t) {
|
|
2318
2355
|
const e = window.__plunoProductAgentNetworkCapture ?? wn();
|
|
2319
2356
|
return e.subscribers.add(t), () => {
|
|
@@ -2329,7 +2366,7 @@ function wn() {
|
|
|
2329
2366
|
}
|
|
2330
2367
|
});
|
|
2331
2368
|
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, u) {
|
|
2332
|
-
const
|
|
2369
|
+
const h = Date.now();
|
|
2333
2370
|
let g;
|
|
2334
2371
|
try {
|
|
2335
2372
|
g = s.call(this, f, u);
|
|
@@ -2337,24 +2374,24 @@ function wn() {
|
|
|
2337
2374
|
throw m;
|
|
2338
2375
|
}
|
|
2339
2376
|
try {
|
|
2340
|
-
const m = f instanceof Request ? f : null, C = ii(f, m), T =
|
|
2341
|
-
if (!
|
|
2377
|
+
const m = f instanceof Request ? f : null, C = ii(f, m), T = us(u?.headers ?? m?.headers);
|
|
2378
|
+
if (!Y(C, T, u?.body)) {
|
|
2342
2379
|
const _ = {
|
|
2343
|
-
requestId:
|
|
2344
|
-
url: W(C,
|
|
2380
|
+
requestId: Ke("fetch"),
|
|
2381
|
+
url: W(C, $e),
|
|
2345
2382
|
method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
2346
2383
|
requestHeaders: T,
|
|
2347
|
-
requestBody:
|
|
2384
|
+
requestBody: xt(u?.body),
|
|
2348
2385
|
resourceType: "fetch",
|
|
2349
|
-
startedAt: new Date(
|
|
2386
|
+
startedAt: new Date(h).toISOString()
|
|
2350
2387
|
};
|
|
2351
2388
|
g.then(
|
|
2352
2389
|
(v) => {
|
|
2353
|
-
oi(v, _,
|
|
2390
|
+
oi(v, _, h, e).catch(() => {
|
|
2354
2391
|
e({
|
|
2355
2392
|
..._,
|
|
2356
2393
|
responseStatus: v.status,
|
|
2357
|
-
durationMs: Date.now() -
|
|
2394
|
+
durationMs: Date.now() - h
|
|
2358
2395
|
});
|
|
2359
2396
|
});
|
|
2360
2397
|
},
|
|
@@ -2362,7 +2399,7 @@ function wn() {
|
|
|
2362
2399
|
e({
|
|
2363
2400
|
..._,
|
|
2364
2401
|
errorText: W(v instanceof Error ? v.message : String(v)),
|
|
2365
|
-
durationMs: Date.now() -
|
|
2402
|
+
durationMs: Date.now() - h
|
|
2366
2403
|
});
|
|
2367
2404
|
}
|
|
2368
2405
|
);
|
|
@@ -2370,29 +2407,29 @@ function wn() {
|
|
|
2370
2407
|
} catch {
|
|
2371
2408
|
}
|
|
2372
2409
|
return g;
|
|
2373
|
-
}, a = function(f, u,
|
|
2374
|
-
const C = n.call(this, f, u,
|
|
2375
|
-
return
|
|
2376
|
-
requestId:
|
|
2410
|
+
}, a = function(f, u, h, g, m) {
|
|
2411
|
+
const C = n.call(this, f, u, h ?? !0, g ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
2412
|
+
return je.set(this, {
|
|
2413
|
+
requestId: Ke("xhr"),
|
|
2377
2414
|
method: String(f ?? "GET").toUpperCase(),
|
|
2378
|
-
url: W(T,
|
|
2415
|
+
url: W(T, $e),
|
|
2379
2416
|
requestHeaders: {},
|
|
2380
2417
|
startedAtMs: Date.now(),
|
|
2381
2418
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2382
|
-
excluded:
|
|
2419
|
+
excluded: Y(T)
|
|
2383
2420
|
}), C;
|
|
2384
2421
|
}, l = function(f, u) {
|
|
2385
|
-
const
|
|
2386
|
-
return g && Object.keys(g.requestHeaders).length <
|
|
2422
|
+
const h = r.call(this, f, u), g = je.get(this);
|
|
2423
|
+
return g && Object.keys(g.requestHeaders).length < it && (g.requestHeaders[f] = lt(f, u), g.excluded = g.excluded || Y(g.url, g.requestHeaders)), h;
|
|
2387
2424
|
}, c = function(f) {
|
|
2388
2425
|
try {
|
|
2389
|
-
const u =
|
|
2390
|
-
u && (u.excluded = u.excluded ||
|
|
2426
|
+
const u = je.get(this);
|
|
2427
|
+
u && (u.excluded = u.excluded || Y(u.url, u.requestHeaders, f), u.requestBody = xt(f), u.excluded || this.addEventListener(
|
|
2391
2428
|
"loadend",
|
|
2392
2429
|
() => {
|
|
2393
2430
|
queueMicrotask(() => {
|
|
2394
2431
|
try {
|
|
2395
|
-
const
|
|
2432
|
+
const h = hi(this.getAllResponseHeaders());
|
|
2396
2433
|
e({
|
|
2397
2434
|
requestId: u.requestId,
|
|
2398
2435
|
url: u.url,
|
|
@@ -2401,8 +2438,8 @@ function wn() {
|
|
|
2401
2438
|
requestBody: u.requestBody,
|
|
2402
2439
|
resourceType: "xhr",
|
|
2403
2440
|
responseStatus: this.status,
|
|
2404
|
-
responseHeaders:
|
|
2405
|
-
responseBody: li(this,
|
|
2441
|
+
responseHeaders: h,
|
|
2442
|
+
responseBody: li(this, h),
|
|
2406
2443
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
2407
2444
|
startedAt: u.startedAt,
|
|
2408
2445
|
durationMs: Date.now() - u.startedAtMs
|
|
@@ -2439,16 +2476,16 @@ function wn() {
|
|
|
2439
2476
|
d = new PerformanceObserver((y) => {
|
|
2440
2477
|
for (const f of y.getEntries()) {
|
|
2441
2478
|
const u = f;
|
|
2442
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
2479
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || Y(u.name))
|
|
2443
2480
|
continue;
|
|
2444
|
-
const
|
|
2481
|
+
const h = performance.timeOrigin + u.startTime;
|
|
2445
2482
|
e({
|
|
2446
|
-
requestId:
|
|
2447
|
-
url: W(u.name,
|
|
2483
|
+
requestId: Ke("resource"),
|
|
2484
|
+
url: W(u.name, $e),
|
|
2448
2485
|
method: "GET",
|
|
2449
2486
|
resourceType: "resource",
|
|
2450
2487
|
responseStatus: u.responseStatus,
|
|
2451
|
-
startedAt: new Date(
|
|
2488
|
+
startedAt: new Date(h).toISOString(),
|
|
2452
2489
|
durationMs: u.duration
|
|
2453
2490
|
});
|
|
2454
2491
|
}
|
|
@@ -2459,7 +2496,7 @@ function wn() {
|
|
|
2459
2496
|
d.disconnect(), d = null;
|
|
2460
2497
|
}
|
|
2461
2498
|
}
|
|
2462
|
-
const
|
|
2499
|
+
const p = {
|
|
2463
2500
|
subscribers: t,
|
|
2464
2501
|
destroy: () => {
|
|
2465
2502
|
d?.disconnect();
|
|
@@ -2481,7 +2518,7 @@ function wn() {
|
|
|
2481
2518
|
}
|
|
2482
2519
|
}
|
|
2483
2520
|
};
|
|
2484
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
2521
|
+
return window.__plunoProductAgentNetworkCapture = p, p;
|
|
2485
2522
|
}
|
|
2486
2523
|
function w(t, e, s) {
|
|
2487
2524
|
if (typeof window > "u")
|
|
@@ -2494,17 +2531,17 @@ function w(t, e, s) {
|
|
|
2494
2531
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
2495
2532
|
i.push(r), i.length > 120 && i.splice(0, i.length - 120), n.__plunoProductAgentDiagnostics__ = i, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: r }));
|
|
2496
2533
|
}
|
|
2497
|
-
function
|
|
2534
|
+
function kt(t) {
|
|
2498
2535
|
const e = typeof t == "function" ? t() : t;
|
|
2499
2536
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
2500
2537
|
}
|
|
2501
2538
|
function Mn(t) {
|
|
2502
2539
|
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";
|
|
2503
2540
|
}
|
|
2504
|
-
function
|
|
2541
|
+
function fe(t) {
|
|
2505
2542
|
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";
|
|
2506
2543
|
}
|
|
2507
|
-
function
|
|
2544
|
+
function K(t) {
|
|
2508
2545
|
if (typeof t.sessionId == "string")
|
|
2509
2546
|
return t.sessionId;
|
|
2510
2547
|
if (t.session && typeof t.session == "object") {
|
|
@@ -2531,10 +2568,10 @@ function En() {
|
|
|
2531
2568
|
};
|
|
2532
2569
|
}
|
|
2533
2570
|
function kn() {
|
|
2534
|
-
return
|
|
2571
|
+
return Wt(globalThis, "getPageSnapshot", async () => ot());
|
|
2535
2572
|
}
|
|
2536
2573
|
function Cn() {
|
|
2537
|
-
return
|
|
2574
|
+
return Wt(globalThis, "pageImages", {
|
|
2538
2575
|
inspectImage: async (e, s) => await bn(e, s)
|
|
2539
2576
|
});
|
|
2540
2577
|
}
|
|
@@ -2543,7 +2580,7 @@ async function bn(t, e = {}) {
|
|
|
2543
2580
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
2544
2581
|
type: "pluno.pageImages.inspectImage",
|
|
2545
2582
|
imageAttached: !1,
|
|
2546
|
-
imageAttachmentError:
|
|
2583
|
+
imageAttachmentError: Ft
|
|
2547
2584
|
} : {
|
|
2548
2585
|
type: "pluno.pageImages.inspectImage",
|
|
2549
2586
|
imageAttached: !0,
|
|
@@ -2558,11 +2595,11 @@ async function bn(t, e = {}) {
|
|
|
2558
2595
|
};
|
|
2559
2596
|
}
|
|
2560
2597
|
async function _n(t) {
|
|
2561
|
-
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:
|
|
2598
|
+
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: Ft } : {
|
|
2562
2599
|
ok: !0,
|
|
2563
2600
|
mimeType: t.type,
|
|
2564
2601
|
sizeBytes: t.size,
|
|
2565
|
-
dataUrl: await
|
|
2602
|
+
dataUrl: await On(t)
|
|
2566
2603
|
} : { 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." } : Pn(t);
|
|
2567
2604
|
}
|
|
2568
2605
|
function Pn(t) {
|
|
@@ -2599,7 +2636,7 @@ function Dn(t) {
|
|
|
2599
2636
|
} catch {
|
|
2600
2637
|
}
|
|
2601
2638
|
}
|
|
2602
|
-
function
|
|
2639
|
+
function On(t) {
|
|
2603
2640
|
return new Promise((e, s) => {
|
|
2604
2641
|
const n = new FileReader();
|
|
2605
2642
|
n.onload = () => {
|
|
@@ -2611,7 +2648,7 @@ function qn(t) {
|
|
|
2611
2648
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(t);
|
|
2612
2649
|
});
|
|
2613
2650
|
}
|
|
2614
|
-
async function
|
|
2651
|
+
async function Ct(t, e) {
|
|
2615
2652
|
const s = Object.getPrototypeOf(async function() {
|
|
2616
2653
|
}).constructor, n = t.timeoutMs ?? An, r = Date.now(), i = [];
|
|
2617
2654
|
let o;
|
|
@@ -2627,11 +2664,11 @@ async function kt(t, e) {
|
|
|
2627
2664
|
try {
|
|
2628
2665
|
const c = /* @__PURE__ */ Symbol("execute_code_timeout"), d = await Promise.race([
|
|
2629
2666
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
2630
|
-
new Promise((
|
|
2631
|
-
o = window.setTimeout(() =>
|
|
2667
|
+
new Promise((p) => {
|
|
2668
|
+
o = window.setTimeout(() => p(c), n);
|
|
2632
2669
|
})
|
|
2633
2670
|
]);
|
|
2634
|
-
return d === c ?
|
|
2671
|
+
return d === c ? Ln(n) : {
|
|
2635
2672
|
ok: !0,
|
|
2636
2673
|
result: d,
|
|
2637
2674
|
console: i,
|
|
@@ -2660,7 +2697,7 @@ async function kt(t, e) {
|
|
|
2660
2697
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
2661
2698
|
}
|
|
2662
2699
|
}
|
|
2663
|
-
function
|
|
2700
|
+
function qn(t, e) {
|
|
2664
2701
|
if (!t || typeof t != "object")
|
|
2665
2702
|
return;
|
|
2666
2703
|
const s = t.sandboxFilesToken;
|
|
@@ -2693,8 +2730,8 @@ function Ln(t, e) {
|
|
|
2693
2730
|
);
|
|
2694
2731
|
if (!l.ok)
|
|
2695
2732
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
2696
|
-
const c = await l.blob(),
|
|
2697
|
-
return new File([c],
|
|
2733
|
+
const c = await l.blob(), p = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
2734
|
+
return new File([c], p || a.split("/").pop() || "file", {
|
|
2698
2735
|
type: c.type
|
|
2699
2736
|
});
|
|
2700
2737
|
}
|
|
@@ -2704,7 +2741,7 @@ function Ln(t, e) {
|
|
|
2704
2741
|
}
|
|
2705
2742
|
};
|
|
2706
2743
|
}
|
|
2707
|
-
function
|
|
2744
|
+
function Ln(t) {
|
|
2708
2745
|
return {
|
|
2709
2746
|
ok: !1,
|
|
2710
2747
|
exception: {
|
|
@@ -2744,7 +2781,7 @@ function Hn(t) {
|
|
|
2744
2781
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
2745
2782
|
}
|
|
2746
2783
|
function b() {
|
|
2747
|
-
const t =
|
|
2784
|
+
const t = Jt();
|
|
2748
2785
|
return {
|
|
2749
2786
|
url: location.href,
|
|
2750
2787
|
title: document.title,
|
|
@@ -2756,17 +2793,17 @@ function $n() {
|
|
|
2756
2793
|
return {
|
|
2757
2794
|
pageUrl: location.href,
|
|
2758
2795
|
pageTitle: document.title,
|
|
2759
|
-
htmlContent:
|
|
2796
|
+
htmlContent: ot()
|
|
2760
2797
|
};
|
|
2761
2798
|
}
|
|
2762
2799
|
function jn(t) {
|
|
2763
|
-
return
|
|
2764
|
-
|
|
2800
|
+
return Se.add(t), ge || (ge = Fn()), () => {
|
|
2801
|
+
Se.delete(t), Se.size === 0 && (ge?.(), ge = null);
|
|
2765
2802
|
};
|
|
2766
2803
|
}
|
|
2767
2804
|
function Fn() {
|
|
2768
2805
|
const t = () => {
|
|
2769
|
-
for (const i of Array.from(
|
|
2806
|
+
for (const i of Array.from(Se))
|
|
2770
2807
|
i();
|
|
2771
2808
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
2772
2809
|
const o = e(...i);
|
|
@@ -2779,38 +2816,38 @@ function Fn() {
|
|
|
2779
2816
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
|
|
2780
2817
|
};
|
|
2781
2818
|
}
|
|
2782
|
-
function
|
|
2783
|
-
return
|
|
2819
|
+
function me() {
|
|
2820
|
+
return Jt()?.surface === "browser_extension_sdk_preview";
|
|
2784
2821
|
}
|
|
2785
|
-
function
|
|
2822
|
+
function ot() {
|
|
2786
2823
|
if (!document.body)
|
|
2787
2824
|
return "";
|
|
2788
|
-
const t = [], e = [], s = (
|
|
2789
|
-
const m =
|
|
2790
|
-
!m || e.includes(m) || (t.push([
|
|
2825
|
+
const t = [], e = [], s = (h, g) => {
|
|
2826
|
+
const m = Z(g);
|
|
2827
|
+
!m || e.includes(m) || (t.push([h, m]), e.push(m));
|
|
2791
2828
|
};
|
|
2792
2829
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
2793
2830
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
2794
|
-
(
|
|
2831
|
+
(h) => Gt(h) && !h.parentElement?.closest(n)
|
|
2795
2832
|
);
|
|
2796
|
-
for (const
|
|
2797
|
-
s("Active overlay",
|
|
2798
|
-
const i = zn(), o = i ?
|
|
2799
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2800
|
-
const a = t.map(([
|
|
2833
|
+
for (const h of r.slice(0, 3))
|
|
2834
|
+
s("Active overlay", Fe(le(h), e));
|
|
2835
|
+
const i = zn(), o = i ? Fe(le(i), e) : "";
|
|
2836
|
+
s("Main page content", o), s("Additional visible page text", Fe(le(document.body), e));
|
|
2837
|
+
const a = t.map(([h, g]) => `${h}:
|
|
2801
2838
|
${g}`).join(`
|
|
2802
2839
|
|
|
2803
2840
|
`).trim().slice(0, 12e3), l = Kn(r, i).trim(), c = `Simplified DOM outline:
|
|
2804
2841
|
`, d = `
|
|
2805
2842
|
|
|
2806
2843
|
Visible page text:
|
|
2807
|
-
`,
|
|
2844
|
+
`, p = 12e3 - c.length - d.length, y = Math.min(a.length, 7900), f = l.slice(0, p - y), u = a.slice(0, p - f.length);
|
|
2808
2845
|
return `${c}${f}${d}${u}`;
|
|
2809
2846
|
}
|
|
2810
2847
|
function le(t) {
|
|
2811
2848
|
return t.innerText ?? t.textContent ?? "";
|
|
2812
2849
|
}
|
|
2813
|
-
function
|
|
2850
|
+
function Z(t) {
|
|
2814
2851
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2815
2852
|
`).split(`
|
|
2816
2853
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2818,18 +2855,18 @@ function Q(t) {
|
|
|
2818
2855
|
|
|
2819
2856
|
`).trim();
|
|
2820
2857
|
}
|
|
2821
|
-
function
|
|
2822
|
-
let s =
|
|
2858
|
+
function Fe(t, e) {
|
|
2859
|
+
let s = Z(t);
|
|
2823
2860
|
for (const n of e)
|
|
2824
2861
|
s = s.replace(n, "");
|
|
2825
|
-
return
|
|
2862
|
+
return Z(s);
|
|
2826
2863
|
}
|
|
2827
|
-
function
|
|
2864
|
+
function Gt(t) {
|
|
2828
2865
|
const e = window.getComputedStyle(t);
|
|
2829
2866
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2830
2867
|
}
|
|
2831
2868
|
function zn() {
|
|
2832
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
2869
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Gt).sort((t, e) => le(e).length - le(t).length)[0] ?? null;
|
|
2833
2870
|
}
|
|
2834
2871
|
function Kn(t, e) {
|
|
2835
2872
|
const s = /* @__PURE__ */ new Set([
|
|
@@ -2911,77 +2948,77 @@ function Kn(t, e) {
|
|
|
2911
2948
|
"data-test",
|
|
2912
2949
|
"data-qa",
|
|
2913
2950
|
"data-cy"
|
|
2914
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets:
|
|
2951
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = Gn(), y = new Set(t);
|
|
2915
2952
|
e && y.add(e);
|
|
2916
2953
|
let f = 0;
|
|
2917
2954
|
const u = (T) => {
|
|
2918
2955
|
const S = T.getAttribute("role");
|
|
2919
2956
|
return S && !o.has(S) ? S : "";
|
|
2920
|
-
},
|
|
2957
|
+
}, h = (T) => {
|
|
2921
2958
|
const S = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
|
|
2922
2959
|
return `${T.tagName.toLowerCase()}|${u(T)}|${S}`;
|
|
2923
2960
|
}, g = (T, S, _) => {
|
|
2924
|
-
const v = (R,
|
|
2925
|
-
const P = R.tagName.toLowerCase(), F = window.getComputedStyle(R),
|
|
2926
|
-
if (f >= 1e3 && !
|
|
2961
|
+
const v = (R, te) => {
|
|
2962
|
+
const P = R.tagName.toLowerCase(), F = window.getComputedStyle(R), J = d.has(R);
|
|
2963
|
+
if (f >= 1e3 && !J || _.has(R) || i.has(P) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || F.display === "none" || F.visibility === "hidden")
|
|
2927
2964
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2928
2965
|
f += 1;
|
|
2929
|
-
const
|
|
2966
|
+
const se = u(R), N = Xt(R), ue = a.has(se) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(P) || P === "a" && R.hasAttribute("href"), de = Array.from(R.children).filter((I) => I instanceof HTMLElement), z = /* @__PURE__ */ new Map();
|
|
2930
2967
|
for (const I of de) {
|
|
2931
|
-
const A =
|
|
2968
|
+
const A = h(I);
|
|
2932
2969
|
z.set(A, (z.get(A) ?? 0) + 1);
|
|
2933
2970
|
}
|
|
2934
2971
|
const x = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
|
|
2935
2972
|
for (const I of de) {
|
|
2936
|
-
const A =
|
|
2973
|
+
const A = h(I), j = E.get(A) ?? 0;
|
|
2937
2974
|
E.set(A, j + 1), (z.get(A) ?? 0) > 8 && j >= 6 && !d.has(I) && x.set(A, (x.get(A) ?? 0) + 1);
|
|
2938
2975
|
}
|
|
2939
|
-
const
|
|
2976
|
+
const O = /* @__PURE__ */ new Map(), ct = /* @__PURE__ */ new Set(), Ue = [], ut = [];
|
|
2940
2977
|
for (const I of de) {
|
|
2941
|
-
const A =
|
|
2942
|
-
if (
|
|
2943
|
-
|
|
2978
|
+
const A = h(I), j = z.get(A) ?? 0, pt = O.get(A) ?? 0;
|
|
2979
|
+
if (O.set(A, pt + 1), j > 8 && pt >= 6 && !d.has(I)) {
|
|
2980
|
+
ct.has(A) || (Ue.push([`… ${x.get(A) ?? 0} similar siblings omitted`]), ct.add(A));
|
|
2944
2981
|
continue;
|
|
2945
2982
|
}
|
|
2946
|
-
const
|
|
2947
|
-
|
|
2983
|
+
const gt = v(I, te);
|
|
2984
|
+
ut.push(gt), Ue.push(gt.lines);
|
|
2948
2985
|
}
|
|
2949
|
-
const
|
|
2986
|
+
const ve = [];
|
|
2950
2987
|
if (R.shadowRoot)
|
|
2951
2988
|
for (const I of Array.from(R.shadowRoot.children))
|
|
2952
|
-
I instanceof HTMLElement &&
|
|
2953
|
-
const
|
|
2954
|
-
[N, ...
|
|
2955
|
-
).slice(0, 180),
|
|
2956
|
-
if (
|
|
2957
|
-
const I =
|
|
2958
|
-
|
|
2989
|
+
I instanceof HTMLElement && ve.push(v(I, te + 1));
|
|
2990
|
+
const he = [...ut, ...ve], De = N.length > 0 || ue || he.some((I) => I.hasUsefulContent), dt = Z(
|
|
2991
|
+
[N, ...he.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
2992
|
+
).slice(0, 180), Is = R.hasAttribute("contenteditable") && (N.length > 0 || !R.querySelector("[contenteditable]")), ht = c.some((I) => R.hasAttribute(I)) || !!se || Is, Oe = (R.getClientRects().length > 0 || F.display === "contents") && (s.has(P) || ht || J) && (De || J) && (!r.has(P) || De || ht || J), qe = Oe ? 1 : 0, ne = [];
|
|
2993
|
+
if (Oe) {
|
|
2994
|
+
const I = he.some((j) => j.containsTextElement), A = n.has(P) && !I ? dt : N;
|
|
2995
|
+
ne.push(Vt(R, l, o, A.slice(0, 180)));
|
|
2959
2996
|
}
|
|
2960
|
-
for (const I of
|
|
2961
|
-
|
|
2962
|
-
const Le =
|
|
2997
|
+
for (const I of Ue)
|
|
2998
|
+
ne.push(...ye(I, qe));
|
|
2999
|
+
const Le = ve.flatMap((I) => I.lines);
|
|
2963
3000
|
if (Le.length > 0) {
|
|
2964
3001
|
const I = Le.slice(0, 20);
|
|
2965
3002
|
Le.length > I.length && I.push("… shadow DOM omitted");
|
|
2966
3003
|
const A = P.includes("tooltip") || P.includes("popper") || P.includes("loader");
|
|
2967
|
-
if (
|
|
2968
|
-
const j =
|
|
2969
|
-
|
|
3004
|
+
if (te < 2 && !A) {
|
|
3005
|
+
const j = Oe ? "#shadow-root" : `${P} #shadow-root`;
|
|
3006
|
+
ne.push(...ye([j, ...ye(I, 1)], qe));
|
|
2970
3007
|
} else
|
|
2971
|
-
|
|
3008
|
+
ne.push(...ye(I, qe));
|
|
2972
3009
|
}
|
|
2973
3010
|
return {
|
|
2974
|
-
lines:
|
|
2975
|
-
hasUsefulContent:
|
|
2976
|
-
textPreview:
|
|
2977
|
-
containsTextElement: n.has(P) ||
|
|
3011
|
+
lines: ne,
|
|
3012
|
+
hasUsefulContent: De,
|
|
3013
|
+
textPreview: dt,
|
|
3014
|
+
containsTextElement: n.has(P) || he.some((I) => I.containsTextElement)
|
|
2978
3015
|
};
|
|
2979
3016
|
};
|
|
2980
3017
|
return [`--- ${S} ---`, ...v(T, 0).lines].join(`
|
|
2981
3018
|
`);
|
|
2982
|
-
}, m = [], C =
|
|
3019
|
+
}, m = [], C = Z(window.getSelection()?.toString() ?? "");
|
|
2983
3020
|
C && m.push(`--- selected text ---
|
|
2984
|
-
${JSON.stringify(C)}`),
|
|
3021
|
+
${JSON.stringify(C)}`), p.length > 0 && m.push(Vn(p, s, l, o));
|
|
2985
3022
|
for (const T of t.slice(0, 3))
|
|
2986
3023
|
m.push(g(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2987
3024
|
if (e && m.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -2992,7 +3029,7 @@ ${JSON.stringify(C)}`), h.length > 0 && m.push(Vn(h, s, l, o));
|
|
|
2992
3029
|
|
|
2993
3030
|
`);
|
|
2994
3031
|
}
|
|
2995
|
-
function
|
|
3032
|
+
function Vt(t, e, s, n) {
|
|
2996
3033
|
const r = t.tagName.toLowerCase();
|
|
2997
3034
|
let i = r;
|
|
2998
3035
|
const o = t.getAttribute("id");
|
|
@@ -3018,11 +3055,11 @@ function Gn() {
|
|
|
3018
3055
|
return;
|
|
3019
3056
|
const d = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
3020
3057
|
d.add(l), e.set(a, d);
|
|
3021
|
-
let
|
|
3022
|
-
for (;
|
|
3023
|
-
t.add(
|
|
3024
|
-
const y =
|
|
3025
|
-
|
|
3058
|
+
let p = a;
|
|
3059
|
+
for (; p; ) {
|
|
3060
|
+
t.add(p);
|
|
3061
|
+
const y = p.getRootNode();
|
|
3062
|
+
p = p.parentElement ?? (y instanceof ShadowRoot && y.host instanceof HTMLElement ? y.host : null);
|
|
3026
3063
|
}
|
|
3027
3064
|
};
|
|
3028
3065
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -3030,7 +3067,7 @@ function Gn() {
|
|
|
3030
3067
|
n = n.shadowRoot.activeElement;
|
|
3031
3068
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
3032
3069
|
const r = window.getSelection();
|
|
3033
|
-
r && !r.isCollapsed && (s(
|
|
3070
|
+
r && !r.isCollapsed && (s(bt(r.anchorNode), "selected text"), s(bt(r.focusNode), "selected text"));
|
|
3034
3071
|
const i = [
|
|
3035
3072
|
["[aria-selected='true']", "selected"],
|
|
3036
3073
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -3042,8 +3079,8 @@ function Gn() {
|
|
|
3042
3079
|
for (let a = 0; a < o.length; a += 1) {
|
|
3043
3080
|
const l = o[a];
|
|
3044
3081
|
for (const [c, d] of i)
|
|
3045
|
-
for (const
|
|
3046
|
-
s(
|
|
3082
|
+
for (const p of Array.from(l.querySelectorAll(c)))
|
|
3083
|
+
s(p, d);
|
|
3047
3084
|
for (const c of Array.from(l.querySelectorAll("*")))
|
|
3048
3085
|
c.shadowRoot && o.push(c.shadowRoot);
|
|
3049
3086
|
}
|
|
@@ -3060,40 +3097,40 @@ function Vn(t, e, s, n) {
|
|
|
3060
3097
|
for (; a; ) {
|
|
3061
3098
|
const d = a.tagName.toLowerCase();
|
|
3062
3099
|
(a === i.element || e.has(d) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
3063
|
-
const
|
|
3064
|
-
a = a.parentElement ?? (
|
|
3100
|
+
const p = a.getRootNode();
|
|
3101
|
+
a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
|
|
3065
3102
|
}
|
|
3066
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d,
|
|
3103
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d, p) => Vt(
|
|
3067
3104
|
d,
|
|
3068
3105
|
s,
|
|
3069
3106
|
n,
|
|
3070
|
-
|
|
3107
|
+
p === l.length - 1 ? Xt(d).slice(0, 180) : ""
|
|
3071
3108
|
));
|
|
3072
3109
|
o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
|
|
3073
3110
|
}
|
|
3074
3111
|
return r.join(`
|
|
3075
3112
|
`);
|
|
3076
3113
|
}
|
|
3077
|
-
function
|
|
3114
|
+
function bt(t) {
|
|
3078
3115
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
3079
3116
|
}
|
|
3080
|
-
function
|
|
3117
|
+
function ye(t, e) {
|
|
3081
3118
|
if (e === 0)
|
|
3082
3119
|
return t;
|
|
3083
3120
|
const s = " ".repeat(e);
|
|
3084
3121
|
return t.map((n) => `${s}${n}`);
|
|
3085
3122
|
}
|
|
3086
|
-
function
|
|
3087
|
-
return
|
|
3123
|
+
function Xt(t) {
|
|
3124
|
+
return Z(
|
|
3088
3125
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
3089
3126
|
);
|
|
3090
3127
|
}
|
|
3091
3128
|
function Xn(t) {
|
|
3092
3129
|
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);
|
|
3093
3130
|
}
|
|
3094
|
-
function
|
|
3095
|
-
const t = document.querySelector(
|
|
3096
|
-
if (!(t ?? document.querySelector(
|
|
3131
|
+
function Jt() {
|
|
3132
|
+
const t = document.querySelector(ft);
|
|
3133
|
+
if (!(t ?? document.querySelector(Ve)))
|
|
3097
3134
|
return;
|
|
3098
3135
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
3099
3136
|
return {
|
|
@@ -3102,7 +3139,7 @@ function Xt() {
|
|
|
3102
3139
|
selectors: [
|
|
3103
3140
|
{
|
|
3104
3141
|
name: "widget_host",
|
|
3105
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
3142
|
+
selector: s === "browser_extension_sdk_preview" ? ft : Ve,
|
|
3106
3143
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
3107
3144
|
},
|
|
3108
3145
|
{
|
|
@@ -3141,7 +3178,7 @@ function Yn(t) {
|
|
|
3141
3178
|
return null;
|
|
3142
3179
|
}
|
|
3143
3180
|
}
|
|
3144
|
-
function
|
|
3181
|
+
function _t(t, e) {
|
|
3145
3182
|
if (!t || typeof t != "object")
|
|
3146
3183
|
return [];
|
|
3147
3184
|
const s = t[e];
|
|
@@ -3204,9 +3241,9 @@ function rr(t) {
|
|
|
3204
3241
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
3205
3242
|
} : null;
|
|
3206
3243
|
}
|
|
3207
|
-
function
|
|
3208
|
-
return Array.isArray(t) ?
|
|
3209
|
-
t.map((s) =>
|
|
3244
|
+
function Pt(t, e) {
|
|
3245
|
+
return Array.isArray(t) ? Ze(
|
|
3246
|
+
t.map((s) => Yt(s, e)).filter((s) => s !== null)
|
|
3210
3247
|
) : [];
|
|
3211
3248
|
}
|
|
3212
3249
|
function ir(t) {
|
|
@@ -3230,29 +3267,29 @@ function ir(t) {
|
|
|
3230
3267
|
];
|
|
3231
3268
|
}) : [];
|
|
3232
3269
|
}
|
|
3233
|
-
function
|
|
3270
|
+
function Yt(t, e) {
|
|
3234
3271
|
if (!t || typeof t != "object")
|
|
3235
3272
|
return null;
|
|
3236
3273
|
const s = t, n = s.data;
|
|
3237
3274
|
if (!n || typeof n != "object")
|
|
3238
3275
|
return null;
|
|
3239
3276
|
const r = n;
|
|
3240
|
-
if (r.hiddenFromTranscript === !0 ||
|
|
3277
|
+
if (r.hiddenFromTranscript === !0 || Us(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
|
|
3241
3278
|
return null;
|
|
3242
3279
|
if (r.type === "message") {
|
|
3243
3280
|
const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
|
|
3244
3281
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3245
3282
|
role: i,
|
|
3246
3283
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
3247
|
-
content:
|
|
3248
|
-
|
|
3284
|
+
content: ks(
|
|
3285
|
+
pr(r.content),
|
|
3249
3286
|
e
|
|
3250
3287
|
),
|
|
3251
3288
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3252
3289
|
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3253
|
-
respondsToUserMessageId:
|
|
3290
|
+
respondsToUserMessageId: L(r) ?? void 0,
|
|
3254
3291
|
...k(r) ? { runId: k(r) } : {},
|
|
3255
|
-
attachments:
|
|
3292
|
+
attachments: as(r.attachments, e)
|
|
3256
3293
|
};
|
|
3257
3294
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
3258
3295
|
value: r.id,
|
|
@@ -3263,31 +3300,31 @@ function Jt(t, e) {
|
|
|
3263
3300
|
}), o;
|
|
3264
3301
|
}
|
|
3265
3302
|
if (r.type === "function_call_output") {
|
|
3266
|
-
const i =
|
|
3303
|
+
const i = bs(r.output);
|
|
3267
3304
|
if (i !== null)
|
|
3268
3305
|
return {
|
|
3269
3306
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3270
3307
|
role: "tool",
|
|
3271
3308
|
content: "",
|
|
3272
3309
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3273
|
-
respondsToUserMessageId:
|
|
3310
|
+
respondsToUserMessageId: L(r) ?? void 0,
|
|
3274
3311
|
...k(r) ? { runId: k(r) } : {},
|
|
3275
3312
|
dataType: "function_call_output",
|
|
3276
|
-
toolName:
|
|
3313
|
+
toolName: Cs,
|
|
3277
3314
|
callId: ae(r) ?? void 0,
|
|
3278
3315
|
sharePromptAllowed: i
|
|
3279
3316
|
};
|
|
3280
|
-
const o =
|
|
3317
|
+
const o = js(r.output);
|
|
3281
3318
|
if (o)
|
|
3282
3319
|
return {
|
|
3283
3320
|
id: String(s.id ?? crypto.randomUUID()),
|
|
3284
3321
|
role: "tool",
|
|
3285
3322
|
content: "",
|
|
3286
3323
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3287
|
-
respondsToUserMessageId:
|
|
3324
|
+
respondsToUserMessageId: L(r) ?? void 0,
|
|
3288
3325
|
...k(r) ? { runId: k(r) } : {},
|
|
3289
3326
|
dataType: "scheduled_check_in",
|
|
3290
|
-
toolName:
|
|
3327
|
+
toolName: $t,
|
|
3291
3328
|
callId: ae(r) ?? void 0,
|
|
3292
3329
|
scheduledCheckInAt: o
|
|
3293
3330
|
};
|
|
@@ -3298,7 +3335,7 @@ function Jt(t, e) {
|
|
|
3298
3335
|
content: `Connect ${a.appName} to continue`,
|
|
3299
3336
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3300
3337
|
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3301
|
-
respondsToUserMessageId:
|
|
3338
|
+
respondsToUserMessageId: L(r) ?? void 0,
|
|
3302
3339
|
...k(r) ? { runId: k(r) } : {},
|
|
3303
3340
|
dataType: "function_call_output",
|
|
3304
3341
|
toolName: "authenticate_pipedream_app",
|
|
@@ -3310,7 +3347,7 @@ function Jt(t, e) {
|
|
|
3310
3347
|
content: "Connect WhatsApp to continue",
|
|
3311
3348
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3312
3349
|
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3313
|
-
respondsToUserMessageId:
|
|
3350
|
+
respondsToUserMessageId: L(r) ?? void 0,
|
|
3314
3351
|
...k(r) ? { runId: k(r) } : {},
|
|
3315
3352
|
dataType: "function_call_output",
|
|
3316
3353
|
toolName: "request_personal_channel_connection",
|
|
@@ -3324,7 +3361,7 @@ function Jt(t, e) {
|
|
|
3324
3361
|
content: r.type === "mcp_call" ? or(r) : ur(r),
|
|
3325
3362
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3326
3363
|
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3327
|
-
respondsToUserMessageId:
|
|
3364
|
+
respondsToUserMessageId: L(r) ?? void 0,
|
|
3328
3365
|
...k(r) ? { runId: k(r) } : {},
|
|
3329
3366
|
dataType: String(r.type),
|
|
3330
3367
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
@@ -3336,7 +3373,7 @@ function Jt(t, e) {
|
|
|
3336
3373
|
content: cr(r),
|
|
3337
3374
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3338
3375
|
...D(r) !== null ? { causalSequence: D(r) } : {},
|
|
3339
|
-
respondsToUserMessageId:
|
|
3376
|
+
respondsToUserMessageId: L(r) ?? void 0,
|
|
3340
3377
|
...k(r) ? { runId: k(r) } : {},
|
|
3341
3378
|
dataType: String(r.type),
|
|
3342
3379
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -3400,22 +3437,22 @@ function ur(t) {
|
|
|
3400
3437
|
}
|
|
3401
3438
|
function dr(t) {
|
|
3402
3439
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3403
|
-
return
|
|
3440
|
+
return Q(t.summary);
|
|
3404
3441
|
if (typeof t.arguments == "string")
|
|
3405
3442
|
try {
|
|
3406
3443
|
const e = JSON.parse(t.arguments);
|
|
3407
3444
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
3408
|
-
return
|
|
3445
|
+
return Q(e.summary);
|
|
3409
3446
|
} catch {
|
|
3410
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3447
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? Q(t.name) : "🛠️ Run tool";
|
|
3411
3448
|
}
|
|
3412
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3449
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? Q(t.name) : "🛠️ Run tool";
|
|
3413
3450
|
}
|
|
3414
|
-
function
|
|
3451
|
+
function Q(t) {
|
|
3415
3452
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3416
3453
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3417
3454
|
}
|
|
3418
|
-
function
|
|
3455
|
+
function hr(t) {
|
|
3419
3456
|
if (t == null)
|
|
3420
3457
|
return t;
|
|
3421
3458
|
if (typeof t != "object")
|
|
@@ -3437,7 +3474,7 @@ function ae(t) {
|
|
|
3437
3474
|
function D(t) {
|
|
3438
3475
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
3439
3476
|
}
|
|
3440
|
-
function
|
|
3477
|
+
function pr(t) {
|
|
3441
3478
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
3442
3479
|
if (!e || typeof e != "object")
|
|
3443
3480
|
return "";
|
|
@@ -3445,8 +3482,8 @@ function hr(t) {
|
|
|
3445
3482
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
3446
3483
|
}).filter(Boolean).join("") : "";
|
|
3447
3484
|
}
|
|
3448
|
-
function
|
|
3449
|
-
const s =
|
|
3485
|
+
function Je(t, e) {
|
|
3486
|
+
const s = es(t, e), n = Tr(
|
|
3450
3487
|
gr(
|
|
3451
3488
|
Rr(t, e),
|
|
3452
3489
|
s
|
|
@@ -3454,11 +3491,11 @@ function Ve(t, e) {
|
|
|
3454
3491
|
s
|
|
3455
3492
|
), r = n.findIndex((o) => o.id === s.id);
|
|
3456
3493
|
if (r === -1)
|
|
3457
|
-
return
|
|
3494
|
+
return Ze(
|
|
3458
3495
|
[...n, s]
|
|
3459
3496
|
);
|
|
3460
3497
|
const i = [...n];
|
|
3461
|
-
return i[r] = s,
|
|
3498
|
+
return i[r] = s, Ze(i);
|
|
3462
3499
|
}
|
|
3463
3500
|
function gr(t, e) {
|
|
3464
3501
|
const s = e.assistantDraftItemId;
|
|
@@ -3466,7 +3503,7 @@ function gr(t, e) {
|
|
|
3466
3503
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
3467
3504
|
) : t;
|
|
3468
3505
|
}
|
|
3469
|
-
function
|
|
3506
|
+
function ze(t, e, s) {
|
|
3470
3507
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3471
3508
|
}
|
|
3472
3509
|
function fr(t, e, s, n) {
|
|
@@ -3491,7 +3528,7 @@ function mr(t, e) {
|
|
|
3491
3528
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3492
3529
|
);
|
|
3493
3530
|
if (s === -1)
|
|
3494
|
-
return
|
|
3531
|
+
return Je(t, e);
|
|
3495
3532
|
const n = [...t];
|
|
3496
3533
|
return n[s] = {
|
|
3497
3534
|
...n[s],
|
|
@@ -3515,7 +3552,7 @@ function Ir(t) {
|
|
|
3515
3552
|
return !e || !s ? null : {
|
|
3516
3553
|
id: `transient-activity:${e}`,
|
|
3517
3554
|
role: "tool",
|
|
3518
|
-
content:
|
|
3555
|
+
content: Q(
|
|
3519
3556
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3520
3557
|
),
|
|
3521
3558
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3537,20 +3574,20 @@ function Tr(t, e) {
|
|
|
3537
3574
|
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);
|
|
3538
3575
|
return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
|
|
3539
3576
|
}
|
|
3540
|
-
function
|
|
3541
|
-
return
|
|
3577
|
+
function Qt(t, e) {
|
|
3578
|
+
return vs(
|
|
3542
3579
|
t,
|
|
3543
3580
|
e.map(
|
|
3544
|
-
(s) =>
|
|
3581
|
+
(s) => es(t, s)
|
|
3545
3582
|
),
|
|
3546
|
-
|
|
3583
|
+
Zt
|
|
3547
3584
|
);
|
|
3548
3585
|
}
|
|
3549
3586
|
function Sr(t, e) {
|
|
3550
3587
|
const s = new Map(t.map((n) => [n.id, n]));
|
|
3551
3588
|
for (const n of e)
|
|
3552
3589
|
s.set(n.id, n);
|
|
3553
|
-
return
|
|
3590
|
+
return Qt(
|
|
3554
3591
|
t,
|
|
3555
3592
|
[...s.values()]
|
|
3556
3593
|
).sort(wr);
|
|
@@ -3561,8 +3598,8 @@ function wr(t, e) {
|
|
|
3561
3598
|
const n = Date.parse(t.createdAt) - Date.parse(e.createdAt);
|
|
3562
3599
|
return Number.isNaN(n) ? 0 : n;
|
|
3563
3600
|
}
|
|
3564
|
-
function
|
|
3565
|
-
const e =
|
|
3601
|
+
function Zt(t) {
|
|
3602
|
+
const e = V(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3566
3603
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3567
3604
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3568
3605
|
];
|
|
@@ -3573,24 +3610,24 @@ function Qt(t) {
|
|
|
3573
3610
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3574
3611
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3575
3612
|
...t.runId ? { runId: t.runId } : {},
|
|
3576
|
-
isOptimistic:
|
|
3613
|
+
isOptimistic: _e(t),
|
|
3577
3614
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3578
3615
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3579
3616
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
3580
3617
|
};
|
|
3581
3618
|
}
|
|
3582
|
-
function
|
|
3619
|
+
function es(t, e) {
|
|
3583
3620
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3584
3621
|
return e;
|
|
3585
3622
|
const s = t.find(
|
|
3586
|
-
(o) => o.role === "user" && (o.id === e.id ||
|
|
3623
|
+
(o) => o.role === "user" && (o.id === e.id || _e(o) && ts(o, e))
|
|
3587
3624
|
);
|
|
3588
3625
|
if (!s?.attachments?.length)
|
|
3589
3626
|
return e;
|
|
3590
3627
|
const n = e.attachments.map((o) => {
|
|
3591
3628
|
const a = Mr(s.attachments ?? [], o);
|
|
3592
3629
|
return a ? Ar(o, a) : o;
|
|
3593
|
-
}), r = { ...e, attachments: n }, i =
|
|
3630
|
+
}), r = { ...e, attachments: n }, i = V(e);
|
|
3594
3631
|
return i && Object.defineProperty(r, "clientMessageId", {
|
|
3595
3632
|
value: i,
|
|
3596
3633
|
enumerable: !1
|
|
@@ -3607,21 +3644,21 @@ function Rr(t, e) {
|
|
|
3607
3644
|
if (e.role !== "user")
|
|
3608
3645
|
return t;
|
|
3609
3646
|
const s = t.findIndex(
|
|
3610
|
-
(r) =>
|
|
3647
|
+
(r) => _e(r) && ts(r, e)
|
|
3611
3648
|
);
|
|
3612
3649
|
if (s === -1)
|
|
3613
3650
|
return t;
|
|
3614
3651
|
const n = [...t];
|
|
3615
3652
|
return n.splice(s, 1), n;
|
|
3616
3653
|
}
|
|
3617
|
-
function
|
|
3618
|
-
const s =
|
|
3654
|
+
function ts(t, e) {
|
|
3655
|
+
const s = V(t), n = V(e);
|
|
3619
3656
|
return s && n ? s === n : t.content === e.content;
|
|
3620
3657
|
}
|
|
3621
|
-
function
|
|
3658
|
+
function _e(t) {
|
|
3622
3659
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3623
3660
|
}
|
|
3624
|
-
function
|
|
3661
|
+
function V(t) {
|
|
3625
3662
|
const e = t.clientMessageId;
|
|
3626
3663
|
if (e)
|
|
3627
3664
|
return e;
|
|
@@ -3630,13 +3667,13 @@ function G(t) {
|
|
|
3630
3667
|
);
|
|
3631
3668
|
return n ? t.id.slice(n.length) : null;
|
|
3632
3669
|
}
|
|
3633
|
-
function
|
|
3634
|
-
const e =
|
|
3670
|
+
function Ut(t) {
|
|
3671
|
+
const e = ss(t);
|
|
3635
3672
|
if (e === null)
|
|
3636
3673
|
return !1;
|
|
3637
3674
|
const s = t[e].id;
|
|
3638
3675
|
if (t.some(
|
|
3639
|
-
(r) => r.respondsToUserMessageId === s &&
|
|
3676
|
+
(r) => r.respondsToUserMessageId === s && Ae(r)
|
|
3640
3677
|
))
|
|
3641
3678
|
return !0;
|
|
3642
3679
|
for (let r = t.length - 1; r > e; r -= 1) {
|
|
@@ -3657,7 +3694,7 @@ function Pt(t) {
|
|
|
3657
3694
|
function Er(t, e, s) {
|
|
3658
3695
|
const n = new Set(
|
|
3659
3696
|
t.filter(
|
|
3660
|
-
(r) => r.role === "user" && e !== null &&
|
|
3697
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3661
3698
|
).map((r) => r.id)
|
|
3662
3699
|
);
|
|
3663
3700
|
return t.some((r, i) => {
|
|
@@ -3668,14 +3705,14 @@ function Er(t, e, s) {
|
|
|
3668
3705
|
if (s && r.runId === s) {
|
|
3669
3706
|
if (n.size === 0)
|
|
3670
3707
|
return !0;
|
|
3671
|
-
const o =
|
|
3708
|
+
const o = ns(t, i);
|
|
3672
3709
|
return !r.respondsToUserMessageId && o !== null && n.has(o);
|
|
3673
3710
|
}
|
|
3674
3711
|
return !1;
|
|
3675
3712
|
});
|
|
3676
3713
|
}
|
|
3677
3714
|
function kr(t) {
|
|
3678
|
-
const e =
|
|
3715
|
+
const e = ss(t);
|
|
3679
3716
|
if (e === null)
|
|
3680
3717
|
return t.some(H);
|
|
3681
3718
|
const s = t[e].id;
|
|
@@ -3683,16 +3720,16 @@ function kr(t) {
|
|
|
3683
3720
|
(n) => n.respondsToUserMessageId === s && H(n)
|
|
3684
3721
|
) : t.slice(e + 1).some(H);
|
|
3685
3722
|
}
|
|
3686
|
-
function
|
|
3723
|
+
function ss(t) {
|
|
3687
3724
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3688
|
-
if (t[e].role === "user" && !
|
|
3725
|
+
if (t[e].role === "user" && !_e(t[e]))
|
|
3689
3726
|
return e;
|
|
3690
3727
|
return null;
|
|
3691
3728
|
}
|
|
3692
|
-
function
|
|
3729
|
+
function Ae(t) {
|
|
3693
3730
|
return H(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
|
|
3694
3731
|
}
|
|
3695
|
-
function
|
|
3732
|
+
function ee(t) {
|
|
3696
3733
|
for (let e = t.length - 1; e >= 0; e -= 1) {
|
|
3697
3734
|
const s = t[e];
|
|
3698
3735
|
if (!s || typeof s != "object")
|
|
@@ -3707,7 +3744,7 @@ function Z(t) {
|
|
|
3707
3744
|
return null;
|
|
3708
3745
|
}
|
|
3709
3746
|
function Cr(t) {
|
|
3710
|
-
const e =
|
|
3747
|
+
const e = ee(t);
|
|
3711
3748
|
if (e === null)
|
|
3712
3749
|
return null;
|
|
3713
3750
|
const n = U(t[e])?.page;
|
|
@@ -3722,14 +3759,14 @@ function U(t) {
|
|
|
3722
3759
|
const e = t.data;
|
|
3723
3760
|
return e && typeof e == "object" ? e : null;
|
|
3724
3761
|
}
|
|
3725
|
-
function
|
|
3762
|
+
function Re(t) {
|
|
3726
3763
|
return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
|
|
3727
3764
|
}
|
|
3728
|
-
function
|
|
3765
|
+
function vt(t) {
|
|
3729
3766
|
return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
|
|
3730
3767
|
}
|
|
3731
3768
|
function br(t, e) {
|
|
3732
|
-
const s =
|
|
3769
|
+
const s = ee(e);
|
|
3733
3770
|
if (s === null)
|
|
3734
3771
|
return !1;
|
|
3735
3772
|
const n = e[s], r = n && typeof n == "object" ? n.id : null;
|
|
@@ -3737,11 +3774,11 @@ function br(t, e) {
|
|
|
3737
3774
|
return !1;
|
|
3738
3775
|
const i = t.findIndex((o) => o.role === "user" && o.id === r);
|
|
3739
3776
|
return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
|
|
3740
|
-
(o) => o.respondsToUserMessageId === r &&
|
|
3741
|
-
) : t.slice(i + 1).some(
|
|
3777
|
+
(o) => o.respondsToUserMessageId === r && Ae(o)
|
|
3778
|
+
) : t.slice(i + 1).some(Ae);
|
|
3742
3779
|
}
|
|
3743
|
-
function
|
|
3744
|
-
const e =
|
|
3780
|
+
function Ye(t) {
|
|
3781
|
+
const e = ee(t);
|
|
3745
3782
|
if (e === null)
|
|
3746
3783
|
return null;
|
|
3747
3784
|
const s = t[e];
|
|
@@ -3754,7 +3791,7 @@ function Xe(t) {
|
|
|
3754
3791
|
return typeof r == "string" ? r : null;
|
|
3755
3792
|
}
|
|
3756
3793
|
function _r(t) {
|
|
3757
|
-
const e =
|
|
3794
|
+
const e = ee(t);
|
|
3758
3795
|
if (e === null)
|
|
3759
3796
|
return null;
|
|
3760
3797
|
for (let s = t.length - 1; s > e; s -= 1) {
|
|
@@ -3768,16 +3805,16 @@ function _r(t) {
|
|
|
3768
3805
|
if (i.type === "message" && i.role === "assistant")
|
|
3769
3806
|
return null;
|
|
3770
3807
|
if (i.type === "run_error")
|
|
3771
|
-
return i.retryable !== !0 ? null :
|
|
3808
|
+
return i.retryable !== !0 ? null : Qe(t, i) ?? Ye(t);
|
|
3772
3809
|
if (i.type === "run_status")
|
|
3773
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3810
|
+
return i.status === "interrupted" && i.retryable === !0 ? Qe(t, i) ?? Ye(t) : null;
|
|
3774
3811
|
}
|
|
3775
3812
|
return null;
|
|
3776
3813
|
}
|
|
3777
|
-
function
|
|
3814
|
+
function Qe(t, e) {
|
|
3778
3815
|
if (typeof e.clientMessageId == "string")
|
|
3779
3816
|
return e.clientMessageId;
|
|
3780
|
-
const s =
|
|
3817
|
+
const s = L(e);
|
|
3781
3818
|
if (!s)
|
|
3782
3819
|
return null;
|
|
3783
3820
|
const n = t.find((i) => M(i, "id") === s), r = U(n);
|
|
@@ -3796,13 +3833,13 @@ function Pr(t, e) {
|
|
|
3796
3833
|
}
|
|
3797
3834
|
return s;
|
|
3798
3835
|
}
|
|
3799
|
-
function
|
|
3836
|
+
function Dt(t, e, s, n, r, i) {
|
|
3800
3837
|
if (!e || !vr(t))
|
|
3801
3838
|
return !1;
|
|
3802
3839
|
const o = t;
|
|
3803
|
-
if (
|
|
3840
|
+
if (Re(o) || s !== null && typeof o.id == "string" && o.id !== s)
|
|
3804
3841
|
return !1;
|
|
3805
|
-
const a =
|
|
3842
|
+
const a = L(o);
|
|
3806
3843
|
return n !== null ? a !== null ? a === n : r !== null && k(o) === r && i === n : r === null || k(o) === r;
|
|
3807
3844
|
}
|
|
3808
3845
|
function Ur(t, e) {
|
|
@@ -3813,7 +3850,7 @@ function Ur(t, e) {
|
|
|
3813
3850
|
}
|
|
3814
3851
|
return null;
|
|
3815
3852
|
}
|
|
3816
|
-
function
|
|
3853
|
+
function ns(t, e) {
|
|
3817
3854
|
for (let s = e - 1; s >= 0; s -= 1)
|
|
3818
3855
|
if (t[s].role === "user")
|
|
3819
3856
|
return t[s].id;
|
|
@@ -3834,44 +3871,44 @@ function Dr(t) {
|
|
|
3834
3871
|
const e = t;
|
|
3835
3872
|
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";
|
|
3836
3873
|
}
|
|
3837
|
-
function
|
|
3838
|
-
return t.filter((e, s) =>
|
|
3874
|
+
function Ze(t) {
|
|
3875
|
+
return t.filter((e, s) => X(e) ? !Fr(t, s) && !rs(t, s) && !$r(t, s) && !jr(t, s) : Or(e) ? e.retryable === !0 && Hr(t, s) ? !1 : !Wr(t, s) : !0);
|
|
3839
3876
|
}
|
|
3840
|
-
function
|
|
3877
|
+
function Or(t) {
|
|
3841
3878
|
return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
|
|
3842
3879
|
}
|
|
3843
|
-
function
|
|
3880
|
+
function X(t) {
|
|
3844
3881
|
return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
|
|
3845
3882
|
}
|
|
3846
|
-
function
|
|
3883
|
+
function qr(t, e, s, n) {
|
|
3847
3884
|
const r = t.findIndex(
|
|
3848
|
-
(l, c) =>
|
|
3885
|
+
(l, c) => X(l) && !rs(t, c)
|
|
3849
3886
|
), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
|
|
3850
3887
|
(l) => l.role === "user" && l.id === o
|
|
3851
3888
|
) : null;
|
|
3852
3889
|
return {
|
|
3853
|
-
clientMessageId: a ?
|
|
3890
|
+
clientMessageId: a ? V(a) : o ? null : n,
|
|
3854
3891
|
respondsToUserMessageId: o,
|
|
3855
3892
|
runId: s ?? i?.runId ?? null
|
|
3856
3893
|
};
|
|
3857
3894
|
}
|
|
3858
|
-
function
|
|
3895
|
+
function we(t) {
|
|
3859
3896
|
return t?.type === "run_status" && t.status === "stopped";
|
|
3860
3897
|
}
|
|
3861
|
-
function
|
|
3862
|
-
return H(e) ? "completed" :
|
|
3898
|
+
function Lr(t, e) {
|
|
3899
|
+
return H(e) ? "completed" : we(t) ? "stopped" : !Re(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
|
|
3863
3900
|
}
|
|
3864
|
-
function
|
|
3901
|
+
function Ot(t, e, s) {
|
|
3865
3902
|
const n = new Set(
|
|
3866
3903
|
t.filter(
|
|
3867
|
-
(r) => r.role === "user" && e !== null &&
|
|
3904
|
+
(r) => r.role === "user" && e !== null && V(r) === e
|
|
3868
3905
|
).map((r) => r.id)
|
|
3869
3906
|
);
|
|
3870
3907
|
return t.filter(
|
|
3871
|
-
(r) => !
|
|
3908
|
+
(r) => !X(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
|
|
3872
3909
|
);
|
|
3873
3910
|
}
|
|
3874
|
-
function
|
|
3911
|
+
function rs(t, e) {
|
|
3875
3912
|
return t.some(
|
|
3876
3913
|
(s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && Nr(
|
|
3877
3914
|
t,
|
|
@@ -3903,7 +3940,7 @@ function xr(t, e) {
|
|
|
3903
3940
|
) : t;
|
|
3904
3941
|
}
|
|
3905
3942
|
function qt(t) {
|
|
3906
|
-
return t.role === "tool" ||
|
|
3943
|
+
return t.role === "tool" || X(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
|
|
3907
3944
|
}
|
|
3908
3945
|
function Br(t, e) {
|
|
3909
3946
|
return t.some(
|
|
@@ -3927,7 +3964,7 @@ function Hr(t, e) {
|
|
|
3927
3964
|
const r = t[n];
|
|
3928
3965
|
if (r.role === "user")
|
|
3929
3966
|
return !1;
|
|
3930
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
3967
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || X(r)))
|
|
3931
3968
|
return !0;
|
|
3932
3969
|
}
|
|
3933
3970
|
return !1;
|
|
@@ -3947,7 +3984,7 @@ function jr(t, e) {
|
|
|
3947
3984
|
function Fr(t, e) {
|
|
3948
3985
|
const s = t[e];
|
|
3949
3986
|
for (let n = e + 1; n < t.length; n += 1)
|
|
3950
|
-
if (
|
|
3987
|
+
if (X(t[n]) && ce(s, t[n]))
|
|
3951
3988
|
return !0;
|
|
3952
3989
|
return !1;
|
|
3953
3990
|
}
|
|
@@ -3959,7 +3996,7 @@ function M(t, e) {
|
|
|
3959
3996
|
}
|
|
3960
3997
|
function zr(t, e) {
|
|
3961
3998
|
try {
|
|
3962
|
-
const s = window.localStorage.getItem(`${
|
|
3999
|
+
const s = window.localStorage.getItem(`${zt}${t}`);
|
|
3963
4000
|
if (!s)
|
|
3964
4001
|
return null;
|
|
3965
4002
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
@@ -3974,16 +4011,16 @@ function zr(t, e) {
|
|
|
3974
4011
|
return null;
|
|
3975
4012
|
}
|
|
3976
4013
|
}
|
|
3977
|
-
function
|
|
4014
|
+
function is(t) {
|
|
3978
4015
|
return t.role === "user" || t.role === "assistant" || t.dataType === "run_status" || t.dataType === "run_error";
|
|
3979
4016
|
}
|
|
3980
4017
|
function Kr(t, e) {
|
|
3981
4018
|
try {
|
|
3982
4019
|
window.localStorage.setItem(
|
|
3983
|
-
`${
|
|
4020
|
+
`${zt}${t}`,
|
|
3984
4021
|
JSON.stringify({
|
|
3985
4022
|
sessionId: e.sessionId,
|
|
3986
|
-
messages: e.messages.filter(
|
|
4023
|
+
messages: e.messages.filter(is).slice(-mn).map(ni)
|
|
3987
4024
|
})
|
|
3988
4025
|
);
|
|
3989
4026
|
} catch {
|
|
@@ -3992,33 +4029,33 @@ function Kr(t, e) {
|
|
|
3992
4029
|
}
|
|
3993
4030
|
function Gr(t) {
|
|
3994
4031
|
try {
|
|
3995
|
-
const e = window.localStorage.getItem(`${
|
|
4032
|
+
const e = window.localStorage.getItem(`${Xe}${t}`);
|
|
3996
4033
|
if (!e)
|
|
3997
4034
|
return [];
|
|
3998
4035
|
const s = JSON.parse(e);
|
|
3999
|
-
return Array.isArray(s) ? s.filter(
|
|
4036
|
+
return Array.isArray(s) ? s.filter(at) : [];
|
|
4000
4037
|
} catch {
|
|
4001
4038
|
return [];
|
|
4002
4039
|
}
|
|
4003
4040
|
}
|
|
4004
|
-
function
|
|
4041
|
+
function G(t, e) {
|
|
4005
4042
|
try {
|
|
4006
|
-
const s = e.filter(
|
|
4043
|
+
const s = e.filter(at);
|
|
4007
4044
|
if (s.length === 0) {
|
|
4008
|
-
window.localStorage.removeItem(`${
|
|
4045
|
+
window.localStorage.removeItem(`${Xe}${t}`);
|
|
4009
4046
|
return;
|
|
4010
4047
|
}
|
|
4011
4048
|
window.localStorage.setItem(
|
|
4012
|
-
`${
|
|
4049
|
+
`${Xe}${t}`,
|
|
4013
4050
|
JSON.stringify(s.slice(-25))
|
|
4014
4051
|
);
|
|
4015
4052
|
} catch {
|
|
4016
4053
|
return;
|
|
4017
4054
|
}
|
|
4018
4055
|
}
|
|
4019
|
-
function
|
|
4056
|
+
function os(t, e) {
|
|
4020
4057
|
try {
|
|
4021
|
-
const s = `${
|
|
4058
|
+
const s = `${be}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
4022
4059
|
...o,
|
|
4023
4060
|
storedAt: Date.now(),
|
|
4024
4061
|
unloadUrl: n,
|
|
@@ -4034,16 +4071,16 @@ function is(t, e) {
|
|
|
4034
4071
|
}
|
|
4035
4072
|
function Lt(t, e) {
|
|
4036
4073
|
try {
|
|
4037
|
-
if (window.sessionStorage.getItem(`${
|
|
4074
|
+
if (window.sessionStorage.getItem(`${be}${t}`) === null)
|
|
4038
4075
|
return;
|
|
4039
4076
|
} catch {
|
|
4040
4077
|
return;
|
|
4041
4078
|
}
|
|
4042
|
-
|
|
4079
|
+
os(t, e);
|
|
4043
4080
|
}
|
|
4044
4081
|
function Vr(t) {
|
|
4045
4082
|
try {
|
|
4046
|
-
const e = `${
|
|
4083
|
+
const e = `${be}${t}`, s = window.sessionStorage.getItem(e);
|
|
4047
4084
|
if (window.sessionStorage.removeItem(e), !s)
|
|
4048
4085
|
return [];
|
|
4049
4086
|
const n = JSON.parse(s);
|
|
@@ -4078,7 +4115,7 @@ function Jr(t) {
|
|
|
4078
4115
|
if (!t || typeof t != "object")
|
|
4079
4116
|
return !1;
|
|
4080
4117
|
const e = t, s = e.event;
|
|
4081
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
4118
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && at(s) && s.type === "tool.result";
|
|
4082
4119
|
}
|
|
4083
4120
|
function Yr(t, e) {
|
|
4084
4121
|
const s = new Set(
|
|
@@ -4091,24 +4128,24 @@ function Yr(t, e) {
|
|
|
4091
4128
|
}
|
|
4092
4129
|
function Qr(t) {
|
|
4093
4130
|
try {
|
|
4094
|
-
window.sessionStorage.removeItem(`${
|
|
4131
|
+
window.sessionStorage.removeItem(`${be}${t}`);
|
|
4095
4132
|
} catch {
|
|
4096
4133
|
return;
|
|
4097
4134
|
}
|
|
4098
4135
|
}
|
|
4099
|
-
function
|
|
4136
|
+
function at(t) {
|
|
4100
4137
|
if (!t || typeof t != "object")
|
|
4101
4138
|
return !1;
|
|
4102
4139
|
const e = t;
|
|
4103
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
4140
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && Nt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Nt(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;
|
|
4104
4141
|
}
|
|
4105
|
-
function
|
|
4142
|
+
function Nt(t) {
|
|
4106
4143
|
if (!t || typeof t != "object")
|
|
4107
4144
|
return !1;
|
|
4108
4145
|
const e = t;
|
|
4109
4146
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
4110
4147
|
}
|
|
4111
|
-
function
|
|
4148
|
+
function as(t, e) {
|
|
4112
4149
|
if (!Array.isArray(t))
|
|
4113
4150
|
return;
|
|
4114
4151
|
const s = t.filter((r) => {
|
|
@@ -4116,30 +4153,30 @@ function os(t, e) {
|
|
|
4116
4153
|
return !1;
|
|
4117
4154
|
const i = r;
|
|
4118
4155
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
4119
|
-
}), n = e ? s.map((r) =>
|
|
4156
|
+
}), n = e ? s.map((r) => ls(r, e)) : s;
|
|
4120
4157
|
return n.length > 0 ? n : void 0;
|
|
4121
4158
|
}
|
|
4122
|
-
function
|
|
4159
|
+
function ls(t, e) {
|
|
4123
4160
|
return t.fileUrl?.startsWith("/") ? {
|
|
4124
4161
|
...t,
|
|
4125
4162
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
4126
4163
|
} : t;
|
|
4127
4164
|
}
|
|
4128
|
-
function
|
|
4165
|
+
function et(t) {
|
|
4129
4166
|
return t.type || ti(t.name) || "application/octet-stream";
|
|
4130
4167
|
}
|
|
4131
4168
|
function Zr(t) {
|
|
4132
|
-
|
|
4169
|
+
cs({
|
|
4133
4170
|
name: t.name,
|
|
4134
|
-
mimeType:
|
|
4171
|
+
mimeType: et(t),
|
|
4135
4172
|
sizeBytes: t.size
|
|
4136
4173
|
});
|
|
4137
4174
|
}
|
|
4138
|
-
function
|
|
4175
|
+
function cs(t) {
|
|
4139
4176
|
const e = ei(t.name), s = t.mimeType.trim().toLowerCase();
|
|
4140
|
-
if (!
|
|
4177
|
+
if (!pn.has(`${e}:${s}`))
|
|
4141
4178
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
4142
|
-
if (t.sizeBytes <= 0 || t.sizeBytes >=
|
|
4179
|
+
if (t.sizeBytes <= 0 || t.sizeBytes >= jt)
|
|
4143
4180
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
4144
4181
|
}
|
|
4145
4182
|
function ei(t) {
|
|
@@ -4167,17 +4204,17 @@ function si(t) {
|
|
|
4167
4204
|
dataType: typeof e.dataType == "string" ? e.dataType : void 0,
|
|
4168
4205
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
4169
4206
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
4170
|
-
attachments:
|
|
4207
|
+
attachments: as(e.attachments)?.map(Ee),
|
|
4171
4208
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
4172
4209
|
};
|
|
4173
4210
|
}
|
|
4174
4211
|
function ni(t) {
|
|
4175
4212
|
return t.attachments?.length ? {
|
|
4176
4213
|
...t,
|
|
4177
|
-
attachments: t.attachments.map(
|
|
4214
|
+
attachments: t.attachments.map(Ee)
|
|
4178
4215
|
} : t;
|
|
4179
4216
|
}
|
|
4180
|
-
function
|
|
4217
|
+
function Ee(t) {
|
|
4181
4218
|
const {
|
|
4182
4219
|
dataUrl: e,
|
|
4183
4220
|
objectUrl: s,
|
|
@@ -4187,7 +4224,7 @@ function Re(t) {
|
|
|
4187
4224
|
} = t;
|
|
4188
4225
|
return i;
|
|
4189
4226
|
}
|
|
4190
|
-
function
|
|
4227
|
+
function L(t) {
|
|
4191
4228
|
const e = t.respondsToUserMessageId;
|
|
4192
4229
|
return typeof e == "string" && e ? e : null;
|
|
4193
4230
|
}
|
|
@@ -4199,25 +4236,25 @@ function ri(t) {
|
|
|
4199
4236
|
const e = t?.timeoutMs;
|
|
4200
4237
|
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 <= Rn);
|
|
4201
4238
|
}
|
|
4202
|
-
function
|
|
4239
|
+
function us(t) {
|
|
4203
4240
|
const e = {};
|
|
4204
4241
|
try {
|
|
4205
4242
|
new Headers(t).forEach((s, n) => {
|
|
4206
|
-
Object.keys(e).length <
|
|
4243
|
+
Object.keys(e).length < it && (e[n] = lt(n, s));
|
|
4207
4244
|
});
|
|
4208
4245
|
} catch {
|
|
4209
4246
|
return {};
|
|
4210
4247
|
}
|
|
4211
4248
|
return e;
|
|
4212
4249
|
}
|
|
4213
|
-
function
|
|
4214
|
-
return
|
|
4250
|
+
function lt(t, e) {
|
|
4251
|
+
return ms(t) ? Pe : W(Ce(e), gn);
|
|
4215
4252
|
}
|
|
4216
4253
|
function ii(t, e) {
|
|
4217
4254
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
4218
4255
|
}
|
|
4219
4256
|
async function oi(t, e, s, n) {
|
|
4220
|
-
const r =
|
|
4257
|
+
const r = us(t.headers);
|
|
4221
4258
|
n({
|
|
4222
4259
|
...e,
|
|
4223
4260
|
responseStatus: t.status,
|
|
@@ -4227,7 +4264,7 @@ async function oi(t, e, s, n) {
|
|
|
4227
4264
|
});
|
|
4228
4265
|
}
|
|
4229
4266
|
async function ai(t) {
|
|
4230
|
-
if (!
|
|
4267
|
+
if (!ds(t.headers))
|
|
4231
4268
|
return;
|
|
4232
4269
|
let e = null, s = null;
|
|
4233
4270
|
try {
|
|
@@ -4246,7 +4283,7 @@ async function ai(t) {
|
|
|
4246
4283
|
const { done: l, value: c } = a;
|
|
4247
4284
|
if (l)
|
|
4248
4285
|
return W(i + r.decode());
|
|
4249
|
-
const d =
|
|
4286
|
+
const d = rt - o;
|
|
4250
4287
|
if (c.byteLength > d)
|
|
4251
4288
|
return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${W(i)}... [truncated]`;
|
|
4252
4289
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
@@ -4259,43 +4296,43 @@ async function ai(t) {
|
|
|
4259
4296
|
}
|
|
4260
4297
|
}
|
|
4261
4298
|
function li(t, e) {
|
|
4262
|
-
if (
|
|
4299
|
+
if (ds(new Headers(e)))
|
|
4263
4300
|
try {
|
|
4264
4301
|
return t.responseType === "" || t.responseType === "text" ? W(t.responseText ?? "") : void 0;
|
|
4265
4302
|
} catch {
|
|
4266
4303
|
return;
|
|
4267
4304
|
}
|
|
4268
4305
|
}
|
|
4269
|
-
function
|
|
4306
|
+
function xt(t) {
|
|
4270
4307
|
if (typeof t == "string")
|
|
4271
4308
|
return W(t);
|
|
4272
4309
|
}
|
|
4273
4310
|
function ci(t) {
|
|
4274
|
-
return
|
|
4311
|
+
return q({
|
|
4275
4312
|
...t,
|
|
4276
|
-
requestBody:
|
|
4277
|
-
responseBody:
|
|
4313
|
+
requestBody: Bt(t.requestBody),
|
|
4314
|
+
responseBody: Bt(t.responseBody)
|
|
4278
4315
|
});
|
|
4279
4316
|
}
|
|
4280
|
-
function
|
|
4317
|
+
function Bt(t) {
|
|
4281
4318
|
if (typeof t != "string")
|
|
4282
4319
|
return t;
|
|
4283
4320
|
const e = t.trim();
|
|
4284
4321
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4285
|
-
return
|
|
4322
|
+
return Ce(t);
|
|
4286
4323
|
try {
|
|
4287
|
-
return JSON.stringify(
|
|
4324
|
+
return JSON.stringify(q(JSON.parse(t)));
|
|
4288
4325
|
} catch {
|
|
4289
|
-
return
|
|
4326
|
+
return Ce(t);
|
|
4290
4327
|
}
|
|
4291
4328
|
}
|
|
4292
|
-
function
|
|
4329
|
+
function ds(t) {
|
|
4293
4330
|
if (!t)
|
|
4294
4331
|
return !1;
|
|
4295
4332
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4296
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
4333
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= rt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4297
4334
|
}
|
|
4298
|
-
function
|
|
4335
|
+
function Y(t, e = {}, s) {
|
|
4299
4336
|
if (di(s))
|
|
4300
4337
|
return !0;
|
|
4301
4338
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
@@ -4312,7 +4349,7 @@ function J(t, e = {}, s) {
|
|
|
4312
4349
|
}
|
|
4313
4350
|
}
|
|
4314
4351
|
function ui(t, e) {
|
|
4315
|
-
if (
|
|
4352
|
+
if (Y(t))
|
|
4316
4353
|
return !0;
|
|
4317
4354
|
try {
|
|
4318
4355
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -4324,50 +4361,50 @@ function ui(t, e) {
|
|
|
4324
4361
|
function di(t) {
|
|
4325
4362
|
return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
|
|
4326
4363
|
}
|
|
4327
|
-
function
|
|
4364
|
+
function hi(t) {
|
|
4328
4365
|
const e = {};
|
|
4329
4366
|
for (const s of t.trim().split(/[\r\n]+/)) {
|
|
4330
4367
|
const n = s.indexOf(":");
|
|
4331
4368
|
if (n <= 0)
|
|
4332
4369
|
continue;
|
|
4333
|
-
if (Object.keys(e).length >=
|
|
4370
|
+
if (Object.keys(e).length >= it)
|
|
4334
4371
|
break;
|
|
4335
4372
|
const r = s.slice(0, n).trim();
|
|
4336
|
-
e[r] =
|
|
4373
|
+
e[r] = lt(r, s.slice(n + 1).trim());
|
|
4337
4374
|
}
|
|
4338
4375
|
return e;
|
|
4339
4376
|
}
|
|
4340
|
-
function W(t, e =
|
|
4377
|
+
function W(t, e = rt) {
|
|
4341
4378
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4342
4379
|
}
|
|
4343
|
-
function
|
|
4380
|
+
function Ke(t) {
|
|
4344
4381
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4345
4382
|
}
|
|
4346
|
-
class
|
|
4383
|
+
class Me extends Error {
|
|
4347
4384
|
constructor(e, s) {
|
|
4348
4385
|
super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
4349
4386
|
}
|
|
4350
4387
|
status;
|
|
4351
4388
|
}
|
|
4352
|
-
async function
|
|
4389
|
+
async function Ie(t, e) {
|
|
4353
4390
|
let s = null;
|
|
4354
|
-
for (let n = 0; n <
|
|
4391
|
+
for (let n = 0; n < Et; n += 1)
|
|
4355
4392
|
try {
|
|
4356
4393
|
return await t();
|
|
4357
4394
|
} catch (r) {
|
|
4358
|
-
if (s = r, n >=
|
|
4395
|
+
if (s = r, n >= Et - 1 || !gi(r))
|
|
4359
4396
|
throw r;
|
|
4360
|
-
await
|
|
4397
|
+
await pi(n);
|
|
4361
4398
|
}
|
|
4362
4399
|
throw s instanceof Error ? s : new Error(e);
|
|
4363
4400
|
}
|
|
4364
|
-
function
|
|
4401
|
+
function pi(t) {
|
|
4365
4402
|
return new Promise((e) => {
|
|
4366
|
-
window.setTimeout(e,
|
|
4403
|
+
window.setTimeout(e, hn[t] ?? 0);
|
|
4367
4404
|
});
|
|
4368
4405
|
}
|
|
4369
4406
|
function gi(t) {
|
|
4370
|
-
return t instanceof
|
|
4407
|
+
return t instanceof Me ? fi(t.status) : t instanceof TypeError;
|
|
4371
4408
|
}
|
|
4372
4409
|
function fi(t) {
|
|
4373
4410
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
@@ -4375,13 +4412,13 @@ function fi(t) {
|
|
|
4375
4412
|
function mi(t) {
|
|
4376
4413
|
return t === 401 || t === 403;
|
|
4377
4414
|
}
|
|
4378
|
-
const
|
|
4379
|
-
function
|
|
4380
|
-
return
|
|
4415
|
+
const Pe = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", yi = "[REDACTED_SIGNED_URL]", Ii = 20, Ti = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, hs = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ps = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, gs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, fs = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, Si = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, wi = /\bhttps?:\/\/[^\s"'<>]+/gi, Mi = /[),.;\]]+$/;
|
|
4416
|
+
function q(t) {
|
|
4417
|
+
return ke(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4381
4418
|
}
|
|
4382
|
-
function
|
|
4419
|
+
function ke(t, e, s) {
|
|
4383
4420
|
if (typeof t == "string")
|
|
4384
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4421
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Ce(t);
|
|
4385
4422
|
if (t === null || typeof t != "object")
|
|
4386
4423
|
return t;
|
|
4387
4424
|
if (e >= Ii)
|
|
@@ -4389,20 +4426,20 @@ function Ee(t, e, s) {
|
|
|
4389
4426
|
if (s.has(t))
|
|
4390
4427
|
return "[REDACTED_CIRCULAR]";
|
|
4391
4428
|
if (s.add(t), Array.isArray(t))
|
|
4392
|
-
return t.map((r) =>
|
|
4429
|
+
return t.map((r) => ke(r, e + 1, s));
|
|
4393
4430
|
const n = {};
|
|
4394
4431
|
for (const [r, i] of Object.entries(t))
|
|
4395
|
-
r === "pageContent" ? n[r] = i :
|
|
4432
|
+
r === "pageContent" ? n[r] = i : ms(r) ? n[r] = Pe : n[r] = r.toLowerCase() === "url" ? Ai(i) : ke(i, e + 1, s);
|
|
4396
4433
|
return n;
|
|
4397
4434
|
}
|
|
4398
|
-
function
|
|
4435
|
+
function ms(t) {
|
|
4399
4436
|
const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
4400
4437
|
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");
|
|
4401
4438
|
}
|
|
4402
4439
|
function Ai(t) {
|
|
4403
|
-
return typeof t == "string" ?
|
|
4440
|
+
return typeof t == "string" ? ys(t) : ke(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4404
4441
|
}
|
|
4405
|
-
function
|
|
4442
|
+
function ys(t) {
|
|
4406
4443
|
try {
|
|
4407
4444
|
const e = new URL(t, location.href);
|
|
4408
4445
|
for (const s of Array.from(e.searchParams.keys()))
|
|
@@ -4412,26 +4449,26 @@ function ms(t) {
|
|
|
4412
4449
|
return Ri(t);
|
|
4413
4450
|
}
|
|
4414
4451
|
}
|
|
4415
|
-
function
|
|
4416
|
-
return t.replace(Si, yi).replace(wi, Ei).replace(
|
|
4452
|
+
function Ce(t) {
|
|
4453
|
+
return t.replace(Si, yi).replace(wi, Ei).replace(hs, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(gs, $).replace(fs, (e, s) => `${s}: ${Pe}`);
|
|
4417
4454
|
}
|
|
4418
4455
|
function Ri(t) {
|
|
4419
|
-
return t.replace(
|
|
4456
|
+
return t.replace(hs, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(gs, $).replace(fs, (e, s) => `${s}: ${Pe}`);
|
|
4420
4457
|
}
|
|
4421
4458
|
function Ei(t) {
|
|
4422
4459
|
const e = t.match(Mi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
4423
|
-
return `${
|
|
4460
|
+
return `${ys(s)}${e}`;
|
|
4424
4461
|
}
|
|
4425
4462
|
export {
|
|
4426
|
-
|
|
4427
|
-
|
|
4463
|
+
ft as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4464
|
+
Ve as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4428
4465
|
Xs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4429
4466
|
Vs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4430
4467
|
Js as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
4431
4468
|
ki as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
4432
|
-
|
|
4469
|
+
Kt as PlunoProductAgent,
|
|
4433
4470
|
In as calculateReconnectDelay,
|
|
4434
|
-
|
|
4471
|
+
Kt as default,
|
|
4435
4472
|
Wn as getProductAgentOriginAccessErrorMessage,
|
|
4436
4473
|
Zr as validateProductAgentProviderInputFile
|
|
4437
4474
|
};
|