@pluno/product-agent-web 0.1.204 → 0.1.206

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.
@@ -474,7 +474,7 @@ function Tn(s, e, t) {
474
474
  function Is(s) {
475
475
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
476
476
  }
477
- function So(s) {
477
+ function Ao(s) {
478
478
  return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
479
479
  }
480
480
  function wn(s, e) {
@@ -485,7 +485,7 @@ function An(s) {
485
485
  const e = s.paidCreditFallbackModel;
486
486
  return typeof e == "string" && e.length > 0;
487
487
  }
488
- function To(s) {
488
+ function Mo(s) {
489
489
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
490
490
  return s.hasRunningAssistantTurn && !e ? {
491
491
  action: "stop",
@@ -835,7 +835,7 @@ class kn {
835
835
  return `${Ve(e.scope)}:category:${e.category}`;
836
836
  }
837
837
  }
838
- function wo(s, e) {
838
+ function bo(s, e) {
839
839
  return {
840
840
  load: async () => En(s, e),
841
841
  save: async (t) => s.setItem(e, JSON.stringify(t))
@@ -863,13 +863,13 @@ const Cn = {
863
863
  completed: "✅",
864
864
  failed: "❗",
865
865
  stopped: "⏹️"
866
- }, Pn = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
867
- function _n(s, e) {
868
- if (!e) return _e(s);
869
- const t = _e(s), n = `${Cn[e]} Pluno`;
866
+ }, _n = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
867
+ function Pn(s, e) {
868
+ if (!e) return Pe(s);
869
+ const t = Pe(s), n = `${Cn[e]} Pluno`;
870
870
  return t ? `${n}: ${t}` : n;
871
871
  }
872
- class Ao {
872
+ class Ro {
873
873
  constructor(e) {
874
874
  this.titleDocument = e;
875
875
  }
@@ -891,10 +891,10 @@ class Ao {
891
891
  }
892
892
  applyStatus(e) {
893
893
  const t = this.titleDocument.getTitle();
894
- t !== this.lastAppliedTitle && (this.baseTitle = _e(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
894
+ t !== this.lastAppliedTitle && (this.baseTitle = Pe(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
895
895
  }
896
896
  applyClear() {
897
- const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ? _e(e) : e;
897
+ const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ? Pe(e) : e;
898
898
  this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : n !== e && this.titleDocument.setTitle(n);
899
899
  }
900
900
  handleTitleChanged() {
@@ -903,11 +903,11 @@ class Ao {
903
903
  applyTitle() {
904
904
  if (!this.status)
905
905
  return;
906
- const e = _n(this.baseTitle, this.status);
906
+ const e = Pn(this.baseTitle, this.status);
907
907
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
908
908
  }
909
909
  }
910
- function Mo(s) {
910
+ function ko(s) {
911
911
  return {
912
912
  getTitle: () => s.title,
913
913
  setTitle: (e) => {
@@ -923,10 +923,10 @@ function Mo(s) {
923
923
  }
924
924
  };
925
925
  }
926
- function _e(s) {
927
- return s.replace(Pn, "");
926
+ function Pe(s) {
927
+ return s.replace(_n, "");
928
928
  }
929
- function bo(s) {
929
+ function Eo(s) {
930
930
  if (!s || typeof s != "object" || !("type" in s)) return !1;
931
931
  const e = s;
932
932
  switch (e.type) {
@@ -937,6 +937,10 @@ function bo(s) {
937
937
  return !0;
938
938
  case "runtime.warmup":
939
939
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
940
+ case "runtime.report_displayed_error":
941
+ return (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint);
942
+ case "runtime.report_invalid_state_transition":
943
+ return (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll") && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
940
944
  case "runtime.widget_lifecycle":
941
945
  return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
942
946
  case "session.load":
@@ -954,7 +958,7 @@ function bo(s) {
954
958
  case "conversation.stage_proactive_suggestion":
955
959
  return typeof e.question == "string" && typeof e.clientMessageId == "string";
956
960
  case "conversation.stage":
957
- return typeof e.content == "string" && typeof e.clientMessageId == "string" && (e.attachments === void 0 || Array.isArray(e.attachments));
961
+ return typeof e.content == "string" && typeof e.clientMessageId == "string" && (e.submittedAt === void 0 || typeof e.submittedAt == "number") && (e.attachments === void 0 || Array.isArray(e.attachments));
958
962
  case "conversation.fail_staged":
959
963
  return typeof e.clientMessageId == "string" && typeof e.message == "string";
960
964
  case "conversation.send":
@@ -963,7 +967,7 @@ function bo(s) {
963
967
  return !1;
964
968
  }
965
969
  }
966
- class Ro {
970
+ class Co {
967
971
  constructor(e, t, n) {
968
972
  this.adapter = t, this.state = Xe(e), this.model = n;
969
973
  }
@@ -1023,10 +1027,26 @@ class Ro {
1023
1027
  recordWidgetLifecycle(e, t) {
1024
1028
  this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
1025
1029
  }
1030
+ reportInvalidStateTransition(e, t) {
1031
+ this.adapter.dispatch({
1032
+ type: "runtime.report_invalid_state_transition",
1033
+ reason: e,
1034
+ clientMessageId: t
1035
+ }).catch(() => {
1036
+ });
1037
+ }
1038
+ reportDisplayedError(e, t) {
1039
+ this.adapter.dispatch({
1040
+ type: "runtime.report_displayed_error",
1041
+ reason: e,
1042
+ errorFingerprint: t
1043
+ }).catch(() => {
1044
+ });
1045
+ }
1026
1046
  sendMessage(e, t = {}) {
1027
1047
  const n = e.trim(), i = t.attachments ?? [];
1028
1048
  if (!n && i.length === 0) return Promise.resolve(null);
1029
- const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), o = this.state, a = {
1049
+ const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), o = t.submittedAt ?? Date.now(), a = this.state, l = {
1030
1050
  id: `local-${r}`,
1031
1051
  role: "user",
1032
1052
  content: n,
@@ -1036,7 +1056,7 @@ class Ro {
1036
1056
  };
1037
1057
  return this.state = {
1038
1058
  ...this.state,
1039
- messages: [...this.state.messages, a],
1059
+ messages: [...this.state.messages, l],
1040
1060
  pendingMessageStatus: "sending",
1041
1061
  turnPhase: this.state.isThinking ? this.state.turnPhase : "sending",
1042
1062
  taskStatus: "working",
@@ -1044,8 +1064,8 @@ class Ro {
1044
1064
  lastError: null
1045
1065
  }, this.emit("state", this.getState()), this.enqueueOperation(() => this.sendMessageNow(
1046
1066
  n,
1047
- { ...t, clientMessageId: r },
1048
- o
1067
+ { ...t, clientMessageId: r, submittedAt: o },
1068
+ a
1049
1069
  ));
1050
1070
  }
1051
1071
  async sendMessageNow(e, t, n) {
@@ -1057,7 +1077,8 @@ class Ro {
1057
1077
  content: i,
1058
1078
  clientMessageId: r,
1059
1079
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1060
- attachments: o.length > 0 ? o : void 0
1080
+ attachments: o.length > 0 ? o : void 0,
1081
+ submittedAt: t.submittedAt
1061
1082
  }), a = !0, o.length > 0) {
1062
1083
  if (!this.adapter.uploadAttachment)
1063
1084
  throw new Error("The runtime does not support attachments.");
@@ -1348,24 +1369,24 @@ class Se extends Error {
1348
1369
  function Nn(s) {
1349
1370
  return s === 408 || s === 425 || s === 429 || s >= 500;
1350
1371
  }
1351
- const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, Fn = 6e4, $n = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, Ft = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", $t = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, jt = 8e3, zt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
1372
+ const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, Fn = 6e4, $n = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, Ft = 15e3, Xn = 6e4, Jn = 8, Yn = "Browser connection was interrupted.", $t = 15e3, Zn = "Pluno could not send this message. Try it again.", ei = "Still connecting to Pluno. Retrying automatically.", ti = 2e3, si = 1e3, ni = 100, jt = 8e3, zt = 3, ii = [300, 1e3], Ts = 50 * 1024 * 1024, ri = /* @__PURE__ */ new Set([
1352
1373
  ".jpeg:image/jpeg",
1353
1374
  ".jpg:image/jpeg",
1354
1375
  ".pdf:application/pdf",
1355
1376
  ".png:image/png",
1356
1377
  ".webp:image/webp"
1357
- ]), ko = ".pdf,.png,.jpg,.jpeg,.webp", Tt = 64e3, Ye = 4e3, wt = 30, ri = 2e3, oi = 1e3, ws = "Image is too large for model vision input.", ai = 100, li = 20, As = "pluno.productAgent.state.", at = "pluno.productAgent.pendingEvents.", xe = "pluno.productAgent.activeToolCalls.", ci = 100;
1358
- function ui(s, e = 0) {
1378
+ ]), _o = ".pdf,.png,.jpg,.jpeg,.webp", Tt = 64e3, Ye = 4e3, wt = 30, oi = 2e3, ai = 1e3, ws = "Image is too large for model vision input.", li = 100, ci = 20, As = "pluno.productAgent.state.", at = "pluno.productAgent.pendingEvents.", xe = "pluno.productAgent.activeToolCalls.", ui = 100;
1379
+ function di(s, e = 0) {
1359
1380
  const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
1360
1381
  return Math.max(e, t);
1361
1382
  }
1362
1383
  const Ee = /* @__PURE__ */ new Set();
1363
1384
  let Te = null;
1364
- function di(s, e = Math.random) {
1385
+ function hi(s, e = Math.random) {
1365
1386
  const t = Math.min(ot, Qn * 2 ** s), n = 1 - Wt + e() * Wt * 2;
1366
1387
  return Math.min(ot, Math.round(t * n));
1367
1388
  }
1368
- function hi(s) {
1389
+ function pi(s) {
1369
1390
  const e = s.split(".")[1];
1370
1391
  if (!e)
1371
1392
  return null;
@@ -1376,7 +1397,7 @@ function hi(s) {
1376
1397
  return null;
1377
1398
  }
1378
1399
  }
1379
- function pi(s) {
1400
+ function gi(s) {
1380
1401
  if (s instanceof X)
1381
1402
  return s.retryable;
1382
1403
  if (s && typeof s == "object") {
@@ -1386,7 +1407,7 @@ function pi(s) {
1386
1407
  }
1387
1408
  return !0;
1388
1409
  }
1389
- function gi(s) {
1410
+ function fi(s) {
1390
1411
  if (s instanceof Error)
1391
1412
  return s;
1392
1413
  if (s && typeof s == "object") {
@@ -1443,9 +1464,9 @@ class Le {
1443
1464
  maxFailureIntervalMs: 3e4
1444
1465
  }), this.personalModelSelectionOverride = e.productVariant === "personal" && Qe(e.model) ? e.model : null, this.state = {
1445
1466
  ...this.state,
1446
- starterPrompts: Gi(e.initialStarterPrompts)
1467
+ starterPrompts: Xi(e.initialStarterPrompts)
1447
1468
  }, this.account = e.initialAccount ? { ...e.initialAccount } : null;
1448
- const n = e.restorePersistedState === !1 ? null : Lr(e.clientId, e.expectedPersistedSessionId);
1469
+ const n = e.restorePersistedState === !1 ? null : Br(e.clientId, e.expectedPersistedSessionId);
1449
1470
  n && (this.state = {
1450
1471
  ...this.state,
1451
1472
  ...n,
@@ -1466,9 +1487,9 @@ class Le {
1466
1487
  taskStatus: null,
1467
1488
  isRetrying: !1,
1468
1489
  lastError: null
1469
- }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = $r(
1470
- Hr(e.clientId),
1471
- Br(e.clientId)
1490
+ }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = Kr(
1491
+ Fr(e.clientId),
1492
+ $r(e.clientId)
1472
1493
  );
1473
1494
  const i = [...this.queuedClientEvents].reverse().find(
1474
1495
  (r) => r.type === "chat.user_message" && typeof r.clientMessageId == "string"
@@ -1533,6 +1554,9 @@ class Le {
1533
1554
  retryAttemptsByClientMessageId = {};
1534
1555
  retryTimersByClientMessageId = {};
1535
1556
  reportedHealthSignalKeys = /* @__PURE__ */ new Set();
1557
+ firstResponseTimersByClientMessageId = /* @__PURE__ */ new Map();
1558
+ lastProjectedTurnPhase = null;
1559
+ lastProjectedTurnClientMessageId = null;
1536
1560
  /** @internal */
1537
1561
  transportDiagnosticEpisodes = /* @__PURE__ */ new Map();
1538
1562
  /** @internal */
@@ -1615,10 +1639,10 @@ class Le {
1615
1639
  t.skipStoredTransportIdentityCollisionCheck === !0
1616
1640
  ), i = new Le({
1617
1641
  ...e,
1618
- backendUrl: Ui(e.backendUrl ?? Hn),
1619
- clientId: e.clientId ?? Yi(),
1642
+ backendUrl: Oi(e.backendUrl ?? Hn),
1643
+ clientId: e.clientId ?? tr(),
1620
1644
  productVariant: e.productVariant ?? "customer_embedded",
1621
- entrySurface: Di(e.entrySurface)
1645
+ entrySurface: xi(e.entrySurface)
1622
1646
  }, n);
1623
1647
  try {
1624
1648
  Qs().catch((r) => {
@@ -1691,7 +1715,7 @@ class Le {
1691
1715
  throw new X("Pluno token request was cancelled", !0);
1692
1716
  if (!c)
1693
1717
  throw new X("Pluno token provider did not return a token", !1);
1694
- return this.token = c, this.tokenExpiresAtMs = hi(c), c;
1718
+ return this.token = c, this.tokenExpiresAtMs = pi(c), c;
1695
1719
  } finally {
1696
1720
  a !== null && window.clearTimeout(a);
1697
1721
  }
@@ -1716,7 +1740,7 @@ class Le {
1716
1740
  return;
1717
1741
  if (!this.token && !this.options.webSocketFactory)
1718
1742
  throw new X("Pluno requires a token or tokenProvider", !1);
1719
- const t = xi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1743
+ const t = Hi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1720
1744
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
1721
1745
  this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(n));
1722
1746
  }, jn), n.addEventListener("open", () => {
@@ -1733,11 +1757,11 @@ class Le {
1733
1757
  this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
1734
1758
  }, zn));
1735
1759
  }), n.addEventListener("message", (i) => {
1736
- this.socket === n && this.handleServerEvent(zi(i.data));
1760
+ this.socket === n && this.handleServerEvent(Qi(i.data));
1737
1761
  }), n.addEventListener("sendfailure", (i) => {
1738
1762
  if (this.socket !== n)
1739
1763
  return;
1740
- const r = Ki(i?.detail?.data);
1764
+ const r = Vi(i?.detail?.data);
1741
1765
  r?.type === "chat.user_message" && r.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
1742
1766
  (o) => o.type === "chat.user_message" && o.clientMessageId === r.clientMessageId
1743
1767
  ) && (this.queuedClientEvents.push(r), 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();
@@ -1761,14 +1785,14 @@ class Le {
1761
1785
  } catch (t) {
1762
1786
  if (e !== this.connectionAttemptId || this.state.status === "closed")
1763
1787
  return;
1764
- const n = gi(t);
1765
- if (pi(t)) {
1788
+ const n = fi(t);
1789
+ if (gi(t)) {
1766
1790
  b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
1767
1791
  message: n.message,
1768
1792
  reconnectAttempt: this.reconnectAttempts
1769
1793
  }), t instanceof X && this.reportTransportDiagnostic("auth_timeout"), this.setState({
1770
1794
  status: "reconnecting",
1771
- lastError: Zn,
1795
+ lastError: ei,
1772
1796
  lastErrorCode: "connection_failed"
1773
1797
  }), this.emit("error", n), this.scheduleReconnect(
1774
1798
  t instanceof X ? t.retryAfterMs : void 0
@@ -1785,16 +1809,16 @@ class Le {
1785
1809
  }
1786
1810
  }
1787
1811
  disconnect() {
1788
- this.stopSessionRecoveryPolling(), 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.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.clientDiagnosticsRetryTimer !== null && (window.clearTimeout(this.clientDiagnosticsRetryTimer), this.clientDiagnosticsRetryTimer = null), this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [], 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;
1812
+ this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), 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.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.clientDiagnosticsRetryTimer !== null && (window.clearTimeout(this.clientDiagnosticsRetryTimer), this.clientDiagnosticsRetryTimer = null), this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [], 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;
1789
1813
  }
1790
1814
  destroy() {
1791
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), jr(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();
1815
+ this.disconnect(), this.clearAllFirstResponseTimers(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Gr(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();
1792
1816
  for (const e of Object.values(this.listeners))
1793
1817
  e?.clear();
1794
1818
  this.accountListeners.clear(), this.interactionListeners.clear();
1795
1819
  }
1796
1820
  warmup(e = "panel_open") {
1797
- const t = P(), n = `${this.state.sessionId ?? "draft"}:${t.url}`, i = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, r = {
1821
+ const t = _(), n = `${this.state.sessionId ?? "draft"}:${t.url}`, i = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, r = {
1798
1822
  type: "runtime.warmup",
1799
1823
  reason: e,
1800
1824
  ...e === "composer_input" ? { warmupId: i?.event.warmupId ?? x() } : {},
@@ -1821,7 +1845,7 @@ class Le {
1821
1845
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1822
1846
  entrySurface: this.options.entrySurface,
1823
1847
  ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
1824
- pageOrigin: P().origin
1848
+ pageOrigin: _().origin
1825
1849
  }
1826
1850
  };
1827
1851
  this.authenticatedSocket === this.socket && this.sendNow(n) || (this.pendingWidgetLifecycleEvents.push(n), this.pendingWidgetLifecycleEvents.length > 20 && this.pendingWidgetLifecycleEvents.splice(0, this.pendingWidgetLifecycleEvents.length - 20));
@@ -1838,7 +1862,7 @@ class Le {
1838
1862
  return null;
1839
1863
  if (this.pendingClientMessageId)
1840
1864
  throw new Error("Wait for the current message to finish sending before sending another.");
1841
- const o = P(), a = t.clientMessageId ?? x(), l = t.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
1865
+ const o = _(), a = t.clientMessageId ?? x(), l = t.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
1842
1866
  (S) => S.id === this.stagedProactiveSuggestionQuestionMessageId
1843
1867
  ) ?? null : null, u = l ? {
1844
1868
  id: `local-proactive-suggestion-question-${a}`,
@@ -1884,7 +1908,7 @@ class Le {
1884
1908
  taskStatus: "working",
1885
1909
  isRetrying: !1,
1886
1910
  lastError: null
1887
- }), g || (this.sessionHistoryManager.addOptimistic({
1911
+ }), this.startFirstResponseTimer(a, t.submittedAt), g || (this.sessionHistoryManager.addOptimistic({
1888
1912
  id: d.id,
1889
1913
  title: null,
1890
1914
  customTitle: null,
@@ -1910,7 +1934,7 @@ class Le {
1910
1934
  }
1911
1935
  r = S;
1912
1936
  } catch (S) {
1913
- throw g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
1937
+ throw this.clearFirstResponseTimer(a), g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
1914
1938
  ...g ? {} : { messages: m },
1915
1939
  ...f ? {} : { ...w, isThinking: !1 },
1916
1940
  pendingMessageStatus: p,
@@ -1924,7 +1948,7 @@ class Le {
1924
1948
  sessionId: this.state.sessionId ?? void 0,
1925
1949
  clientMessageId: a,
1926
1950
  initiatedBy: t.initiatedBy,
1927
- invocation: qi(t.invocation ?? t.initiatedBy),
1951
+ invocation: Li(t.invocation ?? t.initiatedBy),
1928
1952
  entrySurface: this.options.entrySurface,
1929
1953
  content: n,
1930
1954
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
@@ -1936,6 +1960,15 @@ class Le {
1936
1960
  };
1937
1961
  return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
1938
1962
  }
1963
+ reportInvalidStateTransition(e, t) {
1964
+ this.reportHealthSignal("invalid_state_transition", {
1965
+ reason: e,
1966
+ clientMessageId: t
1967
+ });
1968
+ }
1969
+ reportDisplayedError(e, t) {
1970
+ this.reportHealthSignal("user_visible_error", { reason: e, errorFingerprint: t });
1971
+ }
1939
1972
  getModel() {
1940
1973
  return this.options.model;
1941
1974
  }
@@ -1958,7 +1991,7 @@ class Le {
1958
1991
  return e ? (this.retryAttemptsByClientMessageId[t] = 0, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.activeClientMessageId = t, this.latestRecoverableClientMessageId = t, 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: t, automatic: !1 }), !0) : !1;
1959
1992
  }
1960
1993
  createLocalAttachment(e) {
1961
- this.options.productVariant === "customer_embedded" && zr(e);
1994
+ this.options.productVariant === "customer_embedded" && Qr(e);
1962
1995
  const t = x(), n = {
1963
1996
  id: t,
1964
1997
  name: e.name || "attachment",
@@ -1973,7 +2006,7 @@ class Le {
1973
2006
  mimeType: n.mimeType,
1974
2007
  sizeBytes: n.sizeBytes,
1975
2008
  blob: e,
1976
- origin: P().origin,
2009
+ origin: _().origin,
1977
2010
  sessionId: this.state.sessionId ?? void 0,
1978
2011
  createdAt: i,
1979
2012
  lastUsedAt: i
@@ -2004,7 +2037,7 @@ class Le {
2004
2037
  name: e.name || "attachment",
2005
2038
  mimeType: i,
2006
2039
  sizeBytes: e.size,
2007
- page: P(),
2040
+ page: _(),
2008
2041
  model: this.options.model,
2009
2042
  metadata: Kt(this.options.metadata),
2010
2043
  entrySurface: this.options.entrySurface
@@ -2027,7 +2060,7 @@ class Le {
2027
2060
  body: e
2028
2061
  });
2029
2062
  if (!c.ok)
2030
- throw new Pe("Failed to upload attachment", c.status);
2063
+ throw new _e("Failed to upload attachment", c.status);
2031
2064
  return c;
2032
2065
  }, "Failed to upload attachment"), o = l;
2033
2066
  }
@@ -2064,14 +2097,14 @@ class Le {
2064
2097
  const n = await this.fetchEmbedAttachmentUpload(e, !1);
2065
2098
  if (n.ok)
2066
2099
  return await n.json();
2067
- if (lo(n.status) && this.options.tokenProvider && !t) {
2100
+ if (ho(n.status) && this.options.tokenProvider && !t) {
2068
2101
  t = !0;
2069
2102
  const i = await this.fetchEmbedAttachmentUpload(e, !0);
2070
2103
  if (i.ok)
2071
2104
  return await i.json();
2072
- throw new Pe("Failed to prepare attachment upload", i.status);
2105
+ throw new _e("Failed to prepare attachment upload", i.status);
2073
2106
  }
2074
- throw new Pe("Failed to prepare attachment upload", n.status);
2107
+ throw new _e("Failed to prepare attachment upload", n.status);
2075
2108
  }, "Failed to prepare attachment upload");
2076
2109
  }
2077
2110
  async fetchEmbedAttachmentUpload(e, t) {
@@ -2089,7 +2122,7 @@ class Le {
2089
2122
  if (!this.state.sessionId)
2090
2123
  return;
2091
2124
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
2092
- const e = Er(
2125
+ const e = Pr(
2093
2126
  this.state.messages,
2094
2127
  this.state.assistantDraftRespondsToUserMessageId,
2095
2128
  this.state.assistantDraftRunId,
@@ -2132,11 +2165,11 @@ class Le {
2132
2165
  startNewSession(e = {}) {
2133
2166
  this.stopSessionRecoveryPolling();
2134
2167
  const t = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
2135
- !this.options.keepRunsActiveOnSessionNavigation && t && 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((i) => i.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), t && this.send({
2168
+ !this.options.keepRunsActiveOnSessionNavigation && t && 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((i) => i.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), 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), t && this.send({
2136
2169
  type: "session.reset",
2137
2170
  sessionId: this.state.sessionId ?? void 0,
2138
2171
  warmupId: n ?? void 0,
2139
- page: P()
2172
+ page: _()
2140
2173
  }), this.setState({
2141
2174
  sessionId: null,
2142
2175
  starterPrompts: [...this.state.starterPrompts],
@@ -2164,7 +2197,7 @@ class Le {
2164
2197
  }), i = {
2165
2198
  type: "sessions.list",
2166
2199
  requestId: t,
2167
- page: P(),
2200
+ page: _(),
2168
2201
  ...e.cursor ? { cursor: e.cursor } : {},
2169
2202
  ...e.limit ? { limit: e.limit } : {},
2170
2203
  ...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
@@ -2399,12 +2432,12 @@ class Le {
2399
2432
  loadSession(e) {
2400
2433
  const t = x(), n = this.activeComposerWarmupId;
2401
2434
  this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages);
2402
- const i = this.getCachedSessionTimeline(e), r = [...i ?? []].reverse().find((a) => a.dataType === "assistant_draft" && a.steered !== !0), o = Rr(i ?? []);
2435
+ const i = this.getCachedSessionTimeline(e), r = [...i ?? []].reverse().find((a) => a.dataType === "assistant_draft" && a.steered !== !0), o = Cr(i ?? []);
2403
2436
  !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({
2404
2437
  type: "session.reset",
2405
2438
  warmupId: n,
2406
- page: P()
2407
- }), 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 = t, this.sessionActivityRequestId = null, this.setState({
2439
+ page: _()
2440
+ }), this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), 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 = t, this.sessionActivityRequestId = null, this.setState({
2408
2441
  sessionId: e,
2409
2442
  // A session-keyed timeline can render immediately while the subscription handshake and authoritative
2410
2443
  // history reload preserve the live-event race guarantees for this selected chat.
@@ -2426,7 +2459,7 @@ class Le {
2426
2459
  type: "session.load",
2427
2460
  requestId: t,
2428
2461
  sessionId: e,
2429
- page: P()
2462
+ page: _()
2430
2463
  });
2431
2464
  }
2432
2465
  canLoadSessionHistoryOverHttp() {
@@ -2472,7 +2505,7 @@ class Le {
2472
2505
  type: "session.load",
2473
2506
  requestId: t,
2474
2507
  sessionId: e,
2475
- page: P(),
2508
+ page: _(),
2476
2509
  subscribeOnly: !0
2477
2510
  }), n;
2478
2511
  }
@@ -2598,9 +2631,9 @@ class Le {
2598
2631
  }
2599
2632
  }
2600
2633
  reportHealthSignal(e, t = {}) {
2601
- const n = t.clientMessageId ?? this.activeResponseRunId;
2634
+ const n = t.errorFingerprint ?? t.clientMessageId ?? this.activeResponseRunId ?? (t.previousPhase && t.nextPhase ? `${t.previousPhase}:${t.nextPhase}:${t.reason ?? "unknown"}` : null);
2602
2635
  if (n) {
2603
- const r = `${e}:${n}`;
2636
+ const r = `${e}:${n}:${e === "invalid_state_transition" ? t.reason ?? "unknown" : ""}`;
2604
2637
  if (this.reportedHealthSignalKeys.has(r))
2605
2638
  return;
2606
2639
  this.reportedHealthSignalKeys.add(r);
@@ -2615,7 +2648,7 @@ class Le {
2615
2648
  ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
2616
2649
  ...t
2617
2650
  };
2618
- if (this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN) {
2651
+ if (this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN || this.authenticatedSocket !== this.socket) {
2619
2652
  this.queueHealthDiagnostic(i);
2620
2653
  return;
2621
2654
  }
@@ -2631,6 +2664,27 @@ class Le {
2631
2664
  }), this.queueHealthDiagnostic(i);
2632
2665
  }
2633
2666
  }
2667
+ startFirstResponseTimer(e, t) {
2668
+ this.clearFirstResponseTimer(e);
2669
+ const n = t ?? Date.now(), i = window.setTimeout(() => {
2670
+ this.firstResponseTimersByClientMessageId.delete(e), this.reportHealthSignal("first_response_slow", {
2671
+ clientMessageId: e,
2672
+ durationMs: Date.now() - n
2673
+ });
2674
+ }, Math.max(0, Xn - (Date.now() - n)));
2675
+ this.firstResponseTimersByClientMessageId.set(e, { submittedAt: n, timer: i });
2676
+ }
2677
+ clearFirstResponseTimer(e) {
2678
+ if (!e)
2679
+ return;
2680
+ const t = this.firstResponseTimersByClientMessageId.get(e);
2681
+ t && (window.clearTimeout(t.timer), this.firstResponseTimersByClientMessageId.delete(e));
2682
+ }
2683
+ clearAllFirstResponseTimers() {
2684
+ for (const { timer: e } of this.firstResponseTimersByClientMessageId.values())
2685
+ window.clearTimeout(e);
2686
+ this.firstResponseTimersByClientMessageId.clear();
2687
+ }
2634
2688
  /** @internal */
2635
2689
  reportTransportDiagnostic(e, t = {}) {
2636
2690
  const n = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", i = `${e}:${t.closeCode ?? "none"}:${n}`, r = (/* @__PURE__ */ new Date()).toISOString(), o = this.transportDiagnosticEpisodes.get(i), a = {
@@ -2727,7 +2781,7 @@ class Le {
2727
2781
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
2728
2782
  return;
2729
2783
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
2730
- const e = Li();
2784
+ const e = Bi();
2731
2785
  this.sendNow(
2732
2786
  L({
2733
2787
  type: "starter_prompts.page_context",
@@ -2738,13 +2792,13 @@ class Le {
2738
2792
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
2739
2793
  }
2740
2794
  startStarterPromptUrlWatcher() {
2741
- this.locationChangeCleanup || (this.locationChangeCleanup = Ni(() => this.handleStarterPromptUrlChange()));
2795
+ this.locationChangeCleanup || (this.locationChangeCleanup = Wi(() => this.handleStarterPromptUrlChange()));
2742
2796
  }
2743
2797
  handleStarterPromptUrlChange() {
2744
2798
  const e = location.href;
2745
2799
  e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
2746
2800
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
2747
- }, ci));
2801
+ }, ui));
2748
2802
  }
2749
2803
  refreshStarterPromptsForCurrentUrl() {
2750
2804
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -2774,7 +2828,7 @@ class Le {
2774
2828
  }
2775
2829
  rememberSessionTimeline(e, t) {
2776
2830
  const n = [...t];
2777
- for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > li; ) {
2831
+ for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > ci; ) {
2778
2832
  const i = this.sessionTimelineCache.keys().next().value;
2779
2833
  if (!i)
2780
2834
  break;
@@ -2837,7 +2891,7 @@ class Le {
2837
2891
  reason: A(n, "reason"),
2838
2892
  stoppedItemId: A(t, "id"),
2839
2893
  stoppedAt: A(t, "createdAt"),
2840
- stoppedCausalSequence: _(n),
2894
+ stoppedCausalSequence: P(n),
2841
2895
  toolCallIds: new Set(
2842
2896
  this.state.messages.filter(
2843
2897
  (a) => Ae(a, i, r)
@@ -2866,7 +2920,7 @@ class Le {
2866
2920
  if (!r || i?.type === "message" && i.role === "user" || Ce(i))
2867
2921
  return !0;
2868
2922
  if (r.stoppedCausalSequence !== null) {
2869
- const o = i ? _(i) : null;
2923
+ const o = i ? P(i) : null;
2870
2924
  return o === null || o <= r.stoppedCausalSequence;
2871
2925
  }
2872
2926
  if (r.stoppedAt) {
@@ -2928,7 +2982,7 @@ class Le {
2928
2982
  }
2929
2983
  }
2930
2984
  if (!this.shouldIgnoreStoppedTurnEvent(e) && (this.updateInactiveSessionTimelineCache(e), !this.shouldIgnoreBackgroundSessionEvent(e))) {
2931
- if (e.type === "run.steered") {
2985
+ if (Si(e) && this.clearFirstResponseTimer(this.activeClientMessageId), e.type === "run.steered") {
2932
2986
  this.handleRunSteered(e);
2933
2987
  return;
2934
2988
  }
@@ -2943,16 +2997,16 @@ class Le {
2943
2997
  this.activeResponseRunId = t, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
2944
2998
  return;
2945
2999
  }
2946
- if (yi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
3000
+ if (Ii(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2947
3001
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.transportDiagnosticEpisodes.clear();
2948
- const t = Zi(e.user);
3002
+ const t = sr(e.user);
2949
3003
  this.authenticatedSocket !== this.socket && this.authenticatedUserId && t && t.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = t?.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();
2950
- const n = Qi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
3004
+ const n = Ji(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
2951
3005
  b("web-sdk.agent", "Received auth.ok appearance", {
2952
3006
  hasAppearance: i,
2953
3007
  rawAppearance: e.appearance,
2954
3008
  normalizedAppearance: n
2955
- }), this.runtimeHelperJavascript = Vi(e.runtimeHelpers)?.javascript ?? null;
3009
+ }), this.runtimeHelperJavascript = Yi(e.runtimeHelpers)?.javascript ?? null;
2956
3010
  const r = Vt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
2957
3011
  user: t,
2958
3012
  status: "connected",
@@ -2965,7 +3019,7 @@ class Le {
2965
3019
  }), o && r.length === 0 && !a && !et() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2966
3020
  type: "page.upsert",
2967
3021
  sessionId: this.state.sessionId,
2968
- page: P(),
3022
+ page: _(),
2969
3023
  model: this.options.model
2970
3024
  });
2971
3025
  return;
@@ -3003,7 +3057,7 @@ class Le {
3003
3057
  runId: u?.runId
3004
3058
  }), g = this.filterStoppedSnapshotItems(n, r), f = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, h = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
3005
3059
  f && h && (this.pendingClientMessageId = h);
3006
- let m = ar(
3060
+ let m = ur(
3007
3061
  e.assistantDraft
3008
3062
  );
3009
3063
  m && this.findStoppedTurn(r, {
@@ -3012,9 +3066,9 @@ class Le {
3012
3066
  }) && (m = void 0);
3013
3067
  const M = m !== void 0;
3014
3068
  this.rememberUserMessageClientMessageIds(g);
3015
- const w = Tr(g), D = g.filter((U) => {
3069
+ const w = Mr(g), D = g.filter((U) => {
3016
3070
  const q = C(U);
3017
- return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(g, q) !== w;
3071
+ return wr(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(g, q) !== w;
3018
3072
  }), S = lt(
3019
3073
  this.state.messages,
3020
3074
  st(D, this.options.backendUrl)
@@ -3025,12 +3079,12 @@ class Le {
3025
3079
  v,
3026
3080
  re,
3027
3081
  Y,
3028
- wr(g, q)
3082
+ br(g, q)
3029
3083
  )
3030
- ), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), Q = mr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
3031
- if (!T && Sr(this.state.messages, g))
3084
+ ), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), Q = Sr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
3085
+ if (!T && Ar(this.state.messages, g))
3032
3086
  return;
3033
- this.lastUserMessagePageUrl = yr(g);
3087
+ this.lastUserMessagePageUrl = Tr(g);
3034
3088
  const j = B || d ? null : ut(g);
3035
3089
  if (this.latestRecoverableClientMessageId = j, Q && this.clearRetryTimers(), this.setState({
3036
3090
  sessionId: A(e.session, "id") ?? this.state.sessionId,
@@ -3103,14 +3157,14 @@ class Le {
3103
3157
  this.options.backendUrl
3104
3158
  );
3105
3159
  t === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
3106
- messages: dr(this.state.messages, i)
3160
+ messages: gr(this.state.messages, i)
3107
3161
  });
3108
3162
  return;
3109
3163
  }
3110
3164
  if (e.type === "sessions.page") {
3111
3165
  const t = typeof e.requestId == "string" ? e.requestId : null, n = t ? this.pendingSessionHistoryRequests.get(t) : null;
3112
3166
  t && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(t), n.resolve({
3113
- sessions: er(e.sessions),
3167
+ sessions: nr(e.sessions),
3114
3168
  nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
3115
3169
  }));
3116
3170
  return;
@@ -3145,15 +3199,15 @@ class Le {
3145
3199
  }
3146
3200
  const n = ve(e.item, this.options.backendUrl);
3147
3201
  if (n) {
3148
- const i = Cr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
3149
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), F(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Mr(t) && this.clearRunAckResyncRetryTimer();
3202
+ const i = vr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
3203
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), F(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), kr(t) && this.clearRunAckResyncRetryTimer();
3150
3204
  const o = de(this.state.messages, n), a = ss(o), l = ns(
3151
3205
  t,
3152
3206
  this.state.assistantDraft,
3153
3207
  this.state.assistantDraftItemId,
3154
3208
  this.state.assistantDraftRespondsToUserMessageId,
3155
3209
  this.state.assistantDraftRunId,
3156
- _s(
3210
+ Ps(
3157
3211
  o,
3158
3212
  o.findIndex((d) => d.id === n.id)
3159
3213
  )
@@ -3322,13 +3376,13 @@ class Le {
3322
3376
  return;
3323
3377
  }
3324
3378
  o && i && r && (this.retryableClientMessageId = r);
3325
- const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Oi(a.message);
3379
+ const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Ni(a.message);
3326
3380
  l && console.error(l);
3327
3381
  const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, d = rs(
3328
3382
  this.state.messages,
3329
3383
  c,
3330
3384
  u
3331
- ), g = fr(
3385
+ ), g = Ir(
3332
3386
  d,
3333
3387
  c,
3334
3388
  u
@@ -3495,7 +3549,7 @@ class Le {
3495
3549
  }
3496
3550
  e.type === "error" && typeof e.requestId != "string" && !is(e, t) && this.rememberSessionTimeline(
3497
3551
  t,
3498
- kr(n, e)
3552
+ _r(n, e)
3499
3553
  );
3500
3554
  }
3501
3555
  }
@@ -3601,7 +3655,7 @@ class Le {
3601
3655
  }, e);
3602
3656
  }
3603
3657
  clearThinkingWatchdog() {
3604
- this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId = null, this.activeResponseUserMessageId = null, this.activeResponseRunId = null, this.activeUserMessageEvent = null;
3658
+ this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.clearFirstResponseTimer(this.activeClientMessageId), this.activeClientMessageId = null, this.activeResponseUserMessageId = null, this.activeResponseRunId = null, this.activeUserMessageEvent = null;
3605
3659
  }
3606
3660
  handleRunAck(e) {
3607
3661
  const t = typeof e.clientMessageId == "string" ? e.clientMessageId : null, n = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId;
@@ -3657,17 +3711,18 @@ class Le {
3657
3711
  if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
3658
3712
  return;
3659
3713
  const t = this.retryAttemptsByClientMessageId[e] ?? 0;
3660
- if (t >= Xn) {
3714
+ if (t >= Jn) {
3661
3715
  this.failPendingDelivery(e);
3662
3716
  return;
3663
3717
  }
3664
3718
  t === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = t + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
3665
3719
  this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
3666
- }, ui(t, ei));
3720
+ }, di(t, ti));
3667
3721
  }
3668
3722
  failPendingDelivery(e) {
3669
3723
  if (this.pendingClientMessageId !== e)
3670
3724
  return;
3725
+ this.clearFirstResponseTimer(e);
3671
3726
  const t = this.pendingUserMessageEvent;
3672
3727
  this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = t, this.retryableClientMessageId = e, this.setState({
3673
3728
  pendingMessageStatus: null,
@@ -3675,7 +3730,7 @@ class Le {
3675
3730
  ...this.state.isThinking ? {} : { turnPhase: null },
3676
3731
  isRetrying: !1,
3677
3732
  ...this.state.isThinking ? {} : { taskStatus: "failed" },
3678
- lastError: Yn,
3733
+ lastError: Zn,
3679
3734
  lastErrorCode: "message_delivery_failed"
3680
3735
  });
3681
3736
  }
@@ -3742,7 +3797,7 @@ class Le {
3742
3797
  ),
3743
3798
  isThinking: !1,
3744
3799
  taskStatus: "failed",
3745
- lastError: Jn,
3800
+ lastError: Yn,
3746
3801
  lastErrorCode: "run_recovery_exhausted"
3747
3802
  }), this.clearThinkingWatchdog();
3748
3803
  return;
@@ -3758,7 +3813,7 @@ class Le {
3758
3813
  this.state.sessionId ? this.send({
3759
3814
  type: "page.upsert",
3760
3815
  sessionId: this.state.sessionId,
3761
- page: P(),
3816
+ page: _(),
3762
3817
  model: this.options.model
3763
3818
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
3764
3819
  }
@@ -3769,7 +3824,7 @@ class Le {
3769
3824
  if (!t || !n || !i)
3770
3825
  return;
3771
3826
  const a = i === "execute_code", l = i === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
3772
- if (!a && !l || !Xr(o)) {
3827
+ if (!a && !l || !Zr(o)) {
3773
3828
  this.setToolMessageLoading(n, !1), this.send({
3774
3829
  type: "tool.result",
3775
3830
  sessionId: t,
@@ -3818,7 +3873,7 @@ class Le {
3818
3873
  let c = null, u;
3819
3874
  c = await this.executeRuntimeHelper(), u = await Gt(
3820
3875
  o,
3821
- _i(e.runtimeContext, this.options.backendUrl)
3876
+ Di(e.runtimeContext, this.options.backendUrl)
3822
3877
  ).catch((d) => ({
3823
3878
  ok: !1,
3824
3879
  exception: {
@@ -3831,7 +3886,7 @@ class Le {
3831
3886
  toolName: i,
3832
3887
  summary: o.summary,
3833
3888
  rawInput: L(o),
3834
- rawOutput: L(Xi(u, c))
3889
+ rawOutput: L(Zi(u, c))
3835
3890
  }), ls(this.options.clientId, this.activeBrowserToolCalls.values()));
3836
3891
  }
3837
3892
  setToolMessageLoading(e, t) {
@@ -3853,10 +3908,10 @@ class Le {
3853
3908
  };
3854
3909
  }
3855
3910
  installSessionBrowserApis() {
3856
- this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Ti();
3911
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Mi();
3857
3912
  }
3858
3913
  cleanupSessionBrowserApis() {
3859
- this.sessionBrowserApisCleanup && (Ci(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3914
+ this.sessionBrowserApisCleanup && (vi(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3860
3915
  }
3861
3916
  async executeRuntimeHelper() {
3862
3917
  if (!this.runtimeHelperJavascript?.trim())
@@ -3864,31 +3919,31 @@ class Le {
3864
3919
  const e = await Gt({
3865
3920
  javascript: this.runtimeHelperJavascript
3866
3921
  });
3867
- return e.ok === !1 ? Ji(e) : null;
3922
+ return e.ok === !1 ? er(e) : null;
3868
3923
  }
3869
3924
  enableNetworkCapture() {
3870
- this.networkCaptureCleanup || (this.networkCaptureCleanup = fi((e) => {
3871
- so(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3925
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = mi((e) => {
3926
+ ro(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3872
3927
  }));
3873
3928
  }
3874
3929
  enqueueNetworkEvent(e) {
3875
- this.queuedNetworkEvents.length >= si || (this.queuedNetworkEvents.push(to(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3930
+ this.queuedNetworkEvents.length >= ni || (this.queuedNetworkEvents.push(io(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3876
3931
  this.networkBatchTimer = null;
3877
3932
  const t = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
3878
3933
  t.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
3879
3934
  type: "network.batch",
3880
3935
  sessionId: this.state.sessionId ?? void 0,
3881
- page: P(),
3936
+ page: _(),
3882
3937
  events: t
3883
3938
  });
3884
- }, ti)));
3939
+ }, si)));
3885
3940
  }
3886
3941
  scheduleReconnect(e = 0) {
3887
3942
  if (this.reconnectTimer !== null || this.state.status === "closed")
3888
3943
  return;
3889
3944
  const t = Math.min(
3890
3945
  ot,
3891
- Math.max(di(this.reconnectAttempts), e)
3946
+ Math.max(hi(this.reconnectAttempts), e)
3892
3947
  );
3893
3948
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
3894
3949
  this.reconnectTimer = null, this.connect().catch((n) => {
@@ -3943,8 +3998,13 @@ class Le {
3943
3998
  taskStatus: r,
3944
3999
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
3945
4000
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
3946
- }, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null;
3947
- this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Nr(this.options.clientId, this.state), this.emit("state", this.getState()), Je("state", this.state.status, {
4001
+ }, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null, u = this.activeClientMessageId ?? this.pendingClientMessageId;
4002
+ u && u === this.lastProjectedTurnClientMessageId && c && Ti(this.lastProjectedTurnPhase, o.turnPhase) && this.reportHealthSignal("invalid_state_transition", {
4003
+ clientMessageId: u,
4004
+ reason: "active_turn_phase_moved_backward",
4005
+ previousPhase: this.lastProjectedTurnPhase,
4006
+ nextPhase: o.turnPhase
4007
+ }), this.state = o, this.lastProjectedTurnClientMessageId = u, this.lastProjectedTurnPhase = o.turnPhase, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Wr(this.options.clientId, this.state), this.emit("state", this.getState()), Je("state", this.state.status, {
3948
4008
  status: this.state.status,
3949
4009
  sessionId: this.state.sessionId,
3950
4010
  messageCount: this.state.messages.length,
@@ -4003,13 +4063,13 @@ class Le {
4003
4063
  }
4004
4064
  }
4005
4065
  const Ze = /* @__PURE__ */ new WeakMap();
4006
- function fi(s) {
4007
- const e = window.__plunoProductAgentNetworkCapture ?? mi();
4066
+ function mi(s) {
4067
+ const e = window.__plunoProductAgentNetworkCapture ?? yi();
4008
4068
  return e.subscribers.add(s), () => {
4009
4069
  e.subscribers.delete(s), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
4010
4070
  };
4011
4071
  }
4012
- function mi() {
4072
+ function yi() {
4013
4073
  const s = /* @__PURE__ */ new Set(), e = (g) => {
4014
4074
  s.forEach((f) => {
4015
4075
  try {
@@ -4026,7 +4086,7 @@ function mi() {
4026
4086
  throw m;
4027
4087
  }
4028
4088
  try {
4029
- const m = f instanceof Request ? f : null, M = Jr(f, m), w = xs(h?.headers ?? m?.headers);
4089
+ const m = f instanceof Request ? f : null, M = eo(f, m), w = xs(h?.headers ?? m?.headers);
4030
4090
  if (!te(M, w, h?.body)) {
4031
4091
  const H = {
4032
4092
  requestId: nt("fetch"),
@@ -4039,7 +4099,7 @@ function mi() {
4039
4099
  };
4040
4100
  y.then(
4041
4101
  (S) => {
4042
- Yr(S, H, p, e).catch(() => {
4102
+ to(S, H, p, e).catch(() => {
4043
4103
  e({
4044
4104
  ...H,
4045
4105
  responseStatus: S.status,
@@ -4081,7 +4141,7 @@ function mi() {
4081
4141
  () => {
4082
4142
  queueMicrotask(() => {
4083
4143
  try {
4084
- const p = io(this.getAllResponseHeaders());
4144
+ const p = ao(this.getAllResponseHeaders());
4085
4145
  e({
4086
4146
  requestId: h.requestId,
4087
4147
  url: h.url,
@@ -4091,7 +4151,7 @@ function mi() {
4091
4151
  resourceType: "xhr",
4092
4152
  responseStatus: this.status,
4093
4153
  responseHeaders: p,
4094
- responseBody: eo(this, p),
4154
+ responseBody: no(this, p),
4095
4155
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
4096
4156
  startedAt: h.startedAt,
4097
4157
  durationMs: Date.now() - h.startedAtMs
@@ -4187,9 +4247,29 @@ function Kt(s) {
4187
4247
  const e = typeof s == "function" ? s() : s;
4188
4248
  return e && Object.keys(e).length > 0 ? e : void 0;
4189
4249
  }
4190
- function yi(s) {
4250
+ function Ii(s) {
4191
4251
  return s.type === "run.model_started" || s.type === "conversation.state" || s.type === "session.updated" || s.type === "session.item" || s.type === "chat.assistant_delta" || s.type === "chat.assistant_done" || s.type === "tool.call";
4192
4252
  }
4253
+ function Si(s) {
4254
+ if (s.type === "chat.assistant_delta")
4255
+ return typeof s.delta == "string" && s.delta.trim().length > 0;
4256
+ if (s.type === "tool.call")
4257
+ return s.hiddenFromTranscript !== !0 && s.replayOnly !== !0;
4258
+ if (s.type !== "session.item")
4259
+ return !1;
4260
+ const e = C(s.item);
4261
+ return e ? e.type === "message" && e.role === "assistant" ? typeof e.content == "string" && e.content.trim().length > 0 : e.type === "tool_call" || e.type === "function_call" : !1;
4262
+ }
4263
+ function Ti(s, e) {
4264
+ if (!s || !e)
4265
+ return !1;
4266
+ const t = {
4267
+ sending: 0,
4268
+ starting: 1,
4269
+ thinking: 2
4270
+ };
4271
+ return t[e] < t[s];
4272
+ }
4193
4273
  function ce(s) {
4194
4274
  return s.type === "run.steered" || s.type === "run.ack" || s.type === "run.model_started" || s.type === "conversation.state" || s.type === "scheduled_follow_ups.updated" || s.type === "session.updated" || s.type === "session.item" || s.type === "chat.assistant_delta" || s.type === "chat.assistant_done" || s.type === "tool.call" || s.type === "tool.status" || s.type === "error" && typeof s.requestId != "string";
4195
4275
  }
@@ -4208,27 +4288,27 @@ function K(s) {
4208
4288
  }
4209
4289
  return null;
4210
4290
  }
4211
- const Ii = 5e3, Si = 12e4;
4212
- function Ti() {
4291
+ const wi = 5e3, Ai = 12e4;
4292
+ function Mi() {
4213
4293
  const s = [
4214
- Ai(),
4215
- wi()
4294
+ Ri(),
4295
+ bi()
4216
4296
  ].filter((e) => typeof e == "function");
4217
4297
  return () => {
4218
4298
  for (const e of s.reverse())
4219
4299
  e();
4220
4300
  };
4221
4301
  }
4222
- function wi() {
4302
+ function bi() {
4223
4303
  return hs(globalThis, "getPageSnapshot", async () => At());
4224
4304
  }
4225
- function Ai() {
4305
+ function Ri() {
4226
4306
  return hs(globalThis, "pageImages", {
4227
- inspectImage: async (e, t) => await Mi(e, t)
4307
+ inspectImage: async (e, t) => await ki(e, t)
4228
4308
  });
4229
4309
  }
4230
- async function Mi(s, e = {}) {
4231
- const t = Ei(e.name), n = await bi(s);
4310
+ async function ki(s, e = {}) {
4311
+ const t = Pi(e.name), n = await Ei(s);
4232
4312
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
4233
4313
  type: "pluno.pageImages.inspectImage",
4234
4314
  imageAttached: !1,
@@ -4246,15 +4326,15 @@ async function Mi(s, e = {}) {
4246
4326
  imageAttachmentError: n.error
4247
4327
  };
4248
4328
  }
4249
- async function bi(s) {
4329
+ async function Ei(s) {
4250
4330
  return s instanceof Blob ? s.type.startsWith("image/") ? s.size === 0 ? { ok: !1, error: "Page image is empty." } : s.size > 8 * 1024 * 1024 ? { ok: !1, error: ws } : {
4251
4331
  ok: !0,
4252
4332
  mimeType: s.type,
4253
4333
  sizeBytes: s.size,
4254
- dataUrl: await Pi(s)
4255
- } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof s != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Ri(s);
4334
+ dataUrl: await Ui(s)
4335
+ } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof s != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Ci(s);
4256
4336
  }
4257
- function Ri(s) {
4337
+ function Ci(s) {
4258
4338
  if (!s.startsWith("data:") || !s.includes(","))
4259
4339
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
4260
4340
  const [e, t] = s.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), i = n[0] ?? "";
@@ -4265,7 +4345,7 @@ function Ri(s) {
4265
4345
  const r = t.replace(/[ \t\r\n\f]+/g, "");
4266
4346
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(r))
4267
4347
  return { ok: !1, error: "Page image data URL has invalid base64." };
4268
- const o = ki(r);
4348
+ const o = _i(r);
4269
4349
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
4270
4350
  ok: !0,
4271
4351
  mimeType: i,
@@ -4273,22 +4353,22 @@ function Ri(s) {
4273
4353
  dataUrl: `data:${i};base64,${r}`
4274
4354
  };
4275
4355
  }
4276
- function ki(s) {
4356
+ function _i(s) {
4277
4357
  if (s.length === 0 || s.length % 4 !== 0)
4278
4358
  return null;
4279
4359
  const e = s.length - s.replace(/=+$/, "").length;
4280
4360
  return e > 2 ? null : s.length / 4 * 3 - e;
4281
4361
  }
4282
- function Ei(s) {
4362
+ function Pi(s) {
4283
4363
  return (typeof s == "string" ? s.trim() : "") || "Page image";
4284
4364
  }
4285
- function Ci(s) {
4365
+ function vi(s) {
4286
4366
  try {
4287
4367
  s();
4288
4368
  } catch {
4289
4369
  }
4290
4370
  }
4291
- function Pi(s) {
4371
+ function Ui(s) {
4292
4372
  return new Promise((e, t) => {
4293
4373
  const n = new FileReader();
4294
4374
  n.onload = () => {
@@ -4302,7 +4382,7 @@ function Pi(s) {
4302
4382
  }
4303
4383
  async function Gt(s, e) {
4304
4384
  const t = Object.getPrototypeOf(async function() {
4305
- }).constructor, n = s.timeoutMs ?? Ii, i = Date.now(), r = [];
4385
+ }).constructor, n = s.timeoutMs ?? wi, i = Date.now(), r = [];
4306
4386
  let o;
4307
4387
  const a = {
4308
4388
  log: console.log,
@@ -4320,7 +4400,7 @@ async function Gt(s, e) {
4320
4400
  o = window.setTimeout(() => d(c), n);
4321
4401
  })
4322
4402
  ]);
4323
- return u === c ? vi(n) : {
4403
+ return u === c ? qi(n) : {
4324
4404
  ok: !0,
4325
4405
  result: u,
4326
4406
  console: r,
@@ -4349,7 +4429,7 @@ async function Gt(s, e) {
4349
4429
  e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
4350
4430
  }
4351
4431
  }
4352
- function _i(s, e) {
4432
+ function Di(s, e) {
4353
4433
  if (!s || typeof s != "object")
4354
4434
  return;
4355
4435
  const t = s.sandboxFilesToken;
@@ -4393,7 +4473,7 @@ function _i(s, e) {
4393
4473
  }
4394
4474
  };
4395
4475
  }
4396
- function vi(s) {
4476
+ function qi(s) {
4397
4477
  return {
4398
4478
  ok: !1,
4399
4479
  exception: {
@@ -4407,10 +4487,10 @@ function vi(s) {
4407
4487
  }
4408
4488
  };
4409
4489
  }
4410
- function Ui(s) {
4490
+ function Oi(s) {
4411
4491
  return s.replace(/\/+$/, "");
4412
4492
  }
4413
- function Di(s) {
4493
+ function xi(s) {
4414
4494
  const e = {
4415
4495
  sidepanel: "extension_sidepanel",
4416
4496
  browser_extension_page_ui: "extension_widget",
@@ -4422,17 +4502,17 @@ function Di(s) {
4422
4502
  };
4423
4503
  return s && s in e ? e[s] : s ?? "embedded_custom_ui";
4424
4504
  }
4425
- function qi(s) {
4505
+ function Li(s) {
4426
4506
  return s === "pluno" ? "scheduled_continuation" : s ?? "user";
4427
4507
  }
4428
- function Oi(s, e = location.origin) {
4508
+ function Ni(s, e = location.origin) {
4429
4509
  return /origin (?:is not allowed|does not match browser origin)/i.test(s) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
4430
4510
  }
4431
- function xi(s) {
4511
+ function Hi(s) {
4432
4512
  const e = new URL("/api/product-agent/embed/ws", s);
4433
4513
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
4434
4514
  }
4435
- function P() {
4515
+ function _() {
4436
4516
  const s = ks();
4437
4517
  return {
4438
4518
  url: location.href,
@@ -4441,19 +4521,19 @@ function P() {
4441
4521
  ...s ? { plunoProductAgentUi: s } : {}
4442
4522
  };
4443
4523
  }
4444
- function Li() {
4524
+ function Bi() {
4445
4525
  return {
4446
4526
  pageUrl: location.href,
4447
4527
  pageTitle: document.title,
4448
4528
  htmlContent: At()
4449
4529
  };
4450
4530
  }
4451
- function Ni(s) {
4452
- return Ee.add(s), Te || (Te = Hi()), () => {
4531
+ function Wi(s) {
4532
+ return Ee.add(s), Te || (Te = Fi()), () => {
4453
4533
  Ee.delete(s), Ee.size === 0 && (Te?.(), Te = null);
4454
4534
  };
4455
4535
  }
4456
- function Hi() {
4536
+ function Fi() {
4457
4537
  const s = () => {
4458
4538
  for (const r of Array.from(Ee))
4459
4539
  r();
@@ -4484,12 +4564,12 @@ function At() {
4484
4564
  );
4485
4565
  for (const p of i.slice(0, 3))
4486
4566
  t("Active overlay", tt(he(p), e));
4487
- const r = Bi(), o = r ? tt(he(r), e) : "";
4567
+ const r = $i(), o = r ? tt(he(r), e) : "";
4488
4568
  t("Main page content", o), t("Additional visible page text", tt(he(document.body), e));
4489
4569
  const a = s.map(([p, y]) => `${p}:
4490
4570
  ${y}`).join(`
4491
4571
 
4492
- `).trim().slice(0, 12e3), l = Wi(i, r).trim(), c = `Simplified DOM outline:
4572
+ `).trim().slice(0, 12e3), l = ji(i, r).trim(), c = `Simplified DOM outline:
4493
4573
  `, u = `
4494
4574
 
4495
4575
  Visible page text:
@@ -4517,10 +4597,10 @@ function Ms(s) {
4517
4597
  const e = window.getComputedStyle(s);
4518
4598
  return e.display !== "none" && e.visibility !== "hidden" && s.getClientRects().length > 0;
4519
4599
  }
4520
- function Bi() {
4600
+ function $i() {
4521
4601
  return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ms).sort((s, e) => he(e).length - he(s).length)[0] ?? null;
4522
4602
  }
4523
- function Wi(s, e) {
4603
+ function ji(s, e) {
4524
4604
  const t = /* @__PURE__ */ new Set([
4525
4605
  "main",
4526
4606
  "nav",
@@ -4600,7 +4680,7 @@ function Wi(s, e) {
4600
4680
  "data-test",
4601
4681
  "data-qa",
4602
4682
  "data-cy"
4603
- ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = Fi(), g = new Set(s);
4683
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = zi(), g = new Set(s);
4604
4684
  e && g.add(e);
4605
4685
  let f = 0;
4606
4686
  const h = (w) => {
@@ -4627,13 +4707,13 @@ function Wi(s, e) {
4627
4707
  }
4628
4708
  const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], kt = [];
4629
4709
  for (const I of B) {
4630
- const R = p(I), z = Q.get(R) ?? 0, Pt = j.get(R) ?? 0;
4631
- if (j.set(R, Pt + 1), z > 8 && Pt >= 6 && !u.has(I)) {
4710
+ const R = p(I), z = Q.get(R) ?? 0, _t = j.get(R) ?? 0;
4711
+ if (j.set(R, _t + 1), z > 8 && _t >= 6 && !u.has(I)) {
4632
4712
  U.has(R) || (q.push([`… ${me.get(R) ?? 0} similar siblings omitted`]), U.add(R));
4633
4713
  continue;
4634
4714
  }
4635
- const _t = S(I, N);
4636
- kt.push(_t), q.push(_t.lines);
4715
+ const Pt = S(I, N);
4716
+ kt.push(Pt), q.push(Pt.lines);
4637
4717
  }
4638
4718
  const Be = [];
4639
4719
  if (T.shadowRoot)
@@ -4670,7 +4750,7 @@ function Wi(s, e) {
4670
4750
  `);
4671
4751
  }, m = [], M = ne(window.getSelection()?.toString() ?? "");
4672
4752
  M && m.push(`--- selected text ---
4673
- ${JSON.stringify(M)}`), d.length > 0 && m.push($i(d, t, l, o));
4753
+ ${JSON.stringify(M)}`), d.length > 0 && m.push(Ki(d, t, l, o));
4674
4754
  for (const w of s.slice(0, 3))
4675
4755
  m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4676
4756
  if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
@@ -4685,7 +4765,7 @@ function bs(s, e, t, n) {
4685
4765
  const i = s.tagName.toLowerCase();
4686
4766
  let r = i;
4687
4767
  const o = s.getAttribute("id");
4688
- o && ji(o) && (r += `#${o}`);
4768
+ o && Gi(o) && (r += `#${o}`);
4689
4769
  for (const a of e) {
4690
4770
  const l = s.getAttribute(a);
4691
4771
  l && l.length <= 160 && (a !== "role" || !t.has(l)) && (r += `[${a}=${JSON.stringify(l)}]`);
@@ -4698,7 +4778,7 @@ function bs(s, e, t, n) {
4698
4778
  s.hasAttribute(a) && (r += `[${a}]`);
4699
4779
  return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
4700
4780
  }
4701
- function Fi() {
4781
+ function zi() {
4702
4782
  const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
4703
4783
  if (!a)
4704
4784
  return;
@@ -4741,7 +4821,7 @@ function Fi() {
4741
4821
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
4742
4822
  };
4743
4823
  }
4744
- function $i(s, e, t, n) {
4824
+ function Ki(s, e, t, n) {
4745
4825
  const i = ["--- active/current elements ---"];
4746
4826
  for (const r of s) {
4747
4827
  const o = [];
@@ -4777,7 +4857,7 @@ function Rs(s) {
4777
4857
  Array.from(s.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
4778
4858
  );
4779
4859
  }
4780
- function ji(s) {
4860
+ function Gi(s) {
4781
4861
  return s.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(s) && !/[a-f0-9]{12,}/i.test(s) && !/:r[0-9a-z]+:/i.test(s);
4782
4862
  }
4783
4863
  function ks() {
@@ -4814,7 +4894,7 @@ function ks() {
4814
4894
  ]
4815
4895
  };
4816
4896
  }
4817
- function zi(s) {
4897
+ function Qi(s) {
4818
4898
  try {
4819
4899
  const e = JSON.parse(s);
4820
4900
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -4822,7 +4902,7 @@ function zi(s) {
4822
4902
  return { type: "error", message: "Invalid server event" };
4823
4903
  }
4824
4904
  }
4825
- function Ki(s) {
4905
+ function Vi(s) {
4826
4906
  if (typeof s != "string")
4827
4907
  return null;
4828
4908
  try {
@@ -4846,10 +4926,10 @@ function Xt(s) {
4846
4926
  return typeof t.taskId != "string" || !t.taskId || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? [] : [{ taskId: t.taskId, dueAt: t.dueAt }];
4847
4927
  }) : [];
4848
4928
  }
4849
- function Gi(s) {
4929
+ function Xi(s) {
4850
4930
  return Array.isArray(s) ? s.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
4851
4931
  }
4852
- function Qi(s) {
4932
+ function Ji(s) {
4853
4933
  if (!s || typeof s != "object")
4854
4934
  return null;
4855
4935
  const e = s, t = e.appearance, n = t && typeof t == "object" ? t : e, i = typeof n.accentColor == "string" ? n.accentColor : null, r = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
@@ -4860,13 +4940,13 @@ function Qi(s) {
4860
4940
  ...a !== null ? { scribbleStyle: a } : {}
4861
4941
  };
4862
4942
  }
4863
- function Vi(s) {
4943
+ function Yi(s) {
4864
4944
  if (!s || typeof s != "object")
4865
4945
  return null;
4866
4946
  const e = s.javascript;
4867
4947
  return typeof e != "string" || !e.trim() ? null : { javascript: e };
4868
4948
  }
4869
- function Xi(s, e) {
4949
+ function Zi(s, e) {
4870
4950
  return e ? s && typeof s == "object" ? {
4871
4951
  ...s,
4872
4952
  helperError: e
@@ -4876,13 +4956,13 @@ function Xi(s, e) {
4876
4956
  helperError: e
4877
4957
  } : s;
4878
4958
  }
4879
- function Ji(s) {
4959
+ function er(s) {
4880
4960
  if (!s || typeof s != "object")
4881
4961
  return s;
4882
4962
  const e = s;
4883
4963
  return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : s;
4884
4964
  }
4885
- function Yi() {
4965
+ function tr() {
4886
4966
  const s = "pluno.productAgent.clientId", e = window.localStorage.getItem(s);
4887
4967
  if (e)
4888
4968
  return e;
@@ -4892,7 +4972,7 @@ function Yi() {
4892
4972
  function x() {
4893
4973
  return crypto.randomUUID();
4894
4974
  }
4895
- function Zi(s) {
4975
+ function sr(s) {
4896
4976
  if (!s || typeof s != "object")
4897
4977
  return null;
4898
4978
  const e = s, t = typeof e.id == "string" ? e.id : null;
@@ -4908,7 +4988,7 @@ function st(s, e) {
4908
4988
  s.map((t) => ve(t, e)).filter((t) => t !== null)
4909
4989
  ) : [];
4910
4990
  }
4911
- function er(s) {
4991
+ function nr(s) {
4912
4992
  return Array.isArray(s) ? s.flatMap((e) => {
4913
4993
  if (!e || typeof e != "object")
4914
4994
  return [];
@@ -4949,7 +5029,7 @@ function ve(s, e) {
4949
5029
  ),
4950
5030
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4951
5031
  ...E(i) !== null ? { displaySequence: E(i) } : {},
4952
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5032
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
4953
5033
  respondsToUserMessageId: O(i) ?? void 0,
4954
5034
  ...k(i) ? { runId: k(i) } : {},
4955
5035
  dataType: "assistant_draft",
@@ -4966,7 +5046,7 @@ function ve(s, e) {
4966
5046
  ),
4967
5047
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4968
5048
  ...E(i) !== null ? { displaySequence: E(i) } : {},
4969
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5049
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
4970
5050
  respondsToUserMessageId: O(i) ?? void 0,
4971
5051
  ...k(i) ? { runId: k(i) } : {},
4972
5052
  attachments: Ds(i.attachments, e),
@@ -5015,14 +5095,14 @@ function ve(s, e) {
5015
5095
  scheduledCheckInId: o.id ?? void 0,
5016
5096
  scheduledCheckInAt: o.dueAt
5017
5097
  };
5018
- const a = sr(i.output), l = nr(i.output);
5098
+ const a = rr(i.output), l = or(i.output);
5019
5099
  return a ? {
5020
5100
  id: String(t.id ?? crypto.randomUUID()),
5021
5101
  role: "tool",
5022
5102
  content: `Connect ${a.appName} to continue`,
5023
5103
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
5024
5104
  ...E(i) !== null ? { displaySequence: E(i) } : {},
5025
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5105
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
5026
5106
  respondsToUserMessageId: O(i) ?? void 0,
5027
5107
  ...k(i) ? { runId: k(i) } : {},
5028
5108
  dataType: "function_call_output",
@@ -5035,7 +5115,7 @@ function ve(s, e) {
5035
5115
  content: "Connect WhatsApp to continue",
5036
5116
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
5037
5117
  ...E(i) !== null ? { displaySequence: E(i) } : {},
5038
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5118
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
5039
5119
  respondsToUserMessageId: O(i) ?? void 0,
5040
5120
  ...k(i) ? { runId: k(i) } : {},
5041
5121
  dataType: "function_call_output",
@@ -5047,10 +5127,10 @@ function ve(s, e) {
5047
5127
  return i.type === "function_call" || i.type === "tool_call" || i.type === "web_search_call" || i.type === "mcp_call" || i.type === "tab_lifecycle_decision" ? {
5048
5128
  id: String(t.id ?? crypto.randomUUID()),
5049
5129
  role: "tool",
5050
- content: i.type === "mcp_call" ? tr(i) : rr(i),
5130
+ content: i.type === "mcp_call" ? ir(i) : lr(i),
5051
5131
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
5052
5132
  ...E(i) !== null ? { displaySequence: E(i) } : {},
5053
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5133
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
5054
5134
  respondsToUserMessageId: O(i) ?? void 0,
5055
5135
  ...k(i) ? { runId: k(i) } : {},
5056
5136
  dataType: String(i.type),
@@ -5061,10 +5141,10 @@ function ve(s, e) {
5061
5141
  } : i.type === "run_status" || i.type === "run_error" ? i.type === "run_error" && i.stage === "tool_execution" ? null : {
5062
5142
  id: String(t.id ?? crypto.randomUUID()),
5063
5143
  role: "system",
5064
- content: ir(i),
5144
+ content: ar(i),
5065
5145
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
5066
5146
  ...E(i) !== null ? { displaySequence: E(i) } : {},
5067
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5147
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
5068
5148
  respondsToUserMessageId: O(i) ?? void 0,
5069
5149
  ...k(i) ? { runId: k(i) } : {},
5070
5150
  dataType: String(i.type),
@@ -5074,11 +5154,11 @@ function ve(s, e) {
5074
5154
  ...typeof i.securitySettingsUrl == "string" ? { securitySettingsUrl: i.securitySettingsUrl } : {}
5075
5155
  } : null;
5076
5156
  }
5077
- function tr(s) {
5157
+ function ir(s) {
5078
5158
  const t = (typeof s.server_label == "string" ? s.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
5079
5159
  return t ? `🔌 Using ${t}` : "🔌 Using connected integration";
5080
5160
  }
5081
- function sr(s) {
5161
+ function rr(s) {
5082
5162
  if (typeof s != "string")
5083
5163
  return null;
5084
5164
  try {
@@ -5095,7 +5175,7 @@ function sr(s) {
5095
5175
  return null;
5096
5176
  }
5097
5177
  }
5098
- function nr(s) {
5178
+ function or(s) {
5099
5179
  if (typeof s != "string")
5100
5180
  return null;
5101
5181
  try {
@@ -5110,10 +5190,10 @@ function nr(s) {
5110
5190
  return null;
5111
5191
  }
5112
5192
  }
5113
- function ir(s) {
5193
+ function ar(s) {
5114
5194
  return s.type === "run_status" && s.status === "steered" ? "Steered" : typeof s.message == "string" && s.message.trim().length > 0 ? s.message : "";
5115
5195
  }
5116
- function rr(s) {
5196
+ function lr(s) {
5117
5197
  if (s.type === "web_search_call") {
5118
5198
  const e = s.action;
5119
5199
  if (e && typeof e == "object") {
@@ -5125,9 +5205,9 @@ function rr(s) {
5125
5205
  }
5126
5206
  return "🔎 Searching the web";
5127
5207
  }
5128
- return or(s);
5208
+ return cr(s);
5129
5209
  }
5130
- function or(s) {
5210
+ function cr(s) {
5131
5211
  if (typeof s.summary == "string" && s.summary.trim().length > 0)
5132
5212
  return se(s.summary);
5133
5213
  if (typeof s.arguments == "string")
@@ -5144,7 +5224,7 @@ function se(s) {
5144
5224
  const e = s.trim() || "Run tool", t = e.codePointAt(0) ?? 0;
5145
5225
  return t >= 126976 && t <= 129791 || t >= 9728 && t <= 10175 || t >= 127462 && t <= 127487 ? e : `🛠️ ${e}`;
5146
5226
  }
5147
- function ar(s) {
5227
+ function ur(s) {
5148
5228
  if (s == null)
5149
5229
  return s;
5150
5230
  if (typeof s != "object")
@@ -5163,7 +5243,7 @@ function ue(s) {
5163
5243
  const e = s.callId ?? s.call_id;
5164
5244
  return typeof e == "string" && e ? e : null;
5165
5245
  }
5166
- function _(s) {
5246
+ function P(s) {
5167
5247
  return typeof s.causalSequence == "number" && Number.isSafeInteger(s.causalSequence) ? s.causalSequence : null;
5168
5248
  }
5169
5249
  function E(s) {
@@ -5181,10 +5261,10 @@ function de(s, e) {
5181
5261
  const t = Es(
5182
5262
  s,
5183
5263
  Mt(s, e)
5184
- ), n = ur(
5185
- cr(
5186
- gr(
5187
- lr(s, e),
5264
+ ), n = pr(
5265
+ hr(
5266
+ yr(
5267
+ dr(s, e),
5188
5268
  e
5189
5269
  ),
5190
5270
  t
@@ -5209,7 +5289,7 @@ function Mt(s, e, t = !0) {
5209
5289
  const i = s.flatMap((r) => (e.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId === e.respondsToUserMessageId : e.runId !== void 0 && r.respondsToUserMessageId === void 0 && r.runId === e.runId) && r.displaySequence !== void 0 ? [r.displaySequence] : []);
5210
5290
  return e.displaySequence = (i.length > 0 ? Math.max(...i) : 0) + 1, e;
5211
5291
  }
5212
- function lr(s, e) {
5292
+ function dr(s, e) {
5213
5293
  const t = e.proactiveSuggestionClientMessageId;
5214
5294
  if (!t)
5215
5295
  return s;
@@ -5219,7 +5299,7 @@ function lr(s, e) {
5219
5299
  const r = [...s];
5220
5300
  return r[i] = e, r;
5221
5301
  }
5222
- function cr(s, e) {
5302
+ function hr(s, e) {
5223
5303
  const t = e.assistantDraftItemId;
5224
5304
  return t ? s.map(
5225
5305
  (n) => n.dataType === "assistant_draft" && n.id === t ? e : n
@@ -5287,7 +5367,7 @@ function ts(s) {
5287
5367
  loading: !0
5288
5368
  };
5289
5369
  }
5290
- function ur(s, e) {
5370
+ function pr(s, e) {
5291
5371
  if (e.id.startsWith("transient-activity:"))
5292
5372
  return s;
5293
5373
  const t = e.toolName === "tab_lifecycle";
@@ -5313,7 +5393,7 @@ function lt(s, e) {
5313
5393
  ct
5314
5394
  );
5315
5395
  }
5316
- function dr(s, e) {
5396
+ function gr(s, e) {
5317
5397
  const t = new Map(s.map((r) => [r.id, r])), n = e.map(
5318
5398
  (r) => Mt(s, r, !1)
5319
5399
  );
@@ -5363,22 +5443,22 @@ function Es(s, e) {
5363
5443
  if (!t?.attachments?.length)
5364
5444
  return e;
5365
5445
  const n = e.attachments.map((o) => {
5366
- const a = hr(t.attachments ?? [], o);
5367
- return a ? pr(o, a) : o;
5446
+ const a = fr(t.attachments ?? [], o);
5447
+ return a ? mr(o, a) : o;
5368
5448
  }), i = { ...e, attachments: n }, r = J(e);
5369
5449
  return r && Object.defineProperty(i, "clientMessageId", {
5370
5450
  value: r,
5371
5451
  enumerable: !1
5372
5452
  }), i;
5373
5453
  }
5374
- function hr(s, e) {
5454
+ function fr(s, e) {
5375
5455
  return e.id ? s.find((t) => t.id === e.id) ?? null : null;
5376
5456
  }
5377
- function pr(s, e) {
5457
+ function mr(s, e) {
5378
5458
  const { previewUrl: t } = e;
5379
5459
  return t ? { ...s, previewUrl: t } : s;
5380
5460
  }
5381
- function gr(s, e) {
5461
+ function yr(s, e) {
5382
5462
  if (e.role !== "user")
5383
5463
  return s;
5384
5464
  const t = s.findIndex(
@@ -5406,7 +5486,7 @@ function J(s) {
5406
5486
  return n ? s.id.slice(n.length) : null;
5407
5487
  }
5408
5488
  function ss(s) {
5409
- const e = Ps(s);
5489
+ const e = _s(s);
5410
5490
  if (e === null)
5411
5491
  return !1;
5412
5492
  const t = s[e].id;
@@ -5429,7 +5509,7 @@ function ss(s) {
5429
5509
  }
5430
5510
  return !1;
5431
5511
  }
5432
- function fr(s, e, t) {
5512
+ function Ir(s, e, t) {
5433
5513
  const n = new Set(
5434
5514
  s.filter(
5435
5515
  (i) => i.role === "user" && e !== null && J(i) === e
@@ -5443,14 +5523,14 @@ function fr(s, e, t) {
5443
5523
  if (t && i.runId === t) {
5444
5524
  if (n.size === 0)
5445
5525
  return !0;
5446
- const o = _s(s, r);
5526
+ const o = Ps(s, r);
5447
5527
  return !i.respondsToUserMessageId && o !== null && n.has(o);
5448
5528
  }
5449
5529
  return !1;
5450
5530
  });
5451
5531
  }
5452
- function mr(s) {
5453
- const e = Ps(s);
5532
+ function Sr(s) {
5533
+ const e = _s(s);
5454
5534
  if (e === null)
5455
5535
  return s.some(F);
5456
5536
  const t = s[e].id;
@@ -5458,7 +5538,7 @@ function mr(s) {
5458
5538
  (n) => n.respondsToUserMessageId === t && F(n)
5459
5539
  ) : s.slice(e + 1).some(F);
5460
5540
  }
5461
- function Ps(s) {
5541
+ function _s(s) {
5462
5542
  for (let e = s.length - 1; e >= 0; e -= 1)
5463
5543
  if (s[e].role === "user" && !Ne(s[e]))
5464
5544
  return e;
@@ -5481,7 +5561,7 @@ function ie(s) {
5481
5561
  }
5482
5562
  return null;
5483
5563
  }
5484
- function yr(s) {
5564
+ function Tr(s) {
5485
5565
  const e = ie(s);
5486
5566
  if (e === null)
5487
5567
  return null;
@@ -5500,10 +5580,10 @@ function C(s) {
5500
5580
  function pe(s) {
5501
5581
  return s?.retryable !== !0 ? !1 : s.type === "run_error" ? !0 : s.type === "run_status" && s.status === "interrupted";
5502
5582
  }
5503
- function Ir(s) {
5583
+ function wr(s) {
5504
5584
  return s?.type === "run_status" && s.status === "interrupted" && s.reason === "backend_restart";
5505
5585
  }
5506
- function Sr(s, e) {
5586
+ function Ar(s, e) {
5507
5587
  const t = ie(e);
5508
5588
  if (t === null)
5509
5589
  return !1;
@@ -5528,7 +5608,7 @@ function ut(s) {
5528
5608
  const i = n.clientMessageId;
5529
5609
  return typeof i == "string" ? i : null;
5530
5610
  }
5531
- function Tr(s) {
5611
+ function Mr(s) {
5532
5612
  const e = ie(s);
5533
5613
  if (e === null)
5534
5614
  return null;
@@ -5559,7 +5639,7 @@ function dt(s, e) {
5559
5639
  return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
5560
5640
  }
5561
5641
  function ns(s, e, t, n, i, r) {
5562
- if (!e || !Ar(s))
5642
+ if (!e || !Rr(s))
5563
5643
  return !1;
5564
5644
  const o = s;
5565
5645
  if (pe(o) || t !== null && typeof o.id == "string" && o.id !== t)
@@ -5567,7 +5647,7 @@ function ns(s, e, t, n, i, r) {
5567
5647
  const a = O(o);
5568
5648
  return n !== null ? a !== null ? a === n : i !== null && k(o) === i && r === n : i === null || k(o) === i;
5569
5649
  }
5570
- function wr(s, e) {
5650
+ function br(s, e) {
5571
5651
  for (let t = e - 1; t >= 0; t -= 1) {
5572
5652
  const n = C(s[t]);
5573
5653
  if (n?.type === "message" && n.role === "user")
@@ -5575,13 +5655,13 @@ function wr(s, e) {
5575
5655
  }
5576
5656
  return null;
5577
5657
  }
5578
- function _s(s, e) {
5658
+ function Ps(s, e) {
5579
5659
  for (let t = e - 1; t >= 0; t -= 1)
5580
5660
  if (s[t].role === "user")
5581
5661
  return s[t].id;
5582
5662
  return null;
5583
5663
  }
5584
- function Ar(s) {
5664
+ function Rr(s) {
5585
5665
  if (!s || typeof s != "object")
5586
5666
  return !1;
5587
5667
  const e = s;
@@ -5590,16 +5670,16 @@ function Ar(s) {
5590
5670
  function F(s) {
5591
5671
  return s.role === "assistant" && s.phase !== "commentary";
5592
5672
  }
5593
- function Mr(s) {
5673
+ function kr(s) {
5594
5674
  if (!s || typeof s != "object")
5595
5675
  return !1;
5596
5676
  const e = s;
5597
5677
  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";
5598
5678
  }
5599
5679
  function ht(s) {
5600
- return s.filter((e, t) => G(e) ? !xr(s, t) && !vs(s, t) && !qr(s, t) && !Or(s, t) : br(e) ? e.retryable === !0 && Dr(s, t) ? !1 : !Ur(s, t) : !0);
5680
+ return s.filter((e, t) => G(e) ? !Hr(s, t) && !vs(s, t) && !Lr(s, t) && !Nr(s, t) : Er(e) ? e.retryable === !0 && xr(s, t) ? !1 : !Or(s, t) : !0);
5601
5681
  }
5602
- function br(s) {
5682
+ function Er(s) {
5603
5683
  return s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.steered !== !0);
5604
5684
  }
5605
5685
  function G(s) {
@@ -5608,17 +5688,17 @@ function G(s) {
5608
5688
  function pt(s) {
5609
5689
  return s.steered !== !0 && (s.dataType === "assistant_draft" || s.loading === !0);
5610
5690
  }
5611
- function Rr(s) {
5691
+ function Cr(s) {
5612
5692
  return s.some(pt);
5613
5693
  }
5614
5694
  function is(s, e) {
5615
5695
  return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
5616
5696
  }
5617
- function kr(s, e) {
5697
+ function _r(s, e) {
5618
5698
  const t = [...s].reverse().find(pt), n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : t?.respondsToUserMessageId ?? null, i = typeof e.runId == "string" ? e.runId : t?.runId ?? null;
5619
5699
  return s.flatMap((r) => (n ? r.respondsToUserMessageId === n || !r.respondsToUserMessageId && i !== null && r.runId === i : i ? r.runId === i : pt(r)) ? r.dataType === "assistant_draft" || G(r) ? [] : r.loading === !0 ? [{ ...r, loading: !1 }] : [r] : [r]);
5620
5700
  }
5621
- function Er(s, e, t, n) {
5701
+ function Pr(s, e, t, n) {
5622
5702
  const i = s.findIndex(
5623
5703
  (l, c) => G(l) && !vs(s, c)
5624
5704
  ), r = i === -1 ? null : s[i], o = e ?? r?.respondsToUserMessageId ?? null, a = o ? s.find(
@@ -5633,7 +5713,7 @@ function Er(s, e, t, n) {
5633
5713
  function Ce(s) {
5634
5714
  return s?.type === "run_status" && s.status === "stopped";
5635
5715
  }
5636
- function Cr(s, e) {
5716
+ function vr(s, e) {
5637
5717
  return F(e) ? "completed" : Ce(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
5638
5718
  }
5639
5719
  function rs(s, e, t) {
@@ -5648,14 +5728,14 @@ function rs(s, e, t) {
5648
5728
  }
5649
5729
  function vs(s, e) {
5650
5730
  return s.some(
5651
- (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && Pr(
5731
+ (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && Ur(
5652
5732
  s,
5653
5733
  e,
5654
5734
  n
5655
5735
  )
5656
5736
  );
5657
5737
  }
5658
- function Pr(s, e, t) {
5738
+ function Ur(s, e, t) {
5659
5739
  const n = s[e], i = s[t];
5660
5740
  if (ge(n, i))
5661
5741
  return !0;
@@ -5668,11 +5748,11 @@ function Pr(s, e, t) {
5668
5748
  }
5669
5749
  function os(s, e, t, n) {
5670
5750
  const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
5671
- (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && as(l) && !vr(
5751
+ (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && as(l) && !qr(
5672
5752
  s,
5673
5753
  l.respondsToUserMessageId
5674
5754
  )
5675
- )?.respondsToUserMessageId ?? _r(
5755
+ )?.respondsToUserMessageId ?? Dr(
5676
5756
  s,
5677
5757
  e
5678
5758
  );
@@ -5701,7 +5781,7 @@ function os(s, e, t, n) {
5701
5781
  }
5702
5782
  ];
5703
5783
  }
5704
- function _r(s, e) {
5784
+ function Dr(s, e) {
5705
5785
  const t = s.findIndex(
5706
5786
  (n) => n.role === "user" && n.id === e
5707
5787
  );
@@ -5715,12 +5795,12 @@ function _r(s, e) {
5715
5795
  function as(s) {
5716
5796
  return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
5717
5797
  }
5718
- function vr(s, e) {
5798
+ function qr(s, e) {
5719
5799
  return s.some(
5720
5800
  (t) => t.respondsToUserMessageId === e && (F(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
5721
5801
  );
5722
5802
  }
5723
- function Ur(s, e) {
5803
+ function Or(s, e) {
5724
5804
  const t = s[e];
5725
5805
  for (let n = e + 1; n < s.length; n += 1) {
5726
5806
  const i = s[n];
@@ -5729,7 +5809,7 @@ function Ur(s, e) {
5729
5809
  }
5730
5810
  return !1;
5731
5811
  }
5732
- function Dr(s, e) {
5812
+ function xr(s, e) {
5733
5813
  const t = s[e];
5734
5814
  if (!t.respondsToUserMessageId)
5735
5815
  return !1;
@@ -5742,19 +5822,19 @@ function Dr(s, e) {
5742
5822
  }
5743
5823
  return !1;
5744
5824
  }
5745
- function qr(s, e) {
5825
+ function Lr(s, e) {
5746
5826
  const t = s[e];
5747
5827
  return s.some(
5748
5828
  (n, i) => i !== e && n.role === "assistant" && ge(t, n)
5749
5829
  );
5750
5830
  }
5751
- function Or(s, e) {
5831
+ function Nr(s, e) {
5752
5832
  const t = s[e];
5753
5833
  return s.some(
5754
5834
  (n, i) => i !== e && n.role === "tool" && ge(t, n)
5755
5835
  );
5756
5836
  }
5757
- function xr(s, e) {
5837
+ function Hr(s, e) {
5758
5838
  const t = s[e];
5759
5839
  for (let n = e + 1; n < s.length; n += 1)
5760
5840
  if (G(s[n]) && ge(t, s[n]))
@@ -5767,7 +5847,7 @@ function ge(s, e) {
5767
5847
  function A(s, e) {
5768
5848
  return s && typeof s == "object" && typeof s[e] == "string" ? s[e] : null;
5769
5849
  }
5770
- function Lr(s, e) {
5850
+ function Br(s, e) {
5771
5851
  try {
5772
5852
  const t = window.localStorage.getItem(`${As}${s}`);
5773
5853
  if (!t)
@@ -5775,7 +5855,7 @@ function Lr(s, e) {
5775
5855
  const n = JSON.parse(t), i = typeof n.sessionId == "string" ? n.sessionId : null;
5776
5856
  if (e !== void 0 && i !== e)
5777
5857
  return null;
5778
- const r = Array.isArray(n.messages) ? n.messages.map(Qr).filter((o) => !!o) : [];
5858
+ const r = Array.isArray(n.messages) ? n.messages.map(Jr).filter((o) => !!o) : [];
5779
5859
  return {
5780
5860
  sessionId: i,
5781
5861
  messages: r
@@ -5789,20 +5869,20 @@ function gt(s) {
5789
5869
  // running tool or commentary history from disappearing while authoritative hydration is still in flight.
5790
5870
  s.role === "tool" || s.dataType === "run_status" || s.dataType === "run_error";
5791
5871
  }
5792
- function Nr(s, e) {
5872
+ function Wr(s, e) {
5793
5873
  try {
5794
5874
  window.localStorage.setItem(
5795
5875
  `${As}${s}`,
5796
5876
  JSON.stringify({
5797
5877
  sessionId: e.sessionId,
5798
- messages: e.messages.filter(gt).slice(-ai).map(Vr)
5878
+ messages: e.messages.filter(gt).slice(-li).map(Yr)
5799
5879
  })
5800
5880
  );
5801
5881
  } catch {
5802
5882
  return;
5803
5883
  }
5804
5884
  }
5805
- function Hr(s) {
5885
+ function Fr(s) {
5806
5886
  try {
5807
5887
  const e = window.localStorage.getItem(`${at}${s}`);
5808
5888
  if (!e)
@@ -5853,19 +5933,19 @@ function ls(s, e) {
5853
5933
  }
5854
5934
  Us(s, e);
5855
5935
  }
5856
- function Br(s) {
5936
+ function $r(s) {
5857
5937
  try {
5858
5938
  const e = `${xe}${s}`, t = window.sessionStorage.getItem(e);
5859
5939
  if (window.sessionStorage.removeItem(e), !t)
5860
5940
  return [];
5861
5941
  const n = JSON.parse(t);
5862
- return Array.isArray(n) ? n.flatMap((i) => Fr(i) ? [{
5942
+ return Array.isArray(n) ? n.flatMap((i) => zr(i) ? [{
5863
5943
  ...i.event,
5864
- page: P(),
5944
+ page: _(),
5865
5945
  rawOutput: {
5866
5946
  pageContextRestarted: !0,
5867
5947
  outcome: "unknown",
5868
- message: Wr(location.href),
5948
+ message: jr(location.href),
5869
5949
  currentUrl: location.href,
5870
5950
  console: [],
5871
5951
  metadata: {
@@ -5882,17 +5962,17 @@ function Br(s) {
5882
5962
  return [];
5883
5963
  }
5884
5964
  }
5885
- function Wr(s) {
5965
+ function jr(s) {
5886
5966
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
5887
5967
  Current URL: ${s}`;
5888
5968
  }
5889
- function Fr(s) {
5969
+ function zr(s) {
5890
5970
  if (!s || typeof s != "object")
5891
5971
  return !1;
5892
5972
  const e = s, t = e.event;
5893
5973
  return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && bt(t) && t.type === "tool.result";
5894
5974
  }
5895
- function $r(s, e) {
5975
+ function Kr(s, e) {
5896
5976
  const t = new Set(
5897
5977
  s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
5898
5978
  );
@@ -5901,7 +5981,7 @@ function $r(s, e) {
5901
5981
  ...e.filter((n) => !t.has(n.callId))
5902
5982
  ];
5903
5983
  }
5904
- function jr(s) {
5984
+ function Gr(s) {
5905
5985
  try {
5906
5986
  window.sessionStorage.removeItem(`${xe}${s}`);
5907
5987
  } catch {
@@ -5938,9 +6018,9 @@ function qs(s, e) {
5938
6018
  } : s;
5939
6019
  }
5940
6020
  function ft(s) {
5941
- return s.type || Gr(s.name) || "application/octet-stream";
6021
+ return s.type || Xr(s.name) || "application/octet-stream";
5942
6022
  }
5943
- function zr(s) {
6023
+ function Qr(s) {
5944
6024
  Os({
5945
6025
  name: s.name,
5946
6026
  mimeType: ft(s),
@@ -5948,21 +6028,21 @@ function zr(s) {
5948
6028
  });
5949
6029
  }
5950
6030
  function Os(s) {
5951
- const e = Kr(s.name), t = s.mimeType.trim().toLowerCase();
5952
- if (!ii.has(`${e}:${t}`))
6031
+ const e = Vr(s.name), t = s.mimeType.trim().toLowerCase();
6032
+ if (!ri.has(`${e}:${t}`))
5953
6033
  throw new Error("This attachment type is not supported by the embedded model provider");
5954
6034
  if (s.sizeBytes <= 0 || s.sizeBytes >= Ts)
5955
6035
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
5956
6036
  }
5957
- function Kr(s) {
6037
+ function Vr(s) {
5958
6038
  const e = s.trim().toLowerCase(), t = e.lastIndexOf(".");
5959
6039
  return t >= 0 ? e.slice(t) : "";
5960
6040
  }
5961
- function Gr(s) {
6041
+ function Xr(s) {
5962
6042
  const e = s.toLowerCase();
5963
6043
  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;
5964
6044
  }
5965
- function Qr(s) {
6045
+ function Jr(s) {
5966
6046
  if (!s || typeof s != "object")
5967
6047
  return null;
5968
6048
  const e = s;
@@ -5984,7 +6064,7 @@ function Qr(s) {
5984
6064
  loading: typeof e.loading == "boolean" ? e.loading : void 0
5985
6065
  };
5986
6066
  }
5987
- function Vr(s) {
6067
+ function Yr(s) {
5988
6068
  return s.attachments?.length ? {
5989
6069
  ...s,
5990
6070
  attachments: s.attachments.map(De)
@@ -6008,9 +6088,9 @@ function k(s) {
6008
6088
  const e = s.runId;
6009
6089
  return typeof e == "string" && e ? e : null;
6010
6090
  }
6011
- function Xr(s) {
6091
+ function Zr(s) {
6012
6092
  const e = s?.timeoutMs;
6013
- return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Si);
6093
+ return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Ai);
6014
6094
  }
6015
6095
  function xs(s) {
6016
6096
  const e = {};
@@ -6024,22 +6104,22 @@ function xs(s) {
6024
6104
  return e;
6025
6105
  }
6026
6106
  function Rt(s, e) {
6027
- return Fs(s) ? He : W(Oe(e), ri);
6107
+ return Fs(s) ? He : W(Oe(e), oi);
6028
6108
  }
6029
- function Jr(s, e) {
6109
+ function eo(s, e) {
6030
6110
  return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
6031
6111
  }
6032
- async function Yr(s, e, t, n) {
6112
+ async function to(s, e, t, n) {
6033
6113
  const i = xs(s.headers);
6034
6114
  n({
6035
6115
  ...e,
6036
6116
  responseStatus: s.status,
6037
6117
  responseHeaders: i,
6038
- responseBody: await Zr(s),
6118
+ responseBody: await so(s),
6039
6119
  durationMs: Date.now() - t
6040
6120
  });
6041
6121
  }
6042
- async function Zr(s) {
6122
+ async function so(s) {
6043
6123
  if (!Ls(s.headers))
6044
6124
  return;
6045
6125
  let e = null, t = null;
@@ -6049,7 +6129,7 @@ async function Zr(s) {
6049
6129
  const n = new Promise((a) => {
6050
6130
  t = window.setTimeout(() => {
6051
6131
  e?.cancel(), a("timeout");
6052
- }, oi);
6132
+ }, ai);
6053
6133
  }), i = new TextDecoder();
6054
6134
  let r = "", o = 0;
6055
6135
  for (; ; ) {
@@ -6071,7 +6151,7 @@ async function Zr(s) {
6071
6151
  t !== null && window.clearTimeout(t);
6072
6152
  }
6073
6153
  }
6074
- function eo(s, e) {
6154
+ function no(s, e) {
6075
6155
  if (Ls(new Headers(e)))
6076
6156
  try {
6077
6157
  return s.responseType === "" || s.responseType === "text" ? W(s.responseText ?? "") : void 0;
@@ -6083,7 +6163,7 @@ function us(s) {
6083
6163
  if (typeof s == "string")
6084
6164
  return W(s);
6085
6165
  }
6086
- function to(s) {
6166
+ function io(s) {
6087
6167
  return L({
6088
6168
  ...s,
6089
6169
  requestBody: ds(s.requestBody),
@@ -6109,7 +6189,7 @@ function Ls(s) {
6109
6189
  return t !== null && Number.isInteger(n) && n >= 0 && n <= Tt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
6110
6190
  }
6111
6191
  function te(s, e = {}, t) {
6112
- if (no(t))
6192
+ if (oo(t))
6113
6193
  return !0;
6114
6194
  const n = Object.entries(e).find(([i]) => i.toLowerCase() === "content-type")?.[1]?.toLowerCase();
6115
6195
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -6124,7 +6204,7 @@ function te(s, e = {}, t) {
6124
6204
  return !0;
6125
6205
  }
6126
6206
  }
6127
- function so(s, e) {
6207
+ function ro(s, e) {
6128
6208
  if (te(s))
6129
6209
  return !0;
6130
6210
  try {
@@ -6134,10 +6214,10 @@ function so(s, e) {
6134
6214
  return !0;
6135
6215
  }
6136
6216
  }
6137
- function no(s) {
6217
+ function oo(s) {
6138
6218
  return s instanceof FormData || s instanceof Blob || s instanceof ArrayBuffer || ArrayBuffer.isView(s) || typeof ReadableStream < "u" && s instanceof ReadableStream;
6139
6219
  }
6140
- function io(s) {
6220
+ function ao(s) {
6141
6221
  const e = {};
6142
6222
  for (const t of s.trim().split(/[\r\n]+/)) {
6143
6223
  const n = t.indexOf(":");
@@ -6156,7 +6236,7 @@ function W(s, e = Tt) {
6156
6236
  function nt(s) {
6157
6237
  return `${s}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
6158
6238
  }
6159
- class Pe extends Error {
6239
+ class _e extends Error {
6160
6240
  constructor(e, t) {
6161
6241
  super(`${e} (${t})`), this.status = t, this.name = "AttachmentUploadHttpError";
6162
6242
  }
@@ -6168,27 +6248,27 @@ async function Me(s, e) {
6168
6248
  try {
6169
6249
  return await s();
6170
6250
  } catch (i) {
6171
- if (t = i, n >= zt - 1 || !oo(i))
6251
+ if (t = i, n >= zt - 1 || !co(i))
6172
6252
  throw i;
6173
- await ro(n);
6253
+ await lo(n);
6174
6254
  }
6175
6255
  throw t instanceof Error ? t : new Error(e);
6176
6256
  }
6177
- function ro(s) {
6257
+ function lo(s) {
6178
6258
  return new Promise((e) => {
6179
- window.setTimeout(e, ni[s] ?? 0);
6259
+ window.setTimeout(e, ii[s] ?? 0);
6180
6260
  });
6181
6261
  }
6182
- function oo(s) {
6183
- return s instanceof Pe ? ao(s.status) : s instanceof TypeError;
6262
+ function co(s) {
6263
+ return s instanceof _e ? uo(s.status) : s instanceof TypeError;
6184
6264
  }
6185
- function ao(s) {
6265
+ function uo(s) {
6186
6266
  return s === 408 || s === 409 || s === 429 || s >= 500;
6187
6267
  }
6188
- function lo(s) {
6268
+ function ho(s) {
6189
6269
  return s === 401 || s === 403;
6190
6270
  }
6191
- const He = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", co = "[REDACTED_SIGNED_URL]", uo = 20, ho = /^(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, Ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\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, po = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, go = /\bhttps?:\/\/[^\s"'<>]+/gi, fo = /[),.;\]]+$/;
6271
+ const He = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", po = "[REDACTED_SIGNED_URL]", go = 20, fo = /^(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, Ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\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, mo = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, yo = /\bhttps?:\/\/[^\s"'<>]+/gi, Io = /[),.;\]]+$/;
6192
6272
  function L(s) {
6193
6273
  return qe(s, 0, /* @__PURE__ */ new WeakSet());
6194
6274
  }
@@ -6197,7 +6277,7 @@ function qe(s, e, t) {
6197
6277
  return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : Oe(s);
6198
6278
  if (s === null || typeof s != "object")
6199
6279
  return s;
6200
- if (e >= uo)
6280
+ if (e >= go)
6201
6281
  return "[REDACTED_MAX_DEPTH]";
6202
6282
  if (t.has(s))
6203
6283
  return "[REDACTED_CIRCULAR]";
@@ -6205,40 +6285,40 @@ function qe(s, e, t) {
6205
6285
  return s.map((i) => qe(i, e + 1, t));
6206
6286
  const n = {};
6207
6287
  for (const [i, r] of Object.entries(s))
6208
- i === "pageContent" ? n[i] = r : Fs(i) ? n[i] = He : n[i] = i.toLowerCase() === "url" ? mo(r) : qe(r, e + 1, t);
6288
+ i === "pageContent" ? n[i] = r : Fs(i) ? n[i] = He : n[i] = i.toLowerCase() === "url" ? So(r) : qe(r, e + 1, t);
6209
6289
  return n;
6210
6290
  }
6211
6291
  function Fs(s) {
6212
6292
  const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
6213
6293
  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");
6214
6294
  }
6215
- function mo(s) {
6295
+ function So(s) {
6216
6296
  return typeof s == "string" ? $s(s) : qe(s, 0, /* @__PURE__ */ new WeakSet());
6217
6297
  }
6218
6298
  function $s(s) {
6219
6299
  try {
6220
6300
  const e = new URL(s, location.href);
6221
6301
  for (const t of Array.from(e.searchParams.keys()))
6222
- ho.test(t) && e.searchParams.set(t, $);
6302
+ fo.test(t) && e.searchParams.set(t, $);
6223
6303
  return e.username && (e.username = $), e.password && (e.password = $), e.toString();
6224
6304
  } catch {
6225
- return yo(s);
6305
+ return To(s);
6226
6306
  }
6227
6307
  }
6228
6308
  function Oe(s) {
6229
- return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
6309
+ return s.replace(mo, po).replace(yo, wo).replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
6230
6310
  }
6231
- function yo(s) {
6311
+ function To(s) {
6232
6312
  return s.replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
6233
6313
  }
6234
- function Io(s) {
6235
- const e = s.match(fo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6314
+ function wo(s) {
6315
+ const e = s.match(Io)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6236
6316
  return `${$s(t)}${e}`;
6237
6317
  }
6238
- const Eo = Object.freeze({
6318
+ const Po = Object.freeze({
6239
6319
  init: (s) => Le.init(s)
6240
6320
  });
6241
- function Co(s) {
6321
+ function vo(s) {
6242
6322
  return Le.init(s);
6243
6323
  }
6244
6324
  export {
@@ -6246,30 +6326,30 @@ export {
6246
6326
  Dn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
6247
6327
  Un as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
6248
6328
  qn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
6249
- ko as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6250
- Eo as PlunoProductAgent,
6329
+ _o as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6330
+ Po as PlunoProductAgent,
6251
6331
  kn as ProductAgentInteractionManager,
6252
6332
  xt as ProductAgentQueryController,
6253
- Ro as ProductAgentRemoteRuntimeClient,
6333
+ Co as ProductAgentRemoteRuntimeClient,
6254
6334
  Le as ProductAgentSessionEngine,
6255
6335
  Mn as ProductAgentSessionHistoryManager,
6256
- Ao as ProductAgentTaskPageTitleController,
6336
+ Ro as ProductAgentTaskPageTitleController,
6257
6337
  X as ProductAgentTokenProviderError,
6258
- di as calculateReconnectDelay,
6259
- wo as createLocalStorageInteractionDecisionStorage,
6338
+ hi as calculateReconnectDelay,
6339
+ bo as createLocalStorageInteractionDecisionStorage,
6260
6340
  Re as createProductAgentQueryState,
6261
- Co as createProductAgentRuntime,
6262
- Mo as createProductAgentTaskPageTitleDocument,
6263
- Eo as default,
6264
- _n as formatProductAgentTaskPageTitle,
6265
- Oi as getProductAgentOriginAccessErrorMessage,
6266
- bo as isProductAgentRuntimeCommand,
6341
+ vo as createProductAgentRuntime,
6342
+ ko as createProductAgentTaskPageTitleDocument,
6343
+ Po as default,
6344
+ Pn as formatProductAgentTaskPageTitle,
6345
+ Ni as getProductAgentOriginAccessErrorMessage,
6346
+ Eo as isProductAgentRuntimeCommand,
6267
6347
  Tn as mergeProductAgentEntityPages,
6268
6348
  ke as normalizeProductAgentEntityPage,
6269
6349
  st as normalizeProductAgentSessionItems,
6270
6350
  En as readLocalStorageInteractionDecisions,
6271
- To as resolveProductAgentComposerAction,
6272
- So as resolveProductAgentWidgetPresentation,
6351
+ Mo as resolveProductAgentComposerAction,
6352
+ Ao as resolveProductAgentWidgetPresentation,
6273
6353
  Is as selectProductAgentQueryEntities,
6274
- zr as validateProductAgentProviderInputFile
6354
+ Qr as validateProductAgentProviderInputFile
6275
6355
  };