@pluno/product-agent-web 0.1.180 → 0.1.182

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.
@@ -1,13 +1,13 @@
1
- const ms = "pluno-product-agent-attachments";
2
- const je = "files";
3
- async function ys(t) {
4
- const e = await Ye();
5
- await Ss(e, "readwrite", (s) => s.put(t));
6
- }
7
- async function Is(t, e) {
8
- const s = await Ye();
9
- await Qe(s, "readwrite", async (n) => {
10
- const r = await Ze(
1
+ const Is = "pluno-product-agent-attachments";
2
+ const ze = "files";
3
+ async function Ts(t) {
4
+ const e = await Ze();
5
+ await Ms(e, "readwrite", (s) => s.put(t));
6
+ }
7
+ async function Ss(t, e) {
8
+ const s = await Ze();
9
+ await et(s, "readwrite", async (n) => {
10
+ const r = await tt(
11
11
  n.get(t)
12
12
  );
13
13
  r && n.put({
@@ -16,38 +16,38 @@ async function Is(t, e) {
16
16
  });
17
17
  });
18
18
  }
19
- async function Ts(t = 864e5) {
20
- const e = await Ye(), s = Date.now() - t;
21
- await Qe(e, "readwrite", async (n) => {
19
+ async function ws(t = 864e5) {
20
+ const e = await Ze(), s = Date.now() - t;
21
+ await et(e, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Ze(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await tt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function Ye() {
26
+ function Ze() {
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(ms, 1);
28
+ const s = indexedDB.open(Is, 1);
29
29
  s.onupgradeneeded = () => {
30
- const r = s.result.createObjectStore(je, { keyPath: "attachmentId" });
30
+ const r = s.result.createObjectStore(ze, { 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 Ss(t, e, s) {
36
- return await Qe(t, e, async (n) => await Ze(s(n)));
35
+ async function Ms(t, e, s) {
36
+ return await et(t, e, async (n) => await tt(s(n)));
37
37
  }
38
- function Qe(t, e, s) {
38
+ function et(t, e, s) {
39
39
  return new Promise((n, r) => {
40
- const i = t.transaction(je, e), o = i.objectStore(je);
40
+ const i = t.transaction(ze, e), o = i.objectStore(ze);
41
41
  let a, l = !1;
42
- s(o).then((u) => {
43
- a = u;
44
- }).catch((u) => {
42
+ s(o).then((c) => {
43
+ a = c;
44
+ }).catch((c) => {
45
45
  l = !0;
46
46
  try {
47
47
  i.abort();
48
48
  } catch {
49
49
  }
50
- r(u);
50
+ r(c);
51
51
  }), i.oncomplete = () => {
52
52
  l || n(a);
53
53
  }, i.onerror = () => {
@@ -57,16 +57,16 @@ function Qe(t, e, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Ze(t) {
60
+ function tt(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 ws(t) {
65
+ function As(t) {
66
66
  return t !== null && (typeof t == "object" || typeof t == "function");
67
67
  }
68
68
  function Bt(t, e, s) {
69
- const n = Reflect.get(t, "pluno"), r = ws(n) ? n : {};
69
+ const n = Reflect.get(t, "pluno"), r = As(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,65 +80,65 @@ function Bt(t, e, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const Ms = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function As(t, e) {
83
+ const Rs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function Es(t, e) {
85
85
  return e ? t.replace(
86
- Ms,
86
+ Rs,
87
87
  (s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
88
88
  ) : t;
89
89
  }
90
- const Rs = "save_runtime_captured_skill";
91
- function Es(t) {
92
- return (t.type === "function_call" || t.type === "tool_call") && t.name === Rs;
90
+ const ks = "save_runtime_captured_skill";
91
+ function Cs(t) {
92
+ return (t.type === "function_call" || t.type === "tool_call") && t.name === ks;
93
93
  }
94
- function ks(t, e, s) {
95
- const n = e.map((c) => ({ item: c, identity: s(c) })), r = new Set(
94
+ function bs(t, e, s) {
95
+ const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
96
96
  n.flatMap(
97
- ({ identity: c }) => c.isActivity && !c.isTransient ? c.activityKeys ?? [] : []
97
+ ({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
98
98
  )
99
99
  ), i = n.filter(
100
- ({ identity: c }) => !(c.isTransient && c.activityKeys?.some((h) => r.has(h)))
101
- ), o = new Map(i.map(({ item: c, identity: h }) => [h.id, c])), a = new Map(
100
+ ({ identity: u }) => !(u.isTransient && u.activityKeys?.some((p) => r.has(p)))
101
+ ), o = new Map(i.map(({ item: u, identity: p }) => [p.id, u])), a = new Map(
102
102
  i.flatMap(
103
- ({ item: c, identity: h }) => h.optimisticKey ? [[h.optimisticKey, c]] : []
103
+ ({ item: u, identity: p }) => p.optimisticKey ? [[p.optimisticKey, u]] : []
104
104
  )
105
105
  ), l = new Map(
106
106
  i.flatMap(
107
- ({ item: c, identity: h }) => h.assistantDraftKey ? [[h.assistantDraftKey, c]] : []
107
+ ({ item: u, identity: p }) => p.assistantDraftKey ? [[p.assistantDraftKey, u]] : []
108
108
  )
109
- ), u = /* @__PURE__ */ new Map();
110
- for (const { item: c, identity: h } of i)
111
- for (const g of h.activityKeys ?? []) {
112
- const T = u.get(g);
113
- (!T || s(T).isTransient) && u.set(g, c);
109
+ ), c = /* @__PURE__ */ new Map();
110
+ for (const { item: u, identity: p } of i)
111
+ for (const g of p.activityKeys ?? []) {
112
+ const m = c.get(g);
113
+ (!m || s(m).isTransient) && c.set(g, u);
114
114
  }
115
- const d = new Set(i.map(({ identity: c }) => c.id)), p = new Set(
116
- i.flatMap(({ identity: c }) => c.runId ? [c.runId] : [])
117
- ), I = /* @__PURE__ */ new Set(), f = [];
118
- for (const c of t) {
119
- const h = s(c);
120
- let g = o.get(h.id);
121
- 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((k) => u.get(k)).find((k) => k !== void 0) ?? g), g && !I.has(g)) {
122
- f.push(g), I.add(g);
115
+ const d = new Set(i.map(({ identity: u }) => u.id)), h = new Set(
116
+ i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
117
+ ), y = /* @__PURE__ */ new Set(), f = [];
118
+ for (const u of t) {
119
+ const p = s(u);
120
+ let g = o.get(p.id);
121
+ if (p.isOptimistic && p.optimisticKey ? g = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? g = l.get(p.assistantDraftKey) : p.isActivity && (g = p.activityKeys?.map((k) => c.get(k)).find((k) => k !== void 0) ?? g), g && !y.has(g)) {
122
+ f.push(g), y.add(g);
123
123
  continue;
124
124
  }
125
- const T = h.respondsToUserMessageId !== void 0 && d.has(h.respondsToUserMessageId) || h.runId !== void 0 && p.has(h.runId);
126
- (h.isOptimistic || (h.isAssistantDraft || h.isActivity) && T) && f.push(c);
125
+ const m = p.respondsToUserMessageId !== void 0 && d.has(p.respondsToUserMessageId) || p.runId !== void 0 && h.has(p.runId);
126
+ (p.isOptimistic || (p.isAssistantDraft || p.isActivity) && m) && f.push(u);
127
127
  }
128
- for (const { item: c } of i)
129
- I.has(c) || f.push(c);
128
+ for (const { item: u } of i)
129
+ y.has(u) || f.push(u);
130
130
  return f;
131
131
  }
132
- function Cs(t, e, s, n) {
132
+ function _s(t, e, s, n) {
133
133
  return t.filter((r) => {
134
134
  const i = n(r);
135
135
  return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
136
136
  });
137
137
  }
138
- const Oe = "pluno.productAgent.transportId", bs = "pluno.productAgent.transportIdentity", Le = "pluno.productAgent.transportIdentity.event", _s = 50, Ps = globalThis.setTimeout.bind(globalThis);
138
+ const Oe = "pluno.productAgent.transportId", Ps = "pluno.productAgent.transportIdentity", Ne = "pluno.productAgent.transportIdentity.event", Us = 50, vs = globalThis.setTimeout.bind(globalThis);
139
139
  let ne = null;
140
- const me = /* @__PURE__ */ new Set(), qe = /* @__PURE__ */ new Map();
141
- async function Us(t = Wt()) {
140
+ const Ie = /* @__PURE__ */ new Set(), xe = /* @__PURE__ */ new Map();
141
+ async function Ds(t = Wt()) {
142
142
  const e = t.randomUUID(), s = t.storage.getItem(Oe);
143
143
  let n = s ?? t.randomUUID(), r = !1, i = !1;
144
144
  const o = t.channel.subscribe((l) => {
@@ -158,6 +158,8 @@ async function Us(t = Wt()) {
158
158
  });
159
159
  if (!s)
160
160
  t.storage.setItem(Oe, n), r = !0;
161
+ else if (t.skipStoredIdentityCollisionCheck)
162
+ r = !0;
161
163
  else
162
164
  for (; ; ) {
163
165
  if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
@@ -174,49 +176,52 @@ async function Us(t = Wt()) {
174
176
  }
175
177
  };
176
178
  }
177
- async function Ds() {
178
- ne || (ne = Us(Wt()), ne.then((n) => {
179
- const r = (i) => {
180
- i.persisted || (n.release(), ne = null, me.clear(), window.removeEventListener("pagehide", r));
179
+ async function qs(t = !1) {
180
+ ne || (ne = Ds({
181
+ ...Wt(),
182
+ skipStoredIdentityCollisionCheck: t
183
+ }), ne.then((r) => {
184
+ const i = (o) => {
185
+ o.persisted || (r.release(), ne = null, Ie.clear(), window.removeEventListener("pagehide", i));
181
186
  };
182
- window.addEventListener("pagehide", r);
187
+ window.addEventListener("pagehide", i);
183
188
  }));
184
- const t = await ne, e = vs();
185
- me.add(e);
186
- let s = !1;
189
+ const e = await ne, s = Ls();
190
+ Ie.add(s);
191
+ let n = !1;
187
192
  return {
188
193
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
189
- transportId: e === 0 ? t.transportId : `${t.transportId}.${e}`,
194
+ transportId: s === 0 ? e.transportId : `${e.transportId}.${s}`,
190
195
  release: () => {
191
- s || (s = !0, me.delete(e));
196
+ n || (n = !0, Ie.delete(s));
192
197
  }
193
198
  };
194
199
  }
195
- function vs() {
200
+ function Ls() {
196
201
  let t = 0;
197
- for (; me.has(t); )
202
+ for (; Ie.has(t); )
198
203
  t += 1;
199
204
  return t;
200
205
  }
201
206
  function Wt() {
202
207
  return {
203
208
  storage: Os(),
204
- channel: Ls(),
209
+ channel: Ns(),
205
210
  randomUUID: () => crypto.randomUUID(),
206
- settle: () => new Promise((t) => Ps(t, _s))
211
+ settle: () => new Promise((t) => vs(t, Us))
207
212
  };
208
213
  }
209
214
  function Os() {
210
215
  return {
211
216
  getItem: (t) => {
212
217
  try {
213
- return window.sessionStorage?.getItem(t) ?? qe.get(t) ?? null;
218
+ return window.sessionStorage?.getItem(t) ?? xe.get(t) ?? null;
214
219
  } catch {
215
- return qe.get(t) ?? null;
220
+ return xe.get(t) ?? null;
216
221
  }
217
222
  },
218
223
  setItem: (t, e) => {
219
- qe.set(t, e);
224
+ xe.set(t, e);
220
225
  try {
221
226
  window.sessionStorage?.setItem(t, e);
222
227
  } catch {
@@ -224,9 +229,9 @@ function Os() {
224
229
  }
225
230
  };
226
231
  }
227
- function Ls() {
232
+ function Ns() {
228
233
  if (typeof BroadcastChannel < "u") {
229
- const t = new BroadcastChannel(bs);
234
+ const t = new BroadcastChannel(Ps);
230
235
  return {
231
236
  postMessage: (e) => t.postMessage(e),
232
237
  subscribe: (e) => {
@@ -236,11 +241,11 @@ function Ls() {
236
241
  close: () => t.close()
237
242
  };
238
243
  }
239
- return qs();
244
+ return xs();
240
245
  }
241
- function qs() {
246
+ function xs() {
242
247
  const t = /* @__PURE__ */ new Set(), e = (s) => {
243
- if (s.key !== Le || !s.newValue)
248
+ if (s.key !== Ne || !s.newValue)
244
249
  return;
245
250
  const n = JSON.parse(s.newValue);
246
251
  for (const r of t)
@@ -249,9 +254,9 @@ function qs() {
249
254
  return window.addEventListener("storage", e), {
250
255
  postMessage: (s) => {
251
256
  window.localStorage.setItem(
252
- Le,
257
+ Ne,
253
258
  JSON.stringify({ ...s, eventId: crypto.randomUUID() })
254
- ), window.localStorage.removeItem(Le);
259
+ ), window.localStorage.removeItem(Ne);
255
260
  },
256
261
  subscribe: (s) => (t.add(s), () => t.delete(s)),
257
262
  close: () => {
@@ -260,7 +265,7 @@ function qs() {
260
265
  };
261
266
  }
262
267
  const Ht = "schedule_follow_up";
263
- function Ns(t) {
268
+ function Bs(t) {
264
269
  let e = t;
265
270
  if (typeof e == "string")
266
271
  try {
@@ -273,18 +278,18 @@ function Ns(t) {
273
278
  const s = e;
274
279
  return s.ok !== !0 || s.toolName !== Ht || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
275
280
  }
276
- const xs = [
281
+ const Ws = [
277
282
  { value: "gpt-5.6-terra", label: "gpt-5.6-terra" },
278
283
  { value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5" },
279
284
  { value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash" }
280
- ], Bs = [
285
+ ], Hs = [
281
286
  { value: "anthropic/claude-opus-5", label: "Claude Opus 5" },
282
287
  { value: "gpt-5.6-sol", label: "gpt-5.6-sol" }
283
- ], Ws = [
284
- ...xs,
285
- ...Bs
286
- ], Hs = (t) => Ws.some((e) => e.value === t), $s = globalThis.fetch.bind(globalThis), Fe = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', js = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Fs = ".pluno-pa-widget__panel", zs = ".pluno-pa-widget__timeline", pt = `${Fe}[data-pluno-sdk-preview-channel]`;
287
- let Ks = 0;
288
+ ], $s = [
289
+ ...Ws,
290
+ ...Hs
291
+ ], js = (t) => $s.some((e) => e.value === t), Fs = globalThis.fetch.bind(globalThis), Ke = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', zs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ks = ".pluno-pa-widget__panel", Gs = ".pluno-pa-widget__timeline", ht = `${Ke}[data-pluno-sdk-preview-channel]`;
292
+ let Vs = 0;
288
293
  function gt(t) {
289
294
  const e = {};
290
295
  for (const o of [
@@ -316,14 +321,14 @@ function gt(t) {
316
321
  if (a && typeof a == "object") {
317
322
  const l = a.composerPreload;
318
323
  if (l && typeof l == "object") {
319
- const u = l.runId;
320
- e.composerPreloaded = !0, typeof u == "string" && (e.preloadRunId = u);
324
+ const c = l.runId;
325
+ e.composerPreloaded = !0, typeof c == "string" && (e.preloadRunId = c);
321
326
  }
322
327
  }
323
328
  }
324
329
  return e;
325
330
  }
326
- function Ne(t, e, s) {
331
+ function Be(t, e, s) {
327
332
  if (typeof window > "u")
328
333
  return;
329
334
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -335,36 +340,36 @@ function Ne(t, e, s) {
335
340
  source: "web_sdk",
336
341
  category: t,
337
342
  name: e,
338
- sequence: ++Ks,
343
+ sequence: ++Vs,
339
344
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
340
345
  monotonicMs: performance.now(),
341
346
  data: s
342
347
  };
343
348
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
344
349
  }
345
- class ce extends Error {
350
+ class pe extends Error {
346
351
  }
347
- function Gs(t) {
352
+ function Xs(t) {
348
353
  return t === 408 || t === 425 || t === 429 || t >= 500;
349
354
  }
350
- const Vs = "https://app.pluno.ai", Xs = 2e4, Js = 1e4, Ys = 1e4, Qs = 1e4, Zs = 1e4, en = 3e3, tn = 3e4, sn = 1e3, ft = 3e4, mt = 0.2, yt = 6e4, It = 15e3, re = 8, Tt = "Browser connection was interrupted.", St = 15e3, nn = "Pluno could not send this message. Try it again.", wt = 2e3, rn = 1e3, on = 100, Mt = 8e3, At = 3, an = [300, 1e3], $t = 50 * 1024 * 1024, ln = /* @__PURE__ */ new Set([
355
+ const Js = "https://app.pluno.ai", Ys = 2e4, Qs = 1e4, Zs = 1e4, en = 1e4, tn = 1e4, sn = 3e3, nn = 3e4, rn = 1e3, ft = 3e4, mt = 0.2, yt = 6e4, It = 15e3, re = 8, Tt = "Browser connection was interrupted.", St = 15e3, on = "Pluno could not send this message. Try it again.", wt = 2e3, an = 1e3, ln = 100, Mt = 8e3, At = 3, cn = [300, 1e3], $t = 50 * 1024 * 1024, un = /* @__PURE__ */ new Set([
351
356
  ".jpeg:image/jpeg",
352
357
  ".jpg:image/jpeg",
353
358
  ".pdf:application/pdf",
354
359
  ".png:image/png",
355
360
  ".webp:image/webp"
356
- ]), wi = ".pdf,.png,.jpg,.jpeg,.webp", et = 64e3, xe = 4e3, tt = 30, un = 2e3, cn = 1e3, jt = "Image is too large for model vision input.", dn = 100, Ft = "pluno.productAgent.state.", ze = "pluno.productAgent.pendingEvents.", Ee = "pluno.productAgent.activeToolCalls.", hn = 100;
361
+ ]), Ai = ".pdf,.png,.jpg,.jpeg,.webp", st = 64e3, We = 4e3, nt = 30, dn = 2e3, pn = 1e3, jt = "Image is too large for model vision input.", hn = 100, Ft = "pluno.productAgent.state.", Ge = "pluno.productAgent.pendingEvents.", Ce = "pluno.productAgent.activeToolCalls.", gn = 100;
357
362
  function ie(t, e = 0) {
358
363
  const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
359
364
  return Math.max(e, s);
360
365
  }
361
- const ye = /* @__PURE__ */ new Set();
362
- let de = null;
363
- function pn(t, e = Math.random) {
364
- const s = Math.min(ft, sn * 2 ** t), n = 1 - mt + e() * mt * 2;
366
+ const Te = /* @__PURE__ */ new Set();
367
+ let he = null;
368
+ function fn(t, e = Math.random) {
369
+ const s = Math.min(ft, rn * 2 ** t), n = 1 - mt + e() * mt * 2;
365
370
  return Math.min(ft, Math.round(s * n));
366
371
  }
367
- function gn(t, e, s) {
372
+ function mn(t, e, s) {
368
373
  return new Promise((n, r) => {
369
374
  const i = setTimeout(() => r(new Error(s)), e);
370
375
  t.then(
@@ -381,15 +386,16 @@ class zt {
381
386
  constructor(e, s) {
382
387
  this.options = e, this.transportIdentity = s, this.state = {
383
388
  ...this.state,
384
- starterPrompts: Gn(e.initialStarterPrompts)
389
+ starterPrompts: Xn(e.initialStarterPrompts)
385
390
  };
386
- const n = e.restorePersistedState === !1 ? null : Wr(e.clientId, e.expectedPersistedSessionId);
391
+ const n = e.restorePersistedState === !1 ? null : $r(e.clientId, e.expectedPersistedSessionId);
387
392
  n && (this.state = {
388
393
  ...this.state,
389
394
  ...n,
390
- messages: n.messages.filter(
391
- (i) => !F(i)
392
- ),
395
+ // Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
396
+ // activity is deliberately not restored here because it hydrates after the transcript is visible.
397
+ messages: n.messages.filter(rs),
398
+ isLoadingSession: n.sessionId !== null,
393
399
  status: "idle",
394
400
  user: null,
395
401
  assistantDraft: "",
@@ -403,14 +409,14 @@ class zt {
403
409
  taskStatus: null,
404
410
  isRetrying: !1,
405
411
  lastError: null
406
- }), this.queuedClientEvents = Kr(
407
- $r(e.clientId),
408
- jr(e.clientId)
412
+ }), this.queuedClientEvents = Vr(
413
+ Fr(e.clientId),
414
+ zr(e.clientId)
409
415
  );
410
416
  const r = [...this.queuedClientEvents].reverse().find(
411
417
  (i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
412
418
  );
413
- r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), G(e.clientId, this.queuedClientEvents);
419
+ r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), K(e.clientId, this.queuedClientEvents);
414
420
  }
415
421
  options;
416
422
  listeners = {};
@@ -443,10 +449,7 @@ class zt {
443
449
  sessionLoadRequestTimer = null;
444
450
  pendingSessionSubscription = null;
445
451
  sessionHistoryHydration = null;
446
- sessionItemsRequestId = null;
447
- sessionItemsCursor = null;
448
- hasLoadedOlderSessionItems = !1;
449
- loadedOlderSessionItemIds = /* @__PURE__ */ new Set();
452
+ sessionActivityRequestId = null;
450
453
  transportIdentity;
451
454
  retryAttemptsByClientMessageId = {};
452
455
  retryTimersByClientMessageId = {};
@@ -498,8 +501,6 @@ class zt {
498
501
  appearance: null,
499
502
  messages: [],
500
503
  isLoadingSession: !1,
501
- isLoadingOlderMessages: !1,
502
- hasOlderMessages: !1,
503
504
  assistantDraft: "",
504
505
  assistantDraftItemId: null,
505
506
  assistantDraftPhase: null,
@@ -515,23 +516,25 @@ class zt {
515
516
  lastErrorSecuritySettingsUrl: null
516
517
  };
517
518
  static async init(e) {
518
- const s = await Ds(), n = new zt({
519
+ const s = e, n = await qs(
520
+ s.skipStoredTransportIdentityCollisionCheck === !0
521
+ ), r = new zt({
519
522
  ...e,
520
- backendUrl: Dn(e.backendUrl ?? Vs),
521
- clientId: e.clientId ?? Qn(),
523
+ backendUrl: qn(e.backendUrl ?? Js),
524
+ clientId: e.clientId ?? er(),
522
525
  productVariant: e.productVariant ?? "customer_embedded",
523
- entrySurface: vn(e.entrySurface)
524
- }, s);
526
+ entrySurface: Ln(e.entrySurface)
527
+ }, n);
525
528
  try {
526
- Ts().catch((r) => {
527
- M("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
528
- message: r instanceof Error ? r.message : String(r)
529
+ ws().catch((i) => {
530
+ w("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
531
+ message: i instanceof Error ? i.message : String(i)
529
532
  });
530
- }), e.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await n.connect();
531
- } catch (r) {
532
- throw n.destroy(), r;
533
+ }), s.disableNetworkCapture || r.enableNetworkCapture(), r.startPageLifecycleRecovery(), r.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await r.connect();
534
+ } catch (i) {
535
+ throw r.destroy(), i;
533
536
  }
534
- return n;
537
+ return r;
535
538
  }
536
539
  on(e, s) {
537
540
  const n = this.listeners[e] ?? /* @__PURE__ */ new Set();
@@ -554,15 +557,15 @@ class zt {
554
557
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
555
558
  );
556
559
  try {
557
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await gn(this.options.tokenProvider(), Ys, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
560
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await mn(this.options.tokenProvider(), Zs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
558
561
  return;
559
562
  if (!this.token && !this.options.webSocketFactory)
560
563
  throw new Error("Pluno requires a token or tokenProvider");
561
- const s = qn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
564
+ const s = xn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
562
565
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
563
- this.socket === n && n.readyState === WebSocket.CONNECTING && (M("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
564
- }, Qs), n.addEventListener("open", () => {
565
- this.socket !== n || (this.clearSocketConnectTimer(), M("web-sdk.agent", "Pluno socket opened", {
566
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (w("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
567
+ }, en), n.addEventListener("open", () => {
568
+ this.socket !== n || (this.clearSocketConnectTimer(), w("web-sdk.agent", "Pluno socket opened", {
566
569
  queuedClientEventCount: this.queuedClientEvents.length,
567
570
  isThinking: this.state.isThinking
568
571
  }), !(this.token ? this.sendNow({
@@ -572,19 +575,19 @@ class zt {
572
575
  transportId: this.transportIdentity.transportId,
573
576
  pageUrl: location.href
574
577
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
575
- this.socket === n && (M("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
576
- }, Zs));
578
+ this.socket === n && (w("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
579
+ }, tn));
577
580
  }), n.addEventListener("message", (r) => {
578
- this.socket === n && this.handleServerEvent(zn(r.data));
581
+ this.socket === n && this.handleServerEvent(Gn(r.data));
579
582
  }), n.addEventListener("sendfailure", (r) => {
580
583
  if (this.socket !== n)
581
584
  return;
582
- const i = Kn(r?.detail?.data);
585
+ const i = Vn(r?.detail?.data);
583
586
  i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
584
587
  (o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
585
- ) && (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();
588
+ ) && (this.queuedClientEvents.push(i), K(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();
586
589
  }), n.addEventListener("close", (r) => {
587
- this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (M("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
590
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (w("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
588
591
  code: typeof r?.code == "number" ? r.code : null,
589
592
  reason: typeof r?.reason == "string" ? r.reason : "",
590
593
  wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
@@ -592,7 +595,7 @@ class zt {
592
595
  isThinking: this.state.isThinking
593
596
  }), this.setReconnectingState(), this.scheduleReconnect()));
594
597
  }), n.addEventListener("error", () => {
595
- this.socket !== n || this.state.status === "closed" || (M("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
598
+ this.socket !== n || this.state.status === "closed" || (w("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
596
599
  queuedClientEventCount: this.queuedClientEvents.length,
597
600
  isThinking: this.state.isThinking
598
601
  }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
@@ -615,7 +618,7 @@ class zt {
615
618
  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;
616
619
  }
617
620
  destroy() {
618
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Gr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
621
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Xr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
619
622
  for (const e of Object.values(this.listeners))
620
623
  e?.clear();
621
624
  }
@@ -623,7 +626,7 @@ class zt {
623
626
  const s = b(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
624
627
  type: "runtime.warmup",
625
628
  reason: e,
626
- ...e === "composer_input" ? { warmupId: r?.event.warmupId ?? N() } : {},
629
+ ...e === "composer_input" ? { warmupId: r?.event.warmupId ?? B() } : {},
627
630
  entrySurface: this.options.entrySurface,
628
631
  sessionId: this.state.sessionId ?? void 0,
629
632
  page: s,
@@ -654,23 +657,23 @@ class zt {
654
657
  }
655
658
  async sendMessage(e, s = {}) {
656
659
  const n = e.trim(), r = s.attachments ?? [];
657
- if (this.options.productVariant === "customer_embedded" && (r.forEach(os), r.reduce(
658
- (w, U) => w + U.sizeBytes,
660
+ if (this.options.productVariant === "customer_embedded" && (r.forEach(ls), r.reduce(
661
+ (S, _) => S + _.sizeBytes,
659
662
  0
660
663
  ) > $t))
661
664
  throw new Error("Embedded attachments must total at most 50 MB per message");
662
- let i = r.map(Me);
665
+ let i = r.map(Re);
663
666
  if (!n && i.length === 0)
664
667
  return null;
665
668
  if (this.pendingClientMessageId)
666
669
  throw new Error("Wait for the current message to finish sending before sending another.");
667
- const o = b(), a = s.clientMessageId ?? N(), l = {
670
+ const o = b(), a = s.clientMessageId ?? B(), l = {
668
671
  id: `local-${a}`,
669
672
  role: "user",
670
673
  content: n,
671
674
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
672
675
  ...r.length > 0 ? { attachments: r } : {}
673
- }, u = this.state.messages.some((m) => m.id === l.id || m.clientMessageId === a), d = this.state.isThinking, p = this.state.taskStatus, I = this.state.pendingMessageStatus, f = this.state.turnPhase, c = this.state.messages, h = u ? this.state.messages : [...this.state.messages, l], g = {
676
+ }, c = this.state.messages.some((T) => T.id === l.id || T.clientMessageId === a), d = this.state.isThinking, h = this.state.taskStatus, y = this.state.pendingMessageStatus, f = this.state.turnPhase, u = this.state.messages, p = c ? this.state.messages : [...this.state.messages, l], g = {
674
677
  assistantDraft: this.state.assistantDraft,
675
678
  assistantDraftItemId: this.state.assistantDraftItemId,
676
679
  assistantDraftPhase: this.state.assistantDraftPhase,
@@ -679,7 +682,7 @@ class zt {
679
682
  lastError: this.state.lastError
680
683
  };
681
684
  this.setState({
682
- messages: h,
685
+ messages: p,
683
686
  ...d ? {} : {
684
687
  assistantDraft: "",
685
688
  assistantDraftItemId: null,
@@ -693,31 +696,31 @@ class zt {
693
696
  taskStatus: "working",
694
697
  isRetrying: !1,
695
698
  lastError: null
696
- }), u || this.emit("message", l);
699
+ }), c || this.emit("message", l);
697
700
  try {
698
- const m = [];
699
- for (const w of i) {
700
- const U = w.id ? this.attachmentFiles.get(w.id) : void 0;
701
- if (w.sandboxPath || w.storageKey) {
702
- m.push(w);
701
+ const T = [];
702
+ for (const S of i) {
703
+ const _ = S.id ? this.attachmentFiles.get(S.id) : void 0;
704
+ if (S.sandboxPath || S.storageKey) {
705
+ T.push(S);
703
706
  continue;
704
707
  }
705
- if (!U)
706
- throw new Error(`Attachment bytes are unavailable for ${w.name}`);
707
- m.push(await this.uploadAttachmentForMessage({ file: U, attachment: w }));
708
+ if (!_)
709
+ throw new Error(`Attachment bytes are unavailable for ${S.name}`);
710
+ T.push(await this.uploadAttachmentForMessage({ file: _, attachment: S }));
708
711
  }
709
- i = m;
710
- } catch (m) {
712
+ i = T;
713
+ } catch (T) {
711
714
  throw this.setState({
712
- ...u ? {} : { messages: c },
715
+ ...c ? {} : { messages: u },
713
716
  ...d ? {} : { ...g, isThinking: !1 },
714
- pendingMessageStatus: I,
717
+ pendingMessageStatus: y,
715
718
  turnPhase: f,
716
- taskStatus: p
717
- }), m;
719
+ taskStatus: h
720
+ }), T;
718
721
  }
719
722
  this.retryableClientMessageId = null;
720
- const T = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, k = {
723
+ const m = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, k = {
721
724
  type: "chat.user_message",
722
725
  sessionId: this.state.sessionId ?? void 0,
723
726
  clientMessageId: a,
@@ -725,8 +728,8 @@ class zt {
725
728
  invocation: On(s.invocation ?? s.initiatedBy),
726
729
  entrySurface: this.options.entrySurface,
727
730
  content: n,
728
- pageContent: T && st() || void 0,
729
- attachments: i.length > 0 ? i.map(Me) : void 0,
731
+ pageContent: m && rt() || void 0,
732
+ attachments: i.length > 0 ? i.map(Re) : void 0,
730
733
  page: o,
731
734
  model: this.options.model,
732
735
  metadata: Rt(this.options.metadata)
@@ -755,16 +758,16 @@ class zt {
755
758
  return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
756
759
  }
757
760
  createLocalAttachment(e) {
758
- this.options.productVariant === "customer_embedded" && Vr(e);
759
- const s = N(), n = {
761
+ this.options.productVariant === "customer_embedded" && Jr(e);
762
+ const s = B(), n = {
760
763
  id: s,
761
764
  name: e.name || "attachment",
762
- mimeType: Je(e),
765
+ mimeType: Qe(e),
763
766
  sizeBytes: e.size
764
767
  };
765
768
  this.attachmentFiles.set(s, e);
766
769
  const r = Date.now();
767
- return ys({
770
+ return Ts({
768
771
  attachmentId: s,
769
772
  name: n.name,
770
773
  mimeType: n.mimeType,
@@ -775,7 +778,7 @@ class zt {
775
778
  createdAt: r,
776
779
  lastUsedAt: r
777
780
  }).catch((i) => {
778
- M("web-sdk.attachments", "Failed to store Product Agent attachment", {
781
+ w("web-sdk.attachments", "Failed to store Product Agent attachment", {
779
782
  attachmentId: s,
780
783
  name: n.name,
781
784
  message: i instanceof Error ? i.message : String(i)
@@ -793,7 +796,7 @@ class zt {
793
796
  file: e,
794
797
  attachment: s
795
798
  }) {
796
- const n = this.state.sessionId, r = Je(e), i = {
799
+ const n = this.state.sessionId, r = Qe(e), i = {
797
800
  sessionId: n ?? void 0,
798
801
  attachmentId: s.id,
799
802
  clientId: this.options.clientId,
@@ -808,36 +811,36 @@ class zt {
808
811
  };
809
812
  let o;
810
813
  if (this.options.persistAttachmentUpload)
811
- o = await fe(
814
+ o = await ye(
812
815
  () => this.options.persistAttachmentUpload(i, e),
813
816
  "Failed to upload attachment"
814
817
  );
815
818
  else {
816
- const l = this.options.prepareAttachmentUpload ? await fe(
819
+ const l = this.options.prepareAttachmentUpload ? await ye(
817
820
  () => this.options.prepareAttachmentUpload(i),
818
821
  "Failed to prepare attachment upload"
819
822
  ) : await this.prepareEmbedAttachmentUpload(i);
820
- await fe(async () => {
821
- const u = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
823
+ await ye(async () => {
824
+ const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
822
825
  method: l.uploadMethod,
823
826
  headers: l.uploadHeaders,
824
827
  body: e
825
828
  });
826
- if (!u.ok)
827
- throw new Te("Failed to upload attachment", u.status);
828
- return u;
829
+ if (!c.ok)
830
+ throw new we("Failed to upload attachment", c.status);
831
+ return c;
829
832
  }, "Failed to upload attachment"), o = l;
830
833
  }
831
834
  this.setState({ sessionId: o.sessionId });
832
- const a = is(o.attachment, this.options.backendUrl);
833
- return this.updateAttachmentInState(s.id, a), s.id && Is(s.id, {
835
+ const a = as(o.attachment, this.options.backendUrl);
836
+ return this.updateAttachmentInState(s.id, a), s.id && Ss(s.id, {
834
837
  sessionId: o.sessionId,
835
838
  fileUrl: a.fileUrl,
836
839
  sandboxPath: a.sandboxPath,
837
840
  storageKey: a.storageKey,
838
841
  lastUsedAt: Date.now()
839
842
  }).catch((l) => {
840
- M("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
843
+ w("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
841
844
  attachmentId: s.id,
842
845
  name: a.name,
843
846
  message: l instanceof Error ? l.message : String(l)
@@ -857,18 +860,18 @@ class zt {
857
860
  }
858
861
  async prepareEmbedAttachmentUpload(e) {
859
862
  let s = !1;
860
- return await fe(async () => {
863
+ return await ye(async () => {
861
864
  const n = await this.fetchEmbedAttachmentUpload(e);
862
865
  if (n.ok)
863
866
  return await n.json();
864
- if (di(n.status) && this.options.tokenProvider && !s) {
867
+ if (hi(n.status) && this.options.tokenProvider && !s) {
865
868
  s = !0;
866
869
  const r = await this.fetchEmbedAttachmentUpload(e);
867
870
  if (r.ok)
868
871
  return await r.json();
869
- throw new Te("Failed to prepare attachment upload", r.status);
872
+ throw new we("Failed to prepare attachment upload", r.status);
870
873
  }
871
- throw new Te("Failed to prepare attachment upload", n.status);
874
+ throw new we("Failed to prepare attachment upload", n.status);
872
875
  }, "Failed to prepare attachment upload");
873
876
  }
874
877
  async fetchEmbedAttachmentUpload(e) {
@@ -886,7 +889,7 @@ class zt {
886
889
  if (!this.state.sessionId)
887
890
  return;
888
891
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
889
- const e = Pr(
892
+ const e = vr(
890
893
  this.state.messages,
891
894
  this.state.assistantDraftRespondsToUserMessageId,
892
895
  this.state.assistantDraftRunId,
@@ -899,7 +902,7 @@ class zt {
899
902
  stoppedCausalSequence: null,
900
903
  toolCallIds: new Set(
901
904
  this.state.messages.filter(
902
- (s) => He(
905
+ (s) => je(
903
906
  s,
904
907
  e.respondsToUserMessageId,
905
908
  e.runId
@@ -910,7 +913,7 @@ class zt {
910
913
  for (const [s, n] of this.activeBrowserToolCalls)
911
914
  n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
912
915
  Lt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
913
- messages: vt(
916
+ messages: Dt(
914
917
  this.state.messages,
915
918
  e.clientMessageId,
916
919
  e.runId
@@ -926,7 +929,7 @@ class zt {
926
929
  }
927
930
  startNewSession(e = {}) {
928
931
  const s = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
929
- !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.sessionItemsRequestId = null, this.sessionItemsCursor = null, this.hasLoadedOlderSessionItems = !1, this.loadedOlderSessionItemIds.clear(), this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.options.model = void 0), s && this.send({
932
+ !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({
930
933
  type: "session.reset",
931
934
  sessionId: this.state.sessionId ?? void 0,
932
935
  warmupId: n ?? void 0,
@@ -936,8 +939,6 @@ class zt {
936
939
  starterPrompts: [...this.state.starterPrompts],
937
940
  messages: [],
938
941
  isLoadingSession: !1,
939
- isLoadingOlderMessages: !1,
940
- hasOlderMessages: !1,
941
942
  assistantDraft: "",
942
943
  assistantDraftItemId: null,
943
944
  assistantDraftPhase: null,
@@ -951,7 +952,7 @@ class zt {
951
952
  });
952
953
  }
953
954
  listSessions(e = {}) {
954
- const s = N(), n = new Promise((i, o) => {
955
+ const s = B(), n = new Promise((i, o) => {
955
956
  const a = window.setTimeout(() => {
956
957
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
957
958
  }, Mt);
@@ -973,29 +974,27 @@ class zt {
973
974
  setSessionPinned(e, s) {
974
975
  return this.sendSessionMutation(
975
976
  this.pendingSessionPinRequests,
976
- { type: "session.pin", requestId: N(), sessionId: e, pinned: s },
977
+ { type: "session.pin", requestId: B(), sessionId: e, pinned: s },
977
978
  "Session pin did not respond in time"
978
979
  );
979
980
  }
980
981
  renameSession(e, s) {
981
982
  return this.sendSessionMutation(
982
983
  this.pendingSessionRenameRequests,
983
- { type: "session.rename", requestId: N(), sessionId: e, title: s },
984
+ { type: "session.rename", requestId: B(), sessionId: e, title: s },
984
985
  "Session rename did not respond in time"
985
986
  );
986
987
  }
987
988
  loadSession(e) {
988
- const s = N(), n = this.activeComposerWarmupId;
989
+ const s = B(), n = this.activeComposerWarmupId;
989
990
  !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({
990
991
  type: "session.reset",
991
992
  warmupId: n,
992
993
  page: b()
993
- }), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionItemsRequestId = null, this.sessionItemsCursor = null, this.hasLoadedOlderSessionItems = !1, this.loadedOlderSessionItemIds.clear(), this.setState({
994
+ }), 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({
994
995
  sessionId: e,
995
996
  messages: [],
996
997
  isLoadingSession: !0,
997
- isLoadingOlderMessages: !1,
998
- hasOlderMessages: !1,
999
998
  assistantDraft: "",
1000
999
  assistantDraftItemId: null,
1001
1000
  assistantDraftPhase: null,
@@ -1014,19 +1013,6 @@ class zt {
1014
1013
  page: b()
1015
1014
  });
1016
1015
  }
1017
- loadOlderMessages() {
1018
- if (!this.state.sessionId || !this.sessionItemsCursor || this.state.isLoadingSession || this.state.isLoadingOlderMessages)
1019
- return;
1020
- const e = N();
1021
- this.sessionItemsRequestId = e, this.setState({ isLoadingOlderMessages: !0, lastError: null, lastErrorCode: null }), this.send({
1022
- type: "session.items.list",
1023
- requestId: e,
1024
- sessionId: this.state.sessionId,
1025
- cursor: this.sessionItemsCursor,
1026
- limit: 50,
1027
- page: b()
1028
- });
1029
- }
1030
1016
  canLoadSessionHistoryOverHttp() {
1031
1017
  return !this.options.token && !this.options.tokenProvider ? !1 : this.options.productVariant === "customer_embedded" || !!this.options.runtimeCommunityId;
1032
1018
  }
@@ -1035,7 +1021,7 @@ class zt {
1035
1021
  return;
1036
1022
  let r;
1037
1023
  try {
1038
- r = await this.fetchSessionHistoryPageUntilCurrent(e, null, () => this.sessionLoadRequestId === s && this.state.sessionId === e);
1024
+ r = await this.fetchSessionHistoryPageUntilCurrent(e, "transcript", null, () => this.sessionLoadRequestId === s && this.state.sessionId === e);
1039
1025
  } catch (o) {
1040
1026
  this.failSessionHistoryRequest(s, e, o, !1);
1041
1027
  return;
@@ -1047,16 +1033,17 @@ class zt {
1047
1033
  type: "conversation.state",
1048
1034
  requestId: s,
1049
1035
  session: r.session,
1050
- items: r.items,
1051
- itemsNextCursor: r.nextCursor
1036
+ items: r.items
1052
1037
  });
1053
1038
  for (const o of i)
1054
1039
  this.handleServerEvent(o);
1055
- this.autoLoadRemainingSessionHistory(e);
1040
+ window.setTimeout(() => {
1041
+ this.autoLoadSessionActivity(e);
1042
+ }, 0);
1056
1043
  }
1057
1044
  subscribeToSessionBeforeHistory(e) {
1058
1045
  this.pendingSessionSubscription?.resolve(!1);
1059
- const s = N(), n = new Promise((r) => {
1046
+ const s = B(), n = new Promise((r) => {
1060
1047
  this.pendingSessionSubscription = { requestId: s, sessionId: e, resolve: r };
1061
1048
  });
1062
1049
  return this.send({
@@ -1067,67 +1054,68 @@ class zt {
1067
1054
  subscribeOnly: !0
1068
1055
  }), n;
1069
1056
  }
1070
- async autoLoadRemainingSessionHistory(e) {
1071
- for (; this.state.sessionId === e && this.sessionItemsCursor; ) {
1072
- const s = this.sessionItemsCursor, n = N();
1073
- this.sessionItemsRequestId = n, this.setState({ isLoadingOlderMessages: !0, hasOlderMessages: !0 });
1057
+ async autoLoadSessionActivity(e) {
1058
+ let s = null;
1059
+ do {
1060
+ const n = B();
1061
+ this.sessionActivityRequestId = n;
1074
1062
  let r;
1075
1063
  try {
1076
- r = await this.fetchSessionHistoryPageUntilCurrent(e, s, () => this.state.sessionId === e && this.sessionItemsRequestId === n);
1064
+ r = await this.fetchSessionHistoryPageUntilCurrent(e, "activity", s, () => this.state.sessionId === e && this.sessionActivityRequestId === n);
1077
1065
  } catch (i) {
1078
1066
  this.failSessionHistoryRequest(n, e, i, !0);
1079
1067
  return;
1080
1068
  }
1081
- if (!r || this.state.sessionId !== e || this.sessionItemsRequestId !== n)
1069
+ if (!r || this.state.sessionId !== e || this.sessionActivityRequestId !== n)
1082
1070
  return;
1083
1071
  this.handleServerEvent({
1084
- type: "session.items.page",
1072
+ type: "session.activity.page",
1085
1073
  requestId: n,
1086
1074
  sessionId: e,
1087
1075
  items: r.items,
1088
1076
  nextCursor: r.nextCursor
1089
- });
1090
- }
1077
+ }), s = r.nextCursor;
1078
+ } while (this.state.sessionId === e && s !== null);
1091
1079
  }
1092
- async fetchSessionHistoryPageUntilCurrent(e, s, n) {
1093
- let r = 500;
1094
- for (; n(); )
1080
+ async fetchSessionHistoryPageUntilCurrent(e, s, n, r) {
1081
+ let i = 500;
1082
+ for (; r(); )
1095
1083
  try {
1096
- const i = this.options.token ?? await this.options.tokenProvider?.() ?? this.token;
1097
- if (!i)
1098
- throw new ce("Product Agent history requires authentication");
1099
- this.token = i;
1100
- const o = new URLSearchParams({ limit: "200" });
1101
- s && o.set("cursor", s);
1102
- let a, l;
1103
- this.options.productVariant === "customer_embedded" ? (o.set("client_id", this.options.clientId), o.set("transport_id", this.transportIdentity.transportId), a = `/api/product-agent/embed/sessions/${encodeURIComponent(e)}/history`, l = `Bearer ${i}`) : (o.set("community_id", this.options.runtimeCommunityId ?? ""), this.options.automationRunId && o.set("automation_run_id", this.options.automationRunId), a = `/api/product-agent/runtime/sessions/${encodeURIComponent(e)}/history`, l = i);
1104
- const u = await fetch(new URL(`${a}?${o.toString()}`, this.options.backendUrl), {
1084
+ const o = this.options.token ?? await this.options.tokenProvider?.() ?? this.token;
1085
+ if (!o)
1086
+ throw new pe("Product Agent history requires authentication");
1087
+ this.token = o;
1088
+ const a = new URLSearchParams();
1089
+ s === "activity" && a.set("limit", "200"), n && a.set("cursor", n);
1090
+ let l, c;
1091
+ this.options.productVariant === "customer_embedded" ? (a.set("client_id", this.options.clientId), a.set("transport_id", this.transportIdentity.transportId), l = `/api/product-agent/embed/sessions/${encodeURIComponent(e)}/history${s === "activity" ? "/activity" : ""}`, c = `Bearer ${o}`) : (a.set("community_id", this.options.runtimeCommunityId ?? ""), this.options.automationRunId && a.set("automation_run_id", this.options.automationRunId), l = `/api/product-agent/runtime/sessions/${encodeURIComponent(e)}/history${s === "activity" ? "/activity" : ""}`, c = o);
1092
+ const d = await fetch(new URL(`${l}?${a.toString()}`, this.options.backendUrl), {
1105
1093
  method: "GET",
1106
1094
  cache: "no-store",
1107
- headers: { authorization: l },
1095
+ headers: { authorization: c },
1108
1096
  signal: AbortSignal.timeout(15e3)
1109
1097
  });
1110
- if (!u.ok) {
1111
- const p = await u.text() || `History request failed (${u.status})`;
1112
- throw Gs(u.status) ? new Error(p) : new ce(p);
1098
+ if (!d.ok) {
1099
+ const y = await d.text() || `History request failed (${d.status})`;
1100
+ throw Xs(d.status) ? new Error(y) : new pe(y);
1113
1101
  }
1114
- const d = await u.json();
1115
- if (!d?.session || !Array.isArray(d.items))
1116
- throw new ce("Invalid Product Agent session history response");
1102
+ const h = await d.json();
1103
+ if (!h?.session || !Array.isArray(h.items))
1104
+ throw new pe("Invalid Product Agent session history response");
1117
1105
  return {
1118
- session: d.session,
1119
- items: d.items,
1120
- nextCursor: typeof d.nextCursor == "string" ? d.nextCursor : null
1106
+ session: h.session,
1107
+ items: h.items,
1108
+ nextCursor: typeof h.nextCursor == "string" ? h.nextCursor : null
1121
1109
  };
1122
- } catch (i) {
1123
- if (i instanceof ce)
1124
- throw i;
1125
- M("web-sdk.history", "HTTP session history page failed; retrying", {
1110
+ } catch (o) {
1111
+ if (o instanceof pe)
1112
+ throw o;
1113
+ w("web-sdk.history", "HTTP session history page failed; retrying", {
1126
1114
  sessionId: e,
1127
- hasCursor: !!s,
1128
- retryDelayMs: r,
1129
- message: i instanceof Error ? i.message : String(i)
1130
- }), await new Promise((o) => window.setTimeout(o, r)), r = Math.min(r * 2, 5e3);
1115
+ hasCursor: !!n,
1116
+ retryDelayMs: i,
1117
+ message: o instanceof Error ? o.message : String(o)
1118
+ }), await new Promise((a) => window.setTimeout(a, i)), i = Math.min(i * 2, 5e3);
1131
1119
  }
1132
1120
  return null;
1133
1121
  }
@@ -1135,22 +1123,28 @@ class zt {
1135
1123
  if (this.state.sessionId !== s)
1136
1124
  return;
1137
1125
  const i = n instanceof Error ? n.message : String(n);
1126
+ if (r) {
1127
+ this.sessionActivityRequestId = null, w("web-sdk.history", "Background session activity hydration stopped", {
1128
+ sessionId: s,
1129
+ message: i
1130
+ });
1131
+ return;
1132
+ }
1138
1133
  this.handleServerEvent({
1139
1134
  type: "error",
1140
1135
  code: "history_load_failed",
1141
1136
  message: i,
1142
1137
  requestId: e,
1143
1138
  sessionId: s
1144
- }), M("web-sdk.history", "HTTP session history page failed permanently", {
1139
+ }), w("web-sdk.history", "HTTP session history page failed permanently", {
1145
1140
  sessionId: s,
1146
- olderMessages: r,
1147
1141
  message: i
1148
1142
  });
1149
1143
  }
1150
1144
  send(e) {
1151
1145
  this.sendNow(L(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
1152
1146
  (r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
1153
- ) || this.queuedClientEvents.push(e), G(this.options.clientId, this.queuedClientEvents), this.setState({
1147
+ ) || this.queuedClientEvents.push(e), K(this.options.clientId, this.queuedClientEvents), this.setState({
1154
1148
  status: "reconnecting",
1155
1149
  ...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
1156
1150
  }), this.scheduleReconnect());
@@ -1166,9 +1160,9 @@ class zt {
1166
1160
  return !1;
1167
1161
  const s = this.socket;
1168
1162
  try {
1169
- return s.send(JSON.stringify(e)), Ne("client_event", e.type, gt(e)), !0;
1163
+ return s.send(JSON.stringify(e)), Be("client_event", e.type, gt(e)), !0;
1170
1164
  } catch (n) {
1171
- return M("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
1165
+ return w("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
1172
1166
  message: n instanceof Error ? n.message : String(n),
1173
1167
  queuedClientEventCount: this.queuedClientEvents.length,
1174
1168
  isThinking: this.state.isThinking
@@ -1200,7 +1194,7 @@ class zt {
1200
1194
  }
1201
1195
  }));
1202
1196
  } catch (r) {
1203
- M("web-sdk.agent", "Pluno health signal send failed", {
1197
+ w("web-sdk.agent", "Pluno health signal send failed", {
1204
1198
  name: e,
1205
1199
  message: r instanceof Error ? r.message : String(r)
1206
1200
  });
@@ -1210,7 +1204,7 @@ class zt {
1210
1204
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
1211
1205
  return;
1212
1206
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
1213
- const e = Nn();
1207
+ const e = Bn();
1214
1208
  this.sendNow(
1215
1209
  L({
1216
1210
  type: "starter_prompts.page_context",
@@ -1221,13 +1215,13 @@ class zt {
1221
1215
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
1222
1216
  }
1223
1217
  startStarterPromptUrlWatcher() {
1224
- this.locationChangeCleanup || (this.locationChangeCleanup = xn(() => this.handleStarterPromptUrlChange()));
1218
+ this.locationChangeCleanup || (this.locationChangeCleanup = Wn(() => this.handleStarterPromptUrlChange()));
1225
1219
  }
1226
1220
  handleStarterPromptUrlChange() {
1227
1221
  const e = location.href;
1228
1222
  e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
1229
1223
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
1230
- }, hn));
1224
+ }, gn));
1231
1225
  }
1232
1226
  refreshStarterPromptsForCurrentUrl() {
1233
1227
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -1242,18 +1236,18 @@ class zt {
1242
1236
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
1243
1237
  return;
1244
1238
  const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
1245
- G(this.options.clientId, this.queuedClientEvents);
1239
+ K(this.options.clientId, this.queuedClientEvents);
1246
1240
  for (let s = 0; s < e.length; s += 1) {
1247
1241
  const n = e[s];
1248
1242
  if (!this.sendNow(L(n))) {
1249
- this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), G(this.options.clientId, this.queuedClientEvents);
1243
+ this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), K(this.options.clientId, this.queuedClientEvents);
1250
1244
  return;
1251
1245
  }
1252
- G(this.options.clientId, this.queuedClientEvents);
1246
+ K(this.options.clientId, this.queuedClientEvents);
1253
1247
  }
1254
1248
  }
1255
1249
  resetForAuthenticationScopeChange() {
1256
- this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], G(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear();
1250
+ this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], K(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear();
1257
1251
  }
1258
1252
  flushPendingWidgetLifecycleEvents() {
1259
1253
  if (this.authenticatedSocket !== this.socket || this.socket?.readyState !== WebSocket.OPEN || this.pendingWidgetLifecycleEvents.length === 0)
@@ -1274,8 +1268,8 @@ class zt {
1274
1268
  return;
1275
1269
  this.clearPendingWarmupAckTimer();
1276
1270
  const s = Math.min(
1277
- en * 2 ** e.retryAttempt,
1278
- tn
1271
+ sn * 2 ** e.retryAttempt,
1272
+ nn
1279
1273
  );
1280
1274
  e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
1281
1275
  this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
@@ -1288,26 +1282,26 @@ class zt {
1288
1282
  return [...this.stoppedTurns].reverse().find((o) => o.sessionId !== e ? !1 : r && o.respondsToUserMessageId ? r === o.respondsToUserMessageId : n && o.clientMessageId ? n === o.clientMessageId : !!(i && o.runId && i === o.runId)) ?? null;
1289
1283
  }
1290
1284
  findStoppedTurnForEvent(e) {
1291
- const s = e.type === "session.item" ? P(e.item) : null;
1285
+ const s = e.type === "session.item" ? U(e.item) : null;
1292
1286
  return this.findStoppedTurn(
1293
1287
  oe(e) ?? this.state.sessionId,
1294
1288
  s ?? e
1295
1289
  );
1296
1290
  }
1297
1291
  rememberDurablyStoppedTurn(e, s, n) {
1298
- if (!e || !s || !Ie(s) || this.findStoppedTurn(e, s))
1292
+ if (!e || !s || !Se(s) || this.findStoppedTurn(e, s))
1299
1293
  return;
1300
- const r = x(s), i = _(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
1294
+ const r = N(s), i = C(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
1301
1295
  this.stoppedTurns.push({
1302
1296
  sessionId: e,
1303
1297
  clientMessageId: o,
1304
1298
  respondsToUserMessageId: r,
1305
1299
  runId: i,
1306
1300
  stoppedAt: n,
1307
- stoppedCausalSequence: v(s),
1301
+ stoppedCausalSequence: D(s),
1308
1302
  toolCallIds: new Set(
1309
1303
  this.state.messages.filter(
1310
- (a) => He(a, r, i)
1304
+ (a) => je(a, r, i)
1311
1305
  ).map((a) => a.callId).filter((a) => typeof a == "string")
1312
1306
  )
1313
1307
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
@@ -1317,26 +1311,26 @@ class zt {
1317
1311
  const n = typeof e.callId == "string" ? e.callId : null;
1318
1312
  return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
1319
1313
  }
1320
- return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !Ie(P(e.item)) : e.type !== "conversation.state" : !1;
1314
+ return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !Se(U(e.item)) : e.type !== "conversation.state" : !1;
1321
1315
  }
1322
1316
  filterStoppedSnapshotItems(e, s) {
1323
1317
  return e.filter((n) => {
1324
- const r = P(n), i = r ? this.findStoppedTurn(s, r) : null;
1325
- if (!i || r?.type === "message" && r.role === "user" || Ie(r))
1318
+ const r = U(n), i = r ? this.findStoppedTurn(s, r) : null;
1319
+ if (!i || r?.type === "message" && r.role === "user" || Se(r))
1326
1320
  return !0;
1327
1321
  if (i.stoppedCausalSequence !== null) {
1328
- const o = r ? v(r) : null;
1322
+ const o = r ? D(r) : null;
1329
1323
  return o === null || o <= i.stoppedCausalSequence;
1330
1324
  }
1331
1325
  if (i.stoppedAt) {
1332
- const o = S(n, "createdAt");
1326
+ const o = M(n, "createdAt");
1333
1327
  return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
1334
1328
  }
1335
1329
  return !1;
1336
1330
  });
1337
1331
  }
1338
1332
  handleServerEvent(e) {
1339
- if (Ne("server_event", e.type, gt(e)), e.type === "session.subscribed") {
1333
+ if (Be("server_event", e.type, gt(e)), e.type === "session.subscribed") {
1340
1334
  const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
1341
1335
  if (s && n && s === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
1342
1336
  const r = this.pendingSessionSubscription;
@@ -1354,9 +1348,9 @@ class zt {
1354
1348
  return;
1355
1349
  }
1356
1350
  if (e.type === "session.item" && this.rememberDurablyStoppedTurn(
1357
- S(e.item, "sessionId") ?? this.state.sessionId,
1358
- P(e.item),
1359
- S(e.item, "createdAt")
1351
+ M(e.item, "sessionId") ?? this.state.sessionId,
1352
+ U(e.item),
1353
+ M(e.item, "createdAt")
1360
1354
  ), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
1361
1355
  if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
1362
1356
  this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
@@ -1392,22 +1386,22 @@ class zt {
1392
1386
  this.activeResponseRunId = s, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
1393
1387
  return;
1394
1388
  }
1395
- if (yn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
1389
+ if (Tn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
1396
1390
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
1397
- const s = Zn(e.user);
1391
+ const s = tr(e.user);
1398
1392
  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();
1399
- const n = Vn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
1400
- M("web-sdk.agent", "Received auth.ok appearance", {
1393
+ const n = Jn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
1394
+ w("web-sdk.agent", "Received auth.ok appearance", {
1401
1395
  hasAppearance: r,
1402
1396
  rawAppearance: e.appearance,
1403
1397
  normalizedAppearance: n
1404
- }), this.runtimeHelperJavascript = Xn(e.runtimeHelpers)?.javascript ?? null;
1398
+ }), this.runtimeHelperJavascript = Yn(e.runtimeHelpers)?.javascript ?? null;
1405
1399
  const i = bt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
1406
1400
  user: s,
1407
1401
  status: "connected",
1408
1402
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
1409
1403
  };
1410
- (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 && !he() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
1404
+ (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 && !ge() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
1411
1405
  type: "page.upsert",
1412
1406
  sessionId: this.state.sessionId,
1413
1407
  page: b(),
@@ -1423,138 +1417,131 @@ class zt {
1423
1417
  return;
1424
1418
  }
1425
1419
  if (e.type === "conversation.state") {
1426
- const s = Array.isArray(e.items) ? e.items : [], n = S(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null;
1427
- if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && n !== this.state.sessionId)
1420
+ 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();
1421
+ if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && this.sessionLoadRequestId !== null && r === null || this.state.isLoadingSession && n !== this.state.sessionId)
1428
1422
  return;
1429
- this.updatePersonalModelFromSession(e.session), n === this.state.sessionId && (this.clearSessionLoadRequest(), !this.hasLoadedOlderSessionItems && this.sessionItemsRequestId === null && (this.sessionItemsCursor = typeof e.itemsNextCursor == "string" ? e.itemsNextCursor : null));
1423
+ this.updatePersonalModelFromSession(e.session), n === this.state.sessionId && this.clearSessionLoadRequest();
1430
1424
  for (const E of s)
1431
1425
  this.rememberDurablyStoppedTurn(
1432
1426
  n,
1433
- P(E),
1434
- S(E, "createdAt")
1427
+ U(E),
1428
+ M(E, "createdAt")
1435
1429
  );
1436
- const i = Z(s), o = i === null ? null : s[i], a = P(o), l = this.findStoppedTurn(n, {
1437
- clientMessageId: a?.clientMessageId,
1438
- respondsToUserMessageId: S(o, "id"),
1439
- runId: a?.runId
1440
- }), u = this.filterStoppedSnapshotItems(s, n), d = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, p = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, I = e.isRetrying === !0, f = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
1441
- d && p && (this.pendingClientMessageId = p);
1442
- let c = ar(
1430
+ const o = Z(s), a = o === null ? null : s[o], l = U(a), c = this.findStoppedTurn(n, {
1431
+ clientMessageId: l?.clientMessageId,
1432
+ respondsToUserMessageId: M(a, "id"),
1433
+ runId: l?.runId
1434
+ }), 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;
1435
+ h && y && (this.pendingClientMessageId = y);
1436
+ let p = cr(
1443
1437
  e.assistantDraft
1444
1438
  );
1445
- c && this.findStoppedTurn(n, {
1446
- respondsToUserMessageId: c.respondsToUserMessageId,
1447
- runId: c.runId
1448
- }) && (c = void 0);
1449
- const h = c !== void 0;
1450
- this.rememberUserMessageClientMessageIds(u);
1451
- const g = Rr(u);
1452
- if (g) {
1453
- const E = Er(u, g);
1454
- this.retryAttemptsByClientMessageId[g] = Math.max(
1455
- this.retryAttemptsByClientMessageId[g] ?? 0,
1439
+ p && this.findStoppedTurn(n, {
1440
+ respondsToUserMessageId: p.respondsToUserMessageId,
1441
+ runId: p.runId
1442
+ }) && (p = void 0);
1443
+ const g = p !== void 0;
1444
+ this.rememberUserMessageClientMessageIds(d);
1445
+ const m = kr(d);
1446
+ if (m) {
1447
+ const E = Cr(d, m);
1448
+ this.retryAttemptsByClientMessageId[m] = Math.max(
1449
+ this.retryAttemptsByClientMessageId[m] ?? 0,
1456
1450
  E
1457
1451
  );
1458
1452
  }
1459
- const T = u.filter((E) => {
1460
- const O = P(E);
1461
- return Ut(O) ? !1 : !O || !g || !we(O) ? !0 : Ve(u, O) !== g;
1462
- }), k = fr(
1453
+ const k = d.filter((E) => {
1454
+ const q = U(E);
1455
+ return Ut(q) ? !1 : !q || !m || !Ae(q) ? !0 : Je(d, q) !== m;
1456
+ }), S = Yt(
1463
1457
  this.state.messages,
1464
- _t(T, this.options.backendUrl)
1465
- ), m = this.hasLoadedOlderSessionItems ? mr(
1466
- this.state.messages,
1467
- k,
1468
- this.loadedOlderSessionItemIds
1469
- ) : k, w = Pt(m), U = h ? c?.content ?? "" : this.state.assistantDraft, D = h ? c?.itemId ?? null : this.state.assistantDraftItemId, R = h ? c?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, ee = h ? c?.runId ?? null : this.state.assistantDraftRunId, C = u.some(
1470
- (E, O) => Dt(
1471
- P(E),
1472
- U,
1473
- D,
1458
+ _t(k, this.options.backendUrl)
1459
+ ), _ = 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(
1460
+ (E, q) => vt(
1461
+ U(E),
1462
+ v,
1474
1463
  R,
1475
1464
  ee,
1476
- kr(u, O)
1465
+ P,
1466
+ br(d, q)
1477
1467
  )
1478
- ), te = h ? c?.content ?? "" : this.state.assistantDraft, z = !!c?.content && !C, $ = w && (!te || C), K = wr(m), X = $ && K ? "completed" : l ? "stopped" : $ ? "failed" : null;
1479
- if (!w && Ar(this.state.messages, u))
1468
+ ), X = g ? p?.content ?? "" : this.state.assistantDraft, te = !!p?.content && !F, O = _ && (!X || F), ce = Ar(S), z = O && ce ? "completed" : c ? "stopped" : O ? "failed" : null;
1469
+ if (!_ && Er(this.state.messages, d))
1480
1470
  return;
1481
- this.lastUserMessagePageUrl = Mr(u);
1482
- const q = $ || l ? null : Ge(u);
1483
- if (this.latestRecoverableClientMessageId = q, K && this.clearRetryTimers(), this.setState({
1484
- sessionId: S(e.session, "id") ?? this.state.sessionId,
1485
- messages: m,
1471
+ this.lastUserMessagePageUrl = Rr(d);
1472
+ const x = O || c ? null : Xe(d);
1473
+ if (this.latestRecoverableClientMessageId = x, ce && this.clearRetryTimers(), this.setState({
1474
+ sessionId: M(e.session, "id") ?? this.state.sessionId,
1475
+ messages: S,
1486
1476
  isLoadingSession: !1,
1487
- isLoadingOlderMessages: this.sessionItemsRequestId !== null,
1488
- hasOlderMessages: this.sessionItemsCursor !== null,
1489
- ...d ? { pendingMessageStatus: d } : {},
1490
- ...f ? { turnPhase: f } : {},
1491
- isRetrying: I,
1492
- ...X && this.state.taskStatus === "working" ? { taskStatus: X } : {},
1493
- ...C ? {
1477
+ ...h ? { pendingMessageStatus: h } : {},
1478
+ ...u ? { turnPhase: u } : {},
1479
+ isRetrying: f,
1480
+ ...z && this.state.taskStatus === "working" ? { taskStatus: z } : {},
1481
+ ...F ? {
1494
1482
  assistantDraft: "",
1495
1483
  assistantDraftItemId: null,
1496
1484
  assistantDraftPhase: null,
1497
1485
  assistantDraftRespondsToUserMessageId: null,
1498
1486
  assistantDraftRunId: null
1499
- } : h ? {
1500
- assistantDraft: c?.content ?? "",
1501
- assistantDraftItemId: c?.itemId ?? null,
1502
- assistantDraftPhase: c?.phase ?? null,
1503
- assistantDraftRespondsToUserMessageId: c?.respondsToUserMessageId ?? null,
1504
- assistantDraftRunId: c?.runId ?? null
1487
+ } : g ? {
1488
+ assistantDraft: p?.content ?? "",
1489
+ assistantDraftItemId: p?.itemId ?? null,
1490
+ assistantDraftPhase: p?.phase ?? null,
1491
+ assistantDraftRespondsToUserMessageId: p?.respondsToUserMessageId ?? null,
1492
+ assistantDraftRunId: p?.runId ?? null
1505
1493
  } : {},
1506
- ...z ? {
1494
+ ...te ? {
1507
1495
  isThinking: !0,
1508
1496
  turnPhase: "thinking",
1509
1497
  lastError: null
1510
- } : $ ? {
1498
+ } : O ? {
1511
1499
  isThinking: !1,
1512
1500
  status: "connected",
1513
1501
  lastError: null,
1514
1502
  lastErrorCode: null,
1515
1503
  lastErrorSecuritySettingsUrl: null
1516
- } : q ? {
1504
+ } : x ? {
1517
1505
  isThinking: !0,
1518
- turnPhase: f ?? this.state.turnPhase ?? "starting",
1506
+ turnPhase: u ?? this.state.turnPhase ?? "starting",
1519
1507
  lastError: null
1520
1508
  } : {}
1521
- }), $)
1509
+ }), O)
1522
1510
  this.retryableClientMessageId = null, this.clearThinkingWatchdog();
1523
- else if (!l && (z || q)) {
1524
- if (q) {
1525
- this.activeClientMessageId = q;
1526
- const E = Z(u), O = E === null ? null : u[E];
1527
- this.activeResponseUserMessageId = S(O, "id");
1511
+ else if (!c && (te || x)) {
1512
+ if (x) {
1513
+ this.activeClientMessageId = x;
1514
+ const E = Z(d), q = E === null ? null : d[E];
1515
+ this.activeResponseUserMessageId = M(q, "id");
1528
1516
  }
1529
1517
  this.markThinkingProgress();
1530
1518
  }
1531
- if (g) {
1532
- const E = S(e.session, "id") ?? this.state.sessionId;
1533
- E && this.retryAfterInterruptedRun(E, g);
1519
+ if (m) {
1520
+ const E = M(e.session, "id") ?? this.state.sessionId;
1521
+ E && this.retryAfterInterruptedRun(E, m);
1534
1522
  }
1523
+ i && n && window.setTimeout(() => {
1524
+ this.autoLoadSessionActivity(n);
1525
+ }, 0);
1535
1526
  return;
1536
1527
  }
1537
- if (e.type === "session.items.page") {
1528
+ if (e.type === "session.activity.page") {
1538
1529
  const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
1539
- if (!s || s !== this.sessionItemsRequestId || n !== this.state.sessionId)
1530
+ if (!s || n !== this.state.sessionId)
1540
1531
  return;
1541
1532
  const r = _t(
1542
1533
  Array.isArray(e.items) ? e.items : [],
1543
1534
  this.options.backendUrl
1544
- ), i = new Set(r.map((o) => o.id));
1545
- for (const o of i)
1546
- this.loadedOlderSessionItemIds.add(o);
1547
- this.sessionItemsRequestId = null, this.sessionItemsCursor = typeof e.nextCursor == "string" ? e.nextCursor : null, this.hasLoadedOlderSessionItems = !0, this.setState({
1548
- messages: [...r, ...this.state.messages.filter((o) => !i.has(o.id))],
1549
- isLoadingOlderMessages: !1,
1550
- hasOlderMessages: this.sessionItemsCursor !== null
1535
+ );
1536
+ s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
1537
+ messages: yr(this.state.messages, r)
1551
1538
  });
1552
1539
  return;
1553
1540
  }
1554
1541
  if (e.type === "sessions.page") {
1555
1542
  const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
1556
1543
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
1557
- sessions: er(e.sessions),
1544
+ sessions: sr(e.sessions),
1558
1545
  nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
1559
1546
  }));
1560
1547
  return;
@@ -1569,7 +1556,7 @@ class zt {
1569
1556
  }
1570
1557
  if (e.type === "session.updated") {
1571
1558
  this.clearRunAckResyncRetryTimer();
1572
- const s = S(e.session, "id");
1559
+ const s = M(e.session, "id");
1573
1560
  s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
1574
1561
  ...this.pendingComposerWarmup.event,
1575
1562
  sessionId: s
@@ -1580,10 +1567,10 @@ class zt {
1580
1567
  }
1581
1568
  if (e.type === "session.item") {
1582
1569
  this.rememberUserMessageClientMessageIds([e.item]);
1583
- const s = P(e.item);
1584
- if (we(s)) {
1570
+ const s = U(e.item);
1571
+ if (Ae(s)) {
1585
1572
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1586
- const r = S(e.item, "sessionId") ?? this.state.sessionId, i = s ? x(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1573
+ const r = M(e.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1587
1574
  if (r && a) {
1588
1575
  this.retryAfterInterruptedRun(r, a);
1589
1576
  return;
@@ -1597,19 +1584,19 @@ class zt {
1597
1584
  return;
1598
1585
  const n = Jt(e.item, this.options.backendUrl);
1599
1586
  if (n) {
1600
- const r = Ur(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1601
- n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), W(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), br(s) && this.clearRunAckResyncRetryTimer();
1602
- const o = Ke(this.state.messages, n), a = Pt(o), l = Dt(
1587
+ const r = Dr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1588
+ n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), H(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Pr(s) && this.clearRunAckResyncRetryTimer();
1589
+ const o = Ve(this.state.messages, n), a = Pt(o), l = vt(
1603
1590
  s,
1604
1591
  this.state.assistantDraft,
1605
1592
  this.state.assistantDraftItemId,
1606
1593
  this.state.assistantDraftRespondsToUserMessageId,
1607
1594
  this.state.assistantDraftRunId,
1608
- ts(
1595
+ ss(
1609
1596
  o,
1610
- o.findIndex((p) => p.id === n.id)
1597
+ o.findIndex((h) => h.id === n.id)
1611
1598
  )
1612
- ), u = a && (!this.state.assistantDraft || l), d = Se(n) && (u || W(n) && !this.state.isThinking && this.activeClientMessageId === null);
1599
+ ), c = a && (!this.state.assistantDraft || l), d = Me(n) && (c || H(n) && !this.state.isThinking && this.activeClientMessageId === null);
1613
1600
  this.setState({
1614
1601
  messages: o,
1615
1602
  ...l ? {
@@ -1619,7 +1606,7 @@ class zt {
1619
1606
  assistantDraftRespondsToUserMessageId: null,
1620
1607
  assistantDraftRunId: null
1621
1608
  } : {},
1622
- ...u ? {
1609
+ ...c ? {
1623
1610
  isThinking: !1,
1624
1611
  ...r && this.state.taskStatus === "working" ? { taskStatus: r } : {},
1625
1612
  isRetrying: !1
@@ -1630,15 +1617,15 @@ class zt {
1630
1617
  lastErrorCode: null,
1631
1618
  lastErrorSecuritySettingsUrl: null
1632
1619
  } : {}
1633
- }), u && this.clearThinkingWatchdog(), this.emit("message", n);
1620
+ }), c && this.clearThinkingWatchdog(), this.emit("message", n);
1634
1621
  }
1635
1622
  return;
1636
1623
  }
1637
1624
  if (e.type === "chat.assistant_delta") {
1638
1625
  this.clearRunAckResyncRetryTimer();
1639
- const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((p) => p.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, u = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, d = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
1640
- this.activeClientMessageId && (this.activeResponseUserMessageId = u, this.activeResponseRunId = d), this.setState({
1641
- messages: Ke(this.state.messages, {
1626
+ const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((h) => h.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, d = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
1627
+ this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = d), this.setState({
1628
+ messages: Ve(this.state.messages, {
1642
1629
  id: o,
1643
1630
  role: "assistant",
1644
1631
  content: i,
@@ -1646,13 +1633,13 @@ class zt {
1646
1633
  ...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
1647
1634
  dataType: "assistant_draft",
1648
1635
  ...l ? { phase: l } : {},
1649
- ...u ? { respondsToUserMessageId: u } : {},
1636
+ ...c ? { respondsToUserMessageId: c } : {},
1650
1637
  ...d ? { runId: d } : {}
1651
1638
  }),
1652
1639
  assistantDraft: i,
1653
1640
  assistantDraftItemId: n ?? this.state.assistantDraftItemId,
1654
1641
  assistantDraftPhase: l,
1655
- assistantDraftRespondsToUserMessageId: u,
1642
+ assistantDraftRespondsToUserMessageId: c,
1656
1643
  assistantDraftRunId: d,
1657
1644
  isThinking: !0,
1658
1645
  taskStatus: "working",
@@ -1667,21 +1654,21 @@ class zt {
1667
1654
  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;
1668
1655
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
1669
1656
  return;
1670
- 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 = Cs(
1657
+ 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 = _s(
1671
1658
  this.state.messages.filter(
1672
- (u) => u.dataType !== "assistant_draft" || !He(
1673
- u,
1659
+ (c) => c.dataType !== "assistant_draft" || !je(
1660
+ c,
1674
1661
  n,
1675
1662
  r
1676
1663
  )
1677
1664
  ),
1678
1665
  n,
1679
1666
  r,
1680
- Yt
1667
+ Qt
1681
1668
  );
1682
1669
  this.setState({
1683
1670
  sessionId: s,
1684
- messages: cr(
1671
+ messages: pr(
1685
1672
  l,
1686
1673
  typeof e.responseId == "string" ? e.responseId : null,
1687
1674
  n,
@@ -1704,9 +1691,9 @@ class zt {
1704
1691
  if (s)
1705
1692
  this.nonTranscriptToolCallIds.add(s);
1706
1693
  else {
1707
- const n = pr(e);
1694
+ const n = fr(e);
1708
1695
  if (n) {
1709
- const r = dr(
1696
+ const r = hr(
1710
1697
  this.state.messages,
1711
1698
  n
1712
1699
  );
@@ -1745,13 +1732,6 @@ class zt {
1745
1732
  });
1746
1733
  return;
1747
1734
  }
1748
- if (s && s === this.sessionItemsRequestId) {
1749
- this.sessionItemsRequestId = null, this.setState({
1750
- isLoadingOlderMessages: !1,
1751
- lastError: typeof e.message == "string" ? e.message : "Could not load older messages."
1752
- });
1753
- return;
1754
- }
1755
1735
  const n = s ? this.pendingSessionHistoryRequests.get(s) : null;
1756
1736
  if (s && n) {
1757
1737
  window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof e.message == "string" ? e.message : "Pluno error"));
@@ -1774,20 +1754,20 @@ class zt {
1774
1754
  return;
1775
1755
  }
1776
1756
  o && r && i && (this.retryableClientMessageId = i);
1777
- const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Ln(a.message);
1757
+ const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Nn(a.message);
1778
1758
  l && console.error(l);
1779
- const u = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null, p = vt(
1759
+ const c = i ?? this.activeClientMessageId, d = typeof e.runId == "string" ? e.runId : null, h = Dt(
1780
1760
  this.state.messages,
1781
- u,
1761
+ c,
1782
1762
  d
1783
- ), I = Sr(
1784
- p,
1785
- u,
1763
+ ), y = Mr(
1764
+ h,
1765
+ c,
1786
1766
  d
1787
1767
  );
1788
1768
  this.setState({
1789
- status: I ? "connected" : "error",
1790
- messages: p,
1769
+ status: y ? "connected" : "error",
1770
+ messages: h,
1791
1771
  assistantDraft: "",
1792
1772
  assistantDraftItemId: null,
1793
1773
  assistantDraftPhase: null,
@@ -1796,9 +1776,9 @@ class zt {
1796
1776
  isThinking: !1,
1797
1777
  ...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
1798
1778
  isRetrying: !1,
1799
- lastError: I ? null : a.message,
1800
- lastErrorCode: I ? null : typeof e.code == "string" ? e.code : null,
1801
- lastErrorSecuritySettingsUrl: I ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
1779
+ lastError: y ? null : a.message,
1780
+ lastErrorCode: y ? null : typeof e.code == "string" ? e.code : null,
1781
+ lastErrorSecuritySettingsUrl: y ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
1802
1782
  }), this.clearThinkingWatchdog(), this.emit("error", a);
1803
1783
  }
1804
1784
  }
@@ -1808,7 +1788,7 @@ class zt {
1808
1788
  if (this.options.productVariant !== "personal" || !e || typeof e != "object")
1809
1789
  return;
1810
1790
  const s = e.metadata, n = s && typeof s == "object" ? s.model : void 0;
1811
- this.options.model = Hs(n) ? n : "gpt-5.6-terra";
1791
+ this.options.model = js(n) ? n : "gpt-5.6-terra";
1812
1792
  }
1813
1793
  shouldIgnoreBackgroundSessionEvent(e) {
1814
1794
  if (!this.options.keepRunsActiveOnSessionNavigation || !Et(e))
@@ -1823,7 +1803,7 @@ class zt {
1823
1803
  const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
1824
1804
  if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
1825
1805
  return !1;
1826
- if (he())
1806
+ if (ge())
1827
1807
  return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
1828
1808
  if (e.code === "run_still_active") {
1829
1809
  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) {
@@ -1854,7 +1834,7 @@ class zt {
1854
1834
  }, o), !0;
1855
1835
  }
1856
1836
  retryAfterInterruptedRun(e, s) {
1857
- if (he()) {
1837
+ if (ge()) {
1858
1838
  this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
1859
1839
  return;
1860
1840
  }
@@ -1879,10 +1859,10 @@ class zt {
1879
1859
  }
1880
1860
  rememberUserMessageClientMessageIds(e) {
1881
1861
  for (const s of e) {
1882
- const n = S(s, "id"), r = P(s);
1862
+ const n = M(s, "id"), r = U(s);
1883
1863
  n && r?.type === "message" && r.role === "user" && r.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof r.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId), r.clientMessageId === this.pendingClientMessageId && this.promotePendingDelivery(
1884
1864
  r.clientMessageId,
1885
- S(s, "sessionId") ?? this.state.sessionId,
1865
+ M(s, "sessionId") ?? this.state.sessionId,
1886
1866
  n,
1887
1867
  null
1888
1868
  ), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
@@ -1968,7 +1948,7 @@ class zt {
1968
1948
  }), this.markThinkingProgress();
1969
1949
  }
1970
1950
  schedulePendingDeliveryAck(e) {
1971
- this.clearPendingDeliveryTimers(), !he() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
1951
+ this.clearPendingDeliveryTimers(), !ge() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
1972
1952
  this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
1973
1953
  }, St));
1974
1954
  }
@@ -1994,7 +1974,7 @@ class zt {
1994
1974
  ...this.state.isThinking ? {} : { turnPhase: null },
1995
1975
  isRetrying: !1,
1996
1976
  ...this.state.isThinking ? {} : { taskStatus: "failed" },
1997
- lastError: nn,
1977
+ lastError: on,
1998
1978
  lastErrorCode: "message_delivery_failed"
1999
1979
  });
2000
1980
  }
@@ -2009,7 +1989,7 @@ class zt {
2009
1989
  s,
2010
1990
  typeof e.runId == "string" ? e.runId : null
2011
1991
  ), !(!this.state.isThinking || !s) && this.setState({
2012
- messages: vr(
1992
+ messages: Lr(
2013
1993
  this.state.messages,
2014
1994
  s
2015
1995
  )
@@ -2021,7 +2001,7 @@ class zt {
2021
2001
  }, St);
2022
2002
  }
2023
2003
  recoverMissedRunAck(e) {
2024
- !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (M("web-sdk.agent", "Pluno run ack missed; resyncing session", {
2004
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (w("web-sdk.agent", "Pluno run ack missed; resyncing session", {
2025
2005
  sessionId: this.state.sessionId,
2026
2006
  clientMessageId: e
2027
2007
  }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(e));
@@ -2034,7 +2014,7 @@ class zt {
2034
2014
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
2035
2015
  isThinking: !0,
2036
2016
  lastError: null
2037
- }), M("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
2017
+ }), w("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
2038
2018
  sessionId: this.state.sessionId,
2039
2019
  clientMessageId: e
2040
2020
  }), this.state.sessionId ? this.send({
@@ -2056,13 +2036,13 @@ class zt {
2056
2036
  return;
2057
2037
  const e = this.activeClientMessageId;
2058
2038
  if (!e) {
2059
- M("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
2039
+ w("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
2060
2040
  sessionId: this.state.sessionId
2061
2041
  }), this.reportHealthSignal("run_recovery_exhausted", {
2062
2042
  reason: "missing_client_message_id"
2063
2043
  }), this.setState({
2064
2044
  messages: this.state.messages.filter(
2065
- (r) => !F(r)
2045
+ (r) => !V(r)
2066
2046
  ),
2067
2047
  isThinking: !1,
2068
2048
  taskStatus: "failed",
@@ -2073,7 +2053,7 @@ class zt {
2073
2053
  }
2074
2054
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
2075
2055
  if (n >= re) {
2076
- M("web-sdk.agent", "Pluno run recovery retry exhausted", {
2056
+ w("web-sdk.agent", "Pluno run recovery retry exhausted", {
2077
2057
  sessionId: this.state.sessionId,
2078
2058
  clientMessageId: e
2079
2059
  }), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
@@ -2085,7 +2065,7 @@ class zt {
2085
2065
  return;
2086
2066
  }
2087
2067
  if (s < 1) {
2088
- this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1, M("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
2068
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1, w("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
2089
2069
  sessionId: this.state.sessionId,
2090
2070
  clientMessageId: e,
2091
2071
  resyncAttempts: s + 1
@@ -2096,7 +2076,7 @@ class zt {
2096
2076
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
2097
2077
  isThinking: !0,
2098
2078
  lastError: null
2099
- }), M("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
2079
+ }), w("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
2100
2080
  sessionId: this.state.sessionId,
2101
2081
  clientMessageId: e,
2102
2082
  retryAttempts: n + 1
@@ -2124,7 +2104,7 @@ class zt {
2124
2104
  if (!s || !n || !r)
2125
2105
  return;
2126
2106
  const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
2127
- if (!a && !l || !Zr(o)) {
2107
+ if (!a && !l || !ti(o)) {
2128
2108
  this.setToolMessageLoading(n, !1), this.send({
2129
2109
  type: "tool.result",
2130
2110
  sessionId: s,
@@ -2170,14 +2150,14 @@ class zt {
2170
2150
  startedAtUrl: location.href,
2171
2151
  startedAtOrigin: location.origin
2172
2152
  }), this.installSessionBrowserApis();
2173
- let u = null, d;
2174
- u = await this.executeRuntimeHelper(), d = await kt(
2153
+ let c = null, d;
2154
+ c = await this.executeRuntimeHelper(), d = await kt(
2175
2155
  o,
2176
- Pn(e.runtimeContext, this.options.backendUrl)
2177
- ).catch((p) => ({
2156
+ vn(e.runtimeContext, this.options.backendUrl)
2157
+ ).catch((h) => ({
2178
2158
  ok: !1,
2179
2159
  exception: {
2180
- message: p instanceof Error ? p.message : String(p)
2160
+ message: h instanceof Error ? h.message : String(h)
2181
2161
  }
2182
2162
  })), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
2183
2163
  type: "tool.result",
@@ -2186,11 +2166,11 @@ class zt {
2186
2166
  toolName: r,
2187
2167
  summary: o.summary,
2188
2168
  rawInput: L(o),
2189
- rawOutput: L(Jn(d, u))
2169
+ rawOutput: L(Qn(d, c))
2190
2170
  }), Lt(this.options.clientId, this.activeBrowserToolCalls.values()));
2191
2171
  }
2192
2172
  setToolMessageLoading(e, s) {
2193
- const n = hr(
2173
+ const n = gr(
2194
2174
  this.state.messages,
2195
2175
  e,
2196
2176
  s
@@ -2201,17 +2181,17 @@ class zt {
2201
2181
  if (this.pageLifecycleCleanup)
2202
2182
  return;
2203
2183
  const e = () => {
2204
- ns(this.options.clientId, this.activeBrowserToolCalls.values());
2184
+ is(this.options.clientId, this.activeBrowserToolCalls.values());
2205
2185
  };
2206
2186
  window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
2207
2187
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
2208
2188
  };
2209
2189
  }
2210
2190
  installSessionBrowserApis() {
2211
- this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Sn();
2191
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Mn();
2212
2192
  }
2213
2193
  cleanupSessionBrowserApis() {
2214
- this.sessionBrowserApisCleanup && (bn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
2194
+ this.sessionBrowserApisCleanup && (Pn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
2215
2195
  }
2216
2196
  async executeRuntimeHelper() {
2217
2197
  if (!this.runtimeHelperJavascript?.trim())
@@ -2219,15 +2199,15 @@ class zt {
2219
2199
  const e = await kt({
2220
2200
  javascript: this.runtimeHelperJavascript
2221
2201
  });
2222
- return e.ok === !1 ? Yn(e) : null;
2202
+ return e.ok === !1 ? Zn(e) : null;
2223
2203
  }
2224
2204
  enableNetworkCapture() {
2225
- this.networkCaptureCleanup || (this.networkCaptureCleanup = fn((e) => {
2226
- ii(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
2205
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = yn((e) => {
2206
+ ai(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
2227
2207
  }));
2228
2208
  }
2229
2209
  enqueueNetworkEvent(e) {
2230
- this.queuedNetworkEvents.length >= on || (this.queuedNetworkEvents.push(ri(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
2210
+ this.queuedNetworkEvents.length >= ln || (this.queuedNetworkEvents.push(oi(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
2231
2211
  this.networkBatchTimer = null;
2232
2212
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
2233
2213
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -2236,15 +2216,15 @@ class zt {
2236
2216
  page: b(),
2237
2217
  events: s
2238
2218
  });
2239
- }, rn)));
2219
+ }, an)));
2240
2220
  }
2241
2221
  scheduleReconnect() {
2242
2222
  if (this.reconnectTimer !== null || this.state.status === "closed")
2243
2223
  return;
2244
- const e = pn(this.reconnectAttempts);
2224
+ const e = fn(this.reconnectAttempts);
2245
2225
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
2246
2226
  this.reconnectTimer = null, this.connect().catch((s) => {
2247
- M("web-sdk.agent", "Pluno reconnect failed; retrying", {
2227
+ w("web-sdk.agent", "Pluno reconnect failed; retrying", {
2248
2228
  message: s instanceof Error ? s.message : String(s),
2249
2229
  queuedClientEventCount: this.queuedClientEvents.length,
2250
2230
  isThinking: this.state.isThinking
@@ -2256,9 +2236,9 @@ class zt {
2256
2236
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
2257
2237
  const e = this.socket;
2258
2238
  !e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
2259
- this.socket === e && (M("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
2260
- }, Js));
2261
- }, Xs);
2239
+ this.socket === e && (w("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
2240
+ }, Qs));
2241
+ }, Ys);
2262
2242
  }
2263
2243
  stopHeartbeat() {
2264
2244
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -2296,7 +2276,7 @@ class zt {
2296
2276
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
2297
2277
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
2298
2278
  };
2299
- this.state = o, Hr(this.options.clientId, this.state), this.emit("state", this.getState()), Ne("state", this.state.status, {
2279
+ this.state = o, jr(this.options.clientId, this.state), this.emit("state", this.getState()), Be("state", this.state.status, {
2300
2280
  status: this.state.status,
2301
2281
  sessionId: this.state.sessionId,
2302
2282
  messageCount: this.state.messages.length,
@@ -2318,56 +2298,56 @@ class zt {
2318
2298
  this.listeners[e]?.forEach((r) => r(s));
2319
2299
  }
2320
2300
  }
2321
- const Be = /* @__PURE__ */ new WeakMap();
2322
- function fn(t) {
2323
- const e = window.__plunoProductAgentNetworkCapture ?? mn();
2301
+ const He = /* @__PURE__ */ new WeakMap();
2302
+ function yn(t) {
2303
+ const e = window.__plunoProductAgentNetworkCapture ?? In();
2324
2304
  return e.subscribers.add(t), () => {
2325
2305
  e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
2326
2306
  };
2327
2307
  }
2328
- function mn() {
2329
- const t = /* @__PURE__ */ new Set(), e = (I) => {
2308
+ function In() {
2309
+ const t = /* @__PURE__ */ new Set(), e = (y) => {
2330
2310
  t.forEach((f) => {
2331
2311
  try {
2332
- f(I);
2312
+ f(y);
2333
2313
  } catch {
2334
2314
  }
2335
2315
  });
2336
- }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, c) {
2337
- const h = Date.now();
2316
+ }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, u) {
2317
+ const p = Date.now();
2338
2318
  let g;
2339
2319
  try {
2340
- g = s.call(this, f, c);
2341
- } catch (T) {
2342
- throw T;
2320
+ g = s.call(this, f, u);
2321
+ } catch (m) {
2322
+ throw m;
2343
2323
  }
2344
2324
  try {
2345
- const T = f instanceof Request ? f : null, k = ei(f, T), m = as(c?.headers ?? T?.headers);
2346
- if (!J(k, m, c?.body)) {
2347
- const U = {
2348
- requestId: $e("fetch"),
2349
- url: B(k, xe),
2350
- method: (c?.method ?? T?.method ?? "GET").toUpperCase(),
2351
- requestHeaders: m,
2352
- requestBody: Nt(c?.body),
2325
+ const m = f instanceof Request ? f : null, k = si(f, m), T = cs(u?.headers ?? m?.headers);
2326
+ if (!J(k, T, u?.body)) {
2327
+ const _ = {
2328
+ requestId: Fe("fetch"),
2329
+ url: W(k, We),
2330
+ method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
2331
+ requestHeaders: T,
2332
+ requestBody: Nt(u?.body),
2353
2333
  resourceType: "fetch",
2354
- startedAt: new Date(h).toISOString()
2334
+ startedAt: new Date(p).toISOString()
2355
2335
  };
2356
2336
  g.then(
2357
- (D) => {
2358
- ti(D, U, h, e).catch(() => {
2337
+ (v) => {
2338
+ ni(v, _, p, e).catch(() => {
2359
2339
  e({
2360
- ...U,
2361
- responseStatus: D.status,
2362
- durationMs: Date.now() - h
2340
+ ..._,
2341
+ responseStatus: v.status,
2342
+ durationMs: Date.now() - p
2363
2343
  });
2364
2344
  });
2365
2345
  },
2366
- (D) => {
2346
+ (v) => {
2367
2347
  e({
2368
- ...U,
2369
- errorText: B(D instanceof Error ? D.message : String(D)),
2370
- durationMs: Date.now() - h
2348
+ ..._,
2349
+ errorText: W(v instanceof Error ? v.message : String(v)),
2350
+ durationMs: Date.now() - p
2371
2351
  });
2372
2352
  }
2373
2353
  );
@@ -2375,42 +2355,42 @@ function mn() {
2375
2355
  } catch {
2376
2356
  }
2377
2357
  return g;
2378
- }, a = function(f, c, h, g, T) {
2379
- const k = n.call(this, f, c, h ?? !0, g ?? void 0, T ?? void 0), m = typeof c == "string" ? c : c.toString();
2380
- return Be.set(this, {
2381
- requestId: $e("xhr"),
2358
+ }, a = function(f, u, p, g, m) {
2359
+ const k = n.call(this, f, u, p ?? !0, g ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
2360
+ return He.set(this, {
2361
+ requestId: Fe("xhr"),
2382
2362
  method: String(f ?? "GET").toUpperCase(),
2383
- url: B(m, xe),
2363
+ url: W(T, We),
2384
2364
  requestHeaders: {},
2385
2365
  startedAtMs: Date.now(),
2386
2366
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
2387
- excluded: J(m)
2367
+ excluded: J(T)
2388
2368
  }), k;
2389
- }, l = function(f, c) {
2390
- const h = r.call(this, f, c), g = Be.get(this);
2391
- return g && Object.keys(g.requestHeaders).length < tt && (g.requestHeaders[f] = rt(f, c), g.excluded = g.excluded || J(g.url, g.requestHeaders)), h;
2392
- }, u = function(f) {
2369
+ }, l = function(f, u) {
2370
+ const p = r.call(this, f, u), g = He.get(this);
2371
+ return g && Object.keys(g.requestHeaders).length < nt && (g.requestHeaders[f] = ot(f, u), g.excluded = g.excluded || J(g.url, g.requestHeaders)), p;
2372
+ }, c = function(f) {
2393
2373
  try {
2394
- const c = Be.get(this);
2395
- c && (c.excluded = c.excluded || J(c.url, c.requestHeaders, f), c.requestBody = Nt(f), c.excluded || this.addEventListener(
2374
+ const u = He.get(this);
2375
+ u && (u.excluded = u.excluded || J(u.url, u.requestHeaders, f), u.requestBody = Nt(f), u.excluded || this.addEventListener(
2396
2376
  "loadend",
2397
2377
  () => {
2398
2378
  queueMicrotask(() => {
2399
2379
  try {
2400
- const h = ai(this.getAllResponseHeaders());
2380
+ const p = ci(this.getAllResponseHeaders());
2401
2381
  e({
2402
- requestId: c.requestId,
2403
- url: c.url,
2404
- method: c.method,
2405
- requestHeaders: c.requestHeaders,
2406
- requestBody: c.requestBody,
2382
+ requestId: u.requestId,
2383
+ url: u.url,
2384
+ method: u.method,
2385
+ requestHeaders: u.requestHeaders,
2386
+ requestBody: u.requestBody,
2407
2387
  resourceType: "xhr",
2408
2388
  responseStatus: this.status,
2409
- responseHeaders: h,
2410
- responseBody: ni(this, h),
2389
+ responseHeaders: p,
2390
+ responseBody: ii(this, p),
2411
2391
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
2412
- startedAt: c.startedAt,
2413
- durationMs: Date.now() - c.startedAtMs
2392
+ startedAt: u.startedAt,
2393
+ durationMs: Date.now() - u.startedAtMs
2414
2394
  });
2415
2395
  } catch {
2416
2396
  return;
@@ -2436,25 +2416,25 @@ function mn() {
2436
2416
  } catch {
2437
2417
  }
2438
2418
  try {
2439
- XMLHttpRequest.prototype.send = u;
2419
+ XMLHttpRequest.prototype.send = c;
2440
2420
  } catch {
2441
2421
  }
2442
2422
  let d = null;
2443
2423
  if (typeof PerformanceObserver < "u") {
2444
- d = new PerformanceObserver((I) => {
2445
- for (const f of I.getEntries()) {
2446
- const c = f;
2447
- if (c.initiatorType === "fetch" || c.initiatorType === "xmlhttprequest" || J(c.name))
2424
+ d = new PerformanceObserver((y) => {
2425
+ for (const f of y.getEntries()) {
2426
+ const u = f;
2427
+ if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || J(u.name))
2448
2428
  continue;
2449
- const h = performance.timeOrigin + c.startTime;
2429
+ const p = performance.timeOrigin + u.startTime;
2450
2430
  e({
2451
- requestId: $e("resource"),
2452
- url: B(c.name, xe),
2431
+ requestId: Fe("resource"),
2432
+ url: W(u.name, We),
2453
2433
  method: "GET",
2454
2434
  resourceType: "resource",
2455
- responseStatus: c.responseStatus,
2456
- startedAt: new Date(h).toISOString(),
2457
- durationMs: c.duration
2435
+ responseStatus: u.responseStatus,
2436
+ startedAt: new Date(p).toISOString(),
2437
+ durationMs: u.duration
2458
2438
  });
2459
2439
  }
2460
2440
  });
@@ -2464,7 +2444,7 @@ function mn() {
2464
2444
  d.disconnect(), d = null;
2465
2445
  }
2466
2446
  }
2467
- const p = {
2447
+ const h = {
2468
2448
  subscribers: t,
2469
2449
  destroy: () => {
2470
2450
  d?.disconnect();
@@ -2481,14 +2461,14 @@ function mn() {
2481
2461
  } catch {
2482
2462
  }
2483
2463
  try {
2484
- XMLHttpRequest.prototype.send === u && (XMLHttpRequest.prototype.send = i);
2464
+ XMLHttpRequest.prototype.send === c && (XMLHttpRequest.prototype.send = i);
2485
2465
  } catch {
2486
2466
  }
2487
2467
  }
2488
2468
  };
2489
- return window.__plunoProductAgentNetworkCapture = p, p;
2469
+ return window.__plunoProductAgentNetworkCapture = h, h;
2490
2470
  }
2491
- function M(t, e, s) {
2471
+ function w(t, e, s) {
2492
2472
  if (typeof window > "u")
2493
2473
  return;
2494
2474
  const n = window, r = {
@@ -2503,7 +2483,7 @@ function Rt(t) {
2503
2483
  const e = typeof t == "function" ? t() : t;
2504
2484
  return e && Object.keys(e).length > 0 ? e : void 0;
2505
2485
  }
2506
- function yn(t) {
2486
+ function Tn(t) {
2507
2487
  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";
2508
2488
  }
2509
2489
  function Et(t) {
@@ -2524,27 +2504,27 @@ function oe(t) {
2524
2504
  }
2525
2505
  return null;
2526
2506
  }
2527
- const In = 5e3, Tn = 12e4;
2528
- function Sn() {
2507
+ const Sn = 5e3, wn = 12e4;
2508
+ function Mn() {
2529
2509
  const t = [
2530
- Mn(),
2531
- wn()
2510
+ Rn(),
2511
+ An()
2532
2512
  ].filter((e) => typeof e == "function");
2533
2513
  return () => {
2534
2514
  for (const e of t.reverse())
2535
2515
  e();
2536
2516
  };
2537
2517
  }
2538
- function wn() {
2539
- return Bt(globalThis, "getPageSnapshot", async () => st());
2518
+ function An() {
2519
+ return Bt(globalThis, "getPageSnapshot", async () => rt());
2540
2520
  }
2541
- function Mn() {
2521
+ function Rn() {
2542
2522
  return Bt(globalThis, "pageImages", {
2543
- inspectImage: async (e, s) => await An(e, s)
2523
+ inspectImage: async (e, s) => await En(e, s)
2544
2524
  });
2545
2525
  }
2546
- async function An(t, e = {}) {
2547
- const s = Cn(e.name), n = await Rn(t);
2526
+ async function En(t, e = {}) {
2527
+ const s = _n(e.name), n = await kn(t);
2548
2528
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
2549
2529
  type: "pluno.pageImages.inspectImage",
2550
2530
  imageAttached: !1,
@@ -2562,15 +2542,15 @@ async function An(t, e = {}) {
2562
2542
  imageAttachmentError: n.error
2563
2543
  };
2564
2544
  }
2565
- async function Rn(t) {
2545
+ async function kn(t) {
2566
2546
  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: jt } : {
2567
2547
  ok: !0,
2568
2548
  mimeType: t.type,
2569
2549
  sizeBytes: t.size,
2570
- dataUrl: await _n(t)
2571
- } : { 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." } : En(t);
2550
+ dataUrl: await Un(t)
2551
+ } : { 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." } : Cn(t);
2572
2552
  }
2573
- function En(t) {
2553
+ function Cn(t) {
2574
2554
  if (!t.startsWith("data:") || !t.includes(","))
2575
2555
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
2576
2556
  const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -2581,7 +2561,7 @@ function En(t) {
2581
2561
  const i = s.replace(/[ \t\r\n\f]+/g, "");
2582
2562
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
2583
2563
  return { ok: !1, error: "Page image data URL has invalid base64." };
2584
- const o = kn(i);
2564
+ const o = bn(i);
2585
2565
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
2586
2566
  ok: !0,
2587
2567
  mimeType: r,
@@ -2589,22 +2569,22 @@ function En(t) {
2589
2569
  dataUrl: `data:${r};base64,${i}`
2590
2570
  };
2591
2571
  }
2592
- function kn(t) {
2572
+ function bn(t) {
2593
2573
  if (t.length === 0 || t.length % 4 !== 0)
2594
2574
  return null;
2595
2575
  const e = t.length - t.replace(/=+$/, "").length;
2596
2576
  return e > 2 ? null : t.length / 4 * 3 - e;
2597
2577
  }
2598
- function Cn(t) {
2578
+ function _n(t) {
2599
2579
  return (typeof t == "string" ? t.trim() : "") || "Page image";
2600
2580
  }
2601
- function bn(t) {
2581
+ function Pn(t) {
2602
2582
  try {
2603
2583
  t();
2604
2584
  } catch {
2605
2585
  }
2606
2586
  }
2607
- function _n(t) {
2587
+ function Un(t) {
2608
2588
  return new Promise((e, s) => {
2609
2589
  const n = new FileReader();
2610
2590
  n.onload = () => {
@@ -2618,25 +2598,25 @@ function _n(t) {
2618
2598
  }
2619
2599
  async function kt(t, e) {
2620
2600
  const s = Object.getPrototypeOf(async function() {
2621
- }).constructor, n = t.timeoutMs ?? In, r = Date.now(), i = [];
2601
+ }).constructor, n = t.timeoutMs ?? Sn, r = Date.now(), i = [];
2622
2602
  let o;
2623
2603
  const a = {
2624
2604
  log: console.log,
2625
2605
  info: console.info,
2626
2606
  warn: console.warn,
2627
2607
  error: console.error
2628
- }, l = (u) => (...d) => {
2629
- i.push({ level: u, args: d }), a[u](...d);
2608
+ }, l = (c) => (...d) => {
2609
+ i.push({ level: c, args: d }), a[c](...d);
2630
2610
  };
2631
2611
  console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error");
2632
2612
  try {
2633
- const u = /* @__PURE__ */ Symbol("execute_code_timeout"), d = await Promise.race([
2613
+ const c = /* @__PURE__ */ Symbol("execute_code_timeout"), d = await Promise.race([
2634
2614
  new s("sandboxFiles", t.javascript)(e?.value),
2635
- new Promise((p) => {
2636
- o = window.setTimeout(() => p(u), n);
2615
+ new Promise((h) => {
2616
+ o = window.setTimeout(() => h(c), n);
2637
2617
  })
2638
2618
  ]);
2639
- return d === u ? Un(n) : {
2619
+ return d === c ? Dn(n) : {
2640
2620
  ok: !0,
2641
2621
  result: d,
2642
2622
  console: i,
@@ -2646,14 +2626,14 @@ async function kt(t, e) {
2646
2626
  origin: location.origin
2647
2627
  }
2648
2628
  };
2649
- } catch (u) {
2629
+ } catch (c) {
2650
2630
  return {
2651
2631
  ok: !1,
2652
2632
  console: i,
2653
2633
  exception: {
2654
- name: u instanceof Error ? u.name : "Error",
2655
- message: u instanceof Error ? u.message : String(u),
2656
- stack: u instanceof Error ? u.stack : void 0
2634
+ name: c instanceof Error ? c.name : "Error",
2635
+ message: c instanceof Error ? c.message : String(c),
2636
+ stack: c instanceof Error ? c.stack : void 0
2657
2637
  },
2658
2638
  metadata: {
2659
2639
  durationMs: Date.now() - r,
@@ -2665,7 +2645,7 @@ async function kt(t, e) {
2665
2645
  e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
2666
2646
  }
2667
2647
  }
2668
- function Pn(t, e) {
2648
+ function vn(t, e) {
2669
2649
  if (!t || typeof t != "object")
2670
2650
  return;
2671
2651
  const s = t.sandboxFilesToken;
@@ -2675,13 +2655,13 @@ function Pn(t, e) {
2675
2655
  const r = () => {
2676
2656
  if (!n)
2677
2657
  throw new Error("sandboxFiles is only available during browser-code execution");
2678
- }, i = async (a, l) => await $s(`${e.replace(/\/$/, "")}${a}`, l);
2658
+ }, i = async (a, l) => await Fs(`${e.replace(/\/$/, "")}${a}`, l);
2679
2659
  return {
2680
2660
  value: Object.freeze({
2681
2661
  upload: async (a) => {
2682
2662
  if (r(), !(a instanceof Blob))
2683
2663
  throw new TypeError("sandboxFiles.upload expects a File or Blob");
2684
- const l = a instanceof File && a.name ? a.name : "file", u = `?name=${encodeURIComponent(l)}&size_bytes=${a.size}`, d = await i(`/api/product-agent/attachments/sandbox-files${u}`, {
2664
+ const l = a instanceof File && a.name ? a.name : "file", c = `?name=${encodeURIComponent(l)}&size_bytes=${a.size}`, d = await i(`/api/product-agent/attachments/sandbox-files${c}`, {
2685
2665
  method: "PUT",
2686
2666
  headers: { Authorization: `Bearer ${s}` },
2687
2667
  body: a
@@ -2698,9 +2678,9 @@ function Pn(t, e) {
2698
2678
  );
2699
2679
  if (!l.ok)
2700
2680
  throw new Error(`sandboxFiles.download failed (${l.status})`);
2701
- const u = await l.blob(), p = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
2702
- return new File([u], p || a.split("/").pop() || "file", {
2703
- type: u.type
2681
+ const c = await l.blob(), h = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
2682
+ return new File([c], h || a.split("/").pop() || "file", {
2683
+ type: c.type
2704
2684
  });
2705
2685
  }
2706
2686
  }),
@@ -2709,7 +2689,7 @@ function Pn(t, e) {
2709
2689
  }
2710
2690
  };
2711
2691
  }
2712
- function Un(t) {
2692
+ function Dn(t) {
2713
2693
  return {
2714
2694
  ok: !1,
2715
2695
  exception: {
@@ -2723,10 +2703,10 @@ function Un(t) {
2723
2703
  }
2724
2704
  };
2725
2705
  }
2726
- function Dn(t) {
2706
+ function qn(t) {
2727
2707
  return t.replace(/\/+$/, "");
2728
2708
  }
2729
- function vn(t) {
2709
+ function Ln(t) {
2730
2710
  const e = {
2731
2711
  sidepanel: "extension_sidepanel",
2732
2712
  browser_extension_page_ui: "extension_widget",
@@ -2741,10 +2721,10 @@ function vn(t) {
2741
2721
  function On(t) {
2742
2722
  return t === "pluno" ? "scheduled_continuation" : t ?? "user";
2743
2723
  }
2744
- function Ln(t, e = location.origin) {
2724
+ function Nn(t, e = location.origin) {
2745
2725
  return /origin (?:is not allowed|does not match browser origin)/i.test(t) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
2746
2726
  }
2747
- function qn(t) {
2727
+ function xn(t) {
2748
2728
  const e = new URL("/api/product-agent/embed/ws", t);
2749
2729
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
2750
2730
  }
@@ -2757,21 +2737,21 @@ function b() {
2757
2737
  ...t ? { plunoProductAgentUi: t } : {}
2758
2738
  };
2759
2739
  }
2760
- function Nn() {
2740
+ function Bn() {
2761
2741
  return {
2762
2742
  pageUrl: location.href,
2763
2743
  pageTitle: document.title,
2764
- htmlContent: st()
2744
+ htmlContent: rt()
2765
2745
  };
2766
2746
  }
2767
- function xn(t) {
2768
- return ye.add(t), de || (de = Bn()), () => {
2769
- ye.delete(t), ye.size === 0 && (de?.(), de = null);
2747
+ function Wn(t) {
2748
+ return Te.add(t), he || (he = Hn()), () => {
2749
+ Te.delete(t), Te.size === 0 && (he?.(), he = null);
2770
2750
  };
2771
2751
  }
2772
- function Bn() {
2752
+ function Hn() {
2773
2753
  const t = () => {
2774
- for (const i of Array.from(ye))
2754
+ for (const i of Array.from(Te))
2775
2755
  i();
2776
2756
  }, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
2777
2757
  const o = e(...i);
@@ -2784,33 +2764,33 @@ function Bn() {
2784
2764
  window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
2785
2765
  };
2786
2766
  }
2787
- function he() {
2767
+ function ge() {
2788
2768
  return Xt()?.surface === "browser_extension_sdk_preview";
2789
2769
  }
2790
- function st() {
2770
+ function rt() {
2791
2771
  if (!document.body)
2792
2772
  return "";
2793
- const t = [], e = [], s = (h, g) => {
2794
- const T = Q(g);
2795
- !T || e.includes(T) || (t.push([h, T]), e.push(T));
2773
+ const t = [], e = [], s = (p, g) => {
2774
+ const m = Q(g);
2775
+ !m || e.includes(m) || (t.push([p, m]), e.push(m));
2796
2776
  };
2797
2777
  s("Selected text", window.getSelection()?.toString() ?? "");
2798
2778
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
2799
- (h) => Kt(h) && !h.parentElement?.closest(n)
2779
+ (p) => Kt(p) && !p.parentElement?.closest(n)
2800
2780
  );
2801
- for (const h of r.slice(0, 3))
2802
- s("Active overlay", We(ae(h), e));
2803
- const i = Wn(), o = i ? We(ae(i), e) : "";
2804
- s("Main page content", o), s("Additional visible page text", We(ae(document.body), e));
2805
- const a = t.map(([h, g]) => `${h}:
2781
+ for (const p of r.slice(0, 3))
2782
+ s("Active overlay", $e(ae(p), e));
2783
+ const i = $n(), o = i ? $e(ae(i), e) : "";
2784
+ s("Main page content", o), s("Additional visible page text", $e(ae(document.body), e));
2785
+ const a = t.map(([p, g]) => `${p}:
2806
2786
  ${g}`).join(`
2807
2787
 
2808
- `).trim().slice(0, 12e3), l = Hn(r, i).trim(), u = `Simplified DOM outline:
2788
+ `).trim().slice(0, 12e3), l = jn(r, i).trim(), c = `Simplified DOM outline:
2809
2789
  `, d = `
2810
2790
 
2811
2791
  Visible page text:
2812
- `, p = 12e3 - u.length - d.length, I = Math.min(a.length, 7900), f = l.slice(0, p - I), c = a.slice(0, p - f.length);
2813
- return `${u}${f}${d}${c}`;
2792
+ `, h = 12e3 - c.length - d.length, y = Math.min(a.length, 7900), f = l.slice(0, h - y), u = a.slice(0, h - f.length);
2793
+ return `${c}${f}${d}${u}`;
2814
2794
  }
2815
2795
  function ae(t) {
2816
2796
  return t.innerText ?? t.textContent ?? "";
@@ -2823,7 +2803,7 @@ function Q(t) {
2823
2803
 
2824
2804
  `).trim();
2825
2805
  }
2826
- function We(t, e) {
2806
+ function $e(t, e) {
2827
2807
  let s = Q(t);
2828
2808
  for (const n of e)
2829
2809
  s = s.replace(n, "");
@@ -2833,10 +2813,10 @@ function Kt(t) {
2833
2813
  const e = window.getComputedStyle(t);
2834
2814
  return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
2835
2815
  }
2836
- function Wn() {
2816
+ function $n() {
2837
2817
  return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Kt).sort((t, e) => ae(e).length - ae(t).length)[0] ?? null;
2838
2818
  }
2839
- function Hn(t, e) {
2819
+ function jn(t, e) {
2840
2820
  const s = /* @__PURE__ */ new Set([
2841
2821
  "main",
2842
2822
  "nav",
@@ -2916,84 +2896,84 @@ function Hn(t, e) {
2916
2896
  "data-test",
2917
2897
  "data-qa",
2918
2898
  "data-cy"
2919
- ], u = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = $n(), I = new Set(t);
2920
- e && I.add(e);
2899
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: h } = Fn(), y = new Set(t);
2900
+ e && y.add(e);
2921
2901
  let f = 0;
2922
- const c = (m) => {
2923
- const w = m.getAttribute("role");
2924
- return w && !o.has(w) ? w : "";
2925
- }, h = (m) => {
2926
- const w = m.getAttribute("data-testid") || m.getAttribute("data-test") || m.getAttribute("data-qa") || m.getAttribute("data-cy") || "";
2927
- return `${m.tagName.toLowerCase()}|${c(m)}|${w}`;
2928
- }, g = (m, w, U) => {
2929
- const D = (R, ee) => {
2930
- const C = R.tagName.toLowerCase(), te = window.getComputedStyle(R), z = d.has(R);
2931
- if (f >= 1e3 && !z || U.has(R) || i.has(C) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || te.display === "none" || te.visibility === "hidden")
2902
+ const u = (T) => {
2903
+ const S = T.getAttribute("role");
2904
+ return S && !o.has(S) ? S : "";
2905
+ }, p = (T) => {
2906
+ const S = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
2907
+ return `${T.tagName.toLowerCase()}|${u(T)}|${S}`;
2908
+ }, g = (T, S, _) => {
2909
+ const v = (R, ee) => {
2910
+ const P = R.tagName.toLowerCase(), F = window.getComputedStyle(R), X = d.has(R);
2911
+ if (f >= 1e3 && !X || _.has(R) || i.has(P) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || F.display === "none" || F.visibility === "hidden")
2932
2912
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2933
2913
  f += 1;
2934
- const $ = c(R), K = Vt(R), it = a.has($) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(C) || C === "a" && R.hasAttribute("href"), X = Array.from(R.children).filter((y) => y instanceof HTMLElement), q = /* @__PURE__ */ new Map();
2935
- for (const y of X) {
2936
- const A = h(y);
2937
- q.set(A, (q.get(A) ?? 0) + 1);
2914
+ const te = u(R), O = Vt(R), ce = a.has(te) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(P) || P === "a" && R.hasAttribute("href"), ue = Array.from(R.children).filter((I) => I instanceof HTMLElement), z = /* @__PURE__ */ new Map();
2915
+ for (const I of ue) {
2916
+ const A = p(I);
2917
+ z.set(A, (z.get(A) ?? 0) + 1);
2938
2918
  }
2939
- const E = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map();
2940
- for (const y of X) {
2941
- const A = h(y), j = O.get(A) ?? 0;
2942
- O.set(A, j + 1), (q.get(A) ?? 0) > 8 && j >= 6 && !d.has(y) && E.set(A, (E.get(A) ?? 0) + 1);
2919
+ const x = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
2920
+ for (const I of ue) {
2921
+ const A = p(I), j = E.get(A) ?? 0;
2922
+ E.set(A, j + 1), (z.get(A) ?? 0) > 8 && j >= 6 && !d.has(I) && x.set(A, (x.get(A) ?? 0) + 1);
2943
2923
  }
2944
- const ot = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Set(), be = [], lt = [];
2945
- for (const y of X) {
2946
- const A = h(y), j = q.get(A) ?? 0, dt = ot.get(A) ?? 0;
2947
- if (ot.set(A, dt + 1), j > 8 && dt >= 6 && !d.has(y)) {
2948
- at.has(A) || (be.push([`… ${E.get(A) ?? 0} similar siblings omitted`]), at.add(A));
2924
+ const q = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Set(), Pe = [], lt = [];
2925
+ for (const I of ue) {
2926
+ const A = p(I), j = z.get(A) ?? 0, dt = q.get(A) ?? 0;
2927
+ if (q.set(A, dt + 1), j > 8 && dt >= 6 && !d.has(I)) {
2928
+ at.has(A) || (Pe.push([`… ${x.get(A) ?? 0} similar siblings omitted`]), at.add(A));
2949
2929
  continue;
2950
2930
  }
2951
- const ht = D(y, ee);
2952
- lt.push(ht), be.push(ht.lines);
2931
+ const pt = v(I, ee);
2932
+ lt.push(pt), Pe.push(pt.lines);
2953
2933
  }
2954
- const _e = [];
2934
+ const Ue = [];
2955
2935
  if (R.shadowRoot)
2956
- for (const y of Array.from(R.shadowRoot.children))
2957
- y instanceof HTMLElement && _e.push(D(y, ee + 1));
2958
- const ue = [...lt, ..._e], Pe = K.length > 0 || it || ue.some((y) => y.hasUsefulContent), ut = Q(
2959
- [K, ...ue.map((y) => y.textPreview)].filter(Boolean).join(" ")
2960
- ).slice(0, 180), fs = R.hasAttribute("contenteditable") && (K.length > 0 || !R.querySelector("[contenteditable]")), ct = u.some((y) => R.hasAttribute(y)) || !!$ || fs, Ue = (R.getClientRects().length > 0 || te.display === "contents") && (s.has(C) || ct || z) && (Pe || z) && (!r.has(C) || Pe || ct || z), De = Ue ? 1 : 0, se = [];
2961
- if (Ue) {
2962
- const y = ue.some((j) => j.containsTextElement), A = n.has(C) && !y ? ut : K;
2936
+ for (const I of Array.from(R.shadowRoot.children))
2937
+ I instanceof HTMLElement && Ue.push(v(I, ee + 1));
2938
+ const de = [...lt, ...Ue], ve = O.length > 0 || ce || de.some((I) => I.hasUsefulContent), ct = Q(
2939
+ [O, ...de.map((I) => I.textPreview)].filter(Boolean).join(" ")
2940
+ ).slice(0, 180), ys = R.hasAttribute("contenteditable") && (O.length > 0 || !R.querySelector("[contenteditable]")), ut = c.some((I) => R.hasAttribute(I)) || !!te || ys, De = (R.getClientRects().length > 0 || F.display === "contents") && (s.has(P) || ut || X) && (ve || X) && (!r.has(P) || ve || ut || X), qe = De ? 1 : 0, se = [];
2941
+ if (De) {
2942
+ const I = de.some((j) => j.containsTextElement), A = n.has(P) && !I ? ct : O;
2963
2943
  se.push(Gt(R, l, o, A.slice(0, 180)));
2964
2944
  }
2965
- for (const y of be)
2966
- se.push(...pe(y, De));
2967
- const ve = _e.flatMap((y) => y.lines);
2968
- if (ve.length > 0) {
2969
- const y = ve.slice(0, 20);
2970
- ve.length > y.length && y.push("… shadow DOM omitted");
2971
- const A = C.includes("tooltip") || C.includes("popper") || C.includes("loader");
2945
+ for (const I of Pe)
2946
+ se.push(...fe(I, qe));
2947
+ const Le = Ue.flatMap((I) => I.lines);
2948
+ if (Le.length > 0) {
2949
+ const I = Le.slice(0, 20);
2950
+ Le.length > I.length && I.push("… shadow DOM omitted");
2951
+ const A = P.includes("tooltip") || P.includes("popper") || P.includes("loader");
2972
2952
  if (ee < 2 && !A) {
2973
- const j = Ue ? "#shadow-root" : `${C} #shadow-root`;
2974
- se.push(...pe([j, ...pe(y, 1)], De));
2953
+ const j = De ? "#shadow-root" : `${P} #shadow-root`;
2954
+ se.push(...fe([j, ...fe(I, 1)], qe));
2975
2955
  } else
2976
- se.push(...pe(y, De));
2956
+ se.push(...fe(I, qe));
2977
2957
  }
2978
2958
  return {
2979
2959
  lines: se,
2980
- hasUsefulContent: Pe,
2981
- textPreview: ut,
2982
- containsTextElement: n.has(C) || ue.some((y) => y.containsTextElement)
2960
+ hasUsefulContent: ve,
2961
+ textPreview: ct,
2962
+ containsTextElement: n.has(P) || de.some((I) => I.containsTextElement)
2983
2963
  };
2984
2964
  };
2985
- return [`--- ${w} ---`, ...D(m, 0).lines].join(`
2965
+ return [`--- ${S} ---`, ...v(T, 0).lines].join(`
2986
2966
  `);
2987
- }, T = [], k = Q(window.getSelection()?.toString() ?? "");
2988
- k && T.push(`--- selected text ---
2989
- ${JSON.stringify(k)}`), p.length > 0 && T.push(jn(p, s, l, o));
2990
- for (const m of t.slice(0, 3))
2991
- T.push(g(m, "active overlay DOM", /* @__PURE__ */ new Set()));
2992
- if (e && T.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2993
- const m = e || t.length ? "other visible DOM" : "visible DOM";
2994
- T.push(g(document.body, m, I));
2995
- }
2996
- return T.join(`
2967
+ }, m = [], k = Q(window.getSelection()?.toString() ?? "");
2968
+ k && m.push(`--- selected text ---
2969
+ ${JSON.stringify(k)}`), h.length > 0 && m.push(zn(h, s, l, o));
2970
+ for (const T of t.slice(0, 3))
2971
+ m.push(g(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2972
+ if (e && m.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2973
+ const T = e || t.length ? "other visible DOM" : "visible DOM";
2974
+ m.push(g(document.body, T, y));
2975
+ }
2976
+ return m.join(`
2997
2977
 
2998
2978
  `);
2999
2979
  }
@@ -3001,7 +2981,7 @@ function Gt(t, e, s, n) {
3001
2981
  const r = t.tagName.toLowerCase();
3002
2982
  let i = r;
3003
2983
  const o = t.getAttribute("id");
3004
- o && Fn(o) && (i += `#${o}`);
2984
+ o && Kn(o) && (i += `#${o}`);
3005
2985
  for (const a of e) {
3006
2986
  const l = t.getAttribute(a);
3007
2987
  l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
@@ -3014,20 +2994,20 @@ function Gt(t, e, s, n) {
3014
2994
  t.hasAttribute(a) && (i += `[${a}]`);
3015
2995
  return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
3016
2996
  }
3017
- function $n() {
2997
+ function Fn() {
3018
2998
  const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), s = (a, l) => {
3019
2999
  if (!a)
3020
3000
  return;
3021
- const u = window.getComputedStyle(a);
3022
- if (u.display === "none" || u.visibility === "hidden")
3001
+ const c = window.getComputedStyle(a);
3002
+ if (c.display === "none" || c.visibility === "hidden")
3023
3003
  return;
3024
3004
  const d = e.get(a) ?? /* @__PURE__ */ new Set();
3025
3005
  d.add(l), e.set(a, d);
3026
- let p = a;
3027
- for (; p; ) {
3028
- t.add(p);
3029
- const I = p.getRootNode();
3030
- p = p.parentElement ?? (I instanceof ShadowRoot && I.host instanceof HTMLElement ? I.host : null);
3006
+ let h = a;
3007
+ for (; h; ) {
3008
+ t.add(h);
3009
+ const y = h.getRootNode();
3010
+ h = h.parentElement ?? (y instanceof ShadowRoot && y.host instanceof HTMLElement ? y.host : null);
3031
3011
  }
3032
3012
  };
3033
3013
  let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
@@ -3046,18 +3026,18 @@ function $n() {
3046
3026
  ], o = [document];
3047
3027
  for (let a = 0; a < o.length; a += 1) {
3048
3028
  const l = o[a];
3049
- for (const [u, d] of i)
3050
- for (const p of Array.from(l.querySelectorAll(u)))
3051
- s(p, d);
3052
- for (const u of Array.from(l.querySelectorAll("*")))
3053
- u.shadowRoot && o.push(u.shadowRoot);
3029
+ for (const [c, d] of i)
3030
+ for (const h of Array.from(l.querySelectorAll(c)))
3031
+ s(h, d);
3032
+ for (const c of Array.from(l.querySelectorAll("*")))
3033
+ c.shadowRoot && o.push(c.shadowRoot);
3054
3034
  }
3055
3035
  return {
3056
3036
  priorityElements: t,
3057
3037
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
3058
3038
  };
3059
3039
  }
3060
- function jn(t, e, s, n) {
3040
+ function zn(t, e, s, n) {
3061
3041
  const r = ["--- active/current elements ---"];
3062
3042
  for (const i of t) {
3063
3043
  const o = [];
@@ -3065,16 +3045,16 @@ function jn(t, e, s, n) {
3065
3045
  for (; a; ) {
3066
3046
  const d = a.tagName.toLowerCase();
3067
3047
  (a === i.element || e.has(d) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
3068
- const p = a.getRootNode();
3069
- a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
3048
+ const h = a.getRootNode();
3049
+ a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
3070
3050
  }
3071
- const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, u = l.map((d, p) => Gt(
3051
+ const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((d, h) => Gt(
3072
3052
  d,
3073
3053
  s,
3074
3054
  n,
3075
- p === l.length - 1 ? Vt(d).slice(0, 180) : ""
3055
+ h === l.length - 1 ? Vt(d).slice(0, 180) : ""
3076
3056
  ));
3077
- o.length > l.length && u.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${u.join(" > ")}`);
3057
+ o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
3078
3058
  }
3079
3059
  return r.join(`
3080
3060
  `);
@@ -3082,7 +3062,7 @@ function jn(t, e, s, n) {
3082
3062
  function Ct(t) {
3083
3063
  return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
3084
3064
  }
3085
- function pe(t, e) {
3065
+ function fe(t, e) {
3086
3066
  if (e === 0)
3087
3067
  return t;
3088
3068
  const s = " ".repeat(e);
@@ -3093,12 +3073,12 @@ function Vt(t) {
3093
3073
  Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
3094
3074
  );
3095
3075
  }
3096
- function Fn(t) {
3076
+ function Kn(t) {
3097
3077
  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);
3098
3078
  }
3099
3079
  function Xt() {
3100
- const t = document.querySelector(pt);
3101
- if (!(t ?? document.querySelector(Fe)))
3080
+ const t = document.querySelector(ht);
3081
+ if (!(t ?? document.querySelector(Ke)))
3102
3082
  return;
3103
3083
  const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
3104
3084
  return {
@@ -3107,28 +3087,28 @@ function Xt() {
3107
3087
  selectors: [
3108
3088
  {
3109
3089
  name: "widget_host",
3110
- selector: s === "browser_extension_sdk_preview" ? pt : Fe,
3090
+ selector: s === "browser_extension_sdk_preview" ? ht : Ke,
3111
3091
  description: "Finds Pluno's shadow-host element in the host page DOM."
3112
3092
  },
3113
3093
  {
3114
3094
  name: "widget_root",
3115
- selector: js,
3095
+ selector: zs,
3116
3096
  description: "Finds Pluno's widget root inside the widget host shadow root."
3117
3097
  },
3118
3098
  {
3119
3099
  name: "widget_panel",
3120
- selector: Fs,
3100
+ selector: Ks,
3121
3101
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
3122
3102
  },
3123
3103
  {
3124
3104
  name: "widget_timeline",
3125
- selector: zs,
3105
+ selector: Gs,
3126
3106
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
3127
3107
  }
3128
3108
  ]
3129
3109
  };
3130
3110
  }
3131
- function zn(t) {
3111
+ function Gn(t) {
3132
3112
  try {
3133
3113
  const e = JSON.parse(t);
3134
3114
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -3136,7 +3116,7 @@ function zn(t) {
3136
3116
  return { type: "error", message: "Invalid server event" };
3137
3117
  }
3138
3118
  }
3139
- function Kn(t) {
3119
+ function Vn(t) {
3140
3120
  if (typeof t != "string")
3141
3121
  return null;
3142
3122
  try {
@@ -3152,10 +3132,10 @@ function bt(t, e) {
3152
3132
  const s = t[e];
3153
3133
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
3154
3134
  }
3155
- function Gn(t) {
3135
+ function Xn(t) {
3156
3136
  return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
3157
3137
  }
3158
- function Vn(t) {
3138
+ function Jn(t) {
3159
3139
  if (!t || typeof t != "object")
3160
3140
  return null;
3161
3141
  const e = t, s = e.appearance, n = s && typeof s == "object" ? s : e, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
@@ -3166,13 +3146,13 @@ function Vn(t) {
3166
3146
  ...a !== null ? { scribbleStyle: a } : {}
3167
3147
  };
3168
3148
  }
3169
- function Xn(t) {
3149
+ function Yn(t) {
3170
3150
  if (!t || typeof t != "object")
3171
3151
  return null;
3172
3152
  const e = t.javascript;
3173
3153
  return typeof e != "string" || !e.trim() ? null : { javascript: e };
3174
3154
  }
3175
- function Jn(t, e) {
3155
+ function Qn(t, e) {
3176
3156
  return e ? t && typeof t == "object" ? {
3177
3157
  ...t,
3178
3158
  helperError: e
@@ -3182,23 +3162,23 @@ function Jn(t, e) {
3182
3162
  helperError: e
3183
3163
  } : t;
3184
3164
  }
3185
- function Yn(t) {
3165
+ function Zn(t) {
3186
3166
  if (!t || typeof t != "object")
3187
3167
  return t;
3188
3168
  const e = t;
3189
3169
  return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : t;
3190
3170
  }
3191
- function Qn() {
3171
+ function er() {
3192
3172
  const t = "pluno.productAgent.clientId", e = window.localStorage.getItem(t);
3193
3173
  if (e)
3194
3174
  return e;
3195
3175
  const s = crypto.randomUUID();
3196
3176
  return window.localStorage.setItem(t, s), s;
3197
3177
  }
3198
- function N() {
3178
+ function B() {
3199
3179
  return crypto.randomUUID();
3200
3180
  }
3201
- function Zn(t) {
3181
+ function tr(t) {
3202
3182
  if (!t || typeof t != "object")
3203
3183
  return null;
3204
3184
  const e = t, s = typeof e.id == "string" ? e.id : null;
@@ -3210,21 +3190,21 @@ function Zn(t) {
3210
3190
  } : null;
3211
3191
  }
3212
3192
  function _t(t, e) {
3213
- return Array.isArray(t) ? Xe(
3193
+ return Array.isArray(t) ? Ye(
3214
3194
  t.map((s) => Jt(s, e)).filter((s) => s !== null)
3215
3195
  ) : [];
3216
3196
  }
3217
- function er(t) {
3197
+ function sr(t) {
3218
3198
  return Array.isArray(t) ? t.flatMap((e) => {
3219
3199
  if (!e || typeof e != "object")
3220
3200
  return [];
3221
- const s = e, n = S(s, "id"), r = S(s, "createdAt"), i = S(s, "updatedAt"), o = S(s, "lastActiveAt");
3201
+ const s = e, n = M(s, "id"), r = M(s, "createdAt"), i = M(s, "updatedAt"), o = M(s, "lastActiveAt");
3222
3202
  return !n || !r || !i || !o ? [] : [
3223
3203
  {
3224
3204
  id: n,
3225
- title: S(s, "title"),
3226
- customTitle: S(s, "customTitle"),
3227
- firstUserMessage: S(s, "firstUserMessage"),
3205
+ title: M(s, "title"),
3206
+ customTitle: M(s, "customTitle"),
3207
+ firstUserMessage: M(s, "firstUserMessage"),
3228
3208
  currentPage: s.currentPage ?? null,
3229
3209
  createdAt: r,
3230
3210
  updatedAt: i,
@@ -3242,22 +3222,22 @@ function Jt(t, e) {
3242
3222
  if (!n || typeof n != "object")
3243
3223
  return null;
3244
3224
  const r = n;
3245
- if (r.hiddenFromTranscript === !0 || Es(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
3225
+ if (r.hiddenFromTranscript === !0 || Cs(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
3246
3226
  return null;
3247
3227
  if (r.type === "message") {
3248
3228
  const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
3249
3229
  id: String(s.id ?? crypto.randomUUID()),
3250
3230
  role: i,
3251
3231
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
3252
- content: As(
3253
- lr(r.content),
3232
+ content: Es(
3233
+ ur(r.content),
3254
3234
  e
3255
3235
  ),
3256
3236
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3257
- ...v(r) !== null ? { causalSequence: v(r) } : {},
3258
- respondsToUserMessageId: x(r) ?? void 0,
3259
- ..._(r) ? { runId: _(r) } : {},
3260
- attachments: rs(r.attachments, e)
3237
+ ...D(r) !== null ? { causalSequence: D(r) } : {},
3238
+ respondsToUserMessageId: N(r) ?? void 0,
3239
+ ...C(r) ? { runId: C(r) } : {},
3240
+ attachments: os(r.attachments, e)
3261
3241
  };
3262
3242
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
3263
3243
  value: r.id,
@@ -3268,67 +3248,67 @@ function Jt(t, e) {
3268
3248
  }), o;
3269
3249
  }
3270
3250
  if (r.type === "function_call_output") {
3271
- const i = Ns(r.output);
3251
+ const i = Bs(r.output);
3272
3252
  if (i)
3273
3253
  return {
3274
3254
  id: String(s.id ?? crypto.randomUUID()),
3275
3255
  role: "tool",
3276
3256
  content: "",
3277
3257
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3278
- respondsToUserMessageId: x(r) ?? void 0,
3279
- ..._(r) ? { runId: _(r) } : {},
3258
+ respondsToUserMessageId: N(r) ?? void 0,
3259
+ ...C(r) ? { runId: C(r) } : {},
3280
3260
  dataType: "scheduled_check_in",
3281
3261
  toolName: Ht,
3282
- callId: ge(r) ?? void 0,
3262
+ callId: me(r) ?? void 0,
3283
3263
  scheduledCheckInAt: i
3284
3264
  };
3285
- const o = sr(r.output), a = nr(r.output);
3265
+ const o = rr(r.output), a = ir(r.output);
3286
3266
  return o ? {
3287
3267
  id: String(s.id ?? crypto.randomUUID()),
3288
3268
  role: "tool",
3289
3269
  content: `Connect ${o.appName} to continue`,
3290
3270
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3291
- ...v(r) !== null ? { causalSequence: v(r) } : {},
3292
- respondsToUserMessageId: x(r) ?? void 0,
3293
- ..._(r) ? { runId: _(r) } : {},
3271
+ ...D(r) !== null ? { causalSequence: D(r) } : {},
3272
+ respondsToUserMessageId: N(r) ?? void 0,
3273
+ ...C(r) ? { runId: C(r) } : {},
3294
3274
  dataType: "function_call_output",
3295
3275
  toolName: "authenticate_pipedream_app",
3296
- callId: ge(r) ?? void 0,
3276
+ callId: me(r) ?? void 0,
3297
3277
  integrationAuthRequest: o
3298
3278
  } : a ? {
3299
3279
  id: String(s.id ?? crypto.randomUUID()),
3300
3280
  role: "tool",
3301
3281
  content: "Connect WhatsApp to continue",
3302
3282
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3303
- ...v(r) !== null ? { causalSequence: v(r) } : {},
3304
- respondsToUserMessageId: x(r) ?? void 0,
3305
- ..._(r) ? { runId: _(r) } : {},
3283
+ ...D(r) !== null ? { causalSequence: D(r) } : {},
3284
+ respondsToUserMessageId: N(r) ?? void 0,
3285
+ ...C(r) ? { runId: C(r) } : {},
3306
3286
  dataType: "function_call_output",
3307
3287
  toolName: "request_personal_channel_connection",
3308
- callId: ge(r) ?? void 0,
3288
+ callId: me(r) ?? void 0,
3309
3289
  personalChannelConnectionRequest: a
3310
3290
  } : null;
3311
3291
  }
3312
3292
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
3313
3293
  id: String(s.id ?? crypto.randomUUID()),
3314
3294
  role: "tool",
3315
- content: r.type === "mcp_call" ? tr(r) : ir(r),
3295
+ content: r.type === "mcp_call" ? nr(r) : ar(r),
3316
3296
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3317
- ...v(r) !== null ? { causalSequence: v(r) } : {},
3318
- respondsToUserMessageId: x(r) ?? void 0,
3319
- ..._(r) ? { runId: _(r) } : {},
3297
+ ...D(r) !== null ? { causalSequence: D(r) } : {},
3298
+ respondsToUserMessageId: N(r) ?? void 0,
3299
+ ...C(r) ? { runId: C(r) } : {},
3320
3300
  dataType: String(r.type),
3321
3301
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
3322
- callId: ge(r) ?? void 0,
3302
+ callId: me(r) ?? void 0,
3323
3303
  loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
3324
3304
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
3325
3305
  id: String(s.id ?? crypto.randomUUID()),
3326
3306
  role: "system",
3327
- content: rr(r),
3307
+ content: or(r),
3328
3308
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3329
- ...v(r) !== null ? { causalSequence: v(r) } : {},
3330
- respondsToUserMessageId: x(r) ?? void 0,
3331
- ..._(r) ? { runId: _(r) } : {},
3309
+ ...D(r) !== null ? { causalSequence: D(r) } : {},
3310
+ respondsToUserMessageId: N(r) ?? void 0,
3311
+ ...C(r) ? { runId: C(r) } : {},
3332
3312
  dataType: String(r.type),
3333
3313
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
3334
3314
  ...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
@@ -3336,11 +3316,11 @@ function Jt(t, e) {
3336
3316
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
3337
3317
  } : null;
3338
3318
  }
3339
- function tr(t) {
3319
+ function nr(t) {
3340
3320
  const s = (typeof t.server_label == "string" ? t.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
3341
3321
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
3342
3322
  }
3343
- function sr(t) {
3323
+ function rr(t) {
3344
3324
  if (typeof t != "string")
3345
3325
  return null;
3346
3326
  try {
@@ -3357,7 +3337,7 @@ function sr(t) {
3357
3337
  return null;
3358
3338
  }
3359
3339
  }
3360
- function nr(t) {
3340
+ function ir(t) {
3361
3341
  if (typeof t != "string")
3362
3342
  return null;
3363
3343
  try {
@@ -3372,10 +3352,10 @@ function nr(t) {
3372
3352
  return null;
3373
3353
  }
3374
3354
  }
3375
- function rr(t) {
3355
+ function or(t) {
3376
3356
  return t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message : "";
3377
3357
  }
3378
- function ir(t) {
3358
+ function ar(t) {
3379
3359
  if (t.type === "web_search_call") {
3380
3360
  const e = t.action;
3381
3361
  if (e && typeof e == "object") {
@@ -3387,9 +3367,9 @@ function ir(t) {
3387
3367
  }
3388
3368
  return "🔎 Searching the web";
3389
3369
  }
3390
- return or(t);
3370
+ return lr(t);
3391
3371
  }
3392
- function or(t) {
3372
+ function lr(t) {
3393
3373
  if (typeof t.summary == "string" && t.summary.trim().length > 0)
3394
3374
  return Y(t.summary);
3395
3375
  if (typeof t.arguments == "string")
@@ -3406,7 +3386,7 @@ function Y(t) {
3406
3386
  const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
3407
3387
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
3408
3388
  }
3409
- function ar(t) {
3389
+ function cr(t) {
3410
3390
  if (t == null)
3411
3391
  return t;
3412
3392
  if (typeof t != "object")
@@ -3421,14 +3401,14 @@ function ar(t) {
3421
3401
  runId: typeof e.runId == "string" ? e.runId : null
3422
3402
  };
3423
3403
  }
3424
- function ge(t) {
3404
+ function me(t) {
3425
3405
  const e = t.callId ?? t.call_id;
3426
3406
  return typeof e == "string" && e ? e : null;
3427
3407
  }
3428
- function v(t) {
3408
+ function D(t) {
3429
3409
  return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
3430
3410
  }
3431
- function lr(t) {
3411
+ function ur(t) {
3432
3412
  return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
3433
3413
  if (!e || typeof e != "object")
3434
3414
  return "";
@@ -3436,31 +3416,31 @@ function lr(t) {
3436
3416
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
3437
3417
  }).filter(Boolean).join("") : "";
3438
3418
  }
3439
- function Ke(t, e) {
3440
- const s = Qt(t, e), n = gr(
3441
- ur(
3442
- Tr(t, e),
3419
+ function Ve(t, e) {
3420
+ const s = Zt(t, e), n = mr(
3421
+ dr(
3422
+ wr(t, e),
3443
3423
  s
3444
3424
  ),
3445
3425
  s
3446
3426
  ), r = n.findIndex((o) => o.id === s.id);
3447
3427
  if (r === -1)
3448
- return Xe(
3428
+ return Ye(
3449
3429
  [...n, s]
3450
3430
  );
3451
3431
  const i = [...n];
3452
- return i[r] = s, Xe(i);
3432
+ return i[r] = s, Ye(i);
3453
3433
  }
3454
- function ur(t, e) {
3434
+ function dr(t, e) {
3455
3435
  const s = e.assistantDraftItemId;
3456
3436
  return s ? t.map(
3457
3437
  (n) => n.dataType === "assistant_draft" && n.id === s ? e : n
3458
3438
  ) : t;
3459
3439
  }
3460
- function He(t, e, s) {
3440
+ function je(t, e, s) {
3461
3441
  return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
3462
3442
  }
3463
- function cr(t, e, s, n) {
3443
+ function pr(t, e, s, n) {
3464
3444
  if (s === null) return t;
3465
3445
  let r = -1;
3466
3446
  for (let o = t.length - 1; o >= 0; o -= 1) {
@@ -3477,12 +3457,12 @@ function cr(t, e, s, n) {
3477
3457
  respondsToUserMessageId: s
3478
3458
  }, i;
3479
3459
  }
3480
- function dr(t, e) {
3460
+ function hr(t, e) {
3481
3461
  const s = t.findIndex(
3482
3462
  (r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
3483
3463
  );
3484
3464
  if (s === -1)
3485
- return Ke(t, e);
3465
+ return Ve(t, e);
3486
3466
  const n = [...t];
3487
3467
  return n[s] = {
3488
3468
  ...n[s],
@@ -3494,12 +3474,12 @@ function dr(t, e) {
3494
3474
  ...n[s].runId ? {} : { runId: e.runId }
3495
3475
  }, n;
3496
3476
  }
3497
- function hr(t, e, s) {
3477
+ function gr(t, e, s) {
3498
3478
  let n = !1;
3499
3479
  const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
3500
3480
  return n ? r : t;
3501
3481
  }
3502
- function pr(t) {
3482
+ function fr(t) {
3503
3483
  if (t.hiddenFromTranscript === !0)
3504
3484
  return null;
3505
3485
  const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
@@ -3519,7 +3499,7 @@ function pr(t) {
3519
3499
  loading: !0
3520
3500
  };
3521
3501
  }
3522
- function gr(t, e) {
3502
+ function mr(t, e) {
3523
3503
  if (e.id.startsWith("transient-activity:"))
3524
3504
  return t;
3525
3505
  const s = e.toolName === "tab_lifecycle";
@@ -3528,24 +3508,32 @@ function gr(t, e) {
3528
3508
  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);
3529
3509
  return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
3530
3510
  }
3531
- function fr(t, e) {
3532
- return ks(
3511
+ function Yt(t, e) {
3512
+ return bs(
3533
3513
  t,
3534
3514
  e.map(
3535
- (s) => Qt(t, s)
3515
+ (s) => Zt(t, s)
3536
3516
  ),
3537
- Yt
3517
+ Qt
3538
3518
  );
3539
3519
  }
3540
- function mr(t, e, s) {
3541
- const n = new Map(e.map((i) => [i.id, i]));
3542
- return [
3543
- ...t.filter((i) => s.has(i.id)).map((i) => n.get(i.id) ?? i),
3544
- ...e.filter((i) => !s.has(i.id))
3545
- ];
3520
+ function yr(t, e) {
3521
+ const s = new Map(t.map((n) => [n.id, n]));
3522
+ for (const n of e)
3523
+ s.set(n.id, n);
3524
+ return Yt(
3525
+ t,
3526
+ [...s.values()]
3527
+ ).sort(Ir);
3546
3528
  }
3547
- function Yt(t) {
3548
- const e = V(t) ?? void 0, s = t.assistantDraftItemId, n = [
3529
+ function Ir(t, e) {
3530
+ if ((t.respondsToUserMessageId !== void 0 && t.respondsToUserMessageId === e.respondsToUserMessageId || t.respondsToUserMessageId === void 0 && e.respondsToUserMessageId === void 0 && t.runId !== void 0 && t.runId === e.runId) && t.causalSequence !== void 0 && e.causalSequence !== void 0 && t.causalSequence !== e.causalSequence)
3531
+ return t.causalSequence - e.causalSequence;
3532
+ const n = Date.parse(t.createdAt) - Date.parse(e.createdAt);
3533
+ return Number.isNaN(n) ? 0 : n;
3534
+ }
3535
+ function Qt(t) {
3536
+ const e = G(t) ?? void 0, s = t.assistantDraftItemId, n = [
3549
3537
  ...t.callId ? [`call:${t.callId}`] : [],
3550
3538
  ...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
3551
3539
  ];
@@ -3556,55 +3544,55 @@ function Yt(t) {
3556
3544
  ...n.length > 0 ? { activityKeys: n } : {},
3557
3545
  ...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
3558
3546
  ...t.runId ? { runId: t.runId } : {},
3559
- isOptimistic: ke(t),
3547
+ isOptimistic: be(t),
3560
3548
  isAssistantDraft: t.dataType === "assistant_draft",
3561
3549
  isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
3562
3550
  isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
3563
3551
  };
3564
3552
  }
3565
- function Qt(t, e) {
3553
+ function Zt(t, e) {
3566
3554
  if (e.role !== "user" || !e.attachments?.length)
3567
3555
  return e;
3568
3556
  const s = t.find(
3569
- (o) => o.role === "user" && (o.id === e.id || ke(o) && Zt(o, e))
3557
+ (o) => o.role === "user" && (o.id === e.id || be(o) && es(o, e))
3570
3558
  );
3571
3559
  if (!s?.attachments?.length)
3572
3560
  return e;
3573
3561
  const n = e.attachments.map((o) => {
3574
- const a = yr(s.attachments ?? [], o);
3575
- return a ? Ir(o, a) : o;
3576
- }), r = { ...e, attachments: n }, i = V(e);
3562
+ const a = Tr(s.attachments ?? [], o);
3563
+ return a ? Sr(o, a) : o;
3564
+ }), r = { ...e, attachments: n }, i = G(e);
3577
3565
  return i && Object.defineProperty(r, "clientMessageId", {
3578
3566
  value: i,
3579
3567
  enumerable: !1
3580
3568
  }), r;
3581
3569
  }
3582
- function yr(t, e) {
3570
+ function Tr(t, e) {
3583
3571
  return e.id ? t.find((s) => s.id === e.id) ?? null : null;
3584
3572
  }
3585
- function Ir(t, e) {
3573
+ function Sr(t, e) {
3586
3574
  const { previewUrl: s } = e;
3587
3575
  return s ? { ...t, previewUrl: s } : t;
3588
3576
  }
3589
- function Tr(t, e) {
3577
+ function wr(t, e) {
3590
3578
  if (e.role !== "user")
3591
3579
  return t;
3592
3580
  const s = t.findIndex(
3593
- (r) => ke(r) && Zt(r, e)
3581
+ (r) => be(r) && es(r, e)
3594
3582
  );
3595
3583
  if (s === -1)
3596
3584
  return t;
3597
3585
  const n = [...t];
3598
3586
  return n.splice(s, 1), n;
3599
3587
  }
3600
- function Zt(t, e) {
3601
- const s = V(t), n = V(e);
3588
+ function es(t, e) {
3589
+ const s = G(t), n = G(e);
3602
3590
  return s && n ? s === n : t.content === e.content;
3603
3591
  }
3604
- function ke(t) {
3592
+ function be(t) {
3605
3593
  return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
3606
3594
  }
3607
- function V(t) {
3595
+ function G(t) {
3608
3596
  const e = t.clientMessageId;
3609
3597
  if (e)
3610
3598
  return e;
@@ -3614,18 +3602,18 @@ function V(t) {
3614
3602
  return n ? t.id.slice(n.length) : null;
3615
3603
  }
3616
3604
  function Pt(t) {
3617
- const e = es(t);
3605
+ const e = ts(t);
3618
3606
  if (e === null)
3619
3607
  return !1;
3620
3608
  const s = t[e].id;
3621
3609
  if (t.some(
3622
- (r) => r.respondsToUserMessageId === s && Se(r)
3610
+ (r) => r.respondsToUserMessageId === s && Me(r)
3623
3611
  ))
3624
3612
  return !0;
3625
3613
  for (let r = t.length - 1; r > e; r -= 1) {
3626
3614
  const i = t[r];
3627
3615
  if (!i.respondsToUserMessageId) {
3628
- if (W(i))
3616
+ if (H(i))
3629
3617
  return !0;
3630
3618
  if (i.role === "system") {
3631
3619
  if (i.dataType === "run_error")
@@ -3637,10 +3625,10 @@ function Pt(t) {
3637
3625
  }
3638
3626
  return !1;
3639
3627
  }
3640
- function Sr(t, e, s) {
3628
+ function Mr(t, e, s) {
3641
3629
  const n = new Set(
3642
3630
  t.filter(
3643
- (r) => r.role === "user" && e !== null && V(r) === e
3631
+ (r) => r.role === "user" && e !== null && G(r) === e
3644
3632
  ).map((r) => r.id)
3645
3633
  );
3646
3634
  return t.some((r, i) => {
@@ -3651,29 +3639,29 @@ function Sr(t, e, s) {
3651
3639
  if (s && r.runId === s) {
3652
3640
  if (n.size === 0)
3653
3641
  return !0;
3654
- const o = ts(t, i);
3642
+ const o = ss(t, i);
3655
3643
  return !r.respondsToUserMessageId && o !== null && n.has(o);
3656
3644
  }
3657
3645
  return !1;
3658
3646
  });
3659
3647
  }
3660
- function wr(t) {
3661
- const e = es(t);
3648
+ function Ar(t) {
3649
+ const e = ts(t);
3662
3650
  if (e === null)
3663
- return t.some(W);
3651
+ return t.some(H);
3664
3652
  const s = t[e].id;
3665
3653
  return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
3666
- (n) => n.respondsToUserMessageId === s && W(n)
3667
- ) : t.slice(e + 1).some(W);
3654
+ (n) => n.respondsToUserMessageId === s && H(n)
3655
+ ) : t.slice(e + 1).some(H);
3668
3656
  }
3669
- function es(t) {
3657
+ function ts(t) {
3670
3658
  for (let e = t.length - 1; e >= 0; e -= 1)
3671
- if (t[e].role === "user" && !ke(t[e]))
3659
+ if (t[e].role === "user" && !be(t[e]))
3672
3660
  return e;
3673
3661
  return null;
3674
3662
  }
3675
- function Se(t) {
3676
- return W(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
3663
+ function Me(t) {
3664
+ return H(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
3677
3665
  }
3678
3666
  function Z(t) {
3679
3667
  for (let e = t.length - 1; e >= 0; e -= 1) {
@@ -3689,29 +3677,29 @@ function Z(t) {
3689
3677
  }
3690
3678
  return null;
3691
3679
  }
3692
- function Mr(t) {
3680
+ function Rr(t) {
3693
3681
  const e = Z(t);
3694
3682
  if (e === null)
3695
3683
  return null;
3696
- const n = P(t[e])?.page;
3684
+ const n = U(t[e])?.page;
3697
3685
  if (!n || typeof n != "object")
3698
3686
  return null;
3699
3687
  const r = n.url;
3700
3688
  return typeof r == "string" ? r : null;
3701
3689
  }
3702
- function P(t) {
3690
+ function U(t) {
3703
3691
  if (!t || typeof t != "object")
3704
3692
  return null;
3705
3693
  const e = t.data;
3706
3694
  return e && typeof e == "object" ? e : null;
3707
3695
  }
3708
- function we(t) {
3696
+ function Ae(t) {
3709
3697
  return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
3710
3698
  }
3711
3699
  function Ut(t) {
3712
3700
  return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
3713
3701
  }
3714
- function Ar(t, e) {
3702
+ function Er(t, e) {
3715
3703
  const s = Z(e);
3716
3704
  if (s === null)
3717
3705
  return !1;
@@ -3720,10 +3708,10 @@ function Ar(t, e) {
3720
3708
  return !1;
3721
3709
  const i = t.findIndex((o) => o.role === "user" && o.id === r);
3722
3710
  return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
3723
- (o) => o.respondsToUserMessageId === r && Se(o)
3724
- ) : t.slice(i + 1).some(Se);
3711
+ (o) => o.respondsToUserMessageId === r && Me(o)
3712
+ ) : t.slice(i + 1).some(Me);
3725
3713
  }
3726
- function Ge(t) {
3714
+ function Xe(t) {
3727
3715
  const e = Z(t);
3728
3716
  if (e === null)
3729
3717
  return null;
@@ -3736,7 +3724,7 @@ function Ge(t) {
3736
3724
  const r = n.clientMessageId;
3737
3725
  return typeof r == "string" ? r : null;
3738
3726
  }
3739
- function Rr(t) {
3727
+ function kr(t) {
3740
3728
  const e = Z(t);
3741
3729
  if (e === null)
3742
3730
  return null;
@@ -3751,22 +3739,22 @@ function Rr(t) {
3751
3739
  if (i.type === "message" && i.role === "assistant")
3752
3740
  return null;
3753
3741
  if (i.type === "run_error")
3754
- return i.retryable !== !0 ? null : Ve(t, i) ?? Ge(t);
3742
+ return i.retryable !== !0 ? null : Je(t, i) ?? Xe(t);
3755
3743
  if (i.type === "run_status")
3756
- return i.status === "interrupted" && i.retryable === !0 ? Ve(t, i) ?? Ge(t) : null;
3744
+ return i.status === "interrupted" && i.retryable === !0 ? Je(t, i) ?? Xe(t) : null;
3757
3745
  }
3758
3746
  return null;
3759
3747
  }
3760
- function Ve(t, e) {
3748
+ function Je(t, e) {
3761
3749
  if (typeof e.clientMessageId == "string")
3762
3750
  return e.clientMessageId;
3763
- const s = x(e);
3751
+ const s = N(e);
3764
3752
  if (!s)
3765
3753
  return null;
3766
- const n = t.find((i) => S(i, "id") === s), r = P(n);
3754
+ const n = t.find((i) => M(i, "id") === s), r = U(n);
3767
3755
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
3768
3756
  }
3769
- function Er(t, e) {
3757
+ function Cr(t, e) {
3770
3758
  let s = 0;
3771
3759
  for (const n of t) {
3772
3760
  if (!n || typeof n != "object")
@@ -3779,91 +3767,91 @@ function Er(t, e) {
3779
3767
  }
3780
3768
  return s;
3781
3769
  }
3782
- function Dt(t, e, s, n, r, i) {
3783
- if (!e || !Cr(t))
3770
+ function vt(t, e, s, n, r, i) {
3771
+ if (!e || !_r(t))
3784
3772
  return !1;
3785
3773
  const o = t;
3786
- if (we(o) || s !== null && typeof o.id == "string" && o.id !== s)
3774
+ if (Ae(o) || s !== null && typeof o.id == "string" && o.id !== s)
3787
3775
  return !1;
3788
- const a = x(o);
3789
- return n !== null ? a !== null ? a === n : r !== null && _(o) === r && i === n : r === null || _(o) === r;
3776
+ const a = N(o);
3777
+ return n !== null ? a !== null ? a === n : r !== null && C(o) === r && i === n : r === null || C(o) === r;
3790
3778
  }
3791
- function kr(t, e) {
3779
+ function br(t, e) {
3792
3780
  for (let s = e - 1; s >= 0; s -= 1) {
3793
- const n = P(t[s]);
3781
+ const n = U(t[s]);
3794
3782
  if (n?.type === "message" && n.role === "user")
3795
- return S(t[s], "id");
3783
+ return M(t[s], "id");
3796
3784
  }
3797
3785
  return null;
3798
3786
  }
3799
- function ts(t, e) {
3787
+ function ss(t, e) {
3800
3788
  for (let s = e - 1; s >= 0; s -= 1)
3801
3789
  if (t[s].role === "user")
3802
3790
  return t[s].id;
3803
3791
  return null;
3804
3792
  }
3805
- function Cr(t) {
3793
+ function _r(t) {
3806
3794
  if (!t || typeof t != "object")
3807
3795
  return !1;
3808
3796
  const e = t;
3809
3797
  return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
3810
3798
  }
3811
- function W(t) {
3799
+ function H(t) {
3812
3800
  return t.role === "assistant" && t.phase !== "commentary";
3813
3801
  }
3814
- function br(t) {
3802
+ function Pr(t) {
3815
3803
  if (!t || typeof t != "object")
3816
3804
  return !1;
3817
3805
  const e = t;
3818
3806
  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";
3819
3807
  }
3820
- function Xe(t) {
3821
- return t.filter((e, s) => F(e) ? !Br(t, s) && !ss(t, s) && !Nr(t, s) && !xr(t, s) : _r(e) ? e.retryable === !0 && qr(t, s) ? !1 : !Lr(t, s) : !0);
3808
+ function Ye(t) {
3809
+ return t.filter((e, s) => V(e) ? !Hr(t, s) && !ns(t, s) && !Br(t, s) && !Wr(t, s) : Ur(e) ? e.retryable === !0 && xr(t, s) ? !1 : !Nr(t, s) : !0);
3822
3810
  }
3823
- function _r(t) {
3811
+ function Ur(t) {
3824
3812
  return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
3825
3813
  }
3826
- function F(t) {
3814
+ function V(t) {
3827
3815
  return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
3828
3816
  }
3829
- function Pr(t, e, s, n) {
3817
+ function vr(t, e, s, n) {
3830
3818
  const r = t.findIndex(
3831
- (l, u) => F(l) && !ss(t, u)
3819
+ (l, c) => V(l) && !ns(t, c)
3832
3820
  ), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
3833
3821
  (l) => l.role === "user" && l.id === o
3834
3822
  ) : null;
3835
3823
  return {
3836
- clientMessageId: a ? V(a) : o ? null : n,
3824
+ clientMessageId: a ? G(a) : o ? null : n,
3837
3825
  respondsToUserMessageId: o,
3838
3826
  runId: s ?? i?.runId ?? null
3839
3827
  };
3840
3828
  }
3841
- function Ie(t) {
3829
+ function Se(t) {
3842
3830
  return t?.type === "run_status" && t.status === "stopped";
3843
3831
  }
3844
- function Ur(t, e) {
3845
- return W(e) ? "completed" : Ie(t) ? "stopped" : !we(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
3832
+ function Dr(t, e) {
3833
+ return H(e) ? "completed" : Se(t) ? "stopped" : !Ae(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
3846
3834
  }
3847
- function vt(t, e, s) {
3835
+ function Dt(t, e, s) {
3848
3836
  const n = new Set(
3849
3837
  t.filter(
3850
- (r) => r.role === "user" && e !== null && V(r) === e
3838
+ (r) => r.role === "user" && e !== null && G(r) === e
3851
3839
  ).map((r) => r.id)
3852
3840
  );
3853
3841
  return t.filter(
3854
- (r) => !F(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3842
+ (r) => !V(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3855
3843
  );
3856
3844
  }
3857
- function ss(t, e) {
3845
+ function ns(t, e) {
3858
3846
  return t.some(
3859
- (s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && Dr(
3847
+ (s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && qr(
3860
3848
  t,
3861
3849
  e,
3862
3850
  n
3863
3851
  )
3864
3852
  );
3865
3853
  }
3866
- function Dr(t, e, s) {
3854
+ function qr(t, e, s) {
3867
3855
  const n = t[e], r = t[s];
3868
3856
  if (le(n, r))
3869
3857
  return !0;
@@ -3874,26 +3862,26 @@ function Dr(t, e, s) {
3874
3862
  return t[i].id === n.respondsToUserMessageId;
3875
3863
  return !1;
3876
3864
  }
3877
- function vr(t, e) {
3865
+ function Lr(t, e) {
3878
3866
  const s = [...t].reverse().find(
3879
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Ot(n) && !Or(
3867
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && qt(n) && !Or(
3880
3868
  t,
3881
3869
  n.respondsToUserMessageId
3882
3870
  )
3883
3871
  )?.respondsToUserMessageId;
3884
3872
  return s ? t.map(
3885
- (n) => n.respondsToUserMessageId === s && Ot(n) ? { ...n, steered: !0 } : n
3873
+ (n) => n.respondsToUserMessageId === s && qt(n) ? { ...n, steered: !0 } : n
3886
3874
  ) : t;
3887
3875
  }
3888
- function Ot(t) {
3889
- return t.role === "tool" || F(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
3876
+ function qt(t) {
3877
+ return t.role === "tool" || V(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
3890
3878
  }
3891
3879
  function Or(t, e) {
3892
3880
  return t.some(
3893
- (s) => s.respondsToUserMessageId === e && (W(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3881
+ (s) => s.respondsToUserMessageId === e && (H(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3894
3882
  );
3895
3883
  }
3896
- function Lr(t, e) {
3884
+ function Nr(t, e) {
3897
3885
  const s = t[e];
3898
3886
  for (let n = e + 1; n < t.length; n += 1) {
3899
3887
  const r = t[n];
@@ -3902,7 +3890,7 @@ function Lr(t, e) {
3902
3890
  }
3903
3891
  return !1;
3904
3892
  }
3905
- function qr(t, e) {
3893
+ function xr(t, e) {
3906
3894
  const s = t[e];
3907
3895
  if (!s.respondsToUserMessageId)
3908
3896
  return !1;
@@ -3910,37 +3898,37 @@ function qr(t, e) {
3910
3898
  const r = t[n];
3911
3899
  if (r.role === "user")
3912
3900
  return !1;
3913
- if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || F(r)))
3901
+ if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || V(r)))
3914
3902
  return !0;
3915
3903
  }
3916
3904
  return !1;
3917
3905
  }
3918
- function Nr(t, e) {
3906
+ function Br(t, e) {
3919
3907
  const s = t[e];
3920
3908
  return t.some(
3921
3909
  (n, r) => r !== e && n.role === "assistant" && le(s, n)
3922
3910
  );
3923
3911
  }
3924
- function xr(t, e) {
3912
+ function Wr(t, e) {
3925
3913
  const s = t[e];
3926
3914
  return t.some(
3927
3915
  (n, r) => r !== e && n.role === "tool" && le(s, n)
3928
3916
  );
3929
3917
  }
3930
- function Br(t, e) {
3918
+ function Hr(t, e) {
3931
3919
  const s = t[e];
3932
3920
  for (let n = e + 1; n < t.length; n += 1)
3933
- if (F(t[n]) && le(s, t[n]))
3921
+ if (V(t[n]) && le(s, t[n]))
3934
3922
  return !0;
3935
3923
  return !1;
3936
3924
  }
3937
3925
  function le(t, e) {
3938
3926
  return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
3939
3927
  }
3940
- function S(t, e) {
3928
+ function M(t, e) {
3941
3929
  return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
3942
3930
  }
3943
- function Wr(t, e) {
3931
+ function $r(t, e) {
3944
3932
  try {
3945
3933
  const s = window.localStorage.getItem(`${Ft}${t}`);
3946
3934
  if (!s)
@@ -3948,7 +3936,7 @@ function Wr(t, e) {
3948
3936
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
3949
3937
  if (e !== void 0 && r !== e)
3950
3938
  return null;
3951
- const i = Array.isArray(n.messages) ? n.messages.map(Yr).filter((o) => !!o) : [];
3939
+ const i = Array.isArray(n.messages) ? n.messages.map(Zr).filter((o) => !!o) : [];
3952
3940
  return {
3953
3941
  sessionId: r,
3954
3942
  messages: i
@@ -3957,48 +3945,51 @@ function Wr(t, e) {
3957
3945
  return null;
3958
3946
  }
3959
3947
  }
3960
- function Hr(t, e) {
3948
+ function rs(t) {
3949
+ return t.role === "user" || t.role === "assistant" || t.dataType === "run_status" || t.dataType === "run_error";
3950
+ }
3951
+ function jr(t, e) {
3961
3952
  try {
3962
3953
  window.localStorage.setItem(
3963
3954
  `${Ft}${t}`,
3964
3955
  JSON.stringify({
3965
3956
  sessionId: e.sessionId,
3966
- messages: e.messages.slice(-dn).map(Qr)
3957
+ messages: e.messages.filter(rs).slice(-hn).map(ei)
3967
3958
  })
3968
3959
  );
3969
3960
  } catch {
3970
3961
  return;
3971
3962
  }
3972
3963
  }
3973
- function $r(t) {
3964
+ function Fr(t) {
3974
3965
  try {
3975
- const e = window.localStorage.getItem(`${ze}${t}`);
3966
+ const e = window.localStorage.getItem(`${Ge}${t}`);
3976
3967
  if (!e)
3977
3968
  return [];
3978
3969
  const s = JSON.parse(e);
3979
- return Array.isArray(s) ? s.filter(nt) : [];
3970
+ return Array.isArray(s) ? s.filter(it) : [];
3980
3971
  } catch {
3981
3972
  return [];
3982
3973
  }
3983
3974
  }
3984
- function G(t, e) {
3975
+ function K(t, e) {
3985
3976
  try {
3986
- const s = e.filter(nt);
3977
+ const s = e.filter(it);
3987
3978
  if (s.length === 0) {
3988
- window.localStorage.removeItem(`${ze}${t}`);
3979
+ window.localStorage.removeItem(`${Ge}${t}`);
3989
3980
  return;
3990
3981
  }
3991
3982
  window.localStorage.setItem(
3992
- `${ze}${t}`,
3983
+ `${Ge}${t}`,
3993
3984
  JSON.stringify(s.slice(-25))
3994
3985
  );
3995
3986
  } catch {
3996
3987
  return;
3997
3988
  }
3998
3989
  }
3999
- function ns(t, e) {
3990
+ function is(t, e) {
4000
3991
  try {
4001
- const s = `${Ee}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
3992
+ const s = `${Ce}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
4002
3993
  ...o,
4003
3994
  storedAt: Date.now(),
4004
3995
  unloadUrl: n,
@@ -4014,26 +4005,26 @@ function ns(t, e) {
4014
4005
  }
4015
4006
  function Lt(t, e) {
4016
4007
  try {
4017
- if (window.sessionStorage.getItem(`${Ee}${t}`) === null)
4008
+ if (window.sessionStorage.getItem(`${Ce}${t}`) === null)
4018
4009
  return;
4019
4010
  } catch {
4020
4011
  return;
4021
4012
  }
4022
- ns(t, e);
4013
+ is(t, e);
4023
4014
  }
4024
- function jr(t) {
4015
+ function zr(t) {
4025
4016
  try {
4026
- const e = `${Ee}${t}`, s = window.sessionStorage.getItem(e);
4017
+ const e = `${Ce}${t}`, s = window.sessionStorage.getItem(e);
4027
4018
  if (window.sessionStorage.removeItem(e), !s)
4028
4019
  return [];
4029
4020
  const n = JSON.parse(s);
4030
- return Array.isArray(n) ? n.flatMap((r) => zr(r) ? [{
4021
+ return Array.isArray(n) ? n.flatMap((r) => Gr(r) ? [{
4031
4022
  ...r.event,
4032
4023
  page: b(),
4033
4024
  rawOutput: {
4034
4025
  pageContextRestarted: !0,
4035
4026
  outcome: "unknown",
4036
- message: Fr(location.href),
4027
+ message: Kr(location.href),
4037
4028
  currentUrl: location.href,
4038
4029
  console: [],
4039
4030
  metadata: {
@@ -4050,17 +4041,17 @@ function jr(t) {
4050
4041
  return [];
4051
4042
  }
4052
4043
  }
4053
- function Fr(t) {
4044
+ function Kr(t) {
4054
4045
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
4055
4046
  Current URL: ${t}`;
4056
4047
  }
4057
- function zr(t) {
4048
+ function Gr(t) {
4058
4049
  if (!t || typeof t != "object")
4059
4050
  return !1;
4060
4051
  const e = t, s = e.event;
4061
- return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && nt(s) && s.type === "tool.result";
4052
+ return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && it(s) && s.type === "tool.result";
4062
4053
  }
4063
- function Kr(t, e) {
4054
+ function Vr(t, e) {
4064
4055
  const s = new Set(
4065
4056
  t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
4066
4057
  );
@@ -4069,26 +4060,26 @@ function Kr(t, e) {
4069
4060
  ...e.filter((n) => !s.has(n.callId))
4070
4061
  ];
4071
4062
  }
4072
- function Gr(t) {
4063
+ function Xr(t) {
4073
4064
  try {
4074
- window.sessionStorage.removeItem(`${Ee}${t}`);
4065
+ window.sessionStorage.removeItem(`${Ce}${t}`);
4075
4066
  } catch {
4076
4067
  return;
4077
4068
  }
4078
4069
  }
4079
- function nt(t) {
4070
+ function it(t) {
4080
4071
  if (!t || typeof t != "object")
4081
4072
  return !1;
4082
4073
  const e = t;
4083
- return e.type === "chat.user_message" ? typeof e.content == "string" && qt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? qt(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;
4074
+ return e.type === "chat.user_message" ? typeof e.content == "string" && Ot(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Ot(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;
4084
4075
  }
4085
- function qt(t) {
4076
+ function Ot(t) {
4086
4077
  if (!t || typeof t != "object")
4087
4078
  return !1;
4088
4079
  const e = t;
4089
4080
  return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
4090
4081
  }
4091
- function rs(t, e) {
4082
+ function os(t, e) {
4092
4083
  if (!Array.isArray(t))
4093
4084
  return;
4094
4085
  const s = t.filter((r) => {
@@ -4096,41 +4087,41 @@ function rs(t, e) {
4096
4087
  return !1;
4097
4088
  const i = r;
4098
4089
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
4099
- }), n = e ? s.map((r) => is(r, e)) : s;
4090
+ }), n = e ? s.map((r) => as(r, e)) : s;
4100
4091
  return n.length > 0 ? n : void 0;
4101
4092
  }
4102
- function is(t, e) {
4093
+ function as(t, e) {
4103
4094
  return t.fileUrl?.startsWith("/") ? {
4104
4095
  ...t,
4105
4096
  fileUrl: new URL(t.fileUrl, e).toString()
4106
4097
  } : t;
4107
4098
  }
4108
- function Je(t) {
4109
- return t.type || Jr(t.name) || "application/octet-stream";
4099
+ function Qe(t) {
4100
+ return t.type || Qr(t.name) || "application/octet-stream";
4110
4101
  }
4111
- function Vr(t) {
4112
- os({
4102
+ function Jr(t) {
4103
+ ls({
4113
4104
  name: t.name,
4114
- mimeType: Je(t),
4105
+ mimeType: Qe(t),
4115
4106
  sizeBytes: t.size
4116
4107
  });
4117
4108
  }
4118
- function os(t) {
4119
- const e = Xr(t.name), s = t.mimeType.trim().toLowerCase();
4120
- if (!ln.has(`${e}:${s}`))
4109
+ function ls(t) {
4110
+ const e = Yr(t.name), s = t.mimeType.trim().toLowerCase();
4111
+ if (!un.has(`${e}:${s}`))
4121
4112
  throw new Error("This attachment type is not supported by the embedded model provider");
4122
4113
  if (t.sizeBytes <= 0 || t.sizeBytes >= $t)
4123
4114
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
4124
4115
  }
4125
- function Xr(t) {
4116
+ function Yr(t) {
4126
4117
  const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
4127
4118
  return s >= 0 ? e.slice(s) : "";
4128
4119
  }
4129
- function Jr(t) {
4120
+ function Qr(t) {
4130
4121
  const e = t.toLowerCase();
4131
4122
  return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
4132
4123
  }
4133
- function Yr(t) {
4124
+ function Zr(t) {
4134
4125
  if (!t || typeof t != "object")
4135
4126
  return null;
4136
4127
  const e = t;
@@ -4147,17 +4138,17 @@ function Yr(t) {
4147
4138
  dataType: typeof e.dataType == "string" ? e.dataType : void 0,
4148
4139
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
4149
4140
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
4150
- attachments: rs(e.attachments)?.map(Me),
4141
+ attachments: os(e.attachments)?.map(Re),
4151
4142
  loading: typeof e.loading == "boolean" ? e.loading : void 0
4152
4143
  };
4153
4144
  }
4154
- function Qr(t) {
4145
+ function ei(t) {
4155
4146
  return t.attachments?.length ? {
4156
4147
  ...t,
4157
- attachments: t.attachments.map(Me)
4148
+ attachments: t.attachments.map(Re)
4158
4149
  } : t;
4159
4150
  }
4160
- function Me(t) {
4151
+ function Re(t) {
4161
4152
  const {
4162
4153
  dataUrl: e,
4163
4154
  objectUrl: s,
@@ -4167,47 +4158,47 @@ function Me(t) {
4167
4158
  } = t;
4168
4159
  return i;
4169
4160
  }
4170
- function x(t) {
4161
+ function N(t) {
4171
4162
  const e = t.respondsToUserMessageId;
4172
4163
  return typeof e == "string" && e ? e : null;
4173
4164
  }
4174
- function _(t) {
4165
+ function C(t) {
4175
4166
  const e = t.runId;
4176
4167
  return typeof e == "string" && e ? e : null;
4177
4168
  }
4178
- function Zr(t) {
4169
+ function ti(t) {
4179
4170
  const e = t?.timeoutMs;
4180
- 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 <= Tn);
4171
+ 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 <= wn);
4181
4172
  }
4182
- function as(t) {
4173
+ function cs(t) {
4183
4174
  const e = {};
4184
4175
  try {
4185
4176
  new Headers(t).forEach((s, n) => {
4186
- Object.keys(e).length < tt && (e[n] = rt(n, s));
4177
+ Object.keys(e).length < nt && (e[n] = ot(n, s));
4187
4178
  });
4188
4179
  } catch {
4189
4180
  return {};
4190
4181
  }
4191
4182
  return e;
4192
4183
  }
4193
- function rt(t, e) {
4194
- return ps(t) ? Ce : B(Re(e), un);
4184
+ function ot(t, e) {
4185
+ return fs(t) ? _e : W(ke(e), dn);
4195
4186
  }
4196
- function ei(t, e) {
4187
+ function si(t, e) {
4197
4188
  return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
4198
4189
  }
4199
- async function ti(t, e, s, n) {
4200
- const r = as(t.headers);
4190
+ async function ni(t, e, s, n) {
4191
+ const r = cs(t.headers);
4201
4192
  n({
4202
4193
  ...e,
4203
4194
  responseStatus: t.status,
4204
4195
  responseHeaders: r,
4205
- responseBody: await si(t),
4196
+ responseBody: await ri(t),
4206
4197
  durationMs: Date.now() - s
4207
4198
  });
4208
4199
  }
4209
- async function si(t) {
4210
- if (!ls(t.headers))
4200
+ async function ri(t) {
4201
+ if (!us(t.headers))
4211
4202
  return;
4212
4203
  let e = null, s = null;
4213
4204
  try {
@@ -4216,20 +4207,20 @@ async function si(t) {
4216
4207
  const n = new Promise((a) => {
4217
4208
  s = window.setTimeout(() => {
4218
4209
  e?.cancel(), a("timeout");
4219
- }, cn);
4210
+ }, pn);
4220
4211
  }), r = new TextDecoder();
4221
4212
  let i = "", o = 0;
4222
4213
  for (; ; ) {
4223
4214
  const a = await Promise.race([e.read(), n]);
4224
4215
  if (a === "timeout")
4225
4216
  return;
4226
- const { done: l, value: u } = a;
4217
+ const { done: l, value: c } = a;
4227
4218
  if (l)
4228
- return B(i + r.decode());
4229
- const d = et - o;
4230
- if (u.byteLength > d)
4231
- return i += r.decode(u.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${B(i)}... [truncated]`;
4232
- o += u.byteLength, i += r.decode(u, { stream: !0 });
4219
+ return W(i + r.decode());
4220
+ const d = st - o;
4221
+ if (c.byteLength > d)
4222
+ return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${W(i)}... [truncated]`;
4223
+ o += c.byteLength, i += r.decode(c, { stream: !0 });
4233
4224
  }
4234
4225
  } catch {
4235
4226
  e?.cancel();
@@ -4238,19 +4229,19 @@ async function si(t) {
4238
4229
  s !== null && window.clearTimeout(s);
4239
4230
  }
4240
4231
  }
4241
- function ni(t, e) {
4242
- if (ls(new Headers(e)))
4232
+ function ii(t, e) {
4233
+ if (us(new Headers(e)))
4243
4234
  try {
4244
- return t.responseType === "" || t.responseType === "text" ? B(t.responseText ?? "") : void 0;
4235
+ return t.responseType === "" || t.responseType === "text" ? W(t.responseText ?? "") : void 0;
4245
4236
  } catch {
4246
4237
  return;
4247
4238
  }
4248
4239
  }
4249
4240
  function Nt(t) {
4250
4241
  if (typeof t == "string")
4251
- return B(t);
4242
+ return W(t);
4252
4243
  }
4253
- function ri(t) {
4244
+ function oi(t) {
4254
4245
  return L({
4255
4246
  ...t,
4256
4247
  requestBody: xt(t.requestBody),
@@ -4262,21 +4253,21 @@ function xt(t) {
4262
4253
  return t;
4263
4254
  const e = t.trim();
4264
4255
  if (!e.startsWith("{") && !e.startsWith("["))
4265
- return Re(t);
4256
+ return ke(t);
4266
4257
  try {
4267
4258
  return JSON.stringify(L(JSON.parse(t)));
4268
4259
  } catch {
4269
- return Re(t);
4260
+ return ke(t);
4270
4261
  }
4271
4262
  }
4272
- function ls(t) {
4263
+ function us(t) {
4273
4264
  if (!t)
4274
4265
  return !1;
4275
4266
  const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
4276
- return s !== null && Number.isInteger(n) && n >= 0 && n <= et && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
4267
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= st && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
4277
4268
  }
4278
4269
  function J(t, e = {}, s) {
4279
- if (oi(s))
4270
+ if (li(s))
4280
4271
  return !0;
4281
4272
  const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
4282
4273
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -4291,7 +4282,7 @@ function J(t, e = {}, s) {
4291
4282
  return !0;
4292
4283
  }
4293
4284
  }
4294
- function ii(t, e) {
4285
+ function ai(t, e) {
4295
4286
  if (J(t))
4296
4287
  return !0;
4297
4288
  try {
@@ -4301,117 +4292,117 @@ function ii(t, e) {
4301
4292
  return !0;
4302
4293
  }
4303
4294
  }
4304
- function oi(t) {
4295
+ function li(t) {
4305
4296
  return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
4306
4297
  }
4307
- function ai(t) {
4298
+ function ci(t) {
4308
4299
  const e = {};
4309
4300
  for (const s of t.trim().split(/[\r\n]+/)) {
4310
4301
  const n = s.indexOf(":");
4311
4302
  if (n <= 0)
4312
4303
  continue;
4313
- if (Object.keys(e).length >= tt)
4304
+ if (Object.keys(e).length >= nt)
4314
4305
  break;
4315
4306
  const r = s.slice(0, n).trim();
4316
- e[r] = rt(r, s.slice(n + 1).trim());
4307
+ e[r] = ot(r, s.slice(n + 1).trim());
4317
4308
  }
4318
4309
  return e;
4319
4310
  }
4320
- function B(t, e = et) {
4311
+ function W(t, e = st) {
4321
4312
  return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
4322
4313
  }
4323
- function $e(t) {
4314
+ function Fe(t) {
4324
4315
  return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
4325
4316
  }
4326
- class Te extends Error {
4317
+ class we extends Error {
4327
4318
  constructor(e, s) {
4328
4319
  super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
4329
4320
  }
4330
4321
  status;
4331
4322
  }
4332
- async function fe(t, e) {
4323
+ async function ye(t, e) {
4333
4324
  let s = null;
4334
4325
  for (let n = 0; n < At; n += 1)
4335
4326
  try {
4336
4327
  return await t();
4337
4328
  } catch (r) {
4338
- if (s = r, n >= At - 1 || !ui(r))
4329
+ if (s = r, n >= At - 1 || !di(r))
4339
4330
  throw r;
4340
- await li(n);
4331
+ await ui(n);
4341
4332
  }
4342
4333
  throw s instanceof Error ? s : new Error(e);
4343
4334
  }
4344
- function li(t) {
4335
+ function ui(t) {
4345
4336
  return new Promise((e) => {
4346
- window.setTimeout(e, an[t] ?? 0);
4337
+ window.setTimeout(e, cn[t] ?? 0);
4347
4338
  });
4348
4339
  }
4349
- function ui(t) {
4350
- return t instanceof Te ? ci(t.status) : t instanceof TypeError;
4340
+ function di(t) {
4341
+ return t instanceof we ? pi(t.status) : t instanceof TypeError;
4351
4342
  }
4352
- function ci(t) {
4343
+ function pi(t) {
4353
4344
  return t === 408 || t === 409 || t === 429 || t >= 500;
4354
4345
  }
4355
- function di(t) {
4346
+ function hi(t) {
4356
4347
  return t === 401 || t === 403;
4357
4348
  }
4358
- const Ce = "[REDACTED_SECRET]", H = "[REDACTED_TOKEN]", hi = "[REDACTED_SIGNED_URL]", pi = 20, gi = /^(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, us = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, cs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ds = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, hs = /\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, fi = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, mi = /\bhttps?:\/\/[^\s"'<>]+/gi, yi = /[),.;\]]+$/;
4349
+ const _e = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", gi = "[REDACTED_SIGNED_URL]", fi = 20, mi = /^(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, ds = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ps = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, hs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, gs = /\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, yi = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Ii = /\bhttps?:\/\/[^\s"'<>]+/gi, Ti = /[),.;\]]+$/;
4359
4350
  function L(t) {
4360
- return Ae(t, 0, /* @__PURE__ */ new WeakSet());
4351
+ return Ee(t, 0, /* @__PURE__ */ new WeakSet());
4361
4352
  }
4362
- function Ae(t, e, s) {
4353
+ function Ee(t, e, s) {
4363
4354
  if (typeof t == "string")
4364
- return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Re(t);
4355
+ return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : ke(t);
4365
4356
  if (t === null || typeof t != "object")
4366
4357
  return t;
4367
- if (e >= pi)
4358
+ if (e >= fi)
4368
4359
  return "[REDACTED_MAX_DEPTH]";
4369
4360
  if (s.has(t))
4370
4361
  return "[REDACTED_CIRCULAR]";
4371
4362
  if (s.add(t), Array.isArray(t))
4372
- return t.map((r) => Ae(r, e + 1, s));
4363
+ return t.map((r) => Ee(r, e + 1, s));
4373
4364
  const n = {};
4374
4365
  for (const [r, i] of Object.entries(t))
4375
- r === "pageContent" ? n[r] = i : ps(r) ? n[r] = Ce : n[r] = r.toLowerCase() === "url" ? Ii(i) : Ae(i, e + 1, s);
4366
+ r === "pageContent" ? n[r] = i : fs(r) ? n[r] = _e : n[r] = r.toLowerCase() === "url" ? Si(i) : Ee(i, e + 1, s);
4376
4367
  return n;
4377
4368
  }
4378
- function ps(t) {
4369
+ function fs(t) {
4379
4370
  const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
4380
4371
  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");
4381
4372
  }
4382
- function Ii(t) {
4383
- return typeof t == "string" ? gs(t) : Ae(t, 0, /* @__PURE__ */ new WeakSet());
4373
+ function Si(t) {
4374
+ return typeof t == "string" ? ms(t) : Ee(t, 0, /* @__PURE__ */ new WeakSet());
4384
4375
  }
4385
- function gs(t) {
4376
+ function ms(t) {
4386
4377
  try {
4387
4378
  const e = new URL(t, location.href);
4388
4379
  for (const s of Array.from(e.searchParams.keys()))
4389
- gi.test(s) && e.searchParams.set(s, H);
4390
- return e.username && (e.username = H), e.password && (e.password = H), e.toString();
4380
+ mi.test(s) && e.searchParams.set(s, $);
4381
+ return e.username && (e.username = $), e.password && (e.password = $), e.toString();
4391
4382
  } catch {
4392
- return Ti(t);
4383
+ return wi(t);
4393
4384
  }
4394
4385
  }
4395
- function Re(t) {
4396
- return t.replace(fi, hi).replace(mi, Si).replace(us, `Bearer ${H}`).replace(cs, `Basic ${H}`).replace(ds, H).replace(hs, (e, s) => `${s}: ${Ce}`);
4386
+ function ke(t) {
4387
+ return t.replace(yi, gi).replace(Ii, Mi).replace(ds, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(hs, $).replace(gs, (e, s) => `${s}: ${_e}`);
4397
4388
  }
4398
- function Ti(t) {
4399
- return t.replace(us, `Bearer ${H}`).replace(cs, `Basic ${H}`).replace(ds, H).replace(hs, (e, s) => `${s}: ${Ce}`);
4389
+ function wi(t) {
4390
+ return t.replace(ds, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(hs, $).replace(gs, (e, s) => `${s}: ${_e}`);
4400
4391
  }
4401
- function Si(t) {
4402
- const e = t.match(yi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
4403
- return `${gs(s)}${e}`;
4392
+ function Mi(t) {
4393
+ const e = t.match(Ti)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
4394
+ return `${ms(s)}${e}`;
4404
4395
  }
4405
4396
  export {
4406
- pt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
4407
- Fe as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
4408
- Fs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
4409
- js as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
4410
- zs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
4411
- wi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
4397
+ ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
4398
+ Ke as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
4399
+ Ks as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
4400
+ zs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
4401
+ Gs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
4402
+ Ai as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
4412
4403
  zt as PlunoProductAgent,
4413
- pn as calculateReconnectDelay,
4404
+ fn as calculateReconnectDelay,
4414
4405
  zt as default,
4415
- Ln as getProductAgentOriginAccessErrorMessage,
4416
- Vr as validateProductAgentProviderInputFile
4406
+ Nn as getProductAgentOriginAccessErrorMessage,
4407
+ Jr as validateProductAgentProviderInputFile
4417
4408
  };