@pluno/product-agent-web 0.1.188 → 0.1.189

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,6 +1,6 @@
1
- const Ts = "pluno-product-agent-attachments";
1
+ const Ss = "pluno-product-agent-attachments";
2
2
  const Ge = "files";
3
- async function Ss(t) {
3
+ async function Ts(t) {
4
4
  const e = await tt();
5
5
  await As(e, "readwrite", (s) => s.put(t));
6
6
  }
@@ -25,7 +25,7 @@ async function Ms(t = 864e5) {
25
25
  }
26
26
  function tt() {
27
27
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
28
- const s = indexedDB.open(Ts, 1);
28
+ const s = indexedDB.open(Ss, 1);
29
29
  s.onupgradeneeded = () => {
30
30
  const r = s.result.createObjectStore(Ge, { keyPath: "attachmentId" });
31
31
  r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
@@ -124,24 +124,24 @@ function vs(t, e, s) {
124
124
  ), c = /* @__PURE__ */ new Map();
125
125
  for (const { item: u, identity: h } of i)
126
126
  for (const g of h.activityKeys ?? []) {
127
- const m = c.get(g);
128
- (!m || s(m).isTransient) && c.set(g, u);
127
+ const y = c.get(g);
128
+ (!y || s(y).isTransient) && c.set(g, u);
129
129
  }
130
130
  const d = new Set(i.map(({ identity: u }) => u.id)), p = new Set(
131
131
  i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
132
- ), y = /* @__PURE__ */ new Set(), f = [];
132
+ ), m = /* @__PURE__ */ new Set(), f = [];
133
133
  for (const u of t) {
134
134
  const h = s(u);
135
135
  let g = o.get(h.id);
136
- if (h.isOptimistic && h.optimisticKey ? g = a.get(h.optimisticKey) : h.isAssistantDraft && h.assistantDraftKey ? g = l.get(h.assistantDraftKey) : h.isActivity && (g = h.activityKeys?.map((C) => c.get(C)).find((C) => C !== void 0) ?? g), g && !y.has(g)) {
137
- f.push(g), y.add(g);
136
+ if (h.isOptimistic && h.optimisticKey ? g = a.get(h.optimisticKey) : h.isAssistantDraft && h.assistantDraftKey ? g = l.get(h.assistantDraftKey) : h.isActivity && (g = h.activityKeys?.map((C) => c.get(C)).find((C) => C !== void 0) ?? g), g && !m.has(g)) {
137
+ f.push(g), m.add(g);
138
138
  continue;
139
139
  }
140
- const m = h.respondsToUserMessageId !== void 0 && d.has(h.respondsToUserMessageId) || h.runId !== void 0 && p.has(h.runId);
141
- (h.isOptimistic || (h.isAssistantDraft || h.isActivity) && m) && f.push(u);
140
+ const y = h.respondsToUserMessageId !== void 0 && d.has(h.respondsToUserMessageId) || h.runId !== void 0 && p.has(h.runId);
141
+ (h.isOptimistic || (h.isAssistantDraft || h.isActivity) && y) && f.push(u);
142
142
  }
143
143
  for (const { item: u } of i)
144
- y.has(u) || f.push(u);
144
+ m.has(u) || f.push(u);
145
145
  return f;
146
146
  }
147
147
  function Ds(t, e, s, n) {
@@ -152,7 +152,7 @@ function Ds(t, e, s, n) {
152
152
  }
153
153
  const Ne = "pluno.productAgent.transportId", Os = "pluno.productAgent.transportIdentity", xe = "pluno.productAgent.transportIdentity.event", qs = 50, Ls = globalThis.setTimeout.bind(globalThis);
154
154
  let re = null;
155
- const Te = /* @__PURE__ */ new Set(), Be = /* @__PURE__ */ new Map();
155
+ const Se = /* @__PURE__ */ new Set(), Be = /* @__PURE__ */ new Map();
156
156
  async function Ns(t = Ht()) {
157
157
  const e = t.randomUUID(), s = t.storage.getItem(Ne);
158
158
  let n = s ?? t.randomUUID(), r = !1, i = !1;
@@ -197,24 +197,24 @@ async function xs(t = !1) {
197
197
  skipStoredIdentityCollisionCheck: t
198
198
  }), re.then((r) => {
199
199
  const i = (o) => {
200
- o.persisted || (r.release(), re = null, Te.clear(), window.removeEventListener("pagehide", i));
200
+ o.persisted || (r.release(), re = null, Se.clear(), window.removeEventListener("pagehide", i));
201
201
  };
202
202
  window.addEventListener("pagehide", i);
203
203
  }));
204
204
  const e = await re, s = Bs();
205
- Te.add(s);
205
+ Se.add(s);
206
206
  let n = !1;
207
207
  return {
208
208
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
209
209
  transportId: s === 0 ? e.transportId : `${e.transportId}.${s}`,
210
210
  release: () => {
211
- n || (n = !0, Te.delete(s));
211
+ n || (n = !0, Se.delete(s));
212
212
  }
213
213
  };
214
214
  }
215
215
  function Bs() {
216
216
  let t = 0;
217
- for (; Te.has(t); )
217
+ for (; Se.has(t); )
218
218
  t += 1;
219
219
  return t;
220
220
  }
@@ -307,7 +307,7 @@ const Fs = [
307
307
  ...Fs,
308
308
  ...zs
309
309
  ], We = (t) => Ks.some((e) => e.value === t), Gs = globalThis.fetch.bind(globalThis), Ve = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Vs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Xs = ".pluno-pa-widget__panel", Js = ".pluno-pa-widget__timeline", ft = `${Ve}[data-pluno-sdk-preview-channel]`;
310
- let Ys = 0;
310
+ let Qs = 0;
311
311
  function mt(t) {
312
312
  const e = {};
313
313
  for (const o of [
@@ -358,7 +358,7 @@ function He(t, e, s) {
358
358
  source: "web_sdk",
359
359
  category: t,
360
360
  name: e,
361
- sequence: ++Ys,
361
+ sequence: ++Qs,
362
362
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
363
363
  monotonicMs: performance.now(),
364
364
  data: s
@@ -367,27 +367,27 @@ function He(t, e, s) {
367
367
  }
368
368
  class pe extends Error {
369
369
  }
370
- function Qs(t) {
370
+ function Ys(t) {
371
371
  return t === 408 || t === 425 || t === 429 || t >= 500;
372
372
  }
373
- const Zs = "https://app.pluno.ai", en = 2e4, tn = 1e4, sn = 1e4, nn = 1e4, rn = 1e4, on = 3e3, an = 3e4, ln = 1e3, yt = 3e4, It = 0.2, Tt = 6e4, St = 15e3, ie = 8, wt = "Browser connection was interrupted.", Mt = 15e3, cn = "Pluno could not send this message. Try it again.", At = 2e3, un = 1e3, dn = 100, Rt = 8e3, Et = 3, hn = [300, 1e3], jt = 50 * 1024 * 1024, pn = /* @__PURE__ */ new Set([
373
+ const Zs = "https://app.pluno.ai", en = 2e4, tn = 1e4, sn = 1e4, nn = 1e4, rn = 1e4, on = 3e3, an = 3e4, ln = 1e3, yt = 3e4, It = 0.2, St = 6e4, Tt = 15e3, ie = 8, wt = "Browser connection was interrupted.", Mt = 15e3, cn = "Pluno could not send this message. Try it again.", At = 2e3, un = 1e3, dn = 100, Rt = 8e3, Et = 3, hn = [300, 1e3], jt = 50 * 1024 * 1024, pn = /* @__PURE__ */ new Set([
374
374
  ".jpeg:image/jpeg",
375
375
  ".jpg:image/jpeg",
376
376
  ".pdf:application/pdf",
377
377
  ".png:image/png",
378
378
  ".webp:image/webp"
379
- ]), ki = ".pdf,.png,.jpg,.jpeg,.webp", rt = 64e3, $e = 4e3, it = 30, gn = 2e3, fn = 1e3, Ft = "Image is too large for model vision input.", mn = 100, zt = "pluno.productAgent.state.", Xe = "pluno.productAgent.pendingEvents.", be = "pluno.productAgent.activeToolCalls.", yn = 100;
379
+ ]), Ci = ".pdf,.png,.jpg,.jpeg,.webp", rt = 64e3, $e = 4e3, it = 30, gn = 2e3, fn = 1e3, Ft = "Image is too large for model vision input.", mn = 100, zt = "pluno.productAgent.state.", Xe = "pluno.productAgent.pendingEvents.", be = "pluno.productAgent.activeToolCalls.", yn = 100;
380
380
  function oe(t, e = 0) {
381
381
  const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
382
382
  return Math.max(e, s);
383
383
  }
384
- const Se = /* @__PURE__ */ new Set();
384
+ const Te = /* @__PURE__ */ new Set();
385
385
  let ge = null;
386
386
  function In(t, e = Math.random) {
387
387
  const s = Math.min(yt, ln * 2 ** t), n = 1 - It + e() * It * 2;
388
388
  return Math.min(yt, Math.round(s * n));
389
389
  }
390
- function Tn(t, e, s) {
390
+ function Sn(t, e, s) {
391
391
  return new Promise((n, r) => {
392
392
  const i = setTimeout(() => r(new Error(s)), e);
393
393
  t.then(
@@ -404,9 +404,9 @@ class Kt {
404
404
  constructor(e, s) {
405
405
  this.options = e, this.transportIdentity = s, this.personalModelSelectionOverride = e.productVariant === "personal" && We(e.model) ? e.model : null, this.state = {
406
406
  ...this.state,
407
- starterPrompts: Qn(e.initialStarterPrompts)
407
+ starterPrompts: Yn(e.initialStarterPrompts)
408
408
  };
409
- const n = e.restorePersistedState === !1 ? null : zr(e.clientId, e.expectedPersistedSessionId);
409
+ const n = e.restorePersistedState === !1 ? null : Kr(e.clientId, e.expectedPersistedSessionId);
410
410
  n && (this.state = {
411
411
  ...this.state,
412
412
  ...n,
@@ -428,13 +428,13 @@ class Kt {
428
428
  isRetrying: !1,
429
429
  lastError: null
430
430
  }), this.queuedClientEvents = Yr(
431
- Gr(e.clientId),
432
- Vr(e.clientId)
431
+ Vr(e.clientId),
432
+ Xr(e.clientId)
433
433
  );
434
434
  const r = [...this.queuedClientEvents].reverse().find(
435
435
  (i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
436
436
  );
437
- r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), G(e.clientId, this.queuedClientEvents);
437
+ r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), V(e.clientId, this.queuedClientEvents);
438
438
  }
439
439
  options;
440
440
  listeners = {};
@@ -500,6 +500,7 @@ class Kt {
500
500
  lastUserMessagePageUrl = null;
501
501
  thinkingWatchdogResyncAttemptsByClientMessageId = {};
502
502
  retryableClientMessageId = null;
503
+ stagedProactiveSuggestionQuestionMessageId = null;
503
504
  runtimeHelperJavascript = null;
504
505
  attachmentFiles = /* @__PURE__ */ new Map();
505
506
  sessionBrowserApisCleanup = null;
@@ -549,7 +550,7 @@ class Kt {
549
550
  }, n);
550
551
  try {
551
552
  Ms().catch((i) => {
552
- w("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
553
+ M("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
553
554
  message: i instanceof Error ? i.message : String(i)
554
555
  });
555
556
  }), s.disableNetworkCapture || r.enableNetworkCapture(), r.startPageLifecycleRecovery(), r.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await r.connect();
@@ -570,6 +571,21 @@ class Kt {
570
571
  messages: [...this.state.messages]
571
572
  };
572
573
  }
574
+ stageProactiveSuggestionQuestion(e) {
575
+ const s = e.trim();
576
+ if (!s)
577
+ return;
578
+ const n = this.stagedProactiveSuggestionQuestionMessageId ?? `local-proactive-suggestion-edit-${B()}`;
579
+ this.stagedProactiveSuggestionQuestionMessageId = n;
580
+ const r = {
581
+ id: n,
582
+ role: "assistant",
583
+ phase: "final_answer",
584
+ content: s,
585
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
586
+ }, i = this.state.messages.findIndex((a) => a.id === n), o = [...this.state.messages];
587
+ i >= 0 ? o[i] = r : o.push(r), this.setState({ messages: o }), this.emit("message", r);
588
+ }
573
589
  async connect() {
574
590
  if (this.connectionInProgress || this.socket?.readyState === WebSocket.OPEN || this.socket?.readyState === WebSocket.CONNECTING)
575
591
  return;
@@ -579,15 +595,15 @@ class Kt {
579
595
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
580
596
  );
581
597
  try {
582
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Tn(this.options.tokenProvider(), sn, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
598
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Sn(this.options.tokenProvider(), sn, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
583
599
  return;
584
600
  if (!this.token && !this.options.webSocketFactory)
585
601
  throw new Error("Pluno requires a token or tokenProvider");
586
602
  const s = Hn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
587
603
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
588
- this.socket === n && n.readyState === WebSocket.CONNECTING && (w("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
604
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (M("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
589
605
  }, nn), n.addEventListener("open", () => {
590
- this.socket !== n || (this.clearSocketConnectTimer(), w("web-sdk.agent", "Pluno socket opened", {
606
+ this.socket !== n || (this.clearSocketConnectTimer(), M("web-sdk.agent", "Pluno socket opened", {
591
607
  queuedClientEventCount: this.queuedClientEvents.length,
592
608
  isThinking: this.state.isThinking
593
609
  }), !(this.token ? this.sendNow({
@@ -597,19 +613,19 @@ class Kt {
597
613
  transportId: this.transportIdentity.transportId,
598
614
  pageUrl: location.href
599
615
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
600
- this.socket === n && (w("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
616
+ this.socket === n && (M("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
601
617
  }, rn));
602
618
  }), n.addEventListener("message", (r) => {
603
619
  this.socket === n && this.handleServerEvent(Jn(r.data));
604
620
  }), n.addEventListener("sendfailure", (r) => {
605
621
  if (this.socket !== n)
606
622
  return;
607
- const i = Yn(r?.detail?.data);
623
+ const i = Qn(r?.detail?.data);
608
624
  i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
609
625
  (o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
610
- ) && (this.queuedClientEvents.push(i), G(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
626
+ ) && (this.queuedClientEvents.push(i), V(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
611
627
  }), n.addEventListener("close", (r) => {
612
- this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (w("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
628
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (M("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
613
629
  code: typeof r?.code == "number" ? r.code : null,
614
630
  reason: typeof r?.reason == "string" ? r.reason : "",
615
631
  wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
@@ -617,7 +633,7 @@ class Kt {
617
633
  isThinking: this.state.isThinking
618
634
  }), this.setReconnectingState(), this.scheduleReconnect()));
619
635
  }), n.addEventListener("error", () => {
620
- this.socket !== n || this.state.status === "closed" || (w("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
636
+ this.socket !== n || this.state.status === "closed" || (M("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
621
637
  queuedClientEventCount: this.queuedClientEvents.length,
622
638
  isThinking: this.state.isThinking
623
639
  }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
@@ -640,12 +656,12 @@ class Kt {
640
656
  this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), 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.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
641
657
  }
642
658
  destroy() {
643
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Qr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
659
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Zr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
644
660
  for (const e of Object.values(this.listeners))
645
661
  e?.clear();
646
662
  }
647
663
  warmup(e = "panel_open") {
648
- const s = b(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
664
+ const s = _(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
649
665
  type: "runtime.warmup",
650
666
  reason: e,
651
667
  ...e === "composer_input" ? { warmupId: r?.event.warmupId ?? B() } : {},
@@ -672,7 +688,7 @@ class Kt {
672
688
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
673
689
  entrySurface: this.options.entrySurface,
674
690
  ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
675
- pageOrigin: b().origin
691
+ pageOrigin: _().origin
676
692
  }
677
693
  };
678
694
  this.authenticatedSocket === this.socket && this.sendNow(n) || (this.pendingWidgetLifecycleEvents.push(n), this.pendingWidgetLifecycleEvents.length > 20 && this.pendingWidgetLifecycleEvents.splice(0, this.pendingWidgetLifecycleEvents.length - 20));
@@ -680,7 +696,7 @@ class Kt {
680
696
  async sendMessage(e, s = {}) {
681
697
  const n = e.trim(), r = s.attachments ?? [];
682
698
  if (this.options.productVariant === "customer_embedded" && (r.forEach(cs), r.reduce(
683
- (S, _) => S + _.sizeBytes,
699
+ (T, N) => T + N.sizeBytes,
684
700
  0
685
701
  ) > jt))
686
702
  throw new Error("Embedded attachments must total at most 50 MB per message");
@@ -689,13 +705,30 @@ class Kt {
689
705
  return null;
690
706
  if (this.pendingClientMessageId)
691
707
  throw new Error("Wait for the current message to finish sending before sending another.");
692
- const o = b(), a = s.clientMessageId ?? B(), l = {
708
+ const o = _(), a = s.clientMessageId ?? B(), l = s.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
709
+ (S) => S.id === this.stagedProactiveSuggestionQuestionMessageId
710
+ ) ?? null : null, d = l ? {
711
+ id: `local-proactive-suggestion-question-${a}`,
712
+ role: "assistant",
713
+ phase: "final_answer",
714
+ content: l,
715
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
716
+ } : null, p = {
693
717
  id: `local-${a}`,
694
718
  role: "user",
695
719
  content: n,
696
720
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
697
721
  ...r.length > 0 ? { attachments: r } : {}
698
- }, c = this.state.messages.some((T) => T.id === l.id || T.clientMessageId === a), d = this.state.isThinking, p = this.state.taskStatus, y = this.state.pendingMessageStatus, f = this.state.turnPhase, u = this.state.messages, h = c ? this.state.messages : [...this.state.messages, l], g = {
722
+ }, m = this.state.messages.some((S) => S.id === p.id || S.clientMessageId === a), f = this.state.isThinking, u = this.state.taskStatus, h = this.state.pendingMessageStatus, g = this.state.turnPhase, y = this.state.messages, C = m ? this.state.messages : [
723
+ ...this.state.messages.map(
724
+ (S) => c && S.id === c.id ? {
725
+ ...S,
726
+ id: `local-proactive-suggestion-question-${a}`
727
+ } : S
728
+ ),
729
+ ...!c && d ? [d] : [],
730
+ p
731
+ ], w = {
699
732
  assistantDraft: this.state.assistantDraft,
700
733
  assistantDraftItemId: this.state.assistantDraftItemId,
701
734
  assistantDraftPhase: this.state.assistantDraftPhase,
@@ -704,8 +737,8 @@ class Kt {
704
737
  lastError: this.state.lastError
705
738
  };
706
739
  this.setState({
707
- messages: h,
708
- ...d ? {} : {
740
+ messages: C,
741
+ ...f ? {} : {
709
742
  assistantDraft: "",
710
743
  assistantDraftItemId: null,
711
744
  assistantDraftPhase: null,
@@ -713,36 +746,36 @@ class Kt {
713
746
  assistantDraftRunId: null
714
747
  },
715
748
  pendingMessageStatus: "sending",
716
- turnPhase: d ? f : "sending",
717
- isThinking: d,
749
+ turnPhase: f ? g : "sending",
750
+ isThinking: f,
718
751
  taskStatus: "working",
719
752
  isRetrying: !1,
720
753
  lastError: null
721
- }), c || this.emit("message", l);
754
+ }), m || (d && !c && this.emit("message", d), this.emit("message", p));
722
755
  try {
723
- const T = [];
724
- for (const S of i) {
725
- const _ = S.id ? this.attachmentFiles.get(S.id) : void 0;
726
- if (S.sandboxPath || S.storageKey) {
727
- T.push(S);
756
+ const S = [];
757
+ for (const T of i) {
758
+ const N = T.id ? this.attachmentFiles.get(T.id) : void 0;
759
+ if (T.sandboxPath || T.storageKey) {
760
+ S.push(T);
728
761
  continue;
729
762
  }
730
- if (!_)
731
- throw new Error(`Attachment bytes are unavailable for ${S.name}`);
732
- T.push(await this.uploadAttachmentForMessage({ file: _, attachment: S }));
763
+ if (!N)
764
+ throw new Error(`Attachment bytes are unavailable for ${T.name}`);
765
+ S.push(await this.uploadAttachmentForMessage({ file: N, attachment: T }));
733
766
  }
734
- i = T;
735
- } catch (T) {
767
+ i = S;
768
+ } catch (S) {
736
769
  throw this.setState({
737
- ...c ? {} : { messages: u },
738
- ...d ? {} : { ...g, isThinking: !1 },
739
- pendingMessageStatus: y,
740
- turnPhase: f,
741
- taskStatus: p
742
- }), T;
770
+ ...m ? {} : { messages: y },
771
+ ...f ? {} : { ...w, isThinking: !1 },
772
+ pendingMessageStatus: h,
773
+ turnPhase: g,
774
+ taskStatus: u
775
+ }), S;
743
776
  }
744
777
  this.retryableClientMessageId = null;
745
- const m = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, C = {
778
+ const b = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, D = {
746
779
  type: "chat.user_message",
747
780
  sessionId: this.state.sessionId ?? void 0,
748
781
  clientMessageId: a,
@@ -750,13 +783,14 @@ class Kt {
750
783
  invocation: Bn(s.invocation ?? s.initiatedBy),
751
784
  entrySurface: this.options.entrySurface,
752
785
  content: n,
753
- pageContent: m && ot() || void 0,
786
+ proactiveSuggestionQuestion: s.proactiveSuggestionQuestion,
787
+ pageContent: b && ot() || void 0,
754
788
  attachments: i.length > 0 ? i.map(Ee) : void 0,
755
789
  page: o,
756
790
  model: this.options.model,
757
791
  metadata: kt(this.options.metadata)
758
792
  };
759
- return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = C, this.send(C), this.schedulePendingDeliveryAck(a), a;
793
+ return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = D, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(D), this.schedulePendingDeliveryAck(a), a;
760
794
  }
761
795
  getModel() {
762
796
  return this.options.model;
@@ -777,10 +811,10 @@ class Kt {
777
811
  lastErrorCode: null
778
812
  }), this.send(n), this.schedulePendingDeliveryAck(s), !0;
779
813
  }
780
- return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
814
+ return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.recoveryExhaustionRequestedClientMessageIds.delete(s), this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
781
815
  }
782
816
  createLocalAttachment(e) {
783
- this.options.productVariant === "customer_embedded" && Zr(e);
817
+ this.options.productVariant === "customer_embedded" && ei(e);
784
818
  const s = B(), n = {
785
819
  id: s,
786
820
  name: e.name || "attachment",
@@ -789,18 +823,18 @@ class Kt {
789
823
  };
790
824
  this.attachmentFiles.set(s, e);
791
825
  const r = Date.now();
792
- return Ss({
826
+ return Ts({
793
827
  attachmentId: s,
794
828
  name: n.name,
795
829
  mimeType: n.mimeType,
796
830
  sizeBytes: n.sizeBytes,
797
831
  blob: e,
798
- origin: b().origin,
832
+ origin: _().origin,
799
833
  sessionId: this.state.sessionId ?? void 0,
800
834
  createdAt: r,
801
835
  lastUsedAt: r
802
836
  }).catch((i) => {
803
- w("web-sdk.attachments", "Failed to store Product Agent attachment", {
837
+ M("web-sdk.attachments", "Failed to store Product Agent attachment", {
804
838
  attachmentId: s,
805
839
  name: n.name,
806
840
  message: i instanceof Error ? i.message : String(i)
@@ -826,7 +860,7 @@ class Kt {
826
860
  name: e.name || "attachment",
827
861
  mimeType: r,
828
862
  sizeBytes: e.size,
829
- page: b(),
863
+ page: _(),
830
864
  model: this.options.model,
831
865
  metadata: kt(this.options.metadata),
832
866
  entrySurface: this.options.entrySurface
@@ -862,7 +896,7 @@ class Kt {
862
896
  storageKey: a.storageKey,
863
897
  lastUsedAt: Date.now()
864
898
  }).catch((l) => {
865
- w("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
899
+ M("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
866
900
  attachmentId: s.id,
867
901
  name: a.name,
868
902
  message: l instanceof Error ? l.message : String(l)
@@ -886,7 +920,7 @@ class Kt {
886
920
  const n = await this.fetchEmbedAttachmentUpload(e);
887
921
  if (n.ok)
888
922
  return await n.json();
889
- if (mi(n.status) && this.options.tokenProvider && !s) {
923
+ if (yi(n.status) && this.options.tokenProvider && !s) {
890
924
  s = !0;
891
925
  const r = await this.fetchEmbedAttachmentUpload(e);
892
926
  if (r.ok)
@@ -911,7 +945,7 @@ class Kt {
911
945
  if (!this.state.sessionId)
912
946
  return;
913
947
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
914
- const e = qr(
948
+ const e = Lr(
915
949
  this.state.messages,
916
950
  this.state.assistantDraftRespondsToUserMessageId,
917
951
  this.state.assistantDraftRunId,
@@ -951,11 +985,11 @@ class Kt {
951
985
  }
952
986
  startNewSession(e = {}) {
953
987
  const s = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
954
- !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.personalModelSelectionOverride = null, this.options.model = void 0), s && this.send({
988
+ !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.personalModelSelectionOverride = null, this.options.model = void 0), s && this.send({
955
989
  type: "session.reset",
956
990
  sessionId: this.state.sessionId ?? void 0,
957
991
  warmupId: n ?? void 0,
958
- page: b()
992
+ page: _()
959
993
  }), this.setState({
960
994
  sessionId: null,
961
995
  starterPrompts: [...this.state.starterPrompts],
@@ -982,7 +1016,7 @@ class Kt {
982
1016
  }), r = {
983
1017
  type: "sessions.list",
984
1018
  requestId: s,
985
- page: b(),
1019
+ page: _(),
986
1020
  ...e.cursor ? { cursor: e.cursor } : {},
987
1021
  ...e.limit ? { limit: e.limit } : {},
988
1022
  ...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
@@ -1012,7 +1046,7 @@ class Kt {
1012
1046
  !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId !== e && this.rememberCurrentRunAsDetached(), this.detachedSessionIds.delete(e), this.deferredDetachedSessionEvents.delete(e), !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), n && this.send({
1013
1047
  type: "session.reset",
1014
1048
  warmupId: n,
1015
- page: b()
1049
+ page: _()
1016
1050
  }), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.options.productVariant === "personal" && this.state.sessionId !== e && (this.personalModelSelectionOverride = null, this.options.model = void 0), this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionActivityRequestId = null, this.setState({
1017
1051
  sessionId: e,
1018
1052
  messages: [],
@@ -1032,7 +1066,7 @@ class Kt {
1032
1066
  type: "session.load",
1033
1067
  requestId: s,
1034
1068
  sessionId: e,
1035
- page: b()
1069
+ page: _()
1036
1070
  });
1037
1071
  }
1038
1072
  canLoadSessionHistoryOverHttp() {
@@ -1072,7 +1106,7 @@ class Kt {
1072
1106
  type: "session.load",
1073
1107
  requestId: s,
1074
1108
  sessionId: e,
1075
- page: b(),
1109
+ page: _(),
1076
1110
  subscribeOnly: !0
1077
1111
  }), n;
1078
1112
  }
@@ -1118,8 +1152,8 @@ class Kt {
1118
1152
  signal: AbortSignal.timeout(15e3)
1119
1153
  });
1120
1154
  if (!d.ok) {
1121
- const y = await d.text() || `History request failed (${d.status})`;
1122
- throw Qs(d.status) ? new Error(y) : new pe(y);
1155
+ const m = await d.text() || `History request failed (${d.status})`;
1156
+ throw Ys(d.status) ? new Error(m) : new pe(m);
1123
1157
  }
1124
1158
  const p = await d.json();
1125
1159
  if (!p?.session || !Array.isArray(p.items))
@@ -1132,7 +1166,7 @@ class Kt {
1132
1166
  } catch (o) {
1133
1167
  if (o instanceof pe)
1134
1168
  throw o;
1135
- w("web-sdk.history", "HTTP session history page failed; retrying", {
1169
+ M("web-sdk.history", "HTTP session history page failed; retrying", {
1136
1170
  sessionId: e,
1137
1171
  hasCursor: !!n,
1138
1172
  retryDelayMs: i,
@@ -1146,7 +1180,7 @@ class Kt {
1146
1180
  return;
1147
1181
  const i = n instanceof Error ? n.message : String(n);
1148
1182
  if (r) {
1149
- this.sessionActivityRequestId = null, w("web-sdk.history", "Background session activity hydration stopped", {
1183
+ this.sessionActivityRequestId = null, M("web-sdk.history", "Background session activity hydration stopped", {
1150
1184
  sessionId: s,
1151
1185
  message: i
1152
1186
  });
@@ -1158,7 +1192,7 @@ class Kt {
1158
1192
  message: i,
1159
1193
  requestId: e,
1160
1194
  sessionId: s
1161
- }), w("web-sdk.history", "HTTP session history page failed permanently", {
1195
+ }), M("web-sdk.history", "HTTP session history page failed permanently", {
1162
1196
  sessionId: s,
1163
1197
  message: i
1164
1198
  });
@@ -1166,7 +1200,7 @@ class Kt {
1166
1200
  send(e) {
1167
1201
  this.sendNow(q(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
1168
1202
  (r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
1169
- ) || this.queuedClientEvents.push(e), G(this.options.clientId, this.queuedClientEvents), this.setState({
1203
+ ) || this.queuedClientEvents.push(e), V(this.options.clientId, this.queuedClientEvents), this.setState({
1170
1204
  status: "reconnecting",
1171
1205
  ...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
1172
1206
  }), this.scheduleReconnect());
@@ -1184,7 +1218,7 @@ class Kt {
1184
1218
  try {
1185
1219
  return s.send(JSON.stringify(e)), He("client_event", e.type, mt(e)), !0;
1186
1220
  } catch (n) {
1187
- return w("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
1221
+ return M("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
1188
1222
  message: n instanceof Error ? n.message : String(n),
1189
1223
  queuedClientEventCount: this.queuedClientEvents.length,
1190
1224
  isThinking: this.state.isThinking
@@ -1216,7 +1250,7 @@ class Kt {
1216
1250
  }
1217
1251
  }));
1218
1252
  } catch (r) {
1219
- w("web-sdk.agent", "Pluno health signal send failed", {
1253
+ M("web-sdk.agent", "Pluno health signal send failed", {
1220
1254
  name: e,
1221
1255
  message: r instanceof Error ? r.message : String(r)
1222
1256
  });
@@ -1258,18 +1292,18 @@ class Kt {
1258
1292
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
1259
1293
  return;
1260
1294
  const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
1261
- G(this.options.clientId, this.queuedClientEvents);
1295
+ V(this.options.clientId, this.queuedClientEvents);
1262
1296
  for (let s = 0; s < e.length; s += 1) {
1263
1297
  const n = e[s];
1264
1298
  if (!this.sendNow(q(n))) {
1265
- this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), G(this.options.clientId, this.queuedClientEvents);
1299
+ this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), V(this.options.clientId, this.queuedClientEvents);
1266
1300
  return;
1267
1301
  }
1268
- G(this.options.clientId, this.queuedClientEvents);
1302
+ V(this.options.clientId, this.queuedClientEvents);
1269
1303
  }
1270
1304
  }
1271
1305
  resetForAuthenticationScopeChange() {
1272
- this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], G(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
1306
+ this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], V(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
1273
1307
  }
1274
1308
  flushPendingWidgetLifecycleEvents() {
1275
1309
  if (this.authenticatedSocket !== this.socket || this.socket?.readyState !== WebSocket.OPEN || this.pendingWidgetLifecycleEvents.length === 0)
@@ -1306,7 +1340,7 @@ class Kt {
1306
1340
  findStoppedTurnForEvent(e) {
1307
1341
  const s = e.type === "session.item" ? U(e.item) : null;
1308
1342
  return this.findStoppedTurn(
1309
- K(e) ?? this.state.sessionId,
1343
+ G(e) ?? this.state.sessionId,
1310
1344
  s ?? e
1311
1345
  );
1312
1346
  }
@@ -1320,7 +1354,7 @@ class Kt {
1320
1354
  respondsToUserMessageId: r,
1321
1355
  runId: i,
1322
1356
  stoppedAt: n,
1323
- stoppedCausalSequence: D(s),
1357
+ stoppedCausalSequence: v(s),
1324
1358
  toolCallIds: new Set(
1325
1359
  this.state.messages.filter(
1326
1360
  (a) => ze(a, r, i)
@@ -1341,11 +1375,11 @@ class Kt {
1341
1375
  if (!i || r?.type === "message" && r.role === "user" || we(r))
1342
1376
  return !0;
1343
1377
  if (i.stoppedCausalSequence !== null) {
1344
- const o = r ? D(r) : null;
1378
+ const o = r ? v(r) : null;
1345
1379
  return o === null || o <= i.stoppedCausalSequence;
1346
1380
  }
1347
1381
  if (i.stoppedAt) {
1348
- const o = M(n, "createdAt");
1382
+ const o = A(n, "createdAt");
1349
1383
  return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
1350
1384
  }
1351
1385
  return !1;
@@ -1365,14 +1399,14 @@ class Kt {
1365
1399
  this.pendingSessionSubscription = null, s.resolve(!1), n && (this.sessionHistoryHydration = null, this.handleServerEvent({ ...e, requestId: n.requestId }));
1366
1400
  return;
1367
1401
  }
1368
- if (this.sessionHistoryHydration && fe(e) && K(e) === this.sessionHistoryHydration.sessionId) {
1402
+ if (this.sessionHistoryHydration && fe(e) && G(e) === this.sessionHistoryHydration.sessionId) {
1369
1403
  this.sessionHistoryHydration.bufferedEvents.push(e);
1370
1404
  return;
1371
1405
  }
1372
1406
  if (e.type === "session.item" && this.rememberDurablyStoppedTurn(
1373
- M(e.item, "sessionId") ?? this.state.sessionId,
1407
+ A(e.item, "sessionId") ?? this.state.sessionId,
1374
1408
  U(e.item),
1375
- M(e.item, "createdAt")
1409
+ A(e.item, "createdAt")
1376
1410
  ), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
1377
1411
  if (e.type === "run.ack" && typeof e.sessionId == "string" && typeof e.clientMessageId == "string" && this.detachedClientMessageIds.delete(e.clientMessageId) && e.sessionId !== this.state.sessionId) {
1378
1412
  this.detachedSessionIds.add(e.sessionId), this.deferredDetachedSessionEvents.delete(e.sessionId);
@@ -1386,14 +1420,14 @@ class Kt {
1386
1420
  if (e.type === "run.ack") {
1387
1421
  if (this.shouldIgnoreStoppedTurnEvent(e))
1388
1422
  return;
1389
- const s = K(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null, r = s ? this.deferredDetachedSessionEvents.get(s) ?? [] : [];
1423
+ const s = G(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null, r = s ? this.deferredDetachedSessionEvents.get(s) ?? [] : [];
1390
1424
  s && this.deferredDetachedSessionEvents.delete(s), s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && (n === this.activeClientMessageId || n === this.pendingClientMessageId) && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(e);
1391
1425
  for (const i of r)
1392
1426
  this.handleServerEvent(i);
1393
1427
  return;
1394
1428
  }
1395
1429
  if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
1396
- const s = K(e);
1430
+ const s = G(e);
1397
1431
  if (s) {
1398
1432
  this.deferredSessionUpdatedSessionIds.add(s);
1399
1433
  return;
@@ -1420,7 +1454,7 @@ class Kt {
1420
1454
  const s = rr(e.user);
1421
1455
  this.authenticatedSocket !== this.socket && this.authenticatedUserId && s && s.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = s?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
1422
1456
  const n = Zn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
1423
- w("web-sdk.agent", "Received auth.ok appearance", {
1457
+ M("web-sdk.agent", "Received auth.ok appearance", {
1424
1458
  hasAppearance: r,
1425
1459
  rawAppearance: e.appearance,
1426
1460
  normalizedAppearance: n
@@ -1433,7 +1467,7 @@ class Kt {
1433
1467
  (o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !me() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
1434
1468
  type: "page.upsert",
1435
1469
  sessionId: this.state.sessionId,
1436
- page: b(),
1470
+ page: _(),
1437
1471
  model: this.options.model
1438
1472
  });
1439
1473
  return;
@@ -1446,7 +1480,7 @@ class Kt {
1446
1480
  return;
1447
1481
  }
1448
1482
  if (e.type === "conversation.state") {
1449
- const s = Array.isArray(e.items) ? e.items : [], n = M(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null, i = this.state.isLoadingSession && this.sessionLoadRequestId === null && r === null && n === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
1483
+ const s = Array.isArray(e.items) ? e.items : [], n = A(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null, i = this.state.isLoadingSession && this.sessionLoadRequestId === null && r === null && n === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
1450
1484
  if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && this.sessionLoadRequestId !== null && r === null || this.state.isLoadingSession && n !== this.state.sessionId)
1451
1485
  return;
1452
1486
  this.updatePersonalModelFromSession(e.session), n === this.state.sessionId && this.clearSessionLoadRequest();
@@ -1454,14 +1488,14 @@ class Kt {
1454
1488
  this.rememberDurablyStoppedTurn(
1455
1489
  n,
1456
1490
  U(E),
1457
- M(E, "createdAt")
1491
+ A(E, "createdAt")
1458
1492
  );
1459
- const o = ee(s), a = o === null ? null : s[o], l = U(a), c = this.findStoppedTurn(n, {
1493
+ const o = te(s), a = o === null ? null : s[o], l = U(a), c = this.findStoppedTurn(n, {
1460
1494
  clientMessageId: l?.clientMessageId,
1461
- respondsToUserMessageId: M(a, "id"),
1495
+ respondsToUserMessageId: A(a, "id"),
1462
1496
  runId: l?.runId
1463
- }), d = this.filterStoppedSnapshotItems(s, n), p = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, y = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, f = e.isRetrying === !0, u = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
1464
- p && y && (this.pendingClientMessageId = y);
1497
+ }), d = this.filterStoppedSnapshotItems(s, n), p = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, m = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, f = e.isRetrying === !0, u = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
1498
+ p && m && (this.pendingClientMessageId = m);
1465
1499
  let h = hr(
1466
1500
  e.assistantDraft
1467
1501
  );
@@ -1471,43 +1505,43 @@ class Kt {
1471
1505
  }) && (h = void 0);
1472
1506
  const g = h !== void 0;
1473
1507
  this.rememberUserMessageClientMessageIds(d);
1474
- const m = _r(d);
1475
- if (m) {
1476
- const E = Pr(d, m);
1477
- this.retryAttemptsByClientMessageId[m] = Math.max(
1478
- this.retryAttemptsByClientMessageId[m] ?? 0,
1508
+ const y = Pr(d);
1509
+ if (y) {
1510
+ const E = Ur(d, y);
1511
+ this.retryAttemptsByClientMessageId[y] = Math.max(
1512
+ this.retryAttemptsByClientMessageId[y] ?? 0,
1479
1513
  E
1480
1514
  );
1481
1515
  }
1482
1516
  const C = d.filter((E) => {
1483
1517
  const O = U(E);
1484
- return vt(O) ? !1 : !O || !m || !Re(O) ? !0 : Qe(d, O) !== m;
1485
- }), S = Qt(
1518
+ return vt(O) ? !1 : !O || !y || !Re(O) ? !0 : Ye(d, O) !== y;
1519
+ }), b = Yt(
1486
1520
  this.state.messages,
1487
1521
  Pt(C, this.options.backendUrl)
1488
- ), _ = Ut(S), v = g ? h?.content ?? "" : this.state.assistantDraft, R = g ? h?.itemId ?? null : this.state.assistantDraftItemId, te = g ? h?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, P = g ? h?.runId ?? null : this.state.assistantDraftRunId, F = d.some(
1522
+ ), D = Ut(b), S = g ? h?.content ?? "" : this.state.assistantDraft, T = g ? h?.itemId ?? null : this.state.assistantDraftItemId, N = g ? h?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, P = g ? h?.runId ?? null : this.state.assistantDraftRunId, z = d.some(
1489
1523
  (E, O) => Dt(
1490
1524
  U(E),
1491
- v,
1492
- R,
1493
- te,
1525
+ S,
1526
+ T,
1527
+ N,
1494
1528
  P,
1495
- Ur(d, O)
1529
+ vr(d, O)
1496
1530
  )
1497
- ), J = g ? h?.content ?? "" : this.state.assistantDraft, se = !!h?.content && !F, N = _ && (!J || F), ue = kr(S), z = N && ue ? "completed" : c ? "stopped" : N ? "failed" : null;
1498
- if (!_ && br(this.state.messages, d))
1531
+ ), Q = g ? h?.content ?? "" : this.state.assistantDraft, se = !!h?.content && !z, x = D && (!Q || z), ue = Cr(b), K = x && ue ? "completed" : c ? "stopped" : x ? "failed" : null;
1532
+ if (!D && _r(this.state.messages, d))
1499
1533
  return;
1500
- this.lastUserMessagePageUrl = Cr(d);
1501
- const x = N || c ? null : Ye(d);
1502
- if (this.latestRecoverableClientMessageId = x, ue && this.clearRetryTimers(), this.setState({
1503
- sessionId: M(e.session, "id") ?? this.state.sessionId,
1504
- messages: S,
1534
+ this.lastUserMessagePageUrl = br(d);
1535
+ const W = x || c ? null : Qe(d);
1536
+ if (this.latestRecoverableClientMessageId = W, ue && this.clearRetryTimers(), this.setState({
1537
+ sessionId: A(e.session, "id") ?? this.state.sessionId,
1538
+ messages: b,
1505
1539
  isLoadingSession: !1,
1506
1540
  ...p ? { pendingMessageStatus: p } : {},
1507
1541
  ...u ? { turnPhase: u } : {},
1508
1542
  isRetrying: f,
1509
- ...z && this.state.taskStatus === "working" ? { taskStatus: z } : {},
1510
- ...F ? {
1543
+ ...K && this.state.taskStatus === "working" ? { taskStatus: K } : {},
1544
+ ...z ? {
1511
1545
  assistantDraft: "",
1512
1546
  assistantDraftItemId: null,
1513
1547
  assistantDraftPhase: null,
@@ -1524,30 +1558,30 @@ class Kt {
1524
1558
  isThinking: !0,
1525
1559
  turnPhase: "thinking",
1526
1560
  lastError: null
1527
- } : N ? {
1561
+ } : x ? {
1528
1562
  isThinking: !1,
1529
1563
  status: "connected",
1530
1564
  lastError: null,
1531
1565
  lastErrorCode: null,
1532
1566
  lastErrorSecuritySettingsUrl: null
1533
- } : x ? {
1567
+ } : W ? {
1534
1568
  isThinking: !0,
1535
1569
  turnPhase: u ?? this.state.turnPhase ?? "starting",
1536
1570
  lastError: null
1537
1571
  } : {}
1538
- }), N)
1572
+ }), x)
1539
1573
  this.retryableClientMessageId = null, this.clearThinkingWatchdog();
1540
- else if (!c && (se || x)) {
1541
- if (x) {
1542
- this.activeClientMessageId = x;
1543
- const E = ee(d), O = E === null ? null : d[E];
1544
- this.activeResponseUserMessageId = M(O, "id");
1574
+ else if (!c && (se || W)) {
1575
+ if (W) {
1576
+ this.activeClientMessageId = W;
1577
+ const E = te(d), O = E === null ? null : d[E];
1578
+ this.activeResponseUserMessageId = A(O, "id");
1545
1579
  }
1546
1580
  this.markThinkingProgress();
1547
1581
  }
1548
- if (m) {
1549
- const E = M(e.session, "id") ?? this.state.sessionId;
1550
- E && this.retryAfterInterruptedRun(E, m);
1582
+ if (y) {
1583
+ const E = A(e.session, "id") ?? this.state.sessionId;
1584
+ E && this.retryAfterInterruptedRun(E, y);
1551
1585
  }
1552
1586
  i && n && window.setTimeout(() => {
1553
1587
  this.autoLoadSessionActivity(n);
@@ -1563,7 +1597,7 @@ class Kt {
1563
1597
  this.options.backendUrl
1564
1598
  );
1565
1599
  s === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
1566
- messages: Sr(this.state.messages, r)
1600
+ messages: wr(this.state.messages, r)
1567
1601
  });
1568
1602
  return;
1569
1603
  }
@@ -1585,7 +1619,7 @@ class Kt {
1585
1619
  }
1586
1620
  if (e.type === "session.updated") {
1587
1621
  this.clearRunAckResyncRetryTimer();
1588
- const s = M(e.session, "id");
1622
+ const s = A(e.session, "id");
1589
1623
  s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
1590
1624
  ...this.pendingComposerWarmup.event,
1591
1625
  sessionId: s
@@ -1599,7 +1633,7 @@ class Kt {
1599
1633
  const s = U(e.item);
1600
1634
  if (Re(s)) {
1601
1635
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1602
- const r = M(e.item, "sessionId") ?? this.state.sessionId, i = s ? L(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1636
+ const r = A(e.item, "sessionId") ?? this.state.sessionId, i = s ? L(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1603
1637
  if (r && a) {
1604
1638
  this.retryAfterInterruptedRun(r, a);
1605
1639
  return;
@@ -1611,10 +1645,10 @@ class Kt {
1611
1645
  }
1612
1646
  if (vt(s))
1613
1647
  return;
1614
- const n = Yt(e.item, this.options.backendUrl);
1648
+ const n = Qt(e.item, this.options.backendUrl);
1615
1649
  if (n) {
1616
- const r = Lr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1617
- n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), H(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Dr(s) && this.clearRunAckResyncRetryTimer();
1650
+ const r = Nr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1651
+ n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), $(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Or(s) && this.clearRunAckResyncRetryTimer();
1618
1652
  const o = Je(this.state.messages, n), a = Ut(o), l = Dt(
1619
1653
  s,
1620
1654
  this.state.assistantDraft,
@@ -1625,7 +1659,7 @@ class Kt {
1625
1659
  o,
1626
1660
  o.findIndex((p) => p.id === n.id)
1627
1661
  )
1628
- ), c = a && (!this.state.assistantDraft || l), d = Ae(n) && (c || H(n) && !this.state.isThinking && this.activeClientMessageId === null);
1662
+ ), c = a && (!this.state.assistantDraft || l), d = Ae(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
1629
1663
  this.setState({
1630
1664
  messages: o,
1631
1665
  ...l ? {
@@ -1697,7 +1731,7 @@ class Kt {
1697
1731
  );
1698
1732
  this.setState({
1699
1733
  sessionId: s,
1700
- messages: fr(
1734
+ messages: mr(
1701
1735
  l,
1702
1736
  typeof e.responseId == "string" ? e.responseId : null,
1703
1737
  n,
@@ -1720,9 +1754,9 @@ class Kt {
1720
1754
  if (s)
1721
1755
  this.nonTranscriptToolCallIds.add(s);
1722
1756
  else {
1723
- const n = Ir(e);
1757
+ const n = Sr(e);
1724
1758
  if (n) {
1725
- const r = mr(
1759
+ const r = yr(
1726
1760
  this.state.messages,
1727
1761
  n
1728
1762
  );
@@ -1789,13 +1823,13 @@ class Kt {
1789
1823
  this.state.messages,
1790
1824
  c,
1791
1825
  d
1792
- ), y = Er(
1826
+ ), m = kr(
1793
1827
  p,
1794
1828
  c,
1795
1829
  d
1796
1830
  );
1797
1831
  this.setState({
1798
- status: y ? "connected" : "error",
1832
+ status: m ? "connected" : "error",
1799
1833
  messages: p,
1800
1834
  assistantDraft: "",
1801
1835
  assistantDraftItemId: null,
@@ -1805,9 +1839,9 @@ class Kt {
1805
1839
  isThinking: !1,
1806
1840
  ...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
1807
1841
  isRetrying: !1,
1808
- lastError: y ? null : a.message,
1809
- lastErrorCode: y ? null : typeof e.code == "string" ? e.code : null,
1810
- lastErrorSecuritySettingsUrl: y ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
1842
+ lastError: m ? null : a.message,
1843
+ lastErrorCode: m ? null : typeof e.code == "string" ? e.code : null,
1844
+ lastErrorSecuritySettingsUrl: m ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
1811
1845
  }), this.clearThinkingWatchdog(), this.emit("error", a);
1812
1846
  }
1813
1847
  }
@@ -1823,19 +1857,19 @@ class Kt {
1823
1857
  shouldIgnoreBackgroundSessionEvent(e) {
1824
1858
  if (!this.options.keepRunsActiveOnSessionNavigation || !fe(e))
1825
1859
  return !1;
1826
- const s = K(e);
1860
+ const s = G(e);
1827
1861
  return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
1828
1862
  }
1829
1863
  shouldIgnoreDetachedSessionEvent(e) {
1830
1864
  if (this.options.keepRunsActiveOnSessionNavigation || !fe(e))
1831
1865
  return !1;
1832
- const s = K(e);
1866
+ const s = G(e);
1833
1867
  return !!(s && this.detachedSessionIds.has(s));
1834
1868
  }
1835
1869
  shouldDeferDetachedSessionEvent(e) {
1836
1870
  if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !fe(e))
1837
1871
  return !1;
1838
- const s = K(e);
1872
+ const s = G(e);
1839
1873
  if (!s || s === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(s))
1840
1874
  return !1;
1841
1875
  const n = this.deferredDetachedSessionEvents.get(s) ?? [];
@@ -1905,7 +1939,7 @@ class Kt {
1905
1939
  }, oe(n));
1906
1940
  }
1907
1941
  requestSessionRecoveryExhaustion(e, s) {
1908
- this.retryableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.recoveryExhaustionRequestedClientMessageIds.has(s) ? this.resyncThinkingSession() : (this.recoveryExhaustionRequestedClientMessageIds.add(s), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 })), this.scheduleThinkingWatchdog(St);
1942
+ this.retryableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.recoveryExhaustionRequestedClientMessageIds.has(s) ? this.resyncThinkingSession() : (this.recoveryExhaustionRequestedClientMessageIds.add(s), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 })), this.scheduleThinkingWatchdog(Tt);
1909
1943
  }
1910
1944
  clearRetryTimers() {
1911
1945
  for (const e of Object.values(this.retryTimersByClientMessageId))
@@ -1914,10 +1948,10 @@ class Kt {
1914
1948
  }
1915
1949
  rememberUserMessageClientMessageIds(e) {
1916
1950
  for (const s of e) {
1917
- const n = M(s, "id"), r = U(s);
1951
+ const n = A(s, "id"), r = U(s);
1918
1952
  n && r?.type === "message" && r.role === "user" && r.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof r.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId), r.clientMessageId === this.pendingClientMessageId && this.promotePendingDelivery(
1919
1953
  r.clientMessageId,
1920
- M(s, "sessionId") ?? this.state.sessionId,
1954
+ A(s, "sessionId") ?? this.state.sessionId,
1921
1955
  n,
1922
1956
  null
1923
1957
  ), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
@@ -1959,7 +1993,7 @@ class Kt {
1959
1993
  e.clear();
1960
1994
  }
1961
1995
  markThinkingProgress() {
1962
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Tt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1996
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(St), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1963
1997
  }
1964
1998
  scheduleThinkingWatchdog(e) {
1965
1999
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -2044,7 +2078,7 @@ class Kt {
2044
2078
  s,
2045
2079
  typeof e.runId == "string" ? e.runId : null
2046
2080
  ), !(!this.state.isThinking || !s) && this.setState({
2047
- messages: xr(
2081
+ messages: Br(
2048
2082
  this.state.messages,
2049
2083
  s
2050
2084
  )
@@ -2056,7 +2090,7 @@ class Kt {
2056
2090
  }, Mt);
2057
2091
  }
2058
2092
  recoverMissedRunAck(e) {
2059
- !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (w("web-sdk.agent", "Pluno run ack missed; resyncing session", {
2093
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (M("web-sdk.agent", "Pluno run ack missed; resyncing session", {
2060
2094
  sessionId: this.state.sessionId,
2061
2095
  clientMessageId: e
2062
2096
  }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(e));
@@ -2069,7 +2103,7 @@ class Kt {
2069
2103
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
2070
2104
  isThinking: !0,
2071
2105
  lastError: null
2072
- }), w("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
2106
+ }), M("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
2073
2107
  sessionId: this.state.sessionId,
2074
2108
  clientMessageId: e
2075
2109
  }), this.state.sessionId ? this.send({
@@ -2077,7 +2111,7 @@ class Kt {
2077
2111
  sessionId: this.state.sessionId,
2078
2112
  clientMessageId: e,
2079
2113
  automatic: !0
2080
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(Tt)));
2114
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(St)));
2081
2115
  }, oe(s, At)));
2082
2116
  }
2083
2117
  clearRunAckResyncRetryTimer() {
@@ -2091,13 +2125,13 @@ class Kt {
2091
2125
  return;
2092
2126
  const e = this.activeClientMessageId;
2093
2127
  if (!e) {
2094
- w("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
2128
+ M("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
2095
2129
  sessionId: this.state.sessionId
2096
2130
  }), this.reportHealthSignal("run_recovery_exhausted", {
2097
2131
  reason: "missing_client_message_id"
2098
2132
  }), this.setState({
2099
2133
  messages: this.state.messages.filter(
2100
- (r) => !X(r)
2134
+ (r) => !J(r)
2101
2135
  ),
2102
2136
  isThinking: !1,
2103
2137
  taskStatus: "failed",
@@ -2108,7 +2142,7 @@ class Kt {
2108
2142
  }
2109
2143
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
2110
2144
  if (n >= ie) {
2111
- w("web-sdk.agent", "Pluno run recovery retry exhausted", {
2145
+ M("web-sdk.agent", "Pluno run recovery retry exhausted", {
2112
2146
  sessionId: this.state.sessionId,
2113
2147
  clientMessageId: e
2114
2148
  }), this.state.sessionId ? this.requestSessionRecoveryExhaustion(this.state.sessionId, e) : (this.setState({
@@ -2120,18 +2154,18 @@ class Kt {
2120
2154
  return;
2121
2155
  }
2122
2156
  if (s < 1) {
2123
- this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1, w("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
2157
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = s + 1, M("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
2124
2158
  sessionId: this.state.sessionId,
2125
2159
  clientMessageId: e,
2126
2160
  resyncAttempts: s + 1
2127
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(St);
2161
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Tt);
2128
2162
  return;
2129
2163
  }
2130
2164
  this.setState({
2131
2165
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
2132
2166
  isThinking: !0,
2133
2167
  lastError: null
2134
- }), w("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
2168
+ }), M("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
2135
2169
  sessionId: this.state.sessionId,
2136
2170
  clientMessageId: e,
2137
2171
  retryAttempts: n + 1
@@ -2148,18 +2182,18 @@ class Kt {
2148
2182
  this.state.sessionId ? this.send({
2149
2183
  type: "page.upsert",
2150
2184
  sessionId: this.state.sessionId,
2151
- page: b(),
2185
+ page: _(),
2152
2186
  model: this.options.model
2153
2187
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
2154
2188
  }
2155
2189
  async executeToolCall(e) {
2156
- const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i = Q(
2190
+ const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i = Z(
2157
2191
  typeof e.summary == "string" ? e.summary : "Running browser tool"
2158
2192
  ), o = e.rawInput;
2159
2193
  if (!s || !n || !r)
2160
2194
  return;
2161
2195
  const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
2162
- if (!a && !l || !ri(o)) {
2196
+ if (!a && !l || !ii(o)) {
2163
2197
  this.setToolMessageLoading(n, !1), this.send({
2164
2198
  type: "tool.result",
2165
2199
  sessionId: s,
@@ -2225,7 +2259,7 @@ class Kt {
2225
2259
  }), Lt(this.options.clientId, this.activeBrowserToolCalls.values()));
2226
2260
  }
2227
2261
  setToolMessageLoading(e, s) {
2228
- const n = yr(
2262
+ const n = Ir(
2229
2263
  this.state.messages,
2230
2264
  e,
2231
2265
  s
@@ -2257,18 +2291,18 @@ class Kt {
2257
2291
  return e.ok === !1 ? sr(e) : null;
2258
2292
  }
2259
2293
  enableNetworkCapture() {
2260
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Sn((e) => {
2261
- ui(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
2294
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = Tn((e) => {
2295
+ di(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
2262
2296
  }));
2263
2297
  }
2264
2298
  enqueueNetworkEvent(e) {
2265
- this.queuedNetworkEvents.length >= dn || (this.queuedNetworkEvents.push(ci(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
2299
+ this.queuedNetworkEvents.length >= dn || (this.queuedNetworkEvents.push(ui(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
2266
2300
  this.networkBatchTimer = null;
2267
2301
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
2268
2302
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
2269
2303
  type: "network.batch",
2270
2304
  sessionId: this.state.sessionId ?? void 0,
2271
- page: b(),
2305
+ page: _(),
2272
2306
  events: s
2273
2307
  });
2274
2308
  }, un)));
@@ -2279,7 +2313,7 @@ class Kt {
2279
2313
  const e = In(this.reconnectAttempts);
2280
2314
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
2281
2315
  this.reconnectTimer = null, this.connect().catch((s) => {
2282
- w("web-sdk.agent", "Pluno reconnect failed; retrying", {
2316
+ M("web-sdk.agent", "Pluno reconnect failed; retrying", {
2283
2317
  message: s instanceof Error ? s.message : String(s),
2284
2318
  queuedClientEventCount: this.queuedClientEvents.length,
2285
2319
  isThinking: this.state.isThinking
@@ -2291,7 +2325,7 @@ class Kt {
2291
2325
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
2292
2326
  const e = this.socket;
2293
2327
  !e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
2294
- this.socket === e && (w("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
2328
+ this.socket === e && (M("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
2295
2329
  }, tn));
2296
2330
  }, en);
2297
2331
  }
@@ -2331,7 +2365,7 @@ class Kt {
2331
2365
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
2332
2366
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
2333
2367
  };
2334
- this.state = o, Kr(this.options.clientId, this.state), this.emit("state", this.getState()), He("state", this.state.status, {
2368
+ this.state = o, Gr(this.options.clientId, this.state), this.emit("state", this.getState()), He("state", this.state.status, {
2335
2369
  status: this.state.status,
2336
2370
  sessionId: this.state.sessionId,
2337
2371
  messageCount: this.state.messages.length,
@@ -2354,17 +2388,17 @@ class Kt {
2354
2388
  }
2355
2389
  }
2356
2390
  const je = /* @__PURE__ */ new WeakMap();
2357
- function Sn(t) {
2391
+ function Tn(t) {
2358
2392
  const e = window.__plunoProductAgentNetworkCapture ?? wn();
2359
2393
  return e.subscribers.add(t), () => {
2360
2394
  e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
2361
2395
  };
2362
2396
  }
2363
2397
  function wn() {
2364
- const t = /* @__PURE__ */ new Set(), e = (y) => {
2398
+ const t = /* @__PURE__ */ new Set(), e = (m) => {
2365
2399
  t.forEach((f) => {
2366
2400
  try {
2367
- f(y);
2401
+ f(m);
2368
2402
  } catch {
2369
2403
  }
2370
2404
  });
@@ -2373,35 +2407,35 @@ function wn() {
2373
2407
  let g;
2374
2408
  try {
2375
2409
  g = s.call(this, f, u);
2376
- } catch (m) {
2377
- throw m;
2410
+ } catch (y) {
2411
+ throw y;
2378
2412
  }
2379
2413
  try {
2380
- const m = f instanceof Request ? f : null, C = ii(f, m), T = us(u?.headers ?? m?.headers);
2381
- if (!Y(C, T, u?.body)) {
2382
- const _ = {
2414
+ const y = f instanceof Request ? f : null, C = oi(f, y), w = us(u?.headers ?? y?.headers);
2415
+ if (!Y(C, w, u?.body)) {
2416
+ const D = {
2383
2417
  requestId: Ke("fetch"),
2384
- url: W(C, $e),
2385
- method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
2386
- requestHeaders: T,
2418
+ url: H(C, $e),
2419
+ method: (u?.method ?? y?.method ?? "GET").toUpperCase(),
2420
+ requestHeaders: w,
2387
2421
  requestBody: xt(u?.body),
2388
2422
  resourceType: "fetch",
2389
2423
  startedAt: new Date(h).toISOString()
2390
2424
  };
2391
2425
  g.then(
2392
- (v) => {
2393
- oi(v, _, h, e).catch(() => {
2426
+ (S) => {
2427
+ ai(S, D, h, e).catch(() => {
2394
2428
  e({
2395
- ..._,
2396
- responseStatus: v.status,
2429
+ ...D,
2430
+ responseStatus: S.status,
2397
2431
  durationMs: Date.now() - h
2398
2432
  });
2399
2433
  });
2400
2434
  },
2401
- (v) => {
2435
+ (S) => {
2402
2436
  e({
2403
- ..._,
2404
- errorText: W(v instanceof Error ? v.message : String(v)),
2437
+ ...D,
2438
+ errorText: H(S instanceof Error ? S.message : String(S)),
2405
2439
  durationMs: Date.now() - h
2406
2440
  });
2407
2441
  }
@@ -2410,16 +2444,16 @@ function wn() {
2410
2444
  } catch {
2411
2445
  }
2412
2446
  return g;
2413
- }, a = function(f, u, h, g, m) {
2414
- const C = n.call(this, f, u, h ?? !0, g ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
2447
+ }, a = function(f, u, h, g, y) {
2448
+ const C = n.call(this, f, u, h ?? !0, g ?? void 0, y ?? void 0), w = typeof u == "string" ? u : u.toString();
2415
2449
  return je.set(this, {
2416
2450
  requestId: Ke("xhr"),
2417
2451
  method: String(f ?? "GET").toUpperCase(),
2418
- url: W(T, $e),
2452
+ url: H(w, $e),
2419
2453
  requestHeaders: {},
2420
2454
  startedAtMs: Date.now(),
2421
2455
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
2422
- excluded: Y(T)
2456
+ excluded: Y(w)
2423
2457
  }), C;
2424
2458
  }, l = function(f, u) {
2425
2459
  const h = r.call(this, f, u), g = je.get(this);
@@ -2432,7 +2466,7 @@ function wn() {
2432
2466
  () => {
2433
2467
  queueMicrotask(() => {
2434
2468
  try {
2435
- const h = hi(this.getAllResponseHeaders());
2469
+ const h = pi(this.getAllResponseHeaders());
2436
2470
  e({
2437
2471
  requestId: u.requestId,
2438
2472
  url: u.url,
@@ -2442,7 +2476,7 @@ function wn() {
2442
2476
  resourceType: "xhr",
2443
2477
  responseStatus: this.status,
2444
2478
  responseHeaders: h,
2445
- responseBody: li(this, h),
2479
+ responseBody: ci(this, h),
2446
2480
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
2447
2481
  startedAt: u.startedAt,
2448
2482
  durationMs: Date.now() - u.startedAtMs
@@ -2476,15 +2510,15 @@ function wn() {
2476
2510
  }
2477
2511
  let d = null;
2478
2512
  if (typeof PerformanceObserver < "u") {
2479
- d = new PerformanceObserver((y) => {
2480
- for (const f of y.getEntries()) {
2513
+ d = new PerformanceObserver((m) => {
2514
+ for (const f of m.getEntries()) {
2481
2515
  const u = f;
2482
2516
  if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || Y(u.name))
2483
2517
  continue;
2484
2518
  const h = performance.timeOrigin + u.startTime;
2485
2519
  e({
2486
2520
  requestId: Ke("resource"),
2487
- url: W(u.name, $e),
2521
+ url: H(u.name, $e),
2488
2522
  method: "GET",
2489
2523
  resourceType: "resource",
2490
2524
  responseStatus: u.responseStatus,
@@ -2523,7 +2557,7 @@ function wn() {
2523
2557
  };
2524
2558
  return window.__plunoProductAgentNetworkCapture = p, p;
2525
2559
  }
2526
- function w(t, e, s) {
2560
+ function M(t, e, s) {
2527
2561
  if (typeof window > "u")
2528
2562
  return;
2529
2563
  const n = window, r = {
@@ -2544,7 +2578,7 @@ function Mn(t) {
2544
2578
  function fe(t) {
2545
2579
  return t.type === "run.steered" || t.type === "run.ack" || t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
2546
2580
  }
2547
- function K(t) {
2581
+ function G(t) {
2548
2582
  if (typeof t.sessionId == "string")
2549
2583
  return t.sessionId;
2550
2584
  if (t.session && typeof t.session == "object") {
@@ -2783,7 +2817,7 @@ function Hn(t) {
2783
2817
  const e = new URL("/api/product-agent/embed/ws", t);
2784
2818
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
2785
2819
  }
2786
- function b() {
2820
+ function _() {
2787
2821
  const t = Jt();
2788
2822
  return {
2789
2823
  url: location.href,
@@ -2800,13 +2834,13 @@ function $n() {
2800
2834
  };
2801
2835
  }
2802
2836
  function jn(t) {
2803
- return Se.add(t), ge || (ge = Fn()), () => {
2804
- Se.delete(t), Se.size === 0 && (ge?.(), ge = null);
2837
+ return Te.add(t), ge || (ge = Fn()), () => {
2838
+ Te.delete(t), Te.size === 0 && (ge?.(), ge = null);
2805
2839
  };
2806
2840
  }
2807
2841
  function Fn() {
2808
2842
  const t = () => {
2809
- for (const i of Array.from(Se))
2843
+ for (const i of Array.from(Te))
2810
2844
  i();
2811
2845
  }, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
2812
2846
  const o = e(...i);
@@ -2826,8 +2860,8 @@ function ot() {
2826
2860
  if (!document.body)
2827
2861
  return "";
2828
2862
  const t = [], e = [], s = (h, g) => {
2829
- const m = Z(g);
2830
- !m || e.includes(m) || (t.push([h, m]), e.push(m));
2863
+ const y = ee(g);
2864
+ !y || e.includes(y) || (t.push([h, y]), e.push(y));
2831
2865
  };
2832
2866
  s("Selected text", window.getSelection()?.toString() ?? "");
2833
2867
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
@@ -2844,13 +2878,13 @@ ${g}`).join(`
2844
2878
  `, d = `
2845
2879
 
2846
2880
  Visible page text:
2847
- `, p = 12e3 - c.length - d.length, y = Math.min(a.length, 7900), f = l.slice(0, p - y), u = a.slice(0, p - f.length);
2881
+ `, p = 12e3 - c.length - d.length, m = Math.min(a.length, 7900), f = l.slice(0, p - m), u = a.slice(0, p - f.length);
2848
2882
  return `${c}${f}${d}${u}`;
2849
2883
  }
2850
2884
  function le(t) {
2851
2885
  return t.innerText ?? t.textContent ?? "";
2852
2886
  }
2853
- function Z(t) {
2887
+ function ee(t) {
2854
2888
  return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
2855
2889
  `).split(`
2856
2890
  `).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
@@ -2859,10 +2893,10 @@ function Z(t) {
2859
2893
  `).trim();
2860
2894
  }
2861
2895
  function Fe(t, e) {
2862
- let s = Z(t);
2896
+ let s = ee(t);
2863
2897
  for (const n of e)
2864
2898
  s = s.replace(n, "");
2865
- return Z(s);
2899
+ return ee(s);
2866
2900
  }
2867
2901
  function Gt(t) {
2868
2902
  const e = window.getComputedStyle(t);
@@ -2951,51 +2985,51 @@ function Kn(t, e) {
2951
2985
  "data-test",
2952
2986
  "data-qa",
2953
2987
  "data-cy"
2954
- ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = Gn(), y = new Set(t);
2955
- e && y.add(e);
2988
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = Gn(), m = new Set(t);
2989
+ e && m.add(e);
2956
2990
  let f = 0;
2957
- const u = (T) => {
2958
- const S = T.getAttribute("role");
2959
- return S && !o.has(S) ? S : "";
2960
- }, h = (T) => {
2961
- const S = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
2962
- return `${T.tagName.toLowerCase()}|${u(T)}|${S}`;
2963
- }, g = (T, S, _) => {
2964
- const v = (R, te) => {
2965
- const P = R.tagName.toLowerCase(), F = window.getComputedStyle(R), J = d.has(R);
2966
- if (f >= 1e3 && !J || _.has(R) || i.has(P) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || F.display === "none" || F.visibility === "hidden")
2991
+ const u = (w) => {
2992
+ const b = w.getAttribute("role");
2993
+ return b && !o.has(b) ? b : "";
2994
+ }, h = (w) => {
2995
+ const b = w.getAttribute("data-testid") || w.getAttribute("data-test") || w.getAttribute("data-qa") || w.getAttribute("data-cy") || "";
2996
+ return `${w.tagName.toLowerCase()}|${u(w)}|${b}`;
2997
+ }, g = (w, b, D) => {
2998
+ const S = (T, N) => {
2999
+ const P = T.tagName.toLowerCase(), z = window.getComputedStyle(T), Q = d.has(T);
3000
+ if (f >= 1e3 && !Q || D.has(T) || i.has(P) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || z.display === "none" || z.visibility === "hidden")
2967
3001
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2968
3002
  f += 1;
2969
- const se = u(R), N = Xt(R), ue = a.has(se) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(P) || P === "a" && R.hasAttribute("href"), de = Array.from(R.children).filter((I) => I instanceof HTMLElement), z = /* @__PURE__ */ new Map();
3003
+ const se = u(T), x = Xt(T), ue = a.has(se) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(P) || P === "a" && T.hasAttribute("href"), de = Array.from(T.children).filter((I) => I instanceof HTMLElement), K = /* @__PURE__ */ new Map();
2970
3004
  for (const I of de) {
2971
- const A = h(I);
2972
- z.set(A, (z.get(A) ?? 0) + 1);
3005
+ const R = h(I);
3006
+ K.set(R, (K.get(R) ?? 0) + 1);
2973
3007
  }
2974
- const x = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
3008
+ const W = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
2975
3009
  for (const I of de) {
2976
- const A = h(I), j = E.get(A) ?? 0;
2977
- E.set(A, j + 1), (z.get(A) ?? 0) > 8 && j >= 6 && !d.has(I) && x.set(A, (x.get(A) ?? 0) + 1);
3010
+ const R = h(I), F = E.get(R) ?? 0;
3011
+ E.set(R, F + 1), (K.get(R) ?? 0) > 8 && F >= 6 && !d.has(I) && W.set(R, (W.get(R) ?? 0) + 1);
2978
3012
  }
2979
3013
  const O = /* @__PURE__ */ new Map(), ct = /* @__PURE__ */ new Set(), Ue = [], ut = [];
2980
3014
  for (const I of de) {
2981
- const A = h(I), j = z.get(A) ?? 0, pt = O.get(A) ?? 0;
2982
- if (O.set(A, pt + 1), j > 8 && pt >= 6 && !d.has(I)) {
2983
- ct.has(A) || (Ue.push([`… ${x.get(A) ?? 0} similar siblings omitted`]), ct.add(A));
3015
+ const R = h(I), F = K.get(R) ?? 0, pt = O.get(R) ?? 0;
3016
+ if (O.set(R, pt + 1), F > 8 && pt >= 6 && !d.has(I)) {
3017
+ ct.has(R) || (Ue.push([`… ${W.get(R) ?? 0} similar siblings omitted`]), ct.add(R));
2984
3018
  continue;
2985
3019
  }
2986
- const gt = v(I, te);
3020
+ const gt = S(I, N);
2987
3021
  ut.push(gt), Ue.push(gt.lines);
2988
3022
  }
2989
3023
  const ve = [];
2990
- if (R.shadowRoot)
2991
- for (const I of Array.from(R.shadowRoot.children))
2992
- I instanceof HTMLElement && ve.push(v(I, te + 1));
2993
- const he = [...ut, ...ve], De = N.length > 0 || ue || he.some((I) => I.hasUsefulContent), dt = Z(
2994
- [N, ...he.map((I) => I.textPreview)].filter(Boolean).join(" ")
2995
- ).slice(0, 180), Is = R.hasAttribute("contenteditable") && (N.length > 0 || !R.querySelector("[contenteditable]")), ht = c.some((I) => R.hasAttribute(I)) || !!se || Is, Oe = (R.getClientRects().length > 0 || F.display === "contents") && (s.has(P) || ht || J) && (De || J) && (!r.has(P) || De || ht || J), qe = Oe ? 1 : 0, ne = [];
3024
+ if (T.shadowRoot)
3025
+ for (const I of Array.from(T.shadowRoot.children))
3026
+ I instanceof HTMLElement && ve.push(S(I, N + 1));
3027
+ const he = [...ut, ...ve], De = x.length > 0 || ue || he.some((I) => I.hasUsefulContent), dt = ee(
3028
+ [x, ...he.map((I) => I.textPreview)].filter(Boolean).join(" ")
3029
+ ).slice(0, 180), Is = T.hasAttribute("contenteditable") && (x.length > 0 || !T.querySelector("[contenteditable]")), ht = c.some((I) => T.hasAttribute(I)) || !!se || Is, Oe = (T.getClientRects().length > 0 || z.display === "contents") && (s.has(P) || ht || Q) && (De || Q) && (!r.has(P) || De || ht || Q), qe = Oe ? 1 : 0, ne = [];
2996
3030
  if (Oe) {
2997
- const I = he.some((j) => j.containsTextElement), A = n.has(P) && !I ? dt : N;
2998
- ne.push(Vt(R, l, o, A.slice(0, 180)));
3031
+ const I = he.some((F) => F.containsTextElement), R = n.has(P) && !I ? dt : x;
3032
+ ne.push(Vt(T, l, o, R.slice(0, 180)));
2999
3033
  }
3000
3034
  for (const I of Ue)
3001
3035
  ne.push(...ye(I, qe));
@@ -3003,10 +3037,10 @@ function Kn(t, e) {
3003
3037
  if (Le.length > 0) {
3004
3038
  const I = Le.slice(0, 20);
3005
3039
  Le.length > I.length && I.push("… shadow DOM omitted");
3006
- const A = P.includes("tooltip") || P.includes("popper") || P.includes("loader");
3007
- if (te < 2 && !A) {
3008
- const j = Oe ? "#shadow-root" : `${P} #shadow-root`;
3009
- ne.push(...ye([j, ...ye(I, 1)], qe));
3040
+ const R = P.includes("tooltip") || P.includes("popper") || P.includes("loader");
3041
+ if (N < 2 && !R) {
3042
+ const F = Oe ? "#shadow-root" : `${P} #shadow-root`;
3043
+ ne.push(...ye([F, ...ye(I, 1)], qe));
3010
3044
  } else
3011
3045
  ne.push(...ye(I, qe));
3012
3046
  }
@@ -3017,18 +3051,18 @@ function Kn(t, e) {
3017
3051
  containsTextElement: n.has(P) || he.some((I) => I.containsTextElement)
3018
3052
  };
3019
3053
  };
3020
- return [`--- ${S} ---`, ...v(T, 0).lines].join(`
3054
+ return [`--- ${b} ---`, ...S(w, 0).lines].join(`
3021
3055
  `);
3022
- }, m = [], C = Z(window.getSelection()?.toString() ?? "");
3023
- C && m.push(`--- selected text ---
3024
- ${JSON.stringify(C)}`), p.length > 0 && m.push(Vn(p, s, l, o));
3025
- for (const T of t.slice(0, 3))
3026
- m.push(g(T, "active overlay DOM", /* @__PURE__ */ new Set()));
3027
- if (e && m.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
3028
- const T = e || t.length ? "other visible DOM" : "visible DOM";
3029
- m.push(g(document.body, T, y));
3030
- }
3031
- return m.join(`
3056
+ }, y = [], C = ee(window.getSelection()?.toString() ?? "");
3057
+ C && y.push(`--- selected text ---
3058
+ ${JSON.stringify(C)}`), p.length > 0 && y.push(Vn(p, s, l, o));
3059
+ for (const w of t.slice(0, 3))
3060
+ y.push(g(w, "active overlay DOM", /* @__PURE__ */ new Set()));
3061
+ if (e && y.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
3062
+ const w = e || t.length ? "other visible DOM" : "visible DOM";
3063
+ y.push(g(document.body, w, m));
3064
+ }
3065
+ return y.join(`
3032
3066
 
3033
3067
  `);
3034
3068
  }
@@ -3061,8 +3095,8 @@ function Gn() {
3061
3095
  let p = a;
3062
3096
  for (; p; ) {
3063
3097
  t.add(p);
3064
- const y = p.getRootNode();
3065
- p = p.parentElement ?? (y instanceof ShadowRoot && y.host instanceof HTMLElement ? y.host : null);
3098
+ const m = p.getRootNode();
3099
+ p = p.parentElement ?? (m instanceof ShadowRoot && m.host instanceof HTMLElement ? m.host : null);
3066
3100
  }
3067
3101
  };
3068
3102
  let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
@@ -3124,7 +3158,7 @@ function ye(t, e) {
3124
3158
  return t.map((n) => `${s}${n}`);
3125
3159
  }
3126
3160
  function Xt(t) {
3127
- return Z(
3161
+ return ee(
3128
3162
  Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
3129
3163
  );
3130
3164
  }
@@ -3171,7 +3205,7 @@ function Jn(t) {
3171
3205
  return { type: "error", message: "Invalid server event" };
3172
3206
  }
3173
3207
  }
3174
- function Yn(t) {
3208
+ function Qn(t) {
3175
3209
  if (typeof t != "string")
3176
3210
  return null;
3177
3211
  try {
@@ -3187,7 +3221,7 @@ function _t(t, e) {
3187
3221
  const s = t[e];
3188
3222
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
3189
3223
  }
3190
- function Qn(t) {
3224
+ function Yn(t) {
3191
3225
  return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
3192
3226
  }
3193
3227
  function Zn(t) {
@@ -3246,20 +3280,20 @@ function rr(t) {
3246
3280
  }
3247
3281
  function Pt(t, e) {
3248
3282
  return Array.isArray(t) ? Ze(
3249
- t.map((s) => Yt(s, e)).filter((s) => s !== null)
3283
+ t.map((s) => Qt(s, e)).filter((s) => s !== null)
3250
3284
  ) : [];
3251
3285
  }
3252
3286
  function ir(t) {
3253
3287
  return Array.isArray(t) ? t.flatMap((e) => {
3254
3288
  if (!e || typeof e != "object")
3255
3289
  return [];
3256
- const s = e, n = M(s, "id"), r = M(s, "createdAt"), i = M(s, "updatedAt"), o = M(s, "lastActiveAt");
3290
+ const s = e, n = A(s, "id"), r = A(s, "createdAt"), i = A(s, "updatedAt"), o = A(s, "lastActiveAt");
3257
3291
  return !n || !r || !i || !o ? [] : [
3258
3292
  {
3259
3293
  id: n,
3260
- title: M(s, "title"),
3261
- customTitle: M(s, "customTitle"),
3262
- firstUserMessage: M(s, "firstUserMessage"),
3294
+ title: A(s, "title"),
3295
+ customTitle: A(s, "customTitle"),
3296
+ firstUserMessage: A(s, "firstUserMessage"),
3263
3297
  currentPage: s.currentPage ?? null,
3264
3298
  createdAt: r,
3265
3299
  updatedAt: i,
@@ -3270,7 +3304,7 @@ function ir(t) {
3270
3304
  ];
3271
3305
  }) : [];
3272
3306
  }
3273
- function Yt(t, e) {
3307
+ function Qt(t, e) {
3274
3308
  if (!t || typeof t != "object")
3275
3309
  return null;
3276
3310
  const s = t, n = s.data;
@@ -3289,7 +3323,7 @@ function Yt(t, e) {
3289
3323
  e
3290
3324
  ),
3291
3325
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3292
- ...D(r) !== null ? { causalSequence: D(r) } : {},
3326
+ ...v(r) !== null ? { causalSequence: v(r) } : {},
3293
3327
  respondsToUserMessageId: L(r) ?? void 0,
3294
3328
  ...k(r) ? { runId: k(r) } : {},
3295
3329
  attachments: as(r.attachments, e)
@@ -3300,6 +3334,9 @@ function Yt(t, e) {
3300
3334
  }), typeof r.clientMessageId == "string" && Object.defineProperty(o, "clientMessageId", {
3301
3335
  value: r.clientMessageId,
3302
3336
  enumerable: !1
3337
+ }), typeof r.proactiveSuggestionClientMessageId == "string" && Object.defineProperty(o, "proactiveSuggestionClientMessageId", {
3338
+ value: r.proactiveSuggestionClientMessageId,
3339
+ enumerable: !1
3303
3340
  }), o;
3304
3341
  }
3305
3342
  if (r.type === "function_call_output") {
@@ -3338,7 +3375,7 @@ function Yt(t, e) {
3338
3375
  role: "tool",
3339
3376
  content: `Connect ${a.appName} to continue`,
3340
3377
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3341
- ...D(r) !== null ? { causalSequence: D(r) } : {},
3378
+ ...v(r) !== null ? { causalSequence: v(r) } : {},
3342
3379
  respondsToUserMessageId: L(r) ?? void 0,
3343
3380
  ...k(r) ? { runId: k(r) } : {},
3344
3381
  dataType: "function_call_output",
@@ -3350,7 +3387,7 @@ function Yt(t, e) {
3350
3387
  role: "tool",
3351
3388
  content: "Connect WhatsApp to continue",
3352
3389
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3353
- ...D(r) !== null ? { causalSequence: D(r) } : {},
3390
+ ...v(r) !== null ? { causalSequence: v(r) } : {},
3354
3391
  respondsToUserMessageId: L(r) ?? void 0,
3355
3392
  ...k(r) ? { runId: k(r) } : {},
3356
3393
  dataType: "function_call_output",
@@ -3364,7 +3401,7 @@ function Yt(t, e) {
3364
3401
  role: "tool",
3365
3402
  content: r.type === "mcp_call" ? or(r) : ur(r),
3366
3403
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3367
- ...D(r) !== null ? { causalSequence: D(r) } : {},
3404
+ ...v(r) !== null ? { causalSequence: v(r) } : {},
3368
3405
  respondsToUserMessageId: L(r) ?? void 0,
3369
3406
  ...k(r) ? { runId: k(r) } : {},
3370
3407
  dataType: String(r.type),
@@ -3376,7 +3413,7 @@ function Yt(t, e) {
3376
3413
  role: "system",
3377
3414
  content: cr(r),
3378
3415
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3379
- ...D(r) !== null ? { causalSequence: D(r) } : {},
3416
+ ...v(r) !== null ? { causalSequence: v(r) } : {},
3380
3417
  respondsToUserMessageId: L(r) ?? void 0,
3381
3418
  ...k(r) ? { runId: k(r) } : {},
3382
3419
  dataType: String(r.type),
@@ -3441,18 +3478,18 @@ function ur(t) {
3441
3478
  }
3442
3479
  function dr(t) {
3443
3480
  if (typeof t.summary == "string" && t.summary.trim().length > 0)
3444
- return Q(t.summary);
3481
+ return Z(t.summary);
3445
3482
  if (typeof t.arguments == "string")
3446
3483
  try {
3447
3484
  const e = JSON.parse(t.arguments);
3448
3485
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
3449
- return Q(e.summary);
3486
+ return Z(e.summary);
3450
3487
  } catch {
3451
- return typeof t.name == "string" && t.name.trim().length > 0 ? Q(t.name) : "🛠️ Run tool";
3488
+ return typeof t.name == "string" && t.name.trim().length > 0 ? Z(t.name) : "🛠️ Run tool";
3452
3489
  }
3453
- return typeof t.name == "string" && t.name.trim().length > 0 ? Q(t.name) : "🛠️ Run tool";
3490
+ return typeof t.name == "string" && t.name.trim().length > 0 ? Z(t.name) : "🛠️ Run tool";
3454
3491
  }
3455
- function Q(t) {
3492
+ function Z(t) {
3456
3493
  const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
3457
3494
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
3458
3495
  }
@@ -3475,7 +3512,7 @@ function ae(t) {
3475
3512
  const e = t.callId ?? t.call_id;
3476
3513
  return typeof e == "string" && e ? e : null;
3477
3514
  }
3478
- function D(t) {
3515
+ function v(t) {
3479
3516
  return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
3480
3517
  }
3481
3518
  function pr(t) {
@@ -3488,8 +3525,11 @@ function pr(t) {
3488
3525
  }
3489
3526
  function Je(t, e) {
3490
3527
  const s = es(t, e), n = Tr(
3491
- gr(
3492
- Rr(t, e),
3528
+ fr(
3529
+ Er(
3530
+ gr(t, e),
3531
+ e
3532
+ ),
3493
3533
  s
3494
3534
  ),
3495
3535
  s
@@ -3502,6 +3542,16 @@ function Je(t, e) {
3502
3542
  return i[r] = s, Ze(i);
3503
3543
  }
3504
3544
  function gr(t, e) {
3545
+ const s = e.proactiveSuggestionClientMessageId;
3546
+ if (!s)
3547
+ return t;
3548
+ const n = `local-proactive-suggestion-question-${s}`, r = t.findIndex((o) => o.id === n);
3549
+ if (r < 0)
3550
+ return t;
3551
+ const i = [...t];
3552
+ return i[r] = e, i;
3553
+ }
3554
+ function fr(t, e) {
3505
3555
  const s = e.assistantDraftItemId;
3506
3556
  return s ? t.map(
3507
3557
  (n) => n.dataType === "assistant_draft" && n.id === s ? e : n
@@ -3510,7 +3560,7 @@ function gr(t, e) {
3510
3560
  function ze(t, e, s) {
3511
3561
  return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
3512
3562
  }
3513
- function fr(t, e, s, n) {
3563
+ function mr(t, e, s, n) {
3514
3564
  if (s === null) return t;
3515
3565
  let r = -1;
3516
3566
  for (let o = t.length - 1; o >= 0; o -= 1) {
@@ -3527,7 +3577,7 @@ function fr(t, e, s, n) {
3527
3577
  respondsToUserMessageId: s
3528
3578
  }, i;
3529
3579
  }
3530
- function mr(t, e) {
3580
+ function yr(t, e) {
3531
3581
  const s = t.findIndex(
3532
3582
  (r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
3533
3583
  );
@@ -3544,19 +3594,19 @@ function mr(t, e) {
3544
3594
  ...n[s].runId ? {} : { runId: e.runId }
3545
3595
  }, n;
3546
3596
  }
3547
- function yr(t, e, s) {
3597
+ function Ir(t, e, s) {
3548
3598
  let n = !1;
3549
3599
  const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
3550
3600
  return n ? r : t;
3551
3601
  }
3552
- function Ir(t) {
3602
+ function Sr(t) {
3553
3603
  if (t.hiddenFromTranscript === !0)
3554
3604
  return null;
3555
3605
  const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
3556
3606
  return !e || !s ? null : {
3557
3607
  id: `transient-activity:${e}`,
3558
3608
  role: "tool",
3559
- content: Q(
3609
+ content: Z(
3560
3610
  typeof t.summary == "string" ? t.summary : "Running browser tool"
3561
3611
  ),
3562
3612
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3578,7 +3628,7 @@ function Tr(t, e) {
3578
3628
  const n = (i) => i.id === `transient-activity:${e.callId}` && i.callId === e.callId || s && i.id.startsWith("transient-activity:") && i.toolName === "browser_tabs" && !!i.runId && i.runId === e.runId, r = t.findIndex(n);
3579
3629
  return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
3580
3630
  }
3581
- function Qt(t, e) {
3631
+ function Yt(t, e) {
3582
3632
  return vs(
3583
3633
  t,
3584
3634
  e.map(
@@ -3587,23 +3637,23 @@ function Qt(t, e) {
3587
3637
  Zt
3588
3638
  );
3589
3639
  }
3590
- function Sr(t, e) {
3640
+ function wr(t, e) {
3591
3641
  const s = new Map(t.map((n) => [n.id, n]));
3592
3642
  for (const n of e)
3593
3643
  s.set(n.id, n);
3594
- return Qt(
3644
+ return Yt(
3595
3645
  t,
3596
3646
  [...s.values()]
3597
- ).sort(wr);
3647
+ ).sort(Mr);
3598
3648
  }
3599
- function wr(t, e) {
3649
+ function Mr(t, e) {
3600
3650
  if ((t.respondsToUserMessageId !== void 0 && t.respondsToUserMessageId === e.respondsToUserMessageId || t.respondsToUserMessageId === void 0 && e.respondsToUserMessageId === void 0 && t.runId !== void 0 && t.runId === e.runId) && t.causalSequence !== void 0 && e.causalSequence !== void 0 && t.causalSequence !== e.causalSequence)
3601
3651
  return t.causalSequence - e.causalSequence;
3602
3652
  const n = Date.parse(t.createdAt) - Date.parse(e.createdAt);
3603
3653
  return Number.isNaN(n) ? 0 : n;
3604
3654
  }
3605
3655
  function Zt(t) {
3606
- const e = V(t) ?? void 0, s = t.assistantDraftItemId, n = [
3656
+ const e = X(t) ?? void 0, s = t.assistantDraftItemId, n = [
3607
3657
  ...t.callId ? [`call:${t.callId}`] : [],
3608
3658
  ...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
3609
3659
  ];
@@ -3629,22 +3679,22 @@ function es(t, e) {
3629
3679
  if (!s?.attachments?.length)
3630
3680
  return e;
3631
3681
  const n = e.attachments.map((o) => {
3632
- const a = Mr(s.attachments ?? [], o);
3633
- return a ? Ar(o, a) : o;
3634
- }), r = { ...e, attachments: n }, i = V(e);
3682
+ const a = Ar(s.attachments ?? [], o);
3683
+ return a ? Rr(o, a) : o;
3684
+ }), r = { ...e, attachments: n }, i = X(e);
3635
3685
  return i && Object.defineProperty(r, "clientMessageId", {
3636
3686
  value: i,
3637
3687
  enumerable: !1
3638
3688
  }), r;
3639
3689
  }
3640
- function Mr(t, e) {
3690
+ function Ar(t, e) {
3641
3691
  return e.id ? t.find((s) => s.id === e.id) ?? null : null;
3642
3692
  }
3643
- function Ar(t, e) {
3693
+ function Rr(t, e) {
3644
3694
  const { previewUrl: s } = e;
3645
3695
  return s ? { ...t, previewUrl: s } : t;
3646
3696
  }
3647
- function Rr(t, e) {
3697
+ function Er(t, e) {
3648
3698
  if (e.role !== "user")
3649
3699
  return t;
3650
3700
  const s = t.findIndex(
@@ -3656,13 +3706,13 @@ function Rr(t, e) {
3656
3706
  return n.splice(s, 1), n;
3657
3707
  }
3658
3708
  function ts(t, e) {
3659
- const s = V(t), n = V(e);
3709
+ const s = X(t), n = X(e);
3660
3710
  return s && n ? s === n : t.content === e.content;
3661
3711
  }
3662
3712
  function _e(t) {
3663
3713
  return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
3664
3714
  }
3665
- function V(t) {
3715
+ function X(t) {
3666
3716
  const e = t.clientMessageId;
3667
3717
  if (e)
3668
3718
  return e;
@@ -3683,7 +3733,7 @@ function Ut(t) {
3683
3733
  for (let r = t.length - 1; r > e; r -= 1) {
3684
3734
  const i = t[r];
3685
3735
  if (!i.respondsToUserMessageId) {
3686
- if (H(i))
3736
+ if ($(i))
3687
3737
  return !0;
3688
3738
  if (i.role === "system") {
3689
3739
  if (i.dataType === "run_error")
@@ -3695,10 +3745,10 @@ function Ut(t) {
3695
3745
  }
3696
3746
  return !1;
3697
3747
  }
3698
- function Er(t, e, s) {
3748
+ function kr(t, e, s) {
3699
3749
  const n = new Set(
3700
3750
  t.filter(
3701
- (r) => r.role === "user" && e !== null && V(r) === e
3751
+ (r) => r.role === "user" && e !== null && X(r) === e
3702
3752
  ).map((r) => r.id)
3703
3753
  );
3704
3754
  return t.some((r, i) => {
@@ -3715,14 +3765,14 @@ function Er(t, e, s) {
3715
3765
  return !1;
3716
3766
  });
3717
3767
  }
3718
- function kr(t) {
3768
+ function Cr(t) {
3719
3769
  const e = ss(t);
3720
3770
  if (e === null)
3721
- return t.some(H);
3771
+ return t.some($);
3722
3772
  const s = t[e].id;
3723
3773
  return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
3724
- (n) => n.respondsToUserMessageId === s && H(n)
3725
- ) : t.slice(e + 1).some(H);
3774
+ (n) => n.respondsToUserMessageId === s && $(n)
3775
+ ) : t.slice(e + 1).some($);
3726
3776
  }
3727
3777
  function ss(t) {
3728
3778
  for (let e = t.length - 1; e >= 0; e -= 1)
@@ -3731,9 +3781,9 @@ function ss(t) {
3731
3781
  return null;
3732
3782
  }
3733
3783
  function Ae(t) {
3734
- return H(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
3784
+ return $(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
3735
3785
  }
3736
- function ee(t) {
3786
+ function te(t) {
3737
3787
  for (let e = t.length - 1; e >= 0; e -= 1) {
3738
3788
  const s = t[e];
3739
3789
  if (!s || typeof s != "object")
@@ -3747,8 +3797,8 @@ function ee(t) {
3747
3797
  }
3748
3798
  return null;
3749
3799
  }
3750
- function Cr(t) {
3751
- const e = ee(t);
3800
+ function br(t) {
3801
+ const e = te(t);
3752
3802
  if (e === null)
3753
3803
  return null;
3754
3804
  const n = U(t[e])?.page;
@@ -3769,8 +3819,8 @@ function Re(t) {
3769
3819
  function vt(t) {
3770
3820
  return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
3771
3821
  }
3772
- function br(t, e) {
3773
- const s = ee(e);
3822
+ function _r(t, e) {
3823
+ const s = te(e);
3774
3824
  if (s === null)
3775
3825
  return !1;
3776
3826
  const n = e[s], r = n && typeof n == "object" ? n.id : null;
@@ -3781,8 +3831,8 @@ function br(t, e) {
3781
3831
  (o) => o.respondsToUserMessageId === r && Ae(o)
3782
3832
  ) : t.slice(i + 1).some(Ae);
3783
3833
  }
3784
- function Ye(t) {
3785
- const e = ee(t);
3834
+ function Qe(t) {
3835
+ const e = te(t);
3786
3836
  if (e === null)
3787
3837
  return null;
3788
3838
  const s = t[e];
@@ -3794,8 +3844,8 @@ function Ye(t) {
3794
3844
  const r = n.clientMessageId;
3795
3845
  return typeof r == "string" ? r : null;
3796
3846
  }
3797
- function _r(t) {
3798
- const e = ee(t);
3847
+ function Pr(t) {
3848
+ const e = te(t);
3799
3849
  if (e === null)
3800
3850
  return null;
3801
3851
  for (let s = t.length - 1; s > e; s -= 1) {
@@ -3809,22 +3859,22 @@ function _r(t) {
3809
3859
  if (i.type === "message" && i.role === "assistant")
3810
3860
  return null;
3811
3861
  if (i.type === "run_error")
3812
- return i.retryable !== !0 ? null : Qe(t, i) ?? Ye(t);
3862
+ return i.retryable !== !0 ? null : Ye(t, i) ?? Qe(t);
3813
3863
  if (i.type === "run_status")
3814
- return i.status === "interrupted" && i.retryable === !0 ? Qe(t, i) ?? Ye(t) : null;
3864
+ return i.status === "interrupted" && i.retryable === !0 ? Ye(t, i) ?? Qe(t) : null;
3815
3865
  }
3816
3866
  return null;
3817
3867
  }
3818
- function Qe(t, e) {
3868
+ function Ye(t, e) {
3819
3869
  if (typeof e.clientMessageId == "string")
3820
3870
  return e.clientMessageId;
3821
3871
  const s = L(e);
3822
3872
  if (!s)
3823
3873
  return null;
3824
- const n = t.find((i) => M(i, "id") === s), r = U(n);
3874
+ const n = t.find((i) => A(i, "id") === s), r = U(n);
3825
3875
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
3826
3876
  }
3827
- function Pr(t, e) {
3877
+ function Ur(t, e) {
3828
3878
  let s = 0;
3829
3879
  for (const n of t) {
3830
3880
  if (!n || typeof n != "object")
@@ -3838,7 +3888,7 @@ function Pr(t, e) {
3838
3888
  return s;
3839
3889
  }
3840
3890
  function Dt(t, e, s, n, r, i) {
3841
- if (!e || !vr(t))
3891
+ if (!e || !Dr(t))
3842
3892
  return !1;
3843
3893
  const o = t;
3844
3894
  if (Re(o) || s !== null && typeof o.id == "string" && o.id !== s)
@@ -3846,11 +3896,11 @@ function Dt(t, e, s, n, r, i) {
3846
3896
  const a = L(o);
3847
3897
  return n !== null ? a !== null ? a === n : r !== null && k(o) === r && i === n : r === null || k(o) === r;
3848
3898
  }
3849
- function Ur(t, e) {
3899
+ function vr(t, e) {
3850
3900
  for (let s = e - 1; s >= 0; s -= 1) {
3851
3901
  const n = U(t[s]);
3852
3902
  if (n?.type === "message" && n.role === "user")
3853
- return M(t[s], "id");
3903
+ return A(t[s], "id");
3854
3904
  }
3855
3905
  return null;
3856
3906
  }
@@ -3860,38 +3910,38 @@ function ns(t, e) {
3860
3910
  return t[s].id;
3861
3911
  return null;
3862
3912
  }
3863
- function vr(t) {
3913
+ function Dr(t) {
3864
3914
  if (!t || typeof t != "object")
3865
3915
  return !1;
3866
3916
  const e = t;
3867
3917
  return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
3868
3918
  }
3869
- function H(t) {
3919
+ function $(t) {
3870
3920
  return t.role === "assistant" && t.phase !== "commentary";
3871
3921
  }
3872
- function Dr(t) {
3922
+ function Or(t) {
3873
3923
  if (!t || typeof t != "object")
3874
3924
  return !1;
3875
3925
  const e = t;
3876
3926
  return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
3877
3927
  }
3878
3928
  function Ze(t) {
3879
- return t.filter((e, s) => X(e) ? !Fr(t, s) && !rs(t, s) && !$r(t, s) && !jr(t, s) : Or(e) ? e.retryable === !0 && Hr(t, s) ? !1 : !Wr(t, s) : !0);
3929
+ return t.filter((e, s) => J(e) ? !zr(t, s) && !rs(t, s) && !jr(t, s) && !Fr(t, s) : qr(e) ? e.retryable === !0 && $r(t, s) ? !1 : !Hr(t, s) : !0);
3880
3930
  }
3881
- function Or(t) {
3931
+ function qr(t) {
3882
3932
  return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
3883
3933
  }
3884
- function X(t) {
3934
+ function J(t) {
3885
3935
  return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
3886
3936
  }
3887
- function qr(t, e, s, n) {
3937
+ function Lr(t, e, s, n) {
3888
3938
  const r = t.findIndex(
3889
- (l, c) => X(l) && !rs(t, c)
3939
+ (l, c) => J(l) && !rs(t, c)
3890
3940
  ), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
3891
3941
  (l) => l.role === "user" && l.id === o
3892
3942
  ) : null;
3893
3943
  return {
3894
- clientMessageId: a ? V(a) : o ? null : n,
3944
+ clientMessageId: a ? X(a) : o ? null : n,
3895
3945
  respondsToUserMessageId: o,
3896
3946
  runId: s ?? i?.runId ?? null
3897
3947
  };
@@ -3899,29 +3949,29 @@ function qr(t, e, s, n) {
3899
3949
  function we(t) {
3900
3950
  return t?.type === "run_status" && t.status === "stopped";
3901
3951
  }
3902
- function Lr(t, e) {
3903
- return H(e) ? "completed" : we(t) ? "stopped" : !Re(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
3952
+ function Nr(t, e) {
3953
+ return $(e) ? "completed" : we(t) ? "stopped" : !Re(t) && (t?.type === "run_error" || t?.type === "run_status" && (t.status === "failed" || t.status === "interrupted")) ? "failed" : null;
3904
3954
  }
3905
3955
  function Ot(t, e, s) {
3906
3956
  const n = new Set(
3907
3957
  t.filter(
3908
- (r) => r.role === "user" && e !== null && V(r) === e
3958
+ (r) => r.role === "user" && e !== null && X(r) === e
3909
3959
  ).map((r) => r.id)
3910
3960
  );
3911
3961
  return t.filter(
3912
- (r) => !X(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3962
+ (r) => !J(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3913
3963
  );
3914
3964
  }
3915
3965
  function rs(t, e) {
3916
3966
  return t.some(
3917
- (s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && Nr(
3967
+ (s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && xr(
3918
3968
  t,
3919
3969
  e,
3920
3970
  n
3921
3971
  )
3922
3972
  );
3923
3973
  }
3924
- function Nr(t, e, s) {
3974
+ function xr(t, e, s) {
3925
3975
  const n = t[e], r = t[s];
3926
3976
  if (ce(n, r))
3927
3977
  return !0;
@@ -3932,9 +3982,9 @@ function Nr(t, e, s) {
3932
3982
  return t[i].id === n.respondsToUserMessageId;
3933
3983
  return !1;
3934
3984
  }
3935
- function xr(t, e) {
3985
+ function Br(t, e) {
3936
3986
  const s = [...t].reverse().find(
3937
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && qt(n) && !Br(
3987
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && qt(n) && !Wr(
3938
3988
  t,
3939
3989
  n.respondsToUserMessageId
3940
3990
  )
@@ -3944,14 +3994,14 @@ function xr(t, e) {
3944
3994
  ) : t;
3945
3995
  }
3946
3996
  function qt(t) {
3947
- return t.role === "tool" || X(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
3997
+ return t.role === "tool" || J(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
3948
3998
  }
3949
- function Br(t, e) {
3999
+ function Wr(t, e) {
3950
4000
  return t.some(
3951
- (s) => s.respondsToUserMessageId === e && (H(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
4001
+ (s) => s.respondsToUserMessageId === e && ($(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3952
4002
  );
3953
4003
  }
3954
- function Wr(t, e) {
4004
+ function Hr(t, e) {
3955
4005
  const s = t[e];
3956
4006
  for (let n = e + 1; n < t.length; n += 1) {
3957
4007
  const r = t[n];
@@ -3960,7 +4010,7 @@ function Wr(t, e) {
3960
4010
  }
3961
4011
  return !1;
3962
4012
  }
3963
- function Hr(t, e) {
4013
+ function $r(t, e) {
3964
4014
  const s = t[e];
3965
4015
  if (!s.respondsToUserMessageId)
3966
4016
  return !1;
@@ -3968,37 +4018,37 @@ function Hr(t, e) {
3968
4018
  const r = t[n];
3969
4019
  if (r.role === "user")
3970
4020
  return !1;
3971
- if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || X(r)))
4021
+ if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || J(r)))
3972
4022
  return !0;
3973
4023
  }
3974
4024
  return !1;
3975
4025
  }
3976
- function $r(t, e) {
4026
+ function jr(t, e) {
3977
4027
  const s = t[e];
3978
4028
  return t.some(
3979
4029
  (n, r) => r !== e && n.role === "assistant" && ce(s, n)
3980
4030
  );
3981
4031
  }
3982
- function jr(t, e) {
4032
+ function Fr(t, e) {
3983
4033
  const s = t[e];
3984
4034
  return t.some(
3985
4035
  (n, r) => r !== e && n.role === "tool" && ce(s, n)
3986
4036
  );
3987
4037
  }
3988
- function Fr(t, e) {
4038
+ function zr(t, e) {
3989
4039
  const s = t[e];
3990
4040
  for (let n = e + 1; n < t.length; n += 1)
3991
- if (X(t[n]) && ce(s, t[n]))
4041
+ if (J(t[n]) && ce(s, t[n]))
3992
4042
  return !0;
3993
4043
  return !1;
3994
4044
  }
3995
4045
  function ce(t, e) {
3996
4046
  return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
3997
4047
  }
3998
- function M(t, e) {
4048
+ function A(t, e) {
3999
4049
  return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
4000
4050
  }
4001
- function zr(t, e) {
4051
+ function Kr(t, e) {
4002
4052
  try {
4003
4053
  const s = window.localStorage.getItem(`${zt}${t}`);
4004
4054
  if (!s)
@@ -4006,7 +4056,7 @@ function zr(t, e) {
4006
4056
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
4007
4057
  if (e !== void 0 && r !== e)
4008
4058
  return null;
4009
- const i = Array.isArray(n.messages) ? n.messages.map(si).filter((o) => !!o) : [];
4059
+ const i = Array.isArray(n.messages) ? n.messages.map(ni).filter((o) => !!o) : [];
4010
4060
  return {
4011
4061
  sessionId: r,
4012
4062
  messages: i
@@ -4018,20 +4068,20 @@ function zr(t, e) {
4018
4068
  function is(t) {
4019
4069
  return t.role === "user" || t.role === "assistant" || t.dataType === "run_status" || t.dataType === "run_error";
4020
4070
  }
4021
- function Kr(t, e) {
4071
+ function Gr(t, e) {
4022
4072
  try {
4023
4073
  window.localStorage.setItem(
4024
4074
  `${zt}${t}`,
4025
4075
  JSON.stringify({
4026
4076
  sessionId: e.sessionId,
4027
- messages: e.messages.filter(is).slice(-mn).map(ni)
4077
+ messages: e.messages.filter(is).slice(-mn).map(ri)
4028
4078
  })
4029
4079
  );
4030
4080
  } catch {
4031
4081
  return;
4032
4082
  }
4033
4083
  }
4034
- function Gr(t) {
4084
+ function Vr(t) {
4035
4085
  try {
4036
4086
  const e = window.localStorage.getItem(`${Xe}${t}`);
4037
4087
  if (!e)
@@ -4042,7 +4092,7 @@ function Gr(t) {
4042
4092
  return [];
4043
4093
  }
4044
4094
  }
4045
- function G(t, e) {
4095
+ function V(t, e) {
4046
4096
  try {
4047
4097
  const s = e.filter(at);
4048
4098
  if (s.length === 0) {
@@ -4082,19 +4132,19 @@ function Lt(t, e) {
4082
4132
  }
4083
4133
  os(t, e);
4084
4134
  }
4085
- function Vr(t) {
4135
+ function Xr(t) {
4086
4136
  try {
4087
4137
  const e = `${be}${t}`, s = window.sessionStorage.getItem(e);
4088
4138
  if (window.sessionStorage.removeItem(e), !s)
4089
4139
  return [];
4090
4140
  const n = JSON.parse(s);
4091
- return Array.isArray(n) ? n.flatMap((r) => Jr(r) ? [{
4141
+ return Array.isArray(n) ? n.flatMap((r) => Qr(r) ? [{
4092
4142
  ...r.event,
4093
- page: b(),
4143
+ page: _(),
4094
4144
  rawOutput: {
4095
4145
  pageContextRestarted: !0,
4096
4146
  outcome: "unknown",
4097
- message: Xr(location.href),
4147
+ message: Jr(location.href),
4098
4148
  currentUrl: location.href,
4099
4149
  console: [],
4100
4150
  metadata: {
@@ -4111,11 +4161,11 @@ function Vr(t) {
4111
4161
  return [];
4112
4162
  }
4113
4163
  }
4114
- function Xr(t) {
4164
+ function Jr(t) {
4115
4165
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
4116
4166
  Current URL: ${t}`;
4117
4167
  }
4118
- function Jr(t) {
4168
+ function Qr(t) {
4119
4169
  if (!t || typeof t != "object")
4120
4170
  return !1;
4121
4171
  const e = t, s = e.event;
@@ -4130,7 +4180,7 @@ function Yr(t, e) {
4130
4180
  ...e.filter((n) => !s.has(n.callId))
4131
4181
  ];
4132
4182
  }
4133
- function Qr(t) {
4183
+ function Zr(t) {
4134
4184
  try {
4135
4185
  window.sessionStorage.removeItem(`${be}${t}`);
4136
4186
  } catch {
@@ -4167,9 +4217,9 @@ function ls(t, e) {
4167
4217
  } : t;
4168
4218
  }
4169
4219
  function et(t) {
4170
- return t.type || ti(t.name) || "application/octet-stream";
4220
+ return t.type || si(t.name) || "application/octet-stream";
4171
4221
  }
4172
- function Zr(t) {
4222
+ function ei(t) {
4173
4223
  cs({
4174
4224
  name: t.name,
4175
4225
  mimeType: et(t),
@@ -4177,21 +4227,21 @@ function Zr(t) {
4177
4227
  });
4178
4228
  }
4179
4229
  function cs(t) {
4180
- const e = ei(t.name), s = t.mimeType.trim().toLowerCase();
4230
+ const e = ti(t.name), s = t.mimeType.trim().toLowerCase();
4181
4231
  if (!pn.has(`${e}:${s}`))
4182
4232
  throw new Error("This attachment type is not supported by the embedded model provider");
4183
4233
  if (t.sizeBytes <= 0 || t.sizeBytes >= jt)
4184
4234
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
4185
4235
  }
4186
- function ei(t) {
4236
+ function ti(t) {
4187
4237
  const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
4188
4238
  return s >= 0 ? e.slice(s) : "";
4189
4239
  }
4190
- function ti(t) {
4240
+ function si(t) {
4191
4241
  const e = t.toLowerCase();
4192
4242
  return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
4193
4243
  }
4194
- function si(t) {
4244
+ function ni(t) {
4195
4245
  if (!t || typeof t != "object")
4196
4246
  return null;
4197
4247
  const e = t;
@@ -4213,7 +4263,7 @@ function si(t) {
4213
4263
  loading: typeof e.loading == "boolean" ? e.loading : void 0
4214
4264
  };
4215
4265
  }
4216
- function ni(t) {
4266
+ function ri(t) {
4217
4267
  return t.attachments?.length ? {
4218
4268
  ...t,
4219
4269
  attachments: t.attachments.map(Ee)
@@ -4237,7 +4287,7 @@ function k(t) {
4237
4287
  const e = t.runId;
4238
4288
  return typeof e == "string" && e ? e : null;
4239
4289
  }
4240
- function ri(t) {
4290
+ function ii(t) {
4241
4291
  const e = t?.timeoutMs;
4242
4292
  return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Rn);
4243
4293
  }
@@ -4253,22 +4303,22 @@ function us(t) {
4253
4303
  return e;
4254
4304
  }
4255
4305
  function lt(t, e) {
4256
- return ms(t) ? Pe : W(Ce(e), gn);
4306
+ return ms(t) ? Pe : H(Ce(e), gn);
4257
4307
  }
4258
- function ii(t, e) {
4308
+ function oi(t, e) {
4259
4309
  return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
4260
4310
  }
4261
- async function oi(t, e, s, n) {
4311
+ async function ai(t, e, s, n) {
4262
4312
  const r = us(t.headers);
4263
4313
  n({
4264
4314
  ...e,
4265
4315
  responseStatus: t.status,
4266
4316
  responseHeaders: r,
4267
- responseBody: await ai(t),
4317
+ responseBody: await li(t),
4268
4318
  durationMs: Date.now() - s
4269
4319
  });
4270
4320
  }
4271
- async function ai(t) {
4321
+ async function li(t) {
4272
4322
  if (!ds(t.headers))
4273
4323
  return;
4274
4324
  let e = null, s = null;
@@ -4287,10 +4337,10 @@ async function ai(t) {
4287
4337
  return;
4288
4338
  const { done: l, value: c } = a;
4289
4339
  if (l)
4290
- return W(i + r.decode());
4340
+ return H(i + r.decode());
4291
4341
  const d = rt - o;
4292
4342
  if (c.byteLength > d)
4293
- return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${W(i)}... [truncated]`;
4343
+ return i += r.decode(c.subarray(0, Math.max(d, 0)), { stream: !0 }), e.cancel(), `${H(i)}... [truncated]`;
4294
4344
  o += c.byteLength, i += r.decode(c, { stream: !0 });
4295
4345
  }
4296
4346
  } catch {
@@ -4300,19 +4350,19 @@ async function ai(t) {
4300
4350
  s !== null && window.clearTimeout(s);
4301
4351
  }
4302
4352
  }
4303
- function li(t, e) {
4353
+ function ci(t, e) {
4304
4354
  if (ds(new Headers(e)))
4305
4355
  try {
4306
- return t.responseType === "" || t.responseType === "text" ? W(t.responseText ?? "") : void 0;
4356
+ return t.responseType === "" || t.responseType === "text" ? H(t.responseText ?? "") : void 0;
4307
4357
  } catch {
4308
4358
  return;
4309
4359
  }
4310
4360
  }
4311
4361
  function xt(t) {
4312
4362
  if (typeof t == "string")
4313
- return W(t);
4363
+ return H(t);
4314
4364
  }
4315
- function ci(t) {
4365
+ function ui(t) {
4316
4366
  return q({
4317
4367
  ...t,
4318
4368
  requestBody: Bt(t.requestBody),
@@ -4338,7 +4388,7 @@ function ds(t) {
4338
4388
  return s !== null && Number.isInteger(n) && n >= 0 && n <= rt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
4339
4389
  }
4340
4390
  function Y(t, e = {}, s) {
4341
- if (di(s))
4391
+ if (hi(s))
4342
4392
  return !0;
4343
4393
  const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
4344
4394
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -4353,7 +4403,7 @@ function Y(t, e = {}, s) {
4353
4403
  return !0;
4354
4404
  }
4355
4405
  }
4356
- function ui(t, e) {
4406
+ function di(t, e) {
4357
4407
  if (Y(t))
4358
4408
  return !0;
4359
4409
  try {
@@ -4363,10 +4413,10 @@ function ui(t, e) {
4363
4413
  return !0;
4364
4414
  }
4365
4415
  }
4366
- function di(t) {
4416
+ function hi(t) {
4367
4417
  return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
4368
4418
  }
4369
- function hi(t) {
4419
+ function pi(t) {
4370
4420
  const e = {};
4371
4421
  for (const s of t.trim().split(/[\r\n]+/)) {
4372
4422
  const n = s.indexOf(":");
@@ -4379,7 +4429,7 @@ function hi(t) {
4379
4429
  }
4380
4430
  return e;
4381
4431
  }
4382
- function W(t, e = rt) {
4432
+ function H(t, e = rt) {
4383
4433
  return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
4384
4434
  }
4385
4435
  function Ke(t) {
@@ -4397,27 +4447,27 @@ async function Ie(t, e) {
4397
4447
  try {
4398
4448
  return await t();
4399
4449
  } catch (r) {
4400
- if (s = r, n >= Et - 1 || !gi(r))
4450
+ if (s = r, n >= Et - 1 || !fi(r))
4401
4451
  throw r;
4402
- await pi(n);
4452
+ await gi(n);
4403
4453
  }
4404
4454
  throw s instanceof Error ? s : new Error(e);
4405
4455
  }
4406
- function pi(t) {
4456
+ function gi(t) {
4407
4457
  return new Promise((e) => {
4408
4458
  window.setTimeout(e, hn[t] ?? 0);
4409
4459
  });
4410
4460
  }
4411
- function gi(t) {
4412
- return t instanceof Me ? fi(t.status) : t instanceof TypeError;
4413
- }
4414
4461
  function fi(t) {
4415
- return t === 408 || t === 409 || t === 429 || t >= 500;
4462
+ return t instanceof Me ? mi(t.status) : t instanceof TypeError;
4416
4463
  }
4417
4464
  function mi(t) {
4465
+ return t === 408 || t === 409 || t === 429 || t >= 500;
4466
+ }
4467
+ function yi(t) {
4418
4468
  return t === 401 || t === 403;
4419
4469
  }
4420
- const Pe = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", yi = "[REDACTED_SIGNED_URL]", Ii = 20, Ti = /^(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, hs = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ps = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, gs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, fs = /\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, Si = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, wi = /\bhttps?:\/\/[^\s"'<>]+/gi, Mi = /[),.;\]]+$/;
4470
+ const Pe = "[REDACTED_SECRET]", j = "[REDACTED_TOKEN]", Ii = "[REDACTED_SIGNED_URL]", Si = 20, Ti = /^(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, hs = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ps = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, gs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, fs = /\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, wi = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Mi = /\bhttps?:\/\/[^\s"'<>]+/gi, Ai = /[),.;\]]+$/;
4421
4471
  function q(t) {
4422
4472
  return ke(t, 0, /* @__PURE__ */ new WeakSet());
4423
4473
  }
@@ -4426,7 +4476,7 @@ function ke(t, e, s) {
4426
4476
  return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Ce(t);
4427
4477
  if (t === null || typeof t != "object")
4428
4478
  return t;
4429
- if (e >= Ii)
4479
+ if (e >= Si)
4430
4480
  return "[REDACTED_MAX_DEPTH]";
4431
4481
  if (s.has(t))
4432
4482
  return "[REDACTED_CIRCULAR]";
@@ -4434,34 +4484,34 @@ function ke(t, e, s) {
4434
4484
  return t.map((r) => ke(r, e + 1, s));
4435
4485
  const n = {};
4436
4486
  for (const [r, i] of Object.entries(t))
4437
- r === "pageContent" ? n[r] = i : ms(r) ? n[r] = Pe : n[r] = r.toLowerCase() === "url" ? Ai(i) : ke(i, e + 1, s);
4487
+ r === "pageContent" ? n[r] = i : ms(r) ? n[r] = Pe : n[r] = r.toLowerCase() === "url" ? Ri(i) : ke(i, e + 1, s);
4438
4488
  return n;
4439
4489
  }
4440
4490
  function ms(t) {
4441
4491
  const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
4442
4492
  return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
4443
4493
  }
4444
- function Ai(t) {
4494
+ function Ri(t) {
4445
4495
  return typeof t == "string" ? ys(t) : ke(t, 0, /* @__PURE__ */ new WeakSet());
4446
4496
  }
4447
4497
  function ys(t) {
4448
4498
  try {
4449
4499
  const e = new URL(t, location.href);
4450
4500
  for (const s of Array.from(e.searchParams.keys()))
4451
- Ti.test(s) && e.searchParams.set(s, $);
4452
- return e.username && (e.username = $), e.password && (e.password = $), e.toString();
4501
+ Ti.test(s) && e.searchParams.set(s, j);
4502
+ return e.username && (e.username = j), e.password && (e.password = j), e.toString();
4453
4503
  } catch {
4454
- return Ri(t);
4504
+ return Ei(t);
4455
4505
  }
4456
4506
  }
4457
4507
  function Ce(t) {
4458
- return t.replace(Si, yi).replace(wi, Ei).replace(hs, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(gs, $).replace(fs, (e, s) => `${s}: ${Pe}`);
4459
- }
4460
- function Ri(t) {
4461
- return t.replace(hs, `Bearer ${$}`).replace(ps, `Basic ${$}`).replace(gs, $).replace(fs, (e, s) => `${s}: ${Pe}`);
4508
+ return t.replace(wi, Ii).replace(Mi, ki).replace(hs, `Bearer ${j}`).replace(ps, `Basic ${j}`).replace(gs, j).replace(fs, (e, s) => `${s}: ${Pe}`);
4462
4509
  }
4463
4510
  function Ei(t) {
4464
- const e = t.match(Mi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
4511
+ return t.replace(hs, `Bearer ${j}`).replace(ps, `Basic ${j}`).replace(gs, j).replace(fs, (e, s) => `${s}: ${Pe}`);
4512
+ }
4513
+ function ki(t) {
4514
+ const e = t.match(Ai)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
4465
4515
  return `${ys(s)}${e}`;
4466
4516
  }
4467
4517
  export {
@@ -4470,10 +4520,10 @@ export {
4470
4520
  Xs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
4471
4521
  Vs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
4472
4522
  Js as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
4473
- ki as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
4523
+ Ci as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
4474
4524
  Kt as PlunoProductAgent,
4475
4525
  In as calculateReconnectDelay,
4476
4526
  Kt as default,
4477
4527
  Wn as getProductAgentOriginAccessErrorMessage,
4478
- Zr as validateProductAgentProviderInputFile
4528
+ ei as validateProductAgentProviderInputFile
4479
4529
  };