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