@pluno/product-agent-web 0.1.189 → 0.1.191

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