@pluno/product-agent-web 0.1.152 → 0.1.154

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 Qe = "pluno-product-agent-attachments";
2
- const Pt = "files";
3
- async function ts(e) {
4
- const t = await Ft();
5
- await ns(t, "readwrite", (s) => s.put(e));
6
- }
7
- async function es(e, t) {
8
- const s = await Ft();
9
- await Ht(s, "readwrite", async (n) => {
10
- const r = await Wt(
1
+ const ns = "pluno-product-agent-attachments";
2
+ const vt = "files";
3
+ async function rs(e) {
4
+ const t = await $t();
5
+ await as(t, "readwrite", (s) => s.put(e));
6
+ }
7
+ async function is(e, t) {
8
+ const s = await $t();
9
+ await jt(s, "readwrite", async (n) => {
10
+ const r = await zt(
11
11
  n.get(e)
12
12
  );
13
13
  r && n.put({
@@ -16,28 +16,28 @@ async function es(e, t) {
16
16
  });
17
17
  });
18
18
  }
19
- async function ss(e = 864e5) {
20
- const t = await Ft(), s = Date.now() - e;
21
- await Ht(t, "readwrite", async (n) => {
19
+ async function os(e = 864e5) {
20
+ const t = await $t(), s = Date.now() - e;
21
+ await jt(t, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Wt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await zt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function Ft() {
26
+ function $t() {
27
27
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
28
- const s = indexedDB.open(Qe, 1);
28
+ const s = indexedDB.open(ns, 1);
29
29
  s.onupgradeneeded = () => {
30
- const r = s.result.createObjectStore(Pt, { keyPath: "attachmentId" });
30
+ const r = s.result.createObjectStore(vt, { 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 = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
33
33
  });
34
34
  }
35
- async function ns(e, t, s) {
36
- return await Ht(e, t, async (n) => await Wt(s(n)));
35
+ async function as(e, t, s) {
36
+ return await jt(e, t, async (n) => await zt(s(n)));
37
37
  }
38
- function Ht(e, t, s) {
38
+ function jt(e, t, s) {
39
39
  return new Promise((n, r) => {
40
- const i = e.transaction(Pt, t), o = i.objectStore(Pt);
40
+ const i = e.transaction(vt, t), o = i.objectStore(vt);
41
41
  let a, c = !1;
42
42
  s(o).then((l) => {
43
43
  a = l;
@@ -57,16 +57,16 @@ function Ht(e, t, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Wt(e) {
60
+ function zt(e) {
61
61
  return new Promise((t, s) => {
62
62
  e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
63
63
  });
64
64
  }
65
- function rs(e) {
65
+ function cs(e) {
66
66
  return e !== null && (typeof e == "object" || typeof e == "function");
67
67
  }
68
68
  function be(e, t, s) {
69
- const n = Reflect.get(e, "pluno"), r = rs(n) ? n : {};
69
+ const n = Reflect.get(e, "pluno"), r = cs(n) ? n : {};
70
70
  if (r !== n && !Reflect.set(e, "pluno", r))
71
71
  return null;
72
72
  const i = Object.getOwnPropertyDescriptor(r, t);
@@ -80,14 +80,14 @@ function be(e, t, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const is = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function os(e, t) {
83
+ const ls = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function us(e, t) {
85
85
  return t ? e.replace(
86
- is,
86
+ ls,
87
87
  (s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
88
88
  ) : e;
89
89
  }
90
- function as(e, t, s) {
90
+ function ds(e, t, s) {
91
91
  const n = t.map((u) => ({ item: u, identity: s(u) })), r = new Set(
92
92
  n.flatMap(
93
93
  ({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
@@ -105,37 +105,37 @@ function as(e, t, s) {
105
105
  ), l = /* @__PURE__ */ new Map();
106
106
  for (const { item: u, identity: d } of i)
107
107
  for (const p of d.activityKeys ?? []) {
108
- const m = l.get(p);
109
- (!m || s(m).isTransient) && l.set(p, u);
108
+ const g = l.get(p);
109
+ (!g || s(g).isTransient) && l.set(p, u);
110
110
  }
111
111
  const h = new Set(i.map(({ identity: u }) => u.id)), f = new Set(
112
112
  i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
113
- ), I = /* @__PURE__ */ new Set(), g = [];
113
+ ), I = /* @__PURE__ */ new Set(), m = [];
114
114
  for (const u of e) {
115
115
  const d = s(u);
116
116
  let p = o.get(d.id);
117
- if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((E) => l.get(E)).find((E) => E !== void 0) ?? p), p && !I.has(p)) {
118
- g.push(p), I.add(p);
117
+ if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((A) => l.get(A)).find((A) => A !== void 0) ?? p), p && !I.has(p)) {
118
+ m.push(p), I.add(p);
119
119
  continue;
120
120
  }
121
- const m = d.respondsToUserMessageId !== void 0 && h.has(d.respondsToUserMessageId) || d.runId !== void 0 && f.has(d.runId);
122
- (d.isOptimistic || (d.isAssistantDraft || d.isActivity) && m) && g.push(u);
121
+ const g = d.respondsToUserMessageId !== void 0 && h.has(d.respondsToUserMessageId) || d.runId !== void 0 && f.has(d.runId);
122
+ (d.isOptimistic || (d.isAssistantDraft || d.isActivity) && g) && m.push(u);
123
123
  }
124
124
  for (const { item: u } of i)
125
- I.has(u) || g.push(u);
126
- return g;
125
+ I.has(u) || m.push(u);
126
+ return m;
127
127
  }
128
- function cs(e, t, s, n) {
128
+ function hs(e, t, s, n) {
129
129
  return e.filter((r) => {
130
130
  const i = n(r);
131
131
  return !i.isActivity || !i.isTransient ? !0 : t !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== t : s === null || i.runId !== s;
132
132
  });
133
133
  }
134
- const St = "pluno.productAgent.transportId", ls = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", us = 50, ds = globalThis.setTimeout.bind(globalThis);
135
- let W = null;
136
- const et = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Map();
137
- async function hs(e = Me()) {
138
- const t = e.randomUUID(), s = e.storage.getItem(St);
134
+ const Et = "pluno.productAgent.transportId", ps = "pluno.productAgent.transportIdentity", Rt = "pluno.productAgent.transportIdentity.event", fs = 50, gs = globalThis.setTimeout.bind(globalThis);
135
+ let $ = null;
136
+ const it = /* @__PURE__ */ new Set(), Mt = /* @__PURE__ */ new Map();
137
+ async function ms(e = ke()) {
138
+ const t = e.randomUUID(), s = e.storage.getItem(Et);
139
139
  let n = s ?? e.randomUUID(), r = !1, i = !1;
140
140
  const o = e.channel.subscribe((c) => {
141
141
  if (!(c.senderId === t || c.transportId !== n)) {
@@ -153,14 +153,14 @@ async function hs(e = Me()) {
153
153
  }
154
154
  });
155
155
  if (!s)
156
- e.storage.setItem(St, n), r = !0;
156
+ e.storage.setItem(Et, n), r = !0;
157
157
  else
158
158
  for (; ; ) {
159
159
  if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
160
160
  r = !0;
161
161
  break;
162
162
  }
163
- n = e.randomUUID(), e.storage.setItem(St, n);
163
+ n = e.randomUUID(), e.storage.setItem(Et, n);
164
164
  }
165
165
  let a = !1;
166
166
  return {
@@ -170,49 +170,49 @@ async function hs(e = Me()) {
170
170
  }
171
171
  };
172
172
  }
173
- async function ps() {
174
- W || (W = hs(Me()), W.then((n) => {
173
+ async function ys() {
174
+ $ || ($ = ms(ke()), $.then((n) => {
175
175
  const r = (i) => {
176
- i.persisted || (n.release(), W = null, et.clear(), window.removeEventListener("pagehide", r));
176
+ i.persisted || (n.release(), $ = null, it.clear(), window.removeEventListener("pagehide", r));
177
177
  };
178
178
  window.addEventListener("pagehide", r);
179
179
  }));
180
- const e = await W, t = fs();
181
- et.add(t);
180
+ const e = await $, t = Is();
181
+ it.add(t);
182
182
  let s = !1;
183
183
  return {
184
184
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
185
185
  transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
186
186
  release: () => {
187
- s || (s = !0, et.delete(t));
187
+ s || (s = !0, it.delete(t));
188
188
  }
189
189
  };
190
190
  }
191
- function fs() {
191
+ function Is() {
192
192
  let e = 0;
193
- for (; et.has(e); )
193
+ for (; it.has(e); )
194
194
  e += 1;
195
195
  return e;
196
196
  }
197
- function Me() {
197
+ function ke() {
198
198
  return {
199
- storage: gs(),
200
- channel: ms(),
199
+ storage: Ts(),
200
+ channel: ws(),
201
201
  randomUUID: () => crypto.randomUUID(),
202
- settle: () => new Promise((e) => ds(e, us))
202
+ settle: () => new Promise((e) => gs(e, fs))
203
203
  };
204
204
  }
205
- function gs() {
205
+ function Ts() {
206
206
  return {
207
207
  getItem: (e) => {
208
208
  try {
209
- return window.sessionStorage?.getItem(e) ?? Et.get(e) ?? null;
209
+ return window.sessionStorage?.getItem(e) ?? Mt.get(e) ?? null;
210
210
  } catch {
211
- return Et.get(e) ?? null;
211
+ return Mt.get(e) ?? null;
212
212
  }
213
213
  },
214
214
  setItem: (e, t) => {
215
- Et.set(e, t);
215
+ Mt.set(e, t);
216
216
  try {
217
217
  window.sessionStorage?.setItem(e, t);
218
218
  } catch {
@@ -220,9 +220,9 @@ function gs() {
220
220
  }
221
221
  };
222
222
  }
223
- function ms() {
223
+ function ws() {
224
224
  if (typeof BroadcastChannel < "u") {
225
- const e = new BroadcastChannel(ls);
225
+ const e = new BroadcastChannel(ps);
226
226
  return {
227
227
  postMessage: (t) => e.postMessage(t),
228
228
  subscribe: (t) => {
@@ -232,11 +232,11 @@ function ms() {
232
232
  close: () => e.close()
233
233
  };
234
234
  }
235
- return ys();
235
+ return Ss();
236
236
  }
237
- function ys() {
237
+ function Ss() {
238
238
  const e = /* @__PURE__ */ new Set(), t = (s) => {
239
- if (s.key !== At || !s.newValue)
239
+ if (s.key !== Rt || !s.newValue)
240
240
  return;
241
241
  const n = JSON.parse(s.newValue);
242
242
  for (const r of e)
@@ -245,9 +245,9 @@ function ys() {
245
245
  return window.addEventListener("storage", t), {
246
246
  postMessage: (s) => {
247
247
  window.localStorage.setItem(
248
- At,
248
+ Rt,
249
249
  JSON.stringify({ ...s, eventId: crypto.randomUUID() })
250
- ), window.localStorage.removeItem(At);
250
+ ), window.localStorage.removeItem(Rt);
251
251
  },
252
252
  subscribe: (s) => (e.add(s), () => e.delete(s)),
253
253
  close: () => {
@@ -255,8 +255,8 @@ function ys() {
255
255
  }
256
256
  };
257
257
  }
258
- const ke = "schedule_follow_up";
259
- function Is(e) {
258
+ const _e = "schedule_follow_up";
259
+ function As(e) {
260
260
  let t = e;
261
261
  if (typeof t == "string")
262
262
  try {
@@ -267,11 +267,11 @@ function Is(e) {
267
267
  if (!t || typeof t != "object")
268
268
  return null;
269
269
  const s = t;
270
- return s.ok !== !0 || s.toolName !== ke || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
270
+ return s.ok !== !0 || s.toolName !== _e || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
271
271
  }
272
- const Ts = globalThis.fetch.bind(globalThis), Dt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ws = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ss = ".pluno-pa-widget__panel", As = ".pluno-pa-widget__timeline", ie = `${Dt}[data-pluno-sdk-preview-channel]`;
273
- let Es = 0;
274
- function oe(e) {
272
+ const Es = globalThis.fetch.bind(globalThis), Nt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Rs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ms = ".pluno-pa-widget__panel", bs = ".pluno-pa-widget__timeline", ce = `${Nt}[data-pluno-sdk-preview-channel]`;
273
+ let ks = 0;
274
+ function le(e) {
275
275
  const t = {};
276
276
  for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
277
277
  const o = e[i];
@@ -284,7 +284,7 @@ function oe(e) {
284
284
  const r = e.attachments;
285
285
  return Array.isArray(r) && (t.attachmentCount = r.length), t;
286
286
  }
287
- function Rt(e, t, s) {
287
+ function bt(e, t, s) {
288
288
  if (typeof window > "u")
289
289
  return;
290
290
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -296,25 +296,31 @@ function Rt(e, t, s) {
296
296
  source: "web_sdk",
297
297
  category: e,
298
298
  name: t,
299
- sequence: ++Es,
299
+ sequence: ++ks,
300
300
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
301
301
  monotonicMs: performance.now(),
302
302
  data: s
303
303
  };
304
304
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
305
305
  }
306
- const Rs = "https://app.pluno.ai", bs = "gpt-5.6-terra", Ms = 2e4, ks = 1e4, _s = 1e4, Cs = 1e4, Us = 1e4, Ps = 1e3, ae = 3e4, ce = 0.2, le = 6e4, Ds = 15e3, V = 8, vs = "Pluno could not finish this message. Try it again.", Os = "Browser connection was interrupted.", Ns = 15e3, xs = 2e3, Ls = 1e3, qs = 100, ue = 8e3, de = 3, Bs = [300, 1e3], $t = 64e3, bt = 4e3, jt = 30, Fs = 2e3, Hs = 1e3, _e = "Image is too large for model vision input.", Ws = 100, Ce = "pluno.productAgent.state.", vt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", $s = 100;
307
- function Y(e, t = 0) {
306
+ const _s = "https://app.pluno.ai", Cs = "gpt-5.6-terra", Ps = 2e4, Us = 1e4, Ds = 1e4, vs = 1e4, Ns = 1e4, Os = 1e3, ue = 3e4, de = 0.2, he = 6e4, xs = 15e3, Q = 8, Ls = "Pluno could not finish this message. Try it again.", Bs = "Browser connection was interrupted.", qs = 15e3, Hs = 2e3, Ws = 1e3, Fs = 100, pe = 8e3, fe = 3, $s = [300, 1e3], Ce = 50 * 1024 * 1024, js = /* @__PURE__ */ new Set([
307
+ ".jpeg:image/jpeg",
308
+ ".jpg:image/jpeg",
309
+ ".pdf:application/pdf",
310
+ ".png:image/png",
311
+ ".webp:image/webp"
312
+ ]), ni = ".pdf,.png,.jpg,.jpeg,.webp", Kt = 64e3, kt = 4e3, Gt = 30, zs = 2e3, Ks = 1e3, Pe = "Image is too large for model vision input.", Gs = 100, Ue = "pluno.productAgent.state.", Ot = "pluno.productAgent.pendingEvents.", ut = "pluno.productAgent.activeToolCalls.", Xs = 100;
313
+ function tt(e, t = 0) {
308
314
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
309
315
  return Math.max(t, s);
310
316
  }
311
- const st = /* @__PURE__ */ new Set();
312
- let Z = null;
313
- function js(e, t = Math.random) {
314
- const s = Math.min(ae, Ps * 2 ** e), n = 1 - ce + t() * ce * 2;
315
- return Math.min(ae, Math.round(s * n));
317
+ const ot = /* @__PURE__ */ new Set();
318
+ let et = null;
319
+ function Js(e, t = Math.random) {
320
+ const s = Math.min(ue, Os * 2 ** e), n = 1 - de + t() * de * 2;
321
+ return Math.min(ue, Math.round(s * n));
316
322
  }
317
- function zs(e, t, s) {
323
+ function Vs(e, t, s) {
318
324
  return new Promise((n, r) => {
319
325
  const i = setTimeout(() => r(new Error(s)), t);
320
326
  e.then(
@@ -327,13 +333,13 @@ function zs(e, t, s) {
327
333
  );
328
334
  });
329
335
  }
330
- class Ue {
336
+ class De {
331
337
  constructor(t, s) {
332
338
  this.options = t, this.transportIdentity = s, this.state = {
333
339
  ...this.state,
334
- starterPrompts: kn(t.initialStarterPrompts)
340
+ starterPrompts: Un(t.initialStarterPrompts)
335
341
  };
336
- const n = t.restorePersistedState === !1 ? null : gr(t.clientId, t.expectedPersistedSessionId);
342
+ const n = t.restorePersistedState === !1 ? null : Sr(t.clientId, t.expectedPersistedSessionId);
337
343
  n && (this.state = {
338
344
  ...this.state,
339
345
  ...n,
@@ -346,10 +352,10 @@ class Ue {
346
352
  assistantDraftRunId: null,
347
353
  isThinking: !1,
348
354
  lastError: null
349
- }), this.queuedClientEvents = Ar(
350
- yr(t.clientId),
351
- Tr(t.clientId)
352
- ), j(t.clientId, this.queuedClientEvents);
355
+ }), this.queuedClientEvents = _r(
356
+ Er(t.clientId),
357
+ Mr(t.clientId)
358
+ ), z(t.clientId, this.queuedClientEvents);
353
359
  }
354
360
  options;
355
361
  listeners = {};
@@ -393,8 +399,7 @@ class Ue {
393
399
  retryableClientMessageId = null;
394
400
  runtimeHelperJavascript = null;
395
401
  attachmentFiles = /* @__PURE__ */ new Map();
396
- attachmentBlobCache = /* @__PURE__ */ new Map();
397
- sessionUserFilesApiCleanup = null;
402
+ sessionBrowserApisCleanup = null;
398
403
  activeBrowserToolCalls = /* @__PURE__ */ new Map();
399
404
  pendingToolLoadingByCallId = /* @__PURE__ */ new Map();
400
405
  terminalToolCallIds = /* @__PURE__ */ new Set();
@@ -424,15 +429,15 @@ class Ue {
424
429
  lastErrorSecuritySettingsUrl: null
425
430
  };
426
431
  static async init(t) {
427
- const s = await ps(), n = new Ue({
432
+ const s = await ys(), n = new De({
428
433
  ...t,
429
- backendUrl: hn(t.backendUrl ?? Rs),
430
- clientId: t.clientId ?? Dn(),
431
- model: t.model ?? bs,
432
- entrySurface: pn(t.entrySurface)
434
+ backendUrl: mn(t.backendUrl ?? _s),
435
+ clientId: t.clientId ?? xn(),
436
+ model: t.model ?? Cs,
437
+ entrySurface: yn(t.entrySurface)
433
438
  }, s);
434
439
  try {
435
- ss().catch((r) => {
440
+ os().catch((r) => {
436
441
  S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
437
442
  message: r instanceof Error ? r.message : String(r)
438
443
  });
@@ -463,14 +468,14 @@ class Ue {
463
468
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
464
469
  );
465
470
  try {
466
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await zs(this.options.tokenProvider(), _s, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
471
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Vs(this.options.tokenProvider(), Ds, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
467
472
  return;
468
473
  if (!this.token && !this.options.webSocketFactory)
469
474
  throw new Error("Pluno requires a token or tokenProvider");
470
- const s = mn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
475
+ const s = wn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
471
476
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
472
477
  this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
473
- }, Cs), n.addEventListener("open", () => {
478
+ }, vs), n.addEventListener("open", () => {
474
479
  this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
475
480
  queuedClientEventCount: this.queuedClientEvents.length,
476
481
  isThinking: this.state.isThinking
@@ -482,9 +487,9 @@ class Ue {
482
487
  pageUrl: location.href
483
488
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
484
489
  this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
485
- }, Us));
490
+ }, Ns));
486
491
  }), n.addEventListener("message", (r) => {
487
- this.socket === n && this.handleServerEvent(Mn(r.data));
492
+ this.socket === n && this.handleServerEvent(Pn(r.data));
488
493
  }), n.addEventListener("close", (r) => {
489
494
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
490
495
  code: typeof r?.code == "number" ? r.code : null,
@@ -517,7 +522,7 @@ class Ue {
517
522
  this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), 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.pendingWarmupEvent = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
518
523
  }
519
524
  destroy() {
520
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Er(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
525
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Cr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
521
526
  for (const t of Object.values(this.listeners))
522
527
  t?.clear();
523
528
  }
@@ -527,22 +532,27 @@ class Ue {
527
532
  reason: t,
528
533
  entrySurface: this.options.entrySurface,
529
534
  sessionId: this.state.sessionId ?? void 0,
530
- page: M()
535
+ page: b()
531
536
  };
532
537
  this.sendNow(s) || (this.pendingWarmupEvent = s);
533
538
  }
534
539
  async sendMessage(t, s = {}) {
535
540
  const n = t.trim(), r = s.attachments ?? [];
536
- let i = r.map(Xt);
541
+ if (!this.options.persistAttachmentUpload && (r.forEach(Ke), r.reduce(
542
+ (g, A) => g + A.sizeBytes,
543
+ 0
544
+ ) > Ce))
545
+ throw new Error("Embedded attachments must total at most 50 MB per message");
546
+ let i = r.map(Yt);
537
547
  if (!n && i.length === 0)
538
548
  return null;
539
- const o = M(), a = s.clientMessageId ?? $(), c = {
549
+ const o = b(), a = s.clientMessageId ?? j(), c = {
540
550
  id: `local-${a}`,
541
551
  role: "user",
542
552
  content: n,
543
553
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
544
554
  ...r.length > 0 ? { attachments: r } : {}
545
- }, l = this.state.messages.some((p) => p.id === c.id || p.clientMessageId === a), h = this.state.isThinking, f = this.state.messages, I = l ? this.state.messages : [...this.state.messages, c], g = {
555
+ }, l = this.state.messages.some((p) => p.id === c.id || p.clientMessageId === a), h = this.state.isThinking, f = this.state.messages, I = l ? this.state.messages : [...this.state.messages, c], m = {
546
556
  assistantDraft: this.state.assistantDraft,
547
557
  assistantDraftItemId: this.state.assistantDraftItemId,
548
558
  assistantDraftPhase: this.state.assistantDraftPhase,
@@ -564,21 +574,21 @@ class Ue {
564
574
  }), l || this.emit("message", c);
565
575
  try {
566
576
  const p = [];
567
- for (const m of i) {
568
- const E = m.id ? this.attachmentFiles.get(m.id) : void 0;
569
- if (m.sandboxPath) {
570
- p.push(m);
577
+ for (const g of i) {
578
+ const A = g.id ? this.attachmentFiles.get(g.id) : void 0;
579
+ if (g.sandboxPath || g.storageKey) {
580
+ p.push(g);
571
581
  continue;
572
582
  }
573
- if (!E)
574
- throw new Error(`Attachment bytes are unavailable for ${m.name}`);
575
- p.push(await this.uploadAttachmentForMessage({ file: E, attachment: m }));
583
+ if (!A)
584
+ throw new Error(`Attachment bytes are unavailable for ${g.name}`);
585
+ p.push(await this.uploadAttachmentForMessage({ file: A, attachment: g }));
576
586
  }
577
587
  i = p;
578
588
  } catch (p) {
579
589
  throw this.setState({
580
590
  ...l ? {} : { messages: f },
581
- ...h ? {} : { ...g, isThinking: !1 }
591
+ ...h ? {} : { ...m, isThinking: !1 }
582
592
  }), p;
583
593
  }
584
594
  this.retryableClientMessageId = null;
@@ -587,14 +597,14 @@ class Ue {
587
597
  sessionId: this.state.sessionId ?? void 0,
588
598
  clientMessageId: a,
589
599
  initiatedBy: s.initiatedBy,
590
- invocation: fn(s.invocation ?? s.initiatedBy),
600
+ invocation: In(s.invocation ?? s.initiatedBy),
591
601
  entrySurface: this.options.entrySurface,
592
602
  content: n,
593
- pageContent: u && zt() || void 0,
603
+ pageContent: u && Xt() || void 0,
594
604
  attachments: i.length > 0 ? i : void 0,
595
605
  page: o,
596
606
  model: this.options.model,
597
- metadata: he(this.options.metadata)
607
+ metadata: ge(this.options.metadata)
598
608
  };
599
609
  return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.browserConnectionInterruptedClientMessageIds.delete(a), this.markThinkingProgress(), this.send(d), a;
600
610
  }
@@ -603,21 +613,22 @@ class Ue {
603
613
  return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(s), this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
604
614
  }
605
615
  createLocalAttachment(t) {
606
- const s = $(), n = {
616
+ this.options.persistAttachmentUpload || Pr(t);
617
+ const s = j(), n = {
607
618
  id: s,
608
619
  name: t.name || "attachment",
609
- mimeType: Ae(t),
620
+ mimeType: Ft(t),
610
621
  sizeBytes: t.size
611
622
  };
612
- this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
623
+ this.attachmentFiles.set(s, t);
613
624
  const r = Date.now();
614
- return ts({
625
+ return rs({
615
626
  attachmentId: s,
616
627
  name: n.name,
617
628
  mimeType: n.mimeType,
618
629
  sizeBytes: n.sizeBytes,
619
630
  blob: t,
620
- origin: M().origin,
631
+ origin: b().origin,
621
632
  sessionId: this.state.sessionId ?? void 0,
622
633
  createdAt: r,
623
634
  lastUsedAt: r
@@ -640,7 +651,7 @@ class Ue {
640
651
  file: t,
641
652
  attachment: s
642
653
  }) {
643
- const n = this.state.sessionId, r = Ae(t), i = {
654
+ const n = this.state.sessionId, r = Ft(t), i = {
644
655
  sessionId: n ?? void 0,
645
656
  attachmentId: s.id,
646
657
  clientId: this.options.clientId,
@@ -648,39 +659,40 @@ class Ue {
648
659
  name: t.name || "attachment",
649
660
  mimeType: r,
650
661
  sizeBytes: t.size,
651
- page: M(),
662
+ page: b(),
652
663
  model: this.options.model,
653
- metadata: he(this.options.metadata),
664
+ metadata: ge(this.options.metadata),
654
665
  entrySurface: this.options.entrySurface
655
666
  };
656
667
  let o;
657
668
  if (this.options.persistAttachmentUpload)
658
- o = await tt(
669
+ o = await rt(
659
670
  () => this.options.persistAttachmentUpload(i, t),
660
671
  "Failed to upload attachment"
661
672
  );
662
673
  else {
663
- const c = this.options.prepareAttachmentUpload ? await tt(
674
+ const c = this.options.prepareAttachmentUpload ? await rt(
664
675
  () => this.options.prepareAttachmentUpload(i),
665
676
  "Failed to prepare attachment upload"
666
677
  ) : await this.prepareEmbedAttachmentUpload(i);
667
- await tt(async () => {
678
+ await rt(async () => {
668
679
  const l = await fetch(new URL(c.uploadUrl, this.options.backendUrl), {
669
680
  method: c.uploadMethod,
670
681
  headers: c.uploadHeaders,
671
682
  body: t
672
683
  });
673
684
  if (!l.ok)
674
- throw new nt("Failed to upload attachment", l.status);
685
+ throw new at("Failed to upload attachment", l.status);
675
686
  return l;
676
687
  }, "Failed to upload attachment"), o = c;
677
688
  }
678
689
  this.setState({ sessionId: o.sessionId });
679
- const a = We(o.attachment, this.options.backendUrl);
680
- return this.updateAttachmentInState(s.id, a), s.id && es(s.id, {
690
+ const a = ze(o.attachment, this.options.backendUrl);
691
+ return this.updateAttachmentInState(s.id, a), s.id && is(s.id, {
681
692
  sessionId: o.sessionId,
682
693
  fileUrl: a.fileUrl,
683
694
  sandboxPath: a.sandboxPath,
695
+ storageKey: a.storageKey,
684
696
  lastUsedAt: Date.now()
685
697
  }).catch((c) => {
686
698
  S("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
@@ -703,18 +715,18 @@ class Ue {
703
715
  }
704
716
  async prepareEmbedAttachmentUpload(t) {
705
717
  let s = !1;
706
- return await tt(async () => {
718
+ return await rt(async () => {
707
719
  const n = await this.fetchEmbedAttachmentUpload(t);
708
720
  if (n.ok)
709
721
  return await n.json();
710
- if (Br(n.status) && this.options.tokenProvider && !s) {
722
+ if (Gr(n.status) && this.options.tokenProvider && !s) {
711
723
  s = !0;
712
724
  const r = await this.fetchEmbedAttachmentUpload(t);
713
725
  if (r.ok)
714
726
  return await r.json();
715
- throw new nt("Failed to prepare attachment upload", r.status);
727
+ throw new at("Failed to prepare attachment upload", r.status);
716
728
  }
717
- throw new nt("Failed to prepare attachment upload", n.status);
729
+ throw new at("Failed to prepare attachment upload", n.status);
718
730
  }, "Failed to prepare attachment upload");
719
731
  }
720
732
  async fetchEmbedAttachmentUpload(t) {
@@ -729,14 +741,30 @@ class Ue {
729
741
  });
730
742
  }
731
743
  stop() {
732
- this.state.sessionId && (this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" }), this.setState({ isThinking: !1 }), this.clearThinkingWatchdog());
744
+ if (!this.state.sessionId)
745
+ return;
746
+ this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
747
+ const t = hr(
748
+ this.state.messages,
749
+ this.state.assistantDraftRespondsToUserMessageId,
750
+ this.state.assistantDraftRunId,
751
+ this.activeClientMessageId
752
+ );
753
+ this.setState({
754
+ messages: nt(
755
+ this.state.messages,
756
+ t.clientMessageId,
757
+ t.runId
758
+ ),
759
+ isThinking: !1
760
+ }), this.clearThinkingWatchdog();
733
761
  }
734
762
  startNewSession(t = {}) {
735
763
  const s = t.notifyTransport !== !1;
736
- !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
764
+ !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
737
765
  type: "session.reset",
738
766
  sessionId: this.state.sessionId ?? void 0,
739
- page: M()
767
+ page: b()
740
768
  }), this.setState({
741
769
  sessionId: null,
742
770
  starterPrompts: [...this.state.starterPrompts],
@@ -751,15 +779,15 @@ class Ue {
751
779
  });
752
780
  }
753
781
  listSessions(t = {}) {
754
- const s = $(), n = new Promise((i, o) => {
782
+ const s = j(), n = new Promise((i, o) => {
755
783
  const a = window.setTimeout(() => {
756
784
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
757
- }, ue);
785
+ }, pe);
758
786
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
759
787
  }), r = {
760
788
  type: "sessions.list",
761
789
  requestId: s,
762
- page: M(),
790
+ page: b(),
763
791
  ...t.cursor ? { cursor: t.cursor } : {},
764
792
  ...t.limit ? { limit: t.limit } : {},
765
793
  ...typeof t.pinned == "boolean" ? { pinned: t.pinned } : {}
@@ -773,14 +801,14 @@ class Ue {
773
801
  setSessionPinned(t, s) {
774
802
  return this.sendSessionMutation(
775
803
  this.pendingSessionPinRequests,
776
- { type: "session.pin", requestId: $(), sessionId: t, pinned: s },
804
+ { type: "session.pin", requestId: j(), sessionId: t, pinned: s },
777
805
  "Session pin did not respond in time"
778
806
  );
779
807
  }
780
808
  renameSession(t, s) {
781
809
  return this.sendSessionMutation(
782
810
  this.pendingSessionRenameRequests,
783
- { type: "session.rename", requestId: $(), sessionId: t, title: s },
811
+ { type: "session.rename", requestId: j(), sessionId: t, title: s },
784
812
  "Session rename did not respond in time"
785
813
  );
786
814
  }
@@ -798,11 +826,11 @@ class Ue {
798
826
  }), this.send({
799
827
  type: "session.load",
800
828
  sessionId: t,
801
- page: M()
829
+ page: b()
802
830
  });
803
831
  }
804
832
  send(t) {
805
- this.sendNow(_(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
833
+ this.sendNow(_(t)) || (this.queuedClientEvents.push(t), z(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
806
834
  }
807
835
  async getUploadToken() {
808
836
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -815,7 +843,7 @@ class Ue {
815
843
  return !1;
816
844
  const s = this.socket;
817
845
  try {
818
- return s.send(JSON.stringify(t)), Rt("client_event", t.type, oe(t)), !0;
846
+ return s.send(JSON.stringify(t)), bt("client_event", t.type, le(t)), !0;
819
847
  } catch (n) {
820
848
  return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
821
849
  message: n instanceof Error ? n.message : String(n),
@@ -828,7 +856,7 @@ class Ue {
828
856
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
829
857
  return;
830
858
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
831
- const t = yn();
859
+ const t = Sn();
832
860
  this.sendNow(
833
861
  _({
834
862
  type: "starter_prompts.page_context",
@@ -839,13 +867,13 @@ class Ue {
839
867
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
840
868
  }
841
869
  startStarterPromptUrlWatcher() {
842
- this.locationChangeCleanup || (this.locationChangeCleanup = In(() => this.handleStarterPromptUrlChange()));
870
+ this.locationChangeCleanup || (this.locationChangeCleanup = An(() => this.handleStarterPromptUrlChange()));
843
871
  }
844
872
  handleStarterPromptUrlChange() {
845
873
  const t = location.href;
846
874
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
847
875
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
848
- }, $s));
876
+ }, Xs));
849
877
  }
850
878
  refreshStarterPromptsForCurrentUrl() {
851
879
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -860,27 +888,27 @@ class Ue {
860
888
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
861
889
  return;
862
890
  const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
863
- j(this.options.clientId, this.queuedClientEvents);
891
+ z(this.options.clientId, this.queuedClientEvents);
864
892
  for (let s = 0; s < t.length; s += 1) {
865
893
  const n = t[s];
866
894
  if (!this.sendNow(_(n))) {
867
- this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), j(this.options.clientId, this.queuedClientEvents);
895
+ this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), z(this.options.clientId, this.queuedClientEvents);
868
896
  return;
869
897
  }
870
- j(this.options.clientId, this.queuedClientEvents);
898
+ z(this.options.clientId, this.queuedClientEvents);
871
899
  }
872
900
  }
873
901
  flushPendingWarmupEvent() {
874
902
  !this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
875
903
  }
876
904
  handleServerEvent(t) {
877
- if (Rt("server_event", t.type, oe(t)), t.type === "run.ack") {
878
- const s = kt(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
905
+ if (bt("server_event", t.type, le(t)), t.type === "run.ack") {
906
+ const s = Ct(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
879
907
  s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && n === this.activeClientMessageId && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(t);
880
908
  return;
881
909
  }
882
910
  if (t.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
883
- const s = kt(t);
911
+ const s = Ct(t);
884
912
  if (s) {
885
913
  this.deferredSessionUpdatedSessionIds.add(s);
886
914
  return;
@@ -895,67 +923,67 @@ class Ue {
895
923
  this.clearHeartbeatAckTimer();
896
924
  return;
897
925
  }
898
- if (Xs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
926
+ if (Qs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
899
927
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
900
- const s = _n(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
928
+ const s = Dn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
901
929
  S("web-sdk.agent", "Received auth.ok appearance", {
902
930
  hasAppearance: n,
903
931
  rawAppearance: t.appearance,
904
932
  normalizedAppearance: s
905
- }), this.runtimeHelperJavascript = Cn(t.runtimeHelpers)?.javascript ?? null;
906
- const r = ge(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
907
- user: vn(t.user),
933
+ }), this.runtimeHelperJavascript = vn(t.runtimeHelpers)?.javascript ?? null;
934
+ const r = Ie(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
935
+ user: Ln(t.user),
908
936
  status: "connected",
909
937
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
910
938
  };
911
- (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !wn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
939
+ (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !Rn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
912
940
  type: "page.upsert",
913
941
  sessionId: this.state.sessionId,
914
- page: M(),
942
+ page: b(),
915
943
  model: this.options.model
916
944
  });
917
945
  return;
918
946
  }
919
947
  if (t.type === "starterPrompts.updated") {
920
948
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
921
- starterPrompts: ge(t, "starterPrompts"),
949
+ starterPrompts: Ie(t, "starterPrompts"),
922
950
  starterPromptsLoading: !1
923
951
  });
924
952
  return;
925
953
  }
926
954
  if (t.type === "conversation.state") {
927
- const s = Array.isArray(t.items) ? t.items : [], n = Hn(
955
+ const s = Array.isArray(t.items) ? t.items : [], n = zn(
928
956
  t.assistantDraft
929
957
  ), r = n !== void 0;
930
958
  this.rememberUserMessageClientMessageIds(s);
931
- const i = nr(s);
959
+ const i = ar(s);
932
960
  if (i) {
933
- const p = rr(s, i);
961
+ const p = cr(s, i);
934
962
  this.retryAttemptsByClientMessageId[i] = Math.max(
935
963
  this.retryAttemptsByClientMessageId[i] ?? 0,
936
964
  p
937
965
  );
938
966
  }
939
967
  const o = s.filter((p) => {
940
- const m = q(p);
941
- return !ye(m) && (!i || !Lt(m));
942
- }), a = Vn(
968
+ const g = B(p);
969
+ return we(g) ? !1 : !g || !i || !Bt(g) ? !0 : Ht(s, g) !== i;
970
+ }), a = tr(
943
971
  this.state.messages,
944
- On(o, this.options.backendUrl)
945
- ), c = me(a), l = !r && s.some(
946
- (p) => Te(
947
- q(p),
972
+ Bn(o, this.options.backendUrl)
973
+ ), c = Te(a), l = !r && s.some(
974
+ (p) => Se(
975
+ B(p),
948
976
  this.state.assistantDraft,
949
977
  this.state.assistantDraftItemId,
950
978
  this.state.assistantDraftRespondsToUserMessageId,
951
979
  this.state.assistantDraftRunId
952
980
  )
953
- ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = tr(a), u = I && g;
954
- if (!c && sr(this.state.messages, s))
981
+ ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), m = rr(a), u = I && m;
982
+ if (!c && or(this.state.messages, s))
955
983
  return;
956
- this.lastUserMessagePageUrl = er(s);
984
+ this.lastUserMessagePageUrl = ir(s);
957
985
  const d = I ? null : qt(s);
958
- if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
986
+ if (this.latestRecoverableClientMessageId = d, m && this.clearRetryTimers(), this.setState({
959
987
  sessionId: R(t.session, "id") ?? this.state.sessionId,
960
988
  messages: a,
961
989
  ...r ? {
@@ -995,7 +1023,7 @@ class Ue {
995
1023
  if (t.type === "sessions.page") {
996
1024
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
997
1025
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
998
- sessions: Nn(t.sessions),
1026
+ sessions: qn(t.sessions),
999
1027
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
1000
1028
  }));
1001
1029
  return;
@@ -1014,10 +1042,10 @@ class Ue {
1014
1042
  }
1015
1043
  if (t.type === "session.item") {
1016
1044
  this.rememberUserMessageClientMessageIds([t.item]);
1017
- const s = q(t.item);
1018
- if (Lt(s)) {
1045
+ const s = B(t.item);
1046
+ if (Bt(s)) {
1019
1047
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1020
- const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1048
+ const r = R(t.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);
1021
1049
  if (r && a) {
1022
1050
  this.retryAfterInterruptedRun(r, a);
1023
1051
  return;
@@ -1027,21 +1055,21 @@ class Ue {
1027
1055
  return;
1028
1056
  }
1029
1057
  }
1030
- if (ye(s))
1058
+ if (we(s))
1031
1059
  return;
1032
- const n = Ne(t.item, this.options.backendUrl);
1060
+ const n = Le(t.item, this.options.backendUrl);
1033
1061
  if (n) {
1034
1062
  const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1035
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1063
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), O(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1036
1064
  const i = t.item.data;
1037
- or(i) && this.clearRunAckResyncRetryTimer();
1038
- const o = Ot(this.state.messages, n), a = me(o), c = Te(
1065
+ ur(i) && this.clearRunAckResyncRetryTimer();
1066
+ const o = xt(this.state.messages, n), a = Te(o), c = Se(
1039
1067
  i,
1040
1068
  this.state.assistantDraft,
1041
1069
  this.state.assistantDraftItemId,
1042
1070
  this.state.assistantDraftRespondsToUserMessageId,
1043
1071
  this.state.assistantDraftRunId
1044
- ), l = a && (!this.state.assistantDraft || c), h = l && N(n);
1072
+ ), l = a && (!this.state.assistantDraft || c), h = l && O(n);
1045
1073
  this.setState({
1046
1074
  messages: o,
1047
1075
  ...c ? {
@@ -1068,7 +1096,7 @@ class Ue {
1068
1096
  this.clearRunAckResyncRetryTimer();
1069
1097
  const s = typeof t.delta == "string" ? t.delta : "", n = typeof t.itemId == "string" ? t.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((f) => f.id === o), c = t.phase === "commentary" || t.phase === "final_answer" ? t.phase : r ? null : this.state.assistantDraftPhase, l = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
1070
1098
  this.setState({
1071
- messages: Ot(this.state.messages, {
1099
+ messages: xt(this.state.messages, {
1072
1100
  id: o,
1073
1101
  role: "assistant",
1074
1102
  content: i,
@@ -1094,9 +1122,9 @@ class Ue {
1094
1122
  const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null, r = typeof t.runId == "string" ? t.runId : null;
1095
1123
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
1096
1124
  return;
1097
- const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = cs(
1125
+ const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = hs(
1098
1126
  this.state.messages.filter(
1099
- (l) => l.dataType !== "assistant_draft" || !jn(
1127
+ (l) => l.dataType !== "assistant_draft" || !Xn(
1100
1128
  l,
1101
1129
  n,
1102
1130
  r
@@ -1104,11 +1132,11 @@ class Ue {
1104
1132
  ),
1105
1133
  n,
1106
1134
  r,
1107
- xe
1135
+ Be
1108
1136
  );
1109
1137
  this.setState({
1110
1138
  sessionId: s,
1111
- messages: zn(
1139
+ messages: Jn(
1112
1140
  c,
1113
1141
  typeof t.responseId == "string" ? t.responseId : null,
1114
1142
  n,
@@ -1129,9 +1157,9 @@ class Ue {
1129
1157
  if (s)
1130
1158
  this.nonTranscriptToolCallIds.add(s);
1131
1159
  else {
1132
- const n = Xn(t);
1160
+ const n = Zn(t);
1133
1161
  if (n) {
1134
- const r = Kn(
1162
+ const r = Vn(
1135
1163
  this.state.messages,
1136
1164
  n
1137
1165
  );
@@ -1175,8 +1203,13 @@ class Ue {
1175
1203
  return;
1176
1204
  }
1177
1205
  o && r && i && (this.retryableClientMessageId = i);
1178
- const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = gn(a.message);
1206
+ const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = Tn(a.message);
1179
1207
  c && console.error(c), this.setState({
1208
+ messages: nt(
1209
+ this.state.messages,
1210
+ i ?? this.activeClientMessageId,
1211
+ typeof t.runId == "string" ? t.runId : null
1212
+ ),
1180
1213
  status: "error",
1181
1214
  isThinking: !1,
1182
1215
  lastError: a.message,
@@ -1187,9 +1220,9 @@ class Ue {
1187
1220
  }
1188
1221
  }
1189
1222
  shouldIgnoreBackgroundSessionEvent(t) {
1190
- if (!this.options.keepRunsActiveOnSessionNavigation || !Js(t))
1223
+ if (!this.options.keepRunsActiveOnSessionNavigation || !tn(t))
1191
1224
  return !1;
1192
- const s = kt(t);
1225
+ const s = Ct(t);
1193
1226
  return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
1194
1227
  }
1195
1228
  rememberCurrentRunAsBackground() {
@@ -1211,10 +1244,10 @@ class Ue {
1211
1244
  if (this.retryTimersByClientMessageId[n] !== void 0)
1212
1245
  return !0;
1213
1246
  const i = this.retryAttemptsByClientMessageId[n] ?? 0;
1214
- if (i >= V)
1247
+ if (i >= Q)
1215
1248
  return !1;
1216
1249
  this.retryAttemptsByClientMessageId[n] = i + 1;
1217
- const o = Y(
1250
+ const o = tt(
1218
1251
  i,
1219
1252
  typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
1220
1253
  );
@@ -1231,8 +1264,13 @@ class Ue {
1231
1264
  if (this.retryTimersByClientMessageId[s] !== void 0)
1232
1265
  return;
1233
1266
  const n = this.retryAttemptsByClientMessageId[s] ?? 0;
1234
- if (n >= V) {
1267
+ if (n >= Q) {
1235
1268
  this.retryableClientMessageId = s, this.setState({
1269
+ messages: nt(
1270
+ this.state.messages,
1271
+ s,
1272
+ null
1273
+ ),
1236
1274
  isThinking: !1,
1237
1275
  lastError: this.getRunRecoveryExhaustedErrorMessage(s),
1238
1276
  lastErrorCode: "run_recovery_exhausted"
@@ -1241,7 +1279,7 @@ class Ue {
1241
1279
  }
1242
1280
  this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
1243
1281
  delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !0 });
1244
- }, Y(n));
1282
+ }, tt(n));
1245
1283
  }
1246
1284
  clearRetryTimers() {
1247
1285
  for (const t of Object.values(this.retryTimersByClientMessageId))
@@ -1250,7 +1288,7 @@ class Ue {
1250
1288
  }
1251
1289
  rememberUserMessageClientMessageIds(t) {
1252
1290
  for (const s of t) {
1253
- const n = R(s, "id"), r = q(s);
1291
+ const n = R(s, "id"), r = B(s);
1254
1292
  n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
1255
1293
  }
1256
1294
  }
@@ -1263,7 +1301,7 @@ class Ue {
1263
1301
  const r = new Promise((i, o) => {
1264
1302
  const a = window.setTimeout(() => {
1265
1303
  t.delete(s.requestId), o(new Error(n));
1266
- }, ue);
1304
+ }, pe);
1267
1305
  t.set(s.requestId, { resolve: i, reject: o, timeout: a });
1268
1306
  });
1269
1307
  if (!this.sendNow(s)) {
@@ -1286,7 +1324,7 @@ class Ue {
1286
1324
  t.clear();
1287
1325
  }
1288
1326
  markThinkingProgress() {
1289
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(le), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1327
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(he), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1290
1328
  }
1291
1329
  scheduleThinkingWatchdog(t) {
1292
1330
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1306,7 +1344,7 @@ class Ue {
1306
1344
  handleRunSteered(t) {
1307
1345
  const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
1308
1346
  !this.state.isThinking || !s || this.setState({
1309
- messages: cr(
1347
+ messages: fr(
1310
1348
  this.state.messages,
1311
1349
  s
1312
1350
  )
@@ -1315,7 +1353,7 @@ class Ue {
1315
1353
  scheduleRunAckWatchdog(t) {
1316
1354
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1317
1355
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1318
- }, Ns);
1356
+ }, qs);
1319
1357
  }
1320
1358
  recoverMissedRunAck(t) {
1321
1359
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
@@ -1326,7 +1364,7 @@ class Ue {
1326
1364
  scheduleRunAckResyncRetry(t) {
1327
1365
  this.clearRunAckResyncRetryTimer();
1328
1366
  const s = this.retryAttemptsByClientMessageId[t] ?? 0;
1329
- s >= V || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1367
+ s >= Q || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1330
1368
  this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
1331
1369
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1332
1370
  isThinking: !0,
@@ -1339,8 +1377,8 @@ class Ue {
1339
1377
  sessionId: this.state.sessionId,
1340
1378
  clientMessageId: t,
1341
1379
  automatic: !0
1342
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(le)));
1343
- }, Y(s, xs)));
1380
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(he)));
1381
+ }, tt(s, Hs)));
1344
1382
  }
1345
1383
  clearRunAckResyncRetryTimer() {
1346
1384
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1363,11 +1401,16 @@ class Ue {
1363
1401
  return;
1364
1402
  }
1365
1403
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
1366
- if (n >= V) {
1404
+ if (n >= Q) {
1367
1405
  S("web-sdk.agent", "Pluno run recovery retry exhausted", {
1368
1406
  sessionId: this.state.sessionId,
1369
1407
  clientMessageId: t
1370
1408
  }), this.retryableClientMessageId = t, this.setState({
1409
+ messages: nt(
1410
+ this.state.messages,
1411
+ t,
1412
+ null
1413
+ ),
1371
1414
  isThinking: !1,
1372
1415
  lastError: this.getRunRecoveryExhaustedErrorMessage(t),
1373
1416
  lastErrorCode: "run_recovery_exhausted"
@@ -1379,7 +1422,7 @@ class Ue {
1379
1422
  sessionId: this.state.sessionId,
1380
1423
  clientMessageId: t,
1381
1424
  resyncAttempts: s + 1
1382
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ds);
1425
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(xs);
1383
1426
  return;
1384
1427
  }
1385
1428
  this.setState({
@@ -1397,13 +1440,13 @@ class Ue {
1397
1440
  clientMessageId: t,
1398
1441
  automatic: !0
1399
1442
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
1400
- }, Y(n)));
1443
+ }, tt(n)));
1401
1444
  }
1402
1445
  resyncThinkingSession() {
1403
1446
  this.state.sessionId ? this.send({
1404
1447
  type: "page.upsert",
1405
1448
  sessionId: this.state.sessionId,
1406
- page: M(),
1449
+ page: b(),
1407
1450
  model: this.options.model
1408
1451
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
1409
1452
  }
@@ -1414,7 +1457,7 @@ class Ue {
1414
1457
  if (!s || !n || !r)
1415
1458
  return;
1416
1459
  const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1417
- if (!a && !c || !kr(o)) {
1460
+ if (!a && !c || !Or(o)) {
1418
1461
  this.setToolMessageLoading(n, !1), this.send({
1419
1462
  type: "tool.result",
1420
1463
  sessionId: s,
@@ -1446,7 +1489,6 @@ class Ue {
1446
1489
  });
1447
1490
  return;
1448
1491
  }
1449
- const l = Zs(this.state.messages);
1450
1492
  this.activeBrowserToolCalls.set(n, {
1451
1493
  event: {
1452
1494
  type: "tool.result",
@@ -1460,15 +1502,15 @@ class Ue {
1460
1502
  startedAtMs: Date.now(),
1461
1503
  startedAtUrl: location.href,
1462
1504
  startedAtOrigin: location.origin
1463
- }), this.installSessionUserFilesApi(l);
1464
- let h = null, f;
1465
- h = await this.executeRuntimeHelper(), f = await pe(
1505
+ }), this.installSessionBrowserApis();
1506
+ let l = null, h;
1507
+ l = await this.executeRuntimeHelper(), h = await me(
1466
1508
  o,
1467
- un(t.runtimeContext, this.options.backendUrl)
1468
- ).catch((I) => ({
1509
+ fn(t.runtimeContext, this.options.backendUrl)
1510
+ ).catch((f) => ({
1469
1511
  ok: !1,
1470
1512
  exception: {
1471
- message: I instanceof Error ? I.message : String(I)
1513
+ message: f instanceof Error ? f.message : String(f)
1472
1514
  }
1473
1515
  })), this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
1474
1516
  type: "tool.result",
@@ -1477,11 +1519,11 @@ class Ue {
1477
1519
  toolName: r,
1478
1520
  summary: o.summary,
1479
1521
  rawInput: _(o),
1480
- rawOutput: _(Un(f, h))
1481
- }), Ir(this.options.clientId, this.activeBrowserToolCalls.values());
1522
+ rawOutput: _(Nn(h, l))
1523
+ }), Rr(this.options.clientId, this.activeBrowserToolCalls.values());
1482
1524
  }
1483
1525
  setToolMessageLoading(t, s) {
1484
- const n = Gn(
1526
+ const n = Yn(
1485
1527
  this.state.messages,
1486
1528
  t,
1487
1529
  s
@@ -1492,47 +1534,47 @@ class Ue {
1492
1534
  if (this.pageLifecycleCleanup)
1493
1535
  return;
1494
1536
  const t = () => {
1495
- Fe(this.options.clientId, this.activeBrowserToolCalls.values());
1537
+ $e(this.options.clientId, this.activeBrowserToolCalls.values());
1496
1538
  };
1497
1539
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1498
1540
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1499
1541
  };
1500
1542
  }
1501
- installSessionUserFilesApi(t) {
1502
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Qs(t, this.attachmentFiles, this.attachmentBlobCache);
1543
+ installSessionBrowserApis() {
1544
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = nn();
1503
1545
  }
1504
- cleanupSessionUserFilesApi() {
1505
- this.sessionUserFilesApiCleanup && (cn(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1546
+ cleanupSessionBrowserApis() {
1547
+ this.sessionBrowserApisCleanup && (hn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
1506
1548
  }
1507
1549
  async executeRuntimeHelper() {
1508
1550
  if (!this.runtimeHelperJavascript?.trim())
1509
1551
  return null;
1510
- const t = await pe({
1552
+ const t = await me({
1511
1553
  javascript: this.runtimeHelperJavascript
1512
1554
  });
1513
- return t.ok === !1 ? Pn(t) : null;
1555
+ return t.ok === !1 ? On(t) : null;
1514
1556
  }
1515
1557
  enableNetworkCapture() {
1516
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Ks((t) => {
1517
- vr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1558
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = Ys((t) => {
1559
+ Wr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1518
1560
  }));
1519
1561
  }
1520
1562
  enqueueNetworkEvent(t) {
1521
- this.queuedNetworkEvents.length >= qs || (this.queuedNetworkEvents.push(Dr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1563
+ this.queuedNetworkEvents.length >= Fs || (this.queuedNetworkEvents.push(Hr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1522
1564
  this.networkBatchTimer = null;
1523
1565
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1524
1566
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
1525
1567
  type: "network.batch",
1526
1568
  sessionId: this.state.sessionId ?? void 0,
1527
- page: M(),
1569
+ page: b(),
1528
1570
  events: s
1529
1571
  });
1530
- }, Ls)));
1572
+ }, Ws)));
1531
1573
  }
1532
1574
  scheduleReconnect() {
1533
1575
  if (this.reconnectTimer !== null || this.state.status === "closed")
1534
1576
  return;
1535
- const t = js(this.reconnectAttempts);
1577
+ const t = Js(this.reconnectAttempts);
1536
1578
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1537
1579
  this.reconnectTimer = null, this.connect().catch((s) => {
1538
1580
  S("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1548,8 +1590,8 @@ class Ue {
1548
1590
  const t = this.socket;
1549
1591
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1550
1592
  this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1551
- }, ks));
1552
- }, Ms);
1593
+ }, Us));
1594
+ }, Ps);
1553
1595
  }
1554
1596
  stopHeartbeat() {
1555
1597
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1575,7 +1617,7 @@ class Ue {
1575
1617
  ...t,
1576
1618
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1577
1619
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1578
- }, mr(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
1620
+ }, Ar(this.options.clientId, this.state), this.emit("state", this.getState()), bt("state", this.state.status, {
1579
1621
  status: this.state.status,
1580
1622
  sessionId: this.state.sessionId,
1581
1623
  messageCount: this.state.messages.length,
@@ -1592,52 +1634,52 @@ class Ue {
1592
1634
  this.state.isThinking && this.activeClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId);
1593
1635
  }
1594
1636
  getRunRecoveryExhaustedErrorMessage(t) {
1595
- return t && this.browserConnectionInterruptedClientMessageIds.has(t) ? Os : vs;
1637
+ return t && this.browserConnectionInterruptedClientMessageIds.has(t) ? Bs : Ls;
1596
1638
  }
1597
1639
  emit(t, s) {
1598
1640
  this.listeners[t]?.forEach((r) => r(s));
1599
1641
  }
1600
1642
  }
1601
- const Mt = /* @__PURE__ */ new WeakMap();
1602
- function Ks(e) {
1603
- const t = window.__plunoProductAgentNetworkCapture ?? Gs();
1643
+ const _t = /* @__PURE__ */ new WeakMap();
1644
+ function Ys(e) {
1645
+ const t = window.__plunoProductAgentNetworkCapture ?? Zs();
1604
1646
  return t.subscribers.add(e), () => {
1605
1647
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1606
1648
  };
1607
1649
  }
1608
- function Gs() {
1650
+ function Zs() {
1609
1651
  const e = /* @__PURE__ */ new Set(), t = (I) => {
1610
- e.forEach((g) => {
1652
+ e.forEach((m) => {
1611
1653
  try {
1612
- g(I);
1654
+ m(I);
1613
1655
  } catch {
1614
1656
  }
1615
1657
  });
1616
- }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(g, u) {
1658
+ }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(m, u) {
1617
1659
  const d = Date.now();
1618
1660
  let p;
1619
1661
  try {
1620
- p = s.call(this, g, u);
1621
- } catch (m) {
1622
- throw m;
1662
+ p = s.call(this, m, u);
1663
+ } catch (g) {
1664
+ throw g;
1623
1665
  }
1624
1666
  try {
1625
- const m = g instanceof Request ? g : null, E = _r(g, m), T = $e(u?.headers ?? m?.headers);
1626
- if (!x(E, T, u?.body)) {
1627
- const F = {
1628
- requestId: Ut("fetch"),
1629
- url: U(E, bt),
1630
- method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
1667
+ const g = m instanceof Request ? m : null, A = xr(m, g), T = Ge(u?.headers ?? g?.headers);
1668
+ if (!x(A, T, u?.body)) {
1669
+ const W = {
1670
+ requestId: Dt("fetch"),
1671
+ url: P(A, kt),
1672
+ method: (u?.method ?? g?.method ?? "GET").toUpperCase(),
1631
1673
  requestHeaders: T,
1632
- requestBody: Ee(u?.body),
1674
+ requestBody: Re(u?.body),
1633
1675
  resourceType: "fetch",
1634
1676
  startedAt: new Date(d).toISOString()
1635
1677
  };
1636
1678
  p.then(
1637
1679
  (C) => {
1638
- Cr(C, F, d, t).catch(() => {
1680
+ Lr(C, W, d, t).catch(() => {
1639
1681
  t({
1640
- ...F,
1682
+ ...W,
1641
1683
  responseStatus: C.status,
1642
1684
  durationMs: Date.now() - d
1643
1685
  });
@@ -1645,8 +1687,8 @@ function Gs() {
1645
1687
  },
1646
1688
  (C) => {
1647
1689
  t({
1648
- ...F,
1649
- errorText: U(C instanceof Error ? C.message : String(C)),
1690
+ ...W,
1691
+ errorText: P(C instanceof Error ? C.message : String(C)),
1650
1692
  durationMs: Date.now() - d
1651
1693
  });
1652
1694
  }
@@ -1655,29 +1697,29 @@ function Gs() {
1655
1697
  } catch {
1656
1698
  }
1657
1699
  return p;
1658
- }, a = function(g, u, d, p, m) {
1659
- const E = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
1660
- return Mt.set(this, {
1661
- requestId: Ut("xhr"),
1662
- method: String(g ?? "GET").toUpperCase(),
1663
- url: U(T, bt),
1700
+ }, a = function(m, u, d, p, g) {
1701
+ const A = n.call(this, m, u, d ?? !0, p ?? void 0, g ?? void 0), T = typeof u == "string" ? u : u.toString();
1702
+ return _t.set(this, {
1703
+ requestId: Dt("xhr"),
1704
+ method: String(m ?? "GET").toUpperCase(),
1705
+ url: P(T, kt),
1664
1706
  requestHeaders: {},
1665
1707
  startedAtMs: Date.now(),
1666
1708
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1667
1709
  excluded: x(T)
1668
- }), E;
1669
- }, c = function(g, u) {
1670
- const d = r.call(this, g, u), p = Mt.get(this);
1671
- return p && Object.keys(p.requestHeaders).length < jt && (p.requestHeaders[g] = Jt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1672
- }, l = function(g) {
1710
+ }), A;
1711
+ }, c = function(m, u) {
1712
+ const d = r.call(this, m, u), p = _t.get(this);
1713
+ return p && Object.keys(p.requestHeaders).length < Gt && (p.requestHeaders[m] = Zt(m, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1714
+ }, l = function(m) {
1673
1715
  try {
1674
- const u = Mt.get(this);
1675
- u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody = Ee(g), u.excluded || this.addEventListener(
1716
+ const u = _t.get(this);
1717
+ u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, m), u.requestBody = Re(m), u.excluded || this.addEventListener(
1676
1718
  "loadend",
1677
1719
  () => {
1678
1720
  queueMicrotask(() => {
1679
1721
  try {
1680
- const d = Nr(this.getAllResponseHeaders());
1722
+ const d = $r(this.getAllResponseHeaders());
1681
1723
  t({
1682
1724
  requestId: u.requestId,
1683
1725
  url: u.url,
@@ -1687,7 +1729,7 @@ function Gs() {
1687
1729
  resourceType: "xhr",
1688
1730
  responseStatus: this.status,
1689
1731
  responseHeaders: d,
1690
- responseBody: Pr(this, d),
1732
+ responseBody: qr(this, d),
1691
1733
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1692
1734
  startedAt: u.startedAt,
1693
1735
  durationMs: Date.now() - u.startedAtMs
@@ -1701,7 +1743,7 @@ function Gs() {
1701
1743
  ));
1702
1744
  } catch {
1703
1745
  }
1704
- return i.call(this, g ?? null);
1746
+ return i.call(this, m ?? null);
1705
1747
  };
1706
1748
  try {
1707
1749
  window.fetch = o;
@@ -1722,14 +1764,14 @@ function Gs() {
1722
1764
  let h = null;
1723
1765
  if (typeof PerformanceObserver < "u") {
1724
1766
  h = new PerformanceObserver((I) => {
1725
- for (const g of I.getEntries()) {
1726
- const u = g;
1767
+ for (const m of I.getEntries()) {
1768
+ const u = m;
1727
1769
  if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || x(u.name))
1728
1770
  continue;
1729
1771
  const d = performance.timeOrigin + u.startTime;
1730
1772
  t({
1731
- requestId: Ut("resource"),
1732
- url: U(u.name, bt),
1773
+ requestId: Dt("resource"),
1774
+ url: P(u.name, kt),
1733
1775
  method: "GET",
1734
1776
  resourceType: "resource",
1735
1777
  responseStatus: u.responseStatus,
@@ -1779,17 +1821,17 @@ function S(e, t, s) {
1779
1821
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1780
1822
  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 }));
1781
1823
  }
1782
- function he(e) {
1824
+ function ge(e) {
1783
1825
  const t = typeof e == "function" ? e() : e;
1784
1826
  return t && Object.keys(t).length > 0 ? t : void 0;
1785
1827
  }
1786
- function Xs(e) {
1828
+ function Qs(e) {
1787
1829
  return e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call";
1788
1830
  }
1789
- function Js(e) {
1831
+ function tn(e) {
1790
1832
  return e.type === "run.steered" || e.type === "run.ack" || e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call" || e.type === "tool.status" || e.type === "error" && typeof e.requestId != "string";
1791
1833
  }
1792
- function kt(e) {
1834
+ function Ct(e) {
1793
1835
  if (typeof e.sessionId == "string")
1794
1836
  return e.sessionId;
1795
1837
  if (e.session && typeof e.session == "object") {
@@ -1804,42 +1846,31 @@ function kt(e) {
1804
1846
  }
1805
1847
  return null;
1806
1848
  }
1807
- const Vs = 5e3, Ys = 12e4;
1808
- function Zs(e) {
1809
- const t = [];
1810
- for (const s of e)
1811
- s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
1812
- t.push({
1813
- id: `${s.id}:attachment:${r}`,
1814
- ...n
1815
- });
1816
- });
1817
- return t;
1818
- }
1819
- function Qs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1820
- const n = [
1821
- en(),
1822
- tn()
1823
- ].filter((r) => typeof r == "function");
1849
+ const en = 5e3, sn = 12e4;
1850
+ function nn() {
1851
+ const e = [
1852
+ on(),
1853
+ rn()
1854
+ ].filter((t) => typeof t == "function");
1824
1855
  return () => {
1825
- for (const r of n.reverse())
1826
- r();
1856
+ for (const t of e.reverse())
1857
+ t();
1827
1858
  };
1828
1859
  }
1829
- function tn() {
1830
- return be(globalThis, "getPageSnapshot", async () => zt());
1860
+ function rn() {
1861
+ return be(globalThis, "getPageSnapshot", async () => Xt());
1831
1862
  }
1832
- function en() {
1863
+ function on() {
1833
1864
  return be(globalThis, "pageImages", {
1834
- inspectImage: async (t, s) => await sn(t, s)
1865
+ inspectImage: async (t, s) => await an(t, s)
1835
1866
  });
1836
1867
  }
1837
- async function sn(e, t = {}) {
1838
- const s = an(t.name), n = await nn(e);
1868
+ async function an(e, t = {}) {
1869
+ const s = dn(t.name), n = await cn(e);
1839
1870
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1840
1871
  type: "pluno.pageImages.inspectImage",
1841
1872
  imageAttached: !1,
1842
- imageAttachmentError: _e
1873
+ imageAttachmentError: Pe
1843
1874
  } : {
1844
1875
  type: "pluno.pageImages.inspectImage",
1845
1876
  imageAttached: !0,
@@ -1853,15 +1884,15 @@ async function sn(e, t = {}) {
1853
1884
  imageAttachmentError: n.error
1854
1885
  };
1855
1886
  }
1856
- async function nn(e) {
1857
- return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: _e } : {
1887
+ async function cn(e) {
1888
+ return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: Pe } : {
1858
1889
  ok: !0,
1859
1890
  mimeType: e.type,
1860
1891
  sizeBytes: e.size,
1861
- dataUrl: await ln(e)
1862
- } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : rn(e);
1892
+ dataUrl: await pn(e)
1893
+ } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : ln(e);
1863
1894
  }
1864
- function rn(e) {
1895
+ function ln(e) {
1865
1896
  if (!e.startsWith("data:") || !e.includes(","))
1866
1897
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1867
1898
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1872,7 +1903,7 @@ function rn(e) {
1872
1903
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1873
1904
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1874
1905
  return { ok: !1, error: "Page image data URL has invalid base64." };
1875
- const o = on(i);
1906
+ const o = un(i);
1876
1907
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1877
1908
  ok: !0,
1878
1909
  mimeType: r,
@@ -1880,22 +1911,22 @@ function rn(e) {
1880
1911
  dataUrl: `data:${r};base64,${i}`
1881
1912
  };
1882
1913
  }
1883
- function on(e) {
1914
+ function un(e) {
1884
1915
  if (e.length === 0 || e.length % 4 !== 0)
1885
1916
  return null;
1886
1917
  const t = e.length - e.replace(/=+$/, "").length;
1887
1918
  return t > 2 ? null : e.length / 4 * 3 - t;
1888
1919
  }
1889
- function an(e) {
1920
+ function dn(e) {
1890
1921
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1891
1922
  }
1892
- function cn(e) {
1923
+ function hn(e) {
1893
1924
  try {
1894
1925
  e();
1895
1926
  } catch {
1896
1927
  }
1897
1928
  }
1898
- function ln(e) {
1929
+ function pn(e) {
1899
1930
  return new Promise((t, s) => {
1900
1931
  const n = new FileReader();
1901
1932
  n.onload = () => {
@@ -1903,13 +1934,13 @@ function ln(e) {
1903
1934
  t(n.result);
1904
1935
  return;
1905
1936
  }
1906
- s(new Error("Failed to read Pluno user file"));
1907
- }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1937
+ s(new Error("Failed to read page image"));
1938
+ }, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(e);
1908
1939
  });
1909
1940
  }
1910
- async function pe(e, t) {
1941
+ async function me(e, t) {
1911
1942
  const s = Object.getPrototypeOf(async function() {
1912
- }).constructor, n = e.timeoutMs ?? Vs, r = Date.now(), i = [];
1943
+ }).constructor, n = e.timeoutMs ?? en, r = Date.now(), i = [];
1913
1944
  let o;
1914
1945
  const a = {
1915
1946
  log: console.log,
@@ -1927,7 +1958,7 @@ async function pe(e, t) {
1927
1958
  o = window.setTimeout(() => f(l), n);
1928
1959
  })
1929
1960
  ]);
1930
- return h === l ? dn(n) : {
1961
+ return h === l ? gn(n) : {
1931
1962
  ok: !0,
1932
1963
  result: h,
1933
1964
  console: i,
@@ -1956,7 +1987,7 @@ async function pe(e, t) {
1956
1987
  t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
1957
1988
  }
1958
1989
  }
1959
- function un(e, t) {
1990
+ function fn(e, t) {
1960
1991
  if (!e || typeof e != "object")
1961
1992
  return;
1962
1993
  const s = e.sandboxFilesToken;
@@ -1966,7 +1997,7 @@ function un(e, t) {
1966
1997
  const r = () => {
1967
1998
  if (!n)
1968
1999
  throw new Error("sandboxFiles is only available during browser-code execution");
1969
- }, i = async (a, c) => await Ts(`${t.replace(/\/$/, "")}${a}`, c);
2000
+ }, i = async (a, c) => await Es(`${t.replace(/\/$/, "")}${a}`, c);
1970
2001
  return {
1971
2002
  value: Object.freeze({
1972
2003
  upload: async (a) => {
@@ -2000,7 +2031,7 @@ function un(e, t) {
2000
2031
  }
2001
2032
  };
2002
2033
  }
2003
- function dn(e) {
2034
+ function gn(e) {
2004
2035
  return {
2005
2036
  ok: !1,
2006
2037
  exception: {
@@ -2014,10 +2045,10 @@ function dn(e) {
2014
2045
  }
2015
2046
  };
2016
2047
  }
2017
- function hn(e) {
2048
+ function mn(e) {
2018
2049
  return e.replace(/\/+$/, "");
2019
2050
  }
2020
- function pn(e) {
2051
+ function yn(e) {
2021
2052
  const t = {
2022
2053
  sidepanel: "extension_sidepanel",
2023
2054
  browser_extension_page_ui: "extension_widget",
@@ -2029,18 +2060,18 @@ function pn(e) {
2029
2060
  };
2030
2061
  return e && e in t ? t[e] : e ?? "embedded_custom_ui";
2031
2062
  }
2032
- function fn(e) {
2063
+ function In(e) {
2033
2064
  return e === "pluno" ? "scheduled_continuation" : e ?? "user";
2034
2065
  }
2035
- function gn(e, t = location.origin) {
2066
+ function Tn(e, t = location.origin) {
2036
2067
  return /origin (?:is not allowed|does not match browser origin)/i.test(e) ? `Pluno widget blocked on ${t}: this domain is not allowed. Add ${t} in Pluno under Integration > Domains.` : null;
2037
2068
  }
2038
- function mn(e) {
2069
+ function wn(e) {
2039
2070
  const t = new URL("/api/product-agent/embed/ws", e);
2040
2071
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
2041
2072
  }
2042
- function M() {
2043
- const e = Oe();
2073
+ function b() {
2074
+ const e = xe();
2044
2075
  return {
2045
2076
  url: location.href,
2046
2077
  title: document.title,
@@ -2048,21 +2079,21 @@ function M() {
2048
2079
  ...e ? { plunoProductAgentUi: e } : {}
2049
2080
  };
2050
2081
  }
2051
- function yn() {
2082
+ function Sn() {
2052
2083
  return {
2053
2084
  pageUrl: location.href,
2054
2085
  pageTitle: document.title,
2055
- htmlContent: zt()
2086
+ htmlContent: Xt()
2056
2087
  };
2057
2088
  }
2058
- function In(e) {
2059
- return st.add(e), Z || (Z = Tn()), () => {
2060
- st.delete(e), st.size === 0 && (Z?.(), Z = null);
2089
+ function An(e) {
2090
+ return ot.add(e), et || (et = En()), () => {
2091
+ ot.delete(e), ot.size === 0 && (et?.(), et = null);
2061
2092
  };
2062
2093
  }
2063
- function Tn() {
2094
+ function En() {
2064
2095
  const e = () => {
2065
- for (const i of Array.from(st))
2096
+ for (const i of Array.from(ot))
2066
2097
  i();
2067
2098
  }, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
2068
2099
  const o = t(...i);
@@ -2075,38 +2106,38 @@ function Tn() {
2075
2106
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
2076
2107
  };
2077
2108
  }
2078
- function wn() {
2079
- return Oe()?.surface === "browser_extension_sdk_preview";
2109
+ function Rn() {
2110
+ return xe()?.surface === "browser_extension_sdk_preview";
2080
2111
  }
2081
- function zt() {
2112
+ function Xt() {
2082
2113
  if (!document.body)
2083
2114
  return "";
2084
2115
  const e = [], t = [], s = (d, p) => {
2085
- const m = B(p);
2086
- !m || t.includes(m) || (e.push([d, m]), t.push(m));
2116
+ const g = q(p);
2117
+ !g || t.includes(g) || (e.push([d, g]), t.push(g));
2087
2118
  };
2088
2119
  s("Selected text", window.getSelection()?.toString() ?? "");
2089
2120
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
2090
- (d) => Pe(d) && !d.parentElement?.closest(n)
2121
+ (d) => ve(d) && !d.parentElement?.closest(n)
2091
2122
  );
2092
2123
  for (const d of r.slice(0, 3))
2093
- s("Active overlay", _t(z(d), t));
2094
- const i = Sn(), o = i ? _t(z(i), t) : "";
2095
- s("Main page content", o), s("Additional visible page text", _t(z(document.body), t));
2124
+ s("Active overlay", Pt(K(d), t));
2125
+ const i = Mn(), o = i ? Pt(K(i), t) : "";
2126
+ s("Main page content", o), s("Additional visible page text", Pt(K(document.body), t));
2096
2127
  const a = e.map(([d, p]) => `${d}:
2097
2128
  ${p}`).join(`
2098
2129
 
2099
- `).trim().slice(0, 12e3), c = An(r, i).trim(), l = `Simplified DOM outline:
2130
+ `).trim().slice(0, 12e3), c = bn(r, i).trim(), l = `Simplified DOM outline:
2100
2131
  `, h = `
2101
2132
 
2102
2133
  Visible page text:
2103
- `, f = 12e3 - l.length - h.length, I = Math.min(a.length, 7900), g = c.slice(0, f - I), u = a.slice(0, f - g.length);
2104
- return `${l}${g}${h}${u}`;
2134
+ `, f = 12e3 - l.length - h.length, I = Math.min(a.length, 7900), m = c.slice(0, f - I), u = a.slice(0, f - m.length);
2135
+ return `${l}${m}${h}${u}`;
2105
2136
  }
2106
- function z(e) {
2137
+ function K(e) {
2107
2138
  return e.innerText ?? e.textContent ?? "";
2108
2139
  }
2109
- function B(e) {
2140
+ function q(e) {
2110
2141
  return (e ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
2111
2142
  `).split(`
2112
2143
  `).map((t) => t.replace(/[ \t]+/g, " ").trim()).join(`
@@ -2114,20 +2145,20 @@ function B(e) {
2114
2145
 
2115
2146
  `).trim();
2116
2147
  }
2117
- function _t(e, t) {
2118
- let s = B(e);
2148
+ function Pt(e, t) {
2149
+ let s = q(e);
2119
2150
  for (const n of t)
2120
2151
  s = s.replace(n, "");
2121
- return B(s);
2152
+ return q(s);
2122
2153
  }
2123
- function Pe(e) {
2154
+ function ve(e) {
2124
2155
  const t = window.getComputedStyle(e);
2125
2156
  return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
2126
2157
  }
2127
- function Sn() {
2128
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Pe).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
2158
+ function Mn() {
2159
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(ve).sort((e, t) => K(t).length - K(e).length)[0] ?? null;
2129
2160
  }
2130
- function An(e, t) {
2161
+ function bn(e, t) {
2131
2162
  const s = /* @__PURE__ */ new Set([
2132
2163
  "main",
2133
2164
  "nav",
@@ -2207,92 +2238,92 @@ function An(e, t) {
2207
2238
  "data-test",
2208
2239
  "data-qa",
2209
2240
  "data-cy"
2210
- ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = En(), I = new Set(e);
2241
+ ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = kn(), I = new Set(e);
2211
2242
  t && I.add(t);
2212
- let g = 0;
2243
+ let m = 0;
2213
2244
  const u = (T) => {
2214
2245
  const D = T.getAttribute("role");
2215
2246
  return D && !o.has(D) ? D : "";
2216
2247
  }, d = (T) => {
2217
2248
  const D = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
2218
2249
  return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
2219
- }, p = (T, D, F) => {
2220
- const C = (A, dt) => {
2221
- const b = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
2222
- if (g >= 1e3 && !K || F.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
2250
+ }, p = (T, D, W) => {
2251
+ const C = (E, pt) => {
2252
+ const M = E.tagName.toLowerCase(), ft = window.getComputedStyle(E), J = h.has(E);
2253
+ if (m >= 1e3 && !J || W.has(E) || i.has(M) || E.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ft.display === "none" || ft.visibility === "hidden")
2223
2254
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2224
- g += 1;
2225
- const Vt = u(A), G = ve(A), Ye = a.has(Vt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
2226
- for (const y of pt) {
2255
+ m += 1;
2256
+ const Qt = u(E), V = Oe(E), es = a.has(Qt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(M) || M === "a" && E.hasAttribute("href"), gt = Array.from(E.children).filter((y) => y instanceof HTMLElement), Y = /* @__PURE__ */ new Map();
2257
+ for (const y of gt) {
2227
2258
  const w = d(y);
2228
- X.set(w, (X.get(w) ?? 0) + 1);
2259
+ Y.set(w, (Y.get(w) ?? 0) + 1);
2229
2260
  }
2230
- const ft = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Map();
2231
- for (const y of pt) {
2232
- const w = d(y), v = Yt.get(w) ?? 0;
2233
- Yt.set(w, v + 1), (X.get(w) ?? 0) > 8 && v >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
2261
+ const mt = /* @__PURE__ */ new Map(), te = /* @__PURE__ */ new Map();
2262
+ for (const y of gt) {
2263
+ const w = d(y), v = te.get(w) ?? 0;
2264
+ te.set(w, v + 1), (Y.get(w) ?? 0) > 8 && v >= 6 && !h.has(y) && mt.set(w, (mt.get(w) ?? 0) + 1);
2234
2265
  }
2235
- const Zt = /* @__PURE__ */ new Map(), Qt = /* @__PURE__ */ new Set(), gt = [], te = [];
2236
- for (const y of pt) {
2237
- const w = d(y), v = X.get(w) ?? 0, ne = Zt.get(w) ?? 0;
2238
- if (Zt.set(w, ne + 1), v > 8 && ne >= 6 && !h.has(y)) {
2239
- Qt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Qt.add(w));
2266
+ const ee = /* @__PURE__ */ new Map(), se = /* @__PURE__ */ new Set(), yt = [], ne = [];
2267
+ for (const y of gt) {
2268
+ const w = d(y), v = Y.get(w) ?? 0, oe = ee.get(w) ?? 0;
2269
+ if (ee.set(w, oe + 1), v > 8 && oe >= 6 && !h.has(y)) {
2270
+ se.has(w) || (yt.push([`… ${mt.get(w) ?? 0} similar siblings omitted`]), se.add(w));
2240
2271
  continue;
2241
2272
  }
2242
- const re = C(y, dt);
2243
- te.push(re), gt.push(re.lines);
2273
+ const ae = C(y, pt);
2274
+ ne.push(ae), yt.push(ae.lines);
2244
2275
  }
2245
- const mt = [];
2246
- if (A.shadowRoot)
2247
- for (const y of Array.from(A.shadowRoot.children))
2248
- y instanceof HTMLElement && mt.push(C(y, dt + 1));
2249
- const J = [...te, ...mt], yt = G.length > 0 || Ye || J.some((y) => y.hasUsefulContent), ee = B(
2250
- [G, ...J.map((y) => y.textPreview)].filter(Boolean).join(" ")
2251
- ).slice(0, 180), Ze = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), se = l.some((y) => A.hasAttribute(y)) || !!Vt || Ze, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(b) || se || K) && (yt || K) && (!r.has(b) || yt || se || K), Tt = It ? 1 : 0, H = [];
2252
- if (It) {
2253
- const y = J.some((v) => v.containsTextElement), w = n.has(b) && !y ? ee : G;
2254
- H.push(De(A, c, o, w.slice(0, 180)));
2276
+ const It = [];
2277
+ if (E.shadowRoot)
2278
+ for (const y of Array.from(E.shadowRoot.children))
2279
+ y instanceof HTMLElement && It.push(C(y, pt + 1));
2280
+ const Z = [...ne, ...It], Tt = V.length > 0 || es || Z.some((y) => y.hasUsefulContent), re = q(
2281
+ [V, ...Z.map((y) => y.textPreview)].filter(Boolean).join(" ")
2282
+ ).slice(0, 180), ss = E.hasAttribute("contenteditable") && (V.length > 0 || !E.querySelector("[contenteditable]")), ie = l.some((y) => E.hasAttribute(y)) || !!Qt || ss, wt = (E.getClientRects().length > 0 || ft.display === "contents") && (s.has(M) || ie || J) && (Tt || J) && (!r.has(M) || Tt || ie || J), St = wt ? 1 : 0, F = [];
2283
+ if (wt) {
2284
+ const y = Z.some((v) => v.containsTextElement), w = n.has(M) && !y ? re : V;
2285
+ F.push(Ne(E, c, o, w.slice(0, 180)));
2255
2286
  }
2256
- for (const y of gt)
2257
- H.push(...Q(y, Tt));
2258
- const wt = mt.flatMap((y) => y.lines);
2259
- if (wt.length > 0) {
2260
- const y = wt.slice(0, 20);
2261
- wt.length > y.length && y.push("… shadow DOM omitted");
2262
- const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
2263
- if (dt < 2 && !w) {
2264
- const v = It ? "#shadow-root" : `${b} #shadow-root`;
2265
- H.push(...Q([v, ...Q(y, 1)], Tt));
2287
+ for (const y of yt)
2288
+ F.push(...st(y, St));
2289
+ const At = It.flatMap((y) => y.lines);
2290
+ if (At.length > 0) {
2291
+ const y = At.slice(0, 20);
2292
+ At.length > y.length && y.push("… shadow DOM omitted");
2293
+ const w = M.includes("tooltip") || M.includes("popper") || M.includes("loader");
2294
+ if (pt < 2 && !w) {
2295
+ const v = wt ? "#shadow-root" : `${M} #shadow-root`;
2296
+ F.push(...st([v, ...st(y, 1)], St));
2266
2297
  } else
2267
- H.push(...Q(y, Tt));
2298
+ F.push(...st(y, St));
2268
2299
  }
2269
2300
  return {
2270
- lines: H,
2271
- hasUsefulContent: yt,
2272
- textPreview: ee,
2273
- containsTextElement: n.has(b) || J.some((y) => y.containsTextElement)
2301
+ lines: F,
2302
+ hasUsefulContent: Tt,
2303
+ textPreview: re,
2304
+ containsTextElement: n.has(M) || Z.some((y) => y.containsTextElement)
2274
2305
  };
2275
2306
  };
2276
2307
  return [`--- ${D} ---`, ...C(T, 0).lines].join(`
2277
2308
  `);
2278
- }, m = [], E = B(window.getSelection()?.toString() ?? "");
2279
- E && m.push(`--- selected text ---
2280
- ${JSON.stringify(E)}`), f.length > 0 && m.push(Rn(f, s, c, o));
2309
+ }, g = [], A = q(window.getSelection()?.toString() ?? "");
2310
+ A && g.push(`--- selected text ---
2311
+ ${JSON.stringify(A)}`), f.length > 0 && g.push(_n(f, s, c, o));
2281
2312
  for (const T of e.slice(0, 3))
2282
- m.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2283
- if (t && m.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2313
+ g.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2314
+ if (t && g.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2284
2315
  const T = t || e.length ? "other visible DOM" : "visible DOM";
2285
- m.push(p(document.body, T, I));
2316
+ g.push(p(document.body, T, I));
2286
2317
  }
2287
- return m.join(`
2318
+ return g.join(`
2288
2319
 
2289
2320
  `);
2290
2321
  }
2291
- function De(e, t, s, n) {
2322
+ function Ne(e, t, s, n) {
2292
2323
  const r = e.tagName.toLowerCase();
2293
2324
  let i = r;
2294
2325
  const o = e.getAttribute("id");
2295
- o && bn(o) && (i += `#${o}`);
2326
+ o && Cn(o) && (i += `#${o}`);
2296
2327
  for (const a of t) {
2297
2328
  const c = e.getAttribute(a);
2298
2329
  c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
@@ -2305,7 +2336,7 @@ function De(e, t, s, n) {
2305
2336
  e.hasAttribute(a) && (i += `[${a}]`);
2306
2337
  return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
2307
2338
  }
2308
- function En() {
2339
+ function kn() {
2309
2340
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
2310
2341
  if (!a)
2311
2342
  return;
@@ -2326,7 +2357,7 @@ function En() {
2326
2357
  n = n.shadowRoot.activeElement;
2327
2358
  n !== document.body && n !== document.documentElement && s(n, "focused");
2328
2359
  const r = window.getSelection();
2329
- r && !r.isCollapsed && (s(fe(r.anchorNode), "selected text"), s(fe(r.focusNode), "selected text"));
2360
+ r && !r.isCollapsed && (s(ye(r.anchorNode), "selected text"), s(ye(r.focusNode), "selected text"));
2330
2361
  const i = [
2331
2362
  ["[aria-selected='true']", "selected"],
2332
2363
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -2348,7 +2379,7 @@ function En() {
2348
2379
  priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
2349
2380
  };
2350
2381
  }
2351
- function Rn(e, t, s, n) {
2382
+ function _n(e, t, s, n) {
2352
2383
  const r = ["--- active/current elements ---"];
2353
2384
  for (const i of e) {
2354
2385
  const o = [];
@@ -2359,37 +2390,37 @@ function Rn(e, t, s, n) {
2359
2390
  const f = a.getRootNode();
2360
2391
  a = a.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
2361
2392
  }
2362
- const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => De(
2393
+ const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => Ne(
2363
2394
  h,
2364
2395
  s,
2365
2396
  n,
2366
- f === c.length - 1 ? ve(h).slice(0, 180) : ""
2397
+ f === c.length - 1 ? Oe(h).slice(0, 180) : ""
2367
2398
  ));
2368
2399
  o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
2369
2400
  }
2370
2401
  return r.join(`
2371
2402
  `);
2372
2403
  }
2373
- function fe(e) {
2404
+ function ye(e) {
2374
2405
  return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
2375
2406
  }
2376
- function Q(e, t) {
2407
+ function st(e, t) {
2377
2408
  if (t === 0)
2378
2409
  return e;
2379
2410
  const s = " ".repeat(t);
2380
2411
  return e.map((n) => `${s}${n}`);
2381
2412
  }
2382
- function ve(e) {
2383
- return B(
2413
+ function Oe(e) {
2414
+ return q(
2384
2415
  Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
2385
2416
  );
2386
2417
  }
2387
- function bn(e) {
2418
+ function Cn(e) {
2388
2419
  return e.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(e) && !/[a-f0-9]{12,}/i.test(e) && !/:r[0-9a-z]+:/i.test(e);
2389
2420
  }
2390
- function Oe() {
2391
- const e = document.querySelector(ie);
2392
- if (!(e ?? document.querySelector(Dt)))
2421
+ function xe() {
2422
+ const e = document.querySelector(ce);
2423
+ if (!(e ?? document.querySelector(Nt)))
2393
2424
  return;
2394
2425
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
2395
2426
  return {
@@ -2398,28 +2429,28 @@ function Oe() {
2398
2429
  selectors: [
2399
2430
  {
2400
2431
  name: "widget_host",
2401
- selector: s === "browser_extension_sdk_preview" ? ie : Dt,
2432
+ selector: s === "browser_extension_sdk_preview" ? ce : Nt,
2402
2433
  description: "Finds Pluno's shadow-host element in the host page DOM."
2403
2434
  },
2404
2435
  {
2405
2436
  name: "widget_root",
2406
- selector: ws,
2437
+ selector: Rs,
2407
2438
  description: "Finds Pluno's widget root inside the widget host shadow root."
2408
2439
  },
2409
2440
  {
2410
2441
  name: "widget_panel",
2411
- selector: Ss,
2442
+ selector: Ms,
2412
2443
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
2413
2444
  },
2414
2445
  {
2415
2446
  name: "widget_timeline",
2416
- selector: As,
2447
+ selector: bs,
2417
2448
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2418
2449
  }
2419
2450
  ]
2420
2451
  };
2421
2452
  }
2422
- function Mn(e) {
2453
+ function Pn(e) {
2423
2454
  try {
2424
2455
  const t = JSON.parse(e);
2425
2456
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -2427,16 +2458,16 @@ function Mn(e) {
2427
2458
  return { type: "error", message: "Invalid server event" };
2428
2459
  }
2429
2460
  }
2430
- function ge(e, t) {
2461
+ function Ie(e, t) {
2431
2462
  if (!e || typeof e != "object")
2432
2463
  return [];
2433
2464
  const s = e[t];
2434
2465
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2435
2466
  }
2436
- function kn(e) {
2467
+ function Un(e) {
2437
2468
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
2438
2469
  }
2439
- function _n(e) {
2470
+ function Dn(e) {
2440
2471
  if (!e || typeof e != "object")
2441
2472
  return null;
2442
2473
  const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, 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;
@@ -2447,13 +2478,13 @@ function _n(e) {
2447
2478
  ...a !== null ? { scribbleStyle: a } : {}
2448
2479
  };
2449
2480
  }
2450
- function Cn(e) {
2481
+ function vn(e) {
2451
2482
  if (!e || typeof e != "object")
2452
2483
  return null;
2453
2484
  const t = e.javascript;
2454
2485
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
2455
2486
  }
2456
- function Un(e, t) {
2487
+ function Nn(e, t) {
2457
2488
  return t ? e && typeof e == "object" ? {
2458
2489
  ...e,
2459
2490
  helperError: t
@@ -2463,23 +2494,23 @@ function Un(e, t) {
2463
2494
  helperError: t
2464
2495
  } : e;
2465
2496
  }
2466
- function Pn(e) {
2497
+ function On(e) {
2467
2498
  if (!e || typeof e != "object")
2468
2499
  return e;
2469
2500
  const t = e;
2470
2501
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2471
2502
  }
2472
- function Dn() {
2503
+ function xn() {
2473
2504
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2474
2505
  if (t)
2475
2506
  return t;
2476
2507
  const s = crypto.randomUUID();
2477
2508
  return window.localStorage.setItem(e, s), s;
2478
2509
  }
2479
- function $() {
2510
+ function j() {
2480
2511
  return crypto.randomUUID();
2481
2512
  }
2482
- function vn(e) {
2513
+ function Ln(e) {
2483
2514
  if (!e || typeof e != "object")
2484
2515
  return null;
2485
2516
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2490,12 +2521,12 @@ function vn(e) {
2490
2521
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2491
2522
  } : null;
2492
2523
  }
2493
- function On(e, t) {
2494
- return Array.isArray(e) ? Bt(
2495
- e.map((s) => Ne(s, t)).filter((s) => s !== null)
2524
+ function Bn(e, t) {
2525
+ return Array.isArray(e) ? Wt(
2526
+ e.map((s) => Le(s, t)).filter((s) => s !== null)
2496
2527
  ) : [];
2497
2528
  }
2498
- function Nn(e) {
2529
+ function qn(e) {
2499
2530
  return Array.isArray(e) ? e.flatMap((t) => {
2500
2531
  if (!t || typeof t != "object")
2501
2532
  return [];
@@ -2516,7 +2547,7 @@ function Nn(e) {
2516
2547
  ];
2517
2548
  }) : [];
2518
2549
  }
2519
- function Ne(e, t) {
2550
+ function Le(e, t) {
2520
2551
  if (!e || typeof e != "object")
2521
2552
  return null;
2522
2553
  const s = e, n = s.data;
@@ -2530,14 +2561,14 @@ function Ne(e, t) {
2530
2561
  id: String(s.id ?? crypto.randomUUID()),
2531
2562
  role: i,
2532
2563
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2533
- content: os(
2534
- Wn(r.content),
2564
+ content: us(
2565
+ Kn(r.content),
2535
2566
  t
2536
2567
  ),
2537
2568
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2538
- respondsToUserMessageId: O(r) ?? void 0,
2569
+ respondsToUserMessageId: N(r) ?? void 0,
2539
2570
  ...k(r) ? { runId: k(r) } : {},
2540
- attachments: He(r.attachments, t)
2571
+ attachments: je(r.attachments, t)
2541
2572
  };
2542
2573
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
2543
2574
  value: r.id,
@@ -2548,51 +2579,51 @@ function Ne(e, t) {
2548
2579
  }), o;
2549
2580
  }
2550
2581
  if (r.type === "function_call_output") {
2551
- const i = Is(r.output);
2582
+ const i = As(r.output);
2552
2583
  if (i)
2553
2584
  return {
2554
2585
  id: String(s.id ?? crypto.randomUUID()),
2555
2586
  role: "tool",
2556
2587
  content: "",
2557
2588
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2558
- respondsToUserMessageId: O(r) ?? void 0,
2589
+ respondsToUserMessageId: N(r) ?? void 0,
2559
2590
  ...k(r) ? { runId: k(r) } : {},
2560
2591
  dataType: "scheduled_check_in",
2561
- toolName: ke,
2562
- callId: Ct(r) ?? void 0,
2592
+ toolName: _e,
2593
+ callId: Ut(r) ?? void 0,
2563
2594
  scheduledCheckInAt: i
2564
2595
  };
2565
- const o = Ln(r.output);
2596
+ const o = Wn(r.output);
2566
2597
  return o ? {
2567
2598
  id: String(s.id ?? crypto.randomUUID()),
2568
2599
  role: "tool",
2569
2600
  content: `Connect ${o.appName} to continue`,
2570
2601
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2571
- respondsToUserMessageId: O(r) ?? void 0,
2602
+ respondsToUserMessageId: N(r) ?? void 0,
2572
2603
  ...k(r) ? { runId: k(r) } : {},
2573
2604
  dataType: "function_call_output",
2574
2605
  toolName: "authenticate_pipedream_app",
2575
- callId: Ct(r) ?? void 0,
2606
+ callId: Ut(r) ?? void 0,
2576
2607
  integrationAuthRequest: o
2577
2608
  } : null;
2578
2609
  }
2579
2610
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2580
2611
  id: String(s.id ?? crypto.randomUUID()),
2581
2612
  role: "tool",
2582
- content: r.type === "mcp_call" ? xn(r) : Bn(r),
2613
+ content: r.type === "mcp_call" ? Hn(r) : $n(r),
2583
2614
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2584
- respondsToUserMessageId: O(r) ?? void 0,
2615
+ respondsToUserMessageId: N(r) ?? void 0,
2585
2616
  ...k(r) ? { runId: k(r) } : {},
2586
2617
  dataType: String(r.type),
2587
2618
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
2588
- callId: Ct(r) ?? void 0,
2619
+ callId: Ut(r) ?? void 0,
2589
2620
  loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
2590
2621
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2591
2622
  id: String(s.id ?? crypto.randomUUID()),
2592
2623
  role: "system",
2593
- content: qn(r),
2624
+ content: Fn(r),
2594
2625
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2595
- respondsToUserMessageId: O(r) ?? void 0,
2626
+ respondsToUserMessageId: N(r) ?? void 0,
2596
2627
  ...k(r) ? { runId: k(r) } : {},
2597
2628
  dataType: String(r.type),
2598
2629
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
@@ -2601,11 +2632,11 @@ function Ne(e, t) {
2601
2632
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2602
2633
  } : null;
2603
2634
  }
2604
- function xn(e) {
2635
+ function Hn(e) {
2605
2636
  const s = (typeof e.server_label == "string" ? e.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
2606
2637
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2607
2638
  }
2608
- function Ln(e) {
2639
+ function Wn(e) {
2609
2640
  if (typeof e != "string")
2610
2641
  return null;
2611
2642
  try {
@@ -2622,10 +2653,10 @@ function Ln(e) {
2622
2653
  return null;
2623
2654
  }
2624
2655
  }
2625
- function qn(e) {
2656
+ function Fn(e) {
2626
2657
  return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : e.type === "run_status" && e.status === "steered" ? "Steered" : typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
2627
2658
  }
2628
- function Bn(e) {
2659
+ function $n(e) {
2629
2660
  if (e.type === "web_search_call") {
2630
2661
  const t = e.action;
2631
2662
  if (t && typeof t == "object") {
@@ -2637,9 +2668,9 @@ function Bn(e) {
2637
2668
  }
2638
2669
  return "🔎 Searching the web";
2639
2670
  }
2640
- return Fn(e);
2671
+ return jn(e);
2641
2672
  }
2642
- function Fn(e) {
2673
+ function jn(e) {
2643
2674
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2644
2675
  return L(e.summary);
2645
2676
  if (typeof e.arguments == "string")
@@ -2656,7 +2687,7 @@ function L(e) {
2656
2687
  const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2657
2688
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2658
2689
  }
2659
- function Hn(e) {
2690
+ function zn(e) {
2660
2691
  if (e == null)
2661
2692
  return e;
2662
2693
  if (typeof e != "object")
@@ -2671,11 +2702,11 @@ function Hn(e) {
2671
2702
  runId: typeof t.runId == "string" ? t.runId : null
2672
2703
  };
2673
2704
  }
2674
- function Ct(e) {
2705
+ function Ut(e) {
2675
2706
  const t = e.callId ?? e.call_id;
2676
2707
  return typeof t == "string" && t ? t : null;
2677
2708
  }
2678
- function Wn(e) {
2709
+ function Kn(e) {
2679
2710
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2680
2711
  if (!t || typeof t != "object")
2681
2712
  return "";
@@ -2683,31 +2714,31 @@ function Wn(e) {
2683
2714
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
2684
2715
  }).filter(Boolean).join("") : "";
2685
2716
  }
2686
- function Ot(e, t) {
2687
- const s = Le(e, t), n = Jn(
2688
- $n(
2689
- Qn(e, t),
2717
+ function xt(e, t) {
2718
+ const s = qe(e, t), n = Qn(
2719
+ Gn(
2720
+ nr(e, t),
2690
2721
  s
2691
2722
  ),
2692
2723
  s
2693
2724
  ), r = n.findIndex((o) => o.id === s.id);
2694
2725
  if (r === -1)
2695
- return Bt(
2726
+ return Wt(
2696
2727
  [...n, s]
2697
2728
  );
2698
2729
  const i = [...n];
2699
- return i[r] = s, Bt(i);
2730
+ return i[r] = s, Wt(i);
2700
2731
  }
2701
- function $n(e, t) {
2732
+ function Gn(e, t) {
2702
2733
  const s = t.assistantDraftItemId;
2703
2734
  return s ? e.map(
2704
2735
  (n) => n.dataType === "assistant_draft" && n.id === s ? t : n
2705
2736
  ) : e;
2706
2737
  }
2707
- function jn(e, t, s) {
2738
+ function Xn(e, t, s) {
2708
2739
  return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
2709
2740
  }
2710
- function zn(e, t, s, n) {
2741
+ function Jn(e, t, s, n) {
2711
2742
  if (s === null) return e;
2712
2743
  let r = -1;
2713
2744
  for (let o = e.length - 1; o >= 0; o -= 1) {
@@ -2724,12 +2755,12 @@ function zn(e, t, s, n) {
2724
2755
  respondsToUserMessageId: s
2725
2756
  }, i;
2726
2757
  }
2727
- function Kn(e, t) {
2758
+ function Vn(e, t) {
2728
2759
  const s = e.findIndex(
2729
2760
  (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2730
2761
  );
2731
2762
  if (s === -1)
2732
- return Ot(e, t);
2763
+ return xt(e, t);
2733
2764
  const n = [...e];
2734
2765
  return n[s] = {
2735
2766
  ...n[s],
@@ -2741,12 +2772,12 @@ function Kn(e, t) {
2741
2772
  ...n[s].runId ? {} : { runId: t.runId }
2742
2773
  }, n;
2743
2774
  }
2744
- function Gn(e, t, s) {
2775
+ function Yn(e, t, s) {
2745
2776
  let n = !1;
2746
2777
  const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2747
2778
  return n ? r : e;
2748
2779
  }
2749
- function Xn(e) {
2780
+ function Zn(e) {
2750
2781
  if (e.hiddenFromTranscript === !0)
2751
2782
  return null;
2752
2783
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
@@ -2765,7 +2796,7 @@ function Xn(e) {
2765
2796
  loading: !0
2766
2797
  };
2767
2798
  }
2768
- function Jn(e, t) {
2799
+ function Qn(e, t) {
2769
2800
  if (t.id.startsWith("transient-activity:"))
2770
2801
  return e;
2771
2802
  const s = t.toolName === "tab_lifecycle";
@@ -2773,17 +2804,17 @@ function Jn(e, t) {
2773
2804
  (n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId && n.runId === t.runId)
2774
2805
  );
2775
2806
  }
2776
- function Vn(e, t) {
2777
- return as(
2807
+ function tr(e, t) {
2808
+ return ds(
2778
2809
  e,
2779
2810
  t.map(
2780
- (s) => Le(e, s)
2811
+ (s) => qe(e, s)
2781
2812
  ),
2782
- xe
2813
+ Be
2783
2814
  );
2784
2815
  }
2785
- function xe(e) {
2786
- const t = Nt(e) ?? void 0, s = e.assistantDraftItemId, n = [
2816
+ function Be(e) {
2817
+ const t = G(e) ?? void 0, s = e.assistantDraftItemId, n = [
2787
2818
  ...e.callId ? [`call:${e.callId}`] : [],
2788
2819
  ...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
2789
2820
  ];
@@ -2794,52 +2825,52 @@ function xe(e) {
2794
2825
  ...n.length > 0 ? { activityKeys: n } : {},
2795
2826
  ...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
2796
2827
  ...e.runId ? { runId: e.runId } : {},
2797
- isOptimistic: Kt(e),
2828
+ isOptimistic: Jt(e),
2798
2829
  isAssistantDraft: e.dataType === "assistant_draft",
2799
2830
  isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
2800
2831
  isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
2801
2832
  };
2802
2833
  }
2803
- function Le(e, t) {
2834
+ function qe(e, t) {
2804
2835
  if (t.role !== "user" || !t.attachments?.length)
2805
2836
  return t;
2806
2837
  const s = e.find(
2807
- (r) => r.role === "user" && (r.id === t.id || Kt(r) && qe(r, t))
2838
+ (r) => r.role === "user" && (r.id === t.id || Jt(r) && He(r, t))
2808
2839
  );
2809
2840
  if (!s?.attachments?.length)
2810
2841
  return t;
2811
2842
  const n = t.attachments.map((r) => {
2812
- const i = Yn(s.attachments ?? [], r);
2813
- return i ? Zn(r, i) : r;
2843
+ const i = er(s.attachments ?? [], r);
2844
+ return i ? sr(r, i) : r;
2814
2845
  });
2815
2846
  return { ...t, attachments: n };
2816
2847
  }
2817
- function Yn(e, t) {
2848
+ function er(e, t) {
2818
2849
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2819
2850
  }
2820
- function Zn(e, t) {
2851
+ function sr(e, t) {
2821
2852
  const { previewUrl: s } = t;
2822
2853
  return s ? { ...e, previewUrl: s } : e;
2823
2854
  }
2824
- function Qn(e, t) {
2855
+ function nr(e, t) {
2825
2856
  if (t.role !== "user")
2826
2857
  return e;
2827
2858
  const s = e.findIndex(
2828
- (r) => Kt(r) && qe(r, t)
2859
+ (r) => Jt(r) && He(r, t)
2829
2860
  );
2830
2861
  if (s === -1)
2831
2862
  return e;
2832
2863
  const n = [...e];
2833
2864
  return n.splice(s, 1), n;
2834
2865
  }
2835
- function qe(e, t) {
2836
- const s = Nt(e), n = Nt(t);
2866
+ function He(e, t) {
2867
+ const s = G(e), n = G(t);
2837
2868
  return s && n ? s === n : e.content === t.content;
2838
2869
  }
2839
- function Kt(e) {
2870
+ function Jt(e) {
2840
2871
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2841
2872
  }
2842
- function Nt(e) {
2873
+ function G(e) {
2843
2874
  const t = e.clientMessageId;
2844
2875
  if (t)
2845
2876
  return t;
@@ -2848,18 +2879,18 @@ function Nt(e) {
2848
2879
  );
2849
2880
  return n ? e.id.slice(n.length) : null;
2850
2881
  }
2851
- function me(e) {
2852
- const t = Be(e);
2882
+ function Te(e) {
2883
+ const t = We(e);
2853
2884
  if (t === null)
2854
2885
  return !1;
2855
2886
  const s = e[t].id, n = e.some(
2856
- (r) => r.respondsToUserMessageId === s && xt(r)
2887
+ (r) => r.respondsToUserMessageId === s && Lt(r)
2857
2888
  );
2858
2889
  if (e.some((r) => r.respondsToUserMessageId === s))
2859
2890
  return n;
2860
2891
  for (let r = e.length - 1; r > t; r -= 1) {
2861
2892
  const i = e[r];
2862
- if (N(i))
2893
+ if (O(i))
2863
2894
  return !0;
2864
2895
  if (i.role === "system") {
2865
2896
  if (i.dataType === "run_error")
@@ -2870,25 +2901,25 @@ function me(e) {
2870
2901
  }
2871
2902
  return !1;
2872
2903
  }
2873
- function tr(e) {
2874
- const t = Be(e);
2904
+ function rr(e) {
2905
+ const t = We(e);
2875
2906
  if (t === null)
2876
- return e.some(N);
2907
+ return e.some(O);
2877
2908
  const s = e[t].id;
2878
2909
  return e.some((n) => n.respondsToUserMessageId === s) ? e.some(
2879
- (n) => n.respondsToUserMessageId === s && N(n)
2880
- ) : e.slice(t + 1).some(N);
2910
+ (n) => n.respondsToUserMessageId === s && O(n)
2911
+ ) : e.slice(t + 1).some(O);
2881
2912
  }
2882
- function Be(e) {
2913
+ function We(e) {
2883
2914
  for (let t = e.length - 1; t >= 0; t -= 1)
2884
2915
  if (e[t].role === "user")
2885
2916
  return t;
2886
2917
  return null;
2887
2918
  }
2888
- function xt(e) {
2889
- return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2919
+ function Lt(e) {
2920
+ return O(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2890
2921
  }
2891
- function at(e) {
2922
+ function dt(e) {
2892
2923
  for (let t = e.length - 1; t >= 0; t -= 1) {
2893
2924
  const s = e[t];
2894
2925
  if (!s || typeof s != "object")
@@ -2902,30 +2933,30 @@ function at(e) {
2902
2933
  }
2903
2934
  return null;
2904
2935
  }
2905
- function er(e) {
2906
- const t = at(e);
2936
+ function ir(e) {
2937
+ const t = dt(e);
2907
2938
  if (t === null)
2908
2939
  return null;
2909
- const n = q(e[t])?.page;
2940
+ const n = B(e[t])?.page;
2910
2941
  if (!n || typeof n != "object")
2911
2942
  return null;
2912
2943
  const r = n.url;
2913
2944
  return typeof r == "string" ? r : null;
2914
2945
  }
2915
- function q(e) {
2946
+ function B(e) {
2916
2947
  if (!e || typeof e != "object")
2917
2948
  return null;
2918
2949
  const t = e.data;
2919
2950
  return t && typeof t == "object" ? t : null;
2920
2951
  }
2921
- function Lt(e) {
2952
+ function Bt(e) {
2922
2953
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2923
2954
  }
2924
- function ye(e) {
2955
+ function we(e) {
2925
2956
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2926
2957
  }
2927
- function sr(e, t) {
2928
- const s = at(t);
2958
+ function or(e, t) {
2959
+ const s = dt(t);
2929
2960
  if (s === null)
2930
2961
  return !1;
2931
2962
  const n = t[s], r = n && typeof n == "object" ? n.id : null;
@@ -2933,11 +2964,11 @@ function sr(e, t) {
2933
2964
  return !1;
2934
2965
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2935
2966
  return i === -1 ? !1 : e.some((o) => o.respondsToUserMessageId === r) ? e.some(
2936
- (o) => o.respondsToUserMessageId === r && xt(o)
2937
- ) : e.slice(i + 1).some(xt);
2967
+ (o) => o.respondsToUserMessageId === r && Lt(o)
2968
+ ) : e.slice(i + 1).some(Lt);
2938
2969
  }
2939
2970
  function qt(e) {
2940
- const t = at(e);
2971
+ const t = dt(e);
2941
2972
  if (t === null)
2942
2973
  return null;
2943
2974
  const s = e[t];
@@ -2949,8 +2980,8 @@ function qt(e) {
2949
2980
  const r = n.clientMessageId;
2950
2981
  return typeof r == "string" ? r : null;
2951
2982
  }
2952
- function nr(e) {
2953
- const t = at(e);
2983
+ function ar(e) {
2984
+ const t = dt(e);
2954
2985
  if (t === null)
2955
2986
  return null;
2956
2987
  for (let s = e.length - 1; s > t; s -= 1) {
@@ -2964,22 +2995,22 @@ function nr(e) {
2964
2995
  if (i.type === "message" && i.role === "assistant")
2965
2996
  return null;
2966
2997
  if (i.type === "run_error")
2967
- return i.retryable !== !0 ? null : Ie(e, i) ?? qt(e);
2998
+ return i.retryable !== !0 ? null : Ht(e, i) ?? qt(e);
2968
2999
  if (i.type === "run_status")
2969
- return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ?? qt(e) : null;
3000
+ return i.status === "interrupted" && i.retryable === !0 ? Ht(e, i) ?? qt(e) : null;
2970
3001
  }
2971
3002
  return null;
2972
3003
  }
2973
- function Ie(e, t) {
3004
+ function Ht(e, t) {
2974
3005
  if (typeof t.clientMessageId == "string")
2975
3006
  return t.clientMessageId;
2976
- const s = O(t);
3007
+ const s = N(t);
2977
3008
  if (!s)
2978
3009
  return null;
2979
- const n = e.find((i) => R(i, "id") === s), r = q(n);
3010
+ const n = e.find((i) => R(i, "id") === s), r = B(n);
2980
3011
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2981
3012
  }
2982
- function rr(e, t) {
3013
+ function cr(e, t) {
2983
3014
  let s = 0;
2984
3015
  for (const n of e) {
2985
3016
  if (!n || typeof n != "object")
@@ -2992,65 +3023,106 @@ function rr(e, t) {
2992
3023
  }
2993
3024
  return s;
2994
3025
  }
2995
- function Te(e, t, s, n, r) {
2996
- if (!t || !ir(e))
3026
+ function Se(e, t, s, n, r) {
3027
+ if (!t || !lr(e))
2997
3028
  return !1;
2998
3029
  const i = e;
2999
- return !(Lt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && k(i) !== r));
3030
+ return !(Bt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? N(i) !== n : r !== null && k(i) !== r));
3000
3031
  }
3001
- function ir(e) {
3032
+ function lr(e) {
3002
3033
  if (!e || typeof e != "object")
3003
3034
  return !1;
3004
3035
  const t = e;
3005
3036
  return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted" || t.status === "failed");
3006
3037
  }
3007
- function N(e) {
3038
+ function O(e) {
3008
3039
  return e.role === "assistant" && e.phase !== "commentary";
3009
3040
  }
3010
- function or(e) {
3041
+ function ur(e) {
3011
3042
  if (!e || typeof e != "object")
3012
3043
  return !1;
3013
3044
  const t = e;
3014
3045
  return t.type === "message" && t.role === "user" ? !1 : t.type === "message" || t.type === "function_call" || t.type === "function_call_output" || t.type === "run_error" || t.type === "run_status";
3015
3046
  }
3016
- function Bt(e) {
3017
- return e.filter((t, s) => ct(t) ? !fr(e, s) && !hr(e, s) && !pr(e, s) : ar(t) ? t.retryable === !0 && dr(e, s) ? !1 : !ur(e, s) : !0);
3047
+ function Wt(e) {
3048
+ return e.filter((t, s) => H(t) ? !wr(e, s) && !Fe(e, s) && !Ir(e, s) && !Tr(e, s) : dr(t) ? t.retryable === !0 && yr(e, s) ? !1 : !mr(e, s) : !0);
3018
3049
  }
3019
- function ar(e) {
3050
+ function dr(e) {
3020
3051
  return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
3021
3052
  }
3022
- function ct(e) {
3053
+ function H(e) {
3023
3054
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
3024
3055
  }
3025
- function cr(e, t) {
3056
+ function hr(e, t, s, n) {
3057
+ const r = e.findIndex(
3058
+ (c, l) => H(c) && !Fe(e, l)
3059
+ ), i = r === -1 ? null : e[r], o = t ?? i?.respondsToUserMessageId ?? null, a = o ? e.find(
3060
+ (c) => c.role === "user" && c.id === o
3061
+ ) : null;
3062
+ return {
3063
+ clientMessageId: a ? G(a) : o ? null : n,
3064
+ runId: s ?? i?.runId ?? null
3065
+ };
3066
+ }
3067
+ function nt(e, t, s) {
3068
+ const n = new Set(
3069
+ e.filter(
3070
+ (r) => r.role === "user" && t !== null && G(r) === t
3071
+ ).map((r) => r.id)
3072
+ );
3073
+ return e.filter(
3074
+ (r) => !H(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3075
+ );
3076
+ }
3077
+ function Fe(e, t) {
3078
+ return e.some(
3079
+ (s, n) => n !== t && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && pr(
3080
+ e,
3081
+ t,
3082
+ n
3083
+ )
3084
+ );
3085
+ }
3086
+ function pr(e, t, s) {
3087
+ const n = e[t], r = e[s];
3088
+ if (X(n, r))
3089
+ return !0;
3090
+ if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
3091
+ return !1;
3092
+ for (let i = s - 1; i >= 0; i -= 1)
3093
+ if (e[i].role === "user")
3094
+ return e[i].id === n.respondsToUserMessageId;
3095
+ return !1;
3096
+ }
3097
+ function fr(e, t) {
3026
3098
  const s = [...e].reverse().find(
3027
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !lr(
3099
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && Ae(n) && !gr(
3028
3100
  e,
3029
3101
  n.respondsToUserMessageId
3030
3102
  )
3031
3103
  )?.respondsToUserMessageId;
3032
3104
  return s ? e.map(
3033
- (n) => n.respondsToUserMessageId === s && we(n) ? { ...n, steered: !0 } : n
3105
+ (n) => n.respondsToUserMessageId === s && Ae(n) ? { ...n, steered: !0 } : n
3034
3106
  ) : e;
3035
3107
  }
3036
- function we(e) {
3037
- return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
3108
+ function Ae(e) {
3109
+ return e.role === "tool" || H(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
3038
3110
  }
3039
- function lr(e, t) {
3111
+ function gr(e, t) {
3040
3112
  return e.some(
3041
- (s) => s.respondsToUserMessageId === t && (N(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3113
+ (s) => s.respondsToUserMessageId === t && (O(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3042
3114
  );
3043
3115
  }
3044
- function ur(e, t) {
3116
+ function mr(e, t) {
3045
3117
  const s = e[t];
3046
3118
  for (let n = t + 1; n < e.length; n += 1) {
3047
3119
  const r = e[n];
3048
- if (r.role === "assistant" && lt(s, r))
3120
+ if (r.role === "assistant" && X(s, r))
3049
3121
  return !0;
3050
3122
  }
3051
3123
  return !1;
3052
3124
  }
3053
- function dr(e, t) {
3125
+ function yr(e, t) {
3054
3126
  const s = e[t];
3055
3127
  if (!s.respondsToUserMessageId)
3056
3128
  return !1;
@@ -3058,45 +3130,45 @@ function dr(e, t) {
3058
3130
  const r = e[n];
3059
3131
  if (r.role === "user")
3060
3132
  return !1;
3061
- if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || ct(r)))
3133
+ if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || H(r)))
3062
3134
  return !0;
3063
3135
  }
3064
3136
  return !1;
3065
3137
  }
3066
- function hr(e, t) {
3138
+ function Ir(e, t) {
3067
3139
  const s = e[t];
3068
3140
  return e.some(
3069
- (n, r) => r !== t && n.role === "assistant" && lt(s, n)
3141
+ (n, r) => r !== t && n.role === "assistant" && X(s, n)
3070
3142
  );
3071
3143
  }
3072
- function pr(e, t) {
3144
+ function Tr(e, t) {
3073
3145
  const s = e[t];
3074
3146
  return e.some(
3075
- (n, r) => r !== t && n.role === "tool" && lt(s, n)
3147
+ (n, r) => r !== t && n.role === "tool" && X(s, n)
3076
3148
  );
3077
3149
  }
3078
- function fr(e, t) {
3150
+ function wr(e, t) {
3079
3151
  const s = e[t];
3080
3152
  for (let n = t + 1; n < e.length; n += 1)
3081
- if (ct(e[n]) && lt(s, e[n]))
3153
+ if (H(e[n]) && X(s, e[n]))
3082
3154
  return !0;
3083
3155
  return !1;
3084
3156
  }
3085
- function lt(e, t) {
3157
+ function X(e, t) {
3086
3158
  return !!(e.respondsToUserMessageId && e.respondsToUserMessageId === t.respondsToUserMessageId);
3087
3159
  }
3088
3160
  function R(e, t) {
3089
3161
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
3090
3162
  }
3091
- function gr(e, t) {
3163
+ function Sr(e, t) {
3092
3164
  try {
3093
- const s = window.localStorage.getItem(`${Ce}${e}`);
3165
+ const s = window.localStorage.getItem(`${Ue}${e}`);
3094
3166
  if (!s)
3095
3167
  return null;
3096
3168
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
3097
3169
  if (t !== void 0 && r !== t)
3098
3170
  return null;
3099
- const i = Array.isArray(n.messages) ? n.messages.map(br).filter((o) => !!o) : [];
3171
+ const i = Array.isArray(n.messages) ? n.messages.map(vr).filter((o) => !!o) : [];
3100
3172
  return {
3101
3173
  sessionId: r,
3102
3174
  messages: i
@@ -3105,48 +3177,48 @@ function gr(e, t) {
3105
3177
  return null;
3106
3178
  }
3107
3179
  }
3108
- function mr(e, t) {
3180
+ function Ar(e, t) {
3109
3181
  try {
3110
3182
  window.localStorage.setItem(
3111
- `${Ce}${e}`,
3183
+ `${Ue}${e}`,
3112
3184
  JSON.stringify({
3113
3185
  sessionId: t.sessionId,
3114
- messages: t.messages.slice(-Ws).map(Mr)
3186
+ messages: t.messages.slice(-Gs).map(Nr)
3115
3187
  })
3116
3188
  );
3117
3189
  } catch {
3118
3190
  return;
3119
3191
  }
3120
3192
  }
3121
- function yr(e) {
3193
+ function Er(e) {
3122
3194
  try {
3123
- const t = window.localStorage.getItem(`${vt}${e}`);
3195
+ const t = window.localStorage.getItem(`${Ot}${e}`);
3124
3196
  if (!t)
3125
3197
  return [];
3126
3198
  const s = JSON.parse(t);
3127
- return Array.isArray(s) ? s.filter(Gt) : [];
3199
+ return Array.isArray(s) ? s.filter(Vt) : [];
3128
3200
  } catch {
3129
3201
  return [];
3130
3202
  }
3131
3203
  }
3132
- function j(e, t) {
3204
+ function z(e, t) {
3133
3205
  try {
3134
- const s = t.filter(Gt);
3206
+ const s = t.filter(Vt);
3135
3207
  if (s.length === 0) {
3136
- window.localStorage.removeItem(`${vt}${e}`);
3208
+ window.localStorage.removeItem(`${Ot}${e}`);
3137
3209
  return;
3138
3210
  }
3139
3211
  window.localStorage.setItem(
3140
- `${vt}${e}`,
3212
+ `${Ot}${e}`,
3141
3213
  JSON.stringify(s.slice(-25))
3142
3214
  );
3143
3215
  } catch {
3144
3216
  return;
3145
3217
  }
3146
3218
  }
3147
- function Fe(e, t) {
3219
+ function $e(e, t) {
3148
3220
  try {
3149
- const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
3221
+ const s = `${ut}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
3150
3222
  ...o,
3151
3223
  storedAt: Date.now(),
3152
3224
  unloadUrl: n,
@@ -3160,28 +3232,28 @@ function Fe(e, t) {
3160
3232
  } catch {
3161
3233
  }
3162
3234
  }
3163
- function Ir(e, t) {
3235
+ function Rr(e, t) {
3164
3236
  try {
3165
- if (window.sessionStorage.getItem(`${ot}${e}`) === null)
3237
+ if (window.sessionStorage.getItem(`${ut}${e}`) === null)
3166
3238
  return;
3167
3239
  } catch {
3168
3240
  return;
3169
3241
  }
3170
- Fe(e, t);
3242
+ $e(e, t);
3171
3243
  }
3172
- function Tr(e) {
3244
+ function Mr(e) {
3173
3245
  try {
3174
- const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
3246
+ const t = `${ut}${e}`, s = window.sessionStorage.getItem(t);
3175
3247
  if (window.sessionStorage.removeItem(t), !s)
3176
3248
  return [];
3177
3249
  const n = JSON.parse(s);
3178
- return Array.isArray(n) ? n.flatMap((r) => Sr(r) ? [{
3250
+ return Array.isArray(n) ? n.flatMap((r) => kr(r) ? [{
3179
3251
  ...r.event,
3180
- page: M(),
3252
+ page: b(),
3181
3253
  rawOutput: {
3182
3254
  pageContextRestarted: !0,
3183
3255
  outcome: "unknown",
3184
- message: wr(location.href),
3256
+ message: br(location.href),
3185
3257
  currentUrl: location.href,
3186
3258
  console: [],
3187
3259
  metadata: {
@@ -3198,17 +3270,17 @@ function Tr(e) {
3198
3270
  return [];
3199
3271
  }
3200
3272
  }
3201
- function wr(e) {
3273
+ function br(e) {
3202
3274
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
3203
3275
  Current URL: ${e}`;
3204
3276
  }
3205
- function Sr(e) {
3277
+ function kr(e) {
3206
3278
  if (!e || typeof e != "object")
3207
3279
  return !1;
3208
3280
  const t = e, s = t.event;
3209
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Gt(s) && s.type === "tool.result";
3281
+ return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Vt(s) && s.type === "tool.result";
3210
3282
  }
3211
- function Ar(e, t) {
3283
+ function _r(e, t) {
3212
3284
  const s = new Set(
3213
3285
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
3214
3286
  );
@@ -3217,26 +3289,26 @@ function Ar(e, t) {
3217
3289
  ...t.filter((n) => !s.has(n.callId))
3218
3290
  ];
3219
3291
  }
3220
- function Er(e) {
3292
+ function Cr(e) {
3221
3293
  try {
3222
- window.sessionStorage.removeItem(`${ot}${e}`);
3294
+ window.sessionStorage.removeItem(`${ut}${e}`);
3223
3295
  } catch {
3224
3296
  return;
3225
3297
  }
3226
3298
  }
3227
- function Gt(e) {
3299
+ function Vt(e) {
3228
3300
  if (!e || typeof e != "object")
3229
3301
  return !1;
3230
3302
  const t = e;
3231
- return t.type === "chat.user_message" ? typeof t.content == "string" && Se(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Se(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
3303
+ return t.type === "chat.user_message" ? typeof t.content == "string" && Ee(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Ee(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
3232
3304
  }
3233
- function Se(e) {
3305
+ function Ee(e) {
3234
3306
  if (!e || typeof e != "object")
3235
3307
  return !1;
3236
3308
  const t = e;
3237
3309
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
3238
3310
  }
3239
- function He(e, t) {
3311
+ function je(e, t) {
3240
3312
  if (!Array.isArray(e))
3241
3313
  return;
3242
3314
  const s = e.filter((r) => {
@@ -3244,23 +3316,41 @@ function He(e, t) {
3244
3316
  return !1;
3245
3317
  const i = r;
3246
3318
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
3247
- }), n = t ? s.map((r) => We(r, t)) : s;
3319
+ }), n = t ? s.map((r) => ze(r, t)) : s;
3248
3320
  return n.length > 0 ? n : void 0;
3249
3321
  }
3250
- function We(e, t) {
3322
+ function ze(e, t) {
3251
3323
  return e.fileUrl?.startsWith("/") ? {
3252
3324
  ...e,
3253
3325
  fileUrl: new URL(e.fileUrl, t).toString()
3254
3326
  } : e;
3255
3327
  }
3256
- function Ae(e) {
3257
- return e.type || Rr(e.name) || "application/octet-stream";
3328
+ function Ft(e) {
3329
+ return e.type || Dr(e.name) || "application/octet-stream";
3330
+ }
3331
+ function Pr(e) {
3332
+ Ke({
3333
+ name: e.name,
3334
+ mimeType: Ft(e),
3335
+ sizeBytes: e.size
3336
+ });
3258
3337
  }
3259
- function Rr(e) {
3338
+ function Ke(e) {
3339
+ const t = Ur(e.name), s = e.mimeType.trim().toLowerCase();
3340
+ if (!js.has(`${t}:${s}`))
3341
+ throw new Error("This attachment type is not supported by the embedded model provider");
3342
+ if (e.sizeBytes <= 0 || e.sizeBytes >= Ce)
3343
+ throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
3344
+ }
3345
+ function Ur(e) {
3346
+ const t = e.trim().toLowerCase(), s = t.lastIndexOf(".");
3347
+ return s >= 0 ? t.slice(s) : "";
3348
+ }
3349
+ function Dr(e) {
3260
3350
  const t = e.toLowerCase();
3261
3351
  return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
3262
3352
  }
3263
- function br(e) {
3353
+ function vr(e) {
3264
3354
  if (!e || typeof e != "object")
3265
3355
  return null;
3266
3356
  const t = e;
@@ -3274,17 +3364,17 @@ function br(e) {
3274
3364
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
3275
3365
  scheduledCheckInAt: typeof t.scheduledCheckInAt == "string" ? t.scheduledCheckInAt : void 0,
3276
3366
  securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
3277
- attachments: He(t.attachments)?.map(Xt),
3367
+ attachments: je(t.attachments)?.map(Yt),
3278
3368
  loading: typeof t.loading == "boolean" ? t.loading : void 0
3279
3369
  };
3280
3370
  }
3281
- function Mr(e) {
3371
+ function Nr(e) {
3282
3372
  return e.attachments?.length ? {
3283
3373
  ...e,
3284
- attachments: e.attachments.map(Xt)
3374
+ attachments: e.attachments.map(Yt)
3285
3375
  } : e;
3286
3376
  }
3287
- function Xt(e) {
3377
+ function Yt(e) {
3288
3378
  const {
3289
3379
  dataUrl: t,
3290
3380
  objectUrl: s,
@@ -3293,7 +3383,7 @@ function Xt(e) {
3293
3383
  } = e;
3294
3384
  return r;
3295
3385
  }
3296
- function O(e) {
3386
+ function N(e) {
3297
3387
  const t = e.respondsToUserMessageId;
3298
3388
  return typeof t == "string" && t ? t : null;
3299
3389
  }
@@ -3301,39 +3391,39 @@ function k(e) {
3301
3391
  const t = e.runId;
3302
3392
  return typeof t == "string" && t ? t : null;
3303
3393
  }
3304
- function kr(e) {
3394
+ function Or(e) {
3305
3395
  const t = e?.timeoutMs;
3306
- return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Ys);
3396
+ return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= sn);
3307
3397
  }
3308
- function $e(e) {
3398
+ function Ge(e) {
3309
3399
  const t = {};
3310
3400
  try {
3311
3401
  new Headers(e).forEach((s, n) => {
3312
- Object.keys(t).length < jt && (t[n] = Jt(n, s));
3402
+ Object.keys(t).length < Gt && (t[n] = Zt(n, s));
3313
3403
  });
3314
3404
  } catch {
3315
3405
  return {};
3316
3406
  }
3317
3407
  return t;
3318
3408
  }
3319
- function Jt(e, t) {
3320
- return Je(e) ? ut : U(it(t), Fs);
3409
+ function Zt(e, t) {
3410
+ return Qe(e) ? ht : P(lt(t), zs);
3321
3411
  }
3322
- function _r(e, t) {
3412
+ function xr(e, t) {
3323
3413
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
3324
3414
  }
3325
- async function Cr(e, t, s, n) {
3326
- const r = $e(e.headers);
3415
+ async function Lr(e, t, s, n) {
3416
+ const r = Ge(e.headers);
3327
3417
  n({
3328
3418
  ...t,
3329
3419
  responseStatus: e.status,
3330
3420
  responseHeaders: r,
3331
- responseBody: await Ur(e),
3421
+ responseBody: await Br(e),
3332
3422
  durationMs: Date.now() - s
3333
3423
  });
3334
3424
  }
3335
- async function Ur(e) {
3336
- if (!je(e.headers))
3425
+ async function Br(e) {
3426
+ if (!Xe(e.headers))
3337
3427
  return;
3338
3428
  let t = null, s = null;
3339
3429
  try {
@@ -3342,7 +3432,7 @@ async function Ur(e) {
3342
3432
  const n = new Promise((a) => {
3343
3433
  s = window.setTimeout(() => {
3344
3434
  t?.cancel(), a("timeout");
3345
- }, Hs);
3435
+ }, Ks);
3346
3436
  }), r = new TextDecoder();
3347
3437
  let i = "", o = 0;
3348
3438
  for (; ; ) {
@@ -3351,10 +3441,10 @@ async function Ur(e) {
3351
3441
  return;
3352
3442
  const { done: c, value: l } = a;
3353
3443
  if (c)
3354
- return U(i + r.decode());
3355
- const h = $t - o;
3444
+ return P(i + r.decode());
3445
+ const h = Kt - o;
3356
3446
  if (l.byteLength > h)
3357
- return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${U(i)}... [truncated]`;
3447
+ return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
3358
3448
  o += l.byteLength, i += r.decode(l, { stream: !0 });
3359
3449
  }
3360
3450
  } catch {
@@ -3364,45 +3454,45 @@ async function Ur(e) {
3364
3454
  s !== null && window.clearTimeout(s);
3365
3455
  }
3366
3456
  }
3367
- function Pr(e, t) {
3368
- if (je(new Headers(t)))
3457
+ function qr(e, t) {
3458
+ if (Xe(new Headers(t)))
3369
3459
  try {
3370
- return e.responseType === "" || e.responseType === "text" ? U(e.responseText ?? "") : void 0;
3460
+ return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
3371
3461
  } catch {
3372
3462
  return;
3373
3463
  }
3374
3464
  }
3375
- function Ee(e) {
3465
+ function Re(e) {
3376
3466
  if (typeof e == "string")
3377
- return U(e);
3467
+ return P(e);
3378
3468
  }
3379
- function Dr(e) {
3469
+ function Hr(e) {
3380
3470
  return _({
3381
3471
  ...e,
3382
- requestBody: Re(e.requestBody),
3383
- responseBody: Re(e.responseBody)
3472
+ requestBody: Me(e.requestBody),
3473
+ responseBody: Me(e.responseBody)
3384
3474
  });
3385
3475
  }
3386
- function Re(e) {
3476
+ function Me(e) {
3387
3477
  if (typeof e != "string")
3388
3478
  return e;
3389
3479
  const t = e.trim();
3390
3480
  if (!t.startsWith("{") && !t.startsWith("["))
3391
- return it(e);
3481
+ return lt(e);
3392
3482
  try {
3393
3483
  return JSON.stringify(_(JSON.parse(e)));
3394
3484
  } catch {
3395
- return it(e);
3485
+ return lt(e);
3396
3486
  }
3397
3487
  }
3398
- function je(e) {
3488
+ function Xe(e) {
3399
3489
  if (!e)
3400
3490
  return !1;
3401
3491
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
3402
- return s !== null && Number.isInteger(n) && n >= 0 && n <= $t && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3492
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= Kt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3403
3493
  }
3404
3494
  function x(e, t = {}, s) {
3405
- if (Or(s))
3495
+ if (Fr(s))
3406
3496
  return !0;
3407
3497
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3408
3498
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3417,7 +3507,7 @@ function x(e, t = {}, s) {
3417
3507
  return !0;
3418
3508
  }
3419
3509
  }
3420
- function vr(e, t) {
3510
+ function Wr(e, t) {
3421
3511
  if (x(e))
3422
3512
  return !0;
3423
3513
  try {
@@ -3427,115 +3517,117 @@ function vr(e, t) {
3427
3517
  return !0;
3428
3518
  }
3429
3519
  }
3430
- function Or(e) {
3520
+ function Fr(e) {
3431
3521
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
3432
3522
  }
3433
- function Nr(e) {
3523
+ function $r(e) {
3434
3524
  const t = {};
3435
3525
  for (const s of e.trim().split(/[\r\n]+/)) {
3436
3526
  const n = s.indexOf(":");
3437
3527
  if (n <= 0)
3438
3528
  continue;
3439
- if (Object.keys(t).length >= jt)
3529
+ if (Object.keys(t).length >= Gt)
3440
3530
  break;
3441
3531
  const r = s.slice(0, n).trim();
3442
- t[r] = Jt(r, s.slice(n + 1).trim());
3532
+ t[r] = Zt(r, s.slice(n + 1).trim());
3443
3533
  }
3444
3534
  return t;
3445
3535
  }
3446
- function U(e, t = $t) {
3536
+ function P(e, t = Kt) {
3447
3537
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
3448
3538
  }
3449
- function Ut(e) {
3539
+ function Dt(e) {
3450
3540
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
3451
3541
  }
3452
- class nt extends Error {
3542
+ class at extends Error {
3453
3543
  constructor(t, s) {
3454
3544
  super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
3455
3545
  }
3456
3546
  status;
3457
3547
  }
3458
- async function tt(e, t) {
3548
+ async function rt(e, t) {
3459
3549
  let s = null;
3460
- for (let n = 0; n < de; n += 1)
3550
+ for (let n = 0; n < fe; n += 1)
3461
3551
  try {
3462
3552
  return await e();
3463
3553
  } catch (r) {
3464
- if (s = r, n >= de - 1 || !Lr(r))
3554
+ if (s = r, n >= fe - 1 || !zr(r))
3465
3555
  throw r;
3466
- await xr(n);
3556
+ await jr(n);
3467
3557
  }
3468
3558
  throw s instanceof Error ? s : new Error(t);
3469
3559
  }
3470
- function xr(e) {
3560
+ function jr(e) {
3471
3561
  return new Promise((t) => {
3472
- window.setTimeout(t, Bs[e] ?? 0);
3562
+ window.setTimeout(t, $s[e] ?? 0);
3473
3563
  });
3474
3564
  }
3475
- function Lr(e) {
3476
- return e instanceof nt ? qr(e.status) : e instanceof TypeError;
3565
+ function zr(e) {
3566
+ return e instanceof at ? Kr(e.status) : e instanceof TypeError;
3477
3567
  }
3478
- function qr(e) {
3568
+ function Kr(e) {
3479
3569
  return e === 408 || e === 409 || e === 429 || e >= 500;
3480
3570
  }
3481
- function Br(e) {
3571
+ function Gr(e) {
3482
3572
  return e === 401 || e === 403;
3483
3573
  }
3484
- const ut = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", Fr = "[REDACTED_SIGNED_URL]", Hr = 20, Wr = /^(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, ze = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Ke = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ge = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Xe = /\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, $r = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, jr = /\bhttps?:\/\/[^\s"'<>]+/gi, zr = /[),.;\]]+$/;
3574
+ const ht = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", Xr = "[REDACTED_SIGNED_URL]", Jr = 20, Vr = /^(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, Je = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Ve = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ye = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ze = /\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, Yr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Zr = /\bhttps?:\/\/[^\s"'<>]+/gi, Qr = /[),.;\]]+$/;
3485
3575
  function _(e) {
3486
- return rt(e, 0, /* @__PURE__ */ new WeakSet());
3576
+ return ct(e, 0, /* @__PURE__ */ new WeakSet());
3487
3577
  }
3488
- function rt(e, t, s) {
3578
+ function ct(e, t, s) {
3489
3579
  if (typeof e == "string")
3490
- return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
3580
+ return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : lt(e);
3491
3581
  if (e === null || typeof e != "object")
3492
3582
  return e;
3493
- if (t >= Hr)
3583
+ if (t >= Jr)
3494
3584
  return "[REDACTED_MAX_DEPTH]";
3495
3585
  if (s.has(e))
3496
3586
  return "[REDACTED_CIRCULAR]";
3497
3587
  if (s.add(e), Array.isArray(e))
3498
- return e.map((r) => rt(r, t + 1, s));
3588
+ return e.map((r) => ct(r, t + 1, s));
3499
3589
  const n = {};
3500
3590
  for (const [r, i] of Object.entries(e))
3501
- r === "pageContent" ? n[r] = i : Je(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Kr(i) : rt(i, t + 1, s);
3591
+ r === "pageContent" ? n[r] = i : Qe(r) ? n[r] = ht : n[r] = r.toLowerCase() === "url" ? ti(i) : ct(i, t + 1, s);
3502
3592
  return n;
3503
3593
  }
3504
- function Je(e) {
3594
+ function Qe(e) {
3505
3595
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
3506
3596
  return t.includes("authorization") || t.includes("cookie") || t.includes("password") || t.includes("passwd") || t === "pwd" || t.includes("secret") || t === "token" || t.endsWith("token") || t.includes("apikey") || t.includes("csrf") || t.includes("xsrf") || t === "jwt" || t === "session" || t === "signature" || t.includes("privatekey");
3507
3597
  }
3508
- function Kr(e) {
3509
- return typeof e == "string" ? Ve(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3598
+ function ti(e) {
3599
+ return typeof e == "string" ? ts(e) : ct(e, 0, /* @__PURE__ */ new WeakSet());
3510
3600
  }
3511
- function Ve(e) {
3601
+ function ts(e) {
3512
3602
  try {
3513
3603
  const t = new URL(e, location.href);
3514
3604
  for (const s of Array.from(t.searchParams.keys()))
3515
- Wr.test(s) && t.searchParams.set(s, P);
3516
- return t.username && (t.username = P), t.password && (t.password = P), t.toString();
3605
+ Vr.test(s) && t.searchParams.set(s, U);
3606
+ return t.username && (t.username = U), t.password && (t.password = U), t.toString();
3517
3607
  } catch {
3518
- return Gr(e);
3608
+ return ei(e);
3519
3609
  }
3520
3610
  }
3521
- function it(e) {
3522
- return e.replace($r, Fr).replace(jr, Xr).replace(ze, `Bearer ${P}`).replace(Ke, `Basic ${P}`).replace(Ge, P).replace(Xe, (t, s) => `${s}: ${ut}`);
3611
+ function lt(e) {
3612
+ return e.replace(Yr, Xr).replace(Zr, si).replace(Je, `Bearer ${U}`).replace(Ve, `Basic ${U}`).replace(Ye, U).replace(Ze, (t, s) => `${s}: ${ht}`);
3523
3613
  }
3524
- function Gr(e) {
3525
- return e.replace(ze, `Bearer ${P}`).replace(Ke, `Basic ${P}`).replace(Ge, P).replace(Xe, (t, s) => `${s}: ${ut}`);
3614
+ function ei(e) {
3615
+ return e.replace(Je, `Bearer ${U}`).replace(Ve, `Basic ${U}`).replace(Ye, U).replace(Ze, (t, s) => `${s}: ${ht}`);
3526
3616
  }
3527
- function Xr(e) {
3528
- const t = e.match(zr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3529
- return `${Ve(s)}${t}`;
3617
+ function si(e) {
3618
+ const t = e.match(Qr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3619
+ return `${ts(s)}${t}`;
3530
3620
  }
3531
3621
  export {
3532
- ie as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3533
- Dt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3534
- Ss as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3535
- ws as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3536
- As as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3537
- Ue as PlunoProductAgent,
3538
- js as calculateReconnectDelay,
3539
- Ue as default,
3540
- gn as getProductAgentOriginAccessErrorMessage
3622
+ ce as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3623
+ Nt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3624
+ Ms as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3625
+ Rs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3626
+ bs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3627
+ ni as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
3628
+ De as PlunoProductAgent,
3629
+ Js as calculateReconnectDelay,
3630
+ De as default,
3631
+ Tn as getProductAgentOriginAccessErrorMessage,
3632
+ Pr as validateProductAgentProviderInputFile
3541
3633
  };