@pluno/product-agent-web 0.1.149 → 0.1.150

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 Ze = "pluno-product-agent-attachments";
2
- const Pt = "files";
3
- async function Qe(e) {
4
- const t = await Bt();
5
- await ss(t, "readwrite", (s) => s.put(e));
6
- }
7
- async function ts(e, t) {
8
- const s = await Bt();
9
- await Ft(s, "readwrite", async (n) => {
10
- const r = await Ht(
1
+ const Qe = "pluno-product-agent-attachments";
2
+ const Ut = "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(
11
11
  n.get(e)
12
12
  );
13
13
  r && n.put({
@@ -16,28 +16,28 @@ async function ts(e, t) {
16
16
  });
17
17
  });
18
18
  }
19
- async function es(e = 864e5) {
20
- const t = await Bt(), s = Date.now() - e;
21
- await Ft(t, "readwrite", async (n) => {
19
+ async function ss(e = 864e5) {
20
+ const t = await Ft(), s = Date.now() - e;
21
+ await Ht(t, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Ht(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await Wt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function Bt() {
26
+ function Ft() {
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(Ze, 1);
28
+ const s = indexedDB.open(Qe, 1);
29
29
  s.onupgradeneeded = () => {
30
- const r = s.result.createObjectStore(Pt, { keyPath: "attachmentId" });
30
+ const r = s.result.createObjectStore(Ut, { 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 ss(e, t, s) {
36
- return await Ft(e, t, async (n) => await Ht(s(n)));
35
+ async function ns(e, t, s) {
36
+ return await Ht(e, t, async (n) => await Wt(s(n)));
37
37
  }
38
- function Ft(e, t, s) {
38
+ function Ht(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(Ut, t), o = i.objectStore(Ut);
41
41
  let a, c = !1;
42
42
  s(o).then((l) => {
43
43
  a = l;
@@ -57,16 +57,16 @@ function Ft(e, t, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Ht(e) {
60
+ function Wt(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 ns(e) {
65
+ function rs(e) {
66
66
  return e !== null && (typeof e == "object" || typeof e == "function");
67
67
  }
68
68
  function Re(e, t, s) {
69
- const n = Reflect.get(e, "pluno"), r = ns(n) ? n : {};
69
+ const n = Reflect.get(e, "pluno"), r = rs(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 Re(e, t, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const rs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function is(e, t) {
83
+ const is = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function os(e, t) {
85
85
  return t ? e.replace(
86
- rs,
86
+ is,
87
87
  (s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
88
88
  ) : e;
89
89
  }
90
- function os(e, t, s) {
90
+ function as(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 ?? [] : []
@@ -125,16 +125,16 @@ function os(e, t, s) {
125
125
  I.has(u) || g.push(u);
126
126
  return g;
127
127
  }
128
- function as(e, t, s, n) {
128
+ function cs(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", cs = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", ls = 50, us = globalThis.setTimeout.bind(globalThis);
134
+ const St = "pluno.productAgent.transportId", ls = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", us = 50, ds = globalThis.setTimeout.bind(globalThis);
135
135
  let W = null;
136
136
  const et = /* @__PURE__ */ new Set(), bt = /* @__PURE__ */ new Map();
137
- async function ds(e = ke()) {
137
+ async function hs(e = ke()) {
138
138
  const t = e.randomUUID(), s = e.storage.getItem(St);
139
139
  let n = s ?? e.randomUUID(), r = !1, i = !1;
140
140
  const o = e.channel.subscribe((c) => {
@@ -170,14 +170,14 @@ async function ds(e = ke()) {
170
170
  }
171
171
  };
172
172
  }
173
- async function hs() {
174
- W || (W = ds(ke()), W.then((n) => {
173
+ async function ps() {
174
+ W || (W = hs(ke()), W.then((n) => {
175
175
  const r = (i) => {
176
176
  i.persisted || (n.release(), W = null, et.clear(), window.removeEventListener("pagehide", r));
177
177
  };
178
178
  window.addEventListener("pagehide", r);
179
179
  }));
180
- const e = await W, t = ps();
180
+ const e = await W, t = fs();
181
181
  et.add(t);
182
182
  let s = !1;
183
183
  return {
@@ -188,7 +188,7 @@ async function hs() {
188
188
  }
189
189
  };
190
190
  }
191
- function ps() {
191
+ function fs() {
192
192
  let e = 0;
193
193
  for (; et.has(e); )
194
194
  e += 1;
@@ -196,13 +196,13 @@ function ps() {
196
196
  }
197
197
  function ke() {
198
198
  return {
199
- storage: fs(),
200
- channel: gs(),
199
+ storage: gs(),
200
+ channel: ms(),
201
201
  randomUUID: () => crypto.randomUUID(),
202
- settle: () => new Promise((e) => us(e, ls))
202
+ settle: () => new Promise((e) => ds(e, us))
203
203
  };
204
204
  }
205
- function fs() {
205
+ function gs() {
206
206
  return {
207
207
  getItem: (e) => {
208
208
  try {
@@ -220,9 +220,9 @@ function fs() {
220
220
  }
221
221
  };
222
222
  }
223
- function gs() {
223
+ function ms() {
224
224
  if (typeof BroadcastChannel < "u") {
225
- const e = new BroadcastChannel(cs);
225
+ const e = new BroadcastChannel(ls);
226
226
  return {
227
227
  postMessage: (t) => e.postMessage(t),
228
228
  subscribe: (t) => {
@@ -232,9 +232,9 @@ function gs() {
232
232
  close: () => e.close()
233
233
  };
234
234
  }
235
- return ms();
235
+ return ys();
236
236
  }
237
- function ms() {
237
+ function ys() {
238
238
  const e = /* @__PURE__ */ new Set(), t = (s) => {
239
239
  if (s.key !== At || !s.newValue)
240
240
  return;
@@ -255,9 +255,23 @@ function ms() {
255
255
  }
256
256
  };
257
257
  }
258
- const ys = globalThis.fetch.bind(globalThis), Ut = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Is = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ts = ".pluno-pa-widget__panel", ws = ".pluno-pa-widget__timeline", re = `${Ut}[data-pluno-sdk-preview-channel]`;
259
- let Ss = 0;
260
- function ie(e) {
258
+ const Me = "schedule_follow_up";
259
+ function Is(e) {
260
+ let t = e;
261
+ if (typeof t == "string")
262
+ try {
263
+ t = JSON.parse(t);
264
+ } catch {
265
+ return null;
266
+ }
267
+ if (!t || typeof t != "object")
268
+ return null;
269
+ const s = t;
270
+ return s.ok !== !0 || s.toolName !== Me || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
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 bs = 0;
274
+ function oe(e) {
261
275
  const t = {};
262
276
  for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
263
277
  const o = e[i];
@@ -282,25 +296,25 @@ function Et(e, t, s) {
282
296
  source: "web_sdk",
283
297
  category: e,
284
298
  name: t,
285
- sequence: ++Ss,
299
+ sequence: ++bs,
286
300
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
287
301
  monotonicMs: performance.now(),
288
302
  data: s
289
303
  };
290
304
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
291
305
  }
292
- const As = "https://app.pluno.ai", bs = "gpt-5.6-terra", Es = 2e4, Rs = 1e4, ks = 1e4, Ms = 1e4, _s = 1e4, Cs = 1e3, oe = 3e4, ae = 0.2, ce = 6e4, Ps = 15e3, V = 8, Us = 15e3, Ds = 2e3, Os = 1e3, Ns = 100, le = 8e3, ue = 3, vs = [300, 1e3], Wt = 64e3, Rt = 4e3, $t = 30, xs = 2e3, Ls = 1e3, Me = "Image is too large for model vision input.", qs = 100, _e = "pluno.productAgent.state.", Dt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Bs = 100;
306
+ const Es = "https://app.pluno.ai", Rs = "gpt-5.6-terra", ks = 2e4, Ms = 1e4, _s = 1e4, Cs = 1e4, Ps = 1e4, Us = 1e3, ae = 3e4, ce = 0.2, le = 6e4, Ds = 15e3, V = 8, Os = 15e3, Ns = 2e3, vs = 1e3, xs = 100, ue = 8e3, de = 3, Ls = [300, 1e3], $t = 64e3, Rt = 4e3, jt = 30, qs = 2e3, Bs = 1e3, _e = "Image is too large for model vision input.", Fs = 100, Ce = "pluno.productAgent.state.", Ot = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Hs = 100;
293
307
  function Y(e, t = 0) {
294
308
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
295
309
  return Math.max(t, s);
296
310
  }
297
311
  const st = /* @__PURE__ */ new Set();
298
312
  let Z = null;
299
- function Fs(e, t = Math.random) {
300
- const s = Math.min(oe, Cs * 2 ** e), n = 1 - ae + t() * ae * 2;
301
- return Math.min(oe, Math.round(s * n));
313
+ function Ws(e, t = Math.random) {
314
+ const s = Math.min(ae, Us * 2 ** e), n = 1 - ce + t() * ce * 2;
315
+ return Math.min(ae, Math.round(s * n));
302
316
  }
303
- function Hs(e, t, s) {
317
+ function $s(e, t, s) {
304
318
  return new Promise((n, r) => {
305
319
  const i = setTimeout(() => r(new Error(s)), t);
306
320
  e.then(
@@ -313,13 +327,13 @@ function Hs(e, t, s) {
313
327
  );
314
328
  });
315
329
  }
316
- class Ce {
330
+ class Pe {
317
331
  constructor(t, s) {
318
332
  this.options = t, this.transportIdentity = s, this.state = {
319
333
  ...this.state,
320
- starterPrompts: bn(t.initialStarterPrompts)
334
+ starterPrompts: Rn(t.initialStarterPrompts)
321
335
  };
322
- const n = t.restorePersistedState === !1 ? null : dr(t.clientId, t.expectedPersistedSessionId);
336
+ const n = t.restorePersistedState === !1 ? null : pr(t.clientId, t.expectedPersistedSessionId);
323
337
  n && (this.state = {
324
338
  ...this.state,
325
339
  ...n,
@@ -332,9 +346,9 @@ class Ce {
332
346
  assistantDraftRunId: null,
333
347
  isThinking: !1,
334
348
  lastError: null
335
- }), this.queuedClientEvents = Ir(
336
- pr(t.clientId),
337
- gr(t.clientId)
349
+ }), this.queuedClientEvents = wr(
350
+ gr(t.clientId),
351
+ yr(t.clientId)
338
352
  ), j(t.clientId, this.queuedClientEvents);
339
353
  }
340
354
  options;
@@ -409,15 +423,15 @@ class Ce {
409
423
  lastErrorSecuritySettingsUrl: null
410
424
  };
411
425
  static async init(t) {
412
- const s = await hs(), n = new Ce({
426
+ const s = await ps(), n = new Pe({
413
427
  ...t,
414
- backendUrl: cn(t.backendUrl ?? As),
415
- clientId: t.clientId ?? _n(),
416
- model: t.model ?? bs,
417
- entrySurface: ln(t.entrySurface)
428
+ backendUrl: un(t.backendUrl ?? Es),
429
+ clientId: t.clientId ?? Pn(),
430
+ model: t.model ?? Rs,
431
+ entrySurface: dn(t.entrySurface)
418
432
  }, s);
419
433
  try {
420
- es().catch((r) => {
434
+ ss().catch((r) => {
421
435
  S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
422
436
  message: r instanceof Error ? r.message : String(r)
423
437
  });
@@ -448,14 +462,14 @@ class Ce {
448
462
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
449
463
  );
450
464
  try {
451
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Hs(this.options.tokenProvider(), ks, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
465
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await $s(this.options.tokenProvider(), _s, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
452
466
  return;
453
467
  if (!this.token && !this.options.webSocketFactory)
454
468
  throw new Error("Pluno requires a token or tokenProvider");
455
- const s = hn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
469
+ const s = fn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
456
470
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
457
471
  this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
458
- }, Ms), n.addEventListener("open", () => {
472
+ }, Cs), n.addEventListener("open", () => {
459
473
  this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
460
474
  queuedClientEventCount: this.queuedClientEvents.length,
461
475
  isThinking: this.state.isThinking
@@ -467,9 +481,9 @@ class Ce {
467
481
  pageUrl: location.href
468
482
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
469
483
  this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
470
- }, _s));
484
+ }, Ps));
471
485
  }), n.addEventListener("message", (r) => {
472
- this.socket === n && this.handleServerEvent(An(r.data));
486
+ this.socket === n && this.handleServerEvent(En(r.data));
473
487
  }), n.addEventListener("close", (r) => {
474
488
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
475
489
  code: typeof r?.code == "number" ? r.code : null,
@@ -502,7 +516,7 @@ class Ce {
502
516
  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;
503
517
  }
504
518
  destroy() {
505
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Tr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
519
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Sr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
506
520
  for (const t of Object.values(this.listeners))
507
521
  t?.clear();
508
522
  }
@@ -518,7 +532,7 @@ class Ce {
518
532
  }
519
533
  async sendMessage(t, s = {}) {
520
534
  const n = t.trim(), r = s.attachments ?? [];
521
- let i = r.map(Gt);
535
+ let i = r.map(Xt);
522
536
  if (!n && i.length === 0)
523
537
  return null;
524
538
  const o = k(), a = s.clientMessageId ?? $(), c = {
@@ -572,14 +586,14 @@ class Ce {
572
586
  sessionId: this.state.sessionId ?? void 0,
573
587
  clientMessageId: a,
574
588
  initiatedBy: s.initiatedBy,
575
- invocation: un(s.invocation ?? s.initiatedBy),
589
+ invocation: hn(s.invocation ?? s.initiatedBy),
576
590
  entrySurface: this.options.entrySurface,
577
591
  content: n,
578
- pageContent: u && jt() || void 0,
592
+ pageContent: u && zt() || void 0,
579
593
  attachments: i.length > 0 ? i : void 0,
580
594
  page: o,
581
595
  model: this.options.model,
582
- metadata: de(this.options.metadata)
596
+ metadata: he(this.options.metadata)
583
597
  };
584
598
  return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.markThinkingProgress(), this.send(d), a;
585
599
  }
@@ -596,7 +610,7 @@ class Ce {
596
610
  };
597
611
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
598
612
  const r = Date.now();
599
- return Qe({
613
+ return ts({
600
614
  attachmentId: s,
601
615
  name: n.name,
602
616
  mimeType: n.mimeType,
@@ -635,7 +649,7 @@ class Ce {
635
649
  sizeBytes: t.size,
636
650
  page: k(),
637
651
  model: this.options.model,
638
- metadata: de(this.options.metadata),
652
+ metadata: he(this.options.metadata),
639
653
  entrySurface: this.options.entrySurface
640
654
  };
641
655
  let o;
@@ -661,8 +675,8 @@ class Ce {
661
675
  }, "Failed to upload attachment"), o = c;
662
676
  }
663
677
  this.setState({ sessionId: o.sessionId });
664
- const a = He(o.attachment, this.options.backendUrl);
665
- return this.updateAttachmentInState(s.id, a), s.id && ts(s.id, {
678
+ const a = We(o.attachment, this.options.backendUrl);
679
+ return this.updateAttachmentInState(s.id, a), s.id && es(s.id, {
666
680
  sessionId: o.sessionId,
667
681
  fileUrl: a.fileUrl,
668
682
  sandboxPath: a.sandboxPath,
@@ -692,7 +706,7 @@ class Ce {
692
706
  const n = await this.fetchEmbedAttachmentUpload(t);
693
707
  if (n.ok)
694
708
  return await n.json();
695
- if (vr(n.status) && this.options.tokenProvider && !s) {
709
+ if (Lr(n.status) && this.options.tokenProvider && !s) {
696
710
  s = !0;
697
711
  const r = await this.fetchEmbedAttachmentUpload(t);
698
712
  if (r.ok)
@@ -739,7 +753,7 @@ class Ce {
739
753
  const s = $(), n = new Promise((i, o) => {
740
754
  const a = window.setTimeout(() => {
741
755
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
742
- }, le);
756
+ }, ue);
743
757
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
744
758
  }), r = {
745
759
  type: "sessions.list",
@@ -787,7 +801,7 @@ class Ce {
787
801
  });
788
802
  }
789
803
  send(t) {
790
- this.sendNow(M(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
804
+ this.sendNow(_(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
791
805
  }
792
806
  async getUploadToken() {
793
807
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -800,7 +814,7 @@ class Ce {
800
814
  return !1;
801
815
  const s = this.socket;
802
816
  try {
803
- return s.send(JSON.stringify(t)), Et("client_event", t.type, ie(t)), !0;
817
+ return s.send(JSON.stringify(t)), Et("client_event", t.type, oe(t)), !0;
804
818
  } catch (n) {
805
819
  return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
806
820
  message: n instanceof Error ? n.message : String(n),
@@ -813,9 +827,9 @@ class Ce {
813
827
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
814
828
  return;
815
829
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
816
- const t = pn();
830
+ const t = gn();
817
831
  this.sendNow(
818
- M({
832
+ _({
819
833
  type: "starter_prompts.page_context",
820
834
  pageUrl: t.pageUrl,
821
835
  pageTitle: t.pageTitle,
@@ -824,13 +838,13 @@ class Ce {
824
838
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
825
839
  }
826
840
  startStarterPromptUrlWatcher() {
827
- this.locationChangeCleanup || (this.locationChangeCleanup = fn(() => this.handleStarterPromptUrlChange()));
841
+ this.locationChangeCleanup || (this.locationChangeCleanup = mn(() => this.handleStarterPromptUrlChange()));
828
842
  }
829
843
  handleStarterPromptUrlChange() {
830
844
  const t = location.href;
831
845
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
832
846
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
833
- }, Bs));
847
+ }, Hs));
834
848
  }
835
849
  refreshStarterPromptsForCurrentUrl() {
836
850
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -848,7 +862,7 @@ class Ce {
848
862
  j(this.options.clientId, this.queuedClientEvents);
849
863
  for (let s = 0; s < t.length; s += 1) {
850
864
  const n = t[s];
851
- if (!this.sendNow(M(n))) {
865
+ if (!this.sendNow(_(n))) {
852
866
  this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), j(this.options.clientId, this.queuedClientEvents);
853
867
  return;
854
868
  }
@@ -859,7 +873,7 @@ class Ce {
859
873
  !this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
860
874
  }
861
875
  handleServerEvent(t) {
862
- if (Et("server_event", t.type, ie(t)), t.type === "run.ack") {
876
+ if (Et("server_event", t.type, oe(t)), t.type === "run.ack") {
863
877
  const s = Mt(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
864
878
  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);
865
879
  return;
@@ -880,20 +894,20 @@ class Ce {
880
894
  this.clearHeartbeatAckTimer();
881
895
  return;
882
896
  }
883
- if (js(t) && this.markThinkingProgress(), t.type === "auth.ok") {
897
+ if (Ks(t) && this.markThinkingProgress(), t.type === "auth.ok") {
884
898
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
885
- const s = En(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
899
+ const s = kn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
886
900
  S("web-sdk.agent", "Received auth.ok appearance", {
887
901
  hasAppearance: n,
888
902
  rawAppearance: t.appearance,
889
903
  normalizedAppearance: s
890
- }), this.runtimeHelperJavascript = Rn(t.runtimeHelpers)?.javascript ?? null;
891
- const r = fe(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
892
- user: Cn(t.user),
904
+ }), this.runtimeHelperJavascript = Mn(t.runtimeHelpers)?.javascript ?? null;
905
+ const r = ge(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
906
+ user: Un(t.user),
893
907
  status: "connected",
894
908
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
895
909
  };
896
- (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 && !mn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
910
+ (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 && !In() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
897
911
  type: "page.upsert",
898
912
  sessionId: this.state.sessionId,
899
913
  page: k(),
@@ -903,19 +917,19 @@ class Ce {
903
917
  }
904
918
  if (t.type === "starterPrompts.updated") {
905
919
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
906
- starterPrompts: fe(t, "starterPrompts"),
920
+ starterPrompts: ge(t, "starterPrompts"),
907
921
  starterPromptsLoading: !1
908
922
  });
909
923
  return;
910
924
  }
911
925
  if (t.type === "conversation.state") {
912
- const s = Array.isArray(t.items) ? t.items : [], n = Ln(
926
+ const s = Array.isArray(t.items) ? t.items : [], n = Bn(
913
927
  t.assistantDraft
914
928
  ), r = n !== void 0;
915
929
  this.rememberUserMessageClientMessageIds(s);
916
- const i = Qn(s);
930
+ const i = er(s);
917
931
  if (i) {
918
- const p = tr(s, i);
932
+ const p = sr(s, i);
919
933
  this.retryAttemptsByClientMessageId[i] = Math.max(
920
934
  this.retryAttemptsByClientMessageId[i] ?? 0,
921
935
  p
@@ -923,10 +937,10 @@ class Ce {
923
937
  }
924
938
  const o = s.filter((p) => {
925
939
  const m = q(p);
926
- return !ye(m) && (!i || !xt(m));
927
- }), a = Kn(
940
+ return !ye(m) && (!i || !Lt(m));
941
+ }), a = Xn(
928
942
  this.state.messages,
929
- Pn(o, this.options.backendUrl)
943
+ Dn(o, this.options.backendUrl)
930
944
  ), c = me(a), l = !r && s.some(
931
945
  (p) => Te(
932
946
  q(p),
@@ -935,11 +949,11 @@ class Ce {
935
949
  this.state.assistantDraftRespondsToUserMessageId,
936
950
  this.state.assistantDraftRunId
937
951
  )
938
- ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = Vn(a), u = I && g;
939
- if (!c && Zn(this.state.messages, s))
952
+ ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = Zn(a), u = I && g;
953
+ if (!c && tr(this.state.messages, s))
940
954
  return;
941
- this.lastUserMessagePageUrl = Yn(s);
942
- const d = I ? null : Lt(s);
955
+ this.lastUserMessagePageUrl = Qn(s);
956
+ const d = I ? null : qt(s);
943
957
  if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
944
958
  sessionId: E(t.session, "id") ?? this.state.sessionId,
945
959
  messages: a,
@@ -980,7 +994,7 @@ class Ce {
980
994
  if (t.type === "sessions.page") {
981
995
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
982
996
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
983
- sessions: Un(t.sessions),
997
+ sessions: On(t.sessions),
984
998
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
985
999
  }));
986
1000
  return;
@@ -1000,9 +1014,9 @@ class Ce {
1000
1014
  if (t.type === "session.item") {
1001
1015
  this.rememberUserMessageClientMessageIds([t.item]);
1002
1016
  const s = q(t.item);
1003
- if (xt(s)) {
1017
+ if (Lt(s)) {
1004
1018
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1005
- const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? v(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1019
+ const r = E(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);
1006
1020
  if (r && a) {
1007
1021
  this.retryAfterInterruptedRun(r, a);
1008
1022
  return;
@@ -1014,19 +1028,19 @@ class Ce {
1014
1028
  }
1015
1029
  if (ye(s))
1016
1030
  return;
1017
- const n = Ne(t.item, this.options.backendUrl);
1031
+ const n = ve(t.item, this.options.backendUrl);
1018
1032
  if (n) {
1019
1033
  const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1020
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1034
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), v(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1021
1035
  const i = t.item.data;
1022
- sr(i) && this.clearRunAckResyncRetryTimer();
1023
- const o = Ot(this.state.messages, n), a = me(o), c = Te(
1036
+ rr(i) && this.clearRunAckResyncRetryTimer();
1037
+ const o = Nt(this.state.messages, n), a = me(o), c = Te(
1024
1038
  i,
1025
1039
  this.state.assistantDraft,
1026
1040
  this.state.assistantDraftItemId,
1027
1041
  this.state.assistantDraftRespondsToUserMessageId,
1028
1042
  this.state.assistantDraftRunId
1029
- ), l = a && (!this.state.assistantDraft || c), h = l && N(n);
1043
+ ), l = a && (!this.state.assistantDraft || c), h = l && v(n);
1030
1044
  this.setState({
1031
1045
  messages: o,
1032
1046
  ...c ? {
@@ -1053,7 +1067,7 @@ class Ce {
1053
1067
  this.clearRunAckResyncRetryTimer();
1054
1068
  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;
1055
1069
  this.setState({
1056
- messages: Ot(this.state.messages, {
1070
+ messages: Nt(this.state.messages, {
1057
1071
  id: o,
1058
1072
  role: "assistant",
1059
1073
  content: i,
@@ -1079,9 +1093,9 @@ class Ce {
1079
1093
  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;
1080
1094
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
1081
1095
  return;
1082
- const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = as(
1096
+ const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = cs(
1083
1097
  this.state.messages.filter(
1084
- (l) => l.dataType !== "assistant_draft" || !Fn(
1098
+ (l) => l.dataType !== "assistant_draft" || !Wn(
1085
1099
  l,
1086
1100
  n,
1087
1101
  r
@@ -1089,11 +1103,11 @@ class Ce {
1089
1103
  ),
1090
1104
  n,
1091
1105
  r,
1092
- ve
1106
+ xe
1093
1107
  );
1094
1108
  this.setState({
1095
1109
  sessionId: s,
1096
- messages: Hn(
1110
+ messages: $n(
1097
1111
  c,
1098
1112
  typeof t.responseId == "string" ? t.responseId : null,
1099
1113
  n,
@@ -1114,9 +1128,9 @@ class Ce {
1114
1128
  if (s)
1115
1129
  this.nonTranscriptToolCallIds.add(s);
1116
1130
  else {
1117
- const n = jn(t);
1131
+ const n = Kn(t);
1118
1132
  if (n) {
1119
- const r = Wn(
1133
+ const r = jn(
1120
1134
  this.state.messages,
1121
1135
  n
1122
1136
  );
@@ -1160,7 +1174,7 @@ class Ce {
1160
1174
  return;
1161
1175
  }
1162
1176
  o && r && i && (this.retryableClientMessageId = i);
1163
- const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = dn(a.message);
1177
+ const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = pn(a.message);
1164
1178
  c && console.error(c), this.setState({
1165
1179
  status: "error",
1166
1180
  isThinking: !1,
@@ -1172,7 +1186,7 @@ class Ce {
1172
1186
  }
1173
1187
  }
1174
1188
  shouldIgnoreBackgroundSessionEvent(t) {
1175
- if (!this.options.keepRunsActiveOnSessionNavigation || !zs(t))
1189
+ if (!this.options.keepRunsActiveOnSessionNavigation || !Gs(t))
1176
1190
  return !1;
1177
1191
  const s = Mt(t);
1178
1192
  return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
@@ -1248,7 +1262,7 @@ class Ce {
1248
1262
  const r = new Promise((i, o) => {
1249
1263
  const a = window.setTimeout(() => {
1250
1264
  t.delete(s.requestId), o(new Error(n));
1251
- }, le);
1265
+ }, ue);
1252
1266
  t.set(s.requestId, { resolve: i, reject: o, timeout: a });
1253
1267
  });
1254
1268
  if (!this.sendNow(s)) {
@@ -1271,7 +1285,7 @@ class Ce {
1271
1285
  t.clear();
1272
1286
  }
1273
1287
  markThinkingProgress() {
1274
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ce), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1288
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(le), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1275
1289
  }
1276
1290
  scheduleThinkingWatchdog(t) {
1277
1291
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1291,7 +1305,7 @@ class Ce {
1291
1305
  handleRunSteered(t) {
1292
1306
  const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
1293
1307
  !this.state.isThinking || !s || this.setState({
1294
- messages: rr(
1308
+ messages: or(
1295
1309
  this.state.messages,
1296
1310
  s
1297
1311
  )
@@ -1300,7 +1314,7 @@ class Ce {
1300
1314
  scheduleRunAckWatchdog(t) {
1301
1315
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1302
1316
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1303
- }, Us);
1317
+ }, Os);
1304
1318
  }
1305
1319
  recoverMissedRunAck(t) {
1306
1320
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
@@ -1324,8 +1338,8 @@ class Ce {
1324
1338
  sessionId: this.state.sessionId,
1325
1339
  clientMessageId: t,
1326
1340
  automatic: !0
1327
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ce)));
1328
- }, Y(s, Ds)));
1341
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(le)));
1342
+ }, Y(s, Ns)));
1329
1343
  }
1330
1344
  clearRunAckResyncRetryTimer() {
1331
1345
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1364,7 +1378,7 @@ class Ce {
1364
1378
  sessionId: this.state.sessionId,
1365
1379
  clientMessageId: t,
1366
1380
  resyncAttempts: s + 1
1367
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ps);
1381
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ds);
1368
1382
  return;
1369
1383
  }
1370
1384
  this.setState({
@@ -1399,15 +1413,15 @@ class Ce {
1399
1413
  if (!s || !n || !r)
1400
1414
  return;
1401
1415
  const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1402
- if (!a && !c || !br(o)) {
1416
+ if (!a && !c || !Rr(o)) {
1403
1417
  this.setToolMessageLoading(n, !1), this.send({
1404
1418
  type: "tool.result",
1405
1419
  sessionId: s,
1406
1420
  callId: n,
1407
1421
  toolName: r,
1408
1422
  summary: i,
1409
- rawInput: M(o),
1410
- rawOutput: M({
1423
+ rawInput: _(o),
1424
+ rawOutput: _({
1411
1425
  ok: !1,
1412
1426
  toolName: r,
1413
1427
  error: `Unsupported browser tool: ${r}`
@@ -1422,7 +1436,7 @@ class Ce {
1422
1436
  callId: n,
1423
1437
  toolName: r,
1424
1438
  summary: i,
1425
- rawInput: M(o),
1439
+ rawInput: _(o),
1426
1440
  rawOutput: {
1427
1441
  ok: !1,
1428
1442
  toolName: r,
@@ -1431,7 +1445,7 @@ class Ce {
1431
1445
  });
1432
1446
  return;
1433
1447
  }
1434
- const l = Xs(this.state.messages);
1448
+ const l = Vs(this.state.messages);
1435
1449
  this.activeBrowserToolCalls.set(n, {
1436
1450
  event: {
1437
1451
  type: "tool.result",
@@ -1439,7 +1453,7 @@ class Ce {
1439
1453
  callId: n,
1440
1454
  toolName: r,
1441
1455
  summary: i,
1442
- rawInput: M(o),
1456
+ rawInput: _(o),
1443
1457
  rawOutput: null
1444
1458
  },
1445
1459
  startedAtMs: Date.now(),
@@ -1447,9 +1461,9 @@ class Ce {
1447
1461
  startedAtOrigin: location.origin
1448
1462
  }), this.installSessionUserFilesApi(l);
1449
1463
  let h = null, f;
1450
- h = await this.executeRuntimeHelper(), f = await he(
1464
+ h = await this.executeRuntimeHelper(), f = await pe(
1451
1465
  o,
1452
- on(t.runtimeContext, this.options.backendUrl)
1466
+ cn(t.runtimeContext, this.options.backendUrl)
1453
1467
  ).catch((I) => ({
1454
1468
  ok: !1,
1455
1469
  exception: {
@@ -1461,12 +1475,12 @@ class Ce {
1461
1475
  callId: n,
1462
1476
  toolName: r,
1463
1477
  summary: o.summary,
1464
- rawInput: M(o),
1465
- rawOutput: M(kn(f, h))
1466
- }), fr(this.options.clientId, this.activeBrowserToolCalls.values());
1478
+ rawInput: _(o),
1479
+ rawOutput: _(_n(f, h))
1480
+ }), mr(this.options.clientId, this.activeBrowserToolCalls.values());
1467
1481
  }
1468
1482
  setToolMessageLoading(t, s) {
1469
- const n = $n(
1483
+ const n = zn(
1470
1484
  this.state.messages,
1471
1485
  t,
1472
1486
  s
@@ -1477,33 +1491,33 @@ class Ce {
1477
1491
  if (this.pageLifecycleCleanup)
1478
1492
  return;
1479
1493
  const t = () => {
1480
- Be(this.options.clientId, this.activeBrowserToolCalls.values());
1494
+ Fe(this.options.clientId, this.activeBrowserToolCalls.values());
1481
1495
  };
1482
1496
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1483
1497
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1484
1498
  };
1485
1499
  }
1486
1500
  installSessionUserFilesApi(t) {
1487
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Js(t, this.attachmentFiles, this.attachmentBlobCache);
1501
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Ys(t, this.attachmentFiles, this.attachmentBlobCache);
1488
1502
  }
1489
1503
  cleanupSessionUserFilesApi() {
1490
- this.sessionUserFilesApiCleanup && (nn(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1504
+ this.sessionUserFilesApiCleanup && (on(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1491
1505
  }
1492
1506
  async executeRuntimeHelper() {
1493
1507
  if (!this.runtimeHelperJavascript?.trim())
1494
1508
  return null;
1495
- const t = await he({
1509
+ const t = await pe({
1496
1510
  javascript: this.runtimeHelperJavascript
1497
1511
  });
1498
- return t.ok === !1 ? Mn(t) : null;
1512
+ return t.ok === !1 ? Cn(t) : null;
1499
1513
  }
1500
1514
  enableNetworkCapture() {
1501
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Ws((t) => {
1502
- Cr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1515
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = js((t) => {
1516
+ Ur(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1503
1517
  }));
1504
1518
  }
1505
1519
  enqueueNetworkEvent(t) {
1506
- this.queuedNetworkEvents.length >= Ns || (this.queuedNetworkEvents.push(_r(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1520
+ this.queuedNetworkEvents.length >= xs || (this.queuedNetworkEvents.push(Pr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1507
1521
  this.networkBatchTimer = null;
1508
1522
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1509
1523
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1512,12 +1526,12 @@ class Ce {
1512
1526
  page: k(),
1513
1527
  events: s
1514
1528
  });
1515
- }, Os)));
1529
+ }, vs)));
1516
1530
  }
1517
1531
  scheduleReconnect() {
1518
1532
  if (this.reconnectTimer !== null || this.state.status === "closed")
1519
1533
  return;
1520
- const t = Fs(this.reconnectAttempts);
1534
+ const t = Ws(this.reconnectAttempts);
1521
1535
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1522
1536
  this.reconnectTimer = null, this.connect().catch((s) => {
1523
1537
  S("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1533,8 +1547,8 @@ class Ce {
1533
1547
  const t = this.socket;
1534
1548
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1535
1549
  this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1536
- }, Rs));
1537
- }, Es);
1550
+ }, Ms));
1551
+ }, ks);
1538
1552
  }
1539
1553
  stopHeartbeat() {
1540
1554
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1560,7 +1574,7 @@ class Ce {
1560
1574
  ...t,
1561
1575
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1562
1576
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1563
- }, hr(this.options.clientId, this.state), this.emit("state", this.getState()), Et("state", this.state.status, {
1577
+ }, fr(this.options.clientId, this.state), this.emit("state", this.getState()), Et("state", this.state.status, {
1564
1578
  status: this.state.status,
1565
1579
  sessionId: this.state.sessionId,
1566
1580
  messageCount: this.state.messages.length,
@@ -1578,13 +1592,13 @@ class Ce {
1578
1592
  }
1579
1593
  }
1580
1594
  const kt = /* @__PURE__ */ new WeakMap();
1581
- function Ws(e) {
1582
- const t = window.__plunoProductAgentNetworkCapture ?? $s();
1595
+ function js(e) {
1596
+ const t = window.__plunoProductAgentNetworkCapture ?? zs();
1583
1597
  return t.subscribers.add(e), () => {
1584
1598
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1585
1599
  };
1586
1600
  }
1587
- function $s() {
1601
+ function zs() {
1588
1602
  const e = /* @__PURE__ */ new Set(), t = (I) => {
1589
1603
  e.forEach((g) => {
1590
1604
  try {
@@ -1601,10 +1615,10 @@ function $s() {
1601
1615
  throw m;
1602
1616
  }
1603
1617
  try {
1604
- const m = g instanceof Request ? g : null, b = Er(g, m), T = We(u?.headers ?? m?.headers);
1618
+ const m = g instanceof Request ? g : null, b = kr(g, m), T = $e(u?.headers ?? m?.headers);
1605
1619
  if (!x(b, T, u?.body)) {
1606
1620
  const F = {
1607
- requestId: Ct("fetch"),
1621
+ requestId: Pt("fetch"),
1608
1622
  url: P(b, Rt),
1609
1623
  method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
1610
1624
  requestHeaders: T,
@@ -1613,19 +1627,19 @@ function $s() {
1613
1627
  startedAt: new Date(d).toISOString()
1614
1628
  };
1615
1629
  p.then(
1616
- (_) => {
1617
- Rr(_, F, d, t).catch(() => {
1630
+ (C) => {
1631
+ Mr(C, F, d, t).catch(() => {
1618
1632
  t({
1619
1633
  ...F,
1620
- responseStatus: _.status,
1634
+ responseStatus: C.status,
1621
1635
  durationMs: Date.now() - d
1622
1636
  });
1623
1637
  });
1624
1638
  },
1625
- (_) => {
1639
+ (C) => {
1626
1640
  t({
1627
1641
  ...F,
1628
- errorText: P(_ instanceof Error ? _.message : String(_)),
1642
+ errorText: P(C instanceof Error ? C.message : String(C)),
1629
1643
  durationMs: Date.now() - d
1630
1644
  });
1631
1645
  }
@@ -1637,7 +1651,7 @@ function $s() {
1637
1651
  }, a = function(g, u, d, p, m) {
1638
1652
  const b = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
1639
1653
  return kt.set(this, {
1640
- requestId: Ct("xhr"),
1654
+ requestId: Pt("xhr"),
1641
1655
  method: String(g ?? "GET").toUpperCase(),
1642
1656
  url: P(T, Rt),
1643
1657
  requestHeaders: {},
@@ -1647,7 +1661,7 @@ function $s() {
1647
1661
  }), b;
1648
1662
  }, c = function(g, u) {
1649
1663
  const d = r.call(this, g, u), p = kt.get(this);
1650
- return p && Object.keys(p.requestHeaders).length < $t && (p.requestHeaders[g] = Xt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1664
+ return p && Object.keys(p.requestHeaders).length < jt && (p.requestHeaders[g] = Jt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1651
1665
  }, l = function(g) {
1652
1666
  try {
1653
1667
  const u = kt.get(this);
@@ -1656,7 +1670,7 @@ function $s() {
1656
1670
  () => {
1657
1671
  queueMicrotask(() => {
1658
1672
  try {
1659
- const d = Ur(this.getAllResponseHeaders());
1673
+ const d = Or(this.getAllResponseHeaders());
1660
1674
  t({
1661
1675
  requestId: u.requestId,
1662
1676
  url: u.url,
@@ -1666,7 +1680,7 @@ function $s() {
1666
1680
  resourceType: "xhr",
1667
1681
  responseStatus: this.status,
1668
1682
  responseHeaders: d,
1669
- responseBody: Mr(this, d),
1683
+ responseBody: Cr(this, d),
1670
1684
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1671
1685
  startedAt: u.startedAt,
1672
1686
  durationMs: Date.now() - u.startedAtMs
@@ -1707,7 +1721,7 @@ function $s() {
1707
1721
  continue;
1708
1722
  const d = performance.timeOrigin + u.startTime;
1709
1723
  t({
1710
- requestId: Ct("resource"),
1724
+ requestId: Pt("resource"),
1711
1725
  url: P(u.name, Rt),
1712
1726
  method: "GET",
1713
1727
  resourceType: "resource",
@@ -1758,14 +1772,14 @@ function S(e, t, s) {
1758
1772
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1759
1773
  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 }));
1760
1774
  }
1761
- function de(e) {
1775
+ function he(e) {
1762
1776
  const t = typeof e == "function" ? e() : e;
1763
1777
  return t && Object.keys(t).length > 0 ? t : void 0;
1764
1778
  }
1765
- function js(e) {
1779
+ function Ks(e) {
1766
1780
  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";
1767
1781
  }
1768
- function zs(e) {
1782
+ function Gs(e) {
1769
1783
  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";
1770
1784
  }
1771
1785
  function Mt(e) {
@@ -1783,8 +1797,8 @@ function Mt(e) {
1783
1797
  }
1784
1798
  return null;
1785
1799
  }
1786
- const Ks = 5e3, Gs = 12e4;
1787
- function Xs(e) {
1800
+ const Xs = 5e3, Js = 12e4;
1801
+ function Vs(e) {
1788
1802
  const t = [];
1789
1803
  for (const s of e)
1790
1804
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1795,30 +1809,30 @@ function Xs(e) {
1795
1809
  });
1796
1810
  return t;
1797
1811
  }
1798
- function Js(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1812
+ function Ys(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1799
1813
  const n = [
1800
- Ys(),
1801
- Vs()
1814
+ Qs(),
1815
+ Zs()
1802
1816
  ].filter((r) => typeof r == "function");
1803
1817
  return () => {
1804
1818
  for (const r of n.reverse())
1805
1819
  r();
1806
1820
  };
1807
1821
  }
1808
- function Vs() {
1809
- return Re(globalThis, "getPageSnapshot", async () => jt());
1822
+ function Zs() {
1823
+ return Re(globalThis, "getPageSnapshot", async () => zt());
1810
1824
  }
1811
- function Ys() {
1825
+ function Qs() {
1812
1826
  return Re(globalThis, "pageImages", {
1813
- inspectImage: async (t, s) => await Zs(t, s)
1827
+ inspectImage: async (t, s) => await tn(t, s)
1814
1828
  });
1815
1829
  }
1816
- async function Zs(e, t = {}) {
1817
- const s = sn(t.name), n = await Qs(e);
1830
+ async function tn(e, t = {}) {
1831
+ const s = rn(t.name), n = await en(e);
1818
1832
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1819
1833
  type: "pluno.pageImages.inspectImage",
1820
1834
  imageAttached: !1,
1821
- imageAttachmentError: Me
1835
+ imageAttachmentError: _e
1822
1836
  } : {
1823
1837
  type: "pluno.pageImages.inspectImage",
1824
1838
  imageAttached: !0,
@@ -1832,15 +1846,15 @@ async function Zs(e, t = {}) {
1832
1846
  imageAttachmentError: n.error
1833
1847
  };
1834
1848
  }
1835
- async function Qs(e) {
1836
- 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: Me } : {
1849
+ async function en(e) {
1850
+ 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 } : {
1837
1851
  ok: !0,
1838
1852
  mimeType: e.type,
1839
1853
  sizeBytes: e.size,
1840
- dataUrl: await rn(e)
1841
- } : { 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." } : tn(e);
1854
+ dataUrl: await an(e)
1855
+ } : { 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." } : sn(e);
1842
1856
  }
1843
- function tn(e) {
1857
+ function sn(e) {
1844
1858
  if (!e.startsWith("data:") || !e.includes(","))
1845
1859
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1846
1860
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1851,7 +1865,7 @@ function tn(e) {
1851
1865
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1852
1866
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1853
1867
  return { ok: !1, error: "Page image data URL has invalid base64." };
1854
- const o = en(i);
1868
+ const o = nn(i);
1855
1869
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1856
1870
  ok: !0,
1857
1871
  mimeType: r,
@@ -1859,22 +1873,22 @@ function tn(e) {
1859
1873
  dataUrl: `data:${r};base64,${i}`
1860
1874
  };
1861
1875
  }
1862
- function en(e) {
1876
+ function nn(e) {
1863
1877
  if (e.length === 0 || e.length % 4 !== 0)
1864
1878
  return null;
1865
1879
  const t = e.length - e.replace(/=+$/, "").length;
1866
1880
  return t > 2 ? null : e.length / 4 * 3 - t;
1867
1881
  }
1868
- function sn(e) {
1882
+ function rn(e) {
1869
1883
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1870
1884
  }
1871
- function nn(e) {
1885
+ function on(e) {
1872
1886
  try {
1873
1887
  e();
1874
1888
  } catch {
1875
1889
  }
1876
1890
  }
1877
- function rn(e) {
1891
+ function an(e) {
1878
1892
  return new Promise((t, s) => {
1879
1893
  const n = new FileReader();
1880
1894
  n.onload = () => {
@@ -1886,9 +1900,9 @@ function rn(e) {
1886
1900
  }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1887
1901
  });
1888
1902
  }
1889
- async function he(e, t) {
1903
+ async function pe(e, t) {
1890
1904
  const s = Object.getPrototypeOf(async function() {
1891
- }).constructor, n = e.timeoutMs ?? Ks, r = Date.now(), i = [];
1905
+ }).constructor, n = e.timeoutMs ?? Xs, r = Date.now(), i = [];
1892
1906
  let o;
1893
1907
  const a = {
1894
1908
  log: console.log,
@@ -1906,7 +1920,7 @@ async function he(e, t) {
1906
1920
  o = window.setTimeout(() => f(l), n);
1907
1921
  })
1908
1922
  ]);
1909
- return h === l ? an(n) : {
1923
+ return h === l ? ln(n) : {
1910
1924
  ok: !0,
1911
1925
  result: h,
1912
1926
  console: i,
@@ -1935,7 +1949,7 @@ async function he(e, t) {
1935
1949
  t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
1936
1950
  }
1937
1951
  }
1938
- function on(e, t) {
1952
+ function cn(e, t) {
1939
1953
  if (!e || typeof e != "object")
1940
1954
  return;
1941
1955
  const s = e.sandboxFilesToken;
@@ -1945,7 +1959,7 @@ function on(e, t) {
1945
1959
  const r = () => {
1946
1960
  if (!n)
1947
1961
  throw new Error("sandboxFiles is only available during browser-code execution");
1948
- }, i = async (a, c) => await ys(`${t.replace(/\/$/, "")}${a}`, c);
1962
+ }, i = async (a, c) => await Ts(`${t.replace(/\/$/, "")}${a}`, c);
1949
1963
  return {
1950
1964
  value: Object.freeze({
1951
1965
  upload: async (a) => {
@@ -1979,7 +1993,7 @@ function on(e, t) {
1979
1993
  }
1980
1994
  };
1981
1995
  }
1982
- function an(e) {
1996
+ function ln(e) {
1983
1997
  return {
1984
1998
  ok: !1,
1985
1999
  exception: {
@@ -1993,10 +2007,10 @@ function an(e) {
1993
2007
  }
1994
2008
  };
1995
2009
  }
1996
- function cn(e) {
2010
+ function un(e) {
1997
2011
  return e.replace(/\/+$/, "");
1998
2012
  }
1999
- function ln(e) {
2013
+ function dn(e) {
2000
2014
  const t = {
2001
2015
  sidepanel: "extension_sidepanel",
2002
2016
  browser_extension_page_ui: "extension_widget",
@@ -2008,18 +2022,18 @@ function ln(e) {
2008
2022
  };
2009
2023
  return e && e in t ? t[e] : e ?? "embedded_custom_ui";
2010
2024
  }
2011
- function un(e) {
2025
+ function hn(e) {
2012
2026
  return e === "pluno" ? "scheduled_continuation" : e ?? "user";
2013
2027
  }
2014
- function dn(e, t = location.origin) {
2028
+ function pn(e, t = location.origin) {
2015
2029
  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;
2016
2030
  }
2017
- function hn(e) {
2031
+ function fn(e) {
2018
2032
  const t = new URL("/api/product-agent/embed/ws", e);
2019
2033
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
2020
2034
  }
2021
2035
  function k() {
2022
- const e = Oe();
2036
+ const e = Ne();
2023
2037
  return {
2024
2038
  url: location.href,
2025
2039
  title: document.title,
@@ -2027,19 +2041,19 @@ function k() {
2027
2041
  ...e ? { plunoProductAgentUi: e } : {}
2028
2042
  };
2029
2043
  }
2030
- function pn() {
2044
+ function gn() {
2031
2045
  return {
2032
2046
  pageUrl: location.href,
2033
2047
  pageTitle: document.title,
2034
- htmlContent: jt()
2048
+ htmlContent: zt()
2035
2049
  };
2036
2050
  }
2037
- function fn(e) {
2038
- return st.add(e), Z || (Z = gn()), () => {
2051
+ function mn(e) {
2052
+ return st.add(e), Z || (Z = yn()), () => {
2039
2053
  st.delete(e), st.size === 0 && (Z?.(), Z = null);
2040
2054
  };
2041
2055
  }
2042
- function gn() {
2056
+ function yn() {
2043
2057
  const e = () => {
2044
2058
  for (const i of Array.from(st))
2045
2059
  i();
@@ -2054,10 +2068,10 @@ function gn() {
2054
2068
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
2055
2069
  };
2056
2070
  }
2057
- function mn() {
2058
- return Oe()?.surface === "browser_extension_sdk_preview";
2071
+ function In() {
2072
+ return Ne()?.surface === "browser_extension_sdk_preview";
2059
2073
  }
2060
- function jt() {
2074
+ function zt() {
2061
2075
  if (!document.body)
2062
2076
  return "";
2063
2077
  const e = [], t = [], s = (d, p) => {
@@ -2066,16 +2080,16 @@ function jt() {
2066
2080
  };
2067
2081
  s("Selected text", window.getSelection()?.toString() ?? "");
2068
2082
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
2069
- (d) => Pe(d) && !d.parentElement?.closest(n)
2083
+ (d) => Ue(d) && !d.parentElement?.closest(n)
2070
2084
  );
2071
2085
  for (const d of r.slice(0, 3))
2072
2086
  s("Active overlay", _t(z(d), t));
2073
- const i = yn(), o = i ? _t(z(i), t) : "";
2087
+ const i = Tn(), o = i ? _t(z(i), t) : "";
2074
2088
  s("Main page content", o), s("Additional visible page text", _t(z(document.body), t));
2075
2089
  const a = e.map(([d, p]) => `${d}:
2076
2090
  ${p}`).join(`
2077
2091
 
2078
- `).trim().slice(0, 12e3), c = In(r, i).trim(), l = `Simplified DOM outline:
2092
+ `).trim().slice(0, 12e3), c = wn(r, i).trim(), l = `Simplified DOM outline:
2079
2093
  `, h = `
2080
2094
 
2081
2095
  Visible page text:
@@ -2099,14 +2113,14 @@ function _t(e, t) {
2099
2113
  s = s.replace(n, "");
2100
2114
  return B(s);
2101
2115
  }
2102
- function Pe(e) {
2116
+ function Ue(e) {
2103
2117
  const t = window.getComputedStyle(e);
2104
2118
  return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
2105
2119
  }
2106
- function yn() {
2107
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Pe).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
2120
+ function Tn() {
2121
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ue).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
2108
2122
  }
2109
- function In(e, t) {
2123
+ function wn(e, t) {
2110
2124
  const s = /* @__PURE__ */ new Set([
2111
2125
  "main",
2112
2126
  "nav",
@@ -2186,7 +2200,7 @@ function In(e, t) {
2186
2200
  "data-test",
2187
2201
  "data-qa",
2188
2202
  "data-cy"
2189
- ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = Tn(), I = new Set(e);
2203
+ ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = Sn(), I = new Set(e);
2190
2204
  t && I.add(t);
2191
2205
  let g = 0;
2192
2206
  const u = (T) => {
@@ -2196,41 +2210,41 @@ function In(e, t) {
2196
2210
  const D = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
2197
2211
  return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
2198
2212
  }, p = (T, D, F) => {
2199
- const _ = (A, dt) => {
2213
+ const C = (A, dt) => {
2200
2214
  const R = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
2201
2215
  if (g >= 1e3 && !K || F.has(A) || i.has(R) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
2202
2216
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2203
2217
  g += 1;
2204
- const Jt = u(A), G = De(A), Ve = a.has(Jt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(R) || R === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
2218
+ const Vt = u(A), G = Oe(A), Ye = a.has(Vt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(R) || R === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
2205
2219
  for (const y of pt) {
2206
2220
  const w = d(y);
2207
2221
  X.set(w, (X.get(w) ?? 0) + 1);
2208
2222
  }
2209
- const ft = /* @__PURE__ */ new Map(), Vt = /* @__PURE__ */ new Map();
2223
+ const ft = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Map();
2210
2224
  for (const y of pt) {
2211
- const w = d(y), O = Vt.get(w) ?? 0;
2212
- Vt.set(w, O + 1), (X.get(w) ?? 0) > 8 && O >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
2225
+ const w = d(y), O = Yt.get(w) ?? 0;
2226
+ Yt.set(w, O + 1), (X.get(w) ?? 0) > 8 && O >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
2213
2227
  }
2214
- const Yt = /* @__PURE__ */ new Map(), Zt = /* @__PURE__ */ new Set(), gt = [], Qt = [];
2228
+ const Zt = /* @__PURE__ */ new Map(), Qt = /* @__PURE__ */ new Set(), gt = [], te = [];
2215
2229
  for (const y of pt) {
2216
- const w = d(y), O = X.get(w) ?? 0, se = Yt.get(w) ?? 0;
2217
- if (Yt.set(w, se + 1), O > 8 && se >= 6 && !h.has(y)) {
2218
- Zt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Zt.add(w));
2230
+ const w = d(y), O = X.get(w) ?? 0, ne = Zt.get(w) ?? 0;
2231
+ if (Zt.set(w, ne + 1), O > 8 && ne >= 6 && !h.has(y)) {
2232
+ Qt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Qt.add(w));
2219
2233
  continue;
2220
2234
  }
2221
- const ne = _(y, dt);
2222
- Qt.push(ne), gt.push(ne.lines);
2235
+ const re = C(y, dt);
2236
+ te.push(re), gt.push(re.lines);
2223
2237
  }
2224
2238
  const mt = [];
2225
2239
  if (A.shadowRoot)
2226
2240
  for (const y of Array.from(A.shadowRoot.children))
2227
- y instanceof HTMLElement && mt.push(_(y, dt + 1));
2228
- const J = [...Qt, ...mt], yt = G.length > 0 || Ve || J.some((y) => y.hasUsefulContent), te = B(
2241
+ y instanceof HTMLElement && mt.push(C(y, dt + 1));
2242
+ const J = [...te, ...mt], yt = G.length > 0 || Ye || J.some((y) => y.hasUsefulContent), ee = B(
2229
2243
  [G, ...J.map((y) => y.textPreview)].filter(Boolean).join(" ")
2230
- ).slice(0, 180), Ye = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), ee = l.some((y) => A.hasAttribute(y)) || !!Jt || Ye, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(R) || ee || K) && (yt || K) && (!r.has(R) || yt || ee || K), Tt = It ? 1 : 0, H = [];
2244
+ ).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(R) || se || K) && (yt || K) && (!r.has(R) || yt || se || K), Tt = It ? 1 : 0, H = [];
2231
2245
  if (It) {
2232
- const y = J.some((O) => O.containsTextElement), w = n.has(R) && !y ? te : G;
2233
- H.push(Ue(A, c, o, w.slice(0, 180)));
2246
+ const y = J.some((O) => O.containsTextElement), w = n.has(R) && !y ? ee : G;
2247
+ H.push(De(A, c, o, w.slice(0, 180)));
2234
2248
  }
2235
2249
  for (const y of gt)
2236
2250
  H.push(...Q(y, Tt));
@@ -2248,15 +2262,15 @@ function In(e, t) {
2248
2262
  return {
2249
2263
  lines: H,
2250
2264
  hasUsefulContent: yt,
2251
- textPreview: te,
2265
+ textPreview: ee,
2252
2266
  containsTextElement: n.has(R) || J.some((y) => y.containsTextElement)
2253
2267
  };
2254
2268
  };
2255
- return [`--- ${D} ---`, ..._(T, 0).lines].join(`
2269
+ return [`--- ${D} ---`, ...C(T, 0).lines].join(`
2256
2270
  `);
2257
2271
  }, m = [], b = B(window.getSelection()?.toString() ?? "");
2258
2272
  b && m.push(`--- selected text ---
2259
- ${JSON.stringify(b)}`), f.length > 0 && m.push(wn(f, s, c, o));
2273
+ ${JSON.stringify(b)}`), f.length > 0 && m.push(An(f, s, c, o));
2260
2274
  for (const T of e.slice(0, 3))
2261
2275
  m.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2262
2276
  if (t && m.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
@@ -2267,11 +2281,11 @@ ${JSON.stringify(b)}`), f.length > 0 && m.push(wn(f, s, c, o));
2267
2281
 
2268
2282
  `);
2269
2283
  }
2270
- function Ue(e, t, s, n) {
2284
+ function De(e, t, s, n) {
2271
2285
  const r = e.tagName.toLowerCase();
2272
2286
  let i = r;
2273
2287
  const o = e.getAttribute("id");
2274
- o && Sn(o) && (i += `#${o}`);
2288
+ o && bn(o) && (i += `#${o}`);
2275
2289
  for (const a of t) {
2276
2290
  const c = e.getAttribute(a);
2277
2291
  c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
@@ -2284,7 +2298,7 @@ function Ue(e, t, s, n) {
2284
2298
  e.hasAttribute(a) && (i += `[${a}]`);
2285
2299
  return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
2286
2300
  }
2287
- function Tn() {
2301
+ function Sn() {
2288
2302
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
2289
2303
  if (!a)
2290
2304
  return;
@@ -2305,7 +2319,7 @@ function Tn() {
2305
2319
  n = n.shadowRoot.activeElement;
2306
2320
  n !== document.body && n !== document.documentElement && s(n, "focused");
2307
2321
  const r = window.getSelection();
2308
- r && !r.isCollapsed && (s(pe(r.anchorNode), "selected text"), s(pe(r.focusNode), "selected text"));
2322
+ r && !r.isCollapsed && (s(fe(r.anchorNode), "selected text"), s(fe(r.focusNode), "selected text"));
2309
2323
  const i = [
2310
2324
  ["[aria-selected='true']", "selected"],
2311
2325
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -2327,7 +2341,7 @@ function Tn() {
2327
2341
  priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
2328
2342
  };
2329
2343
  }
2330
- function wn(e, t, s, n) {
2344
+ function An(e, t, s, n) {
2331
2345
  const r = ["--- active/current elements ---"];
2332
2346
  for (const i of e) {
2333
2347
  const o = [];
@@ -2338,18 +2352,18 @@ function wn(e, t, s, n) {
2338
2352
  const f = a.getRootNode();
2339
2353
  a = a.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
2340
2354
  }
2341
- const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => Ue(
2355
+ const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => De(
2342
2356
  h,
2343
2357
  s,
2344
2358
  n,
2345
- f === c.length - 1 ? De(h).slice(0, 180) : ""
2359
+ f === c.length - 1 ? Oe(h).slice(0, 180) : ""
2346
2360
  ));
2347
2361
  o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
2348
2362
  }
2349
2363
  return r.join(`
2350
2364
  `);
2351
2365
  }
2352
- function pe(e) {
2366
+ function fe(e) {
2353
2367
  return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
2354
2368
  }
2355
2369
  function Q(e, t) {
@@ -2358,17 +2372,17 @@ function Q(e, t) {
2358
2372
  const s = " ".repeat(t);
2359
2373
  return e.map((n) => `${s}${n}`);
2360
2374
  }
2361
- function De(e) {
2375
+ function Oe(e) {
2362
2376
  return B(
2363
2377
  Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
2364
2378
  );
2365
2379
  }
2366
- function Sn(e) {
2380
+ function bn(e) {
2367
2381
  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);
2368
2382
  }
2369
- function Oe() {
2370
- const e = document.querySelector(re);
2371
- if (!(e ?? document.querySelector(Ut)))
2383
+ function Ne() {
2384
+ const e = document.querySelector(ie);
2385
+ if (!(e ?? document.querySelector(Dt)))
2372
2386
  return;
2373
2387
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
2374
2388
  return {
@@ -2377,28 +2391,28 @@ function Oe() {
2377
2391
  selectors: [
2378
2392
  {
2379
2393
  name: "widget_host",
2380
- selector: s === "browser_extension_sdk_preview" ? re : Ut,
2394
+ selector: s === "browser_extension_sdk_preview" ? ie : Dt,
2381
2395
  description: "Finds Pluno's shadow-host element in the host page DOM."
2382
2396
  },
2383
2397
  {
2384
2398
  name: "widget_root",
2385
- selector: Is,
2399
+ selector: ws,
2386
2400
  description: "Finds Pluno's widget root inside the widget host shadow root."
2387
2401
  },
2388
2402
  {
2389
2403
  name: "widget_panel",
2390
- selector: Ts,
2404
+ selector: Ss,
2391
2405
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
2392
2406
  },
2393
2407
  {
2394
2408
  name: "widget_timeline",
2395
- selector: ws,
2409
+ selector: As,
2396
2410
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2397
2411
  }
2398
2412
  ]
2399
2413
  };
2400
2414
  }
2401
- function An(e) {
2415
+ function En(e) {
2402
2416
  try {
2403
2417
  const t = JSON.parse(e);
2404
2418
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -2406,16 +2420,16 @@ function An(e) {
2406
2420
  return { type: "error", message: "Invalid server event" };
2407
2421
  }
2408
2422
  }
2409
- function fe(e, t) {
2423
+ function ge(e, t) {
2410
2424
  if (!e || typeof e != "object")
2411
2425
  return [];
2412
2426
  const s = e[t];
2413
2427
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2414
2428
  }
2415
- function bn(e) {
2429
+ function Rn(e) {
2416
2430
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
2417
2431
  }
2418
- function En(e) {
2432
+ function kn(e) {
2419
2433
  if (!e || typeof e != "object")
2420
2434
  return null;
2421
2435
  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;
@@ -2426,13 +2440,13 @@ function En(e) {
2426
2440
  ...a !== null ? { scribbleStyle: a } : {}
2427
2441
  };
2428
2442
  }
2429
- function Rn(e) {
2443
+ function Mn(e) {
2430
2444
  if (!e || typeof e != "object")
2431
2445
  return null;
2432
2446
  const t = e.javascript;
2433
2447
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
2434
2448
  }
2435
- function kn(e, t) {
2449
+ function _n(e, t) {
2436
2450
  return t ? e && typeof e == "object" ? {
2437
2451
  ...e,
2438
2452
  helperError: t
@@ -2442,13 +2456,13 @@ function kn(e, t) {
2442
2456
  helperError: t
2443
2457
  } : e;
2444
2458
  }
2445
- function Mn(e) {
2459
+ function Cn(e) {
2446
2460
  if (!e || typeof e != "object")
2447
2461
  return e;
2448
2462
  const t = e;
2449
2463
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2450
2464
  }
2451
- function _n() {
2465
+ function Pn() {
2452
2466
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2453
2467
  if (t)
2454
2468
  return t;
@@ -2458,7 +2472,7 @@ function _n() {
2458
2472
  function $() {
2459
2473
  return crypto.randomUUID();
2460
2474
  }
2461
- function Cn(e) {
2475
+ function Un(e) {
2462
2476
  if (!e || typeof e != "object")
2463
2477
  return null;
2464
2478
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2469,12 +2483,12 @@ function Cn(e) {
2469
2483
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2470
2484
  } : null;
2471
2485
  }
2472
- function Pn(e, t) {
2473
- return Array.isArray(e) ? qt(
2474
- e.map((s) => Ne(s, t)).filter((s) => s !== null)
2486
+ function Dn(e, t) {
2487
+ return Array.isArray(e) ? Bt(
2488
+ e.map((s) => ve(s, t)).filter((s) => s !== null)
2475
2489
  ) : [];
2476
2490
  }
2477
- function Un(e) {
2491
+ function On(e) {
2478
2492
  return Array.isArray(e) ? e.flatMap((t) => {
2479
2493
  if (!t || typeof t != "object")
2480
2494
  return [];
@@ -2495,7 +2509,7 @@ function Un(e) {
2495
2509
  ];
2496
2510
  }) : [];
2497
2511
  }
2498
- function Ne(e, t) {
2512
+ function ve(e, t) {
2499
2513
  if (!e || typeof e != "object")
2500
2514
  return null;
2501
2515
  const s = e, n = s.data;
@@ -2509,14 +2523,14 @@ function Ne(e, t) {
2509
2523
  id: String(s.id ?? crypto.randomUUID()),
2510
2524
  role: i,
2511
2525
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2512
- content: is(
2513
- qn(r.content),
2526
+ content: os(
2527
+ Fn(r.content),
2514
2528
  t
2515
2529
  ),
2516
2530
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2517
- respondsToUserMessageId: v(r) ?? void 0,
2518
- ...C(r) ? { runId: C(r) } : {},
2519
- attachments: Fe(r.attachments, t)
2531
+ respondsToUserMessageId: N(r) ?? void 0,
2532
+ ...M(r) ? { runId: M(r) } : {},
2533
+ attachments: He(r.attachments, t)
2520
2534
  };
2521
2535
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
2522
2536
  value: r.id,
@@ -2527,38 +2541,52 @@ function Ne(e, t) {
2527
2541
  }), o;
2528
2542
  }
2529
2543
  if (r.type === "function_call_output") {
2530
- const i = On(r.output);
2531
- return i ? {
2544
+ const i = Is(r.output);
2545
+ if (i)
2546
+ return {
2547
+ id: String(s.id ?? crypto.randomUUID()),
2548
+ role: "tool",
2549
+ content: "",
2550
+ createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2551
+ respondsToUserMessageId: N(r) ?? void 0,
2552
+ ...M(r) ? { runId: M(r) } : {},
2553
+ dataType: "scheduled_check_in",
2554
+ toolName: Me,
2555
+ callId: Ct(r) ?? void 0,
2556
+ scheduledCheckInAt: i
2557
+ };
2558
+ const o = vn(r.output);
2559
+ return o ? {
2532
2560
  id: String(s.id ?? crypto.randomUUID()),
2533
2561
  role: "tool",
2534
- content: `Connect ${i.appName} to continue`,
2562
+ content: `Connect ${o.appName} to continue`,
2535
2563
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2536
- respondsToUserMessageId: v(r) ?? void 0,
2537
- ...C(r) ? { runId: C(r) } : {},
2564
+ respondsToUserMessageId: N(r) ?? void 0,
2565
+ ...M(r) ? { runId: M(r) } : {},
2538
2566
  dataType: "function_call_output",
2539
2567
  toolName: "authenticate_pipedream_app",
2540
- callId: ge(r) ?? void 0,
2541
- integrationAuthRequest: i
2568
+ callId: Ct(r) ?? void 0,
2569
+ integrationAuthRequest: o
2542
2570
  } : null;
2543
2571
  }
2544
2572
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2545
2573
  id: String(s.id ?? crypto.randomUUID()),
2546
2574
  role: "tool",
2547
- content: r.type === "mcp_call" ? Dn(r) : vn(r),
2575
+ content: r.type === "mcp_call" ? Nn(r) : Ln(r),
2548
2576
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2549
- respondsToUserMessageId: v(r) ?? void 0,
2550
- ...C(r) ? { runId: C(r) } : {},
2577
+ respondsToUserMessageId: N(r) ?? void 0,
2578
+ ...M(r) ? { runId: M(r) } : {},
2551
2579
  dataType: String(r.type),
2552
2580
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
2553
- callId: ge(r) ?? void 0,
2581
+ callId: Ct(r) ?? void 0,
2554
2582
  loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
2555
2583
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2556
2584
  id: String(s.id ?? crypto.randomUUID()),
2557
2585
  role: "system",
2558
- content: Nn(r),
2586
+ content: xn(r),
2559
2587
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2560
- respondsToUserMessageId: v(r) ?? void 0,
2561
- ...C(r) ? { runId: C(r) } : {},
2588
+ respondsToUserMessageId: N(r) ?? void 0,
2589
+ ...M(r) ? { runId: M(r) } : {},
2562
2590
  dataType: String(r.type),
2563
2591
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
2564
2592
  ...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
@@ -2566,11 +2594,11 @@ function Ne(e, t) {
2566
2594
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2567
2595
  } : null;
2568
2596
  }
2569
- function Dn(e) {
2597
+ function Nn(e) {
2570
2598
  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(" ");
2571
2599
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2572
2600
  }
2573
- function On(e) {
2601
+ function vn(e) {
2574
2602
  if (typeof e != "string")
2575
2603
  return null;
2576
2604
  try {
@@ -2587,10 +2615,10 @@ function On(e) {
2587
2615
  return null;
2588
2616
  }
2589
2617
  }
2590
- function Nn(e) {
2618
+ function xn(e) {
2591
2619
  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.";
2592
2620
  }
2593
- function vn(e) {
2621
+ function Ln(e) {
2594
2622
  if (e.type === "web_search_call") {
2595
2623
  const t = e.action;
2596
2624
  if (t && typeof t == "object") {
@@ -2602,9 +2630,9 @@ function vn(e) {
2602
2630
  }
2603
2631
  return "🔎 Searching the web";
2604
2632
  }
2605
- return xn(e);
2633
+ return qn(e);
2606
2634
  }
2607
- function xn(e) {
2635
+ function qn(e) {
2608
2636
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2609
2637
  return L(e.summary);
2610
2638
  if (typeof e.arguments == "string")
@@ -2621,7 +2649,7 @@ function L(e) {
2621
2649
  const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2622
2650
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2623
2651
  }
2624
- function Ln(e) {
2652
+ function Bn(e) {
2625
2653
  if (e == null)
2626
2654
  return e;
2627
2655
  if (typeof e != "object")
@@ -2636,11 +2664,11 @@ function Ln(e) {
2636
2664
  runId: typeof t.runId == "string" ? t.runId : null
2637
2665
  };
2638
2666
  }
2639
- function ge(e) {
2667
+ function Ct(e) {
2640
2668
  const t = e.callId ?? e.call_id;
2641
2669
  return typeof t == "string" && t ? t : null;
2642
2670
  }
2643
- function qn(e) {
2671
+ function Fn(e) {
2644
2672
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2645
2673
  if (!t || typeof t != "object")
2646
2674
  return "";
@@ -2648,31 +2676,31 @@ function qn(e) {
2648
2676
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
2649
2677
  }).filter(Boolean).join("") : "";
2650
2678
  }
2651
- function Ot(e, t) {
2652
- const s = xe(e, t), n = zn(
2653
- Bn(
2654
- Jn(e, t),
2679
+ function Nt(e, t) {
2680
+ const s = Le(e, t), n = Gn(
2681
+ Hn(
2682
+ Yn(e, t),
2655
2683
  s
2656
2684
  ),
2657
2685
  s
2658
2686
  ), r = n.findIndex((o) => o.id === s.id);
2659
2687
  if (r === -1)
2660
- return qt(
2688
+ return Bt(
2661
2689
  [...n, s]
2662
2690
  );
2663
2691
  const i = [...n];
2664
- return i[r] = s, qt(i);
2692
+ return i[r] = s, Bt(i);
2665
2693
  }
2666
- function Bn(e, t) {
2694
+ function Hn(e, t) {
2667
2695
  const s = t.assistantDraftItemId;
2668
2696
  return s ? e.map(
2669
2697
  (n) => n.dataType === "assistant_draft" && n.id === s ? t : n
2670
2698
  ) : e;
2671
2699
  }
2672
- function Fn(e, t, s) {
2700
+ function Wn(e, t, s) {
2673
2701
  return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
2674
2702
  }
2675
- function Hn(e, t, s, n) {
2703
+ function $n(e, t, s, n) {
2676
2704
  if (s === null) return e;
2677
2705
  let r = -1;
2678
2706
  for (let o = e.length - 1; o >= 0; o -= 1) {
@@ -2689,12 +2717,12 @@ function Hn(e, t, s, n) {
2689
2717
  respondsToUserMessageId: s
2690
2718
  }, i;
2691
2719
  }
2692
- function Wn(e, t) {
2720
+ function jn(e, t) {
2693
2721
  const s = e.findIndex(
2694
2722
  (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2695
2723
  );
2696
2724
  if (s === -1)
2697
- return Ot(e, t);
2725
+ return Nt(e, t);
2698
2726
  const n = [...e];
2699
2727
  return n[s] = {
2700
2728
  ...n[s],
@@ -2706,12 +2734,12 @@ function Wn(e, t) {
2706
2734
  ...n[s].runId ? {} : { runId: t.runId }
2707
2735
  }, n;
2708
2736
  }
2709
- function $n(e, t, s) {
2737
+ function zn(e, t, s) {
2710
2738
  let n = !1;
2711
2739
  const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2712
2740
  return n ? r : e;
2713
2741
  }
2714
- function jn(e) {
2742
+ function Kn(e) {
2715
2743
  if (e.hiddenFromTranscript === !0)
2716
2744
  return null;
2717
2745
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
@@ -2730,7 +2758,7 @@ function jn(e) {
2730
2758
  loading: !0
2731
2759
  };
2732
2760
  }
2733
- function zn(e, t) {
2761
+ function Gn(e, t) {
2734
2762
  if (t.id.startsWith("transient-activity:"))
2735
2763
  return e;
2736
2764
  const s = t.toolName === "tab_lifecycle";
@@ -2738,17 +2766,17 @@ function zn(e, t) {
2738
2766
  (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)
2739
2767
  );
2740
2768
  }
2741
- function Kn(e, t) {
2742
- return os(
2769
+ function Xn(e, t) {
2770
+ return as(
2743
2771
  e,
2744
2772
  t.map(
2745
- (s) => xe(e, s)
2773
+ (s) => Le(e, s)
2746
2774
  ),
2747
- ve
2775
+ xe
2748
2776
  );
2749
2777
  }
2750
- function ve(e) {
2751
- const t = Nt(e) ?? void 0, s = e.assistantDraftItemId, n = [
2778
+ function xe(e) {
2779
+ const t = vt(e) ?? void 0, s = e.assistantDraftItemId, n = [
2752
2780
  ...e.callId ? [`call:${e.callId}`] : [],
2753
2781
  ...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
2754
2782
  ];
@@ -2759,52 +2787,52 @@ function ve(e) {
2759
2787
  ...n.length > 0 ? { activityKeys: n } : {},
2760
2788
  ...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
2761
2789
  ...e.runId ? { runId: e.runId } : {},
2762
- isOptimistic: zt(e),
2790
+ isOptimistic: Kt(e),
2763
2791
  isAssistantDraft: e.dataType === "assistant_draft",
2764
2792
  isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
2765
2793
  isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
2766
2794
  };
2767
2795
  }
2768
- function xe(e, t) {
2796
+ function Le(e, t) {
2769
2797
  if (t.role !== "user" || !t.attachments?.length)
2770
2798
  return t;
2771
2799
  const s = e.find(
2772
- (r) => r.role === "user" && (r.id === t.id || zt(r) && Le(r, t))
2800
+ (r) => r.role === "user" && (r.id === t.id || Kt(r) && qe(r, t))
2773
2801
  );
2774
2802
  if (!s?.attachments?.length)
2775
2803
  return t;
2776
2804
  const n = t.attachments.map((r) => {
2777
- const i = Gn(s.attachments ?? [], r);
2778
- return i ? Xn(r, i) : r;
2805
+ const i = Jn(s.attachments ?? [], r);
2806
+ return i ? Vn(r, i) : r;
2779
2807
  });
2780
2808
  return { ...t, attachments: n };
2781
2809
  }
2782
- function Gn(e, t) {
2810
+ function Jn(e, t) {
2783
2811
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2784
2812
  }
2785
- function Xn(e, t) {
2813
+ function Vn(e, t) {
2786
2814
  const { previewUrl: s } = t;
2787
2815
  return s ? { ...e, previewUrl: s } : e;
2788
2816
  }
2789
- function Jn(e, t) {
2817
+ function Yn(e, t) {
2790
2818
  if (t.role !== "user")
2791
2819
  return e;
2792
2820
  const s = e.findIndex(
2793
- (r) => zt(r) && Le(r, t)
2821
+ (r) => Kt(r) && qe(r, t)
2794
2822
  );
2795
2823
  if (s === -1)
2796
2824
  return e;
2797
2825
  const n = [...e];
2798
2826
  return n.splice(s, 1), n;
2799
2827
  }
2800
- function Le(e, t) {
2801
- const s = Nt(e), n = Nt(t);
2828
+ function qe(e, t) {
2829
+ const s = vt(e), n = vt(t);
2802
2830
  return s && n ? s === n : e.content === t.content;
2803
2831
  }
2804
- function zt(e) {
2832
+ function Kt(e) {
2805
2833
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2806
2834
  }
2807
- function Nt(e) {
2835
+ function vt(e) {
2808
2836
  const t = e.clientMessageId;
2809
2837
  if (t)
2810
2838
  return t;
@@ -2814,17 +2842,17 @@ function Nt(e) {
2814
2842
  return n ? e.id.slice(n.length) : null;
2815
2843
  }
2816
2844
  function me(e) {
2817
- const t = qe(e);
2845
+ const t = Be(e);
2818
2846
  if (t === null)
2819
2847
  return !1;
2820
2848
  const s = e[t].id, n = e.some(
2821
- (r) => r.respondsToUserMessageId === s && vt(r)
2849
+ (r) => r.respondsToUserMessageId === s && xt(r)
2822
2850
  );
2823
2851
  if (e.some((r) => r.respondsToUserMessageId === s))
2824
2852
  return n;
2825
2853
  for (let r = e.length - 1; r > t; r -= 1) {
2826
2854
  const i = e[r];
2827
- if (N(i))
2855
+ if (v(i))
2828
2856
  return !0;
2829
2857
  if (i.role === "system") {
2830
2858
  if (i.dataType === "run_error")
@@ -2835,23 +2863,23 @@ function me(e) {
2835
2863
  }
2836
2864
  return !1;
2837
2865
  }
2838
- function Vn(e) {
2839
- const t = qe(e);
2866
+ function Zn(e) {
2867
+ const t = Be(e);
2840
2868
  if (t === null)
2841
- return e.some(N);
2869
+ return e.some(v);
2842
2870
  const s = e[t].id;
2843
2871
  return e.some((n) => n.respondsToUserMessageId === s) ? e.some(
2844
- (n) => n.respondsToUserMessageId === s && N(n)
2845
- ) : e.slice(t + 1).some(N);
2872
+ (n) => n.respondsToUserMessageId === s && v(n)
2873
+ ) : e.slice(t + 1).some(v);
2846
2874
  }
2847
- function qe(e) {
2875
+ function Be(e) {
2848
2876
  for (let t = e.length - 1; t >= 0; t -= 1)
2849
2877
  if (e[t].role === "user")
2850
2878
  return t;
2851
2879
  return null;
2852
2880
  }
2853
- function vt(e) {
2854
- return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2881
+ function xt(e) {
2882
+ return v(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2855
2883
  }
2856
2884
  function at(e) {
2857
2885
  for (let t = e.length - 1; t >= 0; t -= 1) {
@@ -2867,7 +2895,7 @@ function at(e) {
2867
2895
  }
2868
2896
  return null;
2869
2897
  }
2870
- function Yn(e) {
2898
+ function Qn(e) {
2871
2899
  const t = at(e);
2872
2900
  if (t === null)
2873
2901
  return null;
@@ -2883,13 +2911,13 @@ function q(e) {
2883
2911
  const t = e.data;
2884
2912
  return t && typeof t == "object" ? t : null;
2885
2913
  }
2886
- function xt(e) {
2914
+ function Lt(e) {
2887
2915
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2888
2916
  }
2889
2917
  function ye(e) {
2890
2918
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2891
2919
  }
2892
- function Zn(e, t) {
2920
+ function tr(e, t) {
2893
2921
  const s = at(t);
2894
2922
  if (s === null)
2895
2923
  return !1;
@@ -2898,10 +2926,10 @@ function Zn(e, t) {
2898
2926
  return !1;
2899
2927
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2900
2928
  return i === -1 ? !1 : e.some((o) => o.respondsToUserMessageId === r) ? e.some(
2901
- (o) => o.respondsToUserMessageId === r && vt(o)
2902
- ) : e.slice(i + 1).some(vt);
2929
+ (o) => o.respondsToUserMessageId === r && xt(o)
2930
+ ) : e.slice(i + 1).some(xt);
2903
2931
  }
2904
- function Lt(e) {
2932
+ function qt(e) {
2905
2933
  const t = at(e);
2906
2934
  if (t === null)
2907
2935
  return null;
@@ -2914,7 +2942,7 @@ function Lt(e) {
2914
2942
  const r = n.clientMessageId;
2915
2943
  return typeof r == "string" ? r : null;
2916
2944
  }
2917
- function Qn(e) {
2945
+ function er(e) {
2918
2946
  const t = at(e);
2919
2947
  if (t === null)
2920
2948
  return null;
@@ -2929,22 +2957,22 @@ function Qn(e) {
2929
2957
  if (i.type === "message" && i.role === "assistant")
2930
2958
  return null;
2931
2959
  if (i.type === "run_error")
2932
- return i.retryable !== !0 ? null : Ie(e, i) ?? Lt(e);
2960
+ return i.retryable !== !0 ? null : Ie(e, i) ?? qt(e);
2933
2961
  if (i.type === "run_status")
2934
- return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ?? Lt(e) : null;
2962
+ return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ?? qt(e) : null;
2935
2963
  }
2936
2964
  return null;
2937
2965
  }
2938
2966
  function Ie(e, t) {
2939
2967
  if (typeof t.clientMessageId == "string")
2940
2968
  return t.clientMessageId;
2941
- const s = v(t);
2969
+ const s = N(t);
2942
2970
  if (!s)
2943
2971
  return null;
2944
2972
  const n = e.find((i) => E(i, "id") === s), r = q(n);
2945
2973
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2946
2974
  }
2947
- function tr(e, t) {
2975
+ function sr(e, t) {
2948
2976
  let s = 0;
2949
2977
  for (const n of e) {
2950
2978
  if (!n || typeof n != "object")
@@ -2958,38 +2986,38 @@ function tr(e, t) {
2958
2986
  return s;
2959
2987
  }
2960
2988
  function Te(e, t, s, n, r) {
2961
- if (!t || !er(e))
2989
+ if (!t || !nr(e))
2962
2990
  return !1;
2963
2991
  const i = e;
2964
- return !(xt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? v(i) !== n : r !== null && C(i) !== r));
2992
+ return !(Lt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? N(i) !== n : r !== null && M(i) !== r));
2965
2993
  }
2966
- function er(e) {
2994
+ function nr(e) {
2967
2995
  if (!e || typeof e != "object")
2968
2996
  return !1;
2969
2997
  const t = e;
2970
2998
  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");
2971
2999
  }
2972
- function N(e) {
3000
+ function v(e) {
2973
3001
  return e.role === "assistant" && e.phase !== "commentary";
2974
3002
  }
2975
- function sr(e) {
3003
+ function rr(e) {
2976
3004
  if (!e || typeof e != "object")
2977
3005
  return !1;
2978
3006
  const t = e;
2979
3007
  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";
2980
3008
  }
2981
- function qt(e) {
2982
- return e.filter((t, s) => ct(t) ? !ur(e, s) && !cr(e, s) && !lr(e, s) : nr(t) ? t.retryable === !0 && ar(e, s) ? !1 : !or(e, s) : !0);
3009
+ function Bt(e) {
3010
+ return e.filter((t, s) => ct(t) ? !hr(e, s) && !ur(e, s) && !dr(e, s) : ir(t) ? t.retryable === !0 && lr(e, s) ? !1 : !cr(e, s) : !0);
2983
3011
  }
2984
- function nr(e) {
3012
+ function ir(e) {
2985
3013
  return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
2986
3014
  }
2987
3015
  function ct(e) {
2988
3016
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2989
3017
  }
2990
- function rr(e, t) {
3018
+ function or(e, t) {
2991
3019
  const s = [...e].reverse().find(
2992
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !ir(
3020
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !ar(
2993
3021
  e,
2994
3022
  n.respondsToUserMessageId
2995
3023
  )
@@ -3001,12 +3029,12 @@ function rr(e, t) {
3001
3029
  function we(e) {
3002
3030
  return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
3003
3031
  }
3004
- function ir(e, t) {
3032
+ function ar(e, t) {
3005
3033
  return e.some(
3006
- (s) => s.respondsToUserMessageId === t && (N(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3034
+ (s) => s.respondsToUserMessageId === t && (v(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3007
3035
  );
3008
3036
  }
3009
- function or(e, t) {
3037
+ function cr(e, t) {
3010
3038
  const s = e[t];
3011
3039
  for (let n = t + 1; n < e.length; n += 1) {
3012
3040
  const r = e[n];
@@ -3015,7 +3043,7 @@ function or(e, t) {
3015
3043
  }
3016
3044
  return !1;
3017
3045
  }
3018
- function ar(e, t) {
3046
+ function lr(e, t) {
3019
3047
  const s = e[t];
3020
3048
  if (!s.respondsToUserMessageId)
3021
3049
  return !1;
@@ -3028,19 +3056,19 @@ function ar(e, t) {
3028
3056
  }
3029
3057
  return !1;
3030
3058
  }
3031
- function cr(e, t) {
3059
+ function ur(e, t) {
3032
3060
  const s = e[t];
3033
3061
  return e.some(
3034
3062
  (n, r) => r !== t && n.role === "assistant" && lt(s, n)
3035
3063
  );
3036
3064
  }
3037
- function lr(e, t) {
3065
+ function dr(e, t) {
3038
3066
  const s = e[t];
3039
3067
  return e.some(
3040
3068
  (n, r) => r !== t && n.role === "tool" && lt(s, n)
3041
3069
  );
3042
3070
  }
3043
- function ur(e, t) {
3071
+ function hr(e, t) {
3044
3072
  const s = e[t];
3045
3073
  for (let n = t + 1; n < e.length; n += 1)
3046
3074
  if (ct(e[n]) && lt(s, e[n]))
@@ -3053,15 +3081,15 @@ function lt(e, t) {
3053
3081
  function E(e, t) {
3054
3082
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
3055
3083
  }
3056
- function dr(e, t) {
3084
+ function pr(e, t) {
3057
3085
  try {
3058
- const s = window.localStorage.getItem(`${_e}${e}`);
3086
+ const s = window.localStorage.getItem(`${Ce}${e}`);
3059
3087
  if (!s)
3060
3088
  return null;
3061
3089
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
3062
3090
  if (t !== void 0 && r !== t)
3063
3091
  return null;
3064
- const i = Array.isArray(n.messages) ? n.messages.map(Sr).filter((o) => !!o) : [];
3092
+ const i = Array.isArray(n.messages) ? n.messages.map(br).filter((o) => !!o) : [];
3065
3093
  return {
3066
3094
  sessionId: r,
3067
3095
  messages: i
@@ -3070,46 +3098,46 @@ function dr(e, t) {
3070
3098
  return null;
3071
3099
  }
3072
3100
  }
3073
- function hr(e, t) {
3101
+ function fr(e, t) {
3074
3102
  try {
3075
3103
  window.localStorage.setItem(
3076
- `${_e}${e}`,
3104
+ `${Ce}${e}`,
3077
3105
  JSON.stringify({
3078
3106
  sessionId: t.sessionId,
3079
- messages: t.messages.slice(-qs).map(Ar)
3107
+ messages: t.messages.slice(-Fs).map(Er)
3080
3108
  })
3081
3109
  );
3082
3110
  } catch {
3083
3111
  return;
3084
3112
  }
3085
3113
  }
3086
- function pr(e) {
3114
+ function gr(e) {
3087
3115
  try {
3088
- const t = window.localStorage.getItem(`${Dt}${e}`);
3116
+ const t = window.localStorage.getItem(`${Ot}${e}`);
3089
3117
  if (!t)
3090
3118
  return [];
3091
3119
  const s = JSON.parse(t);
3092
- return Array.isArray(s) ? s.filter(Kt) : [];
3120
+ return Array.isArray(s) ? s.filter(Gt) : [];
3093
3121
  } catch {
3094
3122
  return [];
3095
3123
  }
3096
3124
  }
3097
3125
  function j(e, t) {
3098
3126
  try {
3099
- const s = t.filter(Kt);
3127
+ const s = t.filter(Gt);
3100
3128
  if (s.length === 0) {
3101
- window.localStorage.removeItem(`${Dt}${e}`);
3129
+ window.localStorage.removeItem(`${Ot}${e}`);
3102
3130
  return;
3103
3131
  }
3104
3132
  window.localStorage.setItem(
3105
- `${Dt}${e}`,
3133
+ `${Ot}${e}`,
3106
3134
  JSON.stringify(s.slice(-25))
3107
3135
  );
3108
3136
  } catch {
3109
3137
  return;
3110
3138
  }
3111
3139
  }
3112
- function Be(e, t) {
3140
+ function Fe(e, t) {
3113
3141
  try {
3114
3142
  const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
3115
3143
  ...o,
@@ -3125,28 +3153,28 @@ function Be(e, t) {
3125
3153
  } catch {
3126
3154
  }
3127
3155
  }
3128
- function fr(e, t) {
3156
+ function mr(e, t) {
3129
3157
  try {
3130
3158
  if (window.sessionStorage.getItem(`${ot}${e}`) === null)
3131
3159
  return;
3132
3160
  } catch {
3133
3161
  return;
3134
3162
  }
3135
- Be(e, t);
3163
+ Fe(e, t);
3136
3164
  }
3137
- function gr(e) {
3165
+ function yr(e) {
3138
3166
  try {
3139
3167
  const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
3140
3168
  if (window.sessionStorage.removeItem(t), !s)
3141
3169
  return [];
3142
3170
  const n = JSON.parse(s);
3143
- return Array.isArray(n) ? n.flatMap((r) => yr(r) ? [{
3171
+ return Array.isArray(n) ? n.flatMap((r) => Tr(r) ? [{
3144
3172
  ...r.event,
3145
3173
  page: k(),
3146
3174
  rawOutput: {
3147
3175
  pageContextRestarted: !0,
3148
3176
  outcome: "unknown",
3149
- message: mr(location.href),
3177
+ message: Ir(location.href),
3150
3178
  currentUrl: location.href,
3151
3179
  console: [],
3152
3180
  metadata: {
@@ -3163,17 +3191,17 @@ function gr(e) {
3163
3191
  return [];
3164
3192
  }
3165
3193
  }
3166
- function mr(e) {
3194
+ function Ir(e) {
3167
3195
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
3168
3196
  Current URL: ${e}`;
3169
3197
  }
3170
- function yr(e) {
3198
+ function Tr(e) {
3171
3199
  if (!e || typeof e != "object")
3172
3200
  return !1;
3173
3201
  const t = e, s = t.event;
3174
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Kt(s) && s.type === "tool.result";
3202
+ 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";
3175
3203
  }
3176
- function Ir(e, t) {
3204
+ function wr(e, t) {
3177
3205
  const s = new Set(
3178
3206
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
3179
3207
  );
@@ -3182,14 +3210,14 @@ function Ir(e, t) {
3182
3210
  ...t.filter((n) => !s.has(n.callId))
3183
3211
  ];
3184
3212
  }
3185
- function Tr(e) {
3213
+ function Sr(e) {
3186
3214
  try {
3187
3215
  window.sessionStorage.removeItem(`${ot}${e}`);
3188
3216
  } catch {
3189
3217
  return;
3190
3218
  }
3191
3219
  }
3192
- function Kt(e) {
3220
+ function Gt(e) {
3193
3221
  if (!e || typeof e != "object")
3194
3222
  return !1;
3195
3223
  const t = e;
@@ -3201,7 +3229,7 @@ function Se(e) {
3201
3229
  const t = e;
3202
3230
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
3203
3231
  }
3204
- function Fe(e, t) {
3232
+ function He(e, t) {
3205
3233
  if (!Array.isArray(e))
3206
3234
  return;
3207
3235
  const s = e.filter((r) => {
@@ -3209,23 +3237,23 @@ function Fe(e, t) {
3209
3237
  return !1;
3210
3238
  const i = r;
3211
3239
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
3212
- }), n = t ? s.map((r) => He(r, t)) : s;
3240
+ }), n = t ? s.map((r) => We(r, t)) : s;
3213
3241
  return n.length > 0 ? n : void 0;
3214
3242
  }
3215
- function He(e, t) {
3243
+ function We(e, t) {
3216
3244
  return e.fileUrl?.startsWith("/") ? {
3217
3245
  ...e,
3218
3246
  fileUrl: new URL(e.fileUrl, t).toString()
3219
3247
  } : e;
3220
3248
  }
3221
3249
  function Ae(e) {
3222
- return e.type || wr(e.name) || "application/octet-stream";
3250
+ return e.type || Ar(e.name) || "application/octet-stream";
3223
3251
  }
3224
- function wr(e) {
3252
+ function Ar(e) {
3225
3253
  const t = e.toLowerCase();
3226
3254
  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;
3227
3255
  }
3228
- function Sr(e) {
3256
+ function br(e) {
3229
3257
  if (!e || typeof e != "object")
3230
3258
  return null;
3231
3259
  const t = e;
@@ -3237,18 +3265,19 @@ function Sr(e) {
3237
3265
  respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
3238
3266
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
3239
3267
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
3268
+ scheduledCheckInAt: typeof t.scheduledCheckInAt == "string" ? t.scheduledCheckInAt : void 0,
3240
3269
  securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
3241
- attachments: Fe(t.attachments)?.map(Gt),
3270
+ attachments: He(t.attachments)?.map(Xt),
3242
3271
  loading: typeof t.loading == "boolean" ? t.loading : void 0
3243
3272
  };
3244
3273
  }
3245
- function Ar(e) {
3274
+ function Er(e) {
3246
3275
  return e.attachments?.length ? {
3247
3276
  ...e,
3248
- attachments: e.attachments.map(Gt)
3277
+ attachments: e.attachments.map(Xt)
3249
3278
  } : e;
3250
3279
  }
3251
- function Gt(e) {
3280
+ function Xt(e) {
3252
3281
  const {
3253
3282
  dataUrl: t,
3254
3283
  objectUrl: s,
@@ -3257,47 +3286,47 @@ function Gt(e) {
3257
3286
  } = e;
3258
3287
  return r;
3259
3288
  }
3260
- function v(e) {
3289
+ function N(e) {
3261
3290
  const t = e.respondsToUserMessageId;
3262
3291
  return typeof t == "string" && t ? t : null;
3263
3292
  }
3264
- function C(e) {
3293
+ function M(e) {
3265
3294
  const t = e.runId;
3266
3295
  return typeof t == "string" && t ? t : null;
3267
3296
  }
3268
- function br(e) {
3297
+ function Rr(e) {
3269
3298
  const t = e?.timeoutMs;
3270
- 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 <= Gs);
3299
+ 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 <= Js);
3271
3300
  }
3272
- function We(e) {
3301
+ function $e(e) {
3273
3302
  const t = {};
3274
3303
  try {
3275
3304
  new Headers(e).forEach((s, n) => {
3276
- Object.keys(t).length < $t && (t[n] = Xt(n, s));
3305
+ Object.keys(t).length < jt && (t[n] = Jt(n, s));
3277
3306
  });
3278
3307
  } catch {
3279
3308
  return {};
3280
3309
  }
3281
3310
  return t;
3282
3311
  }
3283
- function Xt(e, t) {
3284
- return Xe(e) ? ut : P(it(t), xs);
3312
+ function Jt(e, t) {
3313
+ return Je(e) ? ut : P(it(t), qs);
3285
3314
  }
3286
- function Er(e, t) {
3315
+ function kr(e, t) {
3287
3316
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
3288
3317
  }
3289
- async function Rr(e, t, s, n) {
3290
- const r = We(e.headers);
3318
+ async function Mr(e, t, s, n) {
3319
+ const r = $e(e.headers);
3291
3320
  n({
3292
3321
  ...t,
3293
3322
  responseStatus: e.status,
3294
3323
  responseHeaders: r,
3295
- responseBody: await kr(e),
3324
+ responseBody: await _r(e),
3296
3325
  durationMs: Date.now() - s
3297
3326
  });
3298
3327
  }
3299
- async function kr(e) {
3300
- if (!$e(e.headers))
3328
+ async function _r(e) {
3329
+ if (!je(e.headers))
3301
3330
  return;
3302
3331
  let t = null, s = null;
3303
3332
  try {
@@ -3306,7 +3335,7 @@ async function kr(e) {
3306
3335
  const n = new Promise((a) => {
3307
3336
  s = window.setTimeout(() => {
3308
3337
  t?.cancel(), a("timeout");
3309
- }, Ls);
3338
+ }, Bs);
3310
3339
  }), r = new TextDecoder();
3311
3340
  let i = "", o = 0;
3312
3341
  for (; ; ) {
@@ -3316,7 +3345,7 @@ async function kr(e) {
3316
3345
  const { done: c, value: l } = a;
3317
3346
  if (c)
3318
3347
  return P(i + r.decode());
3319
- const h = Wt - o;
3348
+ const h = $t - o;
3320
3349
  if (l.byteLength > h)
3321
3350
  return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
3322
3351
  o += l.byteLength, i += r.decode(l, { stream: !0 });
@@ -3328,8 +3357,8 @@ async function kr(e) {
3328
3357
  s !== null && window.clearTimeout(s);
3329
3358
  }
3330
3359
  }
3331
- function Mr(e, t) {
3332
- if ($e(new Headers(t)))
3360
+ function Cr(e, t) {
3361
+ if (je(new Headers(t)))
3333
3362
  try {
3334
3363
  return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
3335
3364
  } catch {
@@ -3340,8 +3369,8 @@ function be(e) {
3340
3369
  if (typeof e == "string")
3341
3370
  return P(e);
3342
3371
  }
3343
- function _r(e) {
3344
- return M({
3372
+ function Pr(e) {
3373
+ return _({
3345
3374
  ...e,
3346
3375
  requestBody: Ee(e.requestBody),
3347
3376
  responseBody: Ee(e.responseBody)
@@ -3354,19 +3383,19 @@ function Ee(e) {
3354
3383
  if (!t.startsWith("{") && !t.startsWith("["))
3355
3384
  return it(e);
3356
3385
  try {
3357
- return JSON.stringify(M(JSON.parse(e)));
3386
+ return JSON.stringify(_(JSON.parse(e)));
3358
3387
  } catch {
3359
3388
  return it(e);
3360
3389
  }
3361
3390
  }
3362
- function $e(e) {
3391
+ function je(e) {
3363
3392
  if (!e)
3364
3393
  return !1;
3365
3394
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
3366
- return s !== null && Number.isInteger(n) && n >= 0 && n <= Wt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3395
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= $t && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3367
3396
  }
3368
3397
  function x(e, t = {}, s) {
3369
- if (Pr(s))
3398
+ if (Dr(s))
3370
3399
  return !0;
3371
3400
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3372
3401
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3381,7 +3410,7 @@ function x(e, t = {}, s) {
3381
3410
  return !0;
3382
3411
  }
3383
3412
  }
3384
- function Cr(e, t) {
3413
+ function Ur(e, t) {
3385
3414
  if (x(e))
3386
3415
  return !0;
3387
3416
  try {
@@ -3391,26 +3420,26 @@ function Cr(e, t) {
3391
3420
  return !0;
3392
3421
  }
3393
3422
  }
3394
- function Pr(e) {
3423
+ function Dr(e) {
3395
3424
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
3396
3425
  }
3397
- function Ur(e) {
3426
+ function Or(e) {
3398
3427
  const t = {};
3399
3428
  for (const s of e.trim().split(/[\r\n]+/)) {
3400
3429
  const n = s.indexOf(":");
3401
3430
  if (n <= 0)
3402
3431
  continue;
3403
- if (Object.keys(t).length >= $t)
3432
+ if (Object.keys(t).length >= jt)
3404
3433
  break;
3405
3434
  const r = s.slice(0, n).trim();
3406
- t[r] = Xt(r, s.slice(n + 1).trim());
3435
+ t[r] = Jt(r, s.slice(n + 1).trim());
3407
3436
  }
3408
3437
  return t;
3409
3438
  }
3410
- function P(e, t = Wt) {
3439
+ function P(e, t = $t) {
3411
3440
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
3412
3441
  }
3413
- function Ct(e) {
3442
+ function Pt(e) {
3414
3443
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
3415
3444
  }
3416
3445
  class nt extends Error {
@@ -3421,32 +3450,32 @@ class nt extends Error {
3421
3450
  }
3422
3451
  async function tt(e, t) {
3423
3452
  let s = null;
3424
- for (let n = 0; n < ue; n += 1)
3453
+ for (let n = 0; n < de; n += 1)
3425
3454
  try {
3426
3455
  return await e();
3427
3456
  } catch (r) {
3428
- if (s = r, n >= ue - 1 || !Or(r))
3457
+ if (s = r, n >= de - 1 || !vr(r))
3429
3458
  throw r;
3430
- await Dr(n);
3459
+ await Nr(n);
3431
3460
  }
3432
3461
  throw s instanceof Error ? s : new Error(t);
3433
3462
  }
3434
- function Dr(e) {
3463
+ function Nr(e) {
3435
3464
  return new Promise((t) => {
3436
- window.setTimeout(t, vs[e] ?? 0);
3465
+ window.setTimeout(t, Ls[e] ?? 0);
3437
3466
  });
3438
3467
  }
3439
- function Or(e) {
3440
- return e instanceof nt ? Nr(e.status) : e instanceof TypeError;
3468
+ function vr(e) {
3469
+ return e instanceof nt ? xr(e.status) : e instanceof TypeError;
3441
3470
  }
3442
- function Nr(e) {
3471
+ function xr(e) {
3443
3472
  return e === 408 || e === 409 || e === 429 || e >= 500;
3444
3473
  }
3445
- function vr(e) {
3474
+ function Lr(e) {
3446
3475
  return e === 401 || e === 403;
3447
3476
  }
3448
- const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", xr = "[REDACTED_SIGNED_URL]", Lr = 20, qr = /^(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, ze = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ke = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ge = /\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, Br = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Fr = /\bhttps?:\/\/[^\s"'<>]+/gi, Hr = /[),.;\]]+$/;
3449
- function M(e) {
3477
+ const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", qr = "[REDACTED_SIGNED_URL]", Br = 20, Fr = /^(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, Hr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Wr = /\bhttps?:\/\/[^\s"'<>]+/gi, $r = /[),.;\]]+$/;
3478
+ function _(e) {
3450
3479
  return rt(e, 0, /* @__PURE__ */ new WeakSet());
3451
3480
  }
3452
3481
  function rt(e, t, s) {
@@ -3454,7 +3483,7 @@ function rt(e, t, s) {
3454
3483
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
3455
3484
  if (e === null || typeof e != "object")
3456
3485
  return e;
3457
- if (t >= Lr)
3486
+ if (t >= Br)
3458
3487
  return "[REDACTED_MAX_DEPTH]";
3459
3488
  if (s.has(e))
3460
3489
  return "[REDACTED_CIRCULAR]";
@@ -3462,44 +3491,44 @@ function rt(e, t, s) {
3462
3491
  return e.map((r) => rt(r, t + 1, s));
3463
3492
  const n = {};
3464
3493
  for (const [r, i] of Object.entries(e))
3465
- r === "pageContent" ? n[r] = i : Xe(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Wr(i) : rt(i, t + 1, s);
3494
+ r === "pageContent" ? n[r] = i : Je(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? jr(i) : rt(i, t + 1, s);
3466
3495
  return n;
3467
3496
  }
3468
- function Xe(e) {
3497
+ function Je(e) {
3469
3498
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
3470
3499
  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");
3471
3500
  }
3472
- function Wr(e) {
3473
- return typeof e == "string" ? Je(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3501
+ function jr(e) {
3502
+ return typeof e == "string" ? Ve(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3474
3503
  }
3475
- function Je(e) {
3504
+ function Ve(e) {
3476
3505
  try {
3477
3506
  const t = new URL(e, location.href);
3478
3507
  for (const s of Array.from(t.searchParams.keys()))
3479
- qr.test(s) && t.searchParams.set(s, U);
3508
+ Fr.test(s) && t.searchParams.set(s, U);
3480
3509
  return t.username && (t.username = U), t.password && (t.password = U), t.toString();
3481
3510
  } catch {
3482
- return $r(e);
3511
+ return zr(e);
3483
3512
  }
3484
3513
  }
3485
3514
  function it(e) {
3486
- return e.replace(Br, xr).replace(Fr, jr).replace(je, `Bearer ${U}`).replace(ze, `Basic ${U}`).replace(Ke, U).replace(Ge, (t, s) => `${s}: ${ut}`);
3515
+ return e.replace(Hr, qr).replace(Wr, Kr).replace(ze, `Bearer ${U}`).replace(Ke, `Basic ${U}`).replace(Ge, U).replace(Xe, (t, s) => `${s}: ${ut}`);
3487
3516
  }
3488
- function $r(e) {
3489
- return e.replace(je, `Bearer ${U}`).replace(ze, `Basic ${U}`).replace(Ke, U).replace(Ge, (t, s) => `${s}: ${ut}`);
3517
+ function zr(e) {
3518
+ return e.replace(ze, `Bearer ${U}`).replace(Ke, `Basic ${U}`).replace(Ge, U).replace(Xe, (t, s) => `${s}: ${ut}`);
3490
3519
  }
3491
- function jr(e) {
3492
- const t = e.match(Hr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3493
- return `${Je(s)}${t}`;
3520
+ function Kr(e) {
3521
+ const t = e.match($r)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3522
+ return `${Ve(s)}${t}`;
3494
3523
  }
3495
3524
  export {
3496
- re as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3497
- Ut as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3498
- Ts as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3499
- Is as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3500
- ws as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3501
- Ce as PlunoProductAgent,
3502
- Fs as calculateReconnectDelay,
3503
- Ce as default,
3504
- dn as getProductAgentOriginAccessErrorMessage
3525
+ ie as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3526
+ Dt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3527
+ Ss as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3528
+ ws as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3529
+ As as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3530
+ Pe as PlunoProductAgent,
3531
+ Ws as calculateReconnectDelay,
3532
+ Pe as default,
3533
+ pn as getProductAgentOriginAccessErrorMessage
3505
3534
  };