@pluno/product-agent-web 0.1.95 → 0.1.97

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,11 +1,11 @@
1
- const ie = "pluno-product-agent-attachments";
1
+ const oe = "pluno-product-agent-attachments";
2
2
  const st = "files";
3
- async function Lt(e) {
3
+ async function Bt(e) {
4
4
  const t = await $();
5
- await qt(t, "readwrite", (s) => s.put(e));
5
+ await xt(t, "readwrite", (s) => s.put(e));
6
6
  }
7
- async function oe(e) {
8
- const t = await $(), s = await qt(
7
+ async function ae(e) {
8
+ const t = await $(), s = await xt(
9
9
  t,
10
10
  "readonly",
11
11
  (r) => r.get(e)
@@ -13,9 +13,9 @@ async function oe(e) {
13
13
  if (!s)
14
14
  return null;
15
15
  const n = Date.now();
16
- return await Bt(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
16
+ return await qt(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
17
17
  }
18
- async function Bt(e, t) {
18
+ async function qt(e, t) {
19
19
  const s = await $();
20
20
  await dt(s, "readwrite", async (n) => {
21
21
  const r = await ht(
@@ -27,7 +27,7 @@ async function Bt(e, t) {
27
27
  });
28
28
  });
29
29
  }
30
- async function ae(e = 864e5) {
30
+ async function ce(e = 864e5) {
31
31
  const t = await $(), s = Date.now() - e;
32
32
  await dt(t, "readwrite", async (n) => {
33
33
  const r = n.index("lastUsedAt");
@@ -36,14 +36,14 @@ async function ae(e = 864e5) {
36
36
  }
37
37
  function $() {
38
38
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
39
- const s = indexedDB.open(ie, 1);
39
+ const s = indexedDB.open(oe, 1);
40
40
  s.onupgradeneeded = () => {
41
41
  const r = s.result.createObjectStore(st, { keyPath: "attachmentId" });
42
42
  r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
43
43
  }, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
44
44
  });
45
45
  }
46
- async function qt(e, t, s) {
46
+ async function xt(e, t, s) {
47
47
  return await dt(e, t, async (n) => await ht(s(n)));
48
48
  }
49
49
  function dt(e, t, s) {
@@ -73,11 +73,11 @@ function ht(e) {
73
73
  e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
74
74
  });
75
75
  }
76
- function ce(e) {
76
+ function le(e) {
77
77
  return e !== null && (typeof e == "object" || typeof e == "function");
78
78
  }
79
- function xt(e, t, s) {
80
- const n = Reflect.get(e, "pluno"), r = ce(n) ? n : {};
79
+ function Ft(e, t, s) {
80
+ const n = Reflect.get(e, "pluno"), r = le(n) ? n : {};
81
81
  if (r !== n && !Reflect.set(e, "pluno", r))
82
82
  return null;
83
83
  const i = Object.getOwnPropertyDescriptor(r, t);
@@ -91,8 +91,8 @@ function xt(e, t, s) {
91
91
  }
92
92
  };
93
93
  }
94
- const H = "pluno.productAgent.scheduledChatContinuation.", nt = "pluno:scheduled-chat-continuation-changed", Ft = 10080 * 6e4, le = 5e3, ue = 15e3;
95
- function de(e, {
94
+ const H = "pluno.productAgent.scheduledChatContinuation.", nt = "pluno:scheduled-chat-continuation-changed", Ht = 10080 * 6e4, ue = 5e3, de = 15e3;
95
+ function he(e, {
96
96
  clientId: t,
97
97
  sessionId: s,
98
98
  callId: n
@@ -103,7 +103,7 @@ function de(e, {
103
103
  clientId: t,
104
104
  sessionId: s,
105
105
  defaultTaskId: `scheduled-${n}`,
106
- expiresAfterDueMs: Ft
106
+ expiresAfterDueMs: Ht
107
107
  })});
108
108
  const scheduleQuery = (query, delaySeconds) => {
109
109
  if (typeof query !== "string" || query.trim().length === 0) {
@@ -132,15 +132,15 @@ const scheduleQuery = (query, delaySeconds) => {
132
132
  };
133
133
  ${e}`;
134
134
  }
135
- function he(e) {
136
- const t = e.storage === void 0 ? pe() : e.storage;
135
+ function pe(e) {
136
+ const t = e.storage === void 0 ? fe() : e.storage;
137
137
  let s = null, n = !1, r = !1, i = !1, o = t !== null;
138
138
  const c = /* @__PURE__ */ new Map(), u = () => {
139
139
  s !== null && (clearTimeout(s), s = null);
140
140
  }, l = () => {
141
141
  u(), !(i || !o) && (s = setTimeout(() => {
142
142
  s = null, h();
143
- }, le));
143
+ }, ue));
144
144
  }, a = () => {
145
145
  o = !1, u();
146
146
  }, h = async () => {
@@ -170,7 +170,7 @@ function he(e) {
170
170
  e.onTasksChanged?.(m);
171
171
  for (const g of m)
172
172
  if (!(g.clientId !== e.clientId || g.dueAt > f || c.has(g.id) || !await e.canDeliver(g))) {
173
- c.set(g.id, f + ue);
173
+ c.set(g.id, f + de);
174
174
  try {
175
175
  await e.deliver(g);
176
176
  } catch {
@@ -216,9 +216,9 @@ function D(e) {
216
216
  if (!e || typeof e != "object")
217
217
  return !1;
218
218
  const t = e;
219
- return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt + Ft;
219
+ return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt + Ht;
220
220
  }
221
- function pe() {
221
+ function fe() {
222
222
  let e;
223
223
  try {
224
224
  e = window.localStorage, e.length;
@@ -262,11 +262,11 @@ function pe() {
262
262
  function J(e) {
263
263
  return `${H}${e}`;
264
264
  }
265
- const V = "pluno.productAgent.transportId", fe = "pluno.productAgent.transportIdentity", Y = "pluno.productAgent.transportIdentity.event", ge = 50, me = globalThis.setTimeout.bind(globalThis);
265
+ const Y = "pluno.productAgent.transportId", ge = "pluno.productAgent.transportIdentity", V = "pluno.productAgent.transportIdentity.event", me = 50, ye = globalThis.setTimeout.bind(globalThis);
266
266
  let P = null;
267
267
  const q = /* @__PURE__ */ new Set();
268
- async function ye(e = Ht()) {
269
- const t = e.randomUUID(), s = e.storage.getItem(V);
268
+ async function Te(e = Wt()) {
269
+ const t = e.randomUUID(), s = e.storage.getItem(Y);
270
270
  let n = s ?? e.randomUUID(), r = !1, i = !1;
271
271
  const o = e.channel.subscribe((u) => {
272
272
  if (!(u.senderId === t || u.transportId !== n)) {
@@ -284,14 +284,14 @@ async function ye(e = Ht()) {
284
284
  }
285
285
  });
286
286
  if (!s)
287
- e.storage.setItem(V, n), r = !0;
287
+ e.storage.setItem(Y, n), r = !0;
288
288
  else
289
289
  for (; ; ) {
290
290
  if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
291
291
  r = !0;
292
292
  break;
293
293
  }
294
- n = e.randomUUID(), e.storage.setItem(V, n);
294
+ n = e.randomUUID(), e.storage.setItem(Y, n);
295
295
  }
296
296
  let c = !1;
297
297
  return {
@@ -301,14 +301,14 @@ async function ye(e = Ht()) {
301
301
  }
302
302
  };
303
303
  }
304
- async function Te() {
305
- P || (P = ye(Ht()), P.then((n) => {
304
+ async function we() {
305
+ P || (P = Te(Wt()), P.then((n) => {
306
306
  const r = (i) => {
307
307
  i.persisted || (n.release(), P = null, q.clear(), window.removeEventListener("pagehide", r));
308
308
  };
309
309
  window.addEventListener("pagehide", r);
310
310
  }));
311
- const e = await P, t = we();
311
+ const e = await P, t = Ie();
312
312
  q.add(t);
313
313
  let s = !1;
314
314
  return {
@@ -319,23 +319,23 @@ async function Te() {
319
319
  }
320
320
  };
321
321
  }
322
- function we() {
322
+ function Ie() {
323
323
  let e = 0;
324
324
  for (; q.has(e); )
325
325
  e += 1;
326
326
  return e;
327
327
  }
328
- function Ht() {
328
+ function Wt() {
329
329
  return {
330
330
  storage: window.sessionStorage,
331
- channel: Ie(),
331
+ channel: Ae(),
332
332
  randomUUID: () => crypto.randomUUID(),
333
- settle: () => new Promise((e) => me(e, ge))
333
+ settle: () => new Promise((e) => ye(e, me))
334
334
  };
335
335
  }
336
- function Ie() {
336
+ function Ae() {
337
337
  if (typeof BroadcastChannel < "u") {
338
- const e = new BroadcastChannel(fe);
338
+ const e = new BroadcastChannel(ge);
339
339
  return {
340
340
  postMessage: (t) => e.postMessage(t),
341
341
  subscribe: (t) => {
@@ -345,11 +345,11 @@ function Ie() {
345
345
  close: () => e.close()
346
346
  };
347
347
  }
348
- return Ae();
348
+ return Se();
349
349
  }
350
- function Ae() {
350
+ function Se() {
351
351
  const e = /* @__PURE__ */ new Set(), t = (s) => {
352
- if (s.key !== Y || !s.newValue)
352
+ if (s.key !== V || !s.newValue)
353
353
  return;
354
354
  const n = JSON.parse(s.newValue);
355
355
  for (const r of e)
@@ -358,9 +358,9 @@ function Ae() {
358
358
  return window.addEventListener("storage", t), {
359
359
  postMessage: (s) => {
360
360
  window.localStorage.setItem(
361
- Y,
361
+ V,
362
362
  JSON.stringify({ ...s, eventId: crypto.randomUUID() })
363
- ), window.localStorage.removeItem(Y);
363
+ ), window.localStorage.removeItem(V);
364
364
  },
365
365
  subscribe: (s) => (e.add(s), () => e.delete(s)),
366
366
  close: () => {
@@ -368,17 +368,18 @@ function Ae() {
368
368
  }
369
369
  };
370
370
  }
371
- const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Se = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ke = ".pluno-pa-widget__panel", Ee = ".pluno-pa-widget__timeline", At = `${rt}[data-pluno-sdk-preview-channel]`, Re = "https://app.pluno.ai", Ce = "gpt-5.6-terra", _e = 2e4, be = 1e4, Me = 1e4, Pe = 1e4, Ue = 1e4, De = 1e3, St = 3e4, kt = 0.2, Et = 6e4, ve = 15e3, N = 3, Ne = 2e3, Oe = 15e3, Le = 1e3, Be = 100, qe = 8e3, xe = 15e3, Rt = 3, Fe = [300, 1e3], pt = 64e3, Z = 4e3, ft = 30, He = 2e3, We = 1e3, je = 200 * 1024 * 1024, gt = "Image is too large for model vision input.", $e = 100, Wt = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", ze = 100;
371
+ const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ke = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ee = ".pluno-pa-widget__panel", Re = ".pluno-pa-widget__timeline", At = `${rt}[data-pluno-sdk-preview-channel]`, _e = "https://app.pluno.ai", Ce = "gpt-5.6-terra", be = 2e4, Me = 1e4, Pe = 1e4, Ue = 1e4, De = 1e4, ve = 1e3, St = 3e4, kt = 0.2, Et = 6e4, Ne = 15e3, N = 8, Oe = 15e3, Le = 2e3, Be = 1e3, qe = 100, xe = 8e3, Fe = 15e3, Rt = 3, He = [300, 1e3], pt = 64e3, Z = 4e3, ft = 30, We = 2e3, je = 1e3, $e = 200 * 1024 * 1024, gt = "Image is too large for model vision input.", ze = 100, jt = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", Ge = 100;
372
372
  function O(e, t = 0) {
373
- return Math.max(t, Ne * 4 ** e);
373
+ const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
374
+ return Math.max(t, s);
374
375
  }
375
376
  const x = /* @__PURE__ */ new Set();
376
377
  let L = null;
377
- function Ge(e, t = Math.random) {
378
- const s = Math.min(St, De * 2 ** e), n = 1 - kt + t() * kt * 2;
378
+ function Xe(e, t = Math.random) {
379
+ const s = Math.min(St, ve * 2 ** e), n = 1 - kt + t() * kt * 2;
379
380
  return Math.min(St, Math.round(s * n));
380
381
  }
381
- function Xe(e, t, s) {
382
+ function Ke(e, t, s) {
382
383
  return new Promise((n, r) => {
383
384
  const i = setTimeout(() => r(new Error(s)), t);
384
385
  e.then(
@@ -391,13 +392,13 @@ function Xe(e, t, s) {
391
392
  );
392
393
  });
393
394
  }
394
- class jt {
395
+ class $t {
395
396
  constructor(t, s) {
396
397
  this.options = t, this.transportIdentity = s, this.state = {
397
398
  ...this.state,
398
- starterPrompts: Is(t.initialStarterPrompts)
399
+ starterPrompts: As(t.initialStarterPrompts)
399
400
  };
400
- const n = t.restorePersistedState === !1 ? null : Zs(t.clientId, t.expectedPersistedSessionId);
401
+ const n = t.restorePersistedState === !1 ? null : Qs(t.clientId, t.expectedPersistedSessionId);
401
402
  n && (this.state = {
402
403
  ...this.state,
403
404
  ...n,
@@ -408,10 +409,10 @@ class jt {
408
409
  assistantDraftRunId: null,
409
410
  isThinking: !1,
410
411
  lastError: null
411
- }), this.queuedClientEvents = on(
412
- tn(t.clientId),
413
- sn(t.clientId)
414
- ), U(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = he({
412
+ }), this.queuedClientEvents = an(
413
+ en(t.clientId),
414
+ nn(t.clientId)
415
+ ), U(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = pe({
415
416
  clientId: t.clientId,
416
417
  canDeliver: (r) => r.sessionId === this.state.sessionId,
417
418
  deliver: async (r) => {
@@ -483,14 +484,14 @@ class jt {
483
484
  lastErrorCode: null
484
485
  };
485
486
  static async init(t) {
486
- const s = await Te(), n = new jt({
487
+ const s = await we(), n = new $t({
487
488
  ...t,
488
- backendUrl: ds(t.backendUrl ?? Re),
489
- clientId: t.clientId ?? Rs(),
489
+ backendUrl: hs(t.backendUrl ?? _e),
490
+ clientId: t.clientId ?? _s(),
490
491
  model: t.model ?? Ce
491
492
  }, s);
492
493
  try {
493
- ae().catch((r) => {
494
+ ce().catch((r) => {
494
495
  y("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
495
496
  message: r instanceof Error ? r.message : String(r)
496
497
  });
@@ -522,14 +523,14 @@ class jt {
522
523
  lastError: null
523
524
  });
524
525
  try {
525
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Xe(this.options.tokenProvider(), Me, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
526
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ke(this.options.tokenProvider(), Pe, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
526
527
  return;
527
528
  if (!this.token && !this.options.webSocketFactory)
528
529
  throw new Error("Pluno requires a token or tokenProvider");
529
- const s = ps(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
530
+ const s = fs(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
530
531
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
531
532
  this.socket === n && n.readyState === WebSocket.CONNECTING && (y("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
532
- }, Pe), n.addEventListener("open", () => {
533
+ }, Ue), n.addEventListener("open", () => {
533
534
  this.socket !== n || (this.clearSocketConnectTimer(), y("web-sdk.agent", "Pluno socket opened", {
534
535
  queuedClientEventCount: this.queuedClientEvents.length,
535
536
  isThinking: this.state.isThinking
@@ -541,9 +542,9 @@ class jt {
541
542
  pageUrl: location.href
542
543
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
543
544
  this.socket === n && (y("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
544
- }, Ue));
545
+ }, De));
545
546
  }), n.addEventListener("message", (r) => {
546
- this.socket === n && this.handleServerEvent(ws(r.data));
547
+ this.socket === n && this.handleServerEvent(Is(r.data));
547
548
  }), n.addEventListener("close", (r) => {
548
549
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (y("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
549
550
  code: typeof r?.code == "number" ? r.code : null,
@@ -576,7 +577,7 @@ class jt {
576
577
  this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
577
578
  }
578
579
  destroy() {
579
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), an(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
580
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), cn(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
580
581
  for (const t of Object.values(this.listeners))
581
582
  t?.clear();
582
583
  }
@@ -612,7 +613,7 @@ class jt {
612
613
  attachments: i.length > 0 ? i : void 0,
613
614
  page: o,
614
615
  model: this.options.model,
615
- metadata: Ct(this.options.metadata)
616
+ metadata: _t(this.options.metadata)
616
617
  };
617
618
  return this.activeClientMessageId = c, this.activeUserMessageEvent = a, this.markThinkingProgress(), this.send(a), this.startBackgroundAttachmentUploads(c, i), c;
618
619
  }
@@ -624,12 +625,12 @@ class jt {
624
625
  const s = B(), n = {
625
626
  id: s,
626
627
  name: t.name || "attachment",
627
- mimeType: vt(t),
628
+ mimeType: Nt(t),
628
629
  sizeBytes: t.size
629
630
  };
630
631
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
631
632
  const r = Date.now();
632
- return Lt({
633
+ return Bt({
633
634
  attachmentId: s,
634
635
  name: n.name,
635
636
  mimeType: n.mimeType,
@@ -684,7 +685,7 @@ class jt {
684
685
  waitForSession: r,
685
686
  notifyCompletion: i
686
687
  }) {
687
- const o = r ? await this.waitForSessionId() : this.state.sessionId, c = vt(t), u = {
688
+ const o = r ? await this.waitForSessionId() : this.state.sessionId, c = Nt(t), u = {
688
689
  sessionId: o ?? void 0,
689
690
  attachmentId: s.id,
690
691
  clientId: this.options.clientId,
@@ -694,7 +695,7 @@ class jt {
694
695
  sizeBytes: t.size,
695
696
  page: S(),
696
697
  model: this.options.model,
697
- metadata: Ct(this.options.metadata)
698
+ metadata: _t(this.options.metadata)
698
699
  }, l = this.options.prepareAttachmentUpload ? await et(
699
700
  () => this.options.prepareAttachmentUpload(u),
700
701
  "Failed to prepare attachment upload"
@@ -710,7 +711,7 @@ class jt {
710
711
  return h;
711
712
  }, "Failed to upload attachment"), this.setState({ sessionId: l.sessionId });
712
713
  const a = Vt(l.attachment, this.options.backendUrl);
713
- return this.updateAttachmentInState(s.id, a), s.id && Bt(s.id, {
714
+ return this.updateAttachmentInState(s.id, a), s.id && qt(s.id, {
714
715
  sessionId: l.sessionId,
715
716
  fileUrl: a.fileUrl,
716
717
  gcsPath: a.gcsPath,
@@ -732,7 +733,7 @@ class jt {
732
733
  return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
733
734
  const n = window.setTimeout(() => {
734
735
  r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
735
- }, xe), r = this.on("state", (i) => {
736
+ }, Fe), r = this.on("state", (i) => {
736
737
  i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
737
738
  });
738
739
  });
@@ -754,7 +755,7 @@ class jt {
754
755
  const n = await this.fetchEmbedAttachmentUpload(t);
755
756
  if (n.ok)
756
757
  return await n.json();
757
- if (Rn(n.status) && this.options.tokenProvider && !s) {
758
+ if (_n(n.status) && this.options.tokenProvider && !s) {
758
759
  s = !0;
759
760
  const r = await this.fetchEmbedAttachmentUpload(t);
760
761
  if (r.ok)
@@ -799,7 +800,7 @@ class jt {
799
800
  const s = B(), n = new Promise((i, o) => {
800
801
  const c = window.setTimeout(() => {
801
802
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
802
- }, qe);
803
+ }, xe);
803
804
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: c });
804
805
  }), r = {
805
806
  type: "sessions.list",
@@ -856,7 +857,7 @@ class jt {
856
857
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
857
858
  return;
858
859
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
859
- const t = fs();
860
+ const t = gs();
860
861
  this.sendNow(
861
862
  k({
862
863
  type: "starter_prompts.page_context",
@@ -867,13 +868,13 @@ class jt {
867
868
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
868
869
  }
869
870
  startStarterPromptUrlWatcher() {
870
- this.locationChangeCleanup || (this.locationChangeCleanup = gs(() => this.handleStarterPromptUrlChange()));
871
+ this.locationChangeCleanup || (this.locationChangeCleanup = ms(() => this.handleStarterPromptUrlChange()));
871
872
  }
872
873
  handleStarterPromptUrlChange() {
873
874
  const t = location.href;
874
875
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
875
876
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
876
- }, ze));
877
+ }, Ge));
877
878
  }
878
879
  refreshStarterPromptsForCurrentUrl() {
879
880
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -909,17 +910,17 @@ class jt {
909
910
  }
910
911
  if (Ve(t) && this.markThinkingProgress(), t.type === "auth.ok") {
911
912
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
912
- const s = As(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
913
+ const s = Ss(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
913
914
  y("web-sdk.agent", "Received auth.ok appearance", {
914
915
  hasAppearance: n,
915
916
  rawAppearance: t.appearance,
916
917
  normalizedAppearance: s
917
- }), this.runtimeHelperJavascript = Ss(t.runtimeHelpers)?.javascript ?? null;
918
+ }), this.runtimeHelperJavascript = ks(t.runtimeHelpers)?.javascript ?? null;
918
919
  const r = bt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
919
920
  user: Cs(t.user),
920
921
  status: "connected"
921
922
  };
922
- (i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !ys() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
923
+ (i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !Ts() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
923
924
  type: "page.upsert",
924
925
  sessionId: this.state.sessionId,
925
926
  page: S(),
@@ -937,29 +938,32 @@ class jt {
937
938
  if (t.type === "conversation.state") {
938
939
  const s = Array.isArray(t.items) ? t.items : [];
939
940
  this.rememberUserMessageClientMessageIds(s);
940
- const n = Ws(s);
941
+ const n = js(s);
941
942
  if (n) {
942
- const a = js(s, n);
943
+ const a = $s(s, n);
943
944
  this.retryAttemptsByClientMessageId[n] = Math.max(
944
945
  this.retryAttemptsByClientMessageId[n] ?? 0,
945
946
  a
946
947
  );
947
948
  }
948
- const r = n ? s.filter((a) => !at(v(a))) : s, i = Os(
949
+ const r = s.filter((a) => {
950
+ const h = v(a);
951
+ return !Pt(h) && (!n || !at(h));
952
+ }), i = Ls(
949
953
  this.state.messages,
950
- _s(r, this.options.backendUrl)
954
+ bs(r, this.options.backendUrl)
951
955
  ), o = Mt(i), c = s.some(
952
- (a) => Ut(
956
+ (a) => Dt(
953
957
  v(a),
954
958
  this.state.assistantDraft,
955
959
  this.state.assistantDraftRespondsToUserMessageId,
956
960
  this.state.assistantDraftRunId
957
961
  )
958
962
  ), u = o && (!this.state.assistantDraft || c);
959
- if (!o && Hs(this.state.messages, s))
963
+ if (!o && Ws(this.state.messages, s))
960
964
  return;
961
965
  const l = u ? null : ct(s);
962
- if (this.latestRecoverableClientMessageId = l, xs(i) && this.clearRetryTimers(), this.setState({
966
+ if (this.latestRecoverableClientMessageId = l, Fs(i) && this.clearRetryTimers(), this.setState({
963
967
  sessionId: I(t.session, "id") ?? this.state.sessionId,
964
968
  messages: i,
965
969
  ...u ? {
@@ -982,7 +986,7 @@ class jt {
982
986
  if (t.type === "sessions.page") {
983
987
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
984
988
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
985
- sessions: bs(t.sessions),
989
+ sessions: Ms(t.sessions),
986
990
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
987
991
  }));
988
992
  return;
@@ -1006,12 +1010,14 @@ class jt {
1006
1010
  return;
1007
1011
  }
1008
1012
  }
1009
- const n = zt(t.item, this.options.backendUrl);
1013
+ if (Pt(s))
1014
+ return;
1015
+ const n = Gt(t.item, this.options.backendUrl);
1010
1016
  if (n) {
1011
1017
  n.role === "assistant" && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1012
1018
  const r = t.item.data;
1013
- zs(r) && this.clearRunAckResyncRetryTimer();
1014
- const i = Ns(this.state.messages, n), o = Mt(i), c = Ut(
1019
+ Gs(r) && this.clearRunAckResyncRetryTimer();
1020
+ const i = Os(this.state.messages, n), o = Mt(i), c = Dt(
1015
1021
  r,
1016
1022
  this.state.assistantDraft,
1017
1023
  this.state.assistantDraftRespondsToUserMessageId,
@@ -1065,7 +1071,7 @@ class jt {
1065
1071
  return;
1066
1072
  }
1067
1073
  o && r && i && (this.retryableClientMessageId = i);
1068
- const c = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = hs(c.message);
1074
+ const c = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = ps(c.message);
1069
1075
  u && console.error(u), this.setState({
1070
1076
  status: "error",
1071
1077
  isThinking: !1,
@@ -1184,7 +1190,7 @@ class jt {
1184
1190
  clientMessageId: t,
1185
1191
  automatic: !0
1186
1192
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(Et)));
1187
- }, O(s)));
1193
+ }, O(s, Le)));
1188
1194
  }
1189
1195
  clearRunAckResyncRetryTimer() {
1190
1196
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1223,7 +1229,7 @@ class jt {
1223
1229
  sessionId: this.state.sessionId,
1224
1230
  clientMessageId: t,
1225
1231
  resyncAttempts: s + 1
1226
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(ve);
1232
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ne);
1227
1233
  return;
1228
1234
  }
1229
1235
  this.setState({
@@ -1255,7 +1261,7 @@ class jt {
1255
1261
  const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = typeof t.summary == "string" ? t.summary : "Running browser tool", o = t.rawInput;
1256
1262
  if (!s || !n || !r)
1257
1263
  return;
1258
- if (r !== "execute_code" || !pn(o)) {
1264
+ if (r !== "execute_code" || !fn(o)) {
1259
1265
  this.send({
1260
1266
  type: "tool.result",
1261
1267
  sessionId: s,
@@ -1271,7 +1277,7 @@ class jt {
1271
1277
  });
1272
1278
  return;
1273
1279
  }
1274
- const c = Qe(this.state.messages);
1280
+ const c = ts(this.state.messages);
1275
1281
  this.activeBrowserToolCalls.set(n, {
1276
1282
  event: {
1277
1283
  type: "tool.result",
@@ -1287,9 +1293,9 @@ class jt {
1287
1293
  startedAtOrigin: location.origin
1288
1294
  }), this.installSessionUserFilesApi(c);
1289
1295
  let u = null, l;
1290
- u = await this.executeRuntimeHelper(), l = await _t({
1296
+ u = await this.executeRuntimeHelper(), l = await Ct({
1291
1297
  ...o,
1292
- javascript: de(o.javascript, {
1298
+ javascript: he(o.javascript, {
1293
1299
  clientId: this.options.clientId,
1294
1300
  sessionId: s,
1295
1301
  callId: n
@@ -1306,40 +1312,40 @@ class jt {
1306
1312
  toolName: r,
1307
1313
  summary: o.summary,
1308
1314
  rawInput: k(o),
1309
- rawOutput: k(ks(l, u))
1310
- }), en(this.options.clientId, this.activeBrowserToolCalls.values());
1315
+ rawOutput: k(Es(l, u))
1316
+ }), sn(this.options.clientId, this.activeBrowserToolCalls.values());
1311
1317
  }
1312
1318
  startPageLifecycleRecovery() {
1313
1319
  if (this.pageLifecycleCleanup)
1314
1320
  return;
1315
1321
  const t = () => {
1316
- Kt(this.options.clientId, this.activeBrowserToolCalls.values());
1322
+ Jt(this.options.clientId, this.activeBrowserToolCalls.values());
1317
1323
  };
1318
1324
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1319
1325
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1320
1326
  };
1321
1327
  }
1322
1328
  installSessionUserFilesApi(t) {
1323
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = ts(t, this.attachmentFiles, this.attachmentBlobCache);
1329
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = es(t, this.attachmentFiles, this.attachmentBlobCache);
1324
1330
  }
1325
1331
  cleanupSessionUserFilesApi() {
1326
- this.sessionUserFilesApiCleanup && (cs(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1332
+ this.sessionUserFilesApiCleanup && (ls(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1327
1333
  }
1328
1334
  async executeRuntimeHelper() {
1329
1335
  if (!this.runtimeHelperJavascript?.trim())
1330
1336
  return null;
1331
- const t = await _t({
1337
+ const t = await Ct({
1332
1338
  javascript: this.runtimeHelperJavascript
1333
1339
  });
1334
- return t.ok === !1 ? Es(t) : null;
1340
+ return t.ok === !1 ? Rs(t) : null;
1335
1341
  }
1336
1342
  enableNetworkCapture() {
1337
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Ke((t) => {
1338
- wn(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1343
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = Je((t) => {
1344
+ In(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1339
1345
  }));
1340
1346
  }
1341
1347
  enqueueNetworkEvent(t) {
1342
- this.queuedNetworkEvents.length >= Be || (this.queuedNetworkEvents.push(Tn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1348
+ this.queuedNetworkEvents.length >= qe || (this.queuedNetworkEvents.push(wn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1343
1349
  this.networkBatchTimer = null;
1344
1350
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1345
1351
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1348,12 +1354,12 @@ class jt {
1348
1354
  page: S(),
1349
1355
  events: s
1350
1356
  });
1351
- }, Le)));
1357
+ }, Be)));
1352
1358
  }
1353
1359
  scheduleReconnect() {
1354
1360
  if (this.reconnectTimer !== null || this.state.status === "closed")
1355
1361
  return;
1356
- const t = Ge(this.reconnectAttempts);
1362
+ const t = Xe(this.reconnectAttempts);
1357
1363
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1358
1364
  this.reconnectTimer = null, this.connect().catch((s) => {
1359
1365
  y("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1369,8 +1375,8 @@ class jt {
1369
1375
  const t = this.socket;
1370
1376
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1371
1377
  this.socket === t && (y("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1372
- }, be));
1373
- }, _e);
1378
+ }, Me));
1379
+ }, be);
1374
1380
  }
1375
1381
  stopHeartbeat() {
1376
1382
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1395,20 +1401,20 @@ class jt {
1395
1401
  ...this.state,
1396
1402
  ...t,
1397
1403
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
1398
- }, Qs(this.options.clientId, this.state), this.emit("state", this.getState());
1404
+ }, tn(this.options.clientId, this.state), this.emit("state", this.getState());
1399
1405
  }
1400
1406
  emit(t, s) {
1401
1407
  this.listeners[t]?.forEach((r) => r(s));
1402
1408
  }
1403
1409
  }
1404
1410
  const Q = /* @__PURE__ */ new WeakMap();
1405
- function Ke(e) {
1406
- const t = window.__plunoProductAgentNetworkCapture ?? Je();
1411
+ function Je(e) {
1412
+ const t = window.__plunoProductAgentNetworkCapture ?? Ye();
1407
1413
  return t.subscribers.add(e), () => {
1408
1414
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1409
1415
  };
1410
1416
  }
1411
- function Je() {
1417
+ function Ye() {
1412
1418
  const e = /* @__PURE__ */ new Set(), t = (T) => {
1413
1419
  e.forEach((p) => {
1414
1420
  try {
@@ -1425,31 +1431,31 @@ function Je() {
1425
1431
  throw m;
1426
1432
  }
1427
1433
  try {
1428
- const m = p instanceof Request ? p : null, g = fn(p, m), A = Yt(d?.headers ?? m?.headers);
1434
+ const m = p instanceof Request ? p : null, g = gn(p, m), A = Zt(d?.headers ?? m?.headers);
1429
1435
  if (!b(g, A, d?.body)) {
1430
1436
  const K = {
1431
1437
  requestId: tt("fetch"),
1432
1438
  url: E(g, Z),
1433
1439
  method: (d?.method ?? m?.method ?? "GET").toUpperCase(),
1434
1440
  requestHeaders: A,
1435
- requestBody: Nt(d?.body),
1441
+ requestBody: Ot(d?.body),
1436
1442
  resourceType: "fetch",
1437
1443
  startedAt: new Date(f).toISOString()
1438
1444
  };
1439
1445
  w.then(
1440
- (_) => {
1441
- gn(_, K, f, t).catch(() => {
1446
+ (C) => {
1447
+ mn(C, K, f, t).catch(() => {
1442
1448
  t({
1443
1449
  ...K,
1444
- responseStatus: _.status,
1450
+ responseStatus: C.status,
1445
1451
  durationMs: Date.now() - f
1446
1452
  });
1447
1453
  });
1448
1454
  },
1449
- (_) => {
1455
+ (C) => {
1450
1456
  t({
1451
1457
  ...K,
1452
- errorText: E(_ instanceof Error ? _.message : String(_)),
1458
+ errorText: E(C instanceof Error ? C.message : String(C)),
1453
1459
  durationMs: Date.now() - f
1454
1460
  });
1455
1461
  }
@@ -1475,12 +1481,12 @@ function Je() {
1475
1481
  }, l = function(p) {
1476
1482
  try {
1477
1483
  const d = Q.get(this);
1478
- d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = Nt(p), d.excluded || this.addEventListener(
1484
+ d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = Ot(p), d.excluded || this.addEventListener(
1479
1485
  "loadend",
1480
1486
  () => {
1481
1487
  queueMicrotask(() => {
1482
1488
  try {
1483
- const f = An(this.getAllResponseHeaders());
1489
+ const f = Sn(this.getAllResponseHeaders());
1484
1490
  t({
1485
1491
  requestId: d.requestId,
1486
1492
  url: d.url,
@@ -1490,7 +1496,7 @@ function Je() {
1490
1496
  resourceType: "xhr",
1491
1497
  responseStatus: this.status,
1492
1498
  responseHeaders: f,
1493
- responseBody: yn(this, f),
1499
+ responseBody: Tn(this, f),
1494
1500
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1495
1501
  startedAt: d.startedAt,
1496
1502
  durationMs: Date.now() - d.startedAtMs
@@ -1582,15 +1588,15 @@ function y(e, t, s) {
1582
1588
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1583
1589
  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 }));
1584
1590
  }
1585
- function Ct(e) {
1591
+ function _t(e) {
1586
1592
  const t = typeof e == "function" ? e() : e;
1587
1593
  return t && Object.keys(t).length > 0 ? t : void 0;
1588
1594
  }
1589
1595
  function Ve(e) {
1590
1596
  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";
1591
1597
  }
1592
- const Ye = 5e3, Ze = 12e4;
1593
- function Qe(e) {
1598
+ const Ze = 5e3, Qe = 12e4;
1599
+ function ts(e) {
1594
1600
  const t = [];
1595
1601
  for (const s of e)
1596
1602
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1601,17 +1607,17 @@ function Qe(e) {
1601
1607
  });
1602
1608
  return t;
1603
1609
  }
1604
- function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1610
+ function es(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1605
1611
  const n = [
1606
- es(e, t, s),
1607
- ss()
1612
+ ss(e, t, s),
1613
+ ns()
1608
1614
  ].filter((r) => typeof r == "function");
1609
1615
  return () => {
1610
1616
  for (const r of n.reverse())
1611
1617
  r();
1612
1618
  };
1613
1619
  }
1614
- function es(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1620
+ function ss(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1615
1621
  const n = new Map(e.map((l) => [l.id, l])), r = (l) => ({
1616
1622
  id: l.id,
1617
1623
  name: l.name,
@@ -1631,7 +1637,7 @@ function es(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1631
1637
  const T = s.get(a.id);
1632
1638
  if (T)
1633
1639
  return T;
1634
- const p = await oe(a.id).then((m) => m?.blob ?? null).catch((m) => (y("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
1640
+ const p = await ae(a.id).then((m) => m?.blob ?? null).catch((m) => (y("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
1635
1641
  attachmentId: a.id,
1636
1642
  name: a.name,
1637
1643
  message: m instanceof Error ? m.message : String(m)
@@ -1640,13 +1646,13 @@ function es(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1640
1646
  return s.set(a.id, p), p;
1641
1647
  if (!a.fileUrl)
1642
1648
  throw new Error(`Pluno user file is missing content: ${l}`);
1643
- const d = await fetch(a.fileUrl, cn(a.fileUrl));
1649
+ const d = await fetch(a.fileUrl, ln(a.fileUrl));
1644
1650
  if (!d.ok)
1645
1651
  throw new Error(`Failed to load Pluno user file: ${l}`);
1646
1652
  const f = await d.blob();
1647
1653
  s.set(a.id, f);
1648
1654
  const w = Date.now();
1649
- return Lt({
1655
+ return Bt({
1650
1656
  attachmentId: a.id,
1651
1657
  name: a.name,
1652
1658
  mimeType: a.mimeType,
@@ -1664,7 +1670,7 @@ function es(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1664
1670
  });
1665
1671
  }), f;
1666
1672
  };
1667
- return xt(globalThis, "userFiles", {
1673
+ return Ft(globalThis, "userFiles", {
1668
1674
  list: () => e.map(r),
1669
1675
  get: (l) => {
1670
1676
  const a = n.get(l);
@@ -1675,7 +1681,7 @@ function es(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1675
1681
  if (!T.startsWith("image/"))
1676
1682
  throw new Error(`Pluno user file is not an image: ${l}`);
1677
1683
  const p = h.type === T ? h : new Blob([h], { type: T });
1678
- return ls(T, p.size) > je ? {
1684
+ return us(T, p.size) > $e ? {
1679
1685
  type: "pluno.userFiles.inspectImage",
1680
1686
  id: a.id,
1681
1687
  name: a.name,
@@ -1702,13 +1708,13 @@ function es(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1702
1708
  }
1703
1709
  });
1704
1710
  }
1705
- function ss() {
1706
- return xt(globalThis, "pageImages", {
1707
- inspectImage: async (t, s) => await ns(t, s)
1711
+ function ns() {
1712
+ return Ft(globalThis, "pageImages", {
1713
+ inspectImage: async (t, s) => await rs(t, s)
1708
1714
  });
1709
1715
  }
1710
- async function ns(e, t = {}) {
1711
- const s = as(t.name), n = await rs(e);
1716
+ async function rs(e, t = {}) {
1717
+ const s = cs(t.name), n = await is(e);
1712
1718
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1713
1719
  type: "pluno.pageImages.inspectImage",
1714
1720
  imageAttached: !1,
@@ -1726,15 +1732,15 @@ async function ns(e, t = {}) {
1726
1732
  imageAttachmentError: n.error
1727
1733
  };
1728
1734
  }
1729
- async function rs(e) {
1735
+ async function is(e) {
1730
1736
  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: gt } : {
1731
1737
  ok: !0,
1732
1738
  mimeType: e.type,
1733
1739
  sizeBytes: e.size,
1734
1740
  dataUrl: await ot(e)
1735
- } : { 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." } : is(e);
1741
+ } : { 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." } : os(e);
1736
1742
  }
1737
- function is(e) {
1743
+ function os(e) {
1738
1744
  if (!e.startsWith("data:") || !e.includes(","))
1739
1745
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1740
1746
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((c) => c.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1745,7 +1751,7 @@ function is(e) {
1745
1751
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1746
1752
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1747
1753
  return { ok: !1, error: "Page image data URL has invalid base64." };
1748
- const o = os(i);
1754
+ const o = as(i);
1749
1755
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1750
1756
  ok: !0,
1751
1757
  mimeType: r,
@@ -1753,16 +1759,16 @@ function is(e) {
1753
1759
  dataUrl: `data:${r};base64,${i}`
1754
1760
  };
1755
1761
  }
1756
- function os(e) {
1762
+ function as(e) {
1757
1763
  if (e.length === 0 || e.length % 4 !== 0)
1758
1764
  return null;
1759
1765
  const t = e.length - e.replace(/=+$/, "").length;
1760
1766
  return t > 2 ? null : e.length / 4 * 3 - t;
1761
1767
  }
1762
- function as(e) {
1768
+ function cs(e) {
1763
1769
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1764
1770
  }
1765
- function cs(e) {
1771
+ function ls(e) {
1766
1772
  try {
1767
1773
  e();
1768
1774
  } catch {
@@ -1780,12 +1786,12 @@ function ot(e) {
1780
1786
  }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1781
1787
  });
1782
1788
  }
1783
- function ls(e, t) {
1789
+ function us(e, t) {
1784
1790
  return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
1785
1791
  }
1786
- async function _t(e) {
1792
+ async function Ct(e) {
1787
1793
  const t = Object.getPrototypeOf(async function() {
1788
- }).constructor, s = e.timeoutMs ?? Ye, n = Date.now(), r = [];
1794
+ }).constructor, s = e.timeoutMs ?? Ze, n = Date.now(), r = [];
1789
1795
  let i;
1790
1796
  const o = {
1791
1797
  log: console.log,
@@ -1803,7 +1809,7 @@ async function _t(e) {
1803
1809
  i = window.setTimeout(() => a(u), s);
1804
1810
  })
1805
1811
  ]);
1806
- return l === u ? us(s) : {
1812
+ return l === u ? ds(s) : {
1807
1813
  ok: !0,
1808
1814
  result: l,
1809
1815
  console: r,
@@ -1832,7 +1838,7 @@ async function _t(e) {
1832
1838
  i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
1833
1839
  }
1834
1840
  }
1835
- function us(e) {
1841
+ function ds(e) {
1836
1842
  return {
1837
1843
  ok: !1,
1838
1844
  exception: {
@@ -1846,18 +1852,18 @@ function us(e) {
1846
1852
  }
1847
1853
  };
1848
1854
  }
1849
- function ds(e) {
1855
+ function hs(e) {
1850
1856
  return e.replace(/\/+$/, "");
1851
1857
  }
1852
- function hs(e, t = location.origin) {
1858
+ function ps(e, t = location.origin) {
1853
1859
  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;
1854
1860
  }
1855
- function ps(e) {
1861
+ function fs(e) {
1856
1862
  const t = new URL("/api/product-agent/embed/ws", e);
1857
1863
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1858
1864
  }
1859
1865
  function S() {
1860
- const e = $t();
1866
+ const e = zt();
1861
1867
  return {
1862
1868
  url: location.href,
1863
1869
  title: document.title,
@@ -1865,19 +1871,19 @@ function S() {
1865
1871
  ...e ? { plunoProductAgentUi: e } : {}
1866
1872
  };
1867
1873
  }
1868
- function fs() {
1874
+ function gs() {
1869
1875
  return {
1870
1876
  pageUrl: location.href,
1871
1877
  pageTitle: document.title,
1872
- htmlContent: Ts()
1878
+ htmlContent: ws()
1873
1879
  };
1874
1880
  }
1875
- function gs(e) {
1876
- return x.add(e), L || (L = ms()), () => {
1881
+ function ms(e) {
1882
+ return x.add(e), L || (L = ys()), () => {
1877
1883
  x.delete(e), x.size === 0 && (L?.(), L = null);
1878
1884
  };
1879
1885
  }
1880
- function ms() {
1886
+ function ys() {
1881
1887
  const e = () => {
1882
1888
  for (const i of Array.from(x))
1883
1889
  i();
@@ -1892,10 +1898,10 @@ function ms() {
1892
1898
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
1893
1899
  };
1894
1900
  }
1895
- function ys() {
1896
- return $t()?.surface === "browser_extension_sdk_preview";
1897
- }
1898
1901
  function Ts() {
1902
+ return zt()?.surface === "browser_extension_sdk_preview";
1903
+ }
1904
+ function ws() {
1899
1905
  const e = document.body?.cloneNode(!0);
1900
1906
  return e instanceof HTMLElement ? (e.querySelectorAll(
1901
1907
  [
@@ -1919,7 +1925,7 @@ function Ts() {
1919
1925
  s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
1920
1926
  }), e.textContent?.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[email]").replace(/\b(?:\d[ -]*?){13,19}\b/g, "[number]").replace(/\b(?:sk|pk|tok|key|secret|token)_[A-Za-z0-9_-]{8,}\b/gi, "[secret]").replace(/\s+/g, " ").trim().slice(0, 12e3) ?? "") : "";
1921
1927
  }
1922
- function $t() {
1928
+ function zt() {
1923
1929
  const e = document.querySelector(At);
1924
1930
  if (!(e ?? document.querySelector(rt)))
1925
1931
  return;
@@ -1935,23 +1941,23 @@ function $t() {
1935
1941
  },
1936
1942
  {
1937
1943
  name: "widget_root",
1938
- selector: Se,
1944
+ selector: ke,
1939
1945
  description: "Finds Pluno's widget root inside the widget host shadow root."
1940
1946
  },
1941
1947
  {
1942
1948
  name: "widget_panel",
1943
- selector: ke,
1949
+ selector: Ee,
1944
1950
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
1945
1951
  },
1946
1952
  {
1947
1953
  name: "widget_timeline",
1948
- selector: Ee,
1954
+ selector: Re,
1949
1955
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
1950
1956
  }
1951
1957
  ]
1952
1958
  };
1953
1959
  }
1954
- function ws(e) {
1960
+ function Is(e) {
1955
1961
  try {
1956
1962
  const t = JSON.parse(e);
1957
1963
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -1965,10 +1971,10 @@ function bt(e, t) {
1965
1971
  const s = e[t];
1966
1972
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
1967
1973
  }
1968
- function Is(e) {
1974
+ function As(e) {
1969
1975
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
1970
1976
  }
1971
- function As(e) {
1977
+ function Ss(e) {
1972
1978
  if (!e || typeof e != "object")
1973
1979
  return null;
1974
1980
  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, c = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
@@ -1979,13 +1985,13 @@ function As(e) {
1979
1985
  ...c !== null ? { scribbleStyle: c } : {}
1980
1986
  };
1981
1987
  }
1982
- function Ss(e) {
1988
+ function ks(e) {
1983
1989
  if (!e || typeof e != "object")
1984
1990
  return null;
1985
1991
  const t = e.javascript;
1986
1992
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
1987
1993
  }
1988
- function ks(e, t) {
1994
+ function Es(e, t) {
1989
1995
  return t ? e && typeof e == "object" ? {
1990
1996
  ...e,
1991
1997
  helperError: t
@@ -1995,13 +2001,13 @@ function ks(e, t) {
1995
2001
  helperError: t
1996
2002
  } : e;
1997
2003
  }
1998
- function Es(e) {
2004
+ function Rs(e) {
1999
2005
  if (!e || typeof e != "object")
2000
2006
  return e;
2001
2007
  const t = e;
2002
2008
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2003
2009
  }
2004
- function Rs() {
2010
+ function _s() {
2005
2011
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2006
2012
  if (t)
2007
2013
  return t;
@@ -2022,14 +2028,14 @@ function Cs(e) {
2022
2028
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2023
2029
  } : null;
2024
2030
  }
2025
- function _s(e, t) {
2031
+ function bs(e, t) {
2026
2032
  return Array.isArray(e) ? lt(
2027
2033
  ut(
2028
- e.map((s) => zt(s, t)).filter((s) => s !== null)
2034
+ e.map((s) => Gt(s, t)).filter((s) => s !== null)
2029
2035
  )
2030
2036
  ) : [];
2031
2037
  }
2032
- function bs(e) {
2038
+ function Ms(e) {
2033
2039
  return Array.isArray(e) ? e.flatMap((t) => {
2034
2040
  if (!t || typeof t != "object")
2035
2041
  return [];
@@ -2048,7 +2054,7 @@ function bs(e) {
2048
2054
  ];
2049
2055
  }) : [];
2050
2056
  }
2051
- function zt(e, t) {
2057
+ function Gt(e, t) {
2052
2058
  if (!e || typeof e != "object")
2053
2059
  return null;
2054
2060
  const s = e, n = s.data;
@@ -2062,40 +2068,40 @@ function zt(e, t) {
2062
2068
  return {
2063
2069
  id: String(s.id ?? crypto.randomUUID()),
2064
2070
  role: i,
2065
- content: vs(r.content),
2071
+ content: Ns(r.content),
2066
2072
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2067
2073
  respondsToUserMessageId: M(r) ?? void 0,
2068
- ...C(r) ? { runId: C(r) } : {},
2069
- attachments: Jt(r.attachments, t)
2074
+ ..._(r) ? { runId: _(r) } : {},
2075
+ attachments: Yt(r.attachments, t)
2070
2076
  };
2071
2077
  }
2072
2078
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "tab_lifecycle_decision" ? {
2073
2079
  id: String(s.id ?? crypto.randomUUID()),
2074
2080
  role: "tool",
2075
- content: Ps(r),
2081
+ content: Us(r),
2076
2082
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2077
2083
  respondsToUserMessageId: M(r) ?? void 0,
2078
- ...C(r) ? { runId: C(r) } : {},
2084
+ ..._(r) ? { runId: _(r) } : {},
2079
2085
  dataType: String(r.type),
2080
2086
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
2081
- callId: Ds(r) ?? void 0,
2087
+ callId: vs(r) ?? void 0,
2082
2088
  loading: r.localExecutionStatus === "running"
2083
2089
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2084
2090
  id: String(s.id ?? crypto.randomUUID()),
2085
2091
  role: "system",
2086
- content: Ms(r),
2092
+ content: Ps(r),
2087
2093
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2088
2094
  respondsToUserMessageId: M(r) ?? void 0,
2089
- ...C(r) ? { runId: C(r) } : {},
2095
+ ..._(r) ? { runId: _(r) } : {},
2090
2096
  dataType: String(r.type),
2091
2097
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
2092
2098
  ...typeof r.retryable == "boolean" ? { retryable: r.retryable } : {}
2093
2099
  } : null;
2094
2100
  }
2095
- function Ms(e) {
2101
+ function Ps(e) {
2096
2102
  return 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." : e.type === "run_status" && e.status === "stopped" ? "Pluno stopped." : "Pluno run status changed.";
2097
2103
  }
2098
- function Ps(e) {
2104
+ function Us(e) {
2099
2105
  if (e.type === "web_search_call") {
2100
2106
  const t = e.action;
2101
2107
  if (t && typeof t == "object") {
@@ -2107,9 +2113,9 @@ function Ps(e) {
2107
2113
  }
2108
2114
  return "Searching the web";
2109
2115
  }
2110
- return Us(e);
2116
+ return Ds(e);
2111
2117
  }
2112
- function Us(e) {
2118
+ function Ds(e) {
2113
2119
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2114
2120
  return e.summary;
2115
2121
  if (typeof e.arguments == "string")
@@ -2122,11 +2128,11 @@ function Us(e) {
2122
2128
  }
2123
2129
  return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
2124
2130
  }
2125
- function Ds(e) {
2131
+ function vs(e) {
2126
2132
  const t = e.callId ?? e.call_id;
2127
2133
  return typeof t == "string" && t ? t : null;
2128
2134
  }
2129
- function vs(e) {
2135
+ function Ns(e) {
2130
2136
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2131
2137
  if (!t || typeof t != "object")
2132
2138
  return "";
@@ -2134,8 +2140,8 @@ function vs(e) {
2134
2140
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
2135
2141
  }).filter(Boolean).join("") : "";
2136
2142
  }
2137
- function Ns(e, t) {
2138
- const s = Gt(e, t), n = qs(e, t), r = n.findIndex((o) => o.id === s.id);
2143
+ function Os(e, t) {
2144
+ const s = Xt(e, t), n = xs(e, t), r = n.findIndex((o) => o.id === s.id);
2139
2145
  if (r === -1)
2140
2146
  return lt(
2141
2147
  ut([...n, s])
@@ -2143,15 +2149,15 @@ function Ns(e, t) {
2143
2149
  const i = [...n];
2144
2150
  return i[r] = s, lt(ut(i));
2145
2151
  }
2146
- function Os(e, t) {
2152
+ function Ls(e, t) {
2147
2153
  const s = t.map(
2148
- (n) => Gt(e, n)
2154
+ (n) => Xt(e, n)
2149
2155
  );
2150
2156
  return t.length > 0 ? s : e.filter(
2151
2157
  (n) => n.role === "user" && n.id.startsWith("local-")
2152
2158
  );
2153
2159
  }
2154
- function Gt(e, t) {
2160
+ function Xt(e, t) {
2155
2161
  if (t.role !== "user" || !t.attachments?.length)
2156
2162
  return t;
2157
2163
  const s = e.find(
@@ -2160,19 +2166,19 @@ function Gt(e, t) {
2160
2166
  if (!s?.attachments?.length)
2161
2167
  return t;
2162
2168
  const n = t.attachments.map((r) => {
2163
- const i = Ls(s.attachments ?? [], r);
2164
- return i ? Bs(r, i) : r;
2169
+ const i = Bs(s.attachments ?? [], r);
2170
+ return i ? qs(r, i) : r;
2165
2171
  });
2166
2172
  return { ...t, attachments: n };
2167
2173
  }
2168
- function Ls(e, t) {
2174
+ function Bs(e, t) {
2169
2175
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2170
2176
  }
2171
- function Bs(e, t) {
2177
+ function qs(e, t) {
2172
2178
  const { previewUrl: s } = t;
2173
2179
  return s ? { ...e, previewUrl: s } : e;
2174
2180
  }
2175
- function qs(e, t) {
2181
+ function xs(e, t) {
2176
2182
  if (t.role !== "user")
2177
2183
  return e;
2178
2184
  const s = e.findIndex(
@@ -2184,7 +2190,7 @@ function qs(e, t) {
2184
2190
  return n.splice(s, 1), n;
2185
2191
  }
2186
2192
  function Mt(e) {
2187
- const t = Xt(e);
2193
+ const t = Kt(e);
2188
2194
  if (t === null)
2189
2195
  return !1;
2190
2196
  for (let s = e.length - 1; s > t; s -= 1) {
@@ -2200,17 +2206,17 @@ function Mt(e) {
2200
2206
  }
2201
2207
  return !1;
2202
2208
  }
2203
- function xs(e) {
2204
- const t = Xt(e);
2209
+ function Fs(e) {
2210
+ const t = Kt(e);
2205
2211
  return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
2206
2212
  }
2207
- function Xt(e) {
2213
+ function Kt(e) {
2208
2214
  for (let t = e.length - 1; t >= 0; t -= 1)
2209
2215
  if (e[t].role === "user")
2210
2216
  return t;
2211
2217
  return null;
2212
2218
  }
2213
- function Fs(e) {
2219
+ function Hs(e) {
2214
2220
  return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2215
2221
  }
2216
2222
  function mt(e) {
@@ -2236,7 +2242,10 @@ function v(e) {
2236
2242
  function at(e) {
2237
2243
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2238
2244
  }
2239
- function Hs(e, t) {
2245
+ function Pt(e) {
2246
+ return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2247
+ }
2248
+ function Ws(e, t) {
2240
2249
  const s = mt(t);
2241
2250
  if (s === null)
2242
2251
  return !1;
@@ -2244,7 +2253,7 @@ function Hs(e, t) {
2244
2253
  if (typeof r != "string" || !r)
2245
2254
  return !1;
2246
2255
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2247
- return i === -1 ? !1 : e.slice(i + 1).some(Fs);
2256
+ return i === -1 ? !1 : e.slice(i + 1).some(Hs);
2248
2257
  }
2249
2258
  function ct(e) {
2250
2259
  const t = mt(e);
@@ -2259,7 +2268,7 @@ function ct(e) {
2259
2268
  const r = n.clientMessageId;
2260
2269
  return typeof r == "string" ? r : null;
2261
2270
  }
2262
- function Ws(e) {
2271
+ function js(e) {
2263
2272
  const t = mt(e);
2264
2273
  if (t === null)
2265
2274
  return null;
@@ -2274,13 +2283,13 @@ function Ws(e) {
2274
2283
  if (i.type === "message" && i.role === "assistant")
2275
2284
  return null;
2276
2285
  if (i.type === "run_error")
2277
- return i.retryable !== !0 ? null : Pt(e, i) ?? ct(e);
2286
+ return i.retryable !== !0 ? null : Ut(e, i) ?? ct(e);
2278
2287
  if (i.type === "run_status")
2279
- return i.status === "interrupted" && i.retryable === !0 ? Pt(e, i) ?? ct(e) : null;
2288
+ return i.status === "interrupted" && i.retryable === !0 ? Ut(e, i) ?? ct(e) : null;
2280
2289
  }
2281
2290
  return null;
2282
2291
  }
2283
- function Pt(e, t) {
2292
+ function Ut(e, t) {
2284
2293
  if (typeof t.clientMessageId == "string")
2285
2294
  return t.clientMessageId;
2286
2295
  const s = M(t);
@@ -2289,7 +2298,7 @@ function Pt(e, t) {
2289
2298
  const n = e.find((i) => I(i, "id") === s), r = v(n);
2290
2299
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2291
2300
  }
2292
- function js(e, t) {
2301
+ function $s(e, t) {
2293
2302
  let s = 0;
2294
2303
  for (const n of e) {
2295
2304
  if (!n || typeof n != "object")
@@ -2302,28 +2311,28 @@ function js(e, t) {
2302
2311
  }
2303
2312
  return s;
2304
2313
  }
2305
- function Ut(e, t, s, n) {
2306
- if (!t || !$s(e))
2314
+ function Dt(e, t, s, n) {
2315
+ if (!t || !zs(e))
2307
2316
  return !1;
2308
2317
  const r = e;
2309
- return !(at(r) || s !== null && M(r) !== s || n !== null && C(r) !== n);
2318
+ return !(at(r) || s !== null && M(r) !== s || n !== null && _(r) !== n);
2310
2319
  }
2311
- function $s(e) {
2320
+ function zs(e) {
2312
2321
  if (!e || typeof e != "object")
2313
2322
  return !1;
2314
2323
  const t = e;
2315
2324
  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");
2316
2325
  }
2317
- function zs(e) {
2326
+ function Gs(e) {
2318
2327
  if (!e || typeof e != "object")
2319
2328
  return !1;
2320
2329
  const t = e;
2321
2330
  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";
2322
2331
  }
2323
2332
  function lt(e) {
2324
- return e.filter((t, s) => yt(t) ? !Ys(e, s) && !Js(e, s) && !Vs(e, s) : Gs(t) ? t.retryable === !0 && Ks(e, s) ? !1 : !Xs(e, s) : !0);
2333
+ return e.filter((t, s) => yt(t) ? !Zs(e, s) && !Ys(e, s) && !Vs(e, s) : Xs(t) ? t.retryable === !0 && Js(e, s) ? !1 : !Ks(e, s) : !0);
2325
2334
  }
2326
- function Gs(e) {
2335
+ function Xs(e) {
2327
2336
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
2328
2337
  }
2329
2338
  function yt(e) {
@@ -2345,7 +2354,7 @@ function ut(e) {
2345
2354
  n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
2346
2355
  return r;
2347
2356
  }
2348
- function Xs(e, t) {
2357
+ function Ks(e, t) {
2349
2358
  const s = e[t];
2350
2359
  for (let n = t + 1; n < e.length; n += 1) {
2351
2360
  const r = e[n];
@@ -2356,7 +2365,7 @@ function Xs(e, t) {
2356
2365
  }
2357
2366
  return !1;
2358
2367
  }
2359
- function Ks(e, t) {
2368
+ function Js(e, t) {
2360
2369
  const s = e[t];
2361
2370
  if (!s.respondsToUserMessageId)
2362
2371
  return !1;
@@ -2369,7 +2378,7 @@ function Ks(e, t) {
2369
2378
  }
2370
2379
  return !1;
2371
2380
  }
2372
- function Js(e, t) {
2381
+ function Ys(e, t) {
2373
2382
  const s = e[t];
2374
2383
  for (let n = t + 1; n < e.length; n += 1)
2375
2384
  if (e[n].role === "assistant" && G(s, e[n]))
@@ -2383,7 +2392,7 @@ function Vs(e, t) {
2383
2392
  return !0;
2384
2393
  return !1;
2385
2394
  }
2386
- function Ys(e, t) {
2395
+ function Zs(e, t) {
2387
2396
  const s = e[t];
2388
2397
  for (let n = t + 1; n < e.length; n += 1)
2389
2398
  if (yt(e[n]) && G(s, e[n]))
@@ -2396,15 +2405,15 @@ function G(e, t) {
2396
2405
  function I(e, t) {
2397
2406
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2398
2407
  }
2399
- function Zs(e, t) {
2408
+ function Qs(e, t) {
2400
2409
  try {
2401
- const s = window.localStorage.getItem(`${Wt}${e}`);
2410
+ const s = window.localStorage.getItem(`${jt}${e}`);
2402
2411
  if (!s)
2403
2412
  return null;
2404
2413
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2405
2414
  if (t !== void 0 && r !== t)
2406
2415
  return null;
2407
- const i = Array.isArray(n.messages) ? n.messages.map(dn).filter((o) => !!o) : [];
2416
+ const i = Array.isArray(n.messages) ? n.messages.map(hn).filter((o) => !!o) : [];
2408
2417
  return {
2409
2418
  sessionId: r,
2410
2419
  messages: i
@@ -2413,20 +2422,20 @@ function Zs(e, t) {
2413
2422
  return null;
2414
2423
  }
2415
2424
  }
2416
- function Qs(e, t) {
2425
+ function tn(e, t) {
2417
2426
  try {
2418
2427
  window.localStorage.setItem(
2419
- `${Wt}${e}`,
2428
+ `${jt}${e}`,
2420
2429
  JSON.stringify({
2421
2430
  sessionId: t.sessionId,
2422
- messages: t.messages.slice(-$e).map(hn)
2431
+ messages: t.messages.slice(-ze).map(pn)
2423
2432
  })
2424
2433
  );
2425
2434
  } catch {
2426
2435
  return;
2427
2436
  }
2428
2437
  }
2429
- function tn(e) {
2438
+ function en(e) {
2430
2439
  try {
2431
2440
  const t = window.localStorage.getItem(`${it}${e}`);
2432
2441
  if (!t)
@@ -2452,7 +2461,7 @@ function U(e, t) {
2452
2461
  return;
2453
2462
  }
2454
2463
  }
2455
- function Kt(e, t) {
2464
+ function Jt(e, t) {
2456
2465
  try {
2457
2466
  const s = `${z}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2458
2467
  ...o,
@@ -2468,28 +2477,28 @@ function Kt(e, t) {
2468
2477
  } catch {
2469
2478
  }
2470
2479
  }
2471
- function en(e, t) {
2480
+ function sn(e, t) {
2472
2481
  try {
2473
2482
  if (window.sessionStorage.getItem(`${z}${e}`) === null)
2474
2483
  return;
2475
2484
  } catch {
2476
2485
  return;
2477
2486
  }
2478
- Kt(e, t);
2487
+ Jt(e, t);
2479
2488
  }
2480
- function sn(e) {
2489
+ function nn(e) {
2481
2490
  try {
2482
2491
  const t = `${z}${e}`, s = window.sessionStorage.getItem(t);
2483
2492
  if (window.sessionStorage.removeItem(t), !s)
2484
2493
  return [];
2485
2494
  const n = JSON.parse(s);
2486
- return Array.isArray(n) ? n.flatMap((r) => rn(r) ? [{
2495
+ return Array.isArray(n) ? n.flatMap((r) => on(r) ? [{
2487
2496
  ...r.event,
2488
2497
  page: S(),
2489
2498
  rawOutput: {
2490
2499
  pageContextRestarted: !0,
2491
2500
  outcome: "unknown",
2492
- message: nn(location.href),
2501
+ message: rn(location.href),
2493
2502
  currentUrl: location.href,
2494
2503
  console: [],
2495
2504
  metadata: {
@@ -2506,17 +2515,17 @@ function sn(e) {
2506
2515
  return [];
2507
2516
  }
2508
2517
  }
2509
- function nn(e) {
2518
+ function rn(e) {
2510
2519
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
2511
2520
  Current URL: ${e}`;
2512
2521
  }
2513
- function rn(e) {
2522
+ function on(e) {
2514
2523
  if (!e || typeof e != "object")
2515
2524
  return !1;
2516
2525
  const t = e, s = t.event;
2517
2526
  return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Tt(s) && s.type === "tool.result";
2518
2527
  }
2519
- function on(e, t) {
2528
+ function an(e, t) {
2520
2529
  const s = new Set(
2521
2530
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
2522
2531
  );
@@ -2525,7 +2534,7 @@ function on(e, t) {
2525
2534
  ...t.filter((n) => !s.has(n.callId))
2526
2535
  ];
2527
2536
  }
2528
- function an(e) {
2537
+ function cn(e) {
2529
2538
  try {
2530
2539
  window.sessionStorage.removeItem(`${z}${e}`);
2531
2540
  } catch {
@@ -2536,15 +2545,15 @@ function Tt(e) {
2536
2545
  if (!e || typeof e != "object")
2537
2546
  return !1;
2538
2547
  const t = e;
2539
- return t.type === "chat.user_message" ? typeof t.content == "string" && Dt(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Dt(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : 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;
2548
+ return t.type === "chat.user_message" ? typeof t.content == "string" && vt(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? vt(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : 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;
2540
2549
  }
2541
- function Dt(e) {
2550
+ function vt(e) {
2542
2551
  if (!e || typeof e != "object")
2543
2552
  return !1;
2544
2553
  const t = e;
2545
2554
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
2546
2555
  }
2547
- function Jt(e, t) {
2556
+ function Yt(e, t) {
2548
2557
  if (!Array.isArray(e))
2549
2558
  return;
2550
2559
  const s = e.filter((r) => {
@@ -2561,15 +2570,15 @@ function Vt(e, t) {
2561
2570
  fileUrl: new URL(e.fileUrl, t).toString()
2562
2571
  } : e;
2563
2572
  }
2564
- function cn(e) {
2565
- if (ln(e))
2573
+ function ln(e) {
2574
+ if (un(e))
2566
2575
  return {
2567
2576
  headers: {
2568
2577
  "ngrok-skip-browser-warning": "true"
2569
2578
  }
2570
2579
  };
2571
2580
  }
2572
- function ln(e) {
2581
+ function un(e) {
2573
2582
  try {
2574
2583
  const t = new URL(e).hostname;
2575
2584
  return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
@@ -2577,14 +2586,14 @@ function ln(e) {
2577
2586
  return !1;
2578
2587
  }
2579
2588
  }
2580
- function vt(e) {
2581
- return e.type || un(e.name) || "application/octet-stream";
2589
+ function Nt(e) {
2590
+ return e.type || dn(e.name) || "application/octet-stream";
2582
2591
  }
2583
- function un(e) {
2592
+ function dn(e) {
2584
2593
  const t = e.toLowerCase();
2585
2594
  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;
2586
2595
  }
2587
- function dn(e) {
2596
+ function hn(e) {
2588
2597
  if (!e || typeof e != "object")
2589
2598
  return null;
2590
2599
  const t = e;
@@ -2596,11 +2605,11 @@ function dn(e) {
2596
2605
  respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
2597
2606
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
2598
2607
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
2599
- attachments: Jt(t.attachments)?.map(wt),
2608
+ attachments: Yt(t.attachments)?.map(wt),
2600
2609
  loading: typeof t.loading == "boolean" ? t.loading : void 0
2601
2610
  };
2602
2611
  }
2603
- function hn(e) {
2612
+ function pn(e) {
2604
2613
  return e.attachments?.length ? {
2605
2614
  ...e,
2606
2615
  attachments: e.attachments.map(wt)
@@ -2619,15 +2628,15 @@ function M(e) {
2619
2628
  const t = e.respondsToUserMessageId;
2620
2629
  return typeof t == "string" && t ? t : null;
2621
2630
  }
2622
- function C(e) {
2631
+ function _(e) {
2623
2632
  const t = e.runId;
2624
2633
  return typeof t == "string" && t ? t : null;
2625
2634
  }
2626
- function pn(e) {
2635
+ function fn(e) {
2627
2636
  const t = e?.timeoutMs;
2628
- 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 <= Ze);
2637
+ 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 <= Qe);
2629
2638
  }
2630
- function Yt(e) {
2639
+ function Zt(e) {
2631
2640
  const t = {};
2632
2641
  try {
2633
2642
  new Headers(e).forEach((s, n) => {
@@ -2639,23 +2648,23 @@ function Yt(e) {
2639
2648
  return t;
2640
2649
  }
2641
2650
  function It(e, t) {
2642
- return ne(e) ? X : E(j(t), He);
2651
+ return re(e) ? X : E(j(t), We);
2643
2652
  }
2644
- function fn(e, t) {
2653
+ function gn(e, t) {
2645
2654
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
2646
2655
  }
2647
- async function gn(e, t, s, n) {
2648
- const r = Yt(e.headers);
2656
+ async function mn(e, t, s, n) {
2657
+ const r = Zt(e.headers);
2649
2658
  n({
2650
2659
  ...t,
2651
2660
  responseStatus: e.status,
2652
2661
  responseHeaders: r,
2653
- responseBody: await mn(e),
2662
+ responseBody: await yn(e),
2654
2663
  durationMs: Date.now() - s
2655
2664
  });
2656
2665
  }
2657
- async function mn(e) {
2658
- if (!Zt(e.headers))
2666
+ async function yn(e) {
2667
+ if (!Qt(e.headers))
2659
2668
  return;
2660
2669
  let t = null, s = null;
2661
2670
  try {
@@ -2664,7 +2673,7 @@ async function mn(e) {
2664
2673
  const n = new Promise((c) => {
2665
2674
  s = window.setTimeout(() => {
2666
2675
  t?.cancel(), c("timeout");
2667
- }, We);
2676
+ }, je);
2668
2677
  }), r = new TextDecoder();
2669
2678
  let i = "", o = 0;
2670
2679
  for (; ; ) {
@@ -2686,26 +2695,26 @@ async function mn(e) {
2686
2695
  s !== null && window.clearTimeout(s);
2687
2696
  }
2688
2697
  }
2689
- function yn(e, t) {
2690
- if (Zt(new Headers(t)))
2698
+ function Tn(e, t) {
2699
+ if (Qt(new Headers(t)))
2691
2700
  try {
2692
2701
  return e.responseType === "" || e.responseType === "text" ? E(e.responseText ?? "") : void 0;
2693
2702
  } catch {
2694
2703
  return;
2695
2704
  }
2696
2705
  }
2697
- function Nt(e) {
2706
+ function Ot(e) {
2698
2707
  if (typeof e == "string")
2699
2708
  return E(e);
2700
2709
  }
2701
- function Tn(e) {
2710
+ function wn(e) {
2702
2711
  return k({
2703
2712
  ...e,
2704
- requestBody: Ot(e.requestBody),
2705
- responseBody: Ot(e.responseBody)
2713
+ requestBody: Lt(e.requestBody),
2714
+ responseBody: Lt(e.responseBody)
2706
2715
  });
2707
2716
  }
2708
- function Ot(e) {
2717
+ function Lt(e) {
2709
2718
  if (typeof e != "string")
2710
2719
  return e;
2711
2720
  const t = e.trim();
@@ -2717,14 +2726,14 @@ function Ot(e) {
2717
2726
  return j(e);
2718
2727
  }
2719
2728
  }
2720
- function Zt(e) {
2729
+ function Qt(e) {
2721
2730
  if (!e)
2722
2731
  return !1;
2723
2732
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
2724
2733
  return s !== null && Number.isInteger(n) && n >= 0 && n <= pt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
2725
2734
  }
2726
2735
  function b(e, t = {}, s) {
2727
- if (In(s))
2736
+ if (An(s))
2728
2737
  return !0;
2729
2738
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
2730
2739
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -2739,7 +2748,7 @@ function b(e, t = {}, s) {
2739
2748
  return !0;
2740
2749
  }
2741
2750
  }
2742
- function wn(e, t) {
2751
+ function In(e, t) {
2743
2752
  if (b(e))
2744
2753
  return !0;
2745
2754
  try {
@@ -2749,10 +2758,10 @@ function wn(e, t) {
2749
2758
  return !0;
2750
2759
  }
2751
2760
  }
2752
- function In(e) {
2761
+ function An(e) {
2753
2762
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
2754
2763
  }
2755
- function An(e) {
2764
+ function Sn(e) {
2756
2765
  const t = {};
2757
2766
  for (const s of e.trim().split(/[\r\n]+/)) {
2758
2767
  const n = s.indexOf(":");
@@ -2783,27 +2792,27 @@ async function et(e, t) {
2783
2792
  try {
2784
2793
  return await e();
2785
2794
  } catch (r) {
2786
- if (s = r, n >= Rt - 1 || !kn(r))
2795
+ if (s = r, n >= Rt - 1 || !En(r))
2787
2796
  throw r;
2788
- await Sn(n);
2797
+ await kn(n);
2789
2798
  }
2790
2799
  throw s instanceof Error ? s : new Error(t);
2791
2800
  }
2792
- function Sn(e) {
2801
+ function kn(e) {
2793
2802
  return new Promise((t) => {
2794
- window.setTimeout(t, Fe[e] ?? 0);
2803
+ window.setTimeout(t, He[e] ?? 0);
2795
2804
  });
2796
2805
  }
2797
- function kn(e) {
2798
- return e instanceof F ? En(e.status) : e instanceof TypeError;
2799
- }
2800
2806
  function En(e) {
2801
- return e === 408 || e === 409 || e === 429 || e >= 500;
2807
+ return e instanceof F ? Rn(e.status) : e instanceof TypeError;
2802
2808
  }
2803
2809
  function Rn(e) {
2810
+ return e === 408 || e === 409 || e === 429 || e >= 500;
2811
+ }
2812
+ function _n(e) {
2804
2813
  return e === 401 || e === 403;
2805
2814
  }
2806
- const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", Cn = "[REDACTED_SIGNED_URL]", _n = 20, bn = /^(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, Qt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, te = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ee = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, se = /\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, Mn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Pn = /\bhttps?:\/\/[^\s"'<>]+/gi, Un = /[),.;\]]+$/;
2815
+ const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", Cn = "[REDACTED_SIGNED_URL]", bn = 20, Mn = /^(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, te = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ee = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, se = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ne = /\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, Pn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Un = /\bhttps?:\/\/[^\s"'<>]+/gi, Dn = /[),.;\]]+$/;
2807
2816
  function k(e) {
2808
2817
  return W(e, 0, /* @__PURE__ */ new WeakSet());
2809
2818
  }
@@ -2812,7 +2821,7 @@ function W(e, t, s) {
2812
2821
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : j(e);
2813
2822
  if (e === null || typeof e != "object")
2814
2823
  return e;
2815
- if (t >= _n)
2824
+ if (t >= bn)
2816
2825
  return "[REDACTED_MAX_DEPTH]";
2817
2826
  if (s.has(e))
2818
2827
  return "[REDACTED_CIRCULAR]";
@@ -2820,44 +2829,44 @@ function W(e, t, s) {
2820
2829
  return e.map((r) => W(r, t + 1, s));
2821
2830
  const n = {};
2822
2831
  for (const [r, i] of Object.entries(e))
2823
- ne(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? Dn(i) : W(i, t + 1, s);
2832
+ re(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? vn(i) : W(i, t + 1, s);
2824
2833
  return n;
2825
2834
  }
2826
- function ne(e) {
2835
+ function re(e) {
2827
2836
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
2828
2837
  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");
2829
2838
  }
2830
- function Dn(e) {
2831
- return typeof e == "string" ? re(e) : W(e, 0, /* @__PURE__ */ new WeakSet());
2839
+ function vn(e) {
2840
+ return typeof e == "string" ? ie(e) : W(e, 0, /* @__PURE__ */ new WeakSet());
2832
2841
  }
2833
- function re(e) {
2842
+ function ie(e) {
2834
2843
  try {
2835
2844
  const t = new URL(e, location.href);
2836
2845
  for (const s of Array.from(t.searchParams.keys()))
2837
- bn.test(s) && t.searchParams.set(s, R);
2846
+ Mn.test(s) && t.searchParams.set(s, R);
2838
2847
  return t.username && (t.username = R), t.password && (t.password = R), t.toString();
2839
2848
  } catch {
2840
- return vn(e);
2849
+ return Nn(e);
2841
2850
  }
2842
2851
  }
2843
2852
  function j(e) {
2844
- return e.replace(Mn, Cn).replace(Pn, Nn).replace(Qt, `Bearer ${R}`).replace(te, `Basic ${R}`).replace(ee, R).replace(se, (t, s) => `${s}: ${X}`);
2845
- }
2846
- function vn(e) {
2847
- return e.replace(Qt, `Bearer ${R}`).replace(te, `Basic ${R}`).replace(ee, R).replace(se, (t, s) => `${s}: ${X}`);
2853
+ return e.replace(Pn, Cn).replace(Un, On).replace(te, `Bearer ${R}`).replace(ee, `Basic ${R}`).replace(se, R).replace(ne, (t, s) => `${s}: ${X}`);
2848
2854
  }
2849
2855
  function Nn(e) {
2850
- const t = e.match(Un)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2851
- return `${re(s)}${t}`;
2856
+ return e.replace(te, `Bearer ${R}`).replace(ee, `Basic ${R}`).replace(se, R).replace(ne, (t, s) => `${s}: ${X}`);
2857
+ }
2858
+ function On(e) {
2859
+ const t = e.match(Dn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2860
+ return `${ie(s)}${t}`;
2852
2861
  }
2853
2862
  export {
2854
2863
  At as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
2855
2864
  rt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
2856
- ke as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2857
- Se as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2858
- Ee as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2859
- jt as PlunoProductAgent,
2860
- Ge as calculateReconnectDelay,
2861
- jt as default,
2862
- hs as getProductAgentOriginAccessErrorMessage
2865
+ Ee as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2866
+ ke as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2867
+ Re as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2868
+ $t as PlunoProductAgent,
2869
+ Xe as calculateReconnectDelay,
2870
+ $t as default,
2871
+ ps as getProductAgentOriginAccessErrorMessage
2863
2872
  };