@pluno/product-agent-web 0.1.132 → 0.1.134

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.
@@ -4,10 +4,10 @@ async function Xe(e) {
4
4
  const t = await vt();
5
5
  await Ve(t, "readwrite", (s) => s.put(e));
6
6
  }
7
- async function Je(e, t) {
7
+ async function Ke(e, t) {
8
8
  const s = await vt();
9
- await Ot(s, "readwrite", async (n) => {
10
- const r = await Nt(
9
+ await Nt(s, "readwrite", async (n) => {
10
+ const r = await Ot(
11
11
  n.get(e)
12
12
  );
13
13
  r && n.put({
@@ -16,11 +16,11 @@ async function Je(e, t) {
16
16
  });
17
17
  });
18
18
  }
19
- async function Ke(e = 864e5) {
19
+ async function Je(e = 864e5) {
20
20
  const t = await vt(), s = Date.now() - e;
21
- await Ot(t, "readwrite", async (n) => {
21
+ await Nt(t, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Nt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await Ot(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
26
  function vt() {
@@ -33,9 +33,9 @@ function vt() {
33
33
  });
34
34
  }
35
35
  async function Ve(e, t, s) {
36
- return await Ot(e, t, async (n) => await Nt(s(n)));
36
+ return await Nt(e, t, async (n) => await Ot(s(n)));
37
37
  }
38
- function Ot(e, t, s) {
38
+ function Nt(e, t, s) {
39
39
  return new Promise((n, r) => {
40
40
  const i = e.transaction(_t, t), o = i.objectStore(_t);
41
41
  let a, c = !1;
@@ -57,7 +57,7 @@ function Ot(e, t, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Nt(e) {
60
+ function Ot(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
  });
@@ -65,7 +65,7 @@ function Nt(e) {
65
65
  function Ye(e) {
66
66
  return e !== null && (typeof e == "object" || typeof e == "function");
67
67
  }
68
- function Te(e, t, s) {
68
+ function Ie(e, t, s) {
69
69
  const n = Reflect.get(e, "pluno"), r = Ye(n) ? n : {};
70
70
  if (r !== n && !Reflect.set(e, "pluno", r))
71
71
  return null;
@@ -80,10 +80,17 @@ function Te(e, t, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const It = "pluno.productAgent.transportId", Ze = "pluno.productAgent.transportIdentity", Tt = "pluno.productAgent.transportIdentity.event", Qe = 50, ts = globalThis.setTimeout.bind(globalThis);
83
+ const Ze = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function Qe(e, t) {
85
+ return t ? e.replace(
86
+ Ze,
87
+ (s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
88
+ ) : e;
89
+ }
90
+ const It = "pluno.productAgent.transportId", ts = "pluno.productAgent.transportIdentity", wt = "pluno.productAgent.transportIdentity.event", es = 50, ss = globalThis.setTimeout.bind(globalThis);
84
91
  let $ = null;
85
- const Q = /* @__PURE__ */ new Set(), wt = /* @__PURE__ */ new Map();
86
- async function es(e = we()) {
92
+ const tt = /* @__PURE__ */ new Set(), At = /* @__PURE__ */ new Map();
93
+ async function ns(e = we()) {
87
94
  const t = e.randomUUID(), s = e.storage.getItem(It);
88
95
  let n = s ?? e.randomUUID(), r = !1, i = !1;
89
96
  const o = e.channel.subscribe((c) => {
@@ -119,49 +126,49 @@ async function es(e = we()) {
119
126
  }
120
127
  };
121
128
  }
122
- async function ss() {
123
- $ || ($ = es(we()), $.then((n) => {
129
+ async function rs() {
130
+ $ || ($ = ns(we()), $.then((n) => {
124
131
  const r = (i) => {
125
- i.persisted || (n.release(), $ = null, Q.clear(), window.removeEventListener("pagehide", r));
132
+ i.persisted || (n.release(), $ = null, tt.clear(), window.removeEventListener("pagehide", r));
126
133
  };
127
134
  window.addEventListener("pagehide", r);
128
135
  }));
129
- const e = await $, t = ns();
130
- Q.add(t);
136
+ const e = await $, t = is();
137
+ tt.add(t);
131
138
  let s = !1;
132
139
  return {
133
140
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
134
141
  transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
135
142
  release: () => {
136
- s || (s = !0, Q.delete(t));
143
+ s || (s = !0, tt.delete(t));
137
144
  }
138
145
  };
139
146
  }
140
- function ns() {
147
+ function is() {
141
148
  let e = 0;
142
- for (; Q.has(e); )
149
+ for (; tt.has(e); )
143
150
  e += 1;
144
151
  return e;
145
152
  }
146
153
  function we() {
147
154
  return {
148
- storage: rs(),
149
- channel: is(),
155
+ storage: os(),
156
+ channel: as(),
150
157
  randomUUID: () => crypto.randomUUID(),
151
- settle: () => new Promise((e) => ts(e, Qe))
158
+ settle: () => new Promise((e) => ss(e, es))
152
159
  };
153
160
  }
154
- function rs() {
161
+ function os() {
155
162
  return {
156
163
  getItem: (e) => {
157
164
  try {
158
- return window.sessionStorage?.getItem(e) ?? wt.get(e) ?? null;
165
+ return window.sessionStorage?.getItem(e) ?? At.get(e) ?? null;
159
166
  } catch {
160
- return wt.get(e) ?? null;
167
+ return At.get(e) ?? null;
161
168
  }
162
169
  },
163
170
  setItem: (e, t) => {
164
- wt.set(e, t);
171
+ At.set(e, t);
165
172
  try {
166
173
  window.sessionStorage?.setItem(e, t);
167
174
  } catch {
@@ -169,9 +176,9 @@ function rs() {
169
176
  }
170
177
  };
171
178
  }
172
- function is() {
179
+ function as() {
173
180
  if (typeof BroadcastChannel < "u") {
174
- const e = new BroadcastChannel(Ze);
181
+ const e = new BroadcastChannel(ts);
175
182
  return {
176
183
  postMessage: (t) => e.postMessage(t),
177
184
  subscribe: (t) => {
@@ -181,11 +188,11 @@ function is() {
181
188
  close: () => e.close()
182
189
  };
183
190
  }
184
- return os();
191
+ return cs();
185
192
  }
186
- function os() {
193
+ function cs() {
187
194
  const e = /* @__PURE__ */ new Set(), t = (s) => {
188
- if (s.key !== Tt || !s.newValue)
195
+ if (s.key !== wt || !s.newValue)
189
196
  return;
190
197
  const n = JSON.parse(s.newValue);
191
198
  for (const r of e)
@@ -194,9 +201,9 @@ function os() {
194
201
  return window.addEventListener("storage", t), {
195
202
  postMessage: (s) => {
196
203
  window.localStorage.setItem(
197
- Tt,
204
+ wt,
198
205
  JSON.stringify({ ...s, eventId: crypto.randomUUID() })
199
- ), window.localStorage.removeItem(Tt);
206
+ ), window.localStorage.removeItem(wt);
200
207
  },
201
208
  subscribe: (s) => (e.add(s), () => e.delete(s)),
202
209
  close: () => {
@@ -204,18 +211,18 @@ function os() {
204
211
  }
205
212
  };
206
213
  }
207
- const as = globalThis.fetch.bind(globalThis), Mt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', cs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ls = ".pluno-pa-widget__panel", us = ".pluno-pa-widget__timeline", te = `${Mt}[data-pluno-sdk-preview-channel]`, ds = "https://app.pluno.ai", hs = "gpt-5.6-terra", ps = 2e4, fs = 1e4, gs = 1e4, ms = 1e4, ys = 1e4, Is = 1e3, ee = 3e4, se = 0.2, ne = 6e4, Ts = 15e3, K = 8, ws = 15e3, Ss = 2e3, As = 1e3, bs = 100, Es = 8e3, re = 3, ks = [300, 1e3], Lt = 64e3, St = 4e3, Bt = 30, Rs = 2e3, _s = 1e3, Se = "Image is too large for model vision input.", Ms = 100, Ae = "pluno.productAgent.state.", Ct = "pluno.productAgent.pendingEvents.", rt = "pluno.productAgent.activeToolCalls.", Cs = 100;
214
+ const ls = globalThis.fetch.bind(globalThis), Mt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', us = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ds = ".pluno-pa-widget__panel", hs = ".pluno-pa-widget__timeline", te = `${Mt}[data-pluno-sdk-preview-channel]`, ps = "https://app.pluno.ai", fs = "gpt-5.6-terra", gs = 2e4, ms = 1e4, ys = 1e4, Ts = 1e4, Is = 1e4, ws = 1e3, ee = 3e4, se = 0.2, ne = 6e4, As = 15e3, J = 8, Ss = 15e3, Es = 2e3, bs = 1e3, ks = 100, Rs = 8e3, re = 3, _s = [300, 1e3], Lt = 64e3, St = 4e3, Bt = 30, Ms = 2e3, Cs = 1e3, Ae = "Image is too large for model vision input.", Ps = 100, Se = "pluno.productAgent.state.", Ct = "pluno.productAgent.pendingEvents.", it = "pluno.productAgent.activeToolCalls.", Us = 100;
208
215
  function V(e, t = 0) {
209
216
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
210
217
  return Math.max(t, s);
211
218
  }
212
- const tt = /* @__PURE__ */ new Set();
219
+ const et = /* @__PURE__ */ new Set();
213
220
  let Y = null;
214
- function Ps(e, t = Math.random) {
215
- const s = Math.min(ee, Is * 2 ** e), n = 1 - se + t() * se * 2;
221
+ function Ds(e, t = Math.random) {
222
+ const s = Math.min(ee, ws * 2 ** e), n = 1 - se + t() * se * 2;
216
223
  return Math.min(ee, Math.round(s * n));
217
224
  }
218
- function Us(e, t, s) {
225
+ function xs(e, t, s) {
219
226
  return new Promise((n, r) => {
220
227
  const i = setTimeout(() => r(new Error(s)), t);
221
228
  e.then(
@@ -228,13 +235,13 @@ function Us(e, t, s) {
228
235
  );
229
236
  });
230
237
  }
231
- class be {
238
+ class Ee {
232
239
  constructor(t, s) {
233
240
  this.options = t, this.transportIdentity = s, this.state = {
234
241
  ...this.state,
235
- starterPrompts: hn(t.initialStarterPrompts)
242
+ starterPrompts: fn(t.initialStarterPrompts)
236
243
  };
237
- const n = t.restorePersistedState === !1 ? null : Vn(t.clientId, t.expectedPersistedSessionId);
244
+ const n = t.restorePersistedState === !1 ? null : Zn(t.clientId, t.expectedPersistedSessionId);
238
245
  n && (this.state = {
239
246
  ...this.state,
240
247
  ...n,
@@ -247,9 +254,9 @@ class be {
247
254
  assistantDraftRunId: null,
248
255
  isThinking: !1,
249
256
  lastError: null
250
- }), this.queuedClientEvents = nr(
251
- Zn(t.clientId),
252
- tr(t.clientId)
257
+ }), this.queuedClientEvents = ir(
258
+ tr(t.clientId),
259
+ sr(t.clientId)
253
260
  ), W(t.clientId, this.queuedClientEvents);
254
261
  }
255
262
  options;
@@ -317,16 +324,16 @@ class be {
317
324
  lastErrorSecuritySettingsUrl: null
318
325
  };
319
326
  static async init(t) {
320
- const s = await ss(), n = new be({
327
+ const s = await rs(), n = new Ee({
321
328
  ...t,
322
- backendUrl: Vs(t.backendUrl ?? ds),
323
- clientId: t.clientId ?? yn(),
324
- model: t.model ?? hs,
325
- entrySurface: Ys(t.entrySurface)
329
+ backendUrl: Zs(t.backendUrl ?? ps),
330
+ clientId: t.clientId ?? In(),
331
+ model: t.model ?? fs,
332
+ entrySurface: Qs(t.entrySurface)
326
333
  }, s);
327
334
  try {
328
- Ke().catch((r) => {
329
- S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
335
+ Je().catch((r) => {
336
+ A("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
330
337
  message: r instanceof Error ? r.message : String(r)
331
338
  });
332
339
  }), t.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), t.autoConnect !== !1 && await n.connect();
@@ -357,15 +364,15 @@ class be {
357
364
  lastError: null
358
365
  });
359
366
  try {
360
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Us(this.options.tokenProvider(), gs, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
367
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await xs(this.options.tokenProvider(), ys, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
361
368
  return;
362
369
  if (!this.token && !this.options.webSocketFactory)
363
370
  throw new Error("Pluno requires a token or tokenProvider");
364
- const s = tn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
371
+ const s = sn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
365
372
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
366
- this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
367
- }, ms), n.addEventListener("open", () => {
368
- this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
373
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (A("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
374
+ }, Ts), n.addEventListener("open", () => {
375
+ this.socket !== n || (this.clearSocketConnectTimer(), A("web-sdk.agent", "Pluno socket opened", {
369
376
  queuedClientEventCount: this.queuedClientEvents.length,
370
377
  isThinking: this.state.isThinking
371
378
  }), !(this.token ? this.sendNow({
@@ -375,12 +382,12 @@ class be {
375
382
  transportId: this.transportIdentity.transportId,
376
383
  pageUrl: location.href
377
384
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
378
- this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
379
- }, ys));
385
+ this.socket === n && (A("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
386
+ }, Is));
380
387
  }), n.addEventListener("message", (r) => {
381
- this.socket === n && this.handleServerEvent(dn(r.data));
388
+ this.socket === n && this.handleServerEvent(pn(r.data));
382
389
  }), n.addEventListener("close", (r) => {
383
- this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
390
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (A("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
384
391
  code: typeof r?.code == "number" ? r.code : null,
385
392
  reason: typeof r?.reason == "string" ? r.reason : "",
386
393
  wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
@@ -388,7 +395,7 @@ class be {
388
395
  isThinking: this.state.isThinking
389
396
  }), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
390
397
  }), n.addEventListener("error", () => {
391
- this.socket !== n || this.state.status === "closed" || (S("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
398
+ this.socket !== n || this.state.status === "closed" || (A("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
392
399
  queuedClientEventCount: this.queuedClientEvents.length,
393
400
  isThinking: this.state.isThinking
394
401
  }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
@@ -411,7 +418,7 @@ class be {
411
418
  this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
412
419
  }
413
420
  destroy() {
414
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), rr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
421
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), or(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
415
422
  for (const t of Object.values(this.listeners))
416
423
  t?.clear();
417
424
  }
@@ -420,7 +427,7 @@ class be {
420
427
  let i = r.map(Wt);
421
428
  if (!n && i.length === 0)
422
429
  return null;
423
- const o = _(), a = s.clientMessageId ?? Et(), c = {
430
+ const o = _(), a = s.clientMessageId ?? kt(), c = {
424
431
  id: `local-${a}`,
425
432
  role: "user",
426
433
  content: n,
@@ -471,7 +478,7 @@ class be {
471
478
  sessionId: this.state.sessionId ?? void 0,
472
479
  clientMessageId: a,
473
480
  initiatedBy: s.initiatedBy,
474
- invocation: Zs(s.invocation ?? s.initiatedBy),
481
+ invocation: tn(s.invocation ?? s.initiatedBy),
475
482
  entrySurface: this.options.entrySurface,
476
483
  content: n,
477
484
  pageContent: y && qt() || void 0,
@@ -487,7 +494,7 @@ class be {
487
494
  return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
488
495
  }
489
496
  createLocalAttachment(t) {
490
- const s = Et(), n = {
497
+ const s = kt(), n = {
491
498
  id: s,
492
499
  name: t.name || "attachment",
493
500
  mimeType: me(t),
@@ -506,7 +513,7 @@ class be {
506
513
  createdAt: r,
507
514
  lastUsedAt: r
508
515
  }).catch((i) => {
509
- S("web-sdk.attachments", "Failed to store Product Agent attachment", {
516
+ A("web-sdk.attachments", "Failed to store Product Agent attachment", {
510
517
  attachmentId: s,
511
518
  name: n.name,
512
519
  message: i instanceof Error ? i.message : String(i)
@@ -536,28 +543,38 @@ class be {
536
543
  model: this.options.model,
537
544
  metadata: ie(this.options.metadata),
538
545
  entrySurface: this.options.entrySurface
539
- }, o = this.options.prepareAttachmentUpload ? await Rt(
540
- () => this.options.prepareAttachmentUpload(i),
541
- "Failed to prepare attachment upload"
542
- ) : await this.prepareEmbedAttachmentUpload(i);
543
- await Rt(async () => {
544
- const c = await fetch(new URL(o.uploadUrl, this.options.backendUrl), {
545
- method: o.uploadMethod,
546
- headers: o.uploadHeaders,
547
- body: t
548
- });
549
- if (!c.ok)
550
- throw new et("Failed to upload attachment", c.status);
551
- return c;
552
- }, "Failed to upload attachment"), this.setState({ sessionId: o.sessionId });
553
- const a = Oe(o.attachment, this.options.backendUrl);
554
- return this.updateAttachmentInState(s.id, a), s.id && Je(s.id, {
546
+ };
547
+ let o;
548
+ if (this.options.persistAttachmentUpload)
549
+ o = await Q(
550
+ () => this.options.persistAttachmentUpload(i, t),
551
+ "Failed to upload attachment"
552
+ );
553
+ else {
554
+ const c = this.options.prepareAttachmentUpload ? await Q(
555
+ () => this.options.prepareAttachmentUpload(i),
556
+ "Failed to prepare attachment upload"
557
+ ) : await this.prepareEmbedAttachmentUpload(i);
558
+ await Q(async () => {
559
+ const l = await fetch(new URL(c.uploadUrl, this.options.backendUrl), {
560
+ method: c.uploadMethod,
561
+ headers: c.uploadHeaders,
562
+ body: t
563
+ });
564
+ if (!l.ok)
565
+ throw new st("Failed to upload attachment", l.status);
566
+ return l;
567
+ }, "Failed to upload attachment"), o = c;
568
+ }
569
+ this.setState({ sessionId: o.sessionId });
570
+ const a = Ne(o.attachment, this.options.backendUrl);
571
+ return this.updateAttachmentInState(s.id, a), s.id && Ke(s.id, {
555
572
  sessionId: o.sessionId,
556
573
  fileUrl: a.fileUrl,
557
574
  sandboxPath: a.sandboxPath,
558
575
  lastUsedAt: Date.now()
559
576
  }).catch((c) => {
560
- S("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
577
+ A("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
561
578
  attachmentId: s.id,
562
579
  name: a.name,
563
580
  message: c instanceof Error ? c.message : String(c)
@@ -577,18 +594,18 @@ class be {
577
594
  }
578
595
  async prepareEmbedAttachmentUpload(t) {
579
596
  let s = !1;
580
- return await Rt(async () => {
597
+ return await Q(async () => {
581
598
  const n = await this.fetchEmbedAttachmentUpload(t);
582
599
  if (n.ok)
583
600
  return await n.json();
584
- if (wr(n.status) && this.options.tokenProvider && !s) {
601
+ if (Sr(n.status) && this.options.tokenProvider && !s) {
585
602
  s = !0;
586
603
  const r = await this.fetchEmbedAttachmentUpload(t);
587
604
  if (r.ok)
588
605
  return await r.json();
589
- throw new et("Failed to prepare attachment upload", r.status);
606
+ throw new st("Failed to prepare attachment upload", r.status);
590
607
  }
591
- throw new et("Failed to prepare attachment upload", n.status);
608
+ throw new st("Failed to prepare attachment upload", n.status);
592
609
  }, "Failed to prepare attachment upload");
593
610
  }
594
611
  async fetchEmbedAttachmentUpload(t) {
@@ -625,10 +642,10 @@ class be {
625
642
  });
626
643
  }
627
644
  listSessions(t = {}) {
628
- const s = Et(), n = new Promise((i, o) => {
645
+ const s = kt(), n = new Promise((i, o) => {
629
646
  const a = window.setTimeout(() => {
630
647
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
631
- }, Es);
648
+ }, Rs);
632
649
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
633
650
  }), r = {
634
651
  type: "sessions.list",
@@ -676,7 +693,7 @@ class be {
676
693
  try {
677
694
  return s.send(JSON.stringify(t)), !0;
678
695
  } catch (n) {
679
- return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
696
+ return A("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
680
697
  message: n instanceof Error ? n.message : String(n),
681
698
  queuedClientEventCount: this.queuedClientEvents.length,
682
699
  isThinking: this.state.isThinking
@@ -687,7 +704,7 @@ class be {
687
704
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
688
705
  return;
689
706
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
690
- const t = en();
707
+ const t = nn();
691
708
  this.sendNow(
692
709
  k({
693
710
  type: "starter_prompts.page_context",
@@ -698,13 +715,13 @@ class be {
698
715
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
699
716
  }
700
717
  startStarterPromptUrlWatcher() {
701
- this.locationChangeCleanup || (this.locationChangeCleanup = sn(() => this.handleStarterPromptUrlChange()));
718
+ this.locationChangeCleanup || (this.locationChangeCleanup = rn(() => this.handleStarterPromptUrlChange()));
702
719
  }
703
720
  handleStarterPromptUrlChange() {
704
721
  const t = location.href;
705
722
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
706
723
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
707
- }, Cs));
724
+ }, Us));
708
725
  }
709
726
  refreshStarterPromptsForCurrentUrl() {
710
727
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -738,19 +755,19 @@ class be {
738
755
  this.clearHeartbeatAckTimer();
739
756
  return;
740
757
  }
741
- if (vs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
758
+ if (Os(t) && this.markThinkingProgress(), t.type === "auth.ok") {
742
759
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
743
- const s = pn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
744
- S("web-sdk.agent", "Received auth.ok appearance", {
760
+ const s = gn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
761
+ A("web-sdk.agent", "Received auth.ok appearance", {
745
762
  hasAppearance: n,
746
763
  rawAppearance: t.appearance,
747
764
  normalizedAppearance: s
748
- }), this.runtimeHelperJavascript = fn(t.runtimeHelpers)?.javascript ?? null;
765
+ }), this.runtimeHelperJavascript = mn(t.runtimeHelpers)?.javascript ?? null;
749
766
  const r = ce(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
750
- user: In(t.user),
767
+ user: wn(t.user),
751
768
  status: "connected"
752
769
  };
753
- (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 && !rn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
770
+ (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 && !an() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
754
771
  type: "page.upsert",
755
772
  sessionId: this.state.sessionId,
756
773
  page: _(),
@@ -766,24 +783,24 @@ class be {
766
783
  return;
767
784
  }
768
785
  if (t.type === "conversation.state") {
769
- const s = Array.isArray(t.items) ? t.items : [], n = Rn(
786
+ const s = Array.isArray(t.items) ? t.items : [], n = Mn(
770
787
  t.assistantDraft
771
788
  ), r = n !== void 0;
772
789
  this.rememberUserMessageClientMessageIds(s);
773
- const i = Hn(s);
790
+ const i = $n(s);
774
791
  if (i) {
775
- const f = Fn(s, i);
792
+ const f = Wn(s, i);
776
793
  this.retryAttemptsByClientMessageId[i] = Math.max(
777
794
  this.retryAttemptsByClientMessageId[i] ?? 0,
778
795
  f
779
796
  );
780
797
  }
781
798
  const o = s.filter((f) => {
782
- const I = L(f);
783
- return !he(I) && (!i || !Pt(I));
784
- }), a = Dn(
799
+ const T = L(f);
800
+ return !he(T) && (!i || !Pt(T));
801
+ }), a = vn(
785
802
  this.state.messages,
786
- Tn(o, this.options.backendUrl)
803
+ An(o, this.options.backendUrl)
787
804
  ), c = de(a), l = !r && s.some(
788
805
  (f) => fe(
789
806
  L(f),
@@ -792,13 +809,13 @@ class be {
792
809
  this.state.assistantDraftRespondsToUserMessageId,
793
810
  this.state.assistantDraftRunId
794
811
  )
795
- ), d = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, y = c && (!d || l), m = Nn(a), u = y && m;
796
- if (!c && qn(this.state.messages, s))
812
+ ), d = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, y = c && (!d || l), m = Bn(a), u = y && m;
813
+ if (!c && Fn(this.state.messages, s))
797
814
  return;
798
- this.lastUserMessagePageUrl = Bn(s);
815
+ this.lastUserMessagePageUrl = Hn(s);
799
816
  const h = y ? null : Ut(s);
800
817
  if (this.latestRecoverableClientMessageId = h, m && this.clearRetryTimers(), this.setState({
801
- sessionId: b(t.session, "id") ?? this.state.sessionId,
818
+ sessionId: E(t.session, "id") ?? this.state.sessionId,
802
819
  messages: a,
803
820
  ...r ? {
804
821
  assistantDraft: n?.content ?? "",
@@ -829,7 +846,7 @@ class be {
829
846
  lastError: null
830
847
  } : {}
831
848
  }), y ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (p || h) && (h && (this.activeClientMessageId = h), this.markThinkingProgress()), i) {
832
- const f = b(t.session, "id") ?? this.state.sessionId;
849
+ const f = E(t.session, "id") ?? this.state.sessionId;
833
850
  f && this.retryAfterInterruptedRun(f, i);
834
851
  }
835
852
  return;
@@ -837,13 +854,13 @@ class be {
837
854
  if (t.type === "sessions.page") {
838
855
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
839
856
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
840
- sessions: wn(t.sessions),
857
+ sessions: Sn(t.sessions),
841
858
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
842
859
  }));
843
860
  return;
844
861
  }
845
862
  if (t.type === "session.updated") {
846
- this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: b(t.session, "id") ?? this.state.sessionId });
863
+ this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: E(t.session, "id") ?? this.state.sessionId });
847
864
  return;
848
865
  }
849
866
  if (t.type === "session.item") {
@@ -851,7 +868,7 @@ class be {
851
868
  const s = L(t.item);
852
869
  if (Pt(s)) {
853
870
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
854
- const r = b(t.item, "sessionId") ?? this.state.sessionId, i = s ? v(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
871
+ const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? v(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
855
872
  if (r && a) {
856
873
  this.retryAfterInterruptedRun(r, a);
857
874
  return;
@@ -868,7 +885,7 @@ class be {
868
885
  const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
869
886
  n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), q(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
870
887
  const i = t.item.data;
871
- Wn(i) && this.clearRunAckResyncRetryTimer();
888
+ zn(i) && this.clearRunAckResyncRetryTimer();
872
889
  const o = Ce(this.state.messages, n), a = de(o), c = fe(
873
890
  i,
874
891
  this.state.assistantDraft,
@@ -929,9 +946,9 @@ class be {
929
946
  }
930
947
  if (t.type === "tool.call") {
931
948
  this.clearRunAckResyncRetryTimer();
932
- const s = Pn(t);
949
+ const s = Dn(t);
933
950
  if (s) {
934
- const n = Mn(
951
+ const n = Pn(
935
952
  this.state.messages,
936
953
  s
937
954
  );
@@ -972,7 +989,7 @@ class be {
972
989
  return;
973
990
  }
974
991
  o && r && i && (this.retryableClientMessageId = i);
975
- const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = Qs(a.message);
992
+ const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = en(a.message);
976
993
  c && console.error(c), this.setState({
977
994
  status: "error",
978
995
  isThinking: !1,
@@ -998,7 +1015,7 @@ class be {
998
1015
  if (this.retryTimersByClientMessageId[n] !== void 0)
999
1016
  return !0;
1000
1017
  const i = this.retryAttemptsByClientMessageId[n] ?? 0;
1001
- if (i >= K)
1018
+ if (i >= J)
1002
1019
  return !1;
1003
1020
  this.retryAttemptsByClientMessageId[n] = i + 1;
1004
1021
  const o = V(
@@ -1018,7 +1035,7 @@ class be {
1018
1035
  if (this.retryTimersByClientMessageId[s] !== void 0)
1019
1036
  return;
1020
1037
  const n = this.retryAttemptsByClientMessageId[s] ?? 0;
1021
- if (n >= K) {
1038
+ if (n >= J) {
1022
1039
  this.retryableClientMessageId = s, this.setState({
1023
1040
  isThinking: !1,
1024
1041
  lastError: "Pluno could not finish this message. Try it again.",
@@ -1037,7 +1054,7 @@ class be {
1037
1054
  }
1038
1055
  rememberUserMessageClientMessageIds(t) {
1039
1056
  for (const s of t) {
1040
- const n = b(s, "id"), r = L(s);
1057
+ const n = E(s, "id"), r = L(s);
1041
1058
  n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
1042
1059
  }
1043
1060
  }
@@ -1067,10 +1084,10 @@ class be {
1067
1084
  scheduleRunAckWatchdog(t) {
1068
1085
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1069
1086
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1070
- }, ws);
1087
+ }, Ss);
1071
1088
  }
1072
1089
  recoverMissedRunAck(t) {
1073
- !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
1090
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (A("web-sdk.agent", "Pluno run ack missed; resyncing session", {
1074
1091
  sessionId: this.state.sessionId,
1075
1092
  clientMessageId: t
1076
1093
  }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
@@ -1078,12 +1095,12 @@ class be {
1078
1095
  scheduleRunAckResyncRetry(t) {
1079
1096
  this.clearRunAckResyncRetryTimer();
1080
1097
  const s = this.retryAttemptsByClientMessageId[t] ?? 0;
1081
- s >= K || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1098
+ s >= J || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1082
1099
  this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
1083
1100
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1084
1101
  isThinking: !0,
1085
1102
  lastError: null
1086
- }), S("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
1103
+ }), A("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
1087
1104
  sessionId: this.state.sessionId,
1088
1105
  clientMessageId: t
1089
1106
  }), this.state.sessionId ? this.send({
@@ -1092,7 +1109,7 @@ class be {
1092
1109
  clientMessageId: t,
1093
1110
  automatic: !0
1094
1111
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ne)));
1095
- }, V(s, Ss)));
1112
+ }, V(s, Es)));
1096
1113
  }
1097
1114
  clearRunAckResyncRetryTimer() {
1098
1115
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1105,7 +1122,7 @@ class be {
1105
1122
  return;
1106
1123
  const t = this.activeClientMessageId;
1107
1124
  if (!t) {
1108
- S("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
1125
+ A("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
1109
1126
  sessionId: this.state.sessionId
1110
1127
  }), this.setState({
1111
1128
  isThinking: !1,
@@ -1115,8 +1132,8 @@ class be {
1115
1132
  return;
1116
1133
  }
1117
1134
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
1118
- if (n >= K) {
1119
- S("web-sdk.agent", "Pluno run recovery retry exhausted", {
1135
+ if (n >= J) {
1136
+ A("web-sdk.agent", "Pluno run recovery retry exhausted", {
1120
1137
  sessionId: this.state.sessionId,
1121
1138
  clientMessageId: t
1122
1139
  }), this.retryableClientMessageId = t, this.setState({
@@ -1127,18 +1144,18 @@ class be {
1127
1144
  return;
1128
1145
  }
1129
1146
  if (s < 1) {
1130
- this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, S("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
1147
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, A("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
1131
1148
  sessionId: this.state.sessionId,
1132
1149
  clientMessageId: t,
1133
1150
  resyncAttempts: s + 1
1134
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ts);
1151
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(As);
1135
1152
  return;
1136
1153
  }
1137
1154
  this.setState({
1138
1155
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1139
1156
  isThinking: !0,
1140
1157
  lastError: null
1141
- }), S("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
1158
+ }), A("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
1142
1159
  sessionId: this.state.sessionId,
1143
1160
  clientMessageId: t,
1144
1161
  retryAttempts: n + 1
@@ -1160,13 +1177,13 @@ class be {
1160
1177
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
1161
1178
  }
1162
1179
  async executeToolCall(t) {
1163
- const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = N(
1180
+ const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = O(
1164
1181
  typeof t.summary == "string" ? t.summary : "Running browser tool"
1165
1182
  ), o = t.rawInput;
1166
1183
  if (!s || !n || !r)
1167
1184
  return;
1168
1185
  const a = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1169
- if (r !== "execute_code" && !a || !cr(o)) {
1186
+ if (r !== "execute_code" && !a || !ur(o)) {
1170
1187
  this.setToolMessageLoading(n, !1), this.send({
1171
1188
  type: "tool.result",
1172
1189
  sessionId: s,
@@ -1198,7 +1215,7 @@ class be {
1198
1215
  });
1199
1216
  return;
1200
1217
  }
1201
- const c = Ls(this.state.messages);
1218
+ const c = qs(this.state.messages);
1202
1219
  this.activeBrowserToolCalls.set(n, {
1203
1220
  event: {
1204
1221
  type: "tool.result",
@@ -1216,7 +1233,7 @@ class be {
1216
1233
  let l = null, d;
1217
1234
  l = await this.executeRuntimeHelper(), d = await oe(
1218
1235
  o,
1219
- Js(t.runtimeContext, this.options.backendUrl)
1236
+ Vs(t.runtimeContext, this.options.backendUrl)
1220
1237
  ).catch((p) => ({
1221
1238
  ok: !1,
1222
1239
  exception: {
@@ -1229,11 +1246,11 @@ class be {
1229
1246
  toolName: r,
1230
1247
  summary: o.summary,
1231
1248
  rawInput: k(o),
1232
- rawOutput: k(gn(d, l))
1233
- }), Qn(this.options.clientId, this.activeBrowserToolCalls.values());
1249
+ rawOutput: k(yn(d, l))
1250
+ }), er(this.options.clientId, this.activeBrowserToolCalls.values());
1234
1251
  }
1235
1252
  setToolMessageLoading(t, s) {
1236
- const n = Cn(
1253
+ const n = Un(
1237
1254
  this.state.messages,
1238
1255
  t,
1239
1256
  s
@@ -1251,10 +1268,10 @@ class be {
1251
1268
  };
1252
1269
  }
1253
1270
  installSessionUserFilesApi(t) {
1254
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Bs(t, this.attachmentFiles, this.attachmentBlobCache);
1271
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Hs(t, this.attachmentFiles, this.attachmentBlobCache);
1255
1272
  }
1256
1273
  cleanupSessionUserFilesApi() {
1257
- this.sessionUserFilesApiCleanup && (Gs(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1274
+ this.sessionUserFilesApiCleanup && (Ks(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1258
1275
  }
1259
1276
  async executeRuntimeHelper() {
1260
1277
  if (!this.runtimeHelperJavascript?.trim())
@@ -1262,15 +1279,15 @@ class be {
1262
1279
  const t = await oe({
1263
1280
  javascript: this.runtimeHelperJavascript
1264
1281
  });
1265
- return t.ok === !1 ? mn(t) : null;
1282
+ return t.ok === !1 ? Tn(t) : null;
1266
1283
  }
1267
1284
  enableNetworkCapture() {
1268
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Ds((t) => {
1269
- fr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1285
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = vs((t) => {
1286
+ mr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1270
1287
  }));
1271
1288
  }
1272
1289
  enqueueNetworkEvent(t) {
1273
- this.queuedNetworkEvents.length >= bs || (this.queuedNetworkEvents.push(pr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1290
+ this.queuedNetworkEvents.length >= ks || (this.queuedNetworkEvents.push(gr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1274
1291
  this.networkBatchTimer = null;
1275
1292
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1276
1293
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1279,15 +1296,15 @@ class be {
1279
1296
  page: _(),
1280
1297
  events: s
1281
1298
  });
1282
- }, As)));
1299
+ }, bs)));
1283
1300
  }
1284
1301
  scheduleReconnect() {
1285
1302
  if (this.reconnectTimer !== null || this.state.status === "closed")
1286
1303
  return;
1287
- const t = Ps(this.reconnectAttempts);
1304
+ const t = Ds(this.reconnectAttempts);
1288
1305
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1289
1306
  this.reconnectTimer = null, this.connect().catch((s) => {
1290
- S("web-sdk.agent", "Pluno reconnect failed; retrying", {
1307
+ A("web-sdk.agent", "Pluno reconnect failed; retrying", {
1291
1308
  message: s instanceof Error ? s.message : String(s),
1292
1309
  queuedClientEventCount: this.queuedClientEvents.length,
1293
1310
  isThinking: this.state.isThinking
@@ -1299,9 +1316,9 @@ class be {
1299
1316
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
1300
1317
  const t = this.socket;
1301
1318
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1302
- this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1303
- }, fs));
1304
- }, ps);
1319
+ this.socket === t && (A("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1320
+ }, ms));
1321
+ }, gs);
1305
1322
  }
1306
1323
  stopHeartbeat() {
1307
1324
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1327,20 +1344,20 @@ class be {
1327
1344
  ...t,
1328
1345
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1329
1346
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1330
- }, Yn(this.options.clientId, this.state), this.emit("state", this.getState());
1347
+ }, Qn(this.options.clientId, this.state), this.emit("state", this.getState());
1331
1348
  }
1332
1349
  emit(t, s) {
1333
1350
  this.listeners[t]?.forEach((r) => r(s));
1334
1351
  }
1335
1352
  }
1336
- const At = /* @__PURE__ */ new WeakMap();
1337
- function Ds(e) {
1338
- const t = window.__plunoProductAgentNetworkCapture ?? xs();
1353
+ const Et = /* @__PURE__ */ new WeakMap();
1354
+ function vs(e) {
1355
+ const t = window.__plunoProductAgentNetworkCapture ?? Ns();
1339
1356
  return t.subscribers.add(e), () => {
1340
1357
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1341
1358
  };
1342
1359
  }
1343
- function xs() {
1360
+ function Ns() {
1344
1361
  const e = /* @__PURE__ */ new Set(), t = (y) => {
1345
1362
  e.forEach((m) => {
1346
1363
  try {
@@ -1353,24 +1370,24 @@ function xs() {
1353
1370
  let f;
1354
1371
  try {
1355
1372
  f = s.call(this, m, u);
1356
- } catch (I) {
1357
- throw I;
1373
+ } catch (T) {
1374
+ throw T;
1358
1375
  }
1359
1376
  try {
1360
- const I = m instanceof Request ? m : null, x = lr(m, I), T = Ne(u?.headers ?? I?.headers);
1361
- if (!O(x, T, u?.body)) {
1377
+ const T = m instanceof Request ? m : null, x = dr(m, T), I = Oe(u?.headers ?? T?.headers);
1378
+ if (!N(x, I, u?.body)) {
1362
1379
  const H = {
1363
- requestId: kt("fetch"),
1380
+ requestId: Rt("fetch"),
1364
1381
  url: C(x, St),
1365
- method: (u?.method ?? I?.method ?? "GET").toUpperCase(),
1366
- requestHeaders: T,
1382
+ method: (u?.method ?? T?.method ?? "GET").toUpperCase(),
1383
+ requestHeaders: I,
1367
1384
  requestBody: ye(u?.body),
1368
1385
  resourceType: "fetch",
1369
1386
  startedAt: new Date(h).toISOString()
1370
1387
  };
1371
1388
  f.then(
1372
1389
  (R) => {
1373
- ur(R, H, h, t).catch(() => {
1390
+ hr(R, H, h, t).catch(() => {
1374
1391
  t({
1375
1392
  ...H,
1376
1393
  responseStatus: R.status,
@@ -1390,29 +1407,29 @@ function xs() {
1390
1407
  } catch {
1391
1408
  }
1392
1409
  return f;
1393
- }, a = function(m, u, h, f, I) {
1394
- const x = n.call(this, m, u, h ?? !0, f ?? void 0, I ?? void 0), T = typeof u == "string" ? u : u.toString();
1395
- return At.set(this, {
1396
- requestId: kt("xhr"),
1410
+ }, a = function(m, u, h, f, T) {
1411
+ const x = n.call(this, m, u, h ?? !0, f ?? void 0, T ?? void 0), I = typeof u == "string" ? u : u.toString();
1412
+ return Et.set(this, {
1413
+ requestId: Rt("xhr"),
1397
1414
  method: String(m ?? "GET").toUpperCase(),
1398
- url: C(T, St),
1415
+ url: C(I, St),
1399
1416
  requestHeaders: {},
1400
1417
  startedAtMs: Date.now(),
1401
1418
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1402
- excluded: O(T)
1419
+ excluded: N(I)
1403
1420
  }), x;
1404
1421
  }, c = function(m, u) {
1405
- const h = r.call(this, m, u), f = At.get(this);
1406
- return f && Object.keys(f.requestHeaders).length < Bt && (f.requestHeaders[m] = jt(m, u), f.excluded = f.excluded || O(f.url, f.requestHeaders)), h;
1422
+ const h = r.call(this, m, u), f = Et.get(this);
1423
+ return f && Object.keys(f.requestHeaders).length < Bt && (f.requestHeaders[m] = jt(m, u), f.excluded = f.excluded || N(f.url, f.requestHeaders)), h;
1407
1424
  }, l = function(m) {
1408
1425
  try {
1409
- const u = At.get(this);
1410
- u && (u.excluded = u.excluded || O(u.url, u.requestHeaders, m), u.requestBody = ye(m), u.excluded || this.addEventListener(
1426
+ const u = Et.get(this);
1427
+ u && (u.excluded = u.excluded || N(u.url, u.requestHeaders, m), u.requestBody = ye(m), u.excluded || this.addEventListener(
1411
1428
  "loadend",
1412
1429
  () => {
1413
1430
  queueMicrotask(() => {
1414
1431
  try {
1415
- const h = mr(this.getAllResponseHeaders());
1432
+ const h = Tr(this.getAllResponseHeaders());
1416
1433
  t({
1417
1434
  requestId: u.requestId,
1418
1435
  url: u.url,
@@ -1422,7 +1439,7 @@ function xs() {
1422
1439
  resourceType: "xhr",
1423
1440
  responseStatus: this.status,
1424
1441
  responseHeaders: h,
1425
- responseBody: hr(this, h),
1442
+ responseBody: fr(this, h),
1426
1443
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1427
1444
  startedAt: u.startedAt,
1428
1445
  durationMs: Date.now() - u.startedAtMs
@@ -1459,11 +1476,11 @@ function xs() {
1459
1476
  d = new PerformanceObserver((y) => {
1460
1477
  for (const m of y.getEntries()) {
1461
1478
  const u = m;
1462
- if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || O(u.name))
1479
+ if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || N(u.name))
1463
1480
  continue;
1464
1481
  const h = performance.timeOrigin + u.startTime;
1465
1482
  t({
1466
- requestId: kt("resource"),
1483
+ requestId: Rt("resource"),
1467
1484
  url: C(u.name, St),
1468
1485
  method: "GET",
1469
1486
  resourceType: "resource",
@@ -1503,7 +1520,7 @@ function xs() {
1503
1520
  };
1504
1521
  return window.__plunoProductAgentNetworkCapture = p, p;
1505
1522
  }
1506
- function S(e, t, s) {
1523
+ function A(e, t, s) {
1507
1524
  if (typeof window > "u")
1508
1525
  return;
1509
1526
  const n = window, r = {
@@ -1518,11 +1535,11 @@ function ie(e) {
1518
1535
  const t = typeof e == "function" ? e() : e;
1519
1536
  return t && Object.keys(t).length > 0 ? t : void 0;
1520
1537
  }
1521
- function vs(e) {
1538
+ function Os(e) {
1522
1539
  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";
1523
1540
  }
1524
- const Os = 5e3, Ns = 12e4;
1525
- function Ls(e) {
1541
+ const Ls = 5e3, Bs = 12e4;
1542
+ function qs(e) {
1526
1543
  const t = [];
1527
1544
  for (const s of e)
1528
1545
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1533,30 +1550,30 @@ function Ls(e) {
1533
1550
  });
1534
1551
  return t;
1535
1552
  }
1536
- function Bs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1553
+ function Hs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1537
1554
  const n = [
1538
- Hs(),
1539
- qs()
1555
+ $s(),
1556
+ Fs()
1540
1557
  ].filter((r) => typeof r == "function");
1541
1558
  return () => {
1542
1559
  for (const r of n.reverse())
1543
1560
  r();
1544
1561
  };
1545
1562
  }
1546
- function qs() {
1547
- return Te(globalThis, "getPageSnapshot", async () => qt());
1563
+ function Fs() {
1564
+ return Ie(globalThis, "getPageSnapshot", async () => qt());
1548
1565
  }
1549
- function Hs() {
1550
- return Te(globalThis, "pageImages", {
1551
- inspectImage: async (t, s) => await Fs(t, s)
1566
+ function $s() {
1567
+ return Ie(globalThis, "pageImages", {
1568
+ inspectImage: async (t, s) => await Ws(t, s)
1552
1569
  });
1553
1570
  }
1554
- async function Fs(e, t = {}) {
1555
- const s = zs(t.name), n = await $s(e);
1571
+ async function Ws(e, t = {}) {
1572
+ const s = Xs(t.name), n = await js(e);
1556
1573
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1557
1574
  type: "pluno.pageImages.inspectImage",
1558
1575
  imageAttached: !1,
1559
- imageAttachmentError: Se
1576
+ imageAttachmentError: Ae
1560
1577
  } : {
1561
1578
  type: "pluno.pageImages.inspectImage",
1562
1579
  imageAttached: !0,
@@ -1570,15 +1587,15 @@ async function Fs(e, t = {}) {
1570
1587
  imageAttachmentError: n.error
1571
1588
  };
1572
1589
  }
1573
- async function $s(e) {
1574
- 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: Se } : {
1590
+ async function js(e) {
1591
+ 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: Ae } : {
1575
1592
  ok: !0,
1576
1593
  mimeType: e.type,
1577
1594
  sizeBytes: e.size,
1578
- dataUrl: await Xs(e)
1579
- } : { 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." } : Ws(e);
1595
+ dataUrl: await Js(e)
1596
+ } : { 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);
1580
1597
  }
1581
- function Ws(e) {
1598
+ function zs(e) {
1582
1599
  if (!e.startsWith("data:") || !e.includes(","))
1583
1600
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1584
1601
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1589,7 +1606,7 @@ function Ws(e) {
1589
1606
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1590
1607
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1591
1608
  return { ok: !1, error: "Page image data URL has invalid base64." };
1592
- const o = js(i);
1609
+ const o = Gs(i);
1593
1610
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1594
1611
  ok: !0,
1595
1612
  mimeType: r,
@@ -1597,22 +1614,22 @@ function Ws(e) {
1597
1614
  dataUrl: `data:${r};base64,${i}`
1598
1615
  };
1599
1616
  }
1600
- function js(e) {
1617
+ function Gs(e) {
1601
1618
  if (e.length === 0 || e.length % 4 !== 0)
1602
1619
  return null;
1603
1620
  const t = e.length - e.replace(/=+$/, "").length;
1604
1621
  return t > 2 ? null : e.length / 4 * 3 - t;
1605
1622
  }
1606
- function zs(e) {
1623
+ function Xs(e) {
1607
1624
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1608
1625
  }
1609
- function Gs(e) {
1626
+ function Ks(e) {
1610
1627
  try {
1611
1628
  e();
1612
1629
  } catch {
1613
1630
  }
1614
1631
  }
1615
- function Xs(e) {
1632
+ function Js(e) {
1616
1633
  return new Promise((t, s) => {
1617
1634
  const n = new FileReader();
1618
1635
  n.onload = () => {
@@ -1626,7 +1643,7 @@ function Xs(e) {
1626
1643
  }
1627
1644
  async function oe(e, t) {
1628
1645
  const s = Object.getPrototypeOf(async function() {
1629
- }).constructor, n = e.timeoutMs ?? Os, r = Date.now(), i = [];
1646
+ }).constructor, n = e.timeoutMs ?? Ls, r = Date.now(), i = [];
1630
1647
  let o;
1631
1648
  const a = {
1632
1649
  log: console.log,
@@ -1644,7 +1661,7 @@ async function oe(e, t) {
1644
1661
  o = window.setTimeout(() => p(l), n);
1645
1662
  })
1646
1663
  ]);
1647
- return d === l ? Ks(n) : {
1664
+ return d === l ? Ys(n) : {
1648
1665
  ok: !0,
1649
1666
  result: d,
1650
1667
  console: i,
@@ -1673,7 +1690,7 @@ async function oe(e, t) {
1673
1690
  t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
1674
1691
  }
1675
1692
  }
1676
- function Js(e, t) {
1693
+ function Vs(e, t) {
1677
1694
  if (!e || typeof e != "object")
1678
1695
  return;
1679
1696
  const s = e.sandboxFilesToken;
@@ -1683,7 +1700,7 @@ function Js(e, t) {
1683
1700
  const r = () => {
1684
1701
  if (!n)
1685
1702
  throw new Error("sandboxFiles is only available during browser-code execution");
1686
- }, i = async (a, c) => await as(`${t.replace(/\/$/, "")}${a}`, c);
1703
+ }, i = async (a, c) => await ls(`${t.replace(/\/$/, "")}${a}`, c);
1687
1704
  return {
1688
1705
  value: Object.freeze({
1689
1706
  upload: async (a) => {
@@ -1717,7 +1734,7 @@ function Js(e, t) {
1717
1734
  }
1718
1735
  };
1719
1736
  }
1720
- function Ks(e) {
1737
+ function Ys(e) {
1721
1738
  return {
1722
1739
  ok: !1,
1723
1740
  exception: {
@@ -1731,10 +1748,10 @@ function Ks(e) {
1731
1748
  }
1732
1749
  };
1733
1750
  }
1734
- function Vs(e) {
1751
+ function Zs(e) {
1735
1752
  return e.replace(/\/+$/, "");
1736
1753
  }
1737
- function Ys(e) {
1754
+ function Qs(e) {
1738
1755
  const t = {
1739
1756
  sidepanel: "extension_sidepanel",
1740
1757
  browser_extension_page_ui: "extension_widget",
@@ -1746,13 +1763,13 @@ function Ys(e) {
1746
1763
  };
1747
1764
  return e && e in t ? t[e] : e ?? "embedded_custom_ui";
1748
1765
  }
1749
- function Zs(e) {
1766
+ function tn(e) {
1750
1767
  return e === "pluno" ? "scheduled_continuation" : e ?? "user";
1751
1768
  }
1752
- function Qs(e, t = location.origin) {
1769
+ function en(e, t = location.origin) {
1753
1770
  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;
1754
1771
  }
1755
- function tn(e) {
1772
+ function sn(e) {
1756
1773
  const t = new URL("/api/product-agent/embed/ws", e);
1757
1774
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1758
1775
  }
@@ -1765,21 +1782,21 @@ function _() {
1765
1782
  ...e ? { plunoProductAgentUi: e } : {}
1766
1783
  };
1767
1784
  }
1768
- function en() {
1785
+ function nn() {
1769
1786
  return {
1770
1787
  pageUrl: location.href,
1771
1788
  pageTitle: document.title,
1772
1789
  htmlContent: qt()
1773
1790
  };
1774
1791
  }
1775
- function sn(e) {
1776
- return tt.add(e), Y || (Y = nn()), () => {
1777
- tt.delete(e), tt.size === 0 && (Y?.(), Y = null);
1792
+ function rn(e) {
1793
+ return et.add(e), Y || (Y = on()), () => {
1794
+ et.delete(e), et.size === 0 && (Y?.(), Y = null);
1778
1795
  };
1779
1796
  }
1780
- function nn() {
1797
+ function on() {
1781
1798
  const e = () => {
1782
- for (const i of Array.from(tt))
1799
+ for (const i of Array.from(et))
1783
1800
  i();
1784
1801
  }, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
1785
1802
  const o = t(...i);
@@ -1792,28 +1809,28 @@ function nn() {
1792
1809
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
1793
1810
  };
1794
1811
  }
1795
- function rn() {
1812
+ function an() {
1796
1813
  return _e()?.surface === "browser_extension_sdk_preview";
1797
1814
  }
1798
1815
  function qt() {
1799
1816
  if (!document.body)
1800
1817
  return "";
1801
1818
  const e = [], t = [], s = (h, f) => {
1802
- const I = B(f);
1803
- !I || t.includes(I) || (e.push([h, I]), t.push(I));
1819
+ const T = B(f);
1820
+ !T || t.includes(T) || (e.push([h, T]), t.push(T));
1804
1821
  };
1805
1822
  s("Selected text", window.getSelection()?.toString() ?? "");
1806
1823
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
1807
- (h) => Ee(h) && !h.parentElement?.closest(n)
1824
+ (h) => be(h) && !h.parentElement?.closest(n)
1808
1825
  );
1809
1826
  for (const h of r.slice(0, 3))
1810
1827
  s("Active overlay", bt(j(h), t));
1811
- const i = on(), o = i ? bt(j(i), t) : "";
1828
+ const i = cn(), o = i ? bt(j(i), t) : "";
1812
1829
  s("Main page content", o), s("Additional visible page text", bt(j(document.body), t));
1813
1830
  const a = e.map(([h, f]) => `${h}:
1814
1831
  ${f}`).join(`
1815
1832
 
1816
- `).trim().slice(0, 12e3), c = an(r, i).trim(), l = `Simplified DOM outline:
1833
+ `).trim().slice(0, 12e3), c = ln(r, i).trim(), l = `Simplified DOM outline:
1817
1834
  `, d = `
1818
1835
 
1819
1836
  Visible page text:
@@ -1837,14 +1854,14 @@ function bt(e, t) {
1837
1854
  s = s.replace(n, "");
1838
1855
  return B(s);
1839
1856
  }
1840
- function Ee(e) {
1857
+ function be(e) {
1841
1858
  const t = window.getComputedStyle(e);
1842
1859
  return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
1843
1860
  }
1844
- function on() {
1845
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ee).sort((e, t) => j(t).length - j(e).length)[0] ?? null;
1861
+ function cn() {
1862
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(be).sort((e, t) => j(t).length - j(e).length)[0] ?? null;
1846
1863
  }
1847
- function an(e, t) {
1864
+ function ln(e, t) {
1848
1865
  const s = /* @__PURE__ */ new Set([
1849
1866
  "main",
1850
1867
  "nav",
@@ -1924,84 +1941,84 @@ function an(e, t) {
1924
1941
  "data-test",
1925
1942
  "data-qa",
1926
1943
  "data-cy"
1927
- ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = cn(), y = new Set(e);
1944
+ ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = un(), y = new Set(e);
1928
1945
  t && y.add(t);
1929
1946
  let m = 0;
1930
- const u = (T) => {
1931
- const U = T.getAttribute("role");
1947
+ const u = (I) => {
1948
+ const U = I.getAttribute("role");
1932
1949
  return U && !o.has(U) ? U : "";
1933
- }, h = (T) => {
1934
- const U = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
1935
- return `${T.tagName.toLowerCase()}|${u(T)}|${U}`;
1936
- }, f = (T, U, H) => {
1937
- const R = (A, ct) => {
1938
- const E = A.tagName.toLowerCase(), lt = window.getComputedStyle(A), z = d.has(A);
1939
- if (m >= 1e3 && !z || H.has(A) || i.has(E) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || lt.display === "none" || lt.visibility === "hidden")
1950
+ }, h = (I) => {
1951
+ const U = I.getAttribute("data-testid") || I.getAttribute("data-test") || I.getAttribute("data-qa") || I.getAttribute("data-cy") || "";
1952
+ return `${I.tagName.toLowerCase()}|${u(I)}|${U}`;
1953
+ }, f = (I, U, H) => {
1954
+ const R = (S, lt) => {
1955
+ const b = S.tagName.toLowerCase(), ut = window.getComputedStyle(S), z = d.has(S);
1956
+ if (m >= 1e3 && !z || H.has(S) || i.has(b) || S.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ut.display === "none" || ut.visibility === "hidden")
1940
1957
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
1941
1958
  m += 1;
1942
- const zt = u(A), G = Re(A), je = a.has(zt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(E) || E === "a" && A.hasAttribute("href"), ut = Array.from(A.children).filter((g) => g instanceof HTMLElement), X = /* @__PURE__ */ new Map();
1943
- for (const g of ut) {
1959
+ const zt = u(S), G = Re(S), je = a.has(zt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && S.hasAttribute("href"), dt = Array.from(S.children).filter((g) => g instanceof HTMLElement), X = /* @__PURE__ */ new Map();
1960
+ for (const g of dt) {
1944
1961
  const w = h(g);
1945
1962
  X.set(w, (X.get(w) ?? 0) + 1);
1946
1963
  }
1947
- const dt = /* @__PURE__ */ new Map(), Gt = /* @__PURE__ */ new Map();
1948
- for (const g of ut) {
1964
+ const ht = /* @__PURE__ */ new Map(), Gt = /* @__PURE__ */ new Map();
1965
+ for (const g of dt) {
1949
1966
  const w = h(g), D = Gt.get(w) ?? 0;
1950
- Gt.set(w, D + 1), (X.get(w) ?? 0) > 8 && D >= 6 && !d.has(g) && dt.set(w, (dt.get(w) ?? 0) + 1);
1967
+ Gt.set(w, D + 1), (X.get(w) ?? 0) > 8 && D >= 6 && !d.has(g) && ht.set(w, (ht.get(w) ?? 0) + 1);
1951
1968
  }
1952
- const Xt = /* @__PURE__ */ new Map(), Jt = /* @__PURE__ */ new Set(), ht = [], Kt = [];
1953
- for (const g of ut) {
1969
+ const Xt = /* @__PURE__ */ new Map(), Kt = /* @__PURE__ */ new Set(), pt = [], Jt = [];
1970
+ for (const g of dt) {
1954
1971
  const w = h(g), D = X.get(w) ?? 0, Zt = Xt.get(w) ?? 0;
1955
1972
  if (Xt.set(w, Zt + 1), D > 8 && Zt >= 6 && !d.has(g)) {
1956
- Jt.has(w) || (ht.push([`… ${dt.get(w) ?? 0} similar siblings omitted`]), Jt.add(w));
1973
+ Kt.has(w) || (pt.push([`… ${ht.get(w) ?? 0} similar siblings omitted`]), Kt.add(w));
1957
1974
  continue;
1958
1975
  }
1959
- const Qt = R(g, ct);
1960
- Kt.push(Qt), ht.push(Qt.lines);
1976
+ const Qt = R(g, lt);
1977
+ Jt.push(Qt), pt.push(Qt.lines);
1961
1978
  }
1962
- const pt = [];
1963
- if (A.shadowRoot)
1964
- for (const g of Array.from(A.shadowRoot.children))
1965
- g instanceof HTMLElement && pt.push(R(g, ct + 1));
1966
- const J = [...Kt, ...pt], ft = G.length > 0 || je || J.some((g) => g.hasUsefulContent), Vt = B(
1967
- [G, ...J.map((g) => g.textPreview)].filter(Boolean).join(" ")
1968
- ).slice(0, 180), ze = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), Yt = l.some((g) => A.hasAttribute(g)) || !!zt || ze, gt = (A.getClientRects().length > 0 || lt.display === "contents") && (s.has(E) || Yt || z) && (ft || z) && (!r.has(E) || ft || Yt || z), mt = gt ? 1 : 0, F = [];
1969
- if (gt) {
1970
- const g = J.some((D) => D.containsTextElement), w = n.has(E) && !g ? Vt : G;
1971
- F.push(ke(A, c, o, w.slice(0, 180)));
1979
+ const ft = [];
1980
+ if (S.shadowRoot)
1981
+ for (const g of Array.from(S.shadowRoot.children))
1982
+ g instanceof HTMLElement && ft.push(R(g, lt + 1));
1983
+ const K = [...Jt, ...ft], gt = G.length > 0 || je || K.some((g) => g.hasUsefulContent), Vt = B(
1984
+ [G, ...K.map((g) => g.textPreview)].filter(Boolean).join(" ")
1985
+ ).slice(0, 180), ze = S.hasAttribute("contenteditable") && (G.length > 0 || !S.querySelector("[contenteditable]")), Yt = l.some((g) => S.hasAttribute(g)) || !!zt || ze, mt = (S.getClientRects().length > 0 || ut.display === "contents") && (s.has(b) || Yt || z) && (gt || z) && (!r.has(b) || gt || Yt || z), yt = mt ? 1 : 0, F = [];
1986
+ if (mt) {
1987
+ const g = K.some((D) => D.containsTextElement), w = n.has(b) && !g ? Vt : G;
1988
+ F.push(ke(S, c, o, w.slice(0, 180)));
1972
1989
  }
1973
- for (const g of ht)
1974
- F.push(...Z(g, mt));
1975
- const yt = pt.flatMap((g) => g.lines);
1976
- if (yt.length > 0) {
1977
- const g = yt.slice(0, 20);
1978
- yt.length > g.length && g.push("… shadow DOM omitted");
1979
- const w = E.includes("tooltip") || E.includes("popper") || E.includes("loader");
1980
- if (ct < 2 && !w) {
1981
- const D = gt ? "#shadow-root" : `${E} #shadow-root`;
1982
- F.push(...Z([D, ...Z(g, 1)], mt));
1990
+ for (const g of pt)
1991
+ F.push(...Z(g, yt));
1992
+ const Tt = ft.flatMap((g) => g.lines);
1993
+ if (Tt.length > 0) {
1994
+ const g = Tt.slice(0, 20);
1995
+ Tt.length > g.length && g.push("… shadow DOM omitted");
1996
+ const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
1997
+ if (lt < 2 && !w) {
1998
+ const D = mt ? "#shadow-root" : `${b} #shadow-root`;
1999
+ F.push(...Z([D, ...Z(g, 1)], yt));
1983
2000
  } else
1984
- F.push(...Z(g, mt));
2001
+ F.push(...Z(g, yt));
1985
2002
  }
1986
2003
  return {
1987
2004
  lines: F,
1988
- hasUsefulContent: ft,
2005
+ hasUsefulContent: gt,
1989
2006
  textPreview: Vt,
1990
- containsTextElement: n.has(E) || J.some((g) => g.containsTextElement)
2007
+ containsTextElement: n.has(b) || K.some((g) => g.containsTextElement)
1991
2008
  };
1992
2009
  };
1993
- return [`--- ${U} ---`, ...R(T, 0).lines].join(`
2010
+ return [`--- ${U} ---`, ...R(I, 0).lines].join(`
1994
2011
  `);
1995
- }, I = [], x = B(window.getSelection()?.toString() ?? "");
1996
- x && I.push(`--- selected text ---
1997
- ${JSON.stringify(x)}`), p.length > 0 && I.push(ln(p, s, c, o));
1998
- for (const T of e.slice(0, 3))
1999
- I.push(f(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2000
- if (t && I.push(f(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2001
- const T = t || e.length ? "other visible DOM" : "visible DOM";
2002
- I.push(f(document.body, T, y));
2003
- }
2004
- return I.join(`
2012
+ }, T = [], x = B(window.getSelection()?.toString() ?? "");
2013
+ x && T.push(`--- selected text ---
2014
+ ${JSON.stringify(x)}`), p.length > 0 && T.push(dn(p, s, c, o));
2015
+ for (const I of e.slice(0, 3))
2016
+ T.push(f(I, "active overlay DOM", /* @__PURE__ */ new Set()));
2017
+ if (t && T.push(f(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2018
+ const I = t || e.length ? "other visible DOM" : "visible DOM";
2019
+ T.push(f(document.body, I, y));
2020
+ }
2021
+ return T.join(`
2005
2022
 
2006
2023
  `);
2007
2024
  }
@@ -2009,7 +2026,7 @@ function ke(e, t, s, n) {
2009
2026
  const r = e.tagName.toLowerCase();
2010
2027
  let i = r;
2011
2028
  const o = e.getAttribute("id");
2012
- o && un(o) && (i += `#${o}`);
2029
+ o && hn(o) && (i += `#${o}`);
2013
2030
  for (const a of t) {
2014
2031
  const c = e.getAttribute(a);
2015
2032
  c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
@@ -2022,7 +2039,7 @@ function ke(e, t, s, n) {
2022
2039
  e.hasAttribute(a) && (i += `[${a}]`);
2023
2040
  return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
2024
2041
  }
2025
- function cn() {
2042
+ function un() {
2026
2043
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
2027
2044
  if (!a)
2028
2045
  return;
@@ -2065,7 +2082,7 @@ function cn() {
2065
2082
  priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
2066
2083
  };
2067
2084
  }
2068
- function ln(e, t, s, n) {
2085
+ function dn(e, t, s, n) {
2069
2086
  const r = ["--- active/current elements ---"];
2070
2087
  for (const i of e) {
2071
2088
  const o = [];
@@ -2101,7 +2118,7 @@ function Re(e) {
2101
2118
  Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
2102
2119
  );
2103
2120
  }
2104
- function un(e) {
2121
+ function hn(e) {
2105
2122
  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);
2106
2123
  }
2107
2124
  function _e() {
@@ -2120,23 +2137,23 @@ function _e() {
2120
2137
  },
2121
2138
  {
2122
2139
  name: "widget_root",
2123
- selector: cs,
2140
+ selector: us,
2124
2141
  description: "Finds Pluno's widget root inside the widget host shadow root."
2125
2142
  },
2126
2143
  {
2127
2144
  name: "widget_panel",
2128
- selector: ls,
2145
+ selector: ds,
2129
2146
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
2130
2147
  },
2131
2148
  {
2132
2149
  name: "widget_timeline",
2133
- selector: us,
2150
+ selector: hs,
2134
2151
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2135
2152
  }
2136
2153
  ]
2137
2154
  };
2138
2155
  }
2139
- function dn(e) {
2156
+ function pn(e) {
2140
2157
  try {
2141
2158
  const t = JSON.parse(e);
2142
2159
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -2150,10 +2167,10 @@ function ce(e, t) {
2150
2167
  const s = e[t];
2151
2168
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2152
2169
  }
2153
- function hn(e) {
2170
+ function fn(e) {
2154
2171
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
2155
2172
  }
2156
- function pn(e) {
2173
+ function gn(e) {
2157
2174
  if (!e || typeof e != "object")
2158
2175
  return null;
2159
2176
  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;
@@ -2164,13 +2181,13 @@ function pn(e) {
2164
2181
  ...a !== null ? { scribbleStyle: a } : {}
2165
2182
  };
2166
2183
  }
2167
- function fn(e) {
2184
+ function mn(e) {
2168
2185
  if (!e || typeof e != "object")
2169
2186
  return null;
2170
2187
  const t = e.javascript;
2171
2188
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
2172
2189
  }
2173
- function gn(e, t) {
2190
+ function yn(e, t) {
2174
2191
  return t ? e && typeof e == "object" ? {
2175
2192
  ...e,
2176
2193
  helperError: t
@@ -2180,23 +2197,23 @@ function gn(e, t) {
2180
2197
  helperError: t
2181
2198
  } : e;
2182
2199
  }
2183
- function mn(e) {
2200
+ function Tn(e) {
2184
2201
  if (!e || typeof e != "object")
2185
2202
  return e;
2186
2203
  const t = e;
2187
2204
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2188
2205
  }
2189
- function yn() {
2206
+ function In() {
2190
2207
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2191
2208
  if (t)
2192
2209
  return t;
2193
2210
  const s = crypto.randomUUID();
2194
2211
  return window.localStorage.setItem(e, s), s;
2195
2212
  }
2196
- function Et() {
2213
+ function kt() {
2197
2214
  return crypto.randomUUID();
2198
2215
  }
2199
- function In(e) {
2216
+ function wn(e) {
2200
2217
  if (!e || typeof e != "object")
2201
2218
  return null;
2202
2219
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2207,23 +2224,23 @@ function In(e) {
2207
2224
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2208
2225
  } : null;
2209
2226
  }
2210
- function Tn(e, t) {
2227
+ function An(e, t) {
2211
2228
  return Array.isArray(e) ? Dt(
2212
2229
  xt(
2213
2230
  e.map((s) => Me(s, t)).filter((s) => s !== null)
2214
2231
  )
2215
2232
  ) : [];
2216
2233
  }
2217
- function wn(e) {
2234
+ function Sn(e) {
2218
2235
  return Array.isArray(e) ? e.flatMap((t) => {
2219
2236
  if (!t || typeof t != "object")
2220
2237
  return [];
2221
- const s = t, n = b(s, "id"), r = b(s, "createdAt"), i = b(s, "updatedAt"), o = b(s, "lastActiveAt");
2238
+ const s = t, n = E(s, "id"), r = E(s, "createdAt"), i = E(s, "updatedAt"), o = E(s, "lastActiveAt");
2222
2239
  return !n || !r || !i || !o ? [] : [
2223
2240
  {
2224
2241
  id: n,
2225
- title: b(s, "title"),
2226
- firstUserMessage: b(s, "firstUserMessage"),
2242
+ title: E(s, "title"),
2243
+ firstUserMessage: E(s, "firstUserMessage"),
2227
2244
  currentPage: s.currentPage ?? null,
2228
2245
  createdAt: r,
2229
2246
  updatedAt: i,
@@ -2249,7 +2266,10 @@ function Me(e, t) {
2249
2266
  id: String(s.id ?? crypto.randomUUID()),
2250
2267
  role: i,
2251
2268
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2252
- content: _n(r.content),
2269
+ content: Qe(
2270
+ Cn(r.content),
2271
+ t
2272
+ ),
2253
2273
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2254
2274
  respondsToUserMessageId: v(r) ?? void 0,
2255
2275
  ...M(r) ? { runId: M(r) } : {},
@@ -2264,7 +2284,7 @@ function Me(e, t) {
2264
2284
  }), o;
2265
2285
  }
2266
2286
  if (r.type === "function_call_output") {
2267
- const i = An(r.output);
2287
+ const i = bn(r.output);
2268
2288
  return i ? {
2269
2289
  id: String(s.id ?? crypto.randomUUID()),
2270
2290
  role: "tool",
@@ -2281,7 +2301,7 @@ function Me(e, t) {
2281
2301
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2282
2302
  id: String(s.id ?? crypto.randomUUID()),
2283
2303
  role: "tool",
2284
- content: r.type === "mcp_call" ? Sn(r) : En(r),
2304
+ content: r.type === "mcp_call" ? En(r) : Rn(r),
2285
2305
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2286
2306
  respondsToUserMessageId: v(r) ?? void 0,
2287
2307
  ...M(r) ? { runId: M(r) } : {},
@@ -2292,7 +2312,7 @@ function Me(e, t) {
2292
2312
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2293
2313
  id: String(s.id ?? crypto.randomUUID()),
2294
2314
  role: "system",
2295
- content: bn(r),
2315
+ content: kn(r),
2296
2316
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2297
2317
  respondsToUserMessageId: v(r) ?? void 0,
2298
2318
  ...M(r) ? { runId: M(r) } : {},
@@ -2302,11 +2322,11 @@ function Me(e, t) {
2302
2322
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2303
2323
  } : null;
2304
2324
  }
2305
- function Sn(e) {
2325
+ function En(e) {
2306
2326
  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(" ");
2307
2327
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2308
2328
  }
2309
- function An(e) {
2329
+ function bn(e) {
2310
2330
  if (typeof e != "string")
2311
2331
  return null;
2312
2332
  try {
@@ -2323,10 +2343,10 @@ function An(e) {
2323
2343
  return null;
2324
2344
  }
2325
2345
  }
2326
- function bn(e) {
2346
+ function kn(e) {
2327
2347
  return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : 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.";
2328
2348
  }
2329
- function En(e) {
2349
+ function Rn(e) {
2330
2350
  if (e.type === "web_search_call") {
2331
2351
  const t = e.action;
2332
2352
  if (t && typeof t == "object") {
@@ -2338,26 +2358,26 @@ function En(e) {
2338
2358
  }
2339
2359
  return "🔎 Searching the web";
2340
2360
  }
2341
- return kn(e);
2361
+ return _n(e);
2342
2362
  }
2343
- function kn(e) {
2363
+ function _n(e) {
2344
2364
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2345
- return N(e.summary);
2365
+ return O(e.summary);
2346
2366
  if (typeof e.arguments == "string")
2347
2367
  try {
2348
2368
  const t = JSON.parse(e.arguments);
2349
2369
  if (typeof t.summary == "string" && t.summary.trim().length > 0)
2350
- return N(t.summary);
2370
+ return O(t.summary);
2351
2371
  } catch {
2352
- return typeof e.name == "string" && e.name.trim().length > 0 ? N(e.name) : "🛠️ Run tool";
2372
+ return typeof e.name == "string" && e.name.trim().length > 0 ? O(e.name) : "🛠️ Run tool";
2353
2373
  }
2354
- return typeof e.name == "string" && e.name.trim().length > 0 ? N(e.name) : "🛠️ Run tool";
2374
+ return typeof e.name == "string" && e.name.trim().length > 0 ? O(e.name) : "🛠️ Run tool";
2355
2375
  }
2356
- function N(e) {
2376
+ function O(e) {
2357
2377
  const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2358
2378
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2359
2379
  }
2360
- function Rn(e) {
2380
+ function Mn(e) {
2361
2381
  if (e == null)
2362
2382
  return e;
2363
2383
  if (typeof e != "object")
@@ -2376,7 +2396,7 @@ function le(e) {
2376
2396
  const t = e.callId ?? e.call_id;
2377
2397
  return typeof t == "string" && t ? t : null;
2378
2398
  }
2379
- function _n(e) {
2399
+ function Cn(e) {
2380
2400
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2381
2401
  if (!t || typeof t != "object")
2382
2402
  return "";
@@ -2385,8 +2405,8 @@ function _n(e) {
2385
2405
  }).filter(Boolean).join("") : "";
2386
2406
  }
2387
2407
  function Ce(e, t) {
2388
- const s = Pe(e, t), n = Un(
2389
- On(e, t),
2408
+ const s = Pe(e, t), n = xn(
2409
+ Ln(e, t),
2390
2410
  s
2391
2411
  ), r = n.findIndex((o) => o.id === s.id);
2392
2412
  if (r === -1)
@@ -2396,7 +2416,7 @@ function Ce(e, t) {
2396
2416
  const i = [...n];
2397
2417
  return i[r] = s, Dt(xt(i));
2398
2418
  }
2399
- function Mn(e, t) {
2419
+ function Pn(e, t) {
2400
2420
  const s = e.findIndex(
2401
2421
  (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2402
2422
  );
@@ -2409,17 +2429,17 @@ function Mn(e, t) {
2409
2429
  loading: !0
2410
2430
  }, n;
2411
2431
  }
2412
- function Cn(e, t, s) {
2432
+ function Un(e, t, s) {
2413
2433
  let n = !1;
2414
2434
  const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2415
2435
  return n ? r : e;
2416
2436
  }
2417
- function Pn(e) {
2437
+ function Dn(e) {
2418
2438
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
2419
2439
  return !t || !s ? null : {
2420
2440
  id: `transient-activity:${t}`,
2421
2441
  role: "tool",
2422
- content: N(
2442
+ content: O(
2423
2443
  typeof e.summary == "string" ? e.summary : "Running browser tool"
2424
2444
  ),
2425
2445
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -2431,7 +2451,7 @@ function Pn(e) {
2431
2451
  loading: !0
2432
2452
  };
2433
2453
  }
2434
- function Un(e, t) {
2454
+ function xn(e, t) {
2435
2455
  if (t.id.startsWith("transient-activity:"))
2436
2456
  return e;
2437
2457
  const s = t.toolName === "tab_lifecycle";
@@ -2439,7 +2459,7 @@ function Un(e, t) {
2439
2459
  (n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId === t.runId && n.respondsToUserMessageId === t.respondsToUserMessageId)
2440
2460
  );
2441
2461
  }
2442
- function Dn(e, t) {
2462
+ function vn(e, t) {
2443
2463
  const s = t.map(
2444
2464
  (n) => Pe(e, n)
2445
2465
  );
@@ -2454,19 +2474,19 @@ function Pe(e, t) {
2454
2474
  if (!s?.attachments?.length)
2455
2475
  return t;
2456
2476
  const n = t.attachments.map((r) => {
2457
- const i = xn(s.attachments ?? [], r);
2458
- return i ? vn(r, i) : r;
2477
+ const i = Nn(s.attachments ?? [], r);
2478
+ return i ? On(r, i) : r;
2459
2479
  });
2460
2480
  return { ...t, attachments: n };
2461
2481
  }
2462
- function xn(e, t) {
2482
+ function Nn(e, t) {
2463
2483
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2464
2484
  }
2465
- function vn(e, t) {
2485
+ function On(e, t) {
2466
2486
  const { previewUrl: s } = t;
2467
2487
  return s ? { ...e, previewUrl: s } : e;
2468
2488
  }
2469
- function On(e, t) {
2489
+ function Ln(e, t) {
2470
2490
  if (t.role !== "user")
2471
2491
  return e;
2472
2492
  const s = e.findIndex(
@@ -2510,7 +2530,7 @@ function de(e) {
2510
2530
  }
2511
2531
  return !1;
2512
2532
  }
2513
- function Nn(e) {
2533
+ function Bn(e) {
2514
2534
  const t = De(e);
2515
2535
  return t === null ? e.some(q) : e.slice(t + 1).some(q);
2516
2536
  }
@@ -2520,10 +2540,10 @@ function De(e) {
2520
2540
  return t;
2521
2541
  return null;
2522
2542
  }
2523
- function Ln(e) {
2543
+ function qn(e) {
2524
2544
  return q(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2525
2545
  }
2526
- function it(e) {
2546
+ function ot(e) {
2527
2547
  for (let t = e.length - 1; t >= 0; t -= 1) {
2528
2548
  const s = e[t];
2529
2549
  if (!s || typeof s != "object")
@@ -2537,8 +2557,8 @@ function it(e) {
2537
2557
  }
2538
2558
  return null;
2539
2559
  }
2540
- function Bn(e) {
2541
- const t = it(e);
2560
+ function Hn(e) {
2561
+ const t = ot(e);
2542
2562
  if (t === null)
2543
2563
  return null;
2544
2564
  const n = L(e[t])?.page;
@@ -2559,18 +2579,18 @@ function Pt(e) {
2559
2579
  function he(e) {
2560
2580
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2561
2581
  }
2562
- function qn(e, t) {
2563
- const s = it(t);
2582
+ function Fn(e, t) {
2583
+ const s = ot(t);
2564
2584
  if (s === null)
2565
2585
  return !1;
2566
2586
  const n = t[s], r = n && typeof n == "object" ? n.id : null;
2567
2587
  if (typeof r != "string" || !r)
2568
2588
  return !1;
2569
2589
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2570
- return i === -1 ? !1 : e.slice(i + 1).some(Ln);
2590
+ return i === -1 ? !1 : e.slice(i + 1).some(qn);
2571
2591
  }
2572
2592
  function Ut(e) {
2573
- const t = it(e);
2593
+ const t = ot(e);
2574
2594
  if (t === null)
2575
2595
  return null;
2576
2596
  const s = e[t];
@@ -2582,8 +2602,8 @@ function Ut(e) {
2582
2602
  const r = n.clientMessageId;
2583
2603
  return typeof r == "string" ? r : null;
2584
2604
  }
2585
- function Hn(e) {
2586
- const t = it(e);
2605
+ function $n(e) {
2606
+ const t = ot(e);
2587
2607
  if (t === null)
2588
2608
  return null;
2589
2609
  for (let s = e.length - 1; s > t; s -= 1) {
@@ -2609,10 +2629,10 @@ function pe(e, t) {
2609
2629
  const s = v(t);
2610
2630
  if (!s)
2611
2631
  return null;
2612
- const n = e.find((i) => b(i, "id") === s), r = L(n);
2632
+ const n = e.find((i) => E(i, "id") === s), r = L(n);
2613
2633
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2614
2634
  }
2615
- function Fn(e, t) {
2635
+ function Wn(e, t) {
2616
2636
  let s = 0;
2617
2637
  for (const n of e) {
2618
2638
  if (!n || typeof n != "object")
@@ -2626,12 +2646,12 @@ function Fn(e, t) {
2626
2646
  return s;
2627
2647
  }
2628
2648
  function fe(e, t, s, n, r) {
2629
- if (!t || !$n(e))
2649
+ if (!t || !jn(e))
2630
2650
  return !1;
2631
2651
  const i = e;
2632
2652
  return !(Pt(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && v(i) !== n || r !== null && M(i) !== r);
2633
2653
  }
2634
- function $n(e) {
2654
+ function jn(e) {
2635
2655
  if (!e || typeof e != "object")
2636
2656
  return !1;
2637
2657
  const t = e;
@@ -2640,16 +2660,16 @@ function $n(e) {
2640
2660
  function q(e) {
2641
2661
  return e.role === "assistant" && e.phase !== "commentary";
2642
2662
  }
2643
- function Wn(e) {
2663
+ function zn(e) {
2644
2664
  if (!e || typeof e != "object")
2645
2665
  return !1;
2646
2666
  const t = e;
2647
2667
  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";
2648
2668
  }
2649
2669
  function Dt(e) {
2650
- return e.filter((t, s) => Ft(t) ? !Kn(e, s) && !Xn(e, s) && !Jn(e, s) : jn(t) ? t.retryable === !0 && Gn(e, s) ? !1 : !zn(e, s) : !0);
2670
+ return e.filter((t, s) => Ft(t) ? !Yn(e, s) && !Jn(e, s) && !Vn(e, s) : Gn(t) ? t.retryable === !0 && Kn(e, s) ? !1 : !Xn(e, s) : !0);
2651
2671
  }
2652
- function jn(e) {
2672
+ function Gn(e) {
2653
2673
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
2654
2674
  }
2655
2675
  function Ft(e) {
@@ -2671,18 +2691,18 @@ function xt(e) {
2671
2691
  n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
2672
2692
  return r;
2673
2693
  }
2674
- function zn(e, t) {
2694
+ function Xn(e, t) {
2675
2695
  const s = e[t];
2676
2696
  for (let n = t + 1; n < e.length; n += 1) {
2677
2697
  const r = e[n];
2678
2698
  if (r.role === "user")
2679
2699
  return !1;
2680
- if (r.role === "assistant" && ot(s, r))
2700
+ if (r.role === "assistant" && at(s, r))
2681
2701
  return !0;
2682
2702
  }
2683
2703
  return !1;
2684
2704
  }
2685
- function Gn(e, t) {
2705
+ function Kn(e, t) {
2686
2706
  const s = e[t];
2687
2707
  if (!s.respondsToUserMessageId)
2688
2708
  return !1;
@@ -2695,42 +2715,42 @@ function Gn(e, t) {
2695
2715
  }
2696
2716
  return !1;
2697
2717
  }
2698
- function Xn(e, t) {
2718
+ function Jn(e, t) {
2699
2719
  const s = e[t];
2700
2720
  for (let n = t + 1; n < e.length; n += 1)
2701
- if (e[n].role === "assistant" && ot(s, e[n]))
2721
+ if (e[n].role === "assistant" && at(s, e[n]))
2702
2722
  return !0;
2703
2723
  return !1;
2704
2724
  }
2705
- function Jn(e, t) {
2725
+ function Vn(e, t) {
2706
2726
  const s = e[t];
2707
2727
  for (let n = t + 1; n < e.length; n += 1)
2708
- if (e[n].role === "tool" && ot(s, e[n]))
2728
+ if (e[n].role === "tool" && at(s, e[n]))
2709
2729
  return !0;
2710
2730
  return !1;
2711
2731
  }
2712
- function Kn(e, t) {
2732
+ function Yn(e, t) {
2713
2733
  const s = e[t];
2714
2734
  for (let n = t + 1; n < e.length; n += 1)
2715
- if (Ft(e[n]) && ot(s, e[n]))
2735
+ if (Ft(e[n]) && at(s, e[n]))
2716
2736
  return !0;
2717
2737
  return !1;
2718
2738
  }
2719
- function ot(e, t) {
2739
+ function at(e, t) {
2720
2740
  return !e.runId || !t.runId ? !0 : e.runId === t.runId;
2721
2741
  }
2722
- function b(e, t) {
2742
+ function E(e, t) {
2723
2743
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2724
2744
  }
2725
- function Vn(e, t) {
2745
+ function Zn(e, t) {
2726
2746
  try {
2727
- const s = window.localStorage.getItem(`${Ae}${e}`);
2747
+ const s = window.localStorage.getItem(`${Se}${e}`);
2728
2748
  if (!s)
2729
2749
  return null;
2730
2750
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2731
2751
  if (t !== void 0 && r !== t)
2732
2752
  return null;
2733
- const i = Array.isArray(n.messages) ? n.messages.map(or).filter((o) => !!o) : [];
2753
+ const i = Array.isArray(n.messages) ? n.messages.map(cr).filter((o) => !!o) : [];
2734
2754
  return {
2735
2755
  sessionId: r,
2736
2756
  messages: i
@@ -2739,20 +2759,20 @@ function Vn(e, t) {
2739
2759
  return null;
2740
2760
  }
2741
2761
  }
2742
- function Yn(e, t) {
2762
+ function Qn(e, t) {
2743
2763
  try {
2744
2764
  window.localStorage.setItem(
2745
- `${Ae}${e}`,
2765
+ `${Se}${e}`,
2746
2766
  JSON.stringify({
2747
2767
  sessionId: t.sessionId,
2748
- messages: t.messages.slice(-Ms).map(ar)
2768
+ messages: t.messages.slice(-Ps).map(lr)
2749
2769
  })
2750
2770
  );
2751
2771
  } catch {
2752
2772
  return;
2753
2773
  }
2754
2774
  }
2755
- function Zn(e) {
2775
+ function tr(e) {
2756
2776
  try {
2757
2777
  const t = window.localStorage.getItem(`${Ct}${e}`);
2758
2778
  if (!t)
@@ -2780,7 +2800,7 @@ function W(e, t) {
2780
2800
  }
2781
2801
  function xe(e, t) {
2782
2802
  try {
2783
- const s = `${rt}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2803
+ const s = `${it}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2784
2804
  ...o,
2785
2805
  storedAt: Date.now(),
2786
2806
  unloadUrl: n,
@@ -2794,28 +2814,28 @@ function xe(e, t) {
2794
2814
  } catch {
2795
2815
  }
2796
2816
  }
2797
- function Qn(e, t) {
2817
+ function er(e, t) {
2798
2818
  try {
2799
- if (window.sessionStorage.getItem(`${rt}${e}`) === null)
2819
+ if (window.sessionStorage.getItem(`${it}${e}`) === null)
2800
2820
  return;
2801
2821
  } catch {
2802
2822
  return;
2803
2823
  }
2804
2824
  xe(e, t);
2805
2825
  }
2806
- function tr(e) {
2826
+ function sr(e) {
2807
2827
  try {
2808
- const t = `${rt}${e}`, s = window.sessionStorage.getItem(t);
2828
+ const t = `${it}${e}`, s = window.sessionStorage.getItem(t);
2809
2829
  if (window.sessionStorage.removeItem(t), !s)
2810
2830
  return [];
2811
2831
  const n = JSON.parse(s);
2812
- return Array.isArray(n) ? n.flatMap((r) => sr(r) ? [{
2832
+ return Array.isArray(n) ? n.flatMap((r) => rr(r) ? [{
2813
2833
  ...r.event,
2814
2834
  page: _(),
2815
2835
  rawOutput: {
2816
2836
  pageContextRestarted: !0,
2817
2837
  outcome: "unknown",
2818
- message: er(location.href),
2838
+ message: nr(location.href),
2819
2839
  currentUrl: location.href,
2820
2840
  console: [],
2821
2841
  metadata: {
@@ -2832,17 +2852,17 @@ function tr(e) {
2832
2852
  return [];
2833
2853
  }
2834
2854
  }
2835
- function er(e) {
2855
+ function nr(e) {
2836
2856
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
2837
2857
  Current URL: ${e}`;
2838
2858
  }
2839
- function sr(e) {
2859
+ function rr(e) {
2840
2860
  if (!e || typeof e != "object")
2841
2861
  return !1;
2842
2862
  const t = e, s = t.event;
2843
2863
  return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && $t(s) && s.type === "tool.result";
2844
2864
  }
2845
- function nr(e, t) {
2865
+ function ir(e, t) {
2846
2866
  const s = new Set(
2847
2867
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
2848
2868
  );
@@ -2851,9 +2871,9 @@ function nr(e, t) {
2851
2871
  ...t.filter((n) => !s.has(n.callId))
2852
2872
  ];
2853
2873
  }
2854
- function rr(e) {
2874
+ function or(e) {
2855
2875
  try {
2856
- window.sessionStorage.removeItem(`${rt}${e}`);
2876
+ window.sessionStorage.removeItem(`${it}${e}`);
2857
2877
  } catch {
2858
2878
  return;
2859
2879
  }
@@ -2878,23 +2898,23 @@ function ve(e, t) {
2878
2898
  return !1;
2879
2899
  const i = r;
2880
2900
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
2881
- }), n = t ? s.map((r) => Oe(r, t)) : s;
2901
+ }), n = t ? s.map((r) => Ne(r, t)) : s;
2882
2902
  return n.length > 0 ? n : void 0;
2883
2903
  }
2884
- function Oe(e, t) {
2904
+ function Ne(e, t) {
2885
2905
  return e.fileUrl?.startsWith("/") ? {
2886
2906
  ...e,
2887
2907
  fileUrl: new URL(e.fileUrl, t).toString()
2888
2908
  } : e;
2889
2909
  }
2890
2910
  function me(e) {
2891
- return e.type || ir(e.name) || "application/octet-stream";
2911
+ return e.type || ar(e.name) || "application/octet-stream";
2892
2912
  }
2893
- function ir(e) {
2913
+ function ar(e) {
2894
2914
  const t = e.toLowerCase();
2895
2915
  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;
2896
2916
  }
2897
- function or(e) {
2917
+ function cr(e) {
2898
2918
  if (!e || typeof e != "object")
2899
2919
  return null;
2900
2920
  const t = e;
@@ -2911,7 +2931,7 @@ function or(e) {
2911
2931
  loading: typeof t.loading == "boolean" ? t.loading : void 0
2912
2932
  };
2913
2933
  }
2914
- function ar(e) {
2934
+ function lr(e) {
2915
2935
  return e.attachments?.length ? {
2916
2936
  ...e,
2917
2937
  attachments: e.attachments.map(Wt)
@@ -2934,11 +2954,11 @@ function M(e) {
2934
2954
  const t = e.runId;
2935
2955
  return typeof t == "string" && t ? t : null;
2936
2956
  }
2937
- function cr(e) {
2957
+ function ur(e) {
2938
2958
  const t = e?.timeoutMs;
2939
- 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 <= Ns);
2959
+ return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Bs);
2940
2960
  }
2941
- function Ne(e) {
2961
+ function Oe(e) {
2942
2962
  const t = {};
2943
2963
  try {
2944
2964
  new Headers(e).forEach((s, n) => {
@@ -2950,22 +2970,22 @@ function Ne(e) {
2950
2970
  return t;
2951
2971
  }
2952
2972
  function jt(e, t) {
2953
- return $e(e) ? at : C(nt(t), Rs);
2973
+ return $e(e) ? ct : C(rt(t), Ms);
2954
2974
  }
2955
- function lr(e, t) {
2975
+ function dr(e, t) {
2956
2976
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
2957
2977
  }
2958
- async function ur(e, t, s, n) {
2959
- const r = Ne(e.headers);
2978
+ async function hr(e, t, s, n) {
2979
+ const r = Oe(e.headers);
2960
2980
  n({
2961
2981
  ...t,
2962
2982
  responseStatus: e.status,
2963
2983
  responseHeaders: r,
2964
- responseBody: await dr(e),
2984
+ responseBody: await pr(e),
2965
2985
  durationMs: Date.now() - s
2966
2986
  });
2967
2987
  }
2968
- async function dr(e) {
2988
+ async function pr(e) {
2969
2989
  if (!Le(e.headers))
2970
2990
  return;
2971
2991
  let t = null, s = null;
@@ -2975,7 +2995,7 @@ async function dr(e) {
2975
2995
  const n = new Promise((a) => {
2976
2996
  s = window.setTimeout(() => {
2977
2997
  t?.cancel(), a("timeout");
2978
- }, _s);
2998
+ }, Cs);
2979
2999
  }), r = new TextDecoder();
2980
3000
  let i = "", o = 0;
2981
3001
  for (; ; ) {
@@ -2997,7 +3017,7 @@ async function dr(e) {
2997
3017
  s !== null && window.clearTimeout(s);
2998
3018
  }
2999
3019
  }
3000
- function hr(e, t) {
3020
+ function fr(e, t) {
3001
3021
  if (Le(new Headers(t)))
3002
3022
  try {
3003
3023
  return e.responseType === "" || e.responseType === "text" ? C(e.responseText ?? "") : void 0;
@@ -3009,23 +3029,23 @@ function ye(e) {
3009
3029
  if (typeof e == "string")
3010
3030
  return C(e);
3011
3031
  }
3012
- function pr(e) {
3032
+ function gr(e) {
3013
3033
  return k({
3014
3034
  ...e,
3015
- requestBody: Ie(e.requestBody),
3016
- responseBody: Ie(e.responseBody)
3035
+ requestBody: Te(e.requestBody),
3036
+ responseBody: Te(e.responseBody)
3017
3037
  });
3018
3038
  }
3019
- function Ie(e) {
3039
+ function Te(e) {
3020
3040
  if (typeof e != "string")
3021
3041
  return e;
3022
3042
  const t = e.trim();
3023
3043
  if (!t.startsWith("{") && !t.startsWith("["))
3024
- return nt(e);
3044
+ return rt(e);
3025
3045
  try {
3026
3046
  return JSON.stringify(k(JSON.parse(e)));
3027
3047
  } catch {
3028
- return nt(e);
3048
+ return rt(e);
3029
3049
  }
3030
3050
  }
3031
3051
  function Le(e) {
@@ -3034,8 +3054,8 @@ function Le(e) {
3034
3054
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
3035
3055
  return s !== null && Number.isInteger(n) && n >= 0 && n <= Lt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3036
3056
  }
3037
- function O(e, t = {}, s) {
3038
- if (gr(s))
3057
+ function N(e, t = {}, s) {
3058
+ if (yr(s))
3039
3059
  return !0;
3040
3060
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3041
3061
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3050,8 +3070,8 @@ function O(e, t = {}, s) {
3050
3070
  return !0;
3051
3071
  }
3052
3072
  }
3053
- function fr(e, t) {
3054
- if (O(e))
3073
+ function mr(e, t) {
3074
+ if (N(e))
3055
3075
  return !0;
3056
3076
  try {
3057
3077
  const s = new URL(e, location.href), n = new URL(t);
@@ -3060,10 +3080,10 @@ function fr(e, t) {
3060
3080
  return !0;
3061
3081
  }
3062
3082
  }
3063
- function gr(e) {
3083
+ function yr(e) {
3064
3084
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
3065
3085
  }
3066
- function mr(e) {
3086
+ function Tr(e) {
3067
3087
  const t = {};
3068
3088
  for (const s of e.trim().split(/[\r\n]+/)) {
3069
3089
  const n = s.indexOf(":");
@@ -3079,96 +3099,96 @@ function mr(e) {
3079
3099
  function C(e, t = Lt) {
3080
3100
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
3081
3101
  }
3082
- function kt(e) {
3102
+ function Rt(e) {
3083
3103
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
3084
3104
  }
3085
- class et extends Error {
3105
+ class st extends Error {
3086
3106
  constructor(t, s) {
3087
3107
  super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
3088
3108
  }
3089
3109
  status;
3090
3110
  }
3091
- async function Rt(e, t) {
3111
+ async function Q(e, t) {
3092
3112
  let s = null;
3093
3113
  for (let n = 0; n < re; n += 1)
3094
3114
  try {
3095
3115
  return await e();
3096
3116
  } catch (r) {
3097
- if (s = r, n >= re - 1 || !Ir(r))
3117
+ if (s = r, n >= re - 1 || !wr(r))
3098
3118
  throw r;
3099
- await yr(n);
3119
+ await Ir(n);
3100
3120
  }
3101
3121
  throw s instanceof Error ? s : new Error(t);
3102
3122
  }
3103
- function yr(e) {
3123
+ function Ir(e) {
3104
3124
  return new Promise((t) => {
3105
- window.setTimeout(t, ks[e] ?? 0);
3125
+ window.setTimeout(t, _s[e] ?? 0);
3106
3126
  });
3107
3127
  }
3108
- function Ir(e) {
3109
- return e instanceof et ? Tr(e.status) : e instanceof TypeError;
3128
+ function wr(e) {
3129
+ return e instanceof st ? Ar(e.status) : e instanceof TypeError;
3110
3130
  }
3111
- function Tr(e) {
3131
+ function Ar(e) {
3112
3132
  return e === 408 || e === 409 || e === 429 || e >= 500;
3113
3133
  }
3114
- function wr(e) {
3134
+ function Sr(e) {
3115
3135
  return e === 401 || e === 403;
3116
3136
  }
3117
- const at = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", Sr = "[REDACTED_SIGNED_URL]", Ar = 20, br = /^(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, Be = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, qe = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, He = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Fe = /\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, Er = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, kr = /\bhttps?:\/\/[^\s"'<>]+/gi, Rr = /[),.;\]]+$/;
3137
+ const ct = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", Er = "[REDACTED_SIGNED_URL]", br = 20, kr = /^(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, Be = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, qe = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, He = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Fe = /\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, Rr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, _r = /\bhttps?:\/\/[^\s"'<>]+/gi, Mr = /[),.;\]]+$/;
3118
3138
  function k(e) {
3119
- return st(e, 0, /* @__PURE__ */ new WeakSet());
3139
+ return nt(e, 0, /* @__PURE__ */ new WeakSet());
3120
3140
  }
3121
- function st(e, t, s) {
3141
+ function nt(e, t, s) {
3122
3142
  if (typeof e == "string")
3123
- return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : nt(e);
3143
+ return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : rt(e);
3124
3144
  if (e === null || typeof e != "object")
3125
3145
  return e;
3126
- if (t >= Ar)
3146
+ if (t >= br)
3127
3147
  return "[REDACTED_MAX_DEPTH]";
3128
3148
  if (s.has(e))
3129
3149
  return "[REDACTED_CIRCULAR]";
3130
3150
  if (s.add(e), Array.isArray(e))
3131
- return e.map((r) => st(r, t + 1, s));
3151
+ return e.map((r) => nt(r, t + 1, s));
3132
3152
  const n = {};
3133
3153
  for (const [r, i] of Object.entries(e))
3134
- r === "pageContent" ? n[r] = i : $e(r) ? n[r] = at : n[r] = r.toLowerCase() === "url" ? _r(i) : st(i, t + 1, s);
3154
+ r === "pageContent" ? n[r] = i : $e(r) ? n[r] = ct : n[r] = r.toLowerCase() === "url" ? Cr(i) : nt(i, t + 1, s);
3135
3155
  return n;
3136
3156
  }
3137
3157
  function $e(e) {
3138
3158
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
3139
3159
  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");
3140
3160
  }
3141
- function _r(e) {
3142
- return typeof e == "string" ? We(e) : st(e, 0, /* @__PURE__ */ new WeakSet());
3161
+ function Cr(e) {
3162
+ return typeof e == "string" ? We(e) : nt(e, 0, /* @__PURE__ */ new WeakSet());
3143
3163
  }
3144
3164
  function We(e) {
3145
3165
  try {
3146
3166
  const t = new URL(e, location.href);
3147
3167
  for (const s of Array.from(t.searchParams.keys()))
3148
- br.test(s) && t.searchParams.set(s, P);
3168
+ kr.test(s) && t.searchParams.set(s, P);
3149
3169
  return t.username && (t.username = P), t.password && (t.password = P), t.toString();
3150
3170
  } catch {
3151
- return Mr(e);
3171
+ return Pr(e);
3152
3172
  }
3153
3173
  }
3154
- function nt(e) {
3155
- return e.replace(Er, Sr).replace(kr, Cr).replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${at}`);
3174
+ function rt(e) {
3175
+ return e.replace(Rr, Er).replace(_r, Ur).replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${ct}`);
3156
3176
  }
3157
- function Mr(e) {
3158
- return e.replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${at}`);
3177
+ function Pr(e) {
3178
+ return e.replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${ct}`);
3159
3179
  }
3160
- function Cr(e) {
3161
- const t = e.match(Rr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3180
+ function Ur(e) {
3181
+ const t = e.match(Mr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3162
3182
  return `${We(s)}${t}`;
3163
3183
  }
3164
3184
  export {
3165
3185
  te as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3166
3186
  Mt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3167
- ls as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3168
- cs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3169
- us as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3170
- be as PlunoProductAgent,
3171
- Ps as calculateReconnectDelay,
3172
- be as default,
3173
- Qs as getProductAgentOriginAccessErrorMessage
3187
+ ds as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3188
+ us as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3189
+ hs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3190
+ Ee as PlunoProductAgent,
3191
+ Ds as calculateReconnectDelay,
3192
+ Ee as default,
3193
+ en as getProductAgentOriginAccessErrorMessage
3174
3194
  };