@pluno/product-agent-web 0.1.148 → 0.1.149

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
- const Ye = "pluno-product-agent-attachments";
2
- const Ct = "files";
3
- async function Ze(e) {
4
- const t = await qt();
5
- await es(t, "readwrite", (s) => s.put(e));
6
- }
7
- async function Qe(e, t) {
8
- const s = await qt();
9
- await Bt(s, "readwrite", async (n) => {
10
- const r = await Ft(
1
+ const Ze = "pluno-product-agent-attachments";
2
+ const Pt = "files";
3
+ async function Qe(e) {
4
+ const t = await Bt();
5
+ await ss(t, "readwrite", (s) => s.put(e));
6
+ }
7
+ async function ts(e, t) {
8
+ const s = await Bt();
9
+ await Ft(s, "readwrite", async (n) => {
10
+ const r = await Ht(
11
11
  n.get(e)
12
12
  );
13
13
  r && n.put({
@@ -16,28 +16,28 @@ async function Qe(e, t) {
16
16
  });
17
17
  });
18
18
  }
19
- async function ts(e = 864e5) {
20
- const t = await qt(), s = Date.now() - e;
21
- await Bt(t, "readwrite", async (n) => {
19
+ async function es(e = 864e5) {
20
+ const t = await Bt(), s = Date.now() - e;
21
+ await Ft(t, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Ft(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await Ht(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function qt() {
26
+ function Bt() {
27
27
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
28
- const s = indexedDB.open(Ye, 1);
28
+ const s = indexedDB.open(Ze, 1);
29
29
  s.onupgradeneeded = () => {
30
- const r = s.result.createObjectStore(Ct, { keyPath: "attachmentId" });
30
+ const r = s.result.createObjectStore(Pt, { keyPath: "attachmentId" });
31
31
  r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
32
32
  }, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
33
33
  });
34
34
  }
35
- async function es(e, t, s) {
36
- return await Bt(e, t, async (n) => await Ft(s(n)));
35
+ async function ss(e, t, s) {
36
+ return await Ft(e, t, async (n) => await Ht(s(n)));
37
37
  }
38
- function Bt(e, t, s) {
38
+ function Ft(e, t, s) {
39
39
  return new Promise((n, r) => {
40
- const i = e.transaction(Ct, t), o = i.objectStore(Ct);
40
+ const i = e.transaction(Pt, t), o = i.objectStore(Pt);
41
41
  let a, c = !1;
42
42
  s(o).then((l) => {
43
43
  a = l;
@@ -57,16 +57,16 @@ function Bt(e, t, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Ft(e) {
60
+ function Ht(e) {
61
61
  return new Promise((t, s) => {
62
62
  e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
63
63
  });
64
64
  }
65
- function ss(e) {
65
+ function ns(e) {
66
66
  return e !== null && (typeof e == "object" || typeof e == "function");
67
67
  }
68
68
  function Re(e, t, s) {
69
- const n = Reflect.get(e, "pluno"), r = ss(n) ? n : {};
69
+ const n = Reflect.get(e, "pluno"), r = ns(n) ? n : {};
70
70
  if (r !== n && !Reflect.set(e, "pluno", r))
71
71
  return null;
72
72
  const i = Object.getOwnPropertyDescriptor(r, t);
@@ -80,14 +80,14 @@ function Re(e, t, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const ns = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function rs(e, t) {
83
+ const rs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function is(e, t) {
85
85
  return t ? e.replace(
86
- ns,
86
+ rs,
87
87
  (s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
88
88
  ) : e;
89
89
  }
90
- function is(e, t, s) {
90
+ function os(e, t, s) {
91
91
  const n = t.map((u) => ({ item: u, identity: s(u) })), r = new Set(
92
92
  n.flatMap(
93
93
  ({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
@@ -114,7 +114,7 @@ function is(e, t, s) {
114
114
  for (const u of e) {
115
115
  const d = s(u);
116
116
  let p = o.get(d.id);
117
- if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((E) => l.get(E)).find((E) => E !== void 0) ?? p), p && !I.has(p)) {
117
+ if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((b) => l.get(b)).find((b) => b !== void 0) ?? p), p && !I.has(p)) {
118
118
  g.push(p), I.add(p);
119
119
  continue;
120
120
  }
@@ -125,16 +125,16 @@ function is(e, t, s) {
125
125
  I.has(u) || g.push(u);
126
126
  return g;
127
127
  }
128
- function os(e, t, s, n) {
128
+ function as(e, t, s, n) {
129
129
  return e.filter((r) => {
130
130
  const i = n(r);
131
131
  return !i.isActivity || !i.isTransient ? !0 : t !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== t : s === null || i.runId !== s;
132
132
  });
133
133
  }
134
- const St = "pluno.productAgent.transportId", as = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", cs = 50, ls = globalThis.setTimeout.bind(globalThis);
134
+ const St = "pluno.productAgent.transportId", cs = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", ls = 50, us = globalThis.setTimeout.bind(globalThis);
135
135
  let W = null;
136
- const et = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Map();
137
- async function us(e = be()) {
136
+ const et = /* @__PURE__ */ new Set(), bt = /* @__PURE__ */ new Map();
137
+ async function ds(e = ke()) {
138
138
  const t = e.randomUUID(), s = e.storage.getItem(St);
139
139
  let n = s ?? e.randomUUID(), r = !1, i = !1;
140
140
  const o = e.channel.subscribe((c) => {
@@ -170,14 +170,14 @@ async function us(e = be()) {
170
170
  }
171
171
  };
172
172
  }
173
- async function ds() {
174
- W || (W = us(be()), W.then((n) => {
173
+ async function hs() {
174
+ W || (W = ds(ke()), W.then((n) => {
175
175
  const r = (i) => {
176
176
  i.persisted || (n.release(), W = null, et.clear(), window.removeEventListener("pagehide", r));
177
177
  };
178
178
  window.addEventListener("pagehide", r);
179
179
  }));
180
- const e = await W, t = hs();
180
+ const e = await W, t = ps();
181
181
  et.add(t);
182
182
  let s = !1;
183
183
  return {
@@ -188,31 +188,31 @@ async function ds() {
188
188
  }
189
189
  };
190
190
  }
191
- function hs() {
191
+ function ps() {
192
192
  let e = 0;
193
193
  for (; et.has(e); )
194
194
  e += 1;
195
195
  return e;
196
196
  }
197
- function be() {
197
+ function ke() {
198
198
  return {
199
- storage: ps(),
200
- channel: fs(),
199
+ storage: fs(),
200
+ channel: gs(),
201
201
  randomUUID: () => crypto.randomUUID(),
202
- settle: () => new Promise((e) => ls(e, cs))
202
+ settle: () => new Promise((e) => us(e, ls))
203
203
  };
204
204
  }
205
- function ps() {
205
+ function fs() {
206
206
  return {
207
207
  getItem: (e) => {
208
208
  try {
209
- return window.sessionStorage?.getItem(e) ?? Et.get(e) ?? null;
209
+ return window.sessionStorage?.getItem(e) ?? bt.get(e) ?? null;
210
210
  } catch {
211
- return Et.get(e) ?? null;
211
+ return bt.get(e) ?? null;
212
212
  }
213
213
  },
214
214
  setItem: (e, t) => {
215
- Et.set(e, t);
215
+ bt.set(e, t);
216
216
  try {
217
217
  window.sessionStorage?.setItem(e, t);
218
218
  } catch {
@@ -220,9 +220,9 @@ function ps() {
220
220
  }
221
221
  };
222
222
  }
223
- function fs() {
223
+ function gs() {
224
224
  if (typeof BroadcastChannel < "u") {
225
- const e = new BroadcastChannel(as);
225
+ const e = new BroadcastChannel(cs);
226
226
  return {
227
227
  postMessage: (t) => e.postMessage(t),
228
228
  subscribe: (t) => {
@@ -232,9 +232,9 @@ function fs() {
232
232
  close: () => e.close()
233
233
  };
234
234
  }
235
- return gs();
235
+ return ms();
236
236
  }
237
- function gs() {
237
+ function ms() {
238
238
  const e = /* @__PURE__ */ new Set(), t = (s) => {
239
239
  if (s.key !== At || !s.newValue)
240
240
  return;
@@ -255,9 +255,9 @@ function gs() {
255
255
  }
256
256
  };
257
257
  }
258
- const ms = globalThis.fetch.bind(globalThis), Pt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ys = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Is = ".pluno-pa-widget__panel", Ts = ".pluno-pa-widget__timeline", ne = `${Pt}[data-pluno-sdk-preview-channel]`;
259
- let ws = 0;
260
- function re(e) {
258
+ const ys = globalThis.fetch.bind(globalThis), Ut = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Is = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ts = ".pluno-pa-widget__panel", ws = ".pluno-pa-widget__timeline", re = `${Ut}[data-pluno-sdk-preview-channel]`;
259
+ let Ss = 0;
260
+ function ie(e) {
261
261
  const t = {};
262
262
  for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
263
263
  const o = e[i];
@@ -270,7 +270,7 @@ function re(e) {
270
270
  const r = e.attachments;
271
271
  return Array.isArray(r) && (t.attachmentCount = r.length), t;
272
272
  }
273
- function Rt(e, t, s) {
273
+ function Et(e, t, s) {
274
274
  if (typeof window > "u")
275
275
  return;
276
276
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -282,25 +282,25 @@ function Rt(e, t, s) {
282
282
  source: "web_sdk",
283
283
  category: e,
284
284
  name: t,
285
- sequence: ++ws,
285
+ sequence: ++Ss,
286
286
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
287
287
  monotonicMs: performance.now(),
288
288
  data: s
289
289
  };
290
290
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
291
291
  }
292
- const Ss = "https://app.pluno.ai", As = "gpt-5.6-terra", Es = 2e4, Rs = 1e4, bs = 1e4, Ms = 1e4, ks = 1e4, _s = 1e3, ie = 3e4, oe = 0.2, ae = 6e4, Cs = 15e3, V = 8, Ps = 15e3, Us = 2e3, Ds = 1e3, vs = 100, ce = 8e3, le = 3, Os = [300, 1e3], Ht = 64e3, bt = 4e3, Wt = 30, Ns = 2e3, xs = 1e3, Me = "Image is too large for model vision input.", Ls = 100, ke = "pluno.productAgent.state.", Ut = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", qs = 100;
292
+ const As = "https://app.pluno.ai", bs = "gpt-5.6-terra", Es = 2e4, Rs = 1e4, ks = 1e4, Ms = 1e4, _s = 1e4, Cs = 1e3, oe = 3e4, ae = 0.2, ce = 6e4, Ps = 15e3, V = 8, Us = 15e3, Ds = 2e3, Os = 1e3, Ns = 100, le = 8e3, ue = 3, vs = [300, 1e3], Wt = 64e3, Rt = 4e3, $t = 30, xs = 2e3, Ls = 1e3, Me = "Image is too large for model vision input.", qs = 100, _e = "pluno.productAgent.state.", Dt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Bs = 100;
293
293
  function Y(e, t = 0) {
294
294
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
295
295
  return Math.max(t, s);
296
296
  }
297
297
  const st = /* @__PURE__ */ new Set();
298
298
  let Z = null;
299
- function Bs(e, t = Math.random) {
300
- const s = Math.min(ie, _s * 2 ** e), n = 1 - oe + t() * oe * 2;
301
- return Math.min(ie, Math.round(s * n));
299
+ function Fs(e, t = Math.random) {
300
+ const s = Math.min(oe, Cs * 2 ** e), n = 1 - ae + t() * ae * 2;
301
+ return Math.min(oe, Math.round(s * n));
302
302
  }
303
- function Fs(e, t, s) {
303
+ function Hs(e, t, s) {
304
304
  return new Promise((n, r) => {
305
305
  const i = setTimeout(() => r(new Error(s)), t);
306
306
  e.then(
@@ -313,13 +313,13 @@ function Fs(e, t, s) {
313
313
  );
314
314
  });
315
315
  }
316
- class _e {
316
+ class Ce {
317
317
  constructor(t, s) {
318
318
  this.options = t, this.transportIdentity = s, this.state = {
319
319
  ...this.state,
320
- starterPrompts: Sn(t.initialStarterPrompts)
320
+ starterPrompts: bn(t.initialStarterPrompts)
321
321
  };
322
- const n = t.restorePersistedState === !1 ? null : lr(t.clientId, t.expectedPersistedSessionId);
322
+ const n = t.restorePersistedState === !1 ? null : dr(t.clientId, t.expectedPersistedSessionId);
323
323
  n && (this.state = {
324
324
  ...this.state,
325
325
  ...n,
@@ -332,9 +332,9 @@ class _e {
332
332
  assistantDraftRunId: null,
333
333
  isThinking: !1,
334
334
  lastError: null
335
- }), this.queuedClientEvents = mr(
336
- dr(t.clientId),
337
- pr(t.clientId)
335
+ }), this.queuedClientEvents = Ir(
336
+ pr(t.clientId),
337
+ gr(t.clientId)
338
338
  ), j(t.clientId, this.queuedClientEvents);
339
339
  }
340
340
  options;
@@ -361,6 +361,9 @@ class _e {
361
361
  retryAttemptsByClientMessageId = {};
362
362
  retryTimersByClientMessageId = {};
363
363
  clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
364
+ backgroundSessionIds = /* @__PURE__ */ new Set();
365
+ backgroundClientMessageIds = /* @__PURE__ */ new Set();
366
+ deferredSessionUpdatedSessionIds = /* @__PURE__ */ new Set();
364
367
  // The backend closes a retryable failed run with assistant_done; that paired event is recovery control flow,
365
368
  // not successful completion of the user turn.
366
369
  retryableFailureRunIdsAwaitingDone = /* @__PURE__ */ new Set();
@@ -406,15 +409,15 @@ class _e {
406
409
  lastErrorSecuritySettingsUrl: null
407
410
  };
408
411
  static async init(t) {
409
- const s = await ds(), n = new _e({
412
+ const s = await hs(), n = new Ce({
410
413
  ...t,
411
- backendUrl: on(t.backendUrl ?? Ss),
412
- clientId: t.clientId ?? Mn(),
413
- model: t.model ?? As,
414
- entrySurface: an(t.entrySurface)
414
+ backendUrl: cn(t.backendUrl ?? As),
415
+ clientId: t.clientId ?? _n(),
416
+ model: t.model ?? bs,
417
+ entrySurface: ln(t.entrySurface)
415
418
  }, s);
416
419
  try {
417
- ts().catch((r) => {
420
+ es().catch((r) => {
418
421
  S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
419
422
  message: r instanceof Error ? r.message : String(r)
420
423
  });
@@ -445,11 +448,11 @@ class _e {
445
448
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
446
449
  );
447
450
  try {
448
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Fs(this.options.tokenProvider(), bs, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
451
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Hs(this.options.tokenProvider(), ks, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
449
452
  return;
450
453
  if (!this.token && !this.options.webSocketFactory)
451
454
  throw new Error("Pluno requires a token or tokenProvider");
452
- const s = un(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
455
+ const s = hn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
453
456
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
454
457
  this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
455
458
  }, Ms), n.addEventListener("open", () => {
@@ -464,9 +467,9 @@ class _e {
464
467
  pageUrl: location.href
465
468
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
466
469
  this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
467
- }, ks));
470
+ }, _s));
468
471
  }), n.addEventListener("message", (r) => {
469
- this.socket === n && this.handleServerEvent(wn(r.data));
472
+ this.socket === n && this.handleServerEvent(An(r.data));
470
473
  }), n.addEventListener("close", (r) => {
471
474
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
472
475
  code: typeof r?.code == "number" ? r.code : null,
@@ -499,7 +502,7 @@ class _e {
499
502
  this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWarmupEvent = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
500
503
  }
501
504
  destroy() {
502
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), yr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
505
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Tr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
503
506
  for (const t of Object.values(this.listeners))
504
507
  t?.clear();
505
508
  }
@@ -509,16 +512,16 @@ class _e {
509
512
  reason: t,
510
513
  entrySurface: this.options.entrySurface,
511
514
  sessionId: this.state.sessionId ?? void 0,
512
- page: M()
515
+ page: k()
513
516
  };
514
517
  this.sendNow(s) || (this.pendingWarmupEvent = s);
515
518
  }
516
519
  async sendMessage(t, s = {}) {
517
520
  const n = t.trim(), r = s.attachments ?? [];
518
- let i = r.map(Kt);
521
+ let i = r.map(Gt);
519
522
  if (!n && i.length === 0)
520
523
  return null;
521
- const o = M(), a = s.clientMessageId ?? $(), c = {
524
+ const o = k(), a = s.clientMessageId ?? $(), c = {
522
525
  id: `local-${a}`,
523
526
  role: "user",
524
527
  content: n,
@@ -547,14 +550,14 @@ class _e {
547
550
  try {
548
551
  const p = [];
549
552
  for (const m of i) {
550
- const E = m.id ? this.attachmentFiles.get(m.id) : void 0;
553
+ const b = m.id ? this.attachmentFiles.get(m.id) : void 0;
551
554
  if (m.sandboxPath) {
552
555
  p.push(m);
553
556
  continue;
554
557
  }
555
- if (!E)
558
+ if (!b)
556
559
  throw new Error(`Attachment bytes are unavailable for ${m.name}`);
557
- p.push(await this.uploadAttachmentForMessage({ file: E, attachment: m }));
560
+ p.push(await this.uploadAttachmentForMessage({ file: b, attachment: m }));
558
561
  }
559
562
  i = p;
560
563
  } catch (p) {
@@ -569,14 +572,14 @@ class _e {
569
572
  sessionId: this.state.sessionId ?? void 0,
570
573
  clientMessageId: a,
571
574
  initiatedBy: s.initiatedBy,
572
- invocation: cn(s.invocation ?? s.initiatedBy),
575
+ invocation: un(s.invocation ?? s.initiatedBy),
573
576
  entrySurface: this.options.entrySurface,
574
577
  content: n,
575
- pageContent: u && $t() || void 0,
578
+ pageContent: u && jt() || void 0,
576
579
  attachments: i.length > 0 ? i : void 0,
577
580
  page: o,
578
581
  model: this.options.model,
579
- metadata: ue(this.options.metadata)
582
+ metadata: de(this.options.metadata)
580
583
  };
581
584
  return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.markThinkingProgress(), this.send(d), a;
582
585
  }
@@ -588,18 +591,18 @@ class _e {
588
591
  const s = $(), n = {
589
592
  id: s,
590
593
  name: t.name || "attachment",
591
- mimeType: Se(t),
594
+ mimeType: Ae(t),
592
595
  sizeBytes: t.size
593
596
  };
594
597
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
595
598
  const r = Date.now();
596
- return Ze({
599
+ return Qe({
597
600
  attachmentId: s,
598
601
  name: n.name,
599
602
  mimeType: n.mimeType,
600
603
  sizeBytes: n.sizeBytes,
601
604
  blob: t,
602
- origin: M().origin,
605
+ origin: k().origin,
603
606
  sessionId: this.state.sessionId ?? void 0,
604
607
  createdAt: r,
605
608
  lastUsedAt: r
@@ -622,7 +625,7 @@ class _e {
622
625
  file: t,
623
626
  attachment: s
624
627
  }) {
625
- const n = this.state.sessionId, r = Se(t), i = {
628
+ const n = this.state.sessionId, r = Ae(t), i = {
626
629
  sessionId: n ?? void 0,
627
630
  attachmentId: s.id,
628
631
  clientId: this.options.clientId,
@@ -630,9 +633,9 @@ class _e {
630
633
  name: t.name || "attachment",
631
634
  mimeType: r,
632
635
  sizeBytes: t.size,
633
- page: M(),
636
+ page: k(),
634
637
  model: this.options.model,
635
- metadata: ue(this.options.metadata),
638
+ metadata: de(this.options.metadata),
636
639
  entrySurface: this.options.entrySurface
637
640
  };
638
641
  let o;
@@ -658,8 +661,8 @@ class _e {
658
661
  }, "Failed to upload attachment"), o = c;
659
662
  }
660
663
  this.setState({ sessionId: o.sessionId });
661
- const a = Fe(o.attachment, this.options.backendUrl);
662
- return this.updateAttachmentInState(s.id, a), s.id && Qe(s.id, {
664
+ const a = He(o.attachment, this.options.backendUrl);
665
+ return this.updateAttachmentInState(s.id, a), s.id && ts(s.id, {
663
666
  sessionId: o.sessionId,
664
667
  fileUrl: a.fileUrl,
665
668
  sandboxPath: a.sandboxPath,
@@ -715,10 +718,10 @@ class _e {
715
718
  }
716
719
  startNewSession(t = {}) {
717
720
  const s = t.notifyTransport !== !1;
718
- !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
721
+ !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
719
722
  type: "session.reset",
720
723
  sessionId: this.state.sessionId ?? void 0,
721
- page: M()
724
+ page: k()
722
725
  }), this.setState({
723
726
  sessionId: null,
724
727
  starterPrompts: [...this.state.starterPrompts],
@@ -736,12 +739,12 @@ class _e {
736
739
  const s = $(), n = new Promise((i, o) => {
737
740
  const a = window.setTimeout(() => {
738
741
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
739
- }, ce);
742
+ }, le);
740
743
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
741
744
  }), r = {
742
745
  type: "sessions.list",
743
746
  requestId: s,
744
- page: M(),
747
+ page: k(),
745
748
  ...t.cursor ? { cursor: t.cursor } : {},
746
749
  ...t.limit ? { limit: t.limit } : {},
747
750
  ...typeof t.pinned == "boolean" ? { pinned: t.pinned } : {}
@@ -767,7 +770,7 @@ class _e {
767
770
  );
768
771
  }
769
772
  loadSession(t) {
770
- !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.clearThinkingWatchdog(), this.lastUserMessagePageUrl = null, this.setState({
773
+ !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(t), this.deferredSessionUpdatedSessionIds.delete(t)), this.clearThinkingWatchdog(), this.lastUserMessagePageUrl = null, this.setState({
771
774
  sessionId: t,
772
775
  assistantDraft: "",
773
776
  assistantDraftItemId: null,
@@ -780,11 +783,11 @@ class _e {
780
783
  }), this.send({
781
784
  type: "session.load",
782
785
  sessionId: t,
783
- page: M()
786
+ page: k()
784
787
  });
785
788
  }
786
789
  send(t) {
787
- this.sendNow(k(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
790
+ this.sendNow(M(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
788
791
  }
789
792
  async getUploadToken() {
790
793
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -797,7 +800,7 @@ class _e {
797
800
  return !1;
798
801
  const s = this.socket;
799
802
  try {
800
- return s.send(JSON.stringify(t)), Rt("client_event", t.type, re(t)), !0;
803
+ return s.send(JSON.stringify(t)), Et("client_event", t.type, ie(t)), !0;
801
804
  } catch (n) {
802
805
  return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
803
806
  message: n instanceof Error ? n.message : String(n),
@@ -810,9 +813,9 @@ class _e {
810
813
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
811
814
  return;
812
815
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
813
- const t = dn();
816
+ const t = pn();
814
817
  this.sendNow(
815
- k({
818
+ M({
816
819
  type: "starter_prompts.page_context",
817
820
  pageUrl: t.pageUrl,
818
821
  pageTitle: t.pageTitle,
@@ -821,13 +824,13 @@ class _e {
821
824
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
822
825
  }
823
826
  startStarterPromptUrlWatcher() {
824
- this.locationChangeCleanup || (this.locationChangeCleanup = hn(() => this.handleStarterPromptUrlChange()));
827
+ this.locationChangeCleanup || (this.locationChangeCleanup = fn(() => this.handleStarterPromptUrlChange()));
825
828
  }
826
829
  handleStarterPromptUrlChange() {
827
830
  const t = location.href;
828
831
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
829
832
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
830
- }, qs));
833
+ }, Bs));
831
834
  }
832
835
  refreshStarterPromptsForCurrentUrl() {
833
836
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -845,7 +848,7 @@ class _e {
845
848
  j(this.options.clientId, this.queuedClientEvents);
846
849
  for (let s = 0; s < t.length; s += 1) {
847
850
  const n = t[s];
848
- if (!this.sendNow(k(n))) {
851
+ if (!this.sendNow(M(n))) {
849
852
  this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), j(this.options.clientId, this.queuedClientEvents);
850
853
  return;
851
854
  }
@@ -856,308 +859,327 @@ class _e {
856
859
  !this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
857
860
  }
858
861
  handleServerEvent(t) {
859
- if (Rt("server_event", t.type, re(t)), t.type === "run.steered") {
860
- this.handleRunSteered(t);
861
- return;
862
- }
863
- if (t.type === "run.ack") {
864
- this.handleRunAck(t);
862
+ if (Et("server_event", t.type, ie(t)), t.type === "run.ack") {
863
+ const s = Mt(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
864
+ s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && n === this.activeClientMessageId && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(t);
865
865
  return;
866
866
  }
867
- if (t.type === "runtime.pong") {
868
- this.clearHeartbeatAckTimer();
869
- return;
870
- }
871
- if ($s(t) && this.markThinkingProgress(), t.type === "auth.ok") {
872
- this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
873
- const s = An(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
874
- S("web-sdk.agent", "Received auth.ok appearance", {
875
- hasAppearance: n,
876
- rawAppearance: t.appearance,
877
- normalizedAppearance: s
878
- }), this.runtimeHelperJavascript = En(t.runtimeHelpers)?.javascript ?? null;
879
- const r = pe(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
880
- user: kn(t.user),
881
- status: "connected",
882
- ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
883
- };
884
- (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !fn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
885
- type: "page.upsert",
886
- sessionId: this.state.sessionId,
887
- page: M(),
888
- model: this.options.model
889
- });
890
- return;
891
- }
892
- if (t.type === "starterPrompts.updated") {
893
- this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
894
- starterPrompts: pe(t, "starterPrompts"),
895
- starterPromptsLoading: !1
896
- });
897
- return;
867
+ if (t.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
868
+ const s = Mt(t);
869
+ if (s) {
870
+ this.deferredSessionUpdatedSessionIds.add(s);
871
+ return;
872
+ }
898
873
  }
899
- if (t.type === "conversation.state") {
900
- const s = Array.isArray(t.items) ? t.items : [], n = Nn(
901
- t.assistantDraft
902
- ), r = n !== void 0;
903
- this.rememberUserMessageClientMessageIds(s);
904
- const i = Yn(s);
905
- if (i) {
906
- const p = Zn(s, i);
907
- this.retryAttemptsByClientMessageId[i] = Math.max(
908
- this.retryAttemptsByClientMessageId[i] ?? 0,
909
- p
910
- );
874
+ if (!this.shouldIgnoreBackgroundSessionEvent(t)) {
875
+ if (t.type === "run.steered") {
876
+ this.handleRunSteered(t);
877
+ return;
911
878
  }
912
- const o = s.filter((p) => {
913
- const m = q(p);
914
- return !me(m) && (!i || !Nt(m));
915
- }), a = jn(
916
- this.state.messages,
917
- _n(o, this.options.backendUrl)
918
- ), c = ge(a), l = !r && s.some(
919
- (p) => Ie(
920
- q(p),
921
- this.state.assistantDraft,
922
- this.state.assistantDraftItemId,
923
- this.state.assistantDraftRespondsToUserMessageId,
924
- this.state.assistantDraftRunId
925
- )
926
- ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = Xn(a), u = I && g;
927
- if (!c && Vn(this.state.messages, s))
879
+ if (t.type === "runtime.pong") {
880
+ this.clearHeartbeatAckTimer();
928
881
  return;
929
- this.lastUserMessagePageUrl = Jn(s);
930
- const d = I ? null : xt(s);
931
- if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
932
- sessionId: R(t.session, "id") ?? this.state.sessionId,
933
- messages: a,
934
- ...r ? {
935
- assistantDraft: n?.content ?? "",
936
- assistantDraftItemId: n?.itemId ?? null,
937
- assistantDraftPhase: n?.phase ?? null,
938
- assistantDraftRespondsToUserMessageId: n?.respondsToUserMessageId ?? null,
939
- assistantDraftRunId: n?.runId ?? null
940
- } : l ? {
941
- assistantDraft: "",
942
- assistantDraftItemId: null,
943
- assistantDraftPhase: null,
944
- assistantDraftRespondsToUserMessageId: null,
945
- assistantDraftRunId: null
946
- } : {},
947
- ...f ? {
948
- isThinking: !0,
949
- lastError: null
950
- } : I ? {
951
- isThinking: !1,
952
- ...u ? {
953
- status: "connected",
954
- lastError: null,
955
- lastErrorCode: null,
956
- lastErrorSecuritySettingsUrl: null
957
- } : {}
958
- } : d ? {
959
- isThinking: !0,
960
- lastError: null
961
- } : {}
962
- }), I ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (f || d) && (d && (this.activeClientMessageId = d), this.markThinkingProgress()), i) {
963
- const p = R(t.session, "id") ?? this.state.sessionId;
964
- p && this.retryAfterInterruptedRun(p, i);
965
882
  }
966
- return;
967
- }
968
- if (t.type === "sessions.page") {
969
- const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
970
- s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
971
- sessions: Cn(t.sessions),
972
- nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
973
- }));
974
- return;
975
- }
976
- if (t.type === "session.pin.updated") {
977
- this.resolvePendingSessionMutation(this.pendingSessionPinRequests, t);
978
- return;
979
- }
980
- if (t.type === "session.rename.updated") {
981
- this.resolvePendingSessionMutation(this.pendingSessionRenameRequests, t);
982
- return;
983
- }
984
- if (t.type === "session.updated") {
985
- this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: R(t.session, "id") ?? this.state.sessionId });
986
- return;
987
- }
988
- if (t.type === "session.item") {
989
- this.rememberUserMessageClientMessageIds([t.item]);
990
- const s = q(t.item);
991
- if (Nt(s)) {
992
- typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
993
- const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
994
- if (r && a) {
995
- this.retryAfterInterruptedRun(r, a);
996
- return;
997
- }
998
- if (r && i) {
999
- this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
1000
- return;
1001
- }
883
+ if (js(t) && this.markThinkingProgress(), t.type === "auth.ok") {
884
+ this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
885
+ const s = En(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
886
+ S("web-sdk.agent", "Received auth.ok appearance", {
887
+ hasAppearance: n,
888
+ rawAppearance: t.appearance,
889
+ normalizedAppearance: s
890
+ }), this.runtimeHelperJavascript = Rn(t.runtimeHelpers)?.javascript ?? null;
891
+ const r = fe(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
892
+ user: Cn(t.user),
893
+ status: "connected",
894
+ ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
895
+ };
896
+ (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !mn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
897
+ type: "page.upsert",
898
+ sessionId: this.state.sessionId,
899
+ page: k(),
900
+ model: this.options.model
901
+ });
902
+ return;
1002
903
  }
1003
- if (me(s))
904
+ if (t.type === "starterPrompts.updated") {
905
+ this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
906
+ starterPrompts: fe(t, "starterPrompts"),
907
+ starterPromptsLoading: !1
908
+ });
1004
909
  return;
1005
- const n = ve(t.item, this.options.backendUrl);
1006
- if (n) {
1007
- const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1008
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), O(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1009
- const i = t.item.data;
1010
- tr(i) && this.clearRunAckResyncRetryTimer();
1011
- const o = Dt(this.state.messages, n), a = ge(o), c = Ie(
1012
- i,
1013
- this.state.assistantDraft,
1014
- this.state.assistantDraftItemId,
1015
- this.state.assistantDraftRespondsToUserMessageId,
1016
- this.state.assistantDraftRunId
1017
- ), l = a && (!this.state.assistantDraft || c), h = l && O(n);
1018
- this.setState({
1019
- messages: o,
1020
- ...c ? {
910
+ }
911
+ if (t.type === "conversation.state") {
912
+ const s = Array.isArray(t.items) ? t.items : [], n = Ln(
913
+ t.assistantDraft
914
+ ), r = n !== void 0;
915
+ this.rememberUserMessageClientMessageIds(s);
916
+ const i = Qn(s);
917
+ if (i) {
918
+ const p = tr(s, i);
919
+ this.retryAttemptsByClientMessageId[i] = Math.max(
920
+ this.retryAttemptsByClientMessageId[i] ?? 0,
921
+ p
922
+ );
923
+ }
924
+ const o = s.filter((p) => {
925
+ const m = q(p);
926
+ return !ye(m) && (!i || !xt(m));
927
+ }), a = Kn(
928
+ this.state.messages,
929
+ Pn(o, this.options.backendUrl)
930
+ ), c = me(a), l = !r && s.some(
931
+ (p) => Te(
932
+ q(p),
933
+ this.state.assistantDraft,
934
+ this.state.assistantDraftItemId,
935
+ this.state.assistantDraftRespondsToUserMessageId,
936
+ this.state.assistantDraftRunId
937
+ )
938
+ ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = Vn(a), u = I && g;
939
+ if (!c && Zn(this.state.messages, s))
940
+ return;
941
+ this.lastUserMessagePageUrl = Yn(s);
942
+ const d = I ? null : Lt(s);
943
+ if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
944
+ sessionId: E(t.session, "id") ?? this.state.sessionId,
945
+ messages: a,
946
+ ...r ? {
947
+ assistantDraft: n?.content ?? "",
948
+ assistantDraftItemId: n?.itemId ?? null,
949
+ assistantDraftPhase: n?.phase ?? null,
950
+ assistantDraftRespondsToUserMessageId: n?.respondsToUserMessageId ?? null,
951
+ assistantDraftRunId: n?.runId ?? null
952
+ } : l ? {
1021
953
  assistantDraft: "",
1022
954
  assistantDraftItemId: null,
1023
955
  assistantDraftPhase: null,
1024
956
  assistantDraftRespondsToUserMessageId: null,
1025
957
  assistantDraftRunId: null
1026
958
  } : {},
1027
- ...l ? {
1028
- isThinking: !1
1029
- } : {},
1030
- ...h ? {
1031
- status: "connected",
1032
- lastError: null,
1033
- lastErrorCode: null,
1034
- lastErrorSecuritySettingsUrl: null
959
+ ...f ? {
960
+ isThinking: !0,
961
+ lastError: null
962
+ } : I ? {
963
+ isThinking: !1,
964
+ ...u ? {
965
+ status: "connected",
966
+ lastError: null,
967
+ lastErrorCode: null,
968
+ lastErrorSecuritySettingsUrl: null
969
+ } : {}
970
+ } : d ? {
971
+ isThinking: !0,
972
+ lastError: null
1035
973
  } : {}
1036
- }), l && this.clearThinkingWatchdog(), this.emit("message", n);
974
+ }), I ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (f || d) && (d && (this.activeClientMessageId = d), this.markThinkingProgress()), i) {
975
+ const p = E(t.session, "id") ?? this.state.sessionId;
976
+ p && this.retryAfterInterruptedRun(p, i);
977
+ }
978
+ return;
1037
979
  }
1038
- return;
1039
- }
1040
- if (t.type === "chat.assistant_delta") {
1041
- this.clearRunAckResyncRetryTimer();
1042
- const s = typeof t.delta == "string" ? t.delta : "", n = typeof t.itemId == "string" ? t.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((f) => f.id === o), c = t.phase === "commentary" || t.phase === "final_answer" ? t.phase : r ? null : this.state.assistantDraftPhase, l = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
1043
- this.setState({
1044
- messages: Dt(this.state.messages, {
1045
- id: o,
1046
- role: "assistant",
1047
- content: i,
1048
- createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1049
- dataType: "assistant_draft",
1050
- ...c ? { phase: c } : {},
1051
- ...l ? { respondsToUserMessageId: l } : {},
1052
- ...h ? { runId: h } : {}
1053
- }),
1054
- assistantDraft: i,
1055
- assistantDraftItemId: n ?? this.state.assistantDraftItemId,
1056
- assistantDraftPhase: c,
1057
- assistantDraftRespondsToUserMessageId: l,
1058
- assistantDraftRunId: h,
1059
- isThinking: !0
1060
- }), this.markThinkingProgress(), this.emit("delta", s);
1061
- return;
1062
- }
1063
- if (t.type === "chat.assistant_done") {
1064
- if (typeof t.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(t.runId))
980
+ if (t.type === "sessions.page") {
981
+ const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
982
+ s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
983
+ sessions: Un(t.sessions),
984
+ nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
985
+ }));
1065
986
  return;
1066
- this.retryableClientMessageId = null;
1067
- const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null, r = typeof t.runId == "string" ? t.runId : null;
1068
- if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
987
+ }
988
+ if (t.type === "session.pin.updated") {
989
+ this.resolvePendingSessionMutation(this.pendingSessionPinRequests, t);
1069
990
  return;
1070
- const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = os(
1071
- this.state.messages.filter(
1072
- (l) => l.dataType !== "assistant_draft" || !qn(
1073
- l,
1074
- n,
1075
- r
1076
- )
1077
- ),
1078
- n,
1079
- r,
1080
- Oe
1081
- );
1082
- this.setState({
1083
- sessionId: s,
1084
- messages: Bn(
1085
- c,
1086
- typeof t.responseId == "string" ? t.responseId : null,
1087
- n,
1088
- r
1089
- ),
1090
- assistantDraft: "",
1091
- assistantDraftItemId: null,
1092
- assistantDraftPhase: null,
1093
- assistantDraftRespondsToUserMessageId: null,
1094
- assistantDraftRunId: null,
1095
- isThinking: a ? !1 : this.state.isThinking
1096
- }), a && this.clearThinkingWatchdog();
1097
- return;
1098
- }
1099
- if (t.type === "tool.call") {
1100
- this.clearRunAckResyncRetryTimer();
1101
- const s = t.hiddenFromTranscript === !0 && typeof t.callId == "string" ? t.callId : null;
1102
- if (s)
1103
- this.nonTranscriptToolCallIds.add(s);
1104
- else {
1105
- const n = Wn(t);
991
+ }
992
+ if (t.type === "session.rename.updated") {
993
+ this.resolvePendingSessionMutation(this.pendingSessionRenameRequests, t);
994
+ return;
995
+ }
996
+ if (t.type === "session.updated") {
997
+ this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: E(t.session, "id") ?? this.state.sessionId });
998
+ return;
999
+ }
1000
+ if (t.type === "session.item") {
1001
+ this.rememberUserMessageClientMessageIds([t.item]);
1002
+ const s = q(t.item);
1003
+ if (xt(s)) {
1004
+ typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1005
+ const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? v(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1006
+ if (r && a) {
1007
+ this.retryAfterInterruptedRun(r, a);
1008
+ return;
1009
+ }
1010
+ if (r && i) {
1011
+ this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.resyncThinkingSession();
1012
+ return;
1013
+ }
1014
+ }
1015
+ if (ye(s))
1016
+ return;
1017
+ const n = Ne(t.item, this.options.backendUrl);
1106
1018
  if (n) {
1107
- const r = Fn(
1108
- this.state.messages,
1109
- n
1110
- );
1019
+ const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1020
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1021
+ const i = t.item.data;
1022
+ sr(i) && this.clearRunAckResyncRetryTimer();
1023
+ const o = Ot(this.state.messages, n), a = me(o), c = Te(
1024
+ i,
1025
+ this.state.assistantDraft,
1026
+ this.state.assistantDraftItemId,
1027
+ this.state.assistantDraftRespondsToUserMessageId,
1028
+ this.state.assistantDraftRunId
1029
+ ), l = a && (!this.state.assistantDraft || c), h = l && N(n);
1111
1030
  this.setState({
1112
- messages: r,
1113
- isThinking: !0
1114
- }), this.emit(
1115
- "message",
1116
- r.find(
1117
- (i) => i.callId === n.callId
1118
- ) ?? n
1119
- );
1031
+ messages: o,
1032
+ ...c ? {
1033
+ assistantDraft: "",
1034
+ assistantDraftItemId: null,
1035
+ assistantDraftPhase: null,
1036
+ assistantDraftRespondsToUserMessageId: null,
1037
+ assistantDraftRunId: null
1038
+ } : {},
1039
+ ...l ? {
1040
+ isThinking: !1
1041
+ } : {},
1042
+ ...h ? {
1043
+ status: "connected",
1044
+ lastError: null,
1045
+ lastErrorCode: null,
1046
+ lastErrorSecuritySettingsUrl: null
1047
+ } : {}
1048
+ }), l && this.clearThinkingWatchdog(), this.emit("message", n);
1120
1049
  }
1121
- }
1122
- this.executeToolCall(t);
1123
- return;
1124
- }
1125
- if (t.type === "tool.status") {
1126
- const s = typeof t.callId == "string" ? t.callId : null;
1127
- if (!s)
1128
1050
  return;
1129
- const n = t.status === "queued" || t.status === "running";
1130
- if (this.nonTranscriptToolCallIds.has(s) || n && this.terminalToolCallIds.has(s))
1051
+ }
1052
+ if (t.type === "chat.assistant_delta") {
1053
+ this.clearRunAckResyncRetryTimer();
1054
+ const s = typeof t.delta == "string" ? t.delta : "", n = typeof t.itemId == "string" ? t.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((f) => f.id === o), c = t.phase === "commentary" || t.phase === "final_answer" ? t.phase : r ? null : this.state.assistantDraftPhase, l = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId;
1055
+ this.setState({
1056
+ messages: Ot(this.state.messages, {
1057
+ id: o,
1058
+ role: "assistant",
1059
+ content: i,
1060
+ createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1061
+ dataType: "assistant_draft",
1062
+ ...c ? { phase: c } : {},
1063
+ ...l ? { respondsToUserMessageId: l } : {},
1064
+ ...h ? { runId: h } : {}
1065
+ }),
1066
+ assistantDraft: i,
1067
+ assistantDraftItemId: n ?? this.state.assistantDraftItemId,
1068
+ assistantDraftPhase: c,
1069
+ assistantDraftRespondsToUserMessageId: l,
1070
+ assistantDraftRunId: h,
1071
+ isThinking: !0
1072
+ }), this.markThinkingProgress(), this.emit("delta", s);
1131
1073
  return;
1132
- n || this.terminalToolCallIds.add(s), this.state.messages.some(
1133
- (i) => i.callId === s
1134
- ) ? this.setToolMessageLoading(s, n) : this.pendingToolLoadingByCallId.set(s, n);
1135
- return;
1136
- }
1137
- if (t.type === "error") {
1138
- const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
1139
- if (s && n) {
1140
- window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof t.message == "string" ? t.message : "Pluno error"));
1074
+ }
1075
+ if (t.type === "chat.assistant_done") {
1076
+ if (typeof t.runId == "string" && this.retryableFailureRunIdsAwaitingDone.delete(t.runId))
1077
+ return;
1078
+ this.retryableClientMessageId = null;
1079
+ const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null, r = typeof t.runId == "string" ? t.runId : null;
1080
+ if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
1081
+ return;
1082
+ const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = as(
1083
+ this.state.messages.filter(
1084
+ (l) => l.dataType !== "assistant_draft" || !Fn(
1085
+ l,
1086
+ n,
1087
+ r
1088
+ )
1089
+ ),
1090
+ n,
1091
+ r,
1092
+ ve
1093
+ );
1094
+ this.setState({
1095
+ sessionId: s,
1096
+ messages: Hn(
1097
+ c,
1098
+ typeof t.responseId == "string" ? t.responseId : null,
1099
+ n,
1100
+ r
1101
+ ),
1102
+ assistantDraft: "",
1103
+ assistantDraftItemId: null,
1104
+ assistantDraftPhase: null,
1105
+ assistantDraftRespondsToUserMessageId: null,
1106
+ assistantDraftRunId: null,
1107
+ isThinking: a ? !1 : this.state.isThinking
1108
+ }), a && this.clearThinkingWatchdog();
1141
1109
  return;
1142
1110
  }
1143
- if (this.rejectPendingSessionMutation(this.pendingSessionPinRequests, t) || this.rejectPendingSessionMutation(this.pendingSessionRenameRequests, t))
1111
+ if (t.type === "tool.call") {
1112
+ this.clearRunAckResyncRetryTimer();
1113
+ const s = t.hiddenFromTranscript === !0 && typeof t.callId == "string" ? t.callId : null;
1114
+ if (s)
1115
+ this.nonTranscriptToolCallIds.add(s);
1116
+ else {
1117
+ const n = jn(t);
1118
+ if (n) {
1119
+ const r = Wn(
1120
+ this.state.messages,
1121
+ n
1122
+ );
1123
+ this.setState({
1124
+ messages: r,
1125
+ isThinking: !0
1126
+ }), this.emit(
1127
+ "message",
1128
+ r.find(
1129
+ (i) => i.callId === n.callId
1130
+ ) ?? n
1131
+ );
1132
+ }
1133
+ }
1134
+ this.executeToolCall(t);
1144
1135
  return;
1145
- const r = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, i = typeof t.clientMessageId == "string" ? t.clientMessageId : null, o = t.retryable === !0 || t.code === "transient_model_error";
1146
- if (this.retryAfterRetryableError(t)) {
1147
- t.code !== "run_still_active" && typeof t.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(t.runId);
1136
+ }
1137
+ if (t.type === "tool.status") {
1138
+ const s = typeof t.callId == "string" ? t.callId : null;
1139
+ if (!s)
1140
+ return;
1141
+ const n = t.status === "queued" || t.status === "running";
1142
+ if (this.nonTranscriptToolCallIds.has(s) || n && this.terminalToolCallIds.has(s))
1143
+ return;
1144
+ n || this.terminalToolCallIds.add(s), this.state.messages.some(
1145
+ (i) => i.callId === s
1146
+ ) ? this.setToolMessageLoading(s, n) : this.pendingToolLoadingByCallId.set(s, n);
1148
1147
  return;
1149
1148
  }
1150
- o && r && i && (this.retryableClientMessageId = i);
1151
- const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = ln(a.message);
1152
- c && console.error(c), this.setState({
1153
- status: "error",
1154
- isThinking: !1,
1155
- lastError: a.message,
1156
- lastErrorCode: typeof t.code == "string" ? t.code : null,
1157
- lastErrorSecuritySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : null
1158
- }), this.clearThinkingWatchdog(), this.emit("error", a);
1149
+ if (t.type === "error") {
1150
+ const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
1151
+ if (s && n) {
1152
+ window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof t.message == "string" ? t.message : "Pluno error"));
1153
+ return;
1154
+ }
1155
+ if (this.rejectPendingSessionMutation(this.pendingSessionPinRequests, t) || this.rejectPendingSessionMutation(this.pendingSessionRenameRequests, t))
1156
+ return;
1157
+ const r = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, i = typeof t.clientMessageId == "string" ? t.clientMessageId : null, o = t.retryable === !0 || t.code === "transient_model_error";
1158
+ if (this.retryAfterRetryableError(t)) {
1159
+ t.code !== "run_still_active" && typeof t.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(t.runId);
1160
+ return;
1161
+ }
1162
+ o && r && i && (this.retryableClientMessageId = i);
1163
+ const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = dn(a.message);
1164
+ c && console.error(c), this.setState({
1165
+ status: "error",
1166
+ isThinking: !1,
1167
+ lastError: a.message,
1168
+ lastErrorCode: typeof t.code == "string" ? t.code : null,
1169
+ lastErrorSecuritySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : null
1170
+ }), this.clearThinkingWatchdog(), this.emit("error", a);
1171
+ }
1159
1172
  }
1160
1173
  }
1174
+ shouldIgnoreBackgroundSessionEvent(t) {
1175
+ if (!this.options.keepRunsActiveOnSessionNavigation || !zs(t))
1176
+ return !1;
1177
+ const s = Mt(t);
1178
+ return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
1179
+ }
1180
+ rememberCurrentRunAsBackground() {
1181
+ this.options.keepRunsActiveOnSessionNavigation && (this.state.sessionId ? this.backgroundSessionIds.add(this.state.sessionId) : this.state.isThinking && this.activeClientMessageId && this.backgroundClientMessageIds.add(this.activeClientMessageId));
1182
+ }
1161
1183
  retryAfterRetryableError(t) {
1162
1184
  const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
1163
1185
  if (!(t.retryable === !0 || t.code === "transient_model_error") || !s || !n || t.code === "run_recovery_exhausted")
@@ -1213,7 +1235,7 @@ class _e {
1213
1235
  }
1214
1236
  rememberUserMessageClientMessageIds(t) {
1215
1237
  for (const s of t) {
1216
- const n = R(s, "id"), r = q(s);
1238
+ const n = E(s, "id"), r = q(s);
1217
1239
  n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
1218
1240
  }
1219
1241
  }
@@ -1226,7 +1248,7 @@ class _e {
1226
1248
  const r = new Promise((i, o) => {
1227
1249
  const a = window.setTimeout(() => {
1228
1250
  t.delete(s.requestId), o(new Error(n));
1229
- }, ce);
1251
+ }, le);
1230
1252
  t.set(s.requestId, { resolve: i, reject: o, timeout: a });
1231
1253
  });
1232
1254
  if (!this.sendNow(s)) {
@@ -1249,7 +1271,7 @@ class _e {
1249
1271
  t.clear();
1250
1272
  }
1251
1273
  markThinkingProgress() {
1252
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ae), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1274
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ce), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1253
1275
  }
1254
1276
  scheduleThinkingWatchdog(t) {
1255
1277
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1269,7 +1291,7 @@ class _e {
1269
1291
  handleRunSteered(t) {
1270
1292
  const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
1271
1293
  !this.state.isThinking || !s || this.setState({
1272
- messages: sr(
1294
+ messages: rr(
1273
1295
  this.state.messages,
1274
1296
  s
1275
1297
  )
@@ -1278,7 +1300,7 @@ class _e {
1278
1300
  scheduleRunAckWatchdog(t) {
1279
1301
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1280
1302
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1281
- }, Ps);
1303
+ }, Us);
1282
1304
  }
1283
1305
  recoverMissedRunAck(t) {
1284
1306
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
@@ -1302,8 +1324,8 @@ class _e {
1302
1324
  sessionId: this.state.sessionId,
1303
1325
  clientMessageId: t,
1304
1326
  automatic: !0
1305
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ae)));
1306
- }, Y(s, Us)));
1327
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ce)));
1328
+ }, Y(s, Ds)));
1307
1329
  }
1308
1330
  clearRunAckResyncRetryTimer() {
1309
1331
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1342,7 +1364,7 @@ class _e {
1342
1364
  sessionId: this.state.sessionId,
1343
1365
  clientMessageId: t,
1344
1366
  resyncAttempts: s + 1
1345
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Cs);
1367
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ps);
1346
1368
  return;
1347
1369
  }
1348
1370
  this.setState({
@@ -1366,7 +1388,7 @@ class _e {
1366
1388
  this.state.sessionId ? this.send({
1367
1389
  type: "page.upsert",
1368
1390
  sessionId: this.state.sessionId,
1369
- page: M(),
1391
+ page: k(),
1370
1392
  model: this.options.model
1371
1393
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
1372
1394
  }
@@ -1377,15 +1399,15 @@ class _e {
1377
1399
  if (!s || !n || !r)
1378
1400
  return;
1379
1401
  const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1380
- if (!a && !c || !Sr(o)) {
1402
+ if (!a && !c || !br(o)) {
1381
1403
  this.setToolMessageLoading(n, !1), this.send({
1382
1404
  type: "tool.result",
1383
1405
  sessionId: s,
1384
1406
  callId: n,
1385
1407
  toolName: r,
1386
1408
  summary: i,
1387
- rawInput: k(o),
1388
- rawOutput: k({
1409
+ rawInput: M(o),
1410
+ rawOutput: M({
1389
1411
  ok: !1,
1390
1412
  toolName: r,
1391
1413
  error: `Unsupported browser tool: ${r}`
@@ -1400,7 +1422,7 @@ class _e {
1400
1422
  callId: n,
1401
1423
  toolName: r,
1402
1424
  summary: i,
1403
- rawInput: k(o),
1425
+ rawInput: M(o),
1404
1426
  rawOutput: {
1405
1427
  ok: !1,
1406
1428
  toolName: r,
@@ -1409,7 +1431,7 @@ class _e {
1409
1431
  });
1410
1432
  return;
1411
1433
  }
1412
- const l = Ks(this.state.messages);
1434
+ const l = Xs(this.state.messages);
1413
1435
  this.activeBrowserToolCalls.set(n, {
1414
1436
  event: {
1415
1437
  type: "tool.result",
@@ -1417,7 +1439,7 @@ class _e {
1417
1439
  callId: n,
1418
1440
  toolName: r,
1419
1441
  summary: i,
1420
- rawInput: k(o),
1442
+ rawInput: M(o),
1421
1443
  rawOutput: null
1422
1444
  },
1423
1445
  startedAtMs: Date.now(),
@@ -1425,9 +1447,9 @@ class _e {
1425
1447
  startedAtOrigin: location.origin
1426
1448
  }), this.installSessionUserFilesApi(l);
1427
1449
  let h = null, f;
1428
- h = await this.executeRuntimeHelper(), f = await de(
1450
+ h = await this.executeRuntimeHelper(), f = await he(
1429
1451
  o,
1430
- nn(t.runtimeContext, this.options.backendUrl)
1452
+ on(t.runtimeContext, this.options.backendUrl)
1431
1453
  ).catch((I) => ({
1432
1454
  ok: !1,
1433
1455
  exception: {
@@ -1439,12 +1461,12 @@ class _e {
1439
1461
  callId: n,
1440
1462
  toolName: r,
1441
1463
  summary: o.summary,
1442
- rawInput: k(o),
1443
- rawOutput: k(Rn(f, h))
1444
- }), hr(this.options.clientId, this.activeBrowserToolCalls.values());
1464
+ rawInput: M(o),
1465
+ rawOutput: M(kn(f, h))
1466
+ }), fr(this.options.clientId, this.activeBrowserToolCalls.values());
1445
1467
  }
1446
1468
  setToolMessageLoading(t, s) {
1447
- const n = Hn(
1469
+ const n = $n(
1448
1470
  this.state.messages,
1449
1471
  t,
1450
1472
  s
@@ -1455,47 +1477,47 @@ class _e {
1455
1477
  if (this.pageLifecycleCleanup)
1456
1478
  return;
1457
1479
  const t = () => {
1458
- qe(this.options.clientId, this.activeBrowserToolCalls.values());
1480
+ Be(this.options.clientId, this.activeBrowserToolCalls.values());
1459
1481
  };
1460
1482
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1461
1483
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1462
1484
  };
1463
1485
  }
1464
1486
  installSessionUserFilesApi(t) {
1465
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Gs(t, this.attachmentFiles, this.attachmentBlobCache);
1487
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Js(t, this.attachmentFiles, this.attachmentBlobCache);
1466
1488
  }
1467
1489
  cleanupSessionUserFilesApi() {
1468
- this.sessionUserFilesApiCleanup && (en(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1490
+ this.sessionUserFilesApiCleanup && (nn(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1469
1491
  }
1470
1492
  async executeRuntimeHelper() {
1471
1493
  if (!this.runtimeHelperJavascript?.trim())
1472
1494
  return null;
1473
- const t = await de({
1495
+ const t = await he({
1474
1496
  javascript: this.runtimeHelperJavascript
1475
1497
  });
1476
- return t.ok === !1 ? bn(t) : null;
1498
+ return t.ok === !1 ? Mn(t) : null;
1477
1499
  }
1478
1500
  enableNetworkCapture() {
1479
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Hs((t) => {
1480
- kr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1501
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = Ws((t) => {
1502
+ Cr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1481
1503
  }));
1482
1504
  }
1483
1505
  enqueueNetworkEvent(t) {
1484
- this.queuedNetworkEvents.length >= vs || (this.queuedNetworkEvents.push(Mr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1506
+ this.queuedNetworkEvents.length >= Ns || (this.queuedNetworkEvents.push(_r(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1485
1507
  this.networkBatchTimer = null;
1486
1508
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1487
1509
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
1488
1510
  type: "network.batch",
1489
1511
  sessionId: this.state.sessionId ?? void 0,
1490
- page: M(),
1512
+ page: k(),
1491
1513
  events: s
1492
1514
  });
1493
- }, Ds)));
1515
+ }, Os)));
1494
1516
  }
1495
1517
  scheduleReconnect() {
1496
1518
  if (this.reconnectTimer !== null || this.state.status === "closed")
1497
1519
  return;
1498
- const t = Bs(this.reconnectAttempts);
1520
+ const t = Fs(this.reconnectAttempts);
1499
1521
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1500
1522
  this.reconnectTimer = null, this.connect().catch((s) => {
1501
1523
  S("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1538,7 +1560,7 @@ class _e {
1538
1560
  ...t,
1539
1561
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1540
1562
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1541
- }, ur(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
1563
+ }, hr(this.options.clientId, this.state), this.emit("state", this.getState()), Et("state", this.state.status, {
1542
1564
  status: this.state.status,
1543
1565
  sessionId: this.state.sessionId,
1544
1566
  messageCount: this.state.messages.length,
@@ -1555,14 +1577,14 @@ class _e {
1555
1577
  this.listeners[t]?.forEach((r) => r(s));
1556
1578
  }
1557
1579
  }
1558
- const Mt = /* @__PURE__ */ new WeakMap();
1559
- function Hs(e) {
1560
- const t = window.__plunoProductAgentNetworkCapture ?? Ws();
1580
+ const kt = /* @__PURE__ */ new WeakMap();
1581
+ function Ws(e) {
1582
+ const t = window.__plunoProductAgentNetworkCapture ?? $s();
1561
1583
  return t.subscribers.add(e), () => {
1562
1584
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1563
1585
  };
1564
1586
  }
1565
- function Ws() {
1587
+ function $s() {
1566
1588
  const e = /* @__PURE__ */ new Set(), t = (I) => {
1567
1589
  e.forEach((g) => {
1568
1590
  try {
@@ -1579,20 +1601,20 @@ function Ws() {
1579
1601
  throw m;
1580
1602
  }
1581
1603
  try {
1582
- const m = g instanceof Request ? g : null, E = Ar(g, m), T = He(u?.headers ?? m?.headers);
1583
- if (!x(E, T, u?.body)) {
1604
+ const m = g instanceof Request ? g : null, b = Er(g, m), T = We(u?.headers ?? m?.headers);
1605
+ if (!x(b, T, u?.body)) {
1584
1606
  const F = {
1585
- requestId: _t("fetch"),
1586
- url: P(E, bt),
1607
+ requestId: Ct("fetch"),
1608
+ url: P(b, Rt),
1587
1609
  method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
1588
1610
  requestHeaders: T,
1589
- requestBody: Ae(u?.body),
1611
+ requestBody: be(u?.body),
1590
1612
  resourceType: "fetch",
1591
1613
  startedAt: new Date(d).toISOString()
1592
1614
  };
1593
1615
  p.then(
1594
1616
  (_) => {
1595
- Er(_, F, d, t).catch(() => {
1617
+ Rr(_, F, d, t).catch(() => {
1596
1618
  t({
1597
1619
  ...F,
1598
1620
  responseStatus: _.status,
@@ -1613,28 +1635,28 @@ function Ws() {
1613
1635
  }
1614
1636
  return p;
1615
1637
  }, a = function(g, u, d, p, m) {
1616
- const E = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
1617
- return Mt.set(this, {
1618
- requestId: _t("xhr"),
1638
+ const b = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
1639
+ return kt.set(this, {
1640
+ requestId: Ct("xhr"),
1619
1641
  method: String(g ?? "GET").toUpperCase(),
1620
- url: P(T, bt),
1642
+ url: P(T, Rt),
1621
1643
  requestHeaders: {},
1622
1644
  startedAtMs: Date.now(),
1623
1645
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1624
1646
  excluded: x(T)
1625
- }), E;
1647
+ }), b;
1626
1648
  }, c = function(g, u) {
1627
- const d = r.call(this, g, u), p = Mt.get(this);
1628
- return p && Object.keys(p.requestHeaders).length < Wt && (p.requestHeaders[g] = Gt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1649
+ const d = r.call(this, g, u), p = kt.get(this);
1650
+ return p && Object.keys(p.requestHeaders).length < $t && (p.requestHeaders[g] = Xt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1629
1651
  }, l = function(g) {
1630
1652
  try {
1631
- const u = Mt.get(this);
1632
- u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody = Ae(g), u.excluded || this.addEventListener(
1653
+ const u = kt.get(this);
1654
+ u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody = be(g), u.excluded || this.addEventListener(
1633
1655
  "loadend",
1634
1656
  () => {
1635
1657
  queueMicrotask(() => {
1636
1658
  try {
1637
- const d = Cr(this.getAllResponseHeaders());
1659
+ const d = Ur(this.getAllResponseHeaders());
1638
1660
  t({
1639
1661
  requestId: u.requestId,
1640
1662
  url: u.url,
@@ -1644,7 +1666,7 @@ function Ws() {
1644
1666
  resourceType: "xhr",
1645
1667
  responseStatus: this.status,
1646
1668
  responseHeaders: d,
1647
- responseBody: br(this, d),
1669
+ responseBody: Mr(this, d),
1648
1670
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1649
1671
  startedAt: u.startedAt,
1650
1672
  durationMs: Date.now() - u.startedAtMs
@@ -1685,8 +1707,8 @@ function Ws() {
1685
1707
  continue;
1686
1708
  const d = performance.timeOrigin + u.startTime;
1687
1709
  t({
1688
- requestId: _t("resource"),
1689
- url: P(u.name, bt),
1710
+ requestId: Ct("resource"),
1711
+ url: P(u.name, Rt),
1690
1712
  method: "GET",
1691
1713
  resourceType: "resource",
1692
1714
  responseStatus: u.responseStatus,
@@ -1736,15 +1758,33 @@ function S(e, t, s) {
1736
1758
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1737
1759
  i.push(r), i.length > 120 && i.splice(0, i.length - 120), n.__plunoProductAgentDiagnostics__ = i, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: r }));
1738
1760
  }
1739
- function ue(e) {
1761
+ function de(e) {
1740
1762
  const t = typeof e == "function" ? e() : e;
1741
1763
  return t && Object.keys(t).length > 0 ? t : void 0;
1742
1764
  }
1743
- function $s(e) {
1765
+ function js(e) {
1744
1766
  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";
1745
1767
  }
1746
- const js = 5e3, zs = 12e4;
1747
- function Ks(e) {
1768
+ function zs(e) {
1769
+ return e.type === "run.steered" || e.type === "run.ack" || e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call" || e.type === "tool.status" || e.type === "error" && typeof e.requestId != "string";
1770
+ }
1771
+ function Mt(e) {
1772
+ if (typeof e.sessionId == "string")
1773
+ return e.sessionId;
1774
+ if (e.session && typeof e.session == "object") {
1775
+ const t = e.session.id;
1776
+ if (typeof t == "string")
1777
+ return t;
1778
+ }
1779
+ if (e.item && typeof e.item == "object") {
1780
+ const t = e.item.sessionId;
1781
+ if (typeof t == "string")
1782
+ return t;
1783
+ }
1784
+ return null;
1785
+ }
1786
+ const Ks = 5e3, Gs = 12e4;
1787
+ function Xs(e) {
1748
1788
  const t = [];
1749
1789
  for (const s of e)
1750
1790
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1755,26 +1795,26 @@ function Ks(e) {
1755
1795
  });
1756
1796
  return t;
1757
1797
  }
1758
- function Gs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1798
+ function Js(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1759
1799
  const n = [
1760
- Js(),
1761
- Xs()
1800
+ Ys(),
1801
+ Vs()
1762
1802
  ].filter((r) => typeof r == "function");
1763
1803
  return () => {
1764
1804
  for (const r of n.reverse())
1765
1805
  r();
1766
1806
  };
1767
1807
  }
1768
- function Xs() {
1769
- return Re(globalThis, "getPageSnapshot", async () => $t());
1808
+ function Vs() {
1809
+ return Re(globalThis, "getPageSnapshot", async () => jt());
1770
1810
  }
1771
- function Js() {
1811
+ function Ys() {
1772
1812
  return Re(globalThis, "pageImages", {
1773
- inspectImage: async (t, s) => await Vs(t, s)
1813
+ inspectImage: async (t, s) => await Zs(t, s)
1774
1814
  });
1775
1815
  }
1776
- async function Vs(e, t = {}) {
1777
- const s = tn(t.name), n = await Ys(e);
1816
+ async function Zs(e, t = {}) {
1817
+ const s = sn(t.name), n = await Qs(e);
1778
1818
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1779
1819
  type: "pluno.pageImages.inspectImage",
1780
1820
  imageAttached: !1,
@@ -1792,15 +1832,15 @@ async function Vs(e, t = {}) {
1792
1832
  imageAttachmentError: n.error
1793
1833
  };
1794
1834
  }
1795
- async function Ys(e) {
1835
+ async function Qs(e) {
1796
1836
  return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: Me } : {
1797
1837
  ok: !0,
1798
1838
  mimeType: e.type,
1799
1839
  sizeBytes: e.size,
1800
- dataUrl: await sn(e)
1801
- } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Zs(e);
1840
+ dataUrl: await rn(e)
1841
+ } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : tn(e);
1802
1842
  }
1803
- function Zs(e) {
1843
+ function tn(e) {
1804
1844
  if (!e.startsWith("data:") || !e.includes(","))
1805
1845
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1806
1846
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1811,7 +1851,7 @@ function Zs(e) {
1811
1851
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1812
1852
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1813
1853
  return { ok: !1, error: "Page image data URL has invalid base64." };
1814
- const o = Qs(i);
1854
+ const o = en(i);
1815
1855
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1816
1856
  ok: !0,
1817
1857
  mimeType: r,
@@ -1819,22 +1859,22 @@ function Zs(e) {
1819
1859
  dataUrl: `data:${r};base64,${i}`
1820
1860
  };
1821
1861
  }
1822
- function Qs(e) {
1862
+ function en(e) {
1823
1863
  if (e.length === 0 || e.length % 4 !== 0)
1824
1864
  return null;
1825
1865
  const t = e.length - e.replace(/=+$/, "").length;
1826
1866
  return t > 2 ? null : e.length / 4 * 3 - t;
1827
1867
  }
1828
- function tn(e) {
1868
+ function sn(e) {
1829
1869
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1830
1870
  }
1831
- function en(e) {
1871
+ function nn(e) {
1832
1872
  try {
1833
1873
  e();
1834
1874
  } catch {
1835
1875
  }
1836
1876
  }
1837
- function sn(e) {
1877
+ function rn(e) {
1838
1878
  return new Promise((t, s) => {
1839
1879
  const n = new FileReader();
1840
1880
  n.onload = () => {
@@ -1846,9 +1886,9 @@ function sn(e) {
1846
1886
  }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1847
1887
  });
1848
1888
  }
1849
- async function de(e, t) {
1889
+ async function he(e, t) {
1850
1890
  const s = Object.getPrototypeOf(async function() {
1851
- }).constructor, n = e.timeoutMs ?? js, r = Date.now(), i = [];
1891
+ }).constructor, n = e.timeoutMs ?? Ks, r = Date.now(), i = [];
1852
1892
  let o;
1853
1893
  const a = {
1854
1894
  log: console.log,
@@ -1866,7 +1906,7 @@ async function de(e, t) {
1866
1906
  o = window.setTimeout(() => f(l), n);
1867
1907
  })
1868
1908
  ]);
1869
- return h === l ? rn(n) : {
1909
+ return h === l ? an(n) : {
1870
1910
  ok: !0,
1871
1911
  result: h,
1872
1912
  console: i,
@@ -1895,7 +1935,7 @@ async function de(e, t) {
1895
1935
  t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
1896
1936
  }
1897
1937
  }
1898
- function nn(e, t) {
1938
+ function on(e, t) {
1899
1939
  if (!e || typeof e != "object")
1900
1940
  return;
1901
1941
  const s = e.sandboxFilesToken;
@@ -1905,7 +1945,7 @@ function nn(e, t) {
1905
1945
  const r = () => {
1906
1946
  if (!n)
1907
1947
  throw new Error("sandboxFiles is only available during browser-code execution");
1908
- }, i = async (a, c) => await ms(`${t.replace(/\/$/, "")}${a}`, c);
1948
+ }, i = async (a, c) => await ys(`${t.replace(/\/$/, "")}${a}`, c);
1909
1949
  return {
1910
1950
  value: Object.freeze({
1911
1951
  upload: async (a) => {
@@ -1939,7 +1979,7 @@ function nn(e, t) {
1939
1979
  }
1940
1980
  };
1941
1981
  }
1942
- function rn(e) {
1982
+ function an(e) {
1943
1983
  return {
1944
1984
  ok: !1,
1945
1985
  exception: {
@@ -1953,10 +1993,10 @@ function rn(e) {
1953
1993
  }
1954
1994
  };
1955
1995
  }
1956
- function on(e) {
1996
+ function cn(e) {
1957
1997
  return e.replace(/\/+$/, "");
1958
1998
  }
1959
- function an(e) {
1999
+ function ln(e) {
1960
2000
  const t = {
1961
2001
  sidepanel: "extension_sidepanel",
1962
2002
  browser_extension_page_ui: "extension_widget",
@@ -1968,18 +2008,18 @@ function an(e) {
1968
2008
  };
1969
2009
  return e && e in t ? t[e] : e ?? "embedded_custom_ui";
1970
2010
  }
1971
- function cn(e) {
2011
+ function un(e) {
1972
2012
  return e === "pluno" ? "scheduled_continuation" : e ?? "user";
1973
2013
  }
1974
- function ln(e, t = location.origin) {
2014
+ function dn(e, t = location.origin) {
1975
2015
  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;
1976
2016
  }
1977
- function un(e) {
2017
+ function hn(e) {
1978
2018
  const t = new URL("/api/product-agent/embed/ws", e);
1979
2019
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1980
2020
  }
1981
- function M() {
1982
- const e = De();
2021
+ function k() {
2022
+ const e = Oe();
1983
2023
  return {
1984
2024
  url: location.href,
1985
2025
  title: document.title,
@@ -1987,19 +2027,19 @@ function M() {
1987
2027
  ...e ? { plunoProductAgentUi: e } : {}
1988
2028
  };
1989
2029
  }
1990
- function dn() {
2030
+ function pn() {
1991
2031
  return {
1992
2032
  pageUrl: location.href,
1993
2033
  pageTitle: document.title,
1994
- htmlContent: $t()
2034
+ htmlContent: jt()
1995
2035
  };
1996
2036
  }
1997
- function hn(e) {
1998
- return st.add(e), Z || (Z = pn()), () => {
2037
+ function fn(e) {
2038
+ return st.add(e), Z || (Z = gn()), () => {
1999
2039
  st.delete(e), st.size === 0 && (Z?.(), Z = null);
2000
2040
  };
2001
2041
  }
2002
- function pn() {
2042
+ function gn() {
2003
2043
  const e = () => {
2004
2044
  for (const i of Array.from(st))
2005
2045
  i();
@@ -2014,10 +2054,10 @@ function pn() {
2014
2054
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
2015
2055
  };
2016
2056
  }
2017
- function fn() {
2018
- return De()?.surface === "browser_extension_sdk_preview";
2057
+ function mn() {
2058
+ return Oe()?.surface === "browser_extension_sdk_preview";
2019
2059
  }
2020
- function $t() {
2060
+ function jt() {
2021
2061
  if (!document.body)
2022
2062
  return "";
2023
2063
  const e = [], t = [], s = (d, p) => {
@@ -2026,16 +2066,16 @@ function $t() {
2026
2066
  };
2027
2067
  s("Selected text", window.getSelection()?.toString() ?? "");
2028
2068
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
2029
- (d) => Ce(d) && !d.parentElement?.closest(n)
2069
+ (d) => Pe(d) && !d.parentElement?.closest(n)
2030
2070
  );
2031
2071
  for (const d of r.slice(0, 3))
2032
- s("Active overlay", kt(z(d), t));
2033
- const i = gn(), o = i ? kt(z(i), t) : "";
2034
- s("Main page content", o), s("Additional visible page text", kt(z(document.body), t));
2072
+ s("Active overlay", _t(z(d), t));
2073
+ const i = yn(), o = i ? _t(z(i), t) : "";
2074
+ s("Main page content", o), s("Additional visible page text", _t(z(document.body), t));
2035
2075
  const a = e.map(([d, p]) => `${d}:
2036
2076
  ${p}`).join(`
2037
2077
 
2038
- `).trim().slice(0, 12e3), c = mn(r, i).trim(), l = `Simplified DOM outline:
2078
+ `).trim().slice(0, 12e3), c = In(r, i).trim(), l = `Simplified DOM outline:
2039
2079
  `, h = `
2040
2080
 
2041
2081
  Visible page text:
@@ -2053,20 +2093,20 @@ function B(e) {
2053
2093
 
2054
2094
  `).trim();
2055
2095
  }
2056
- function kt(e, t) {
2096
+ function _t(e, t) {
2057
2097
  let s = B(e);
2058
2098
  for (const n of t)
2059
2099
  s = s.replace(n, "");
2060
2100
  return B(s);
2061
2101
  }
2062
- function Ce(e) {
2102
+ function Pe(e) {
2063
2103
  const t = window.getComputedStyle(e);
2064
2104
  return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
2065
2105
  }
2066
- function gn() {
2067
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ce).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
2106
+ function yn() {
2107
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Pe).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
2068
2108
  }
2069
- function mn(e, t) {
2109
+ function In(e, t) {
2070
2110
  const s = /* @__PURE__ */ new Set([
2071
2111
  "main",
2072
2112
  "nav",
@@ -2146,7 +2186,7 @@ function mn(e, t) {
2146
2186
  "data-test",
2147
2187
  "data-qa",
2148
2188
  "data-cy"
2149
- ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = yn(), I = new Set(e);
2189
+ ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = Tn(), I = new Set(e);
2150
2190
  t && I.add(t);
2151
2191
  let g = 0;
2152
2192
  const u = (T) => {
@@ -2157,40 +2197,40 @@ function mn(e, t) {
2157
2197
  return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
2158
2198
  }, p = (T, D, F) => {
2159
2199
  const _ = (A, dt) => {
2160
- const b = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
2161
- if (g >= 1e3 && !K || F.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
2200
+ const R = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
2201
+ if (g >= 1e3 && !K || F.has(A) || i.has(R) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
2162
2202
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2163
2203
  g += 1;
2164
- const Xt = u(A), G = Ue(A), Je = a.has(Xt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
2204
+ const Jt = u(A), G = De(A), Ve = a.has(Jt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(R) || R === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
2165
2205
  for (const y of pt) {
2166
2206
  const w = d(y);
2167
2207
  X.set(w, (X.get(w) ?? 0) + 1);
2168
2208
  }
2169
- const ft = /* @__PURE__ */ new Map(), Jt = /* @__PURE__ */ new Map();
2209
+ const ft = /* @__PURE__ */ new Map(), Vt = /* @__PURE__ */ new Map();
2170
2210
  for (const y of pt) {
2171
- const w = d(y), v = Jt.get(w) ?? 0;
2172
- Jt.set(w, v + 1), (X.get(w) ?? 0) > 8 && v >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
2211
+ const w = d(y), O = Vt.get(w) ?? 0;
2212
+ Vt.set(w, O + 1), (X.get(w) ?? 0) > 8 && O >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
2173
2213
  }
2174
- const Vt = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Set(), gt = [], Zt = [];
2214
+ const Yt = /* @__PURE__ */ new Map(), Zt = /* @__PURE__ */ new Set(), gt = [], Qt = [];
2175
2215
  for (const y of pt) {
2176
- const w = d(y), v = X.get(w) ?? 0, ee = Vt.get(w) ?? 0;
2177
- if (Vt.set(w, ee + 1), v > 8 && ee >= 6 && !h.has(y)) {
2178
- Yt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Yt.add(w));
2216
+ const w = d(y), O = X.get(w) ?? 0, se = Yt.get(w) ?? 0;
2217
+ if (Yt.set(w, se + 1), O > 8 && se >= 6 && !h.has(y)) {
2218
+ Zt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Zt.add(w));
2179
2219
  continue;
2180
2220
  }
2181
- const se = _(y, dt);
2182
- Zt.push(se), gt.push(se.lines);
2221
+ const ne = _(y, dt);
2222
+ Qt.push(ne), gt.push(ne.lines);
2183
2223
  }
2184
2224
  const mt = [];
2185
2225
  if (A.shadowRoot)
2186
2226
  for (const y of Array.from(A.shadowRoot.children))
2187
2227
  y instanceof HTMLElement && mt.push(_(y, dt + 1));
2188
- const J = [...Zt, ...mt], yt = G.length > 0 || Je || J.some((y) => y.hasUsefulContent), Qt = B(
2228
+ const J = [...Qt, ...mt], yt = G.length > 0 || Ve || J.some((y) => y.hasUsefulContent), te = B(
2189
2229
  [G, ...J.map((y) => y.textPreview)].filter(Boolean).join(" ")
2190
- ).slice(0, 180), Ve = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), te = l.some((y) => A.hasAttribute(y)) || !!Xt || Ve, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(b) || te || K) && (yt || K) && (!r.has(b) || yt || te || K), Tt = It ? 1 : 0, H = [];
2230
+ ).slice(0, 180), Ye = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), ee = l.some((y) => A.hasAttribute(y)) || !!Jt || Ye, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(R) || ee || K) && (yt || K) && (!r.has(R) || yt || ee || K), Tt = It ? 1 : 0, H = [];
2191
2231
  if (It) {
2192
- const y = J.some((v) => v.containsTextElement), w = n.has(b) && !y ? Qt : G;
2193
- H.push(Pe(A, c, o, w.slice(0, 180)));
2232
+ const y = J.some((O) => O.containsTextElement), w = n.has(R) && !y ? te : G;
2233
+ H.push(Ue(A, c, o, w.slice(0, 180)));
2194
2234
  }
2195
2235
  for (const y of gt)
2196
2236
  H.push(...Q(y, Tt));
@@ -2198,25 +2238,25 @@ function mn(e, t) {
2198
2238
  if (wt.length > 0) {
2199
2239
  const y = wt.slice(0, 20);
2200
2240
  wt.length > y.length && y.push("… shadow DOM omitted");
2201
- const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
2241
+ const w = R.includes("tooltip") || R.includes("popper") || R.includes("loader");
2202
2242
  if (dt < 2 && !w) {
2203
- const v = It ? "#shadow-root" : `${b} #shadow-root`;
2204
- H.push(...Q([v, ...Q(y, 1)], Tt));
2243
+ const O = It ? "#shadow-root" : `${R} #shadow-root`;
2244
+ H.push(...Q([O, ...Q(y, 1)], Tt));
2205
2245
  } else
2206
2246
  H.push(...Q(y, Tt));
2207
2247
  }
2208
2248
  return {
2209
2249
  lines: H,
2210
2250
  hasUsefulContent: yt,
2211
- textPreview: Qt,
2212
- containsTextElement: n.has(b) || J.some((y) => y.containsTextElement)
2251
+ textPreview: te,
2252
+ containsTextElement: n.has(R) || J.some((y) => y.containsTextElement)
2213
2253
  };
2214
2254
  };
2215
2255
  return [`--- ${D} ---`, ..._(T, 0).lines].join(`
2216
2256
  `);
2217
- }, m = [], E = B(window.getSelection()?.toString() ?? "");
2218
- E && m.push(`--- selected text ---
2219
- ${JSON.stringify(E)}`), f.length > 0 && m.push(In(f, s, c, o));
2257
+ }, m = [], b = B(window.getSelection()?.toString() ?? "");
2258
+ b && m.push(`--- selected text ---
2259
+ ${JSON.stringify(b)}`), f.length > 0 && m.push(wn(f, s, c, o));
2220
2260
  for (const T of e.slice(0, 3))
2221
2261
  m.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2222
2262
  if (t && m.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
@@ -2227,11 +2267,11 @@ ${JSON.stringify(E)}`), f.length > 0 && m.push(In(f, s, c, o));
2227
2267
 
2228
2268
  `);
2229
2269
  }
2230
- function Pe(e, t, s, n) {
2270
+ function Ue(e, t, s, n) {
2231
2271
  const r = e.tagName.toLowerCase();
2232
2272
  let i = r;
2233
2273
  const o = e.getAttribute("id");
2234
- o && Tn(o) && (i += `#${o}`);
2274
+ o && Sn(o) && (i += `#${o}`);
2235
2275
  for (const a of t) {
2236
2276
  const c = e.getAttribute(a);
2237
2277
  c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
@@ -2244,7 +2284,7 @@ function Pe(e, t, s, n) {
2244
2284
  e.hasAttribute(a) && (i += `[${a}]`);
2245
2285
  return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
2246
2286
  }
2247
- function yn() {
2287
+ function Tn() {
2248
2288
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
2249
2289
  if (!a)
2250
2290
  return;
@@ -2265,7 +2305,7 @@ function yn() {
2265
2305
  n = n.shadowRoot.activeElement;
2266
2306
  n !== document.body && n !== document.documentElement && s(n, "focused");
2267
2307
  const r = window.getSelection();
2268
- r && !r.isCollapsed && (s(he(r.anchorNode), "selected text"), s(he(r.focusNode), "selected text"));
2308
+ r && !r.isCollapsed && (s(pe(r.anchorNode), "selected text"), s(pe(r.focusNode), "selected text"));
2269
2309
  const i = [
2270
2310
  ["[aria-selected='true']", "selected"],
2271
2311
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -2287,7 +2327,7 @@ function yn() {
2287
2327
  priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
2288
2328
  };
2289
2329
  }
2290
- function In(e, t, s, n) {
2330
+ function wn(e, t, s, n) {
2291
2331
  const r = ["--- active/current elements ---"];
2292
2332
  for (const i of e) {
2293
2333
  const o = [];
@@ -2298,18 +2338,18 @@ function In(e, t, s, n) {
2298
2338
  const f = a.getRootNode();
2299
2339
  a = a.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
2300
2340
  }
2301
- const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => Pe(
2341
+ const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => Ue(
2302
2342
  h,
2303
2343
  s,
2304
2344
  n,
2305
- f === c.length - 1 ? Ue(h).slice(0, 180) : ""
2345
+ f === c.length - 1 ? De(h).slice(0, 180) : ""
2306
2346
  ));
2307
2347
  o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
2308
2348
  }
2309
2349
  return r.join(`
2310
2350
  `);
2311
2351
  }
2312
- function he(e) {
2352
+ function pe(e) {
2313
2353
  return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
2314
2354
  }
2315
2355
  function Q(e, t) {
@@ -2318,17 +2358,17 @@ function Q(e, t) {
2318
2358
  const s = " ".repeat(t);
2319
2359
  return e.map((n) => `${s}${n}`);
2320
2360
  }
2321
- function Ue(e) {
2361
+ function De(e) {
2322
2362
  return B(
2323
2363
  Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
2324
2364
  );
2325
2365
  }
2326
- function Tn(e) {
2366
+ function Sn(e) {
2327
2367
  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);
2328
2368
  }
2329
- function De() {
2330
- const e = document.querySelector(ne);
2331
- if (!(e ?? document.querySelector(Pt)))
2369
+ function Oe() {
2370
+ const e = document.querySelector(re);
2371
+ if (!(e ?? document.querySelector(Ut)))
2332
2372
  return;
2333
2373
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
2334
2374
  return {
@@ -2337,28 +2377,28 @@ function De() {
2337
2377
  selectors: [
2338
2378
  {
2339
2379
  name: "widget_host",
2340
- selector: s === "browser_extension_sdk_preview" ? ne : Pt,
2380
+ selector: s === "browser_extension_sdk_preview" ? re : Ut,
2341
2381
  description: "Finds Pluno's shadow-host element in the host page DOM."
2342
2382
  },
2343
2383
  {
2344
2384
  name: "widget_root",
2345
- selector: ys,
2385
+ selector: Is,
2346
2386
  description: "Finds Pluno's widget root inside the widget host shadow root."
2347
2387
  },
2348
2388
  {
2349
2389
  name: "widget_panel",
2350
- selector: Is,
2390
+ selector: Ts,
2351
2391
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
2352
2392
  },
2353
2393
  {
2354
2394
  name: "widget_timeline",
2355
- selector: Ts,
2395
+ selector: ws,
2356
2396
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2357
2397
  }
2358
2398
  ]
2359
2399
  };
2360
2400
  }
2361
- function wn(e) {
2401
+ function An(e) {
2362
2402
  try {
2363
2403
  const t = JSON.parse(e);
2364
2404
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -2366,16 +2406,16 @@ function wn(e) {
2366
2406
  return { type: "error", message: "Invalid server event" };
2367
2407
  }
2368
2408
  }
2369
- function pe(e, t) {
2409
+ function fe(e, t) {
2370
2410
  if (!e || typeof e != "object")
2371
2411
  return [];
2372
2412
  const s = e[t];
2373
2413
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2374
2414
  }
2375
- function Sn(e) {
2415
+ function bn(e) {
2376
2416
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
2377
2417
  }
2378
- function An(e) {
2418
+ function En(e) {
2379
2419
  if (!e || typeof e != "object")
2380
2420
  return null;
2381
2421
  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;
@@ -2386,13 +2426,13 @@ function An(e) {
2386
2426
  ...a !== null ? { scribbleStyle: a } : {}
2387
2427
  };
2388
2428
  }
2389
- function En(e) {
2429
+ function Rn(e) {
2390
2430
  if (!e || typeof e != "object")
2391
2431
  return null;
2392
2432
  const t = e.javascript;
2393
2433
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
2394
2434
  }
2395
- function Rn(e, t) {
2435
+ function kn(e, t) {
2396
2436
  return t ? e && typeof e == "object" ? {
2397
2437
  ...e,
2398
2438
  helperError: t
@@ -2402,13 +2442,13 @@ function Rn(e, t) {
2402
2442
  helperError: t
2403
2443
  } : e;
2404
2444
  }
2405
- function bn(e) {
2445
+ function Mn(e) {
2406
2446
  if (!e || typeof e != "object")
2407
2447
  return e;
2408
2448
  const t = e;
2409
2449
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2410
2450
  }
2411
- function Mn() {
2451
+ function _n() {
2412
2452
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2413
2453
  if (t)
2414
2454
  return t;
@@ -2418,7 +2458,7 @@ function Mn() {
2418
2458
  function $() {
2419
2459
  return crypto.randomUUID();
2420
2460
  }
2421
- function kn(e) {
2461
+ function Cn(e) {
2422
2462
  if (!e || typeof e != "object")
2423
2463
  return null;
2424
2464
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2429,22 +2469,22 @@ function kn(e) {
2429
2469
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2430
2470
  } : null;
2431
2471
  }
2432
- function _n(e, t) {
2433
- return Array.isArray(e) ? Lt(
2434
- e.map((s) => ve(s, t)).filter((s) => s !== null)
2472
+ function Pn(e, t) {
2473
+ return Array.isArray(e) ? qt(
2474
+ e.map((s) => Ne(s, t)).filter((s) => s !== null)
2435
2475
  ) : [];
2436
2476
  }
2437
- function Cn(e) {
2477
+ function Un(e) {
2438
2478
  return Array.isArray(e) ? e.flatMap((t) => {
2439
2479
  if (!t || typeof t != "object")
2440
2480
  return [];
2441
- const s = t, n = R(s, "id"), r = R(s, "createdAt"), i = R(s, "updatedAt"), o = R(s, "lastActiveAt");
2481
+ const s = t, n = E(s, "id"), r = E(s, "createdAt"), i = E(s, "updatedAt"), o = E(s, "lastActiveAt");
2442
2482
  return !n || !r || !i || !o ? [] : [
2443
2483
  {
2444
2484
  id: n,
2445
- title: R(s, "title"),
2446
- customTitle: R(s, "customTitle"),
2447
- firstUserMessage: R(s, "firstUserMessage"),
2485
+ title: E(s, "title"),
2486
+ customTitle: E(s, "customTitle"),
2487
+ firstUserMessage: E(s, "firstUserMessage"),
2448
2488
  currentPage: s.currentPage ?? null,
2449
2489
  createdAt: r,
2450
2490
  updatedAt: i,
@@ -2455,7 +2495,7 @@ function Cn(e) {
2455
2495
  ];
2456
2496
  }) : [];
2457
2497
  }
2458
- function ve(e, t) {
2498
+ function Ne(e, t) {
2459
2499
  if (!e || typeof e != "object")
2460
2500
  return null;
2461
2501
  const s = e, n = s.data;
@@ -2469,14 +2509,14 @@ function ve(e, t) {
2469
2509
  id: String(s.id ?? crypto.randomUUID()),
2470
2510
  role: i,
2471
2511
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2472
- content: rs(
2473
- xn(r.content),
2512
+ content: is(
2513
+ qn(r.content),
2474
2514
  t
2475
2515
  ),
2476
2516
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2477
- respondsToUserMessageId: N(r) ?? void 0,
2517
+ respondsToUserMessageId: v(r) ?? void 0,
2478
2518
  ...C(r) ? { runId: C(r) } : {},
2479
- attachments: Be(r.attachments, t)
2519
+ attachments: Fe(r.attachments, t)
2480
2520
  };
2481
2521
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
2482
2522
  value: r.id,
@@ -2487,37 +2527,37 @@ function ve(e, t) {
2487
2527
  }), o;
2488
2528
  }
2489
2529
  if (r.type === "function_call_output") {
2490
- const i = Un(r.output);
2530
+ const i = On(r.output);
2491
2531
  return i ? {
2492
2532
  id: String(s.id ?? crypto.randomUUID()),
2493
2533
  role: "tool",
2494
2534
  content: `Connect ${i.appName} to continue`,
2495
2535
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2496
- respondsToUserMessageId: N(r) ?? void 0,
2536
+ respondsToUserMessageId: v(r) ?? void 0,
2497
2537
  ...C(r) ? { runId: C(r) } : {},
2498
2538
  dataType: "function_call_output",
2499
2539
  toolName: "authenticate_pipedream_app",
2500
- callId: fe(r) ?? void 0,
2540
+ callId: ge(r) ?? void 0,
2501
2541
  integrationAuthRequest: i
2502
2542
  } : null;
2503
2543
  }
2504
2544
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2505
2545
  id: String(s.id ?? crypto.randomUUID()),
2506
2546
  role: "tool",
2507
- content: r.type === "mcp_call" ? Pn(r) : vn(r),
2547
+ content: r.type === "mcp_call" ? Dn(r) : vn(r),
2508
2548
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2509
- respondsToUserMessageId: N(r) ?? void 0,
2549
+ respondsToUserMessageId: v(r) ?? void 0,
2510
2550
  ...C(r) ? { runId: C(r) } : {},
2511
2551
  dataType: String(r.type),
2512
2552
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
2513
- callId: fe(r) ?? void 0,
2553
+ callId: ge(r) ?? void 0,
2514
2554
  loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
2515
2555
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2516
2556
  id: String(s.id ?? crypto.randomUUID()),
2517
2557
  role: "system",
2518
- content: Dn(r),
2558
+ content: Nn(r),
2519
2559
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2520
- respondsToUserMessageId: N(r) ?? void 0,
2560
+ respondsToUserMessageId: v(r) ?? void 0,
2521
2561
  ...C(r) ? { runId: C(r) } : {},
2522
2562
  dataType: String(r.type),
2523
2563
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
@@ -2526,11 +2566,11 @@ function ve(e, t) {
2526
2566
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2527
2567
  } : null;
2528
2568
  }
2529
- function Pn(e) {
2569
+ function Dn(e) {
2530
2570
  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(" ");
2531
2571
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2532
2572
  }
2533
- function Un(e) {
2573
+ function On(e) {
2534
2574
  if (typeof e != "string")
2535
2575
  return null;
2536
2576
  try {
@@ -2547,7 +2587,7 @@ function Un(e) {
2547
2587
  return null;
2548
2588
  }
2549
2589
  }
2550
- function Dn(e) {
2590
+ function Nn(e) {
2551
2591
  return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : e.type === "run_status" && e.status === "steered" ? "Steered" : typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
2552
2592
  }
2553
2593
  function vn(e) {
@@ -2562,9 +2602,9 @@ function vn(e) {
2562
2602
  }
2563
2603
  return "🔎 Searching the web";
2564
2604
  }
2565
- return On(e);
2605
+ return xn(e);
2566
2606
  }
2567
- function On(e) {
2607
+ function xn(e) {
2568
2608
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2569
2609
  return L(e.summary);
2570
2610
  if (typeof e.arguments == "string")
@@ -2581,7 +2621,7 @@ function L(e) {
2581
2621
  const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2582
2622
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2583
2623
  }
2584
- function Nn(e) {
2624
+ function Ln(e) {
2585
2625
  if (e == null)
2586
2626
  return e;
2587
2627
  if (typeof e != "object")
@@ -2596,11 +2636,11 @@ function Nn(e) {
2596
2636
  runId: typeof t.runId == "string" ? t.runId : null
2597
2637
  };
2598
2638
  }
2599
- function fe(e) {
2639
+ function ge(e) {
2600
2640
  const t = e.callId ?? e.call_id;
2601
2641
  return typeof t == "string" && t ? t : null;
2602
2642
  }
2603
- function xn(e) {
2643
+ function qn(e) {
2604
2644
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2605
2645
  if (!t || typeof t != "object")
2606
2646
  return "";
@@ -2608,31 +2648,31 @@ function xn(e) {
2608
2648
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
2609
2649
  }).filter(Boolean).join("") : "";
2610
2650
  }
2611
- function Dt(e, t) {
2612
- const s = Ne(e, t), n = $n(
2613
- Ln(
2614
- Gn(e, t),
2651
+ function Ot(e, t) {
2652
+ const s = xe(e, t), n = zn(
2653
+ Bn(
2654
+ Jn(e, t),
2615
2655
  s
2616
2656
  ),
2617
2657
  s
2618
2658
  ), r = n.findIndex((o) => o.id === s.id);
2619
2659
  if (r === -1)
2620
- return Lt(
2660
+ return qt(
2621
2661
  [...n, s]
2622
2662
  );
2623
2663
  const i = [...n];
2624
- return i[r] = s, Lt(i);
2664
+ return i[r] = s, qt(i);
2625
2665
  }
2626
- function Ln(e, t) {
2666
+ function Bn(e, t) {
2627
2667
  const s = t.assistantDraftItemId;
2628
2668
  return s ? e.map(
2629
2669
  (n) => n.dataType === "assistant_draft" && n.id === s ? t : n
2630
2670
  ) : e;
2631
2671
  }
2632
- function qn(e, t, s) {
2672
+ function Fn(e, t, s) {
2633
2673
  return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
2634
2674
  }
2635
- function Bn(e, t, s, n) {
2675
+ function Hn(e, t, s, n) {
2636
2676
  if (s === null) return e;
2637
2677
  let r = -1;
2638
2678
  for (let o = e.length - 1; o >= 0; o -= 1) {
@@ -2649,12 +2689,12 @@ function Bn(e, t, s, n) {
2649
2689
  respondsToUserMessageId: s
2650
2690
  }, i;
2651
2691
  }
2652
- function Fn(e, t) {
2692
+ function Wn(e, t) {
2653
2693
  const s = e.findIndex(
2654
2694
  (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2655
2695
  );
2656
2696
  if (s === -1)
2657
- return Dt(e, t);
2697
+ return Ot(e, t);
2658
2698
  const n = [...e];
2659
2699
  return n[s] = {
2660
2700
  ...n[s],
@@ -2666,12 +2706,12 @@ function Fn(e, t) {
2666
2706
  ...n[s].runId ? {} : { runId: t.runId }
2667
2707
  }, n;
2668
2708
  }
2669
- function Hn(e, t, s) {
2709
+ function $n(e, t, s) {
2670
2710
  let n = !1;
2671
2711
  const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2672
2712
  return n ? r : e;
2673
2713
  }
2674
- function Wn(e) {
2714
+ function jn(e) {
2675
2715
  if (e.hiddenFromTranscript === !0)
2676
2716
  return null;
2677
2717
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
@@ -2690,7 +2730,7 @@ function Wn(e) {
2690
2730
  loading: !0
2691
2731
  };
2692
2732
  }
2693
- function $n(e, t) {
2733
+ function zn(e, t) {
2694
2734
  if (t.id.startsWith("transient-activity:"))
2695
2735
  return e;
2696
2736
  const s = t.toolName === "tab_lifecycle";
@@ -2698,17 +2738,17 @@ function $n(e, t) {
2698
2738
  (n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId && n.runId === t.runId)
2699
2739
  );
2700
2740
  }
2701
- function jn(e, t) {
2702
- return is(
2741
+ function Kn(e, t) {
2742
+ return os(
2703
2743
  e,
2704
2744
  t.map(
2705
- (s) => Ne(e, s)
2745
+ (s) => xe(e, s)
2706
2746
  ),
2707
- Oe
2747
+ ve
2708
2748
  );
2709
2749
  }
2710
- function Oe(e) {
2711
- const t = vt(e) ?? void 0, s = e.assistantDraftItemId, n = [
2750
+ function ve(e) {
2751
+ const t = Nt(e) ?? void 0, s = e.assistantDraftItemId, n = [
2712
2752
  ...e.callId ? [`call:${e.callId}`] : [],
2713
2753
  ...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
2714
2754
  ];
@@ -2719,52 +2759,52 @@ function Oe(e) {
2719
2759
  ...n.length > 0 ? { activityKeys: n } : {},
2720
2760
  ...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
2721
2761
  ...e.runId ? { runId: e.runId } : {},
2722
- isOptimistic: jt(e),
2762
+ isOptimistic: zt(e),
2723
2763
  isAssistantDraft: e.dataType === "assistant_draft",
2724
2764
  isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
2725
2765
  isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
2726
2766
  };
2727
2767
  }
2728
- function Ne(e, t) {
2768
+ function xe(e, t) {
2729
2769
  if (t.role !== "user" || !t.attachments?.length)
2730
2770
  return t;
2731
2771
  const s = e.find(
2732
- (r) => r.role === "user" && (r.id === t.id || jt(r) && xe(r, t))
2772
+ (r) => r.role === "user" && (r.id === t.id || zt(r) && Le(r, t))
2733
2773
  );
2734
2774
  if (!s?.attachments?.length)
2735
2775
  return t;
2736
2776
  const n = t.attachments.map((r) => {
2737
- const i = zn(s.attachments ?? [], r);
2738
- return i ? Kn(r, i) : r;
2777
+ const i = Gn(s.attachments ?? [], r);
2778
+ return i ? Xn(r, i) : r;
2739
2779
  });
2740
2780
  return { ...t, attachments: n };
2741
2781
  }
2742
- function zn(e, t) {
2782
+ function Gn(e, t) {
2743
2783
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2744
2784
  }
2745
- function Kn(e, t) {
2785
+ function Xn(e, t) {
2746
2786
  const { previewUrl: s } = t;
2747
2787
  return s ? { ...e, previewUrl: s } : e;
2748
2788
  }
2749
- function Gn(e, t) {
2789
+ function Jn(e, t) {
2750
2790
  if (t.role !== "user")
2751
2791
  return e;
2752
2792
  const s = e.findIndex(
2753
- (r) => jt(r) && xe(r, t)
2793
+ (r) => zt(r) && Le(r, t)
2754
2794
  );
2755
2795
  if (s === -1)
2756
2796
  return e;
2757
2797
  const n = [...e];
2758
2798
  return n.splice(s, 1), n;
2759
2799
  }
2760
- function xe(e, t) {
2761
- const s = vt(e), n = vt(t);
2800
+ function Le(e, t) {
2801
+ const s = Nt(e), n = Nt(t);
2762
2802
  return s && n ? s === n : e.content === t.content;
2763
2803
  }
2764
- function jt(e) {
2804
+ function zt(e) {
2765
2805
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2766
2806
  }
2767
- function vt(e) {
2807
+ function Nt(e) {
2768
2808
  const t = e.clientMessageId;
2769
2809
  if (t)
2770
2810
  return t;
@@ -2773,18 +2813,18 @@ function vt(e) {
2773
2813
  );
2774
2814
  return n ? e.id.slice(n.length) : null;
2775
2815
  }
2776
- function ge(e) {
2777
- const t = Le(e);
2816
+ function me(e) {
2817
+ const t = qe(e);
2778
2818
  if (t === null)
2779
2819
  return !1;
2780
2820
  const s = e[t].id, n = e.some(
2781
- (r) => r.respondsToUserMessageId === s && Ot(r)
2821
+ (r) => r.respondsToUserMessageId === s && vt(r)
2782
2822
  );
2783
2823
  if (e.some((r) => r.respondsToUserMessageId === s))
2784
2824
  return n;
2785
2825
  for (let r = e.length - 1; r > t; r -= 1) {
2786
2826
  const i = e[r];
2787
- if (O(i))
2827
+ if (N(i))
2788
2828
  return !0;
2789
2829
  if (i.role === "system") {
2790
2830
  if (i.dataType === "run_error")
@@ -2795,23 +2835,23 @@ function ge(e) {
2795
2835
  }
2796
2836
  return !1;
2797
2837
  }
2798
- function Xn(e) {
2799
- const t = Le(e);
2838
+ function Vn(e) {
2839
+ const t = qe(e);
2800
2840
  if (t === null)
2801
- return e.some(O);
2841
+ return e.some(N);
2802
2842
  const s = e[t].id;
2803
2843
  return e.some((n) => n.respondsToUserMessageId === s) ? e.some(
2804
- (n) => n.respondsToUserMessageId === s && O(n)
2805
- ) : e.slice(t + 1).some(O);
2844
+ (n) => n.respondsToUserMessageId === s && N(n)
2845
+ ) : e.slice(t + 1).some(N);
2806
2846
  }
2807
- function Le(e) {
2847
+ function qe(e) {
2808
2848
  for (let t = e.length - 1; t >= 0; t -= 1)
2809
2849
  if (e[t].role === "user")
2810
2850
  return t;
2811
2851
  return null;
2812
2852
  }
2813
- function Ot(e) {
2814
- return O(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2853
+ function vt(e) {
2854
+ return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2815
2855
  }
2816
2856
  function at(e) {
2817
2857
  for (let t = e.length - 1; t >= 0; t -= 1) {
@@ -2827,7 +2867,7 @@ function at(e) {
2827
2867
  }
2828
2868
  return null;
2829
2869
  }
2830
- function Jn(e) {
2870
+ function Yn(e) {
2831
2871
  const t = at(e);
2832
2872
  if (t === null)
2833
2873
  return null;
@@ -2843,13 +2883,13 @@ function q(e) {
2843
2883
  const t = e.data;
2844
2884
  return t && typeof t == "object" ? t : null;
2845
2885
  }
2846
- function Nt(e) {
2886
+ function xt(e) {
2847
2887
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2848
2888
  }
2849
- function me(e) {
2889
+ function ye(e) {
2850
2890
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2851
2891
  }
2852
- function Vn(e, t) {
2892
+ function Zn(e, t) {
2853
2893
  const s = at(t);
2854
2894
  if (s === null)
2855
2895
  return !1;
@@ -2858,10 +2898,10 @@ function Vn(e, t) {
2858
2898
  return !1;
2859
2899
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2860
2900
  return i === -1 ? !1 : e.some((o) => o.respondsToUserMessageId === r) ? e.some(
2861
- (o) => o.respondsToUserMessageId === r && Ot(o)
2862
- ) : e.slice(i + 1).some(Ot);
2901
+ (o) => o.respondsToUserMessageId === r && vt(o)
2902
+ ) : e.slice(i + 1).some(vt);
2863
2903
  }
2864
- function xt(e) {
2904
+ function Lt(e) {
2865
2905
  const t = at(e);
2866
2906
  if (t === null)
2867
2907
  return null;
@@ -2874,7 +2914,7 @@ function xt(e) {
2874
2914
  const r = n.clientMessageId;
2875
2915
  return typeof r == "string" ? r : null;
2876
2916
  }
2877
- function Yn(e) {
2917
+ function Qn(e) {
2878
2918
  const t = at(e);
2879
2919
  if (t === null)
2880
2920
  return null;
@@ -2889,22 +2929,22 @@ function Yn(e) {
2889
2929
  if (i.type === "message" && i.role === "assistant")
2890
2930
  return null;
2891
2931
  if (i.type === "run_error")
2892
- return i.retryable !== !0 ? null : ye(e, i) ?? xt(e);
2932
+ return i.retryable !== !0 ? null : Ie(e, i) ?? Lt(e);
2893
2933
  if (i.type === "run_status")
2894
- return i.status === "interrupted" && i.retryable === !0 ? ye(e, i) ?? xt(e) : null;
2934
+ return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ?? Lt(e) : null;
2895
2935
  }
2896
2936
  return null;
2897
2937
  }
2898
- function ye(e, t) {
2938
+ function Ie(e, t) {
2899
2939
  if (typeof t.clientMessageId == "string")
2900
2940
  return t.clientMessageId;
2901
- const s = N(t);
2941
+ const s = v(t);
2902
2942
  if (!s)
2903
2943
  return null;
2904
- const n = e.find((i) => R(i, "id") === s), r = q(n);
2944
+ const n = e.find((i) => E(i, "id") === s), r = q(n);
2905
2945
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2906
2946
  }
2907
- function Zn(e, t) {
2947
+ function tr(e, t) {
2908
2948
  let s = 0;
2909
2949
  for (const n of e) {
2910
2950
  if (!n || typeof n != "object")
@@ -2917,56 +2957,56 @@ function Zn(e, t) {
2917
2957
  }
2918
2958
  return s;
2919
2959
  }
2920
- function Ie(e, t, s, n, r) {
2921
- if (!t || !Qn(e))
2960
+ function Te(e, t, s, n, r) {
2961
+ if (!t || !er(e))
2922
2962
  return !1;
2923
2963
  const i = e;
2924
- return !(Nt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? N(i) !== n : r !== null && C(i) !== r));
2964
+ return !(xt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? v(i) !== n : r !== null && C(i) !== r));
2925
2965
  }
2926
- function Qn(e) {
2966
+ function er(e) {
2927
2967
  if (!e || typeof e != "object")
2928
2968
  return !1;
2929
2969
  const t = e;
2930
2970
  return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted" || t.status === "failed");
2931
2971
  }
2932
- function O(e) {
2972
+ function N(e) {
2933
2973
  return e.role === "assistant" && e.phase !== "commentary";
2934
2974
  }
2935
- function tr(e) {
2975
+ function sr(e) {
2936
2976
  if (!e || typeof e != "object")
2937
2977
  return !1;
2938
2978
  const t = e;
2939
2979
  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";
2940
2980
  }
2941
- function Lt(e) {
2942
- return e.filter((t, s) => ct(t) ? !cr(e, s) && !or(e, s) && !ar(e, s) : er(t) ? t.retryable === !0 && ir(e, s) ? !1 : !rr(e, s) : !0);
2981
+ function qt(e) {
2982
+ return e.filter((t, s) => ct(t) ? !ur(e, s) && !cr(e, s) && !lr(e, s) : nr(t) ? t.retryable === !0 && ar(e, s) ? !1 : !or(e, s) : !0);
2943
2983
  }
2944
- function er(e) {
2984
+ function nr(e) {
2945
2985
  return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
2946
2986
  }
2947
2987
  function ct(e) {
2948
2988
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2949
2989
  }
2950
- function sr(e, t) {
2990
+ function rr(e, t) {
2951
2991
  const s = [...e].reverse().find(
2952
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && Te(n) && !nr(
2992
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !ir(
2953
2993
  e,
2954
2994
  n.respondsToUserMessageId
2955
2995
  )
2956
2996
  )?.respondsToUserMessageId;
2957
2997
  return s ? e.map(
2958
- (n) => n.respondsToUserMessageId === s && Te(n) ? { ...n, steered: !0 } : n
2998
+ (n) => n.respondsToUserMessageId === s && we(n) ? { ...n, steered: !0 } : n
2959
2999
  ) : e;
2960
3000
  }
2961
- function Te(e) {
3001
+ function we(e) {
2962
3002
  return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
2963
3003
  }
2964
- function nr(e, t) {
3004
+ function ir(e, t) {
2965
3005
  return e.some(
2966
- (s) => s.respondsToUserMessageId === t && (O(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3006
+ (s) => s.respondsToUserMessageId === t && (N(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
2967
3007
  );
2968
3008
  }
2969
- function rr(e, t) {
3009
+ function or(e, t) {
2970
3010
  const s = e[t];
2971
3011
  for (let n = t + 1; n < e.length; n += 1) {
2972
3012
  const r = e[n];
@@ -2975,7 +3015,7 @@ function rr(e, t) {
2975
3015
  }
2976
3016
  return !1;
2977
3017
  }
2978
- function ir(e, t) {
3018
+ function ar(e, t) {
2979
3019
  const s = e[t];
2980
3020
  if (!s.respondsToUserMessageId)
2981
3021
  return !1;
@@ -2988,19 +3028,19 @@ function ir(e, t) {
2988
3028
  }
2989
3029
  return !1;
2990
3030
  }
2991
- function or(e, t) {
3031
+ function cr(e, t) {
2992
3032
  const s = e[t];
2993
3033
  return e.some(
2994
3034
  (n, r) => r !== t && n.role === "assistant" && lt(s, n)
2995
3035
  );
2996
3036
  }
2997
- function ar(e, t) {
3037
+ function lr(e, t) {
2998
3038
  const s = e[t];
2999
3039
  return e.some(
3000
3040
  (n, r) => r !== t && n.role === "tool" && lt(s, n)
3001
3041
  );
3002
3042
  }
3003
- function cr(e, t) {
3043
+ function ur(e, t) {
3004
3044
  const s = e[t];
3005
3045
  for (let n = t + 1; n < e.length; n += 1)
3006
3046
  if (ct(e[n]) && lt(s, e[n]))
@@ -3010,18 +3050,18 @@ function cr(e, t) {
3010
3050
  function lt(e, t) {
3011
3051
  return !!(e.respondsToUserMessageId && e.respondsToUserMessageId === t.respondsToUserMessageId);
3012
3052
  }
3013
- function R(e, t) {
3053
+ function E(e, t) {
3014
3054
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
3015
3055
  }
3016
- function lr(e, t) {
3056
+ function dr(e, t) {
3017
3057
  try {
3018
- const s = window.localStorage.getItem(`${ke}${e}`);
3058
+ const s = window.localStorage.getItem(`${_e}${e}`);
3019
3059
  if (!s)
3020
3060
  return null;
3021
3061
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
3022
3062
  if (t !== void 0 && r !== t)
3023
3063
  return null;
3024
- const i = Array.isArray(n.messages) ? n.messages.map(Tr).filter((o) => !!o) : [];
3064
+ const i = Array.isArray(n.messages) ? n.messages.map(Sr).filter((o) => !!o) : [];
3025
3065
  return {
3026
3066
  sessionId: r,
3027
3067
  messages: i
@@ -3030,46 +3070,46 @@ function lr(e, t) {
3030
3070
  return null;
3031
3071
  }
3032
3072
  }
3033
- function ur(e, t) {
3073
+ function hr(e, t) {
3034
3074
  try {
3035
3075
  window.localStorage.setItem(
3036
- `${ke}${e}`,
3076
+ `${_e}${e}`,
3037
3077
  JSON.stringify({
3038
3078
  sessionId: t.sessionId,
3039
- messages: t.messages.slice(-Ls).map(wr)
3079
+ messages: t.messages.slice(-qs).map(Ar)
3040
3080
  })
3041
3081
  );
3042
3082
  } catch {
3043
3083
  return;
3044
3084
  }
3045
3085
  }
3046
- function dr(e) {
3086
+ function pr(e) {
3047
3087
  try {
3048
- const t = window.localStorage.getItem(`${Ut}${e}`);
3088
+ const t = window.localStorage.getItem(`${Dt}${e}`);
3049
3089
  if (!t)
3050
3090
  return [];
3051
3091
  const s = JSON.parse(t);
3052
- return Array.isArray(s) ? s.filter(zt) : [];
3092
+ return Array.isArray(s) ? s.filter(Kt) : [];
3053
3093
  } catch {
3054
3094
  return [];
3055
3095
  }
3056
3096
  }
3057
3097
  function j(e, t) {
3058
3098
  try {
3059
- const s = t.filter(zt);
3099
+ const s = t.filter(Kt);
3060
3100
  if (s.length === 0) {
3061
- window.localStorage.removeItem(`${Ut}${e}`);
3101
+ window.localStorage.removeItem(`${Dt}${e}`);
3062
3102
  return;
3063
3103
  }
3064
3104
  window.localStorage.setItem(
3065
- `${Ut}${e}`,
3105
+ `${Dt}${e}`,
3066
3106
  JSON.stringify(s.slice(-25))
3067
3107
  );
3068
3108
  } catch {
3069
3109
  return;
3070
3110
  }
3071
3111
  }
3072
- function qe(e, t) {
3112
+ function Be(e, t) {
3073
3113
  try {
3074
3114
  const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
3075
3115
  ...o,
@@ -3085,28 +3125,28 @@ function qe(e, t) {
3085
3125
  } catch {
3086
3126
  }
3087
3127
  }
3088
- function hr(e, t) {
3128
+ function fr(e, t) {
3089
3129
  try {
3090
3130
  if (window.sessionStorage.getItem(`${ot}${e}`) === null)
3091
3131
  return;
3092
3132
  } catch {
3093
3133
  return;
3094
3134
  }
3095
- qe(e, t);
3135
+ Be(e, t);
3096
3136
  }
3097
- function pr(e) {
3137
+ function gr(e) {
3098
3138
  try {
3099
3139
  const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
3100
3140
  if (window.sessionStorage.removeItem(t), !s)
3101
3141
  return [];
3102
3142
  const n = JSON.parse(s);
3103
- return Array.isArray(n) ? n.flatMap((r) => gr(r) ? [{
3143
+ return Array.isArray(n) ? n.flatMap((r) => yr(r) ? [{
3104
3144
  ...r.event,
3105
- page: M(),
3145
+ page: k(),
3106
3146
  rawOutput: {
3107
3147
  pageContextRestarted: !0,
3108
3148
  outcome: "unknown",
3109
- message: fr(location.href),
3149
+ message: mr(location.href),
3110
3150
  currentUrl: location.href,
3111
3151
  console: [],
3112
3152
  metadata: {
@@ -3123,17 +3163,17 @@ function pr(e) {
3123
3163
  return [];
3124
3164
  }
3125
3165
  }
3126
- function fr(e) {
3166
+ function mr(e) {
3127
3167
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
3128
3168
  Current URL: ${e}`;
3129
3169
  }
3130
- function gr(e) {
3170
+ function yr(e) {
3131
3171
  if (!e || typeof e != "object")
3132
3172
  return !1;
3133
3173
  const t = e, s = t.event;
3134
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && zt(s) && s.type === "tool.result";
3174
+ return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Kt(s) && s.type === "tool.result";
3135
3175
  }
3136
- function mr(e, t) {
3176
+ function Ir(e, t) {
3137
3177
  const s = new Set(
3138
3178
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
3139
3179
  );
@@ -3142,26 +3182,26 @@ function mr(e, t) {
3142
3182
  ...t.filter((n) => !s.has(n.callId))
3143
3183
  ];
3144
3184
  }
3145
- function yr(e) {
3185
+ function Tr(e) {
3146
3186
  try {
3147
3187
  window.sessionStorage.removeItem(`${ot}${e}`);
3148
3188
  } catch {
3149
3189
  return;
3150
3190
  }
3151
3191
  }
3152
- function zt(e) {
3192
+ function Kt(e) {
3153
3193
  if (!e || typeof e != "object")
3154
3194
  return !1;
3155
3195
  const t = e;
3156
- return t.type === "chat.user_message" ? typeof t.content == "string" && we(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? we(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
3196
+ return t.type === "chat.user_message" ? typeof t.content == "string" && Se(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Se(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
3157
3197
  }
3158
- function we(e) {
3198
+ function Se(e) {
3159
3199
  if (!e || typeof e != "object")
3160
3200
  return !1;
3161
3201
  const t = e;
3162
3202
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
3163
3203
  }
3164
- function Be(e, t) {
3204
+ function Fe(e, t) {
3165
3205
  if (!Array.isArray(e))
3166
3206
  return;
3167
3207
  const s = e.filter((r) => {
@@ -3169,23 +3209,23 @@ function Be(e, t) {
3169
3209
  return !1;
3170
3210
  const i = r;
3171
3211
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
3172
- }), n = t ? s.map((r) => Fe(r, t)) : s;
3212
+ }), n = t ? s.map((r) => He(r, t)) : s;
3173
3213
  return n.length > 0 ? n : void 0;
3174
3214
  }
3175
- function Fe(e, t) {
3215
+ function He(e, t) {
3176
3216
  return e.fileUrl?.startsWith("/") ? {
3177
3217
  ...e,
3178
3218
  fileUrl: new URL(e.fileUrl, t).toString()
3179
3219
  } : e;
3180
3220
  }
3181
- function Se(e) {
3182
- return e.type || Ir(e.name) || "application/octet-stream";
3221
+ function Ae(e) {
3222
+ return e.type || wr(e.name) || "application/octet-stream";
3183
3223
  }
3184
- function Ir(e) {
3224
+ function wr(e) {
3185
3225
  const t = e.toLowerCase();
3186
3226
  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;
3187
3227
  }
3188
- function Tr(e) {
3228
+ function Sr(e) {
3189
3229
  if (!e || typeof e != "object")
3190
3230
  return null;
3191
3231
  const t = e;
@@ -3198,17 +3238,17 @@ function Tr(e) {
3198
3238
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
3199
3239
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
3200
3240
  securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
3201
- attachments: Be(t.attachments)?.map(Kt),
3241
+ attachments: Fe(t.attachments)?.map(Gt),
3202
3242
  loading: typeof t.loading == "boolean" ? t.loading : void 0
3203
3243
  };
3204
3244
  }
3205
- function wr(e) {
3245
+ function Ar(e) {
3206
3246
  return e.attachments?.length ? {
3207
3247
  ...e,
3208
- attachments: e.attachments.map(Kt)
3248
+ attachments: e.attachments.map(Gt)
3209
3249
  } : e;
3210
3250
  }
3211
- function Kt(e) {
3251
+ function Gt(e) {
3212
3252
  const {
3213
3253
  dataUrl: t,
3214
3254
  objectUrl: s,
@@ -3217,7 +3257,7 @@ function Kt(e) {
3217
3257
  } = e;
3218
3258
  return r;
3219
3259
  }
3220
- function N(e) {
3260
+ function v(e) {
3221
3261
  const t = e.respondsToUserMessageId;
3222
3262
  return typeof t == "string" && t ? t : null;
3223
3263
  }
@@ -3225,39 +3265,39 @@ function C(e) {
3225
3265
  const t = e.runId;
3226
3266
  return typeof t == "string" && t ? t : null;
3227
3267
  }
3228
- function Sr(e) {
3268
+ function br(e) {
3229
3269
  const t = e?.timeoutMs;
3230
- return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= zs);
3270
+ return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Gs);
3231
3271
  }
3232
- function He(e) {
3272
+ function We(e) {
3233
3273
  const t = {};
3234
3274
  try {
3235
3275
  new Headers(e).forEach((s, n) => {
3236
- Object.keys(t).length < Wt && (t[n] = Gt(n, s));
3276
+ Object.keys(t).length < $t && (t[n] = Xt(n, s));
3237
3277
  });
3238
3278
  } catch {
3239
3279
  return {};
3240
3280
  }
3241
3281
  return t;
3242
3282
  }
3243
- function Gt(e, t) {
3244
- return Ge(e) ? ut : P(it(t), Ns);
3283
+ function Xt(e, t) {
3284
+ return Xe(e) ? ut : P(it(t), xs);
3245
3285
  }
3246
- function Ar(e, t) {
3286
+ function Er(e, t) {
3247
3287
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
3248
3288
  }
3249
- async function Er(e, t, s, n) {
3250
- const r = He(e.headers);
3289
+ async function Rr(e, t, s, n) {
3290
+ const r = We(e.headers);
3251
3291
  n({
3252
3292
  ...t,
3253
3293
  responseStatus: e.status,
3254
3294
  responseHeaders: r,
3255
- responseBody: await Rr(e),
3295
+ responseBody: await kr(e),
3256
3296
  durationMs: Date.now() - s
3257
3297
  });
3258
3298
  }
3259
- async function Rr(e) {
3260
- if (!We(e.headers))
3299
+ async function kr(e) {
3300
+ if (!$e(e.headers))
3261
3301
  return;
3262
3302
  let t = null, s = null;
3263
3303
  try {
@@ -3266,7 +3306,7 @@ async function Rr(e) {
3266
3306
  const n = new Promise((a) => {
3267
3307
  s = window.setTimeout(() => {
3268
3308
  t?.cancel(), a("timeout");
3269
- }, xs);
3309
+ }, Ls);
3270
3310
  }), r = new TextDecoder();
3271
3311
  let i = "", o = 0;
3272
3312
  for (; ; ) {
@@ -3276,7 +3316,7 @@ async function Rr(e) {
3276
3316
  const { done: c, value: l } = a;
3277
3317
  if (c)
3278
3318
  return P(i + r.decode());
3279
- const h = Ht - o;
3319
+ const h = Wt - o;
3280
3320
  if (l.byteLength > h)
3281
3321
  return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
3282
3322
  o += l.byteLength, i += r.decode(l, { stream: !0 });
@@ -3288,20 +3328,20 @@ async function Rr(e) {
3288
3328
  s !== null && window.clearTimeout(s);
3289
3329
  }
3290
3330
  }
3291
- function br(e, t) {
3292
- if (We(new Headers(t)))
3331
+ function Mr(e, t) {
3332
+ if ($e(new Headers(t)))
3293
3333
  try {
3294
3334
  return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
3295
3335
  } catch {
3296
3336
  return;
3297
3337
  }
3298
3338
  }
3299
- function Ae(e) {
3339
+ function be(e) {
3300
3340
  if (typeof e == "string")
3301
3341
  return P(e);
3302
3342
  }
3303
- function Mr(e) {
3304
- return k({
3343
+ function _r(e) {
3344
+ return M({
3305
3345
  ...e,
3306
3346
  requestBody: Ee(e.requestBody),
3307
3347
  responseBody: Ee(e.responseBody)
@@ -3314,19 +3354,19 @@ function Ee(e) {
3314
3354
  if (!t.startsWith("{") && !t.startsWith("["))
3315
3355
  return it(e);
3316
3356
  try {
3317
- return JSON.stringify(k(JSON.parse(e)));
3357
+ return JSON.stringify(M(JSON.parse(e)));
3318
3358
  } catch {
3319
3359
  return it(e);
3320
3360
  }
3321
3361
  }
3322
- function We(e) {
3362
+ function $e(e) {
3323
3363
  if (!e)
3324
3364
  return !1;
3325
3365
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
3326
- return s !== null && Number.isInteger(n) && n >= 0 && n <= Ht && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3366
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= Wt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3327
3367
  }
3328
3368
  function x(e, t = {}, s) {
3329
- if (_r(s))
3369
+ if (Pr(s))
3330
3370
  return !0;
3331
3371
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3332
3372
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3341,7 +3381,7 @@ function x(e, t = {}, s) {
3341
3381
  return !0;
3342
3382
  }
3343
3383
  }
3344
- function kr(e, t) {
3384
+ function Cr(e, t) {
3345
3385
  if (x(e))
3346
3386
  return !0;
3347
3387
  try {
@@ -3351,26 +3391,26 @@ function kr(e, t) {
3351
3391
  return !0;
3352
3392
  }
3353
3393
  }
3354
- function _r(e) {
3394
+ function Pr(e) {
3355
3395
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
3356
3396
  }
3357
- function Cr(e) {
3397
+ function Ur(e) {
3358
3398
  const t = {};
3359
3399
  for (const s of e.trim().split(/[\r\n]+/)) {
3360
3400
  const n = s.indexOf(":");
3361
3401
  if (n <= 0)
3362
3402
  continue;
3363
- if (Object.keys(t).length >= Wt)
3403
+ if (Object.keys(t).length >= $t)
3364
3404
  break;
3365
3405
  const r = s.slice(0, n).trim();
3366
- t[r] = Gt(r, s.slice(n + 1).trim());
3406
+ t[r] = Xt(r, s.slice(n + 1).trim());
3367
3407
  }
3368
3408
  return t;
3369
3409
  }
3370
- function P(e, t = Ht) {
3410
+ function P(e, t = Wt) {
3371
3411
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
3372
3412
  }
3373
- function _t(e) {
3413
+ function Ct(e) {
3374
3414
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
3375
3415
  }
3376
3416
  class nt extends Error {
@@ -3381,32 +3421,32 @@ class nt extends Error {
3381
3421
  }
3382
3422
  async function tt(e, t) {
3383
3423
  let s = null;
3384
- for (let n = 0; n < le; n += 1)
3424
+ for (let n = 0; n < ue; n += 1)
3385
3425
  try {
3386
3426
  return await e();
3387
3427
  } catch (r) {
3388
- if (s = r, n >= le - 1 || !Ur(r))
3428
+ if (s = r, n >= ue - 1 || !Or(r))
3389
3429
  throw r;
3390
- await Pr(n);
3430
+ await Dr(n);
3391
3431
  }
3392
3432
  throw s instanceof Error ? s : new Error(t);
3393
3433
  }
3394
- function Pr(e) {
3434
+ function Dr(e) {
3395
3435
  return new Promise((t) => {
3396
- window.setTimeout(t, Os[e] ?? 0);
3436
+ window.setTimeout(t, vs[e] ?? 0);
3397
3437
  });
3398
3438
  }
3399
- function Ur(e) {
3400
- return e instanceof nt ? Dr(e.status) : e instanceof TypeError;
3439
+ function Or(e) {
3440
+ return e instanceof nt ? Nr(e.status) : e instanceof TypeError;
3401
3441
  }
3402
- function Dr(e) {
3442
+ function Nr(e) {
3403
3443
  return e === 408 || e === 409 || e === 429 || e >= 500;
3404
3444
  }
3405
3445
  function vr(e) {
3406
3446
  return e === 401 || e === 403;
3407
3447
  }
3408
- const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", Or = "[REDACTED_SIGNED_URL]", Nr = 20, xr = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, $e = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, je = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ze = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ke = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, Lr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, qr = /\bhttps?:\/\/[^\s"'<>]+/gi, Br = /[),.;\]]+$/;
3409
- function k(e) {
3448
+ const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", xr = "[REDACTED_SIGNED_URL]", Lr = 20, qr = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, je = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ze = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ke = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ge = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, Br = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Fr = /\bhttps?:\/\/[^\s"'<>]+/gi, Hr = /[),.;\]]+$/;
3449
+ function M(e) {
3410
3450
  return rt(e, 0, /* @__PURE__ */ new WeakSet());
3411
3451
  }
3412
3452
  function rt(e, t, s) {
@@ -3414,7 +3454,7 @@ function rt(e, t, s) {
3414
3454
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
3415
3455
  if (e === null || typeof e != "object")
3416
3456
  return e;
3417
- if (t >= Nr)
3457
+ if (t >= Lr)
3418
3458
  return "[REDACTED_MAX_DEPTH]";
3419
3459
  if (s.has(e))
3420
3460
  return "[REDACTED_CIRCULAR]";
@@ -3422,44 +3462,44 @@ function rt(e, t, s) {
3422
3462
  return e.map((r) => rt(r, t + 1, s));
3423
3463
  const n = {};
3424
3464
  for (const [r, i] of Object.entries(e))
3425
- r === "pageContent" ? n[r] = i : Ge(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Fr(i) : rt(i, t + 1, s);
3465
+ r === "pageContent" ? n[r] = i : Xe(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Wr(i) : rt(i, t + 1, s);
3426
3466
  return n;
3427
3467
  }
3428
- function Ge(e) {
3468
+ function Xe(e) {
3429
3469
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
3430
3470
  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");
3431
3471
  }
3432
- function Fr(e) {
3433
- return typeof e == "string" ? Xe(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3472
+ function Wr(e) {
3473
+ return typeof e == "string" ? Je(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3434
3474
  }
3435
- function Xe(e) {
3475
+ function Je(e) {
3436
3476
  try {
3437
3477
  const t = new URL(e, location.href);
3438
3478
  for (const s of Array.from(t.searchParams.keys()))
3439
- xr.test(s) && t.searchParams.set(s, U);
3479
+ qr.test(s) && t.searchParams.set(s, U);
3440
3480
  return t.username && (t.username = U), t.password && (t.password = U), t.toString();
3441
3481
  } catch {
3442
- return Hr(e);
3482
+ return $r(e);
3443
3483
  }
3444
3484
  }
3445
3485
  function it(e) {
3446
- return e.replace(Lr, Or).replace(qr, Wr).replace($e, `Bearer ${U}`).replace(je, `Basic ${U}`).replace(ze, U).replace(Ke, (t, s) => `${s}: ${ut}`);
3486
+ return e.replace(Br, xr).replace(Fr, jr).replace(je, `Bearer ${U}`).replace(ze, `Basic ${U}`).replace(Ke, U).replace(Ge, (t, s) => `${s}: ${ut}`);
3447
3487
  }
3448
- function Hr(e) {
3449
- return e.replace($e, `Bearer ${U}`).replace(je, `Basic ${U}`).replace(ze, U).replace(Ke, (t, s) => `${s}: ${ut}`);
3488
+ function $r(e) {
3489
+ return e.replace(je, `Bearer ${U}`).replace(ze, `Basic ${U}`).replace(Ke, U).replace(Ge, (t, s) => `${s}: ${ut}`);
3450
3490
  }
3451
- function Wr(e) {
3452
- const t = e.match(Br)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3453
- return `${Xe(s)}${t}`;
3491
+ function jr(e) {
3492
+ const t = e.match(Hr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3493
+ return `${Je(s)}${t}`;
3454
3494
  }
3455
3495
  export {
3456
- ne as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3457
- Pt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3458
- Is as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3459
- ys as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3460
- Ts as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3461
- _e as PlunoProductAgent,
3462
- Bs as calculateReconnectDelay,
3463
- _e as default,
3464
- ln as getProductAgentOriginAccessErrorMessage
3496
+ re as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3497
+ Ut as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3498
+ Ts as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3499
+ Is as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3500
+ ws as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3501
+ Ce as PlunoProductAgent,
3502
+ Fs as calculateReconnectDelay,
3503
+ Ce as default,
3504
+ dn as getProductAgentOriginAccessErrorMessage
3465
3505
  };