@pluno/product-agent-web 0.1.175 → 0.1.176

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