@pluno/product-agent-web 0.1.146 → 0.1.148

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 Ve = "pluno-product-agent-attachments";
1
+ const Ye = "pluno-product-agent-attachments";
2
2
  const Ct = "files";
3
- async function Ye(e) {
3
+ async function Ze(e) {
4
4
  const t = await qt();
5
- await ts(t, "readwrite", (s) => s.put(e));
5
+ await es(t, "readwrite", (s) => s.put(e));
6
6
  }
7
- async function Ze(e, t) {
7
+ async function Qe(e, t) {
8
8
  const s = await qt();
9
9
  await Bt(s, "readwrite", async (n) => {
10
- const r = await Ht(
10
+ const r = await Ft(
11
11
  n.get(e)
12
12
  );
13
13
  r && n.put({
@@ -16,24 +16,24 @@ async function Ze(e, t) {
16
16
  });
17
17
  });
18
18
  }
19
- async function Qe(e = 864e5) {
19
+ async function ts(e = 864e5) {
20
20
  const t = await qt(), s = Date.now() - e;
21
21
  await Bt(t, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Ht(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await Ft(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
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(Ve, 1);
28
+ const s = indexedDB.open(Ye, 1);
29
29
  s.onupgradeneeded = () => {
30
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 ts(e, t, s) {
36
- return await Bt(e, t, async (n) => await Ht(s(n)));
35
+ async function es(e, t, s) {
36
+ return await Bt(e, t, async (n) => await Ft(s(n)));
37
37
  }
38
38
  function Bt(e, t, s) {
39
39
  return new Promise((n, r) => {
@@ -57,16 +57,16 @@ function Bt(e, t, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Ht(e) {
60
+ function Ft(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 es(e) {
65
+ function ss(e) {
66
66
  return e !== null && (typeof e == "object" || typeof e == "function");
67
67
  }
68
68
  function Re(e, t, s) {
69
- const n = Reflect.get(e, "pluno"), r = es(n) ? n : {};
69
+ const n = Reflect.get(e, "pluno"), r = ss(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,61 @@ function Re(e, t, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const ss = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function ns(e, t) {
83
+ const ns = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function rs(e, t) {
85
85
  return t ? e.replace(
86
- ss,
86
+ ns,
87
87
  (s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
88
88
  ) : e;
89
89
  }
90
- const St = "pluno.productAgent.transportId", rs = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", is = 50, os = globalThis.setTimeout.bind(globalThis);
90
+ function is(e, t, s) {
91
+ const n = t.map((u) => ({ item: u, identity: s(u) })), r = new Set(
92
+ n.flatMap(
93
+ ({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
94
+ )
95
+ ), i = n.filter(
96
+ ({ identity: u }) => !(u.isTransient && u.activityKeys?.some((d) => r.has(d)))
97
+ ), o = new Map(i.map(({ item: u, identity: d }) => [d.id, u])), a = new Map(
98
+ i.flatMap(
99
+ ({ item: u, identity: d }) => d.optimisticKey ? [[d.optimisticKey, u]] : []
100
+ )
101
+ ), c = new Map(
102
+ i.flatMap(
103
+ ({ item: u, identity: d }) => d.assistantDraftKey ? [[d.assistantDraftKey, u]] : []
104
+ )
105
+ ), l = /* @__PURE__ */ new Map();
106
+ for (const { item: u, identity: d } of i)
107
+ for (const p of d.activityKeys ?? []) {
108
+ const m = l.get(p);
109
+ (!m || s(m).isTransient) && l.set(p, u);
110
+ }
111
+ const h = new Set(i.map(({ identity: u }) => u.id)), f = new Set(
112
+ i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
113
+ ), I = /* @__PURE__ */ new Set(), g = [];
114
+ for (const u of e) {
115
+ const d = s(u);
116
+ let p = o.get(d.id);
117
+ if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((E) => l.get(E)).find((E) => E !== void 0) ?? p), p && !I.has(p)) {
118
+ g.push(p), I.add(p);
119
+ continue;
120
+ }
121
+ const m = d.respondsToUserMessageId !== void 0 && h.has(d.respondsToUserMessageId) || d.runId !== void 0 && f.has(d.runId);
122
+ (d.isOptimistic || (d.isAssistantDraft || d.isActivity) && m) && g.push(u);
123
+ }
124
+ for (const { item: u } of i)
125
+ I.has(u) || g.push(u);
126
+ return g;
127
+ }
128
+ function os(e, t, s, n) {
129
+ return e.filter((r) => {
130
+ const i = n(r);
131
+ return !i.isActivity || !i.isTransient ? !0 : t !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== t : s === null || i.runId !== s;
132
+ });
133
+ }
134
+ const St = "pluno.productAgent.transportId", as = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", cs = 50, ls = globalThis.setTimeout.bind(globalThis);
91
135
  let W = null;
92
136
  const et = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Map();
93
- async function as(e = be()) {
137
+ async function us(e = be()) {
94
138
  const t = e.randomUUID(), s = e.storage.getItem(St);
95
139
  let n = s ?? e.randomUUID(), r = !1, i = !1;
96
140
  const o = e.channel.subscribe((c) => {
@@ -126,14 +170,14 @@ async function as(e = be()) {
126
170
  }
127
171
  };
128
172
  }
129
- async function cs() {
130
- W || (W = as(be()), W.then((n) => {
173
+ async function ds() {
174
+ W || (W = us(be()), W.then((n) => {
131
175
  const r = (i) => {
132
176
  i.persisted || (n.release(), W = null, et.clear(), window.removeEventListener("pagehide", r));
133
177
  };
134
178
  window.addEventListener("pagehide", r);
135
179
  }));
136
- const e = await W, t = ls();
180
+ const e = await W, t = hs();
137
181
  et.add(t);
138
182
  let s = !1;
139
183
  return {
@@ -144,7 +188,7 @@ async function cs() {
144
188
  }
145
189
  };
146
190
  }
147
- function ls() {
191
+ function hs() {
148
192
  let e = 0;
149
193
  for (; et.has(e); )
150
194
  e += 1;
@@ -152,13 +196,13 @@ function ls() {
152
196
  }
153
197
  function be() {
154
198
  return {
155
- storage: us(),
156
- channel: ds(),
199
+ storage: ps(),
200
+ channel: fs(),
157
201
  randomUUID: () => crypto.randomUUID(),
158
- settle: () => new Promise((e) => os(e, is))
202
+ settle: () => new Promise((e) => ls(e, cs))
159
203
  };
160
204
  }
161
- function us() {
205
+ function ps() {
162
206
  return {
163
207
  getItem: (e) => {
164
208
  try {
@@ -176,9 +220,9 @@ function us() {
176
220
  }
177
221
  };
178
222
  }
179
- function ds() {
223
+ function fs() {
180
224
  if (typeof BroadcastChannel < "u") {
181
- const e = new BroadcastChannel(rs);
225
+ const e = new BroadcastChannel(as);
182
226
  return {
183
227
  postMessage: (t) => e.postMessage(t),
184
228
  subscribe: (t) => {
@@ -188,9 +232,9 @@ function ds() {
188
232
  close: () => e.close()
189
233
  };
190
234
  }
191
- return hs();
235
+ return gs();
192
236
  }
193
- function hs() {
237
+ function gs() {
194
238
  const e = /* @__PURE__ */ new Set(), t = (s) => {
195
239
  if (s.key !== At || !s.newValue)
196
240
  return;
@@ -211,8 +255,8 @@ function hs() {
211
255
  }
212
256
  };
213
257
  }
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;
258
+ const ms = globalThis.fetch.bind(globalThis), Pt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ys = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Is = ".pluno-pa-widget__panel", Ts = ".pluno-pa-widget__timeline", ne = `${Pt}[data-pluno-sdk-preview-channel]`;
259
+ let ws = 0;
216
260
  function re(e) {
217
261
  const t = {};
218
262
  for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
@@ -238,25 +282,25 @@ function Rt(e, t, s) {
238
282
  source: "web_sdk",
239
283
  category: e,
240
284
  name: t,
241
- sequence: ++ys,
285
+ sequence: ++ws,
242
286
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
243
287
  monotonicMs: performance.now(),
244
288
  data: s
245
289
  };
246
290
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
247
291
  }
248
- 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;
292
+ const Ss = "https://app.pluno.ai", As = "gpt-5.6-terra", Es = 2e4, Rs = 1e4, bs = 1e4, Ms = 1e4, ks = 1e4, _s = 1e3, ie = 3e4, oe = 0.2, ae = 6e4, Cs = 15e3, V = 8, Ps = 15e3, Us = 2e3, Ds = 1e3, vs = 100, ce = 8e3, le = 3, Os = [300, 1e3], Ht = 64e3, bt = 4e3, Wt = 30, Ns = 2e3, xs = 1e3, Me = "Image is too large for model vision input.", Ls = 100, ke = "pluno.productAgent.state.", Ut = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", qs = 100;
249
293
  function Y(e, t = 0) {
250
294
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
251
295
  return Math.max(t, s);
252
296
  }
253
297
  const st = /* @__PURE__ */ new Set();
254
298
  let Z = null;
255
- function vs(e, t = Math.random) {
256
- const s = Math.min(ie, bs * 2 ** e), n = 1 - oe + t() * oe * 2;
299
+ function Bs(e, t = Math.random) {
300
+ const s = Math.min(ie, _s * 2 ** e), n = 1 - oe + t() * oe * 2;
257
301
  return Math.min(ie, Math.round(s * n));
258
302
  }
259
- function Ls(e, t, s) {
303
+ function Fs(e, t, s) {
260
304
  return new Promise((n, r) => {
261
305
  const i = setTimeout(() => r(new Error(s)), t);
262
306
  e.then(
@@ -273,9 +317,9 @@ class _e {
273
317
  constructor(t, s) {
274
318
  this.options = t, this.transportIdentity = s, this.state = {
275
319
  ...this.state,
276
- starterPrompts: In(t.initialStarterPrompts)
320
+ starterPrompts: Sn(t.initialStarterPrompts)
277
321
  };
278
- const n = t.restorePersistedState === !1 ? null : or(t.clientId, t.expectedPersistedSessionId);
322
+ const n = t.restorePersistedState === !1 ? null : lr(t.clientId, t.expectedPersistedSessionId);
279
323
  n && (this.state = {
280
324
  ...this.state,
281
325
  ...n,
@@ -288,9 +332,9 @@ class _e {
288
332
  assistantDraftRunId: null,
289
333
  isThinking: !1,
290
334
  lastError: null
291
- }), this.queuedClientEvents = pr(
292
- cr(t.clientId),
293
- ur(t.clientId)
335
+ }), this.queuedClientEvents = mr(
336
+ dr(t.clientId),
337
+ pr(t.clientId)
294
338
  ), j(t.clientId, this.queuedClientEvents);
295
339
  }
296
340
  options;
@@ -362,15 +406,15 @@ class _e {
362
406
  lastErrorSecuritySettingsUrl: null
363
407
  };
364
408
  static async init(t) {
365
- const s = await cs(), n = new _e({
409
+ const s = await ds(), n = new _e({
366
410
  ...t,
367
- backendUrl: sn(t.backendUrl ?? Is),
368
- clientId: t.clientId ?? En(),
369
- model: t.model ?? Ts,
370
- entrySurface: nn(t.entrySurface)
411
+ backendUrl: on(t.backendUrl ?? Ss),
412
+ clientId: t.clientId ?? Mn(),
413
+ model: t.model ?? As,
414
+ entrySurface: an(t.entrySurface)
371
415
  }, s);
372
416
  try {
373
- Qe().catch((r) => {
417
+ ts().catch((r) => {
374
418
  S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
375
419
  message: r instanceof Error ? r.message : String(r)
376
420
  });
@@ -401,14 +445,14 @@ class _e {
401
445
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
402
446
  );
403
447
  try {
404
- 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")
448
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Fs(this.options.tokenProvider(), bs, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
405
449
  return;
406
450
  if (!this.token && !this.options.webSocketFactory)
407
451
  throw new Error("Pluno requires a token or tokenProvider");
408
- const s = an(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
452
+ const s = un(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
409
453
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
410
454
  this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
411
- }, Es), n.addEventListener("open", () => {
455
+ }, Ms), n.addEventListener("open", () => {
412
456
  this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
413
457
  queuedClientEventCount: this.queuedClientEvents.length,
414
458
  isThinking: this.state.isThinking
@@ -420,9 +464,9 @@ class _e {
420
464
  pageUrl: location.href
421
465
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
422
466
  this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
423
- }, Rs));
467
+ }, ks));
424
468
  }), n.addEventListener("message", (r) => {
425
- this.socket === n && this.handleServerEvent(yn(r.data));
469
+ this.socket === n && this.handleServerEvent(wn(r.data));
426
470
  }), n.addEventListener("close", (r) => {
427
471
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
428
472
  code: typeof r?.code == "number" ? r.code : null,
@@ -455,7 +499,7 @@ class _e {
455
499
  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;
456
500
  }
457
501
  destroy() {
458
- 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 = [];
502
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), yr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
459
503
  for (const t of Object.values(this.listeners))
460
504
  t?.clear();
461
505
  }
@@ -465,22 +509,22 @@ class _e {
465
509
  reason: t,
466
510
  entrySurface: this.options.entrySurface,
467
511
  sessionId: this.state.sessionId ?? void 0,
468
- page: b()
512
+ page: M()
469
513
  };
470
514
  this.sendNow(s) || (this.pendingWarmupEvent = s);
471
515
  }
472
516
  async sendMessage(t, s = {}) {
473
517
  const n = t.trim(), r = s.attachments ?? [];
474
- let i = r.map(Gt);
518
+ let i = r.map(Kt);
475
519
  if (!n && i.length === 0)
476
520
  return null;
477
- const o = b(), a = s.clientMessageId ?? $(), c = {
521
+ const o = M(), a = s.clientMessageId ?? $(), c = {
478
522
  id: `local-${a}`,
479
523
  role: "user",
480
524
  content: n,
481
525
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
482
526
  ...r.length > 0 ? { attachments: r } : {}
483
- }, l = this.state.messages.some((h) => h.id === c.id || h.clientMessageId === a), u = this.state.isThinking, p = this.state.messages, I = l ? this.state.messages : [...this.state.messages, c], m = {
527
+ }, l = this.state.messages.some((p) => p.id === c.id || p.clientMessageId === a), h = this.state.isThinking, f = this.state.messages, I = l ? this.state.messages : [...this.state.messages, c], g = {
484
528
  assistantDraft: this.state.assistantDraft,
485
529
  assistantDraftItemId: this.state.assistantDraftItemId,
486
530
  assistantDraftPhase: this.state.assistantDraftPhase,
@@ -490,7 +534,7 @@ class _e {
490
534
  };
491
535
  this.setState({
492
536
  messages: I,
493
- ...u ? {} : {
537
+ ...h ? {} : {
494
538
  assistantDraft: "",
495
539
  assistantDraftItemId: null,
496
540
  assistantDraftPhase: null,
@@ -501,40 +545,40 @@ class _e {
501
545
  lastError: null
502
546
  }), l || this.emit("message", c);
503
547
  try {
504
- const h = [];
505
- for (const y of i) {
506
- const k = y.id ? this.attachmentFiles.get(y.id) : void 0;
507
- if (y.sandboxPath) {
508
- h.push(y);
548
+ const p = [];
549
+ for (const m of i) {
550
+ const E = m.id ? this.attachmentFiles.get(m.id) : void 0;
551
+ if (m.sandboxPath) {
552
+ p.push(m);
509
553
  continue;
510
554
  }
511
- if (!k)
512
- throw new Error(`Attachment bytes are unavailable for ${y.name}`);
513
- h.push(await this.uploadAttachmentForMessage({ file: k, attachment: y }));
555
+ if (!E)
556
+ throw new Error(`Attachment bytes are unavailable for ${m.name}`);
557
+ p.push(await this.uploadAttachmentForMessage({ file: E, attachment: m }));
514
558
  }
515
- i = h;
516
- } catch (h) {
559
+ i = p;
560
+ } catch (p) {
517
561
  throw this.setState({
518
- ...l ? {} : { messages: p },
519
- ...u ? {} : { ...m, isThinking: !1 }
520
- }), h;
562
+ ...l ? {} : { messages: f },
563
+ ...h ? {} : { ...g, isThinking: !1 }
564
+ }), p;
521
565
  }
522
566
  this.retryableClientMessageId = null;
523
- const d = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, f = {
567
+ const u = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, d = {
524
568
  type: "chat.user_message",
525
569
  sessionId: this.state.sessionId ?? void 0,
526
570
  clientMessageId: a,
527
571
  initiatedBy: s.initiatedBy,
528
- invocation: rn(s.invocation ?? s.initiatedBy),
572
+ invocation: cn(s.invocation ?? s.initiatedBy),
529
573
  entrySurface: this.options.entrySurface,
530
574
  content: n,
531
- pageContent: d && $t() || void 0,
575
+ pageContent: u && $t() || void 0,
532
576
  attachments: i.length > 0 ? i : void 0,
533
577
  page: o,
534
578
  model: this.options.model,
535
579
  metadata: ue(this.options.metadata)
536
580
  };
537
- return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = f, this.markThinkingProgress(), this.send(f), a;
581
+ return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.markThinkingProgress(), this.send(d), a;
538
582
  }
539
583
  retryLastMessage() {
540
584
  const t = this.state.sessionId, s = this.retryableClientMessageId;
@@ -549,13 +593,13 @@ class _e {
549
593
  };
550
594
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
551
595
  const r = Date.now();
552
- return Ye({
596
+ return Ze({
553
597
  attachmentId: s,
554
598
  name: n.name,
555
599
  mimeType: n.mimeType,
556
600
  sizeBytes: n.sizeBytes,
557
601
  blob: t,
558
- origin: b().origin,
602
+ origin: M().origin,
559
603
  sessionId: this.state.sessionId ?? void 0,
560
604
  createdAt: r,
561
605
  lastUsedAt: r
@@ -586,7 +630,7 @@ class _e {
586
630
  name: t.name || "attachment",
587
631
  mimeType: r,
588
632
  sizeBytes: t.size,
589
- page: b(),
633
+ page: M(),
590
634
  model: this.options.model,
591
635
  metadata: ue(this.options.metadata),
592
636
  entrySurface: this.options.entrySurface
@@ -614,8 +658,8 @@ class _e {
614
658
  }, "Failed to upload attachment"), o = c;
615
659
  }
616
660
  this.setState({ sessionId: o.sessionId });
617
- const a = Be(o.attachment, this.options.backendUrl);
618
- return this.updateAttachmentInState(s.id, a), s.id && Ze(s.id, {
661
+ const a = Fe(o.attachment, this.options.backendUrl);
662
+ return this.updateAttachmentInState(s.id, a), s.id && Qe(s.id, {
619
663
  sessionId: o.sessionId,
620
664
  fileUrl: a.fileUrl,
621
665
  sandboxPath: a.sandboxPath,
@@ -645,7 +689,7 @@ class _e {
645
689
  const n = await this.fetchEmbedAttachmentUpload(t);
646
690
  if (n.ok)
647
691
  return await n.json();
648
- if (Pr(n.status) && this.options.tokenProvider && !s) {
692
+ if (vr(n.status) && this.options.tokenProvider && !s) {
649
693
  s = !0;
650
694
  const r = await this.fetchEmbedAttachmentUpload(t);
651
695
  if (r.ok)
@@ -674,7 +718,7 @@ class _e {
674
718
  !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
675
719
  type: "session.reset",
676
720
  sessionId: this.state.sessionId ?? void 0,
677
- page: b()
721
+ page: M()
678
722
  }), this.setState({
679
723
  sessionId: null,
680
724
  starterPrompts: [...this.state.starterPrompts],
@@ -697,7 +741,7 @@ class _e {
697
741
  }), r = {
698
742
  type: "sessions.list",
699
743
  requestId: s,
700
- page: b(),
744
+ page: M(),
701
745
  ...t.cursor ? { cursor: t.cursor } : {},
702
746
  ...t.limit ? { limit: t.limit } : {},
703
747
  ...typeof t.pinned == "boolean" ? { pinned: t.pinned } : {}
@@ -736,11 +780,11 @@ class _e {
736
780
  }), this.send({
737
781
  type: "session.load",
738
782
  sessionId: t,
739
- page: b()
783
+ page: M()
740
784
  });
741
785
  }
742
786
  send(t) {
743
- this.sendNow(M(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
787
+ this.sendNow(k(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
744
788
  }
745
789
  async getUploadToken() {
746
790
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -766,9 +810,9 @@ class _e {
766
810
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
767
811
  return;
768
812
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
769
- const t = cn();
813
+ const t = dn();
770
814
  this.sendNow(
771
- M({
815
+ k({
772
816
  type: "starter_prompts.page_context",
773
817
  pageUrl: t.pageUrl,
774
818
  pageTitle: t.pageTitle,
@@ -777,13 +821,13 @@ class _e {
777
821
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
778
822
  }
779
823
  startStarterPromptUrlWatcher() {
780
- this.locationChangeCleanup || (this.locationChangeCleanup = ln(() => this.handleStarterPromptUrlChange()));
824
+ this.locationChangeCleanup || (this.locationChangeCleanup = hn(() => this.handleStarterPromptUrlChange()));
781
825
  }
782
826
  handleStarterPromptUrlChange() {
783
827
  const t = location.href;
784
828
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
785
829
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
786
- }, Os));
830
+ }, qs));
787
831
  }
788
832
  refreshStarterPromptsForCurrentUrl() {
789
833
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -801,7 +845,7 @@ class _e {
801
845
  j(this.options.clientId, this.queuedClientEvents);
802
846
  for (let s = 0; s < t.length; s += 1) {
803
847
  const n = t[s];
804
- if (!this.sendNow(M(n))) {
848
+ if (!this.sendNow(k(n))) {
805
849
  this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), j(this.options.clientId, this.queuedClientEvents);
806
850
  return;
807
851
  }
@@ -824,23 +868,23 @@ class _e {
824
868
  this.clearHeartbeatAckTimer();
825
869
  return;
826
870
  }
827
- if (Hs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
871
+ if ($s(t) && this.markThinkingProgress(), t.type === "auth.ok") {
828
872
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
829
- const s = Tn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
873
+ const s = An(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
830
874
  S("web-sdk.agent", "Received auth.ok appearance", {
831
875
  hasAppearance: n,
832
876
  rawAppearance: t.appearance,
833
877
  normalizedAppearance: s
834
- }), this.runtimeHelperJavascript = wn(t.runtimeHelpers)?.javascript ?? null;
878
+ }), this.runtimeHelperJavascript = En(t.runtimeHelpers)?.javascript ?? null;
835
879
  const r = pe(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
836
- user: Rn(t.user),
880
+ user: kn(t.user),
837
881
  status: "connected",
838
882
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
839
883
  };
840
- (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({
884
+ (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 && !fn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
841
885
  type: "page.upsert",
842
886
  sessionId: this.state.sessionId,
843
- page: b(),
887
+ page: M(),
844
888
  model: this.options.model
845
889
  });
846
890
  return;
@@ -853,39 +897,39 @@ class _e {
853
897
  return;
854
898
  }
855
899
  if (t.type === "conversation.state") {
856
- const s = Array.isArray(t.items) ? t.items : [], n = Dn(
900
+ const s = Array.isArray(t.items) ? t.items : [], n = Nn(
857
901
  t.assistantDraft
858
902
  ), r = n !== void 0;
859
903
  this.rememberUserMessageClientMessageIds(s);
860
- const i = Kn(s);
904
+ const i = Yn(s);
861
905
  if (i) {
862
- const h = Jn(s, i);
906
+ const p = Zn(s, i);
863
907
  this.retryAttemptsByClientMessageId[i] = Math.max(
864
908
  this.retryAttemptsByClientMessageId[i] ?? 0,
865
- h
909
+ p
866
910
  );
867
911
  }
868
- const o = s.filter((h) => {
869
- const y = q(h);
870
- return !me(y) && (!i || !Ot(y));
871
- }), a = Hn(
912
+ const o = s.filter((p) => {
913
+ const m = q(p);
914
+ return !me(m) && (!i || !Nt(m));
915
+ }), a = jn(
872
916
  this.state.messages,
873
- bn(o, this.options.backendUrl)
917
+ _n(o, this.options.backendUrl)
874
918
  ), c = ge(a), l = !r && s.some(
875
- (h) => Ie(
876
- q(h),
919
+ (p) => Ie(
920
+ q(p),
877
921
  this.state.assistantDraft,
878
922
  this.state.assistantDraftItemId,
879
923
  this.state.assistantDraftRespondsToUserMessageId,
880
924
  this.state.assistantDraftRunId
881
925
  )
882
- ), u = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, I = c && (!u || l), m = zn(a), d = I && m;
883
- if (!c && Xn(this.state.messages, s))
926
+ ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = Xn(a), u = I && g;
927
+ if (!c && Vn(this.state.messages, s))
884
928
  return;
885
- this.lastUserMessagePageUrl = Gn(s);
886
- const f = I ? null : vt(s);
887
- if (this.latestRecoverableClientMessageId = f, m && this.clearRetryTimers(), this.setState({
888
- sessionId: E(t.session, "id") ?? this.state.sessionId,
929
+ this.lastUserMessagePageUrl = Jn(s);
930
+ const d = I ? null : xt(s);
931
+ if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
932
+ sessionId: R(t.session, "id") ?? this.state.sessionId,
889
933
  messages: a,
890
934
  ...r ? {
891
935
  assistantDraft: n?.content ?? "",
@@ -900,31 +944,31 @@ class _e {
900
944
  assistantDraftRespondsToUserMessageId: null,
901
945
  assistantDraftRunId: null
902
946
  } : {},
903
- ...p ? {
947
+ ...f ? {
904
948
  isThinking: !0,
905
949
  lastError: null
906
950
  } : I ? {
907
951
  isThinking: !1,
908
- ...d ? {
952
+ ...u ? {
909
953
  status: "connected",
910
954
  lastError: null,
911
955
  lastErrorCode: null,
912
956
  lastErrorSecuritySettingsUrl: null
913
957
  } : {}
914
- } : f ? {
958
+ } : d ? {
915
959
  isThinking: !0,
916
960
  lastError: null
917
961
  } : {}
918
- }), I ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (p || f) && (f && (this.activeClientMessageId = f), this.markThinkingProgress()), i) {
919
- const h = E(t.session, "id") ?? this.state.sessionId;
920
- h && this.retryAfterInterruptedRun(h, i);
962
+ }), I ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (f || d) && (d && (this.activeClientMessageId = d), this.markThinkingProgress()), i) {
963
+ const p = R(t.session, "id") ?? this.state.sessionId;
964
+ p && this.retryAfterInterruptedRun(p, i);
921
965
  }
922
966
  return;
923
967
  }
924
968
  if (t.type === "sessions.page") {
925
969
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
926
970
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
927
- sessions: Mn(t.sessions),
971
+ sessions: Cn(t.sessions),
928
972
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
929
973
  }));
930
974
  return;
@@ -938,15 +982,15 @@ class _e {
938
982
  return;
939
983
  }
940
984
  if (t.type === "session.updated") {
941
- this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: E(t.session, "id") ?? this.state.sessionId });
985
+ this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: R(t.session, "id") ?? this.state.sessionId });
942
986
  return;
943
987
  }
944
988
  if (t.type === "session.item") {
945
989
  this.rememberUserMessageClientMessageIds([t.item]);
946
990
  const s = q(t.item);
947
- if (Ot(s)) {
991
+ if (Nt(s)) {
948
992
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
949
- 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);
993
+ const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
950
994
  if (r && a) {
951
995
  this.retryAfterInterruptedRun(r, a);
952
996
  return;
@@ -958,19 +1002,19 @@ class _e {
958
1002
  }
959
1003
  if (me(s))
960
1004
  return;
961
- const n = Ne(t.item, this.options.backendUrl);
1005
+ const n = ve(t.item, this.options.backendUrl);
962
1006
  if (n) {
963
1007
  const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
964
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), x(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1008
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), O(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
965
1009
  const i = t.item.data;
966
- Yn(i) && this.clearRunAckResyncRetryTimer();
1010
+ tr(i) && this.clearRunAckResyncRetryTimer();
967
1011
  const o = Dt(this.state.messages, n), a = ge(o), c = Ie(
968
1012
  i,
969
1013
  this.state.assistantDraft,
970
1014
  this.state.assistantDraftItemId,
971
1015
  this.state.assistantDraftRespondsToUserMessageId,
972
1016
  this.state.assistantDraftRunId
973
- ), l = a && (!this.state.assistantDraft || c), u = l && x(n);
1017
+ ), l = a && (!this.state.assistantDraft || c), h = l && O(n);
974
1018
  this.setState({
975
1019
  messages: o,
976
1020
  ...c ? {
@@ -983,7 +1027,7 @@ class _e {
983
1027
  ...l ? {
984
1028
  isThinking: !1
985
1029
  } : {},
986
- ...u ? {
1030
+ ...h ? {
987
1031
  status: "connected",
988
1032
  lastError: null,
989
1033
  lastErrorCode: null,
@@ -995,7 +1039,7 @@ class _e {
995
1039
  }
996
1040
  if (t.type === "chat.assistant_delta") {
997
1041
  this.clearRunAckResyncRetryTimer();
998
- 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;
1042
+ const s = typeof t.delta == "string" ? t.delta : "", n = typeof t.itemId == "string" ? t.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((f) => f.id === o), c = t.phase === "commentary" || t.phase === "final_answer" ? t.phase : r ? null : this.state.assistantDraftPhase, l = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
999
1043
  this.setState({
1000
1044
  messages: Dt(this.state.messages, {
1001
1045
  id: o,
@@ -1005,13 +1049,13 @@ class _e {
1005
1049
  dataType: "assistant_draft",
1006
1050
  ...c ? { phase: c } : {},
1007
1051
  ...l ? { respondsToUserMessageId: l } : {},
1008
- ...u ? { runId: u } : {}
1052
+ ...h ? { runId: h } : {}
1009
1053
  }),
1010
1054
  assistantDraft: i,
1011
1055
  assistantDraftItemId: n ?? this.state.assistantDraftItemId,
1012
1056
  assistantDraftPhase: c,
1013
1057
  assistantDraftRespondsToUserMessageId: l,
1014
- assistantDraftRunId: u,
1058
+ assistantDraftRunId: h,
1015
1059
  isThinking: !0
1016
1060
  }), this.markThinkingProgress(), this.emit("delta", s);
1017
1061
  return;
@@ -1023,16 +1067,26 @@ class _e {
1023
1067
  const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null, r = typeof t.runId == "string" ? t.runId : null;
1024
1068
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
1025
1069
  return;
1026
- const o = [...this.state.messages].reverse().find((c) => c.role === "user")?.id, a = !n || !o || n === o;
1027
- this.setState({
1028
- sessionId: s,
1029
- messages: this.state.messages.filter(
1030
- (c) => c.dataType !== "assistant_draft" || !On(
1031
- c,
1070
+ const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = os(
1071
+ this.state.messages.filter(
1072
+ (l) => l.dataType !== "assistant_draft" || !qn(
1073
+ l,
1032
1074
  n,
1033
1075
  r
1034
1076
  )
1035
1077
  ),
1078
+ n,
1079
+ r,
1080
+ Oe
1081
+ );
1082
+ this.setState({
1083
+ sessionId: s,
1084
+ messages: Bn(
1085
+ c,
1086
+ typeof t.responseId == "string" ? t.responseId : null,
1087
+ n,
1088
+ r
1089
+ ),
1036
1090
  assistantDraft: "",
1037
1091
  assistantDraftItemId: null,
1038
1092
  assistantDraftPhase: null,
@@ -1048,9 +1102,9 @@ class _e {
1048
1102
  if (s)
1049
1103
  this.nonTranscriptToolCallIds.add(s);
1050
1104
  else {
1051
- const n = qn(t);
1105
+ const n = Wn(t);
1052
1106
  if (n) {
1053
- const r = vn(
1107
+ const r = Fn(
1054
1108
  this.state.messages,
1055
1109
  n
1056
1110
  );
@@ -1094,7 +1148,7 @@ class _e {
1094
1148
  return;
1095
1149
  }
1096
1150
  o && r && i && (this.retryableClientMessageId = i);
1097
- const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = on(a.message);
1151
+ const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = ln(a.message);
1098
1152
  c && console.error(c), this.setState({
1099
1153
  status: "error",
1100
1154
  isThinking: !1,
@@ -1159,7 +1213,7 @@ class _e {
1159
1213
  }
1160
1214
  rememberUserMessageClientMessageIds(t) {
1161
1215
  for (const s of t) {
1162
- const n = E(s, "id"), r = q(s);
1216
+ const n = R(s, "id"), r = q(s);
1163
1217
  n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
1164
1218
  }
1165
1219
  }
@@ -1215,7 +1269,7 @@ class _e {
1215
1269
  handleRunSteered(t) {
1216
1270
  const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
1217
1271
  !this.state.isThinking || !s || this.setState({
1218
- messages: Qn(
1272
+ messages: sr(
1219
1273
  this.state.messages,
1220
1274
  s
1221
1275
  )
@@ -1224,7 +1278,7 @@ class _e {
1224
1278
  scheduleRunAckWatchdog(t) {
1225
1279
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1226
1280
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1227
- }, ks);
1281
+ }, Ps);
1228
1282
  }
1229
1283
  recoverMissedRunAck(t) {
1230
1284
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
@@ -1249,7 +1303,7 @@ class _e {
1249
1303
  clientMessageId: t,
1250
1304
  automatic: !0
1251
1305
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ae)));
1252
- }, Y(s, _s)));
1306
+ }, Y(s, Us)));
1253
1307
  }
1254
1308
  clearRunAckResyncRetryTimer() {
1255
1309
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1288,7 +1342,7 @@ class _e {
1288
1342
  sessionId: this.state.sessionId,
1289
1343
  clientMessageId: t,
1290
1344
  resyncAttempts: s + 1
1291
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ms);
1345
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Cs);
1292
1346
  return;
1293
1347
  }
1294
1348
  this.setState({
@@ -1312,7 +1366,7 @@ class _e {
1312
1366
  this.state.sessionId ? this.send({
1313
1367
  type: "page.upsert",
1314
1368
  sessionId: this.state.sessionId,
1315
- page: b(),
1369
+ page: M(),
1316
1370
  model: this.options.model
1317
1371
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
1318
1372
  }
@@ -1323,15 +1377,15 @@ class _e {
1323
1377
  if (!s || !n || !r)
1324
1378
  return;
1325
1379
  const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1326
- if (!a && !c || !Ir(o)) {
1380
+ if (!a && !c || !Sr(o)) {
1327
1381
  this.setToolMessageLoading(n, !1), this.send({
1328
1382
  type: "tool.result",
1329
1383
  sessionId: s,
1330
1384
  callId: n,
1331
1385
  toolName: r,
1332
1386
  summary: i,
1333
- rawInput: M(o),
1334
- rawOutput: M({
1387
+ rawInput: k(o),
1388
+ rawOutput: k({
1335
1389
  ok: !1,
1336
1390
  toolName: r,
1337
1391
  error: `Unsupported browser tool: ${r}`
@@ -1346,7 +1400,7 @@ class _e {
1346
1400
  callId: n,
1347
1401
  toolName: r,
1348
1402
  summary: i,
1349
- rawInput: M(o),
1403
+ rawInput: k(o),
1350
1404
  rawOutput: {
1351
1405
  ok: !1,
1352
1406
  toolName: r,
@@ -1355,7 +1409,7 @@ class _e {
1355
1409
  });
1356
1410
  return;
1357
1411
  }
1358
- const l = $s(this.state.messages);
1412
+ const l = Ks(this.state.messages);
1359
1413
  this.activeBrowserToolCalls.set(n, {
1360
1414
  event: {
1361
1415
  type: "tool.result",
@@ -1363,17 +1417,17 @@ class _e {
1363
1417
  callId: n,
1364
1418
  toolName: r,
1365
1419
  summary: i,
1366
- rawInput: M(o),
1420
+ rawInput: k(o),
1367
1421
  rawOutput: null
1368
1422
  },
1369
1423
  startedAtMs: Date.now(),
1370
1424
  startedAtUrl: location.href,
1371
1425
  startedAtOrigin: location.origin
1372
1426
  }), this.installSessionUserFilesApi(l);
1373
- let u = null, p;
1374
- u = await this.executeRuntimeHelper(), p = await de(
1427
+ let h = null, f;
1428
+ h = await this.executeRuntimeHelper(), f = await de(
1375
1429
  o,
1376
- tn(t.runtimeContext, this.options.backendUrl)
1430
+ nn(t.runtimeContext, this.options.backendUrl)
1377
1431
  ).catch((I) => ({
1378
1432
  ok: !1,
1379
1433
  exception: {
@@ -1385,12 +1439,12 @@ class _e {
1385
1439
  callId: n,
1386
1440
  toolName: r,
1387
1441
  summary: o.summary,
1388
- rawInput: M(o),
1389
- rawOutput: M(Sn(p, u))
1390
- }), lr(this.options.clientId, this.activeBrowserToolCalls.values());
1442
+ rawInput: k(o),
1443
+ rawOutput: k(Rn(f, h))
1444
+ }), hr(this.options.clientId, this.activeBrowserToolCalls.values());
1391
1445
  }
1392
1446
  setToolMessageLoading(t, s) {
1393
- const n = Ln(
1447
+ const n = Hn(
1394
1448
  this.state.messages,
1395
1449
  t,
1396
1450
  s
@@ -1401,17 +1455,17 @@ class _e {
1401
1455
  if (this.pageLifecycleCleanup)
1402
1456
  return;
1403
1457
  const t = () => {
1404
- Le(this.options.clientId, this.activeBrowserToolCalls.values());
1458
+ qe(this.options.clientId, this.activeBrowserToolCalls.values());
1405
1459
  };
1406
1460
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1407
1461
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1408
1462
  };
1409
1463
  }
1410
1464
  installSessionUserFilesApi(t) {
1411
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = js(t, this.attachmentFiles, this.attachmentBlobCache);
1465
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Gs(t, this.attachmentFiles, this.attachmentBlobCache);
1412
1466
  }
1413
1467
  cleanupSessionUserFilesApi() {
1414
- this.sessionUserFilesApiCleanup && (Zs(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1468
+ this.sessionUserFilesApiCleanup && (en(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1415
1469
  }
1416
1470
  async executeRuntimeHelper() {
1417
1471
  if (!this.runtimeHelperJavascript?.trim())
@@ -1419,29 +1473,29 @@ class _e {
1419
1473
  const t = await de({
1420
1474
  javascript: this.runtimeHelperJavascript
1421
1475
  });
1422
- return t.ok === !1 ? An(t) : null;
1476
+ return t.ok === !1 ? bn(t) : null;
1423
1477
  }
1424
1478
  enableNetworkCapture() {
1425
- this.networkCaptureCleanup || (this.networkCaptureCleanup = qs((t) => {
1426
- Rr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1479
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = Hs((t) => {
1480
+ kr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1427
1481
  }));
1428
1482
  }
1429
1483
  enqueueNetworkEvent(t) {
1430
- this.queuedNetworkEvents.length >= Ps || (this.queuedNetworkEvents.push(Er(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1484
+ this.queuedNetworkEvents.length >= vs || (this.queuedNetworkEvents.push(Mr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1431
1485
  this.networkBatchTimer = null;
1432
1486
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1433
1487
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
1434
1488
  type: "network.batch",
1435
1489
  sessionId: this.state.sessionId ?? void 0,
1436
- page: b(),
1490
+ page: M(),
1437
1491
  events: s
1438
1492
  });
1439
- }, Cs)));
1493
+ }, Ds)));
1440
1494
  }
1441
1495
  scheduleReconnect() {
1442
1496
  if (this.reconnectTimer !== null || this.state.status === "closed")
1443
1497
  return;
1444
- const t = vs(this.reconnectAttempts);
1498
+ const t = Bs(this.reconnectAttempts);
1445
1499
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1446
1500
  this.reconnectTimer = null, this.connect().catch((s) => {
1447
1501
  S("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1457,8 +1511,8 @@ class _e {
1457
1511
  const t = this.socket;
1458
1512
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1459
1513
  this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1460
- }, Ss));
1461
- }, ws);
1514
+ }, Rs));
1515
+ }, Es);
1462
1516
  }
1463
1517
  stopHeartbeat() {
1464
1518
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1484,7 +1538,7 @@ class _e {
1484
1538
  ...t,
1485
1539
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1486
1540
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1487
- }, ar(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
1541
+ }, ur(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
1488
1542
  status: this.state.status,
1489
1543
  sessionId: this.state.sessionId,
1490
1544
  messageCount: this.state.messages.length,
@@ -1502,98 +1556,98 @@ class _e {
1502
1556
  }
1503
1557
  }
1504
1558
  const Mt = /* @__PURE__ */ new WeakMap();
1505
- function qs(e) {
1506
- const t = window.__plunoProductAgentNetworkCapture ?? Bs();
1559
+ function Hs(e) {
1560
+ const t = window.__plunoProductAgentNetworkCapture ?? Ws();
1507
1561
  return t.subscribers.add(e), () => {
1508
1562
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1509
1563
  };
1510
1564
  }
1511
- function Bs() {
1565
+ function Ws() {
1512
1566
  const e = /* @__PURE__ */ new Set(), t = (I) => {
1513
- e.forEach((m) => {
1567
+ e.forEach((g) => {
1514
1568
  try {
1515
- m(I);
1569
+ g(I);
1516
1570
  } catch {
1517
1571
  }
1518
1572
  });
1519
- }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(m, d) {
1520
- const f = Date.now();
1521
- let h;
1573
+ }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(g, u) {
1574
+ const d = Date.now();
1575
+ let p;
1522
1576
  try {
1523
- h = s.call(this, m, d);
1524
- } catch (y) {
1525
- throw y;
1577
+ p = s.call(this, g, u);
1578
+ } catch (m) {
1579
+ throw m;
1526
1580
  }
1527
1581
  try {
1528
- const y = m instanceof Request ? m : null, k = Tr(m, y), T = He(d?.headers ?? y?.headers);
1529
- if (!v(k, T, d?.body)) {
1530
- const H = {
1582
+ const m = g instanceof Request ? g : null, E = Ar(g, m), T = He(u?.headers ?? m?.headers);
1583
+ if (!x(E, T, u?.body)) {
1584
+ const F = {
1531
1585
  requestId: _t("fetch"),
1532
- url: P(k, bt),
1533
- method: (d?.method ?? y?.method ?? "GET").toUpperCase(),
1586
+ url: P(E, bt),
1587
+ method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
1534
1588
  requestHeaders: T,
1535
- requestBody: Ae(d?.body),
1589
+ requestBody: Ae(u?.body),
1536
1590
  resourceType: "fetch",
1537
- startedAt: new Date(f).toISOString()
1591
+ startedAt: new Date(d).toISOString()
1538
1592
  };
1539
- h.then(
1593
+ p.then(
1540
1594
  (_) => {
1541
- wr(_, H, f, t).catch(() => {
1595
+ Er(_, F, d, t).catch(() => {
1542
1596
  t({
1543
- ...H,
1597
+ ...F,
1544
1598
  responseStatus: _.status,
1545
- durationMs: Date.now() - f
1599
+ durationMs: Date.now() - d
1546
1600
  });
1547
1601
  });
1548
1602
  },
1549
1603
  (_) => {
1550
1604
  t({
1551
- ...H,
1605
+ ...F,
1552
1606
  errorText: P(_ instanceof Error ? _.message : String(_)),
1553
- durationMs: Date.now() - f
1607
+ durationMs: Date.now() - d
1554
1608
  });
1555
1609
  }
1556
1610
  );
1557
1611
  }
1558
1612
  } catch {
1559
1613
  }
1560
- return h;
1561
- }, a = function(m, d, f, h, y) {
1562
- const k = n.call(this, m, d, f ?? !0, h ?? void 0, y ?? void 0), T = typeof d == "string" ? d : d.toString();
1614
+ return p;
1615
+ }, a = function(g, u, d, p, m) {
1616
+ const E = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
1563
1617
  return Mt.set(this, {
1564
1618
  requestId: _t("xhr"),
1565
- method: String(m ?? "GET").toUpperCase(),
1619
+ method: String(g ?? "GET").toUpperCase(),
1566
1620
  url: P(T, bt),
1567
1621
  requestHeaders: {},
1568
1622
  startedAtMs: Date.now(),
1569
1623
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1570
- excluded: v(T)
1571
- }), k;
1572
- }, c = function(m, d) {
1573
- const f = r.call(this, m, d), h = Mt.get(this);
1574
- return h && Object.keys(h.requestHeaders).length < Wt && (h.requestHeaders[m] = Xt(m, d), h.excluded = h.excluded || v(h.url, h.requestHeaders)), f;
1575
- }, l = function(m) {
1624
+ excluded: x(T)
1625
+ }), E;
1626
+ }, c = function(g, u) {
1627
+ const d = r.call(this, g, u), p = Mt.get(this);
1628
+ return p && Object.keys(p.requestHeaders).length < Wt && (p.requestHeaders[g] = Gt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1629
+ }, l = function(g) {
1576
1630
  try {
1577
- const d = Mt.get(this);
1578
- d && (d.excluded = d.excluded || v(d.url, d.requestHeaders, m), d.requestBody = Ae(m), d.excluded || this.addEventListener(
1631
+ const u = Mt.get(this);
1632
+ u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody = Ae(g), u.excluded || this.addEventListener(
1579
1633
  "loadend",
1580
1634
  () => {
1581
1635
  queueMicrotask(() => {
1582
1636
  try {
1583
- const f = Mr(this.getAllResponseHeaders());
1637
+ const d = Cr(this.getAllResponseHeaders());
1584
1638
  t({
1585
- requestId: d.requestId,
1586
- url: d.url,
1587
- method: d.method,
1588
- requestHeaders: d.requestHeaders,
1589
- requestBody: d.requestBody,
1639
+ requestId: u.requestId,
1640
+ url: u.url,
1641
+ method: u.method,
1642
+ requestHeaders: u.requestHeaders,
1643
+ requestBody: u.requestBody,
1590
1644
  resourceType: "xhr",
1591
1645
  responseStatus: this.status,
1592
- responseHeaders: f,
1593
- responseBody: Ar(this, f),
1646
+ responseHeaders: d,
1647
+ responseBody: br(this, d),
1594
1648
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1595
- startedAt: d.startedAt,
1596
- durationMs: Date.now() - d.startedAtMs
1649
+ startedAt: u.startedAt,
1650
+ durationMs: Date.now() - u.startedAtMs
1597
1651
  });
1598
1652
  } catch {
1599
1653
  return;
@@ -1604,7 +1658,7 @@ function Bs() {
1604
1658
  ));
1605
1659
  } catch {
1606
1660
  }
1607
- return i.call(this, m ?? null);
1661
+ return i.call(this, g ?? null);
1608
1662
  };
1609
1663
  try {
1610
1664
  window.fetch = o;
@@ -1622,35 +1676,35 @@ function Bs() {
1622
1676
  XMLHttpRequest.prototype.send = l;
1623
1677
  } catch {
1624
1678
  }
1625
- let u = null;
1679
+ let h = null;
1626
1680
  if (typeof PerformanceObserver < "u") {
1627
- u = new PerformanceObserver((I) => {
1628
- for (const m of I.getEntries()) {
1629
- const d = m;
1630
- if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || v(d.name))
1681
+ h = new PerformanceObserver((I) => {
1682
+ for (const g of I.getEntries()) {
1683
+ const u = g;
1684
+ if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || x(u.name))
1631
1685
  continue;
1632
- const f = performance.timeOrigin + d.startTime;
1686
+ const d = performance.timeOrigin + u.startTime;
1633
1687
  t({
1634
1688
  requestId: _t("resource"),
1635
- url: P(d.name, bt),
1689
+ url: P(u.name, bt),
1636
1690
  method: "GET",
1637
1691
  resourceType: "resource",
1638
- responseStatus: d.responseStatus,
1639
- startedAt: new Date(f).toISOString(),
1640
- durationMs: d.duration
1692
+ responseStatus: u.responseStatus,
1693
+ startedAt: new Date(d).toISOString(),
1694
+ durationMs: u.duration
1641
1695
  });
1642
1696
  }
1643
1697
  });
1644
1698
  try {
1645
- u.observe({ type: "resource", buffered: !0 });
1699
+ h.observe({ type: "resource", buffered: !0 });
1646
1700
  } catch {
1647
- u.disconnect(), u = null;
1701
+ h.disconnect(), h = null;
1648
1702
  }
1649
1703
  }
1650
- const p = {
1704
+ const f = {
1651
1705
  subscribers: e,
1652
1706
  destroy: () => {
1653
- u?.disconnect();
1707
+ h?.disconnect();
1654
1708
  try {
1655
1709
  window.fetch === o && (window.fetch = s);
1656
1710
  } catch {
@@ -1669,7 +1723,7 @@ function Bs() {
1669
1723
  }
1670
1724
  }
1671
1725
  };
1672
- return window.__plunoProductAgentNetworkCapture = p, p;
1726
+ return window.__plunoProductAgentNetworkCapture = f, f;
1673
1727
  }
1674
1728
  function S(e, t, s) {
1675
1729
  if (typeof window > "u")
@@ -1686,11 +1740,11 @@ function ue(e) {
1686
1740
  const t = typeof e == "function" ? e() : e;
1687
1741
  return t && Object.keys(t).length > 0 ? t : void 0;
1688
1742
  }
1689
- function Hs(e) {
1743
+ function $s(e) {
1690
1744
  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";
1691
1745
  }
1692
- const Fs = 5e3, Ws = 12e4;
1693
- function $s(e) {
1746
+ const js = 5e3, zs = 12e4;
1747
+ function Ks(e) {
1694
1748
  const t = [];
1695
1749
  for (const s of e)
1696
1750
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1701,26 +1755,26 @@ function $s(e) {
1701
1755
  });
1702
1756
  return t;
1703
1757
  }
1704
- function js(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1758
+ function Gs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1705
1759
  const n = [
1706
- Gs(),
1707
- zs()
1760
+ Js(),
1761
+ Xs()
1708
1762
  ].filter((r) => typeof r == "function");
1709
1763
  return () => {
1710
1764
  for (const r of n.reverse())
1711
1765
  r();
1712
1766
  };
1713
1767
  }
1714
- function zs() {
1768
+ function Xs() {
1715
1769
  return Re(globalThis, "getPageSnapshot", async () => $t());
1716
1770
  }
1717
- function Gs() {
1771
+ function Js() {
1718
1772
  return Re(globalThis, "pageImages", {
1719
- inspectImage: async (t, s) => await Xs(t, s)
1773
+ inspectImage: async (t, s) => await Vs(t, s)
1720
1774
  });
1721
1775
  }
1722
- async function Xs(e, t = {}) {
1723
- const s = Ys(t.name), n = await Ks(e);
1776
+ async function Vs(e, t = {}) {
1777
+ const s = tn(t.name), n = await Ys(e);
1724
1778
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1725
1779
  type: "pluno.pageImages.inspectImage",
1726
1780
  imageAttached: !1,
@@ -1738,15 +1792,15 @@ async function Xs(e, t = {}) {
1738
1792
  imageAttachmentError: n.error
1739
1793
  };
1740
1794
  }
1741
- async function Ks(e) {
1795
+ async function Ys(e) {
1742
1796
  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 } : {
1743
1797
  ok: !0,
1744
1798
  mimeType: e.type,
1745
1799
  sizeBytes: e.size,
1746
- dataUrl: await Qs(e)
1747
- } : { 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);
1800
+ dataUrl: await sn(e)
1801
+ } : { 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." } : Zs(e);
1748
1802
  }
1749
- function Js(e) {
1803
+ function Zs(e) {
1750
1804
  if (!e.startsWith("data:") || !e.includes(","))
1751
1805
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1752
1806
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1757,7 +1811,7 @@ function Js(e) {
1757
1811
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1758
1812
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1759
1813
  return { ok: !1, error: "Page image data URL has invalid base64." };
1760
- const o = Vs(i);
1814
+ const o = Qs(i);
1761
1815
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1762
1816
  ok: !0,
1763
1817
  mimeType: r,
@@ -1765,22 +1819,22 @@ function Js(e) {
1765
1819
  dataUrl: `data:${r};base64,${i}`
1766
1820
  };
1767
1821
  }
1768
- function Vs(e) {
1822
+ function Qs(e) {
1769
1823
  if (e.length === 0 || e.length % 4 !== 0)
1770
1824
  return null;
1771
1825
  const t = e.length - e.replace(/=+$/, "").length;
1772
1826
  return t > 2 ? null : e.length / 4 * 3 - t;
1773
1827
  }
1774
- function Ys(e) {
1828
+ function tn(e) {
1775
1829
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1776
1830
  }
1777
- function Zs(e) {
1831
+ function en(e) {
1778
1832
  try {
1779
1833
  e();
1780
1834
  } catch {
1781
1835
  }
1782
1836
  }
1783
- function Qs(e) {
1837
+ function sn(e) {
1784
1838
  return new Promise((t, s) => {
1785
1839
  const n = new FileReader();
1786
1840
  n.onload = () => {
@@ -1794,27 +1848,27 @@ function Qs(e) {
1794
1848
  }
1795
1849
  async function de(e, t) {
1796
1850
  const s = Object.getPrototypeOf(async function() {
1797
- }).constructor, n = e.timeoutMs ?? Fs, r = Date.now(), i = [];
1851
+ }).constructor, n = e.timeoutMs ?? js, r = Date.now(), i = [];
1798
1852
  let o;
1799
1853
  const a = {
1800
1854
  log: console.log,
1801
1855
  info: console.info,
1802
1856
  warn: console.warn,
1803
1857
  error: console.error
1804
- }, c = (l) => (...u) => {
1805
- i.push({ level: l, args: u }), a[l](...u);
1858
+ }, c = (l) => (...h) => {
1859
+ i.push({ level: l, args: h }), a[l](...h);
1806
1860
  };
1807
1861
  console.log = c("log"), console.info = c("info"), console.warn = c("warn"), console.error = c("error");
1808
1862
  try {
1809
- const l = /* @__PURE__ */ Symbol("execute_code_timeout"), u = await Promise.race([
1863
+ const l = /* @__PURE__ */ Symbol("execute_code_timeout"), h = await Promise.race([
1810
1864
  new s("sandboxFiles", e.javascript)(t?.value),
1811
- new Promise((p) => {
1812
- o = window.setTimeout(() => p(l), n);
1865
+ new Promise((f) => {
1866
+ o = window.setTimeout(() => f(l), n);
1813
1867
  })
1814
1868
  ]);
1815
- return u === l ? en(n) : {
1869
+ return h === l ? rn(n) : {
1816
1870
  ok: !0,
1817
- result: u,
1871
+ result: h,
1818
1872
  console: i,
1819
1873
  metadata: {
1820
1874
  durationMs: Date.now() - r,
@@ -1841,7 +1895,7 @@ async function de(e, t) {
1841
1895
  t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
1842
1896
  }
1843
1897
  }
1844
- function tn(e, t) {
1898
+ function nn(e, t) {
1845
1899
  if (!e || typeof e != "object")
1846
1900
  return;
1847
1901
  const s = e.sandboxFilesToken;
@@ -1851,20 +1905,20 @@ function tn(e, t) {
1851
1905
  const r = () => {
1852
1906
  if (!n)
1853
1907
  throw new Error("sandboxFiles is only available during browser-code execution");
1854
- }, i = async (a, c) => await ps(`${t.replace(/\/$/, "")}${a}`, c);
1908
+ }, i = async (a, c) => await ms(`${t.replace(/\/$/, "")}${a}`, c);
1855
1909
  return {
1856
1910
  value: Object.freeze({
1857
1911
  upload: async (a) => {
1858
1912
  if (r(), !(a instanceof Blob))
1859
1913
  throw new TypeError("sandboxFiles.upload expects a File or Blob");
1860
- const c = a instanceof File && a.name ? a.name : "file", l = `?name=${encodeURIComponent(c)}&size_bytes=${a.size}`, u = await i(`/api/product-agent/attachments/sandbox-files${l}`, {
1914
+ const c = a instanceof File && a.name ? a.name : "file", l = `?name=${encodeURIComponent(c)}&size_bytes=${a.size}`, h = await i(`/api/product-agent/attachments/sandbox-files${l}`, {
1861
1915
  method: "PUT",
1862
1916
  headers: { Authorization: `Bearer ${s}` },
1863
1917
  body: a
1864
1918
  });
1865
- if (!u.ok)
1866
- throw new Error(`sandboxFiles.upload failed (${u.status})`);
1867
- return String((await u.json()).path);
1919
+ if (!h.ok)
1920
+ throw new Error(`sandboxFiles.upload failed (${h.status})`);
1921
+ return String((await h.json()).path);
1868
1922
  },
1869
1923
  download: async (a) => {
1870
1924
  r();
@@ -1874,8 +1928,8 @@ function tn(e, t) {
1874
1928
  );
1875
1929
  if (!c.ok)
1876
1930
  throw new Error(`sandboxFiles.download failed (${c.status})`);
1877
- const l = await c.blob(), p = (c.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
1878
- return new File([l], p || a.split("/").pop() || "file", {
1931
+ const l = await c.blob(), f = (c.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
1932
+ return new File([l], f || a.split("/").pop() || "file", {
1879
1933
  type: l.type
1880
1934
  });
1881
1935
  }
@@ -1885,7 +1939,7 @@ function tn(e, t) {
1885
1939
  }
1886
1940
  };
1887
1941
  }
1888
- function en(e) {
1942
+ function rn(e) {
1889
1943
  return {
1890
1944
  ok: !1,
1891
1945
  exception: {
@@ -1899,10 +1953,10 @@ function en(e) {
1899
1953
  }
1900
1954
  };
1901
1955
  }
1902
- function sn(e) {
1956
+ function on(e) {
1903
1957
  return e.replace(/\/+$/, "");
1904
1958
  }
1905
- function nn(e) {
1959
+ function an(e) {
1906
1960
  const t = {
1907
1961
  sidepanel: "extension_sidepanel",
1908
1962
  browser_extension_page_ui: "extension_widget",
@@ -1914,17 +1968,17 @@ function nn(e) {
1914
1968
  };
1915
1969
  return e && e in t ? t[e] : e ?? "embedded_custom_ui";
1916
1970
  }
1917
- function rn(e) {
1971
+ function cn(e) {
1918
1972
  return e === "pluno" ? "scheduled_continuation" : e ?? "user";
1919
1973
  }
1920
- function on(e, t = location.origin) {
1974
+ function ln(e, t = location.origin) {
1921
1975
  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;
1922
1976
  }
1923
- function an(e) {
1977
+ function un(e) {
1924
1978
  const t = new URL("/api/product-agent/embed/ws", e);
1925
1979
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1926
1980
  }
1927
- function b() {
1981
+ function M() {
1928
1982
  const e = De();
1929
1983
  return {
1930
1984
  url: location.href,
@@ -1933,19 +1987,19 @@ function b() {
1933
1987
  ...e ? { plunoProductAgentUi: e } : {}
1934
1988
  };
1935
1989
  }
1936
- function cn() {
1990
+ function dn() {
1937
1991
  return {
1938
1992
  pageUrl: location.href,
1939
1993
  pageTitle: document.title,
1940
1994
  htmlContent: $t()
1941
1995
  };
1942
1996
  }
1943
- function ln(e) {
1944
- return st.add(e), Z || (Z = un()), () => {
1997
+ function hn(e) {
1998
+ return st.add(e), Z || (Z = pn()), () => {
1945
1999
  st.delete(e), st.size === 0 && (Z?.(), Z = null);
1946
2000
  };
1947
2001
  }
1948
- function un() {
2002
+ function pn() {
1949
2003
  const e = () => {
1950
2004
  for (const i of Array.from(st))
1951
2005
  i();
@@ -1960,33 +2014,33 @@ function un() {
1960
2014
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
1961
2015
  };
1962
2016
  }
1963
- function dn() {
2017
+ function fn() {
1964
2018
  return De()?.surface === "browser_extension_sdk_preview";
1965
2019
  }
1966
2020
  function $t() {
1967
2021
  if (!document.body)
1968
2022
  return "";
1969
- const e = [], t = [], s = (f, h) => {
1970
- const y = B(h);
1971
- !y || t.includes(y) || (e.push([f, y]), t.push(y));
2023
+ const e = [], t = [], s = (d, p) => {
2024
+ const m = B(p);
2025
+ !m || t.includes(m) || (e.push([d, m]), t.push(m));
1972
2026
  };
1973
2027
  s("Selected text", window.getSelection()?.toString() ?? "");
1974
2028
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
1975
- (f) => Ce(f) && !f.parentElement?.closest(n)
2029
+ (d) => Ce(d) && !d.parentElement?.closest(n)
1976
2030
  );
1977
- for (const f of r.slice(0, 3))
1978
- s("Active overlay", kt(z(f), t));
1979
- const i = hn(), o = i ? kt(z(i), t) : "";
2031
+ for (const d of r.slice(0, 3))
2032
+ s("Active overlay", kt(z(d), t));
2033
+ const i = gn(), o = i ? kt(z(i), t) : "";
1980
2034
  s("Main page content", o), s("Additional visible page text", kt(z(document.body), t));
1981
- const a = e.map(([f, h]) => `${f}:
1982
- ${h}`).join(`
2035
+ const a = e.map(([d, p]) => `${d}:
2036
+ ${p}`).join(`
1983
2037
 
1984
- `).trim().slice(0, 12e3), c = pn(r, i).trim(), l = `Simplified DOM outline:
1985
- `, u = `
2038
+ `).trim().slice(0, 12e3), c = mn(r, i).trim(), l = `Simplified DOM outline:
2039
+ `, h = `
1986
2040
 
1987
2041
  Visible page text:
1988
- `, p = 12e3 - l.length - u.length, I = Math.min(a.length, 7900), m = c.slice(0, p - I), d = a.slice(0, p - m.length);
1989
- return `${l}${m}${u}${d}`;
2042
+ `, f = 12e3 - l.length - h.length, I = Math.min(a.length, 7900), g = c.slice(0, f - I), u = a.slice(0, f - g.length);
2043
+ return `${l}${g}${h}${u}`;
1990
2044
  }
1991
2045
  function z(e) {
1992
2046
  return e.innerText ?? e.textContent ?? "";
@@ -2009,10 +2063,10 @@ function Ce(e) {
2009
2063
  const t = window.getComputedStyle(e);
2010
2064
  return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
2011
2065
  }
2012
- function hn() {
2066
+ function gn() {
2013
2067
  return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ce).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
2014
2068
  }
2015
- function pn(e, t) {
2069
+ function mn(e, t) {
2016
2070
  const s = /* @__PURE__ */ new Set([
2017
2071
  "main",
2018
2072
  "nav",
@@ -2092,84 +2146,84 @@ function pn(e, t) {
2092
2146
  "data-test",
2093
2147
  "data-qa",
2094
2148
  "data-cy"
2095
- ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: p } = fn(), I = new Set(e);
2149
+ ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = yn(), I = new Set(e);
2096
2150
  t && I.add(t);
2097
- let m = 0;
2098
- const d = (T) => {
2151
+ let g = 0;
2152
+ const u = (T) => {
2099
2153
  const D = T.getAttribute("role");
2100
2154
  return D && !o.has(D) ? D : "";
2101
- }, f = (T) => {
2155
+ }, d = (T) => {
2102
2156
  const D = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
2103
- return `${T.tagName.toLowerCase()}|${d(T)}|${D}`;
2104
- }, h = (T, D, H) => {
2157
+ return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
2158
+ }, p = (T, D, F) => {
2105
2159
  const _ = (A, dt) => {
2106
- const R = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), G = u.has(A);
2107
- 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")
2160
+ const b = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
2161
+ if (g >= 1e3 && !K || F.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
2108
2162
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2109
- m += 1;
2110
- 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();
2111
- for (const g of pt) {
2112
- const w = f(g);
2113
- K.set(w, (K.get(w) ?? 0) + 1);
2163
+ g += 1;
2164
+ const Xt = u(A), G = Ue(A), Je = a.has(Xt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
2165
+ for (const y of pt) {
2166
+ const w = d(y);
2167
+ X.set(w, (X.get(w) ?? 0) + 1);
2114
2168
  }
2115
2169
  const ft = /* @__PURE__ */ new Map(), Jt = /* @__PURE__ */ new Map();
2116
- for (const g of pt) {
2117
- const w = f(g), N = Jt.get(w) ?? 0;
2118
- Jt.set(w, N + 1), (K.get(w) ?? 0) > 8 && N >= 6 && !u.has(g) && ft.set(w, (ft.get(w) ?? 0) + 1);
2170
+ for (const y of pt) {
2171
+ const w = d(y), v = Jt.get(w) ?? 0;
2172
+ Jt.set(w, v + 1), (X.get(w) ?? 0) > 8 && v >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
2119
2173
  }
2120
2174
  const Vt = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Set(), gt = [], Zt = [];
2121
- for (const g of pt) {
2122
- const w = f(g), N = K.get(w) ?? 0, ee = Vt.get(w) ?? 0;
2123
- if (Vt.set(w, ee + 1), N > 8 && ee >= 6 && !u.has(g)) {
2175
+ for (const y of pt) {
2176
+ const w = d(y), v = X.get(w) ?? 0, ee = Vt.get(w) ?? 0;
2177
+ if (Vt.set(w, ee + 1), v > 8 && ee >= 6 && !h.has(y)) {
2124
2178
  Yt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Yt.add(w));
2125
2179
  continue;
2126
2180
  }
2127
- const se = _(g, dt);
2181
+ const se = _(y, dt);
2128
2182
  Zt.push(se), gt.push(se.lines);
2129
2183
  }
2130
2184
  const mt = [];
2131
2185
  if (A.shadowRoot)
2132
- for (const g of Array.from(A.shadowRoot.children))
2133
- g instanceof HTMLElement && mt.push(_(g, dt + 1));
2134
- const J = [...Zt, ...mt], yt = X.length > 0 || Ke || J.some((g) => g.hasUsefulContent), Qt = B(
2135
- [X, ...J.map((g) => g.textPreview)].filter(Boolean).join(" ")
2136
- ).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 = [];
2186
+ for (const y of Array.from(A.shadowRoot.children))
2187
+ y instanceof HTMLElement && mt.push(_(y, dt + 1));
2188
+ const J = [...Zt, ...mt], yt = G.length > 0 || Je || J.some((y) => y.hasUsefulContent), Qt = B(
2189
+ [G, ...J.map((y) => y.textPreview)].filter(Boolean).join(" ")
2190
+ ).slice(0, 180), Ve = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), te = l.some((y) => A.hasAttribute(y)) || !!Xt || Ve, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(b) || te || K) && (yt || K) && (!r.has(b) || yt || te || K), Tt = It ? 1 : 0, H = [];
2137
2191
  if (It) {
2138
- const g = J.some((N) => N.containsTextElement), w = n.has(R) && !g ? Qt : X;
2139
- F.push(Pe(A, c, o, w.slice(0, 180)));
2192
+ const y = J.some((v) => v.containsTextElement), w = n.has(b) && !y ? Qt : G;
2193
+ H.push(Pe(A, c, o, w.slice(0, 180)));
2140
2194
  }
2141
- for (const g of gt)
2142
- F.push(...Q(g, Tt));
2143
- const wt = mt.flatMap((g) => g.lines);
2195
+ for (const y of gt)
2196
+ H.push(...Q(y, Tt));
2197
+ const wt = mt.flatMap((y) => y.lines);
2144
2198
  if (wt.length > 0) {
2145
- const g = wt.slice(0, 20);
2146
- wt.length > g.length && g.push("… shadow DOM omitted");
2147
- const w = R.includes("tooltip") || R.includes("popper") || R.includes("loader");
2199
+ const y = wt.slice(0, 20);
2200
+ wt.length > y.length && y.push("… shadow DOM omitted");
2201
+ const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
2148
2202
  if (dt < 2 && !w) {
2149
- const N = It ? "#shadow-root" : `${R} #shadow-root`;
2150
- F.push(...Q([N, ...Q(g, 1)], Tt));
2203
+ const v = It ? "#shadow-root" : `${b} #shadow-root`;
2204
+ H.push(...Q([v, ...Q(y, 1)], Tt));
2151
2205
  } else
2152
- F.push(...Q(g, Tt));
2206
+ H.push(...Q(y, Tt));
2153
2207
  }
2154
2208
  return {
2155
- lines: F,
2209
+ lines: H,
2156
2210
  hasUsefulContent: yt,
2157
2211
  textPreview: Qt,
2158
- containsTextElement: n.has(R) || J.some((g) => g.containsTextElement)
2212
+ containsTextElement: n.has(b) || J.some((y) => y.containsTextElement)
2159
2213
  };
2160
2214
  };
2161
2215
  return [`--- ${D} ---`, ..._(T, 0).lines].join(`
2162
2216
  `);
2163
- }, y = [], k = B(window.getSelection()?.toString() ?? "");
2164
- k && y.push(`--- selected text ---
2165
- ${JSON.stringify(k)}`), p.length > 0 && y.push(gn(p, s, c, o));
2217
+ }, m = [], E = B(window.getSelection()?.toString() ?? "");
2218
+ E && m.push(`--- selected text ---
2219
+ ${JSON.stringify(E)}`), f.length > 0 && m.push(In(f, s, c, o));
2166
2220
  for (const T of e.slice(0, 3))
2167
- y.push(h(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2168
- if (t && y.push(h(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2221
+ m.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2222
+ if (t && m.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2169
2223
  const T = t || e.length ? "other visible DOM" : "visible DOM";
2170
- y.push(h(document.body, T, I));
2224
+ m.push(p(document.body, T, I));
2171
2225
  }
2172
- return y.join(`
2226
+ return m.join(`
2173
2227
 
2174
2228
  `);
2175
2229
  }
@@ -2177,7 +2231,7 @@ function Pe(e, t, s, n) {
2177
2231
  const r = e.tagName.toLowerCase();
2178
2232
  let i = r;
2179
2233
  const o = e.getAttribute("id");
2180
- o && mn(o) && (i += `#${o}`);
2234
+ o && Tn(o) && (i += `#${o}`);
2181
2235
  for (const a of t) {
2182
2236
  const c = e.getAttribute(a);
2183
2237
  c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
@@ -2190,20 +2244,20 @@ function Pe(e, t, s, n) {
2190
2244
  e.hasAttribute(a) && (i += `[${a}]`);
2191
2245
  return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
2192
2246
  }
2193
- function fn() {
2247
+ function yn() {
2194
2248
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
2195
2249
  if (!a)
2196
2250
  return;
2197
2251
  const l = window.getComputedStyle(a);
2198
2252
  if (l.display === "none" || l.visibility === "hidden")
2199
2253
  return;
2200
- const u = t.get(a) ?? /* @__PURE__ */ new Set();
2201
- u.add(c), t.set(a, u);
2202
- let p = a;
2203
- for (; p; ) {
2204
- e.add(p);
2205
- const I = p.getRootNode();
2206
- p = p.parentElement ?? (I instanceof ShadowRoot && I.host instanceof HTMLElement ? I.host : null);
2254
+ const h = t.get(a) ?? /* @__PURE__ */ new Set();
2255
+ h.add(c), t.set(a, h);
2256
+ let f = a;
2257
+ for (; f; ) {
2258
+ e.add(f);
2259
+ const I = f.getRootNode();
2260
+ f = f.parentElement ?? (I instanceof ShadowRoot && I.host instanceof HTMLElement ? I.host : null);
2207
2261
  }
2208
2262
  };
2209
2263
  let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
@@ -2222,9 +2276,9 @@ function fn() {
2222
2276
  ], o = [document];
2223
2277
  for (let a = 0; a < o.length; a += 1) {
2224
2278
  const c = o[a];
2225
- for (const [l, u] of i)
2226
- for (const p of Array.from(c.querySelectorAll(l)))
2227
- s(p, u);
2279
+ for (const [l, h] of i)
2280
+ for (const f of Array.from(c.querySelectorAll(l)))
2281
+ s(f, h);
2228
2282
  for (const l of Array.from(c.querySelectorAll("*")))
2229
2283
  l.shadowRoot && o.push(l.shadowRoot);
2230
2284
  }
@@ -2233,22 +2287,22 @@ function fn() {
2233
2287
  priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
2234
2288
  };
2235
2289
  }
2236
- function gn(e, t, s, n) {
2290
+ function In(e, t, s, n) {
2237
2291
  const r = ["--- active/current elements ---"];
2238
2292
  for (const i of e) {
2239
2293
  const o = [];
2240
2294
  let a = i.element;
2241
2295
  for (; a; ) {
2242
- const u = a.tagName.toLowerCase();
2243
- (a === i.element || t.has(u) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
2244
- const p = a.getRootNode();
2245
- a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
2296
+ const h = a.tagName.toLowerCase();
2297
+ (a === i.element || t.has(h) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
2298
+ const f = a.getRootNode();
2299
+ a = a.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
2246
2300
  }
2247
- const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((u, p) => Pe(
2248
- u,
2301
+ const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => Pe(
2302
+ h,
2249
2303
  s,
2250
2304
  n,
2251
- p === c.length - 1 ? Ue(u).slice(0, 180) : ""
2305
+ f === c.length - 1 ? Ue(h).slice(0, 180) : ""
2252
2306
  ));
2253
2307
  o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
2254
2308
  }
@@ -2269,7 +2323,7 @@ function Ue(e) {
2269
2323
  Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
2270
2324
  );
2271
2325
  }
2272
- function mn(e) {
2326
+ function Tn(e) {
2273
2327
  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);
2274
2328
  }
2275
2329
  function De() {
@@ -2288,23 +2342,23 @@ function De() {
2288
2342
  },
2289
2343
  {
2290
2344
  name: "widget_root",
2291
- selector: fs,
2345
+ selector: ys,
2292
2346
  description: "Finds Pluno's widget root inside the widget host shadow root."
2293
2347
  },
2294
2348
  {
2295
2349
  name: "widget_panel",
2296
- selector: gs,
2350
+ selector: Is,
2297
2351
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
2298
2352
  },
2299
2353
  {
2300
2354
  name: "widget_timeline",
2301
- selector: ms,
2355
+ selector: Ts,
2302
2356
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2303
2357
  }
2304
2358
  ]
2305
2359
  };
2306
2360
  }
2307
- function yn(e) {
2361
+ function wn(e) {
2308
2362
  try {
2309
2363
  const t = JSON.parse(e);
2310
2364
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -2318,10 +2372,10 @@ function pe(e, t) {
2318
2372
  const s = e[t];
2319
2373
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2320
2374
  }
2321
- function In(e) {
2375
+ function Sn(e) {
2322
2376
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
2323
2377
  }
2324
- function Tn(e) {
2378
+ function An(e) {
2325
2379
  if (!e || typeof e != "object")
2326
2380
  return null;
2327
2381
  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;
@@ -2332,13 +2386,13 @@ function Tn(e) {
2332
2386
  ...a !== null ? { scribbleStyle: a } : {}
2333
2387
  };
2334
2388
  }
2335
- function wn(e) {
2389
+ function En(e) {
2336
2390
  if (!e || typeof e != "object")
2337
2391
  return null;
2338
2392
  const t = e.javascript;
2339
2393
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
2340
2394
  }
2341
- function Sn(e, t) {
2395
+ function Rn(e, t) {
2342
2396
  return t ? e && typeof e == "object" ? {
2343
2397
  ...e,
2344
2398
  helperError: t
@@ -2348,13 +2402,13 @@ function Sn(e, t) {
2348
2402
  helperError: t
2349
2403
  } : e;
2350
2404
  }
2351
- function An(e) {
2405
+ function bn(e) {
2352
2406
  if (!e || typeof e != "object")
2353
2407
  return e;
2354
2408
  const t = e;
2355
2409
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2356
2410
  }
2357
- function En() {
2411
+ function Mn() {
2358
2412
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2359
2413
  if (t)
2360
2414
  return t;
@@ -2364,7 +2418,7 @@ function En() {
2364
2418
  function $() {
2365
2419
  return crypto.randomUUID();
2366
2420
  }
2367
- function Rn(e) {
2421
+ function kn(e) {
2368
2422
  if (!e || typeof e != "object")
2369
2423
  return null;
2370
2424
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2375,22 +2429,22 @@ function Rn(e) {
2375
2429
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2376
2430
  } : null;
2377
2431
  }
2378
- function bn(e, t) {
2432
+ function _n(e, t) {
2379
2433
  return Array.isArray(e) ? Lt(
2380
- e.map((s) => Ne(s, t)).filter((s) => s !== null)
2434
+ e.map((s) => ve(s, t)).filter((s) => s !== null)
2381
2435
  ) : [];
2382
2436
  }
2383
- function Mn(e) {
2437
+ function Cn(e) {
2384
2438
  return Array.isArray(e) ? e.flatMap((t) => {
2385
2439
  if (!t || typeof t != "object")
2386
2440
  return [];
2387
- const s = t, n = E(s, "id"), r = E(s, "createdAt"), i = E(s, "updatedAt"), o = E(s, "lastActiveAt");
2441
+ const s = t, n = R(s, "id"), r = R(s, "createdAt"), i = R(s, "updatedAt"), o = R(s, "lastActiveAt");
2388
2442
  return !n || !r || !i || !o ? [] : [
2389
2443
  {
2390
2444
  id: n,
2391
- title: E(s, "title"),
2392
- customTitle: E(s, "customTitle"),
2393
- firstUserMessage: E(s, "firstUserMessage"),
2445
+ title: R(s, "title"),
2446
+ customTitle: R(s, "customTitle"),
2447
+ firstUserMessage: R(s, "firstUserMessage"),
2394
2448
  currentPage: s.currentPage ?? null,
2395
2449
  createdAt: r,
2396
2450
  updatedAt: i,
@@ -2401,7 +2455,7 @@ function Mn(e) {
2401
2455
  ];
2402
2456
  }) : [];
2403
2457
  }
2404
- function Ne(e, t) {
2458
+ function ve(e, t) {
2405
2459
  if (!e || typeof e != "object")
2406
2460
  return null;
2407
2461
  const s = e, n = s.data;
@@ -2415,14 +2469,14 @@ function Ne(e, t) {
2415
2469
  id: String(s.id ?? crypto.randomUUID()),
2416
2470
  role: i,
2417
2471
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2418
- content: ns(
2419
- Nn(r.content),
2472
+ content: rs(
2473
+ xn(r.content),
2420
2474
  t
2421
2475
  ),
2422
2476
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2423
- respondsToUserMessageId: O(r) ?? void 0,
2477
+ respondsToUserMessageId: N(r) ?? void 0,
2424
2478
  ...C(r) ? { runId: C(r) } : {},
2425
- attachments: qe(r.attachments, t)
2479
+ attachments: Be(r.attachments, t)
2426
2480
  };
2427
2481
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
2428
2482
  value: r.id,
@@ -2433,13 +2487,13 @@ function Ne(e, t) {
2433
2487
  }), o;
2434
2488
  }
2435
2489
  if (r.type === "function_call_output") {
2436
- const i = _n(r.output);
2490
+ const i = Un(r.output);
2437
2491
  return i ? {
2438
2492
  id: String(s.id ?? crypto.randomUUID()),
2439
2493
  role: "tool",
2440
2494
  content: `Connect ${i.appName} to continue`,
2441
2495
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2442
- respondsToUserMessageId: O(r) ?? void 0,
2496
+ respondsToUserMessageId: N(r) ?? void 0,
2443
2497
  ...C(r) ? { runId: C(r) } : {},
2444
2498
  dataType: "function_call_output",
2445
2499
  toolName: "authenticate_pipedream_app",
@@ -2450,9 +2504,9 @@ function Ne(e, t) {
2450
2504
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2451
2505
  id: String(s.id ?? crypto.randomUUID()),
2452
2506
  role: "tool",
2453
- content: r.type === "mcp_call" ? kn(r) : Pn(r),
2507
+ content: r.type === "mcp_call" ? Pn(r) : vn(r),
2454
2508
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2455
- respondsToUserMessageId: O(r) ?? void 0,
2509
+ respondsToUserMessageId: N(r) ?? void 0,
2456
2510
  ...C(r) ? { runId: C(r) } : {},
2457
2511
  dataType: String(r.type),
2458
2512
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
@@ -2461,9 +2515,9 @@ function Ne(e, t) {
2461
2515
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2462
2516
  id: String(s.id ?? crypto.randomUUID()),
2463
2517
  role: "system",
2464
- content: Cn(r),
2518
+ content: Dn(r),
2465
2519
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2466
- respondsToUserMessageId: O(r) ?? void 0,
2520
+ respondsToUserMessageId: N(r) ?? void 0,
2467
2521
  ...C(r) ? { runId: C(r) } : {},
2468
2522
  dataType: String(r.type),
2469
2523
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
@@ -2472,11 +2526,11 @@ function Ne(e, t) {
2472
2526
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2473
2527
  } : null;
2474
2528
  }
2475
- function kn(e) {
2529
+ function Pn(e) {
2476
2530
  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(" ");
2477
2531
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2478
2532
  }
2479
- function _n(e) {
2533
+ function Un(e) {
2480
2534
  if (typeof e != "string")
2481
2535
  return null;
2482
2536
  try {
@@ -2493,10 +2547,10 @@ function _n(e) {
2493
2547
  return null;
2494
2548
  }
2495
2549
  }
2496
- function Cn(e) {
2550
+ function Dn(e) {
2497
2551
  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.";
2498
2552
  }
2499
- function Pn(e) {
2553
+ function vn(e) {
2500
2554
  if (e.type === "web_search_call") {
2501
2555
  const t = e.action;
2502
2556
  if (t && typeof t == "object") {
@@ -2508,9 +2562,9 @@ function Pn(e) {
2508
2562
  }
2509
2563
  return "🔎 Searching the web";
2510
2564
  }
2511
- return Un(e);
2565
+ return On(e);
2512
2566
  }
2513
- function Un(e) {
2567
+ function On(e) {
2514
2568
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2515
2569
  return L(e.summary);
2516
2570
  if (typeof e.arguments == "string")
@@ -2527,7 +2581,7 @@ function L(e) {
2527
2581
  const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2528
2582
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2529
2583
  }
2530
- function Dn(e) {
2584
+ function Nn(e) {
2531
2585
  if (e == null)
2532
2586
  return e;
2533
2587
  if (typeof e != "object")
@@ -2546,7 +2600,7 @@ function fe(e) {
2546
2600
  const t = e.callId ?? e.call_id;
2547
2601
  return typeof t == "string" && t ? t : null;
2548
2602
  }
2549
- function Nn(e) {
2603
+ function xn(e) {
2550
2604
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2551
2605
  if (!t || typeof t != "object")
2552
2606
  return "";
@@ -2555,9 +2609,9 @@ function Nn(e) {
2555
2609
  }).filter(Boolean).join("") : "";
2556
2610
  }
2557
2611
  function Dt(e, t) {
2558
- const s = xe(e, t), n = Bn(
2559
- xn(
2560
- jn(e, t),
2612
+ const s = Ne(e, t), n = $n(
2613
+ Ln(
2614
+ Gn(e, t),
2561
2615
  s
2562
2616
  ),
2563
2617
  s
@@ -2569,16 +2623,33 @@ function Dt(e, t) {
2569
2623
  const i = [...n];
2570
2624
  return i[r] = s, Lt(i);
2571
2625
  }
2572
- function xn(e, t) {
2626
+ function Ln(e, t) {
2573
2627
  const s = t.assistantDraftItemId;
2574
2628
  return s ? e.map(
2575
2629
  (n) => n.dataType === "assistant_draft" && n.id === s ? t : n
2576
2630
  ) : e;
2577
2631
  }
2578
- function On(e, t, s) {
2632
+ function qn(e, t, s) {
2579
2633
  return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
2580
2634
  }
2581
- function vn(e, t) {
2635
+ function Bn(e, t, s, n) {
2636
+ if (s === null) return e;
2637
+ let r = -1;
2638
+ for (let o = e.length - 1; o >= 0; o -= 1) {
2639
+ const a = e[o];
2640
+ if (a.role === "assistant" && a.phase !== "commentary" && !a.respondsToUserMessageId && (t !== null && a.id === t || n !== null && a.runId === n)) {
2641
+ r = o;
2642
+ break;
2643
+ }
2644
+ }
2645
+ if (r === -1) return e;
2646
+ const i = [...e];
2647
+ return i[r] = {
2648
+ ...i[r],
2649
+ respondsToUserMessageId: s
2650
+ }, i;
2651
+ }
2652
+ function Fn(e, t) {
2582
2653
  const s = e.findIndex(
2583
2654
  (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2584
2655
  );
@@ -2595,12 +2666,12 @@ function vn(e, t) {
2595
2666
  ...n[s].runId ? {} : { runId: t.runId }
2596
2667
  }, n;
2597
2668
  }
2598
- function Ln(e, t, s) {
2669
+ function Hn(e, t, s) {
2599
2670
  let n = !1;
2600
2671
  const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2601
2672
  return n ? r : e;
2602
2673
  }
2603
- function qn(e) {
2674
+ function Wn(e) {
2604
2675
  if (e.hiddenFromTranscript === !0)
2605
2676
  return null;
2606
2677
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
@@ -2619,7 +2690,7 @@ function qn(e) {
2619
2690
  loading: !0
2620
2691
  };
2621
2692
  }
2622
- function Bn(e, t) {
2693
+ function $n(e, t) {
2623
2694
  if (t.id.startsWith("transient-activity:"))
2624
2695
  return e;
2625
2696
  const s = t.toolName === "tab_lifecycle";
@@ -2627,90 +2698,73 @@ function Bn(e, t) {
2627
2698
  (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)
2628
2699
  );
2629
2700
  }
2630
- function Hn(e, t) {
2631
- const s = Fn(
2701
+ function jn(e, t) {
2702
+ return is(
2703
+ e,
2632
2704
  t.map(
2633
- (c) => xe(e, c)
2634
- )
2635
- ), n = new Map(s.map((c) => [c.id, c])), r = new Map(
2636
- s.flatMap((c) => {
2637
- const l = c.clientMessageId;
2638
- return l ? [[l, c]] : [];
2639
- })
2640
- ), i = new Map(
2641
- s.flatMap((c) => {
2642
- const l = c.assistantDraftItemId;
2643
- return l ? [[l, c]] : [];
2644
- })
2645
- ), o = /* @__PURE__ */ new Set(), a = [];
2646
- for (const c of e) {
2647
- let l = n.get(c.id);
2648
- if (jt(c)) {
2649
- const u = Nt(c);
2650
- if (l = u ? r.get(u) : void 0, !l) {
2651
- a.push(c);
2652
- continue;
2653
- }
2654
- } else if (c.dataType === "assistant_draft" && (l = i.get(c.id), !l)) {
2655
- a.push(c);
2656
- continue;
2657
- }
2658
- l && !o.has(l) && (a.push(l), o.add(l));
2659
- }
2660
- for (const c of s)
2661
- o.has(c) || a.push(c);
2662
- return a;
2663
- }
2664
- function Fn(e) {
2665
- const t = new Set(
2666
- e.flatMap(
2667
- (s) => s.callId && !s.id.startsWith("transient-activity:") ? [s.callId] : []
2668
- )
2669
- );
2670
- return e.filter(
2671
- (s) => !(s.callId && s.id.startsWith("transient-activity:") && t.has(s.callId))
2705
+ (s) => Ne(e, s)
2706
+ ),
2707
+ Oe
2672
2708
  );
2673
2709
  }
2674
- function xe(e, t) {
2710
+ function Oe(e) {
2711
+ const t = vt(e) ?? void 0, s = e.assistantDraftItemId, n = [
2712
+ ...e.callId ? [`call:${e.callId}`] : [],
2713
+ ...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
2714
+ ];
2715
+ return {
2716
+ id: e.id,
2717
+ ...t ? { optimisticKey: t } : {},
2718
+ ...e.dataType === "assistant_draft" ? { assistantDraftKey: e.id } : s ? { assistantDraftKey: s } : {},
2719
+ ...n.length > 0 ? { activityKeys: n } : {},
2720
+ ...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
2721
+ ...e.runId ? { runId: e.runId } : {},
2722
+ isOptimistic: jt(e),
2723
+ isAssistantDraft: e.dataType === "assistant_draft",
2724
+ isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
2725
+ isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
2726
+ };
2727
+ }
2728
+ function Ne(e, t) {
2675
2729
  if (t.role !== "user" || !t.attachments?.length)
2676
2730
  return t;
2677
2731
  const s = e.find(
2678
- (r) => r.role === "user" && (r.id === t.id || jt(r) && Oe(r, t))
2732
+ (r) => r.role === "user" && (r.id === t.id || jt(r) && xe(r, t))
2679
2733
  );
2680
2734
  if (!s?.attachments?.length)
2681
2735
  return t;
2682
2736
  const n = t.attachments.map((r) => {
2683
- const i = Wn(s.attachments ?? [], r);
2684
- return i ? $n(r, i) : r;
2737
+ const i = zn(s.attachments ?? [], r);
2738
+ return i ? Kn(r, i) : r;
2685
2739
  });
2686
2740
  return { ...t, attachments: n };
2687
2741
  }
2688
- function Wn(e, t) {
2742
+ function zn(e, t) {
2689
2743
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2690
2744
  }
2691
- function $n(e, t) {
2745
+ function Kn(e, t) {
2692
2746
  const { previewUrl: s } = t;
2693
2747
  return s ? { ...e, previewUrl: s } : e;
2694
2748
  }
2695
- function jn(e, t) {
2749
+ function Gn(e, t) {
2696
2750
  if (t.role !== "user")
2697
2751
  return e;
2698
2752
  const s = e.findIndex(
2699
- (r) => jt(r) && Oe(r, t)
2753
+ (r) => jt(r) && xe(r, t)
2700
2754
  );
2701
2755
  if (s === -1)
2702
2756
  return e;
2703
2757
  const n = [...e];
2704
2758
  return n.splice(s, 1), n;
2705
2759
  }
2706
- function Oe(e, t) {
2707
- const s = Nt(e), n = Nt(t);
2760
+ function xe(e, t) {
2761
+ const s = vt(e), n = vt(t);
2708
2762
  return s && n ? s === n : e.content === t.content;
2709
2763
  }
2710
2764
  function jt(e) {
2711
2765
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2712
2766
  }
2713
- function Nt(e) {
2767
+ function vt(e) {
2714
2768
  const t = e.clientMessageId;
2715
2769
  if (t)
2716
2770
  return t;
@@ -2720,17 +2774,17 @@ function Nt(e) {
2720
2774
  return n ? e.id.slice(n.length) : null;
2721
2775
  }
2722
2776
  function ge(e) {
2723
- const t = ve(e);
2777
+ const t = Le(e);
2724
2778
  if (t === null)
2725
2779
  return !1;
2726
2780
  const s = e[t].id, n = e.some(
2727
- (r) => r.respondsToUserMessageId === s && xt(r)
2781
+ (r) => r.respondsToUserMessageId === s && Ot(r)
2728
2782
  );
2729
2783
  if (e.some((r) => r.respondsToUserMessageId === s))
2730
2784
  return n;
2731
2785
  for (let r = e.length - 1; r > t; r -= 1) {
2732
2786
  const i = e[r];
2733
- if (x(i))
2787
+ if (O(i))
2734
2788
  return !0;
2735
2789
  if (i.role === "system") {
2736
2790
  if (i.dataType === "run_error")
@@ -2741,23 +2795,23 @@ function ge(e) {
2741
2795
  }
2742
2796
  return !1;
2743
2797
  }
2744
- function zn(e) {
2745
- const t = ve(e);
2798
+ function Xn(e) {
2799
+ const t = Le(e);
2746
2800
  if (t === null)
2747
- return e.some(x);
2801
+ return e.some(O);
2748
2802
  const s = e[t].id;
2749
2803
  return e.some((n) => n.respondsToUserMessageId === s) ? e.some(
2750
- (n) => n.respondsToUserMessageId === s && x(n)
2751
- ) : e.slice(t + 1).some(x);
2804
+ (n) => n.respondsToUserMessageId === s && O(n)
2805
+ ) : e.slice(t + 1).some(O);
2752
2806
  }
2753
- function ve(e) {
2807
+ function Le(e) {
2754
2808
  for (let t = e.length - 1; t >= 0; t -= 1)
2755
2809
  if (e[t].role === "user")
2756
2810
  return t;
2757
2811
  return null;
2758
2812
  }
2759
- function xt(e) {
2760
- return x(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2813
+ function Ot(e) {
2814
+ return O(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2761
2815
  }
2762
2816
  function at(e) {
2763
2817
  for (let t = e.length - 1; t >= 0; t -= 1) {
@@ -2773,7 +2827,7 @@ function at(e) {
2773
2827
  }
2774
2828
  return null;
2775
2829
  }
2776
- function Gn(e) {
2830
+ function Jn(e) {
2777
2831
  const t = at(e);
2778
2832
  if (t === null)
2779
2833
  return null;
@@ -2789,13 +2843,13 @@ function q(e) {
2789
2843
  const t = e.data;
2790
2844
  return t && typeof t == "object" ? t : null;
2791
2845
  }
2792
- function Ot(e) {
2846
+ function Nt(e) {
2793
2847
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2794
2848
  }
2795
2849
  function me(e) {
2796
2850
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2797
2851
  }
2798
- function Xn(e, t) {
2852
+ function Vn(e, t) {
2799
2853
  const s = at(t);
2800
2854
  if (s === null)
2801
2855
  return !1;
@@ -2804,10 +2858,10 @@ function Xn(e, t) {
2804
2858
  return !1;
2805
2859
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2806
2860
  return i === -1 ? !1 : e.some((o) => o.respondsToUserMessageId === r) ? e.some(
2807
- (o) => o.respondsToUserMessageId === r && xt(o)
2808
- ) : e.slice(i + 1).some(xt);
2861
+ (o) => o.respondsToUserMessageId === r && Ot(o)
2862
+ ) : e.slice(i + 1).some(Ot);
2809
2863
  }
2810
- function vt(e) {
2864
+ function xt(e) {
2811
2865
  const t = at(e);
2812
2866
  if (t === null)
2813
2867
  return null;
@@ -2820,7 +2874,7 @@ function vt(e) {
2820
2874
  const r = n.clientMessageId;
2821
2875
  return typeof r == "string" ? r : null;
2822
2876
  }
2823
- function Kn(e) {
2877
+ function Yn(e) {
2824
2878
  const t = at(e);
2825
2879
  if (t === null)
2826
2880
  return null;
@@ -2835,22 +2889,22 @@ function Kn(e) {
2835
2889
  if (i.type === "message" && i.role === "assistant")
2836
2890
  return null;
2837
2891
  if (i.type === "run_error")
2838
- return i.retryable !== !0 ? null : ye(e, i) ?? vt(e);
2892
+ return i.retryable !== !0 ? null : ye(e, i) ?? xt(e);
2839
2893
  if (i.type === "run_status")
2840
- return i.status === "interrupted" && i.retryable === !0 ? ye(e, i) ?? vt(e) : null;
2894
+ return i.status === "interrupted" && i.retryable === !0 ? ye(e, i) ?? xt(e) : null;
2841
2895
  }
2842
2896
  return null;
2843
2897
  }
2844
2898
  function ye(e, t) {
2845
2899
  if (typeof t.clientMessageId == "string")
2846
2900
  return t.clientMessageId;
2847
- const s = O(t);
2901
+ const s = N(t);
2848
2902
  if (!s)
2849
2903
  return null;
2850
- const n = e.find((i) => E(i, "id") === s), r = q(n);
2904
+ const n = e.find((i) => R(i, "id") === s), r = q(n);
2851
2905
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2852
2906
  }
2853
- function Jn(e, t) {
2907
+ function Zn(e, t) {
2854
2908
  let s = 0;
2855
2909
  for (const n of e) {
2856
2910
  if (!n || typeof n != "object")
@@ -2864,38 +2918,38 @@ function Jn(e, t) {
2864
2918
  return s;
2865
2919
  }
2866
2920
  function Ie(e, t, s, n, r) {
2867
- if (!t || !Vn(e))
2921
+ if (!t || !Qn(e))
2868
2922
  return !1;
2869
2923
  const i = e;
2870
- return !(Ot(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && C(i) !== r));
2924
+ return !(Nt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? N(i) !== n : r !== null && C(i) !== r));
2871
2925
  }
2872
- function Vn(e) {
2926
+ function Qn(e) {
2873
2927
  if (!e || typeof e != "object")
2874
2928
  return !1;
2875
2929
  const t = e;
2876
2930
  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");
2877
2931
  }
2878
- function x(e) {
2932
+ function O(e) {
2879
2933
  return e.role === "assistant" && e.phase !== "commentary";
2880
2934
  }
2881
- function Yn(e) {
2935
+ function tr(e) {
2882
2936
  if (!e || typeof e != "object")
2883
2937
  return !1;
2884
2938
  const t = e;
2885
2939
  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";
2886
2940
  }
2887
2941
  function Lt(e) {
2888
- 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);
2942
+ return e.filter((t, s) => ct(t) ? !cr(e, s) && !or(e, s) && !ar(e, s) : er(t) ? t.retryable === !0 && ir(e, s) ? !1 : !rr(e, s) : !0);
2889
2943
  }
2890
- function Zn(e) {
2944
+ function er(e) {
2891
2945
  return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
2892
2946
  }
2893
2947
  function ct(e) {
2894
2948
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2895
2949
  }
2896
- function Qn(e, t) {
2950
+ function sr(e, t) {
2897
2951
  const s = [...e].reverse().find(
2898
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && Te(n) && !tr(
2952
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && Te(n) && !nr(
2899
2953
  e,
2900
2954
  n.respondsToUserMessageId
2901
2955
  )
@@ -2907,12 +2961,12 @@ function Qn(e, t) {
2907
2961
  function Te(e) {
2908
2962
  return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
2909
2963
  }
2910
- function tr(e, t) {
2964
+ function nr(e, t) {
2911
2965
  return e.some(
2912
- (s) => s.respondsToUserMessageId === t && (x(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
2966
+ (s) => s.respondsToUserMessageId === t && (O(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
2913
2967
  );
2914
2968
  }
2915
- function er(e, t) {
2969
+ function rr(e, t) {
2916
2970
  const s = e[t];
2917
2971
  for (let n = t + 1; n < e.length; n += 1) {
2918
2972
  const r = e[n];
@@ -2921,7 +2975,7 @@ function er(e, t) {
2921
2975
  }
2922
2976
  return !1;
2923
2977
  }
2924
- function sr(e, t) {
2978
+ function ir(e, t) {
2925
2979
  const s = e[t];
2926
2980
  if (!s.respondsToUserMessageId)
2927
2981
  return !1;
@@ -2934,19 +2988,19 @@ function sr(e, t) {
2934
2988
  }
2935
2989
  return !1;
2936
2990
  }
2937
- function nr(e, t) {
2991
+ function or(e, t) {
2938
2992
  const s = e[t];
2939
2993
  return e.some(
2940
2994
  (n, r) => r !== t && n.role === "assistant" && lt(s, n)
2941
2995
  );
2942
2996
  }
2943
- function rr(e, t) {
2997
+ function ar(e, t) {
2944
2998
  const s = e[t];
2945
2999
  return e.some(
2946
3000
  (n, r) => r !== t && n.role === "tool" && lt(s, n)
2947
3001
  );
2948
3002
  }
2949
- function ir(e, t) {
3003
+ function cr(e, t) {
2950
3004
  const s = e[t];
2951
3005
  for (let n = t + 1; n < e.length; n += 1)
2952
3006
  if (ct(e[n]) && lt(s, e[n]))
@@ -2956,10 +3010,10 @@ function ir(e, t) {
2956
3010
  function lt(e, t) {
2957
3011
  return !!(e.respondsToUserMessageId && e.respondsToUserMessageId === t.respondsToUserMessageId);
2958
3012
  }
2959
- function E(e, t) {
3013
+ function R(e, t) {
2960
3014
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2961
3015
  }
2962
- function or(e, t) {
3016
+ function lr(e, t) {
2963
3017
  try {
2964
3018
  const s = window.localStorage.getItem(`${ke}${e}`);
2965
3019
  if (!s)
@@ -2967,7 +3021,7 @@ function or(e, t) {
2967
3021
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2968
3022
  if (t !== void 0 && r !== t)
2969
3023
  return null;
2970
- const i = Array.isArray(n.messages) ? n.messages.map(mr).filter((o) => !!o) : [];
3024
+ const i = Array.isArray(n.messages) ? n.messages.map(Tr).filter((o) => !!o) : [];
2971
3025
  return {
2972
3026
  sessionId: r,
2973
3027
  messages: i
@@ -2976,20 +3030,20 @@ function or(e, t) {
2976
3030
  return null;
2977
3031
  }
2978
3032
  }
2979
- function ar(e, t) {
3033
+ function ur(e, t) {
2980
3034
  try {
2981
3035
  window.localStorage.setItem(
2982
3036
  `${ke}${e}`,
2983
3037
  JSON.stringify({
2984
3038
  sessionId: t.sessionId,
2985
- messages: t.messages.slice(-xs).map(yr)
3039
+ messages: t.messages.slice(-Ls).map(wr)
2986
3040
  })
2987
3041
  );
2988
3042
  } catch {
2989
3043
  return;
2990
3044
  }
2991
3045
  }
2992
- function cr(e) {
3046
+ function dr(e) {
2993
3047
  try {
2994
3048
  const t = window.localStorage.getItem(`${Ut}${e}`);
2995
3049
  if (!t)
@@ -3015,7 +3069,7 @@ function j(e, t) {
3015
3069
  return;
3016
3070
  }
3017
3071
  }
3018
- function Le(e, t) {
3072
+ function qe(e, t) {
3019
3073
  try {
3020
3074
  const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
3021
3075
  ...o,
@@ -3031,28 +3085,28 @@ function Le(e, t) {
3031
3085
  } catch {
3032
3086
  }
3033
3087
  }
3034
- function lr(e, t) {
3088
+ function hr(e, t) {
3035
3089
  try {
3036
3090
  if (window.sessionStorage.getItem(`${ot}${e}`) === null)
3037
3091
  return;
3038
3092
  } catch {
3039
3093
  return;
3040
3094
  }
3041
- Le(e, t);
3095
+ qe(e, t);
3042
3096
  }
3043
- function ur(e) {
3097
+ function pr(e) {
3044
3098
  try {
3045
3099
  const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
3046
3100
  if (window.sessionStorage.removeItem(t), !s)
3047
3101
  return [];
3048
3102
  const n = JSON.parse(s);
3049
- return Array.isArray(n) ? n.flatMap((r) => hr(r) ? [{
3103
+ return Array.isArray(n) ? n.flatMap((r) => gr(r) ? [{
3050
3104
  ...r.event,
3051
- page: b(),
3105
+ page: M(),
3052
3106
  rawOutput: {
3053
3107
  pageContextRestarted: !0,
3054
3108
  outcome: "unknown",
3055
- message: dr(location.href),
3109
+ message: fr(location.href),
3056
3110
  currentUrl: location.href,
3057
3111
  console: [],
3058
3112
  metadata: {
@@ -3069,17 +3123,17 @@ function ur(e) {
3069
3123
  return [];
3070
3124
  }
3071
3125
  }
3072
- function dr(e) {
3126
+ function fr(e) {
3073
3127
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
3074
3128
  Current URL: ${e}`;
3075
3129
  }
3076
- function hr(e) {
3130
+ function gr(e) {
3077
3131
  if (!e || typeof e != "object")
3078
3132
  return !1;
3079
3133
  const t = e, s = t.event;
3080
3134
  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";
3081
3135
  }
3082
- function pr(e, t) {
3136
+ function mr(e, t) {
3083
3137
  const s = new Set(
3084
3138
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
3085
3139
  );
@@ -3088,7 +3142,7 @@ function pr(e, t) {
3088
3142
  ...t.filter((n) => !s.has(n.callId))
3089
3143
  ];
3090
3144
  }
3091
- function fr(e) {
3145
+ function yr(e) {
3092
3146
  try {
3093
3147
  window.sessionStorage.removeItem(`${ot}${e}`);
3094
3148
  } catch {
@@ -3107,7 +3161,7 @@ function we(e) {
3107
3161
  const t = e;
3108
3162
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
3109
3163
  }
3110
- function qe(e, t) {
3164
+ function Be(e, t) {
3111
3165
  if (!Array.isArray(e))
3112
3166
  return;
3113
3167
  const s = e.filter((r) => {
@@ -3115,23 +3169,23 @@ function qe(e, t) {
3115
3169
  return !1;
3116
3170
  const i = r;
3117
3171
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
3118
- }), n = t ? s.map((r) => Be(r, t)) : s;
3172
+ }), n = t ? s.map((r) => Fe(r, t)) : s;
3119
3173
  return n.length > 0 ? n : void 0;
3120
3174
  }
3121
- function Be(e, t) {
3175
+ function Fe(e, t) {
3122
3176
  return e.fileUrl?.startsWith("/") ? {
3123
3177
  ...e,
3124
3178
  fileUrl: new URL(e.fileUrl, t).toString()
3125
3179
  } : e;
3126
3180
  }
3127
3181
  function Se(e) {
3128
- return e.type || gr(e.name) || "application/octet-stream";
3182
+ return e.type || Ir(e.name) || "application/octet-stream";
3129
3183
  }
3130
- function gr(e) {
3184
+ function Ir(e) {
3131
3185
  const t = e.toLowerCase();
3132
3186
  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;
3133
3187
  }
3134
- function mr(e) {
3188
+ function Tr(e) {
3135
3189
  if (!e || typeof e != "object")
3136
3190
  return null;
3137
3191
  const t = e;
@@ -3144,17 +3198,17 @@ function mr(e) {
3144
3198
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
3145
3199
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
3146
3200
  securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
3147
- attachments: qe(t.attachments)?.map(Gt),
3201
+ attachments: Be(t.attachments)?.map(Kt),
3148
3202
  loading: typeof t.loading == "boolean" ? t.loading : void 0
3149
3203
  };
3150
3204
  }
3151
- function yr(e) {
3205
+ function wr(e) {
3152
3206
  return e.attachments?.length ? {
3153
3207
  ...e,
3154
- attachments: e.attachments.map(Gt)
3208
+ attachments: e.attachments.map(Kt)
3155
3209
  } : e;
3156
3210
  }
3157
- function Gt(e) {
3211
+ function Kt(e) {
3158
3212
  const {
3159
3213
  dataUrl: t,
3160
3214
  objectUrl: s,
@@ -3163,7 +3217,7 @@ function Gt(e) {
3163
3217
  } = e;
3164
3218
  return r;
3165
3219
  }
3166
- function O(e) {
3220
+ function N(e) {
3167
3221
  const t = e.respondsToUserMessageId;
3168
3222
  return typeof t == "string" && t ? t : null;
3169
3223
  }
@@ -3171,39 +3225,39 @@ function C(e) {
3171
3225
  const t = e.runId;
3172
3226
  return typeof t == "string" && t ? t : null;
3173
3227
  }
3174
- function Ir(e) {
3228
+ function Sr(e) {
3175
3229
  const t = e?.timeoutMs;
3176
- 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);
3230
+ 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 <= zs);
3177
3231
  }
3178
3232
  function He(e) {
3179
3233
  const t = {};
3180
3234
  try {
3181
3235
  new Headers(e).forEach((s, n) => {
3182
- Object.keys(t).length < Wt && (t[n] = Xt(n, s));
3236
+ Object.keys(t).length < Wt && (t[n] = Gt(n, s));
3183
3237
  });
3184
3238
  } catch {
3185
3239
  return {};
3186
3240
  }
3187
3241
  return t;
3188
3242
  }
3189
- function Xt(e, t) {
3190
- return Ge(e) ? ut : P(it(t), Ds);
3243
+ function Gt(e, t) {
3244
+ return Ge(e) ? ut : P(it(t), Ns);
3191
3245
  }
3192
- function Tr(e, t) {
3246
+ function Ar(e, t) {
3193
3247
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
3194
3248
  }
3195
- async function wr(e, t, s, n) {
3249
+ async function Er(e, t, s, n) {
3196
3250
  const r = He(e.headers);
3197
3251
  n({
3198
3252
  ...t,
3199
3253
  responseStatus: e.status,
3200
3254
  responseHeaders: r,
3201
- responseBody: await Sr(e),
3255
+ responseBody: await Rr(e),
3202
3256
  durationMs: Date.now() - s
3203
3257
  });
3204
3258
  }
3205
- async function Sr(e) {
3206
- if (!Fe(e.headers))
3259
+ async function Rr(e) {
3260
+ if (!We(e.headers))
3207
3261
  return;
3208
3262
  let t = null, s = null;
3209
3263
  try {
@@ -3212,7 +3266,7 @@ async function Sr(e) {
3212
3266
  const n = new Promise((a) => {
3213
3267
  s = window.setTimeout(() => {
3214
3268
  t?.cancel(), a("timeout");
3215
- }, Ns);
3269
+ }, xs);
3216
3270
  }), r = new TextDecoder();
3217
3271
  let i = "", o = 0;
3218
3272
  for (; ; ) {
@@ -3222,9 +3276,9 @@ async function Sr(e) {
3222
3276
  const { done: c, value: l } = a;
3223
3277
  if (c)
3224
3278
  return P(i + r.decode());
3225
- const u = Ft - o;
3226
- if (l.byteLength > u)
3227
- return i += r.decode(l.subarray(0, Math.max(u, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
3279
+ const h = Ht - o;
3280
+ if (l.byteLength > h)
3281
+ return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
3228
3282
  o += l.byteLength, i += r.decode(l, { stream: !0 });
3229
3283
  }
3230
3284
  } catch {
@@ -3234,8 +3288,8 @@ async function Sr(e) {
3234
3288
  s !== null && window.clearTimeout(s);
3235
3289
  }
3236
3290
  }
3237
- function Ar(e, t) {
3238
- if (Fe(new Headers(t)))
3291
+ function br(e, t) {
3292
+ if (We(new Headers(t)))
3239
3293
  try {
3240
3294
  return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
3241
3295
  } catch {
@@ -3246,8 +3300,8 @@ function Ae(e) {
3246
3300
  if (typeof e == "string")
3247
3301
  return P(e);
3248
3302
  }
3249
- function Er(e) {
3250
- return M({
3303
+ function Mr(e) {
3304
+ return k({
3251
3305
  ...e,
3252
3306
  requestBody: Ee(e.requestBody),
3253
3307
  responseBody: Ee(e.responseBody)
@@ -3260,19 +3314,19 @@ function Ee(e) {
3260
3314
  if (!t.startsWith("{") && !t.startsWith("["))
3261
3315
  return it(e);
3262
3316
  try {
3263
- return JSON.stringify(M(JSON.parse(e)));
3317
+ return JSON.stringify(k(JSON.parse(e)));
3264
3318
  } catch {
3265
3319
  return it(e);
3266
3320
  }
3267
3321
  }
3268
- function Fe(e) {
3322
+ function We(e) {
3269
3323
  if (!e)
3270
3324
  return !1;
3271
3325
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
3272
- return s !== null && Number.isInteger(n) && n >= 0 && n <= Ft && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3326
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= Ht && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3273
3327
  }
3274
- function v(e, t = {}, s) {
3275
- if (br(s))
3328
+ function x(e, t = {}, s) {
3329
+ if (_r(s))
3276
3330
  return !0;
3277
3331
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3278
3332
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3287,8 +3341,8 @@ function v(e, t = {}, s) {
3287
3341
  return !0;
3288
3342
  }
3289
3343
  }
3290
- function Rr(e, t) {
3291
- if (v(e))
3344
+ function kr(e, t) {
3345
+ if (x(e))
3292
3346
  return !0;
3293
3347
  try {
3294
3348
  const s = new URL(e, location.href), n = new URL(t);
@@ -3297,10 +3351,10 @@ function Rr(e, t) {
3297
3351
  return !0;
3298
3352
  }
3299
3353
  }
3300
- function br(e) {
3354
+ function _r(e) {
3301
3355
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
3302
3356
  }
3303
- function Mr(e) {
3357
+ function Cr(e) {
3304
3358
  const t = {};
3305
3359
  for (const s of e.trim().split(/[\r\n]+/)) {
3306
3360
  const n = s.indexOf(":");
@@ -3309,11 +3363,11 @@ function Mr(e) {
3309
3363
  if (Object.keys(t).length >= Wt)
3310
3364
  break;
3311
3365
  const r = s.slice(0, n).trim();
3312
- t[r] = Xt(r, s.slice(n + 1).trim());
3366
+ t[r] = Gt(r, s.slice(n + 1).trim());
3313
3367
  }
3314
3368
  return t;
3315
3369
  }
3316
- function P(e, t = Ft) {
3370
+ function P(e, t = Ht) {
3317
3371
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
3318
3372
  }
3319
3373
  function _t(e) {
@@ -3331,28 +3385,28 @@ async function tt(e, t) {
3331
3385
  try {
3332
3386
  return await e();
3333
3387
  } catch (r) {
3334
- if (s = r, n >= le - 1 || !_r(r))
3388
+ if (s = r, n >= le - 1 || !Ur(r))
3335
3389
  throw r;
3336
- await kr(n);
3390
+ await Pr(n);
3337
3391
  }
3338
3392
  throw s instanceof Error ? s : new Error(t);
3339
3393
  }
3340
- function kr(e) {
3394
+ function Pr(e) {
3341
3395
  return new Promise((t) => {
3342
- window.setTimeout(t, Us[e] ?? 0);
3396
+ window.setTimeout(t, Os[e] ?? 0);
3343
3397
  });
3344
3398
  }
3345
- function _r(e) {
3346
- return e instanceof nt ? Cr(e.status) : e instanceof TypeError;
3399
+ function Ur(e) {
3400
+ return e instanceof nt ? Dr(e.status) : e instanceof TypeError;
3347
3401
  }
3348
- function Cr(e) {
3402
+ function Dr(e) {
3349
3403
  return e === 408 || e === 409 || e === 429 || e >= 500;
3350
3404
  }
3351
- function Pr(e) {
3405
+ function vr(e) {
3352
3406
  return e === 401 || e === 403;
3353
3407
  }
3354
- 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 = /[),.;\]]+$/;
3355
- function M(e) {
3408
+ const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", Or = "[REDACTED_SIGNED_URL]", Nr = 20, xr = /^(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, $e = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, je = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ze = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ke = /\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, Lr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, qr = /\bhttps?:\/\/[^\s"'<>]+/gi, Br = /[),.;\]]+$/;
3409
+ function k(e) {
3356
3410
  return rt(e, 0, /* @__PURE__ */ new WeakSet());
3357
3411
  }
3358
3412
  function rt(e, t, s) {
@@ -3360,7 +3414,7 @@ function rt(e, t, s) {
3360
3414
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
3361
3415
  if (e === null || typeof e != "object")
3362
3416
  return e;
3363
- if (t >= Dr)
3417
+ if (t >= Nr)
3364
3418
  return "[REDACTED_MAX_DEPTH]";
3365
3419
  if (s.has(e))
3366
3420
  return "[REDACTED_CIRCULAR]";
@@ -3368,44 +3422,44 @@ function rt(e, t, s) {
3368
3422
  return e.map((r) => rt(r, t + 1, s));
3369
3423
  const n = {};
3370
3424
  for (const [r, i] of Object.entries(e))
3371
- r === "pageContent" ? n[r] = i : Ge(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Lr(i) : rt(i, t + 1, s);
3425
+ r === "pageContent" ? n[r] = i : Ge(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Fr(i) : rt(i, t + 1, s);
3372
3426
  return n;
3373
3427
  }
3374
3428
  function Ge(e) {
3375
3429
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
3376
3430
  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");
3377
3431
  }
3378
- function Lr(e) {
3432
+ function Fr(e) {
3379
3433
  return typeof e == "string" ? Xe(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3380
3434
  }
3381
3435
  function Xe(e) {
3382
3436
  try {
3383
3437
  const t = new URL(e, location.href);
3384
3438
  for (const s of Array.from(t.searchParams.keys()))
3385
- Nr.test(s) && t.searchParams.set(s, U);
3439
+ xr.test(s) && t.searchParams.set(s, U);
3386
3440
  return t.username && (t.username = U), t.password && (t.password = U), t.toString();
3387
3441
  } catch {
3388
- return qr(e);
3442
+ return Hr(e);
3389
3443
  }
3390
3444
  }
3391
3445
  function it(e) {
3392
- 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}`);
3446
+ return e.replace(Lr, Or).replace(qr, Wr).replace($e, `Bearer ${U}`).replace(je, `Basic ${U}`).replace(ze, U).replace(Ke, (t, s) => `${s}: ${ut}`);
3393
3447
  }
3394
- function qr(e) {
3395
- return e.replace(We, `Bearer ${U}`).replace($e, `Basic ${U}`).replace(je, U).replace(ze, (t, s) => `${s}: ${ut}`);
3448
+ function Hr(e) {
3449
+ return e.replace($e, `Bearer ${U}`).replace(je, `Basic ${U}`).replace(ze, U).replace(Ke, (t, s) => `${s}: ${ut}`);
3396
3450
  }
3397
- function Br(e) {
3398
- const t = e.match(vr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3451
+ function Wr(e) {
3452
+ const t = e.match(Br)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3399
3453
  return `${Xe(s)}${t}`;
3400
3454
  }
3401
3455
  export {
3402
3456
  ne as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3403
3457
  Pt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3404
- gs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3405
- fs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3406
- ms as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3458
+ Is as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3459
+ ys as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3460
+ Ts as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3407
3461
  _e as PlunoProductAgent,
3408
- vs as calculateReconnectDelay,
3462
+ Bs as calculateReconnectDelay,
3409
3463
  _e as default,
3410
- on as getProductAgentOriginAccessErrorMessage
3464
+ ln as getProductAgentOriginAccessErrorMessage
3411
3465
  };