@pluno/product-agent-web 0.1.142 → 0.1.144

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 Ke = "pluno-product-agent-attachments";
2
- const _t = "files";
3
- async function Je(e) {
4
- const t = await Lt();
5
- await Ze(t, "readwrite", (s) => s.put(e));
6
- }
7
- async function Ve(e, t) {
8
- const s = await Lt();
9
- await qt(s, "readwrite", async (n) => {
10
- const r = await Bt(
1
+ const Ve = "pluno-product-agent-attachments";
2
+ const Ct = "files";
3
+ async function Ye(e) {
4
+ const t = await qt();
5
+ await ts(t, "readwrite", (s) => s.put(e));
6
+ }
7
+ async function Ze(e, t) {
8
+ const s = await qt();
9
+ await Bt(s, "readwrite", async (n) => {
10
+ const r = await Ht(
11
11
  n.get(e)
12
12
  );
13
13
  r && n.put({
@@ -16,28 +16,28 @@ async function Ve(e, t) {
16
16
  });
17
17
  });
18
18
  }
19
- async function Ye(e = 864e5) {
20
- const t = await Lt(), s = Date.now() - e;
21
- await qt(t, "readwrite", async (n) => {
19
+ async function Qe(e = 864e5) {
20
+ const t = await qt(), s = Date.now() - e;
21
+ await Bt(t, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Bt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await Ht(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function Lt() {
26
+ function qt() {
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(Ke, 1);
28
+ const s = indexedDB.open(Ve, 1);
29
29
  s.onupgradeneeded = () => {
30
- const r = s.result.createObjectStore(_t, { keyPath: "attachmentId" });
30
+ const r = s.result.createObjectStore(Ct, { 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 Ze(e, t, s) {
36
- return await qt(e, t, async (n) => await Bt(s(n)));
35
+ async function ts(e, t, s) {
36
+ return await Bt(e, t, async (n) => await Ht(s(n)));
37
37
  }
38
- function qt(e, t, s) {
38
+ function Bt(e, t, s) {
39
39
  return new Promise((n, r) => {
40
- const i = e.transaction(_t, t), o = i.objectStore(_t);
40
+ const i = e.transaction(Ct, t), o = i.objectStore(Ct);
41
41
  let a, c = !1;
42
42
  s(o).then((l) => {
43
43
  a = l;
@@ -57,16 +57,16 @@ function qt(e, t, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Bt(e) {
60
+ function Ht(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 Qe(e) {
65
+ function es(e) {
66
66
  return e !== null && (typeof e == "object" || typeof e == "function");
67
67
  }
68
- function Ae(e, t, s) {
69
- const n = Reflect.get(e, "pluno"), r = Qe(n) ? n : {};
68
+ function Re(e, t, s) {
69
+ const n = Reflect.get(e, "pluno"), r = es(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,17 +80,17 @@ function Ae(e, t, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const ts = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function es(e, t) {
83
+ const ss = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function ns(e, t) {
85
85
  return t ? e.replace(
86
- ts,
86
+ ss,
87
87
  (s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
88
88
  ) : e;
89
89
  }
90
- const St = "pluno.productAgent.transportId", ss = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", ns = 50, rs = globalThis.setTimeout.bind(globalThis);
90
+ const St = "pluno.productAgent.transportId", rs = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", is = 50, os = globalThis.setTimeout.bind(globalThis);
91
91
  let W = null;
92
92
  const et = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Map();
93
- async function is(e = Ee()) {
93
+ async function as(e = be()) {
94
94
  const t = e.randomUUID(), s = e.storage.getItem(St);
95
95
  let n = s ?? e.randomUUID(), r = !1, i = !1;
96
96
  const o = e.channel.subscribe((c) => {
@@ -126,14 +126,14 @@ async function is(e = Ee()) {
126
126
  }
127
127
  };
128
128
  }
129
- async function os() {
130
- W || (W = is(Ee()), W.then((n) => {
129
+ async function cs() {
130
+ W || (W = as(be()), W.then((n) => {
131
131
  const r = (i) => {
132
132
  i.persisted || (n.release(), W = null, et.clear(), window.removeEventListener("pagehide", r));
133
133
  };
134
134
  window.addEventListener("pagehide", r);
135
135
  }));
136
- const e = await W, t = as();
136
+ const e = await W, t = ls();
137
137
  et.add(t);
138
138
  let s = !1;
139
139
  return {
@@ -144,21 +144,21 @@ async function os() {
144
144
  }
145
145
  };
146
146
  }
147
- function as() {
147
+ function ls() {
148
148
  let e = 0;
149
149
  for (; et.has(e); )
150
150
  e += 1;
151
151
  return e;
152
152
  }
153
- function Ee() {
153
+ function be() {
154
154
  return {
155
- storage: cs(),
156
- channel: ls(),
155
+ storage: us(),
156
+ channel: ds(),
157
157
  randomUUID: () => crypto.randomUUID(),
158
- settle: () => new Promise((e) => rs(e, ns))
158
+ settle: () => new Promise((e) => os(e, is))
159
159
  };
160
160
  }
161
- function cs() {
161
+ function us() {
162
162
  return {
163
163
  getItem: (e) => {
164
164
  try {
@@ -176,9 +176,9 @@ function cs() {
176
176
  }
177
177
  };
178
178
  }
179
- function ls() {
179
+ function ds() {
180
180
  if (typeof BroadcastChannel < "u") {
181
- const e = new BroadcastChannel(ss);
181
+ const e = new BroadcastChannel(rs);
182
182
  return {
183
183
  postMessage: (t) => e.postMessage(t),
184
184
  subscribe: (t) => {
@@ -188,9 +188,9 @@ function ls() {
188
188
  close: () => e.close()
189
189
  };
190
190
  }
191
- return us();
191
+ return hs();
192
192
  }
193
- function us() {
193
+ function hs() {
194
194
  const e = /* @__PURE__ */ new Set(), t = (s) => {
195
195
  if (s.key !== At || !s.newValue)
196
196
  return;
@@ -211,18 +211,50 @@ function us() {
211
211
  }
212
212
  };
213
213
  }
214
- const ds = globalThis.fetch.bind(globalThis), Ct = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', hs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ps = ".pluno-pa-widget__panel", fs = ".pluno-pa-widget__timeline", se = `${Ct}[data-pluno-sdk-preview-channel]`, gs = "https://app.pluno.ai", ms = "gpt-5.6-terra", ys = 2e4, Is = 1e4, Ts = 1e4, ws = 1e4, Ss = 1e4, As = 1e3, ne = 3e4, re = 0.2, ie = 6e4, Es = 15e3, V = 8, Rs = 15e3, bs = 2e3, Ms = 1e3, ks = 100, oe = 8e3, ae = 3, _s = [300, 1e3], Ht = 64e3, Rt = 4e3, Ft = 30, Cs = 2e3, Ps = 1e3, Re = "Image is too large for model vision input.", Us = 100, be = "pluno.productAgent.state.", Pt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Ds = 100;
214
+ const ps = globalThis.fetch.bind(globalThis), Pt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', fs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', gs = ".pluno-pa-widget__panel", ms = ".pluno-pa-widget__timeline", ne = `${Pt}[data-pluno-sdk-preview-channel]`;
215
+ let ys = 0;
216
+ function re(e) {
217
+ const t = {};
218
+ for (const r of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason"]) {
219
+ const i = e[r];
220
+ (typeof i == "string" || typeof i == "number" || typeof i == "boolean" || i === null) && (t[r] = i);
221
+ }
222
+ const s = e.content;
223
+ typeof s == "string" && (t.contentLength = s.length);
224
+ const n = e.attachments;
225
+ return Array.isArray(n) && (t.attachmentCount = n.length), t;
226
+ }
227
+ function Rt(e, t, s) {
228
+ if (typeof window > "u")
229
+ return;
230
+ const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
231
+ if (!n)
232
+ return;
233
+ const r = {
234
+ schemaVersion: 1,
235
+ traceId: n,
236
+ source: "web_sdk",
237
+ category: e,
238
+ name: t,
239
+ sequence: ++ys,
240
+ wallTime: (/* @__PURE__ */ new Date()).toISOString(),
241
+ monotonicMs: performance.now(),
242
+ data: s
243
+ };
244
+ window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
245
+ }
246
+ const Is = "https://app.pluno.ai", Ts = "gpt-5.6-terra", ws = 2e4, Ss = 1e4, As = 1e4, Es = 1e4, Rs = 1e4, bs = 1e3, ie = 3e4, oe = 0.2, ae = 6e4, Ms = 15e3, V = 8, ks = 15e3, _s = 2e3, Cs = 1e3, Ps = 100, ce = 8e3, le = 3, Us = [300, 1e3], Ft = 64e3, bt = 4e3, Wt = 30, Ds = 2e3, Ns = 1e3, Me = "Image is too large for model vision input.", xs = 100, ke = "pluno.productAgent.state.", Ut = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Os = 100;
215
247
  function Y(e, t = 0) {
216
248
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
217
249
  return Math.max(t, s);
218
250
  }
219
251
  const st = /* @__PURE__ */ new Set();
220
252
  let Z = null;
221
- function xs(e, t = Math.random) {
222
- const s = Math.min(ne, As * 2 ** e), n = 1 - re + t() * re * 2;
223
- return Math.min(ne, Math.round(s * n));
253
+ function vs(e, t = Math.random) {
254
+ const s = Math.min(ie, bs * 2 ** e), n = 1 - oe + t() * oe * 2;
255
+ return Math.min(ie, Math.round(s * n));
224
256
  }
225
- function Ns(e, t, s) {
257
+ function Ls(e, t, s) {
226
258
  return new Promise((n, r) => {
227
259
  const i = setTimeout(() => r(new Error(s)), t);
228
260
  e.then(
@@ -235,13 +267,13 @@ function Ns(e, t, s) {
235
267
  );
236
268
  });
237
269
  }
238
- class Me {
270
+ class _e {
239
271
  constructor(t, s) {
240
272
  this.options = t, this.transportIdentity = s, this.state = {
241
273
  ...this.state,
242
- starterPrompts: gn(t.initialStarterPrompts)
274
+ starterPrompts: In(t.initialStarterPrompts)
243
275
  };
244
- const n = t.restorePersistedState === !1 ? null : nr(t.clientId, t.expectedPersistedSessionId);
276
+ const n = t.restorePersistedState === !1 ? null : or(t.clientId, t.expectedPersistedSessionId);
245
277
  n && (this.state = {
246
278
  ...this.state,
247
279
  ...n,
@@ -254,9 +286,9 @@ class Me {
254
286
  assistantDraftRunId: null,
255
287
  isThinking: !1,
256
288
  lastError: null
257
- }), this.queuedClientEvents = ur(
258
- ir(t.clientId),
259
- ar(t.clientId)
289
+ }), this.queuedClientEvents = pr(
290
+ cr(t.clientId),
291
+ ur(t.clientId)
260
292
  ), j(t.clientId, this.queuedClientEvents);
261
293
  }
262
294
  options;
@@ -328,15 +360,15 @@ class Me {
328
360
  lastErrorSecuritySettingsUrl: null
329
361
  };
330
362
  static async init(t) {
331
- const s = await os(), n = new Me({
363
+ const s = await cs(), n = new _e({
332
364
  ...t,
333
- backendUrl: Qs(t.backendUrl ?? gs),
334
- clientId: t.clientId ?? wn(),
335
- model: t.model ?? ms,
336
- entrySurface: tn(t.entrySurface)
365
+ backendUrl: sn(t.backendUrl ?? Is),
366
+ clientId: t.clientId ?? En(),
367
+ model: t.model ?? Ts,
368
+ entrySurface: nn(t.entrySurface)
337
369
  }, s);
338
370
  try {
339
- Ye().catch((r) => {
371
+ Qe().catch((r) => {
340
372
  S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
341
373
  message: r instanceof Error ? r.message : String(r)
342
374
  });
@@ -367,14 +399,14 @@ class Me {
367
399
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
368
400
  );
369
401
  try {
370
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ns(this.options.tokenProvider(), Ts, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
402
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ls(this.options.tokenProvider(), As, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
371
403
  return;
372
404
  if (!this.token && !this.options.webSocketFactory)
373
405
  throw new Error("Pluno requires a token or tokenProvider");
374
- const s = nn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
406
+ const s = an(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
375
407
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
376
408
  this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
377
- }, ws), n.addEventListener("open", () => {
409
+ }, Es), n.addEventListener("open", () => {
378
410
  this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
379
411
  queuedClientEventCount: this.queuedClientEvents.length,
380
412
  isThinking: this.state.isThinking
@@ -386,9 +418,9 @@ class Me {
386
418
  pageUrl: location.href
387
419
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
388
420
  this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
389
- }, Ss));
421
+ }, Rs));
390
422
  }), n.addEventListener("message", (r) => {
391
- this.socket === n && this.handleServerEvent(fn(r.data));
423
+ this.socket === n && this.handleServerEvent(yn(r.data));
392
424
  }), n.addEventListener("close", (r) => {
393
425
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
394
426
  code: typeof r?.code == "number" ? r.code : null,
@@ -421,7 +453,7 @@ class Me {
421
453
  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;
422
454
  }
423
455
  destroy() {
424
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), dr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
456
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), fr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
425
457
  for (const t of Object.values(this.listeners))
426
458
  t?.clear();
427
459
  }
@@ -430,13 +462,14 @@ class Me {
430
462
  type: "runtime.warmup",
431
463
  reason: t,
432
464
  entrySurface: this.options.entrySurface,
465
+ sessionId: this.state.sessionId ?? void 0,
433
466
  page: b()
434
467
  };
435
468
  this.sendNow(s) || (this.pendingWarmupEvent = s);
436
469
  }
437
470
  async sendMessage(t, s = {}) {
438
471
  const n = t.trim(), r = s.attachments ?? [];
439
- let i = r.map(zt);
472
+ let i = r.map(Gt);
440
473
  if (!n && i.length === 0)
441
474
  return null;
442
475
  const o = b(), a = s.clientMessageId ?? $(), c = {
@@ -490,14 +523,14 @@ class Me {
490
523
  sessionId: this.state.sessionId ?? void 0,
491
524
  clientMessageId: a,
492
525
  initiatedBy: s.initiatedBy,
493
- invocation: en(s.invocation ?? s.initiatedBy),
526
+ invocation: rn(s.invocation ?? s.initiatedBy),
494
527
  entrySurface: this.options.entrySurface,
495
528
  content: n,
496
- pageContent: d && Wt() || void 0,
529
+ pageContent: d && $t() || void 0,
497
530
  attachments: i.length > 0 ? i : void 0,
498
531
  page: o,
499
532
  model: this.options.model,
500
- metadata: ce(this.options.metadata)
533
+ metadata: ue(this.options.metadata)
501
534
  };
502
535
  return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = f, this.markThinkingProgress(), this.send(f), a;
503
536
  }
@@ -509,12 +542,12 @@ class Me {
509
542
  const s = $(), n = {
510
543
  id: s,
511
544
  name: t.name || "attachment",
512
- mimeType: Te(t),
545
+ mimeType: Se(t),
513
546
  sizeBytes: t.size
514
547
  };
515
548
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
516
549
  const r = Date.now();
517
- return Je({
550
+ return Ye({
518
551
  attachmentId: s,
519
552
  name: n.name,
520
553
  mimeType: n.mimeType,
@@ -543,7 +576,7 @@ class Me {
543
576
  file: t,
544
577
  attachment: s
545
578
  }) {
546
- const n = this.state.sessionId, r = Te(t), i = {
579
+ const n = this.state.sessionId, r = Se(t), i = {
547
580
  sessionId: n ?? void 0,
548
581
  attachmentId: s.id,
549
582
  clientId: this.options.clientId,
@@ -553,7 +586,7 @@ class Me {
553
586
  sizeBytes: t.size,
554
587
  page: b(),
555
588
  model: this.options.model,
556
- metadata: ce(this.options.metadata),
589
+ metadata: ue(this.options.metadata),
557
590
  entrySurface: this.options.entrySurface
558
591
  };
559
592
  let o;
@@ -579,8 +612,8 @@ class Me {
579
612
  }, "Failed to upload attachment"), o = c;
580
613
  }
581
614
  this.setState({ sessionId: o.sessionId });
582
- const a = Le(o.attachment, this.options.backendUrl);
583
- return this.updateAttachmentInState(s.id, a), s.id && Ve(s.id, {
615
+ const a = Be(o.attachment, this.options.backendUrl);
616
+ return this.updateAttachmentInState(s.id, a), s.id && Ze(s.id, {
584
617
  sessionId: o.sessionId,
585
618
  fileUrl: a.fileUrl,
586
619
  sandboxPath: a.sandboxPath,
@@ -610,7 +643,7 @@ class Me {
610
643
  const n = await this.fetchEmbedAttachmentUpload(t);
611
644
  if (n.ok)
612
645
  return await n.json();
613
- if (kr(n.status) && this.options.tokenProvider && !s) {
646
+ if (Pr(n.status) && this.options.tokenProvider && !s) {
614
647
  s = !0;
615
648
  const r = await this.fetchEmbedAttachmentUpload(t);
616
649
  if (r.ok)
@@ -657,7 +690,7 @@ class Me {
657
690
  const s = $(), n = new Promise((i, o) => {
658
691
  const a = window.setTimeout(() => {
659
692
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
660
- }, oe);
693
+ }, ce);
661
694
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
662
695
  }), r = {
663
696
  type: "sessions.list",
@@ -718,7 +751,7 @@ class Me {
718
751
  return !1;
719
752
  const s = this.socket;
720
753
  try {
721
- return s.send(JSON.stringify(t)), !0;
754
+ return s.send(JSON.stringify(t)), Rt("client_event", t.type, re(t)), !0;
722
755
  } catch (n) {
723
756
  return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
724
757
  message: n instanceof Error ? n.message : String(n),
@@ -731,7 +764,7 @@ class Me {
731
764
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
732
765
  return;
733
766
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
734
- const t = rn();
767
+ const t = cn();
735
768
  this.sendNow(
736
769
  M({
737
770
  type: "starter_prompts.page_context",
@@ -742,13 +775,13 @@ class Me {
742
775
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
743
776
  }
744
777
  startStarterPromptUrlWatcher() {
745
- this.locationChangeCleanup || (this.locationChangeCleanup = on(() => this.handleStarterPromptUrlChange()));
778
+ this.locationChangeCleanup || (this.locationChangeCleanup = ln(() => this.handleStarterPromptUrlChange()));
746
779
  }
747
780
  handleStarterPromptUrlChange() {
748
781
  const t = location.href;
749
782
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
750
783
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
751
- }, Ds));
784
+ }, Os));
752
785
  }
753
786
  refreshStarterPromptsForCurrentUrl() {
754
787
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -777,7 +810,7 @@ class Me {
777
810
  !this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
778
811
  }
779
812
  handleServerEvent(t) {
780
- if (t.type === "run.steered") {
813
+ if (Rt("server_event", t.type, re(t)), t.type === "run.steered") {
781
814
  this.handleRunSteered(t);
782
815
  return;
783
816
  }
@@ -789,20 +822,20 @@ class Me {
789
822
  this.clearHeartbeatAckTimer();
790
823
  return;
791
824
  }
792
- if (Ls(t) && this.markThinkingProgress(), t.type === "auth.ok") {
825
+ if (Hs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
793
826
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
794
- const s = mn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
827
+ const s = Tn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
795
828
  S("web-sdk.agent", "Received auth.ok appearance", {
796
829
  hasAppearance: n,
797
830
  rawAppearance: t.appearance,
798
831
  normalizedAppearance: s
799
- }), this.runtimeHelperJavascript = yn(t.runtimeHelpers)?.javascript ?? null;
800
- const r = de(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
801
- user: Sn(t.user),
832
+ }), this.runtimeHelperJavascript = wn(t.runtimeHelpers)?.javascript ?? null;
833
+ const r = pe(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
834
+ user: Rn(t.user),
802
835
  status: "connected",
803
836
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
804
837
  };
805
- (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 && !cn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
838
+ (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 && !dn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
806
839
  type: "page.upsert",
807
840
  sessionId: this.state.sessionId,
808
841
  page: b(),
@@ -812,19 +845,19 @@ class Me {
812
845
  }
813
846
  if (t.type === "starterPrompts.updated") {
814
847
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
815
- starterPrompts: de(t, "starterPrompts"),
848
+ starterPrompts: pe(t, "starterPrompts"),
816
849
  starterPromptsLoading: !1
817
850
  });
818
851
  return;
819
852
  }
820
853
  if (t.type === "conversation.state") {
821
- const s = Array.isArray(t.items) ? t.items : [], n = Cn(
854
+ const s = Array.isArray(t.items) ? t.items : [], n = Dn(
822
855
  t.assistantDraft
823
856
  ), r = n !== void 0;
824
857
  this.rememberUserMessageClientMessageIds(s);
825
- const i = zn(s);
858
+ const i = Kn(s);
826
859
  if (i) {
827
- const h = Gn(s, i);
860
+ const h = Jn(s, i);
828
861
  this.retryAttemptsByClientMessageId[i] = Math.max(
829
862
  this.retryAttemptsByClientMessageId[i] ?? 0,
830
863
  h
@@ -832,23 +865,23 @@ class Me {
832
865
  }
833
866
  const o = s.filter((h) => {
834
867
  const y = q(h);
835
- return !fe(y) && (!i || !Nt(y));
836
- }), a = Ln(
868
+ return !me(y) && (!i || !Ot(y));
869
+ }), a = Hn(
837
870
  this.state.messages,
838
- An(o, this.options.backendUrl)
839
- ), c = pe(a), l = !r && s.some(
840
- (h) => me(
871
+ bn(o, this.options.backendUrl)
872
+ ), c = ge(a), l = !r && s.some(
873
+ (h) => Ie(
841
874
  q(h),
842
875
  this.state.assistantDraft,
843
876
  this.state.assistantDraftItemId,
844
877
  this.state.assistantDraftRespondsToUserMessageId,
845
878
  this.state.assistantDraftRunId
846
879
  )
847
- ), u = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, I = c && (!u || l), m = Wn(a), d = I && m;
848
- if (!c && jn(this.state.messages, s))
880
+ ), u = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, I = c && (!u || l), m = zn(a), d = I && m;
881
+ if (!c && Xn(this.state.messages, s))
849
882
  return;
850
- this.lastUserMessagePageUrl = $n(s);
851
- const f = I ? null : Ot(s);
883
+ this.lastUserMessagePageUrl = Gn(s);
884
+ const f = I ? null : vt(s);
852
885
  if (this.latestRecoverableClientMessageId = f, m && this.clearRetryTimers(), this.setState({
853
886
  sessionId: E(t.session, "id") ?? this.state.sessionId,
854
887
  messages: a,
@@ -889,7 +922,7 @@ class Me {
889
922
  if (t.type === "sessions.page") {
890
923
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
891
924
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
892
- sessions: En(t.sessions),
925
+ sessions: Mn(t.sessions),
893
926
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
894
927
  }));
895
928
  return;
@@ -909,7 +942,7 @@ class Me {
909
942
  if (t.type === "session.item") {
910
943
  this.rememberUserMessageClientMessageIds([t.item]);
911
944
  const s = q(t.item);
912
- if (Nt(s)) {
945
+ if (Ot(s)) {
913
946
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
914
947
  const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
915
948
  if (r && a) {
@@ -921,21 +954,21 @@ class Me {
921
954
  return;
922
955
  }
923
956
  }
924
- if (fe(s))
957
+ if (me(s))
925
958
  return;
926
- const n = Ue(t.item, this.options.backendUrl);
959
+ const n = Ne(t.item, this.options.backendUrl);
927
960
  if (n) {
928
961
  const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
929
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
962
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), x(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
930
963
  const i = t.item.data;
931
- Kn(i) && this.clearRunAckResyncRetryTimer();
932
- const o = Ut(this.state.messages, n), a = pe(o), c = me(
964
+ Yn(i) && this.clearRunAckResyncRetryTimer();
965
+ const o = Dt(this.state.messages, n), a = ge(o), c = Ie(
933
966
  i,
934
967
  this.state.assistantDraft,
935
968
  this.state.assistantDraftItemId,
936
969
  this.state.assistantDraftRespondsToUserMessageId,
937
970
  this.state.assistantDraftRunId
938
- ), l = a && (!this.state.assistantDraft || c), u = l && N(n);
971
+ ), l = a && (!this.state.assistantDraft || c), u = l && x(n);
939
972
  this.setState({
940
973
  messages: o,
941
974
  ...c ? {
@@ -962,7 +995,7 @@ class Me {
962
995
  this.clearRunAckResyncRetryTimer();
963
996
  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((p) => p.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, u = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
964
997
  this.setState({
965
- messages: Ut(this.state.messages, {
998
+ messages: Dt(this.state.messages, {
966
999
  id: o,
967
1000
  role: "assistant",
968
1001
  content: i,
@@ -992,7 +1025,7 @@ class Me {
992
1025
  this.setState({
993
1026
  sessionId: s,
994
1027
  messages: this.state.messages.filter(
995
- (c) => c.dataType !== "assistant_draft" || !Dn(
1028
+ (c) => c.dataType !== "assistant_draft" || !On(
996
1029
  c,
997
1030
  n,
998
1031
  r
@@ -1013,9 +1046,9 @@ class Me {
1013
1046
  if (s)
1014
1047
  this.nonTranscriptToolCallIds.add(s);
1015
1048
  else {
1016
- const n = On(t);
1049
+ const n = qn(t);
1017
1050
  if (n) {
1018
- const r = xn(
1051
+ const r = vn(
1019
1052
  this.state.messages,
1020
1053
  n
1021
1054
  );
@@ -1059,7 +1092,7 @@ class Me {
1059
1092
  return;
1060
1093
  }
1061
1094
  o && r && i && (this.retryableClientMessageId = i);
1062
- const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = sn(a.message);
1095
+ const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = on(a.message);
1063
1096
  c && console.error(c), this.setState({
1064
1097
  status: "error",
1065
1098
  isThinking: !1,
@@ -1137,7 +1170,7 @@ class Me {
1137
1170
  const r = new Promise((i, o) => {
1138
1171
  const a = window.setTimeout(() => {
1139
1172
  t.delete(s.requestId), o(new Error(n));
1140
- }, oe);
1173
+ }, ce);
1141
1174
  t.set(s.requestId, { resolve: i, reject: o, timeout: a });
1142
1175
  });
1143
1176
  if (!this.sendNow(s)) {
@@ -1160,7 +1193,7 @@ class Me {
1160
1193
  t.clear();
1161
1194
  }
1162
1195
  markThinkingProgress() {
1163
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ie), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1196
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ae), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1164
1197
  }
1165
1198
  scheduleThinkingWatchdog(t) {
1166
1199
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1180,7 +1213,7 @@ class Me {
1180
1213
  handleRunSteered(t) {
1181
1214
  const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
1182
1215
  !this.state.isThinking || !s || this.setState({
1183
- messages: Vn(
1216
+ messages: Qn(
1184
1217
  this.state.messages,
1185
1218
  s
1186
1219
  )
@@ -1189,7 +1222,7 @@ class Me {
1189
1222
  scheduleRunAckWatchdog(t) {
1190
1223
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1191
1224
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1192
- }, Rs);
1225
+ }, ks);
1193
1226
  }
1194
1227
  recoverMissedRunAck(t) {
1195
1228
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
@@ -1213,8 +1246,8 @@ class Me {
1213
1246
  sessionId: this.state.sessionId,
1214
1247
  clientMessageId: t,
1215
1248
  automatic: !0
1216
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ie)));
1217
- }, Y(s, bs)));
1249
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ae)));
1250
+ }, Y(s, _s)));
1218
1251
  }
1219
1252
  clearRunAckResyncRetryTimer() {
1220
1253
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1253,7 +1286,7 @@ class Me {
1253
1286
  sessionId: this.state.sessionId,
1254
1287
  clientMessageId: t,
1255
1288
  resyncAttempts: s + 1
1256
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Es);
1289
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ms);
1257
1290
  return;
1258
1291
  }
1259
1292
  this.setState({
@@ -1288,7 +1321,7 @@ class Me {
1288
1321
  if (!s || !n || !r)
1289
1322
  return;
1290
1323
  const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1291
- if (!a && !c || !gr(o)) {
1324
+ if (!a && !c || !Ir(o)) {
1292
1325
  this.setToolMessageLoading(n, !1), this.send({
1293
1326
  type: "tool.result",
1294
1327
  sessionId: s,
@@ -1320,7 +1353,7 @@ class Me {
1320
1353
  });
1321
1354
  return;
1322
1355
  }
1323
- const l = Hs(this.state.messages);
1356
+ const l = $s(this.state.messages);
1324
1357
  this.activeBrowserToolCalls.set(n, {
1325
1358
  event: {
1326
1359
  type: "tool.result",
@@ -1336,9 +1369,9 @@ class Me {
1336
1369
  startedAtOrigin: location.origin
1337
1370
  }), this.installSessionUserFilesApi(l);
1338
1371
  let u = null, p;
1339
- u = await this.executeRuntimeHelper(), p = await le(
1372
+ u = await this.executeRuntimeHelper(), p = await de(
1340
1373
  o,
1341
- Ys(t.runtimeContext, this.options.backendUrl)
1374
+ tn(t.runtimeContext, this.options.backendUrl)
1342
1375
  ).catch((I) => ({
1343
1376
  ok: !1,
1344
1377
  exception: {
@@ -1351,11 +1384,11 @@ class Me {
1351
1384
  toolName: r,
1352
1385
  summary: o.summary,
1353
1386
  rawInput: M(o),
1354
- rawOutput: M(In(p, u))
1355
- }), or(this.options.clientId, this.activeBrowserToolCalls.values());
1387
+ rawOutput: M(Sn(p, u))
1388
+ }), lr(this.options.clientId, this.activeBrowserToolCalls.values());
1356
1389
  }
1357
1390
  setToolMessageLoading(t, s) {
1358
- const n = Nn(
1391
+ const n = Ln(
1359
1392
  this.state.messages,
1360
1393
  t,
1361
1394
  s
@@ -1366,33 +1399,33 @@ class Me {
1366
1399
  if (this.pageLifecycleCleanup)
1367
1400
  return;
1368
1401
  const t = () => {
1369
- Oe(this.options.clientId, this.activeBrowserToolCalls.values());
1402
+ Le(this.options.clientId, this.activeBrowserToolCalls.values());
1370
1403
  };
1371
1404
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1372
1405
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1373
1406
  };
1374
1407
  }
1375
1408
  installSessionUserFilesApi(t) {
1376
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Fs(t, this.attachmentFiles, this.attachmentBlobCache);
1409
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = js(t, this.attachmentFiles, this.attachmentBlobCache);
1377
1410
  }
1378
1411
  cleanupSessionUserFilesApi() {
1379
- this.sessionUserFilesApiCleanup && (Js(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1412
+ this.sessionUserFilesApiCleanup && (Zs(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1380
1413
  }
1381
1414
  async executeRuntimeHelper() {
1382
1415
  if (!this.runtimeHelperJavascript?.trim())
1383
1416
  return null;
1384
- const t = await le({
1417
+ const t = await de({
1385
1418
  javascript: this.runtimeHelperJavascript
1386
1419
  });
1387
- return t.ok === !1 ? Tn(t) : null;
1420
+ return t.ok === !1 ? An(t) : null;
1388
1421
  }
1389
1422
  enableNetworkCapture() {
1390
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Os((t) => {
1391
- Sr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1423
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = qs((t) => {
1424
+ Rr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1392
1425
  }));
1393
1426
  }
1394
1427
  enqueueNetworkEvent(t) {
1395
- this.queuedNetworkEvents.length >= ks || (this.queuedNetworkEvents.push(wr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1428
+ this.queuedNetworkEvents.length >= Ps || (this.queuedNetworkEvents.push(Er(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1396
1429
  this.networkBatchTimer = null;
1397
1430
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1398
1431
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1401,12 +1434,12 @@ class Me {
1401
1434
  page: b(),
1402
1435
  events: s
1403
1436
  });
1404
- }, Ms)));
1437
+ }, Cs)));
1405
1438
  }
1406
1439
  scheduleReconnect() {
1407
1440
  if (this.reconnectTimer !== null || this.state.status === "closed")
1408
1441
  return;
1409
- const t = xs(this.reconnectAttempts);
1442
+ const t = vs(this.reconnectAttempts);
1410
1443
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1411
1444
  this.reconnectTimer = null, this.connect().catch((s) => {
1412
1445
  S("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1422,8 +1455,8 @@ class Me {
1422
1455
  const t = this.socket;
1423
1456
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1424
1457
  this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1425
- }, Is));
1426
- }, ys);
1458
+ }, Ss));
1459
+ }, ws);
1427
1460
  }
1428
1461
  stopHeartbeat() {
1429
1462
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1449,7 +1482,14 @@ class Me {
1449
1482
  ...t,
1450
1483
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1451
1484
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1452
- }, rr(this.options.clientId, this.state), this.emit("state", this.getState());
1485
+ }, ar(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
1486
+ status: this.state.status,
1487
+ sessionId: this.state.sessionId,
1488
+ messageCount: this.state.messages.length,
1489
+ assistantDraftLength: this.state.assistantDraft.length,
1490
+ isThinking: this.state.isThinking,
1491
+ hasError: this.state.lastError !== null
1492
+ });
1453
1493
  }
1454
1494
  setReconnectingState() {
1455
1495
  const t = this.state.lastError !== null && !this.state.isThinking && this.state.lastErrorCode !== "connection_failed";
@@ -1459,14 +1499,14 @@ class Me {
1459
1499
  this.listeners[t]?.forEach((r) => r(s));
1460
1500
  }
1461
1501
  }
1462
- const bt = /* @__PURE__ */ new WeakMap();
1463
- function Os(e) {
1464
- const t = window.__plunoProductAgentNetworkCapture ?? vs();
1502
+ const Mt = /* @__PURE__ */ new WeakMap();
1503
+ function qs(e) {
1504
+ const t = window.__plunoProductAgentNetworkCapture ?? Bs();
1465
1505
  return t.subscribers.add(e), () => {
1466
1506
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1467
1507
  };
1468
1508
  }
1469
- function vs() {
1509
+ function Bs() {
1470
1510
  const e = /* @__PURE__ */ new Set(), t = (I) => {
1471
1511
  e.forEach((m) => {
1472
1512
  try {
@@ -1483,20 +1523,20 @@ function vs() {
1483
1523
  throw y;
1484
1524
  }
1485
1525
  try {
1486
- const y = m instanceof Request ? m : null, k = mr(m, y), T = qe(d?.headers ?? y?.headers);
1526
+ const y = m instanceof Request ? m : null, k = Tr(m, y), T = He(d?.headers ?? y?.headers);
1487
1527
  if (!v(k, T, d?.body)) {
1488
1528
  const H = {
1489
- requestId: kt("fetch"),
1490
- url: P(k, Rt),
1529
+ requestId: _t("fetch"),
1530
+ url: P(k, bt),
1491
1531
  method: (d?.method ?? y?.method ?? "GET").toUpperCase(),
1492
1532
  requestHeaders: T,
1493
- requestBody: we(d?.body),
1533
+ requestBody: Ae(d?.body),
1494
1534
  resourceType: "fetch",
1495
1535
  startedAt: new Date(f).toISOString()
1496
1536
  };
1497
1537
  h.then(
1498
1538
  (_) => {
1499
- yr(_, H, f, t).catch(() => {
1539
+ wr(_, H, f, t).catch(() => {
1500
1540
  t({
1501
1541
  ...H,
1502
1542
  responseStatus: _.status,
@@ -1518,27 +1558,27 @@ function vs() {
1518
1558
  return h;
1519
1559
  }, a = function(m, d, f, h, y) {
1520
1560
  const k = n.call(this, m, d, f ?? !0, h ?? void 0, y ?? void 0), T = typeof d == "string" ? d : d.toString();
1521
- return bt.set(this, {
1522
- requestId: kt("xhr"),
1561
+ return Mt.set(this, {
1562
+ requestId: _t("xhr"),
1523
1563
  method: String(m ?? "GET").toUpperCase(),
1524
- url: P(T, Rt),
1564
+ url: P(T, bt),
1525
1565
  requestHeaders: {},
1526
1566
  startedAtMs: Date.now(),
1527
1567
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1528
1568
  excluded: v(T)
1529
1569
  }), k;
1530
1570
  }, c = function(m, d) {
1531
- const f = r.call(this, m, d), h = bt.get(this);
1532
- return h && Object.keys(h.requestHeaders).length < Ft && (h.requestHeaders[m] = Gt(m, d), h.excluded = h.excluded || v(h.url, h.requestHeaders)), f;
1571
+ const f = r.call(this, m, d), h = Mt.get(this);
1572
+ return h && Object.keys(h.requestHeaders).length < Wt && (h.requestHeaders[m] = Xt(m, d), h.excluded = h.excluded || v(h.url, h.requestHeaders)), f;
1533
1573
  }, l = function(m) {
1534
1574
  try {
1535
- const d = bt.get(this);
1536
- d && (d.excluded = d.excluded || v(d.url, d.requestHeaders, m), d.requestBody = we(m), d.excluded || this.addEventListener(
1575
+ const d = Mt.get(this);
1576
+ d && (d.excluded = d.excluded || v(d.url, d.requestHeaders, m), d.requestBody = Ae(m), d.excluded || this.addEventListener(
1537
1577
  "loadend",
1538
1578
  () => {
1539
1579
  queueMicrotask(() => {
1540
1580
  try {
1541
- const f = Er(this.getAllResponseHeaders());
1581
+ const f = Mr(this.getAllResponseHeaders());
1542
1582
  t({
1543
1583
  requestId: d.requestId,
1544
1584
  url: d.url,
@@ -1548,7 +1588,7 @@ function vs() {
1548
1588
  resourceType: "xhr",
1549
1589
  responseStatus: this.status,
1550
1590
  responseHeaders: f,
1551
- responseBody: Tr(this, f),
1591
+ responseBody: Ar(this, f),
1552
1592
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1553
1593
  startedAt: d.startedAt,
1554
1594
  durationMs: Date.now() - d.startedAtMs
@@ -1589,8 +1629,8 @@ function vs() {
1589
1629
  continue;
1590
1630
  const f = performance.timeOrigin + d.startTime;
1591
1631
  t({
1592
- requestId: kt("resource"),
1593
- url: P(d.name, Rt),
1632
+ requestId: _t("resource"),
1633
+ url: P(d.name, bt),
1594
1634
  method: "GET",
1595
1635
  resourceType: "resource",
1596
1636
  responseStatus: d.responseStatus,
@@ -1640,15 +1680,15 @@ function S(e, t, s) {
1640
1680
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1641
1681
  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 }));
1642
1682
  }
1643
- function ce(e) {
1683
+ function ue(e) {
1644
1684
  const t = typeof e == "function" ? e() : e;
1645
1685
  return t && Object.keys(t).length > 0 ? t : void 0;
1646
1686
  }
1647
- function Ls(e) {
1687
+ function Hs(e) {
1648
1688
  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";
1649
1689
  }
1650
- const qs = 5e3, Bs = 12e4;
1651
- function Hs(e) {
1690
+ const Fs = 5e3, Ws = 12e4;
1691
+ function $s(e) {
1652
1692
  const t = [];
1653
1693
  for (const s of e)
1654
1694
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1659,30 +1699,30 @@ function Hs(e) {
1659
1699
  });
1660
1700
  return t;
1661
1701
  }
1662
- function Fs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1702
+ function js(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1663
1703
  const n = [
1664
- $s(),
1665
- Ws()
1704
+ Gs(),
1705
+ zs()
1666
1706
  ].filter((r) => typeof r == "function");
1667
1707
  return () => {
1668
1708
  for (const r of n.reverse())
1669
1709
  r();
1670
1710
  };
1671
1711
  }
1672
- function Ws() {
1673
- return Ae(globalThis, "getPageSnapshot", async () => Wt());
1712
+ function zs() {
1713
+ return Re(globalThis, "getPageSnapshot", async () => $t());
1674
1714
  }
1675
- function $s() {
1676
- return Ae(globalThis, "pageImages", {
1677
- inspectImage: async (t, s) => await js(t, s)
1715
+ function Gs() {
1716
+ return Re(globalThis, "pageImages", {
1717
+ inspectImage: async (t, s) => await Xs(t, s)
1678
1718
  });
1679
1719
  }
1680
- async function js(e, t = {}) {
1681
- const s = Ks(t.name), n = await zs(e);
1720
+ async function Xs(e, t = {}) {
1721
+ const s = Ys(t.name), n = await Ks(e);
1682
1722
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1683
1723
  type: "pluno.pageImages.inspectImage",
1684
1724
  imageAttached: !1,
1685
- imageAttachmentError: Re
1725
+ imageAttachmentError: Me
1686
1726
  } : {
1687
1727
  type: "pluno.pageImages.inspectImage",
1688
1728
  imageAttached: !0,
@@ -1696,15 +1736,15 @@ async function js(e, t = {}) {
1696
1736
  imageAttachmentError: n.error
1697
1737
  };
1698
1738
  }
1699
- async function zs(e) {
1700
- 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: Re } : {
1739
+ async function Ks(e) {
1740
+ 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 } : {
1701
1741
  ok: !0,
1702
1742
  mimeType: e.type,
1703
1743
  sizeBytes: e.size,
1704
- dataUrl: await Vs(e)
1705
- } : { 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." } : Gs(e);
1744
+ dataUrl: await Qs(e)
1745
+ } : { 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." } : Js(e);
1706
1746
  }
1707
- function Gs(e) {
1747
+ function Js(e) {
1708
1748
  if (!e.startsWith("data:") || !e.includes(","))
1709
1749
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1710
1750
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1715,7 +1755,7 @@ function Gs(e) {
1715
1755
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1716
1756
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1717
1757
  return { ok: !1, error: "Page image data URL has invalid base64." };
1718
- const o = Xs(i);
1758
+ const o = Vs(i);
1719
1759
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1720
1760
  ok: !0,
1721
1761
  mimeType: r,
@@ -1723,22 +1763,22 @@ function Gs(e) {
1723
1763
  dataUrl: `data:${r};base64,${i}`
1724
1764
  };
1725
1765
  }
1726
- function Xs(e) {
1766
+ function Vs(e) {
1727
1767
  if (e.length === 0 || e.length % 4 !== 0)
1728
1768
  return null;
1729
1769
  const t = e.length - e.replace(/=+$/, "").length;
1730
1770
  return t > 2 ? null : e.length / 4 * 3 - t;
1731
1771
  }
1732
- function Ks(e) {
1772
+ function Ys(e) {
1733
1773
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1734
1774
  }
1735
- function Js(e) {
1775
+ function Zs(e) {
1736
1776
  try {
1737
1777
  e();
1738
1778
  } catch {
1739
1779
  }
1740
1780
  }
1741
- function Vs(e) {
1781
+ function Qs(e) {
1742
1782
  return new Promise((t, s) => {
1743
1783
  const n = new FileReader();
1744
1784
  n.onload = () => {
@@ -1750,9 +1790,9 @@ function Vs(e) {
1750
1790
  }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1751
1791
  });
1752
1792
  }
1753
- async function le(e, t) {
1793
+ async function de(e, t) {
1754
1794
  const s = Object.getPrototypeOf(async function() {
1755
- }).constructor, n = e.timeoutMs ?? qs, r = Date.now(), i = [];
1795
+ }).constructor, n = e.timeoutMs ?? Fs, r = Date.now(), i = [];
1756
1796
  let o;
1757
1797
  const a = {
1758
1798
  log: console.log,
@@ -1770,7 +1810,7 @@ async function le(e, t) {
1770
1810
  o = window.setTimeout(() => p(l), n);
1771
1811
  })
1772
1812
  ]);
1773
- return u === l ? Zs(n) : {
1813
+ return u === l ? en(n) : {
1774
1814
  ok: !0,
1775
1815
  result: u,
1776
1816
  console: i,
@@ -1799,7 +1839,7 @@ async function le(e, t) {
1799
1839
  t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
1800
1840
  }
1801
1841
  }
1802
- function Ys(e, t) {
1842
+ function tn(e, t) {
1803
1843
  if (!e || typeof e != "object")
1804
1844
  return;
1805
1845
  const s = e.sandboxFilesToken;
@@ -1809,7 +1849,7 @@ function Ys(e, t) {
1809
1849
  const r = () => {
1810
1850
  if (!n)
1811
1851
  throw new Error("sandboxFiles is only available during browser-code execution");
1812
- }, i = async (a, c) => await ds(`${t.replace(/\/$/, "")}${a}`, c);
1852
+ }, i = async (a, c) => await ps(`${t.replace(/\/$/, "")}${a}`, c);
1813
1853
  return {
1814
1854
  value: Object.freeze({
1815
1855
  upload: async (a) => {
@@ -1843,7 +1883,7 @@ function Ys(e, t) {
1843
1883
  }
1844
1884
  };
1845
1885
  }
1846
- function Zs(e) {
1886
+ function en(e) {
1847
1887
  return {
1848
1888
  ok: !1,
1849
1889
  exception: {
@@ -1857,10 +1897,10 @@ function Zs(e) {
1857
1897
  }
1858
1898
  };
1859
1899
  }
1860
- function Qs(e) {
1900
+ function sn(e) {
1861
1901
  return e.replace(/\/+$/, "");
1862
1902
  }
1863
- function tn(e) {
1903
+ function nn(e) {
1864
1904
  const t = {
1865
1905
  sidepanel: "extension_sidepanel",
1866
1906
  browser_extension_page_ui: "extension_widget",
@@ -1872,18 +1912,18 @@ function tn(e) {
1872
1912
  };
1873
1913
  return e && e in t ? t[e] : e ?? "embedded_custom_ui";
1874
1914
  }
1875
- function en(e) {
1915
+ function rn(e) {
1876
1916
  return e === "pluno" ? "scheduled_continuation" : e ?? "user";
1877
1917
  }
1878
- function sn(e, t = location.origin) {
1918
+ function on(e, t = location.origin) {
1879
1919
  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;
1880
1920
  }
1881
- function nn(e) {
1921
+ function an(e) {
1882
1922
  const t = new URL("/api/product-agent/embed/ws", e);
1883
1923
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1884
1924
  }
1885
1925
  function b() {
1886
- const e = Pe();
1926
+ const e = De();
1887
1927
  return {
1888
1928
  url: location.href,
1889
1929
  title: document.title,
@@ -1891,19 +1931,19 @@ function b() {
1891
1931
  ...e ? { plunoProductAgentUi: e } : {}
1892
1932
  };
1893
1933
  }
1894
- function rn() {
1934
+ function cn() {
1895
1935
  return {
1896
1936
  pageUrl: location.href,
1897
1937
  pageTitle: document.title,
1898
- htmlContent: Wt()
1938
+ htmlContent: $t()
1899
1939
  };
1900
1940
  }
1901
- function on(e) {
1902
- return st.add(e), Z || (Z = an()), () => {
1941
+ function ln(e) {
1942
+ return st.add(e), Z || (Z = un()), () => {
1903
1943
  st.delete(e), st.size === 0 && (Z?.(), Z = null);
1904
1944
  };
1905
1945
  }
1906
- function an() {
1946
+ function un() {
1907
1947
  const e = () => {
1908
1948
  for (const i of Array.from(st))
1909
1949
  i();
@@ -1918,10 +1958,10 @@ function an() {
1918
1958
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
1919
1959
  };
1920
1960
  }
1921
- function cn() {
1922
- return Pe()?.surface === "browser_extension_sdk_preview";
1961
+ function dn() {
1962
+ return De()?.surface === "browser_extension_sdk_preview";
1923
1963
  }
1924
- function Wt() {
1964
+ function $t() {
1925
1965
  if (!document.body)
1926
1966
  return "";
1927
1967
  const e = [], t = [], s = (f, h) => {
@@ -1930,16 +1970,16 @@ function Wt() {
1930
1970
  };
1931
1971
  s("Selected text", window.getSelection()?.toString() ?? "");
1932
1972
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
1933
- (f) => ke(f) && !f.parentElement?.closest(n)
1973
+ (f) => Ce(f) && !f.parentElement?.closest(n)
1934
1974
  );
1935
1975
  for (const f of r.slice(0, 3))
1936
- s("Active overlay", Mt(z(f), t));
1937
- const i = ln(), o = i ? Mt(z(i), t) : "";
1938
- s("Main page content", o), s("Additional visible page text", Mt(z(document.body), t));
1976
+ s("Active overlay", kt(z(f), t));
1977
+ const i = hn(), o = i ? kt(z(i), t) : "";
1978
+ s("Main page content", o), s("Additional visible page text", kt(z(document.body), t));
1939
1979
  const a = e.map(([f, h]) => `${f}:
1940
1980
  ${h}`).join(`
1941
1981
 
1942
- `).trim().slice(0, 12e3), c = un(r, i).trim(), l = `Simplified DOM outline:
1982
+ `).trim().slice(0, 12e3), c = pn(r, i).trim(), l = `Simplified DOM outline:
1943
1983
  `, u = `
1944
1984
 
1945
1985
  Visible page text:
@@ -1957,20 +1997,20 @@ function B(e) {
1957
1997
 
1958
1998
  `).trim();
1959
1999
  }
1960
- function Mt(e, t) {
2000
+ function kt(e, t) {
1961
2001
  let s = B(e);
1962
2002
  for (const n of t)
1963
2003
  s = s.replace(n, "");
1964
2004
  return B(s);
1965
2005
  }
1966
- function ke(e) {
2006
+ function Ce(e) {
1967
2007
  const t = window.getComputedStyle(e);
1968
2008
  return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
1969
2009
  }
1970
- function ln() {
1971
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(ke).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
2010
+ function hn() {
2011
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ce).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
1972
2012
  }
1973
- function un(e, t) {
2013
+ function pn(e, t) {
1974
2014
  const s = /* @__PURE__ */ new Set([
1975
2015
  "main",
1976
2016
  "nav",
@@ -2050,7 +2090,7 @@ function un(e, t) {
2050
2090
  "data-test",
2051
2091
  "data-qa",
2052
2092
  "data-cy"
2053
- ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: p } = dn(), I = new Set(e);
2093
+ ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: p } = fn(), I = new Set(e);
2054
2094
  t && I.add(t);
2055
2095
  let m = 0;
2056
2096
  const d = (T) => {
@@ -2065,36 +2105,36 @@ function un(e, t) {
2065
2105
  if (m >= 1e3 && !G || H.has(A) || i.has(R) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
2066
2106
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2067
2107
  m += 1;
2068
- const Xt = d(A), X = Ce(A), Ge = a.has(Xt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(R) || R === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((g) => g instanceof HTMLElement), K = /* @__PURE__ */ new Map();
2108
+ const Kt = d(A), X = Ue(A), Ke = a.has(Kt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(R) || R === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((g) => g instanceof HTMLElement), K = /* @__PURE__ */ new Map();
2069
2109
  for (const g of pt) {
2070
2110
  const w = f(g);
2071
2111
  K.set(w, (K.get(w) ?? 0) + 1);
2072
2112
  }
2073
- const ft = /* @__PURE__ */ new Map(), Kt = /* @__PURE__ */ new Map();
2113
+ const ft = /* @__PURE__ */ new Map(), Jt = /* @__PURE__ */ new Map();
2074
2114
  for (const g of pt) {
2075
- const w = f(g), x = Kt.get(w) ?? 0;
2076
- Kt.set(w, x + 1), (K.get(w) ?? 0) > 8 && x >= 6 && !u.has(g) && ft.set(w, (ft.get(w) ?? 0) + 1);
2115
+ const w = f(g), N = Jt.get(w) ?? 0;
2116
+ Jt.set(w, N + 1), (K.get(w) ?? 0) > 8 && N >= 6 && !u.has(g) && ft.set(w, (ft.get(w) ?? 0) + 1);
2077
2117
  }
2078
- const Jt = /* @__PURE__ */ new Map(), Vt = /* @__PURE__ */ new Set(), gt = [], Yt = [];
2118
+ const Vt = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Set(), gt = [], Zt = [];
2079
2119
  for (const g of pt) {
2080
- const w = f(g), x = K.get(w) ?? 0, te = Jt.get(w) ?? 0;
2081
- if (Jt.set(w, te + 1), x > 8 && te >= 6 && !u.has(g)) {
2082
- Vt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Vt.add(w));
2120
+ const w = f(g), N = K.get(w) ?? 0, ee = Vt.get(w) ?? 0;
2121
+ if (Vt.set(w, ee + 1), N > 8 && ee >= 6 && !u.has(g)) {
2122
+ Yt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Yt.add(w));
2083
2123
  continue;
2084
2124
  }
2085
- const ee = _(g, dt);
2086
- Yt.push(ee), gt.push(ee.lines);
2125
+ const se = _(g, dt);
2126
+ Zt.push(se), gt.push(se.lines);
2087
2127
  }
2088
2128
  const mt = [];
2089
2129
  if (A.shadowRoot)
2090
2130
  for (const g of Array.from(A.shadowRoot.children))
2091
2131
  g instanceof HTMLElement && mt.push(_(g, dt + 1));
2092
- const J = [...Yt, ...mt], yt = X.length > 0 || Ge || J.some((g) => g.hasUsefulContent), Zt = B(
2132
+ const J = [...Zt, ...mt], yt = X.length > 0 || Ke || J.some((g) => g.hasUsefulContent), Qt = B(
2093
2133
  [X, ...J.map((g) => g.textPreview)].filter(Boolean).join(" ")
2094
- ).slice(0, 180), Xe = A.hasAttribute("contenteditable") && (X.length > 0 || !A.querySelector("[contenteditable]")), Qt = l.some((g) => A.hasAttribute(g)) || !!Xt || Xe, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(R) || Qt || G) && (yt || G) && (!r.has(R) || yt || Qt || G), Tt = It ? 1 : 0, F = [];
2134
+ ).slice(0, 180), Je = A.hasAttribute("contenteditable") && (X.length > 0 || !A.querySelector("[contenteditable]")), te = l.some((g) => A.hasAttribute(g)) || !!Kt || Je, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(R) || te || G) && (yt || G) && (!r.has(R) || yt || te || G), Tt = It ? 1 : 0, F = [];
2095
2135
  if (It) {
2096
- const g = J.some((x) => x.containsTextElement), w = n.has(R) && !g ? Zt : X;
2097
- F.push(_e(A, c, o, w.slice(0, 180)));
2136
+ const g = J.some((N) => N.containsTextElement), w = n.has(R) && !g ? Qt : X;
2137
+ F.push(Pe(A, c, o, w.slice(0, 180)));
2098
2138
  }
2099
2139
  for (const g of gt)
2100
2140
  F.push(...Q(g, Tt));
@@ -2104,15 +2144,15 @@ function un(e, t) {
2104
2144
  wt.length > g.length && g.push("… shadow DOM omitted");
2105
2145
  const w = R.includes("tooltip") || R.includes("popper") || R.includes("loader");
2106
2146
  if (dt < 2 && !w) {
2107
- const x = It ? "#shadow-root" : `${R} #shadow-root`;
2108
- F.push(...Q([x, ...Q(g, 1)], Tt));
2147
+ const N = It ? "#shadow-root" : `${R} #shadow-root`;
2148
+ F.push(...Q([N, ...Q(g, 1)], Tt));
2109
2149
  } else
2110
2150
  F.push(...Q(g, Tt));
2111
2151
  }
2112
2152
  return {
2113
2153
  lines: F,
2114
2154
  hasUsefulContent: yt,
2115
- textPreview: Zt,
2155
+ textPreview: Qt,
2116
2156
  containsTextElement: n.has(R) || J.some((g) => g.containsTextElement)
2117
2157
  };
2118
2158
  };
@@ -2120,7 +2160,7 @@ function un(e, t) {
2120
2160
  `);
2121
2161
  }, y = [], k = B(window.getSelection()?.toString() ?? "");
2122
2162
  k && y.push(`--- selected text ---
2123
- ${JSON.stringify(k)}`), p.length > 0 && y.push(hn(p, s, c, o));
2163
+ ${JSON.stringify(k)}`), p.length > 0 && y.push(gn(p, s, c, o));
2124
2164
  for (const T of e.slice(0, 3))
2125
2165
  y.push(h(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2126
2166
  if (t && y.push(h(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
@@ -2131,11 +2171,11 @@ ${JSON.stringify(k)}`), p.length > 0 && y.push(hn(p, s, c, o));
2131
2171
 
2132
2172
  `);
2133
2173
  }
2134
- function _e(e, t, s, n) {
2174
+ function Pe(e, t, s, n) {
2135
2175
  const r = e.tagName.toLowerCase();
2136
2176
  let i = r;
2137
2177
  const o = e.getAttribute("id");
2138
- o && pn(o) && (i += `#${o}`);
2178
+ o && mn(o) && (i += `#${o}`);
2139
2179
  for (const a of t) {
2140
2180
  const c = e.getAttribute(a);
2141
2181
  c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
@@ -2148,7 +2188,7 @@ function _e(e, t, s, n) {
2148
2188
  e.hasAttribute(a) && (i += `[${a}]`);
2149
2189
  return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
2150
2190
  }
2151
- function dn() {
2191
+ function fn() {
2152
2192
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
2153
2193
  if (!a)
2154
2194
  return;
@@ -2169,7 +2209,7 @@ function dn() {
2169
2209
  n = n.shadowRoot.activeElement;
2170
2210
  n !== document.body && n !== document.documentElement && s(n, "focused");
2171
2211
  const r = window.getSelection();
2172
- r && !r.isCollapsed && (s(ue(r.anchorNode), "selected text"), s(ue(r.focusNode), "selected text"));
2212
+ r && !r.isCollapsed && (s(he(r.anchorNode), "selected text"), s(he(r.focusNode), "selected text"));
2173
2213
  const i = [
2174
2214
  ["[aria-selected='true']", "selected"],
2175
2215
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -2191,7 +2231,7 @@ function dn() {
2191
2231
  priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
2192
2232
  };
2193
2233
  }
2194
- function hn(e, t, s, n) {
2234
+ function gn(e, t, s, n) {
2195
2235
  const r = ["--- active/current elements ---"];
2196
2236
  for (const i of e) {
2197
2237
  const o = [];
@@ -2202,18 +2242,18 @@ function hn(e, t, s, n) {
2202
2242
  const p = a.getRootNode();
2203
2243
  a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
2204
2244
  }
2205
- const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((u, p) => _e(
2245
+ const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((u, p) => Pe(
2206
2246
  u,
2207
2247
  s,
2208
2248
  n,
2209
- p === c.length - 1 ? Ce(u).slice(0, 180) : ""
2249
+ p === c.length - 1 ? Ue(u).slice(0, 180) : ""
2210
2250
  ));
2211
2251
  o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
2212
2252
  }
2213
2253
  return r.join(`
2214
2254
  `);
2215
2255
  }
2216
- function ue(e) {
2256
+ function he(e) {
2217
2257
  return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
2218
2258
  }
2219
2259
  function Q(e, t) {
@@ -2222,17 +2262,17 @@ function Q(e, t) {
2222
2262
  const s = " ".repeat(t);
2223
2263
  return e.map((n) => `${s}${n}`);
2224
2264
  }
2225
- function Ce(e) {
2265
+ function Ue(e) {
2226
2266
  return B(
2227
2267
  Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
2228
2268
  );
2229
2269
  }
2230
- function pn(e) {
2270
+ function mn(e) {
2231
2271
  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);
2232
2272
  }
2233
- function Pe() {
2234
- const e = document.querySelector(se);
2235
- if (!(e ?? document.querySelector(Ct)))
2273
+ function De() {
2274
+ const e = document.querySelector(ne);
2275
+ if (!(e ?? document.querySelector(Pt)))
2236
2276
  return;
2237
2277
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
2238
2278
  return {
@@ -2241,28 +2281,28 @@ function Pe() {
2241
2281
  selectors: [
2242
2282
  {
2243
2283
  name: "widget_host",
2244
- selector: s === "browser_extension_sdk_preview" ? se : Ct,
2284
+ selector: s === "browser_extension_sdk_preview" ? ne : Pt,
2245
2285
  description: "Finds Pluno's shadow-host element in the host page DOM."
2246
2286
  },
2247
2287
  {
2248
2288
  name: "widget_root",
2249
- selector: hs,
2289
+ selector: fs,
2250
2290
  description: "Finds Pluno's widget root inside the widget host shadow root."
2251
2291
  },
2252
2292
  {
2253
2293
  name: "widget_panel",
2254
- selector: ps,
2294
+ selector: gs,
2255
2295
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
2256
2296
  },
2257
2297
  {
2258
2298
  name: "widget_timeline",
2259
- selector: fs,
2299
+ selector: ms,
2260
2300
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2261
2301
  }
2262
2302
  ]
2263
2303
  };
2264
2304
  }
2265
- function fn(e) {
2305
+ function yn(e) {
2266
2306
  try {
2267
2307
  const t = JSON.parse(e);
2268
2308
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -2270,16 +2310,16 @@ function fn(e) {
2270
2310
  return { type: "error", message: "Invalid server event" };
2271
2311
  }
2272
2312
  }
2273
- function de(e, t) {
2313
+ function pe(e, t) {
2274
2314
  if (!e || typeof e != "object")
2275
2315
  return [];
2276
2316
  const s = e[t];
2277
2317
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2278
2318
  }
2279
- function gn(e) {
2319
+ function In(e) {
2280
2320
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
2281
2321
  }
2282
- function mn(e) {
2322
+ function Tn(e) {
2283
2323
  if (!e || typeof e != "object")
2284
2324
  return null;
2285
2325
  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;
@@ -2290,13 +2330,13 @@ function mn(e) {
2290
2330
  ...a !== null ? { scribbleStyle: a } : {}
2291
2331
  };
2292
2332
  }
2293
- function yn(e) {
2333
+ function wn(e) {
2294
2334
  if (!e || typeof e != "object")
2295
2335
  return null;
2296
2336
  const t = e.javascript;
2297
2337
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
2298
2338
  }
2299
- function In(e, t) {
2339
+ function Sn(e, t) {
2300
2340
  return t ? e && typeof e == "object" ? {
2301
2341
  ...e,
2302
2342
  helperError: t
@@ -2306,13 +2346,13 @@ function In(e, t) {
2306
2346
  helperError: t
2307
2347
  } : e;
2308
2348
  }
2309
- function Tn(e) {
2349
+ function An(e) {
2310
2350
  if (!e || typeof e != "object")
2311
2351
  return e;
2312
2352
  const t = e;
2313
2353
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2314
2354
  }
2315
- function wn() {
2355
+ function En() {
2316
2356
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2317
2357
  if (t)
2318
2358
  return t;
@@ -2322,7 +2362,7 @@ function wn() {
2322
2362
  function $() {
2323
2363
  return crypto.randomUUID();
2324
2364
  }
2325
- function Sn(e) {
2365
+ function Rn(e) {
2326
2366
  if (!e || typeof e != "object")
2327
2367
  return null;
2328
2368
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2333,12 +2373,12 @@ function Sn(e) {
2333
2373
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2334
2374
  } : null;
2335
2375
  }
2336
- function An(e, t) {
2337
- return Array.isArray(e) ? vt(
2338
- e.map((s) => Ue(s, t)).filter((s) => s !== null)
2376
+ function bn(e, t) {
2377
+ return Array.isArray(e) ? Lt(
2378
+ e.map((s) => Ne(s, t)).filter((s) => s !== null)
2339
2379
  ) : [];
2340
2380
  }
2341
- function En(e) {
2381
+ function Mn(e) {
2342
2382
  return Array.isArray(e) ? e.flatMap((t) => {
2343
2383
  if (!t || typeof t != "object")
2344
2384
  return [];
@@ -2359,7 +2399,7 @@ function En(e) {
2359
2399
  ];
2360
2400
  }) : [];
2361
2401
  }
2362
- function Ue(e, t) {
2402
+ function Ne(e, t) {
2363
2403
  if (!e || typeof e != "object")
2364
2404
  return null;
2365
2405
  const s = e, n = s.data;
@@ -2373,14 +2413,14 @@ function Ue(e, t) {
2373
2413
  id: String(s.id ?? crypto.randomUUID()),
2374
2414
  role: i,
2375
2415
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2376
- content: es(
2377
- Pn(r.content),
2416
+ content: ns(
2417
+ Nn(r.content),
2378
2418
  t
2379
2419
  ),
2380
2420
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2381
2421
  respondsToUserMessageId: O(r) ?? void 0,
2382
2422
  ...C(r) ? { runId: C(r) } : {},
2383
- attachments: ve(r.attachments, t)
2423
+ attachments: qe(r.attachments, t)
2384
2424
  };
2385
2425
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
2386
2426
  value: r.id,
@@ -2391,7 +2431,7 @@ function Ue(e, t) {
2391
2431
  }), o;
2392
2432
  }
2393
2433
  if (r.type === "function_call_output") {
2394
- const i = bn(r.output);
2434
+ const i = _n(r.output);
2395
2435
  return i ? {
2396
2436
  id: String(s.id ?? crypto.randomUUID()),
2397
2437
  role: "tool",
@@ -2401,25 +2441,25 @@ function Ue(e, t) {
2401
2441
  ...C(r) ? { runId: C(r) } : {},
2402
2442
  dataType: "function_call_output",
2403
2443
  toolName: "authenticate_pipedream_app",
2404
- callId: he(r) ?? void 0,
2444
+ callId: fe(r) ?? void 0,
2405
2445
  integrationAuthRequest: i
2406
2446
  } : null;
2407
2447
  }
2408
2448
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2409
2449
  id: String(s.id ?? crypto.randomUUID()),
2410
2450
  role: "tool",
2411
- content: r.type === "mcp_call" ? Rn(r) : kn(r),
2451
+ content: r.type === "mcp_call" ? kn(r) : Pn(r),
2412
2452
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2413
2453
  respondsToUserMessageId: O(r) ?? void 0,
2414
2454
  ...C(r) ? { runId: C(r) } : {},
2415
2455
  dataType: String(r.type),
2416
2456
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
2417
- callId: he(r) ?? void 0,
2457
+ callId: fe(r) ?? void 0,
2418
2458
  loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
2419
2459
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2420
2460
  id: String(s.id ?? crypto.randomUUID()),
2421
2461
  role: "system",
2422
- content: Mn(r),
2462
+ content: Cn(r),
2423
2463
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2424
2464
  respondsToUserMessageId: O(r) ?? void 0,
2425
2465
  ...C(r) ? { runId: C(r) } : {},
@@ -2430,11 +2470,11 @@ function Ue(e, t) {
2430
2470
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2431
2471
  } : null;
2432
2472
  }
2433
- function Rn(e) {
2473
+ function kn(e) {
2434
2474
  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(" ");
2435
2475
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2436
2476
  }
2437
- function bn(e) {
2477
+ function _n(e) {
2438
2478
  if (typeof e != "string")
2439
2479
  return null;
2440
2480
  try {
@@ -2451,10 +2491,10 @@ function bn(e) {
2451
2491
  return null;
2452
2492
  }
2453
2493
  }
2454
- function Mn(e) {
2494
+ function Cn(e) {
2455
2495
  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.";
2456
2496
  }
2457
- function kn(e) {
2497
+ function Pn(e) {
2458
2498
  if (e.type === "web_search_call") {
2459
2499
  const t = e.action;
2460
2500
  if (t && typeof t == "object") {
@@ -2466,9 +2506,9 @@ function kn(e) {
2466
2506
  }
2467
2507
  return "🔎 Searching the web";
2468
2508
  }
2469
- return _n(e);
2509
+ return Un(e);
2470
2510
  }
2471
- function _n(e) {
2511
+ function Un(e) {
2472
2512
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2473
2513
  return L(e.summary);
2474
2514
  if (typeof e.arguments == "string")
@@ -2485,7 +2525,7 @@ function L(e) {
2485
2525
  const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2486
2526
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2487
2527
  }
2488
- function Cn(e) {
2528
+ function Dn(e) {
2489
2529
  if (e == null)
2490
2530
  return e;
2491
2531
  if (typeof e != "object")
@@ -2500,11 +2540,11 @@ function Cn(e) {
2500
2540
  runId: typeof t.runId == "string" ? t.runId : null
2501
2541
  };
2502
2542
  }
2503
- function he(e) {
2543
+ function fe(e) {
2504
2544
  const t = e.callId ?? e.call_id;
2505
2545
  return typeof t == "string" && t ? t : null;
2506
2546
  }
2507
- function Pn(e) {
2547
+ function Nn(e) {
2508
2548
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2509
2549
  if (!t || typeof t != "object")
2510
2550
  return "";
@@ -2512,36 +2552,36 @@ function Pn(e) {
2512
2552
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
2513
2553
  }).filter(Boolean).join("") : "";
2514
2554
  }
2515
- function Ut(e, t) {
2516
- const s = De(e, t), n = vn(
2517
- Un(
2518
- Fn(e, t),
2555
+ function Dt(e, t) {
2556
+ const s = xe(e, t), n = Bn(
2557
+ xn(
2558
+ jn(e, t),
2519
2559
  s
2520
2560
  ),
2521
2561
  s
2522
2562
  ), r = n.findIndex((o) => o.id === s.id);
2523
2563
  if (r === -1)
2524
- return vt(
2564
+ return Lt(
2525
2565
  [...n, s]
2526
2566
  );
2527
2567
  const i = [...n];
2528
- return i[r] = s, vt(i);
2568
+ return i[r] = s, Lt(i);
2529
2569
  }
2530
- function Un(e, t) {
2570
+ function xn(e, t) {
2531
2571
  const s = t.assistantDraftItemId;
2532
2572
  return s ? e.map(
2533
2573
  (n) => n.dataType === "assistant_draft" && n.id === s ? t : n
2534
2574
  ) : e;
2535
2575
  }
2536
- function Dn(e, t, s) {
2576
+ function On(e, t, s) {
2537
2577
  return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
2538
2578
  }
2539
- function xn(e, t) {
2579
+ function vn(e, t) {
2540
2580
  const s = e.findIndex(
2541
2581
  (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2542
2582
  );
2543
2583
  if (s === -1)
2544
- return Ut(e, t);
2584
+ return Dt(e, t);
2545
2585
  const n = [...e];
2546
2586
  return n[s] = {
2547
2587
  ...n[s],
@@ -2553,12 +2593,12 @@ function xn(e, t) {
2553
2593
  ...n[s].runId ? {} : { runId: t.runId }
2554
2594
  }, n;
2555
2595
  }
2556
- function Nn(e, t, s) {
2596
+ function Ln(e, t, s) {
2557
2597
  let n = !1;
2558
2598
  const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2559
2599
  return n ? r : e;
2560
2600
  }
2561
- function On(e) {
2601
+ function qn(e) {
2562
2602
  if (e.hiddenFromTranscript === !0)
2563
2603
  return null;
2564
2604
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
@@ -2577,7 +2617,7 @@ function On(e) {
2577
2617
  loading: !0
2578
2618
  };
2579
2619
  }
2580
- function vn(e, t) {
2620
+ function Bn(e, t) {
2581
2621
  if (t.id.startsWith("transient-activity:"))
2582
2622
  return e;
2583
2623
  const s = t.toolName === "tab_lifecycle";
@@ -2585,10 +2625,10 @@ function vn(e, t) {
2585
2625
  (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)
2586
2626
  );
2587
2627
  }
2588
- function Ln(e, t) {
2589
- const s = qn(
2628
+ function Hn(e, t) {
2629
+ const s = Fn(
2590
2630
  t.map(
2591
- (c) => De(e, c)
2631
+ (c) => xe(e, c)
2592
2632
  )
2593
2633
  ), n = new Map(s.map((c) => [c.id, c])), r = new Map(
2594
2634
  s.flatMap((c) => {
@@ -2603,8 +2643,8 @@ function Ln(e, t) {
2603
2643
  ), o = /* @__PURE__ */ new Set(), a = [];
2604
2644
  for (const c of e) {
2605
2645
  let l = n.get(c.id);
2606
- if ($t(c)) {
2607
- const u = Dt(c);
2646
+ if (jt(c)) {
2647
+ const u = Nt(c);
2608
2648
  if (l = u ? r.get(u) : void 0, !l) {
2609
2649
  a.push(c);
2610
2650
  continue;
@@ -2619,7 +2659,7 @@ function Ln(e, t) {
2619
2659
  o.has(c) || a.push(c);
2620
2660
  return a;
2621
2661
  }
2622
- function qn(e) {
2662
+ function Fn(e) {
2623
2663
  const t = new Set(
2624
2664
  e.flatMap(
2625
2665
  (s) => s.callId && !s.id.startsWith("transient-activity:") ? [s.callId] : []
@@ -2629,46 +2669,46 @@ function qn(e) {
2629
2669
  (s) => !(s.callId && s.id.startsWith("transient-activity:") && t.has(s.callId))
2630
2670
  );
2631
2671
  }
2632
- function De(e, t) {
2672
+ function xe(e, t) {
2633
2673
  if (t.role !== "user" || !t.attachments?.length)
2634
2674
  return t;
2635
2675
  const s = e.find(
2636
- (r) => r.role === "user" && (r.id === t.id || $t(r) && xe(r, t))
2676
+ (r) => r.role === "user" && (r.id === t.id || jt(r) && Oe(r, t))
2637
2677
  );
2638
2678
  if (!s?.attachments?.length)
2639
2679
  return t;
2640
2680
  const n = t.attachments.map((r) => {
2641
- const i = Bn(s.attachments ?? [], r);
2642
- return i ? Hn(r, i) : r;
2681
+ const i = Wn(s.attachments ?? [], r);
2682
+ return i ? $n(r, i) : r;
2643
2683
  });
2644
2684
  return { ...t, attachments: n };
2645
2685
  }
2646
- function Bn(e, t) {
2686
+ function Wn(e, t) {
2647
2687
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2648
2688
  }
2649
- function Hn(e, t) {
2689
+ function $n(e, t) {
2650
2690
  const { previewUrl: s } = t;
2651
2691
  return s ? { ...e, previewUrl: s } : e;
2652
2692
  }
2653
- function Fn(e, t) {
2693
+ function jn(e, t) {
2654
2694
  if (t.role !== "user")
2655
2695
  return e;
2656
2696
  const s = e.findIndex(
2657
- (r) => $t(r) && xe(r, t)
2697
+ (r) => jt(r) && Oe(r, t)
2658
2698
  );
2659
2699
  if (s === -1)
2660
2700
  return e;
2661
2701
  const n = [...e];
2662
2702
  return n.splice(s, 1), n;
2663
2703
  }
2664
- function xe(e, t) {
2665
- const s = Dt(e), n = Dt(t);
2704
+ function Oe(e, t) {
2705
+ const s = Nt(e), n = Nt(t);
2666
2706
  return s && n ? s === n : e.content === t.content;
2667
2707
  }
2668
- function $t(e) {
2708
+ function jt(e) {
2669
2709
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2670
2710
  }
2671
- function Dt(e) {
2711
+ function Nt(e) {
2672
2712
  const t = e.clientMessageId;
2673
2713
  if (t)
2674
2714
  return t;
@@ -2677,8 +2717,8 @@ function Dt(e) {
2677
2717
  );
2678
2718
  return n ? e.id.slice(n.length) : null;
2679
2719
  }
2680
- function pe(e) {
2681
- const t = Ne(e);
2720
+ function ge(e) {
2721
+ const t = ve(e);
2682
2722
  if (t === null)
2683
2723
  return !1;
2684
2724
  const s = e[t].id, n = e.some(
@@ -2688,7 +2728,7 @@ function pe(e) {
2688
2728
  return n;
2689
2729
  for (let r = e.length - 1; r > t; r -= 1) {
2690
2730
  const i = e[r];
2691
- if (N(i))
2731
+ if (x(i))
2692
2732
  return !0;
2693
2733
  if (i.role === "system") {
2694
2734
  if (i.dataType === "run_error")
@@ -2699,23 +2739,23 @@ function pe(e) {
2699
2739
  }
2700
2740
  return !1;
2701
2741
  }
2702
- function Wn(e) {
2703
- const t = Ne(e);
2742
+ function zn(e) {
2743
+ const t = ve(e);
2704
2744
  if (t === null)
2705
- return e.some(N);
2745
+ return e.some(x);
2706
2746
  const s = e[t].id;
2707
2747
  return e.some((n) => n.respondsToUserMessageId === s) ? e.some(
2708
- (n) => n.respondsToUserMessageId === s && N(n)
2709
- ) : e.slice(t + 1).some(N);
2748
+ (n) => n.respondsToUserMessageId === s && x(n)
2749
+ ) : e.slice(t + 1).some(x);
2710
2750
  }
2711
- function Ne(e) {
2751
+ function ve(e) {
2712
2752
  for (let t = e.length - 1; t >= 0; t -= 1)
2713
2753
  if (e[t].role === "user")
2714
2754
  return t;
2715
2755
  return null;
2716
2756
  }
2717
2757
  function xt(e) {
2718
- return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2758
+ return x(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2719
2759
  }
2720
2760
  function at(e) {
2721
2761
  for (let t = e.length - 1; t >= 0; t -= 1) {
@@ -2731,7 +2771,7 @@ function at(e) {
2731
2771
  }
2732
2772
  return null;
2733
2773
  }
2734
- function $n(e) {
2774
+ function Gn(e) {
2735
2775
  const t = at(e);
2736
2776
  if (t === null)
2737
2777
  return null;
@@ -2747,13 +2787,13 @@ function q(e) {
2747
2787
  const t = e.data;
2748
2788
  return t && typeof t == "object" ? t : null;
2749
2789
  }
2750
- function Nt(e) {
2790
+ function Ot(e) {
2751
2791
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2752
2792
  }
2753
- function fe(e) {
2793
+ function me(e) {
2754
2794
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2755
2795
  }
2756
- function jn(e, t) {
2796
+ function Xn(e, t) {
2757
2797
  const s = at(t);
2758
2798
  if (s === null)
2759
2799
  return !1;
@@ -2765,7 +2805,7 @@ function jn(e, t) {
2765
2805
  (o) => o.respondsToUserMessageId === r && xt(o)
2766
2806
  ) : e.slice(i + 1).some(xt);
2767
2807
  }
2768
- function Ot(e) {
2808
+ function vt(e) {
2769
2809
  const t = at(e);
2770
2810
  if (t === null)
2771
2811
  return null;
@@ -2778,7 +2818,7 @@ function Ot(e) {
2778
2818
  const r = n.clientMessageId;
2779
2819
  return typeof r == "string" ? r : null;
2780
2820
  }
2781
- function zn(e) {
2821
+ function Kn(e) {
2782
2822
  const t = at(e);
2783
2823
  if (t === null)
2784
2824
  return null;
@@ -2793,13 +2833,13 @@ function zn(e) {
2793
2833
  if (i.type === "message" && i.role === "assistant")
2794
2834
  return null;
2795
2835
  if (i.type === "run_error")
2796
- return i.retryable !== !0 ? null : ge(e, i) ?? Ot(e);
2836
+ return i.retryable !== !0 ? null : ye(e, i) ?? vt(e);
2797
2837
  if (i.type === "run_status")
2798
- return i.status === "interrupted" && i.retryable === !0 ? ge(e, i) ?? Ot(e) : null;
2838
+ return i.status === "interrupted" && i.retryable === !0 ? ye(e, i) ?? vt(e) : null;
2799
2839
  }
2800
2840
  return null;
2801
2841
  }
2802
- function ge(e, t) {
2842
+ function ye(e, t) {
2803
2843
  if (typeof t.clientMessageId == "string")
2804
2844
  return t.clientMessageId;
2805
2845
  const s = O(t);
@@ -2808,7 +2848,7 @@ function ge(e, t) {
2808
2848
  const n = e.find((i) => E(i, "id") === s), r = q(n);
2809
2849
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2810
2850
  }
2811
- function Gn(e, t) {
2851
+ function Jn(e, t) {
2812
2852
  let s = 0;
2813
2853
  for (const n of e) {
2814
2854
  if (!n || typeof n != "object")
@@ -2821,56 +2861,56 @@ function Gn(e, t) {
2821
2861
  }
2822
2862
  return s;
2823
2863
  }
2824
- function me(e, t, s, n, r) {
2825
- if (!t || !Xn(e))
2864
+ function Ie(e, t, s, n, r) {
2865
+ if (!t || !Vn(e))
2826
2866
  return !1;
2827
2867
  const i = e;
2828
- return !(Nt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && C(i) !== r));
2868
+ return !(Ot(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && C(i) !== r));
2829
2869
  }
2830
- function Xn(e) {
2870
+ function Vn(e) {
2831
2871
  if (!e || typeof e != "object")
2832
2872
  return !1;
2833
2873
  const t = e;
2834
2874
  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");
2835
2875
  }
2836
- function N(e) {
2876
+ function x(e) {
2837
2877
  return e.role === "assistant" && e.phase !== "commentary";
2838
2878
  }
2839
- function Kn(e) {
2879
+ function Yn(e) {
2840
2880
  if (!e || typeof e != "object")
2841
2881
  return !1;
2842
2882
  const t = e;
2843
2883
  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";
2844
2884
  }
2845
- function vt(e) {
2846
- return e.filter((t, s) => ct(t) ? !sr(e, s) && !tr(e, s) && !er(e, s) : Jn(t) ? t.retryable === !0 && Qn(e, s) ? !1 : !Zn(e, s) : !0);
2885
+ function Lt(e) {
2886
+ return e.filter((t, s) => ct(t) ? !ir(e, s) && !nr(e, s) && !rr(e, s) : Zn(t) ? t.retryable === !0 && sr(e, s) ? !1 : !er(e, s) : !0);
2847
2887
  }
2848
- function Jn(e) {
2888
+ function Zn(e) {
2849
2889
  return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
2850
2890
  }
2851
2891
  function ct(e) {
2852
2892
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2853
2893
  }
2854
- function Vn(e, t) {
2894
+ function Qn(e, t) {
2855
2895
  const s = [...e].reverse().find(
2856
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && ye(n) && !Yn(
2896
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && Te(n) && !tr(
2857
2897
  e,
2858
2898
  n.respondsToUserMessageId
2859
2899
  )
2860
2900
  )?.respondsToUserMessageId;
2861
2901
  return s ? e.map(
2862
- (n) => n.respondsToUserMessageId === s && ye(n) ? { ...n, steered: !0 } : n
2902
+ (n) => n.respondsToUserMessageId === s && Te(n) ? { ...n, steered: !0 } : n
2863
2903
  ) : e;
2864
2904
  }
2865
- function ye(e) {
2905
+ function Te(e) {
2866
2906
  return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
2867
2907
  }
2868
- function Yn(e, t) {
2908
+ function tr(e, t) {
2869
2909
  return e.some(
2870
- (s) => s.respondsToUserMessageId === t && (N(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
2910
+ (s) => s.respondsToUserMessageId === t && (x(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
2871
2911
  );
2872
2912
  }
2873
- function Zn(e, t) {
2913
+ function er(e, t) {
2874
2914
  const s = e[t];
2875
2915
  for (let n = t + 1; n < e.length; n += 1) {
2876
2916
  const r = e[n];
@@ -2879,7 +2919,7 @@ function Zn(e, t) {
2879
2919
  }
2880
2920
  return !1;
2881
2921
  }
2882
- function Qn(e, t) {
2922
+ function sr(e, t) {
2883
2923
  const s = e[t];
2884
2924
  if (!s.respondsToUserMessageId)
2885
2925
  return !1;
@@ -2892,19 +2932,19 @@ function Qn(e, t) {
2892
2932
  }
2893
2933
  return !1;
2894
2934
  }
2895
- function tr(e, t) {
2935
+ function nr(e, t) {
2896
2936
  const s = e[t];
2897
2937
  return e.some(
2898
2938
  (n, r) => r !== t && n.role === "assistant" && lt(s, n)
2899
2939
  );
2900
2940
  }
2901
- function er(e, t) {
2941
+ function rr(e, t) {
2902
2942
  const s = e[t];
2903
2943
  return e.some(
2904
2944
  (n, r) => r !== t && n.role === "tool" && lt(s, n)
2905
2945
  );
2906
2946
  }
2907
- function sr(e, t) {
2947
+ function ir(e, t) {
2908
2948
  const s = e[t];
2909
2949
  for (let n = t + 1; n < e.length; n += 1)
2910
2950
  if (ct(e[n]) && lt(s, e[n]))
@@ -2917,15 +2957,15 @@ function lt(e, t) {
2917
2957
  function E(e, t) {
2918
2958
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2919
2959
  }
2920
- function nr(e, t) {
2960
+ function or(e, t) {
2921
2961
  try {
2922
- const s = window.localStorage.getItem(`${be}${e}`);
2962
+ const s = window.localStorage.getItem(`${ke}${e}`);
2923
2963
  if (!s)
2924
2964
  return null;
2925
2965
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2926
2966
  if (t !== void 0 && r !== t)
2927
2967
  return null;
2928
- const i = Array.isArray(n.messages) ? n.messages.map(pr).filter((o) => !!o) : [];
2968
+ const i = Array.isArray(n.messages) ? n.messages.map(mr).filter((o) => !!o) : [];
2929
2969
  return {
2930
2970
  sessionId: r,
2931
2971
  messages: i
@@ -2934,46 +2974,46 @@ function nr(e, t) {
2934
2974
  return null;
2935
2975
  }
2936
2976
  }
2937
- function rr(e, t) {
2977
+ function ar(e, t) {
2938
2978
  try {
2939
2979
  window.localStorage.setItem(
2940
- `${be}${e}`,
2980
+ `${ke}${e}`,
2941
2981
  JSON.stringify({
2942
2982
  sessionId: t.sessionId,
2943
- messages: t.messages.slice(-Us).map(fr)
2983
+ messages: t.messages.slice(-xs).map(yr)
2944
2984
  })
2945
2985
  );
2946
2986
  } catch {
2947
2987
  return;
2948
2988
  }
2949
2989
  }
2950
- function ir(e) {
2990
+ function cr(e) {
2951
2991
  try {
2952
- const t = window.localStorage.getItem(`${Pt}${e}`);
2992
+ const t = window.localStorage.getItem(`${Ut}${e}`);
2953
2993
  if (!t)
2954
2994
  return [];
2955
2995
  const s = JSON.parse(t);
2956
- return Array.isArray(s) ? s.filter(jt) : [];
2996
+ return Array.isArray(s) ? s.filter(zt) : [];
2957
2997
  } catch {
2958
2998
  return [];
2959
2999
  }
2960
3000
  }
2961
3001
  function j(e, t) {
2962
3002
  try {
2963
- const s = t.filter(jt);
3003
+ const s = t.filter(zt);
2964
3004
  if (s.length === 0) {
2965
- window.localStorage.removeItem(`${Pt}${e}`);
3005
+ window.localStorage.removeItem(`${Ut}${e}`);
2966
3006
  return;
2967
3007
  }
2968
3008
  window.localStorage.setItem(
2969
- `${Pt}${e}`,
3009
+ `${Ut}${e}`,
2970
3010
  JSON.stringify(s.slice(-25))
2971
3011
  );
2972
3012
  } catch {
2973
3013
  return;
2974
3014
  }
2975
3015
  }
2976
- function Oe(e, t) {
3016
+ function Le(e, t) {
2977
3017
  try {
2978
3018
  const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2979
3019
  ...o,
@@ -2989,28 +3029,28 @@ function Oe(e, t) {
2989
3029
  } catch {
2990
3030
  }
2991
3031
  }
2992
- function or(e, t) {
3032
+ function lr(e, t) {
2993
3033
  try {
2994
3034
  if (window.sessionStorage.getItem(`${ot}${e}`) === null)
2995
3035
  return;
2996
3036
  } catch {
2997
3037
  return;
2998
3038
  }
2999
- Oe(e, t);
3039
+ Le(e, t);
3000
3040
  }
3001
- function ar(e) {
3041
+ function ur(e) {
3002
3042
  try {
3003
3043
  const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
3004
3044
  if (window.sessionStorage.removeItem(t), !s)
3005
3045
  return [];
3006
3046
  const n = JSON.parse(s);
3007
- return Array.isArray(n) ? n.flatMap((r) => lr(r) ? [{
3047
+ return Array.isArray(n) ? n.flatMap((r) => hr(r) ? [{
3008
3048
  ...r.event,
3009
3049
  page: b(),
3010
3050
  rawOutput: {
3011
3051
  pageContextRestarted: !0,
3012
3052
  outcome: "unknown",
3013
- message: cr(location.href),
3053
+ message: dr(location.href),
3014
3054
  currentUrl: location.href,
3015
3055
  console: [],
3016
3056
  metadata: {
@@ -3027,17 +3067,17 @@ function ar(e) {
3027
3067
  return [];
3028
3068
  }
3029
3069
  }
3030
- function cr(e) {
3070
+ function dr(e) {
3031
3071
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
3032
3072
  Current URL: ${e}`;
3033
3073
  }
3034
- function lr(e) {
3074
+ function hr(e) {
3035
3075
  if (!e || typeof e != "object")
3036
3076
  return !1;
3037
3077
  const t = e, s = t.event;
3038
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && jt(s) && s.type === "tool.result";
3078
+ return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && zt(s) && s.type === "tool.result";
3039
3079
  }
3040
- function ur(e, t) {
3080
+ function pr(e, t) {
3041
3081
  const s = new Set(
3042
3082
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
3043
3083
  );
@@ -3046,26 +3086,26 @@ function ur(e, t) {
3046
3086
  ...t.filter((n) => !s.has(n.callId))
3047
3087
  ];
3048
3088
  }
3049
- function dr(e) {
3089
+ function fr(e) {
3050
3090
  try {
3051
3091
  window.sessionStorage.removeItem(`${ot}${e}`);
3052
3092
  } catch {
3053
3093
  return;
3054
3094
  }
3055
3095
  }
3056
- function jt(e) {
3096
+ function zt(e) {
3057
3097
  if (!e || typeof e != "object")
3058
3098
  return !1;
3059
3099
  const t = e;
3060
- return t.type === "chat.user_message" ? typeof t.content == "string" && Ie(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Ie(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
3100
+ return t.type === "chat.user_message" ? typeof t.content == "string" && we(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? we(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
3061
3101
  }
3062
- function Ie(e) {
3102
+ function we(e) {
3063
3103
  if (!e || typeof e != "object")
3064
3104
  return !1;
3065
3105
  const t = e;
3066
3106
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
3067
3107
  }
3068
- function ve(e, t) {
3108
+ function qe(e, t) {
3069
3109
  if (!Array.isArray(e))
3070
3110
  return;
3071
3111
  const s = e.filter((r) => {
@@ -3073,23 +3113,23 @@ function ve(e, t) {
3073
3113
  return !1;
3074
3114
  const i = r;
3075
3115
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
3076
- }), n = t ? s.map((r) => Le(r, t)) : s;
3116
+ }), n = t ? s.map((r) => Be(r, t)) : s;
3077
3117
  return n.length > 0 ? n : void 0;
3078
3118
  }
3079
- function Le(e, t) {
3119
+ function Be(e, t) {
3080
3120
  return e.fileUrl?.startsWith("/") ? {
3081
3121
  ...e,
3082
3122
  fileUrl: new URL(e.fileUrl, t).toString()
3083
3123
  } : e;
3084
3124
  }
3085
- function Te(e) {
3086
- return e.type || hr(e.name) || "application/octet-stream";
3125
+ function Se(e) {
3126
+ return e.type || gr(e.name) || "application/octet-stream";
3087
3127
  }
3088
- function hr(e) {
3128
+ function gr(e) {
3089
3129
  const t = e.toLowerCase();
3090
3130
  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;
3091
3131
  }
3092
- function pr(e) {
3132
+ function mr(e) {
3093
3133
  if (!e || typeof e != "object")
3094
3134
  return null;
3095
3135
  const t = e;
@@ -3102,17 +3142,17 @@ function pr(e) {
3102
3142
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
3103
3143
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
3104
3144
  securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
3105
- attachments: ve(t.attachments)?.map(zt),
3145
+ attachments: qe(t.attachments)?.map(Gt),
3106
3146
  loading: typeof t.loading == "boolean" ? t.loading : void 0
3107
3147
  };
3108
3148
  }
3109
- function fr(e) {
3149
+ function yr(e) {
3110
3150
  return e.attachments?.length ? {
3111
3151
  ...e,
3112
- attachments: e.attachments.map(zt)
3152
+ attachments: e.attachments.map(Gt)
3113
3153
  } : e;
3114
3154
  }
3115
- function zt(e) {
3155
+ function Gt(e) {
3116
3156
  const {
3117
3157
  dataUrl: t,
3118
3158
  objectUrl: s,
@@ -3129,39 +3169,39 @@ function C(e) {
3129
3169
  const t = e.runId;
3130
3170
  return typeof t == "string" && t ? t : null;
3131
3171
  }
3132
- function gr(e) {
3172
+ function Ir(e) {
3133
3173
  const t = e?.timeoutMs;
3134
- 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 <= Bs);
3174
+ 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 <= Ws);
3135
3175
  }
3136
- function qe(e) {
3176
+ function He(e) {
3137
3177
  const t = {};
3138
3178
  try {
3139
3179
  new Headers(e).forEach((s, n) => {
3140
- Object.keys(t).length < Ft && (t[n] = Gt(n, s));
3180
+ Object.keys(t).length < Wt && (t[n] = Xt(n, s));
3141
3181
  });
3142
3182
  } catch {
3143
3183
  return {};
3144
3184
  }
3145
3185
  return t;
3146
3186
  }
3147
- function Gt(e, t) {
3148
- return je(e) ? ut : P(it(t), Cs);
3187
+ function Xt(e, t) {
3188
+ return Ge(e) ? ut : P(it(t), Ds);
3149
3189
  }
3150
- function mr(e, t) {
3190
+ function Tr(e, t) {
3151
3191
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
3152
3192
  }
3153
- async function yr(e, t, s, n) {
3154
- const r = qe(e.headers);
3193
+ async function wr(e, t, s, n) {
3194
+ const r = He(e.headers);
3155
3195
  n({
3156
3196
  ...t,
3157
3197
  responseStatus: e.status,
3158
3198
  responseHeaders: r,
3159
- responseBody: await Ir(e),
3199
+ responseBody: await Sr(e),
3160
3200
  durationMs: Date.now() - s
3161
3201
  });
3162
3202
  }
3163
- async function Ir(e) {
3164
- if (!Be(e.headers))
3203
+ async function Sr(e) {
3204
+ if (!Fe(e.headers))
3165
3205
  return;
3166
3206
  let t = null, s = null;
3167
3207
  try {
@@ -3170,7 +3210,7 @@ async function Ir(e) {
3170
3210
  const n = new Promise((a) => {
3171
3211
  s = window.setTimeout(() => {
3172
3212
  t?.cancel(), a("timeout");
3173
- }, Ps);
3213
+ }, Ns);
3174
3214
  }), r = new TextDecoder();
3175
3215
  let i = "", o = 0;
3176
3216
  for (; ; ) {
@@ -3180,7 +3220,7 @@ async function Ir(e) {
3180
3220
  const { done: c, value: l } = a;
3181
3221
  if (c)
3182
3222
  return P(i + r.decode());
3183
- const u = Ht - o;
3223
+ const u = Ft - o;
3184
3224
  if (l.byteLength > u)
3185
3225
  return i += r.decode(l.subarray(0, Math.max(u, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
3186
3226
  o += l.byteLength, i += r.decode(l, { stream: !0 });
@@ -3192,26 +3232,26 @@ async function Ir(e) {
3192
3232
  s !== null && window.clearTimeout(s);
3193
3233
  }
3194
3234
  }
3195
- function Tr(e, t) {
3196
- if (Be(new Headers(t)))
3235
+ function Ar(e, t) {
3236
+ if (Fe(new Headers(t)))
3197
3237
  try {
3198
3238
  return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
3199
3239
  } catch {
3200
3240
  return;
3201
3241
  }
3202
3242
  }
3203
- function we(e) {
3243
+ function Ae(e) {
3204
3244
  if (typeof e == "string")
3205
3245
  return P(e);
3206
3246
  }
3207
- function wr(e) {
3247
+ function Er(e) {
3208
3248
  return M({
3209
3249
  ...e,
3210
- requestBody: Se(e.requestBody),
3211
- responseBody: Se(e.responseBody)
3250
+ requestBody: Ee(e.requestBody),
3251
+ responseBody: Ee(e.responseBody)
3212
3252
  });
3213
3253
  }
3214
- function Se(e) {
3254
+ function Ee(e) {
3215
3255
  if (typeof e != "string")
3216
3256
  return e;
3217
3257
  const t = e.trim();
@@ -3223,14 +3263,14 @@ function Se(e) {
3223
3263
  return it(e);
3224
3264
  }
3225
3265
  }
3226
- function Be(e) {
3266
+ function Fe(e) {
3227
3267
  if (!e)
3228
3268
  return !1;
3229
3269
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
3230
- return s !== null && Number.isInteger(n) && n >= 0 && n <= Ht && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3270
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= Ft && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3231
3271
  }
3232
3272
  function v(e, t = {}, s) {
3233
- if (Ar(s))
3273
+ if (br(s))
3234
3274
  return !0;
3235
3275
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3236
3276
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3245,7 +3285,7 @@ function v(e, t = {}, s) {
3245
3285
  return !0;
3246
3286
  }
3247
3287
  }
3248
- function Sr(e, t) {
3288
+ function Rr(e, t) {
3249
3289
  if (v(e))
3250
3290
  return !0;
3251
3291
  try {
@@ -3255,26 +3295,26 @@ function Sr(e, t) {
3255
3295
  return !0;
3256
3296
  }
3257
3297
  }
3258
- function Ar(e) {
3298
+ function br(e) {
3259
3299
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
3260
3300
  }
3261
- function Er(e) {
3301
+ function Mr(e) {
3262
3302
  const t = {};
3263
3303
  for (const s of e.trim().split(/[\r\n]+/)) {
3264
3304
  const n = s.indexOf(":");
3265
3305
  if (n <= 0)
3266
3306
  continue;
3267
- if (Object.keys(t).length >= Ft)
3307
+ if (Object.keys(t).length >= Wt)
3268
3308
  break;
3269
3309
  const r = s.slice(0, n).trim();
3270
- t[r] = Gt(r, s.slice(n + 1).trim());
3310
+ t[r] = Xt(r, s.slice(n + 1).trim());
3271
3311
  }
3272
3312
  return t;
3273
3313
  }
3274
- function P(e, t = Ht) {
3314
+ function P(e, t = Ft) {
3275
3315
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
3276
3316
  }
3277
- function kt(e) {
3317
+ function _t(e) {
3278
3318
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
3279
3319
  }
3280
3320
  class nt extends Error {
@@ -3285,31 +3325,31 @@ class nt extends Error {
3285
3325
  }
3286
3326
  async function tt(e, t) {
3287
3327
  let s = null;
3288
- for (let n = 0; n < ae; n += 1)
3328
+ for (let n = 0; n < le; n += 1)
3289
3329
  try {
3290
3330
  return await e();
3291
3331
  } catch (r) {
3292
- if (s = r, n >= ae - 1 || !br(r))
3332
+ if (s = r, n >= le - 1 || !_r(r))
3293
3333
  throw r;
3294
- await Rr(n);
3334
+ await kr(n);
3295
3335
  }
3296
3336
  throw s instanceof Error ? s : new Error(t);
3297
3337
  }
3298
- function Rr(e) {
3338
+ function kr(e) {
3299
3339
  return new Promise((t) => {
3300
- window.setTimeout(t, _s[e] ?? 0);
3340
+ window.setTimeout(t, Us[e] ?? 0);
3301
3341
  });
3302
3342
  }
3303
- function br(e) {
3304
- return e instanceof nt ? Mr(e.status) : e instanceof TypeError;
3343
+ function _r(e) {
3344
+ return e instanceof nt ? Cr(e.status) : e instanceof TypeError;
3305
3345
  }
3306
- function Mr(e) {
3346
+ function Cr(e) {
3307
3347
  return e === 408 || e === 409 || e === 429 || e >= 500;
3308
3348
  }
3309
- function kr(e) {
3349
+ function Pr(e) {
3310
3350
  return e === 401 || e === 403;
3311
3351
  }
3312
- const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", _r = "[REDACTED_SIGNED_URL]", Cr = 20, Pr = /^(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, He = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Fe = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, We = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, $e = /\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, Ur = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Dr = /\bhttps?:\/\/[^\s"'<>]+/gi, xr = /[),.;\]]+$/;
3352
+ const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", Ur = "[REDACTED_SIGNED_URL]", Dr = 20, Nr = /^(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, We = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, $e = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, je = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ze = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, xr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Or = /\bhttps?:\/\/[^\s"'<>]+/gi, vr = /[),.;\]]+$/;
3313
3353
  function M(e) {
3314
3354
  return rt(e, 0, /* @__PURE__ */ new WeakSet());
3315
3355
  }
@@ -3318,7 +3358,7 @@ function rt(e, t, s) {
3318
3358
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
3319
3359
  if (e === null || typeof e != "object")
3320
3360
  return e;
3321
- if (t >= Cr)
3361
+ if (t >= Dr)
3322
3362
  return "[REDACTED_MAX_DEPTH]";
3323
3363
  if (s.has(e))
3324
3364
  return "[REDACTED_CIRCULAR]";
@@ -3326,44 +3366,44 @@ function rt(e, t, s) {
3326
3366
  return e.map((r) => rt(r, t + 1, s));
3327
3367
  const n = {};
3328
3368
  for (const [r, i] of Object.entries(e))
3329
- r === "pageContent" ? n[r] = i : je(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Nr(i) : rt(i, t + 1, s);
3369
+ r === "pageContent" ? n[r] = i : Ge(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Lr(i) : rt(i, t + 1, s);
3330
3370
  return n;
3331
3371
  }
3332
- function je(e) {
3372
+ function Ge(e) {
3333
3373
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
3334
3374
  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");
3335
3375
  }
3336
- function Nr(e) {
3337
- return typeof e == "string" ? ze(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3376
+ function Lr(e) {
3377
+ return typeof e == "string" ? Xe(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3338
3378
  }
3339
- function ze(e) {
3379
+ function Xe(e) {
3340
3380
  try {
3341
3381
  const t = new URL(e, location.href);
3342
3382
  for (const s of Array.from(t.searchParams.keys()))
3343
- Pr.test(s) && t.searchParams.set(s, U);
3383
+ Nr.test(s) && t.searchParams.set(s, U);
3344
3384
  return t.username && (t.username = U), t.password && (t.password = U), t.toString();
3345
3385
  } catch {
3346
- return Or(e);
3386
+ return qr(e);
3347
3387
  }
3348
3388
  }
3349
3389
  function it(e) {
3350
- return e.replace(Ur, _r).replace(Dr, vr).replace(He, `Bearer ${U}`).replace(Fe, `Basic ${U}`).replace(We, U).replace($e, (t, s) => `${s}: ${ut}`);
3390
+ return e.replace(xr, Ur).replace(Or, Br).replace(We, `Bearer ${U}`).replace($e, `Basic ${U}`).replace(je, U).replace(ze, (t, s) => `${s}: ${ut}`);
3351
3391
  }
3352
- function Or(e) {
3353
- return e.replace(He, `Bearer ${U}`).replace(Fe, `Basic ${U}`).replace(We, U).replace($e, (t, s) => `${s}: ${ut}`);
3392
+ function qr(e) {
3393
+ return e.replace(We, `Bearer ${U}`).replace($e, `Basic ${U}`).replace(je, U).replace(ze, (t, s) => `${s}: ${ut}`);
3354
3394
  }
3355
- function vr(e) {
3356
- const t = e.match(xr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3357
- return `${ze(s)}${t}`;
3395
+ function Br(e) {
3396
+ const t = e.match(vr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3397
+ return `${Xe(s)}${t}`;
3358
3398
  }
3359
3399
  export {
3360
- se as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3361
- Ct as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3362
- ps as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3363
- hs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3364
- fs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3365
- Me as PlunoProductAgent,
3366
- xs as calculateReconnectDelay,
3367
- Me as default,
3368
- sn as getProductAgentOriginAccessErrorMessage
3400
+ ne as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3401
+ Pt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3402
+ gs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3403
+ fs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3404
+ ms as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3405
+ _e as PlunoProductAgent,
3406
+ vs as calculateReconnectDelay,
3407
+ _e as default,
3408
+ on as getProductAgentOriginAccessErrorMessage
3369
3409
  };