@pluno/product-agent-web 0.1.266 → 0.1.267

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.
@@ -37,7 +37,7 @@ function Fp(t, e, n, i) {
37
37
  function $p(t) {
38
38
  return Lr(t) > 0.5 ? [24, 24, 27] : [250, 250, 249];
39
39
  }
40
- const Hp = "0.1.266", ri = {
40
+ const Hp = "0.1.267", ri = {
41
41
  version: Hp
42
42
  }, ye = (t) => typeof t == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(t) ? t : null;
43
43
  function Ad(t) {
@@ -84,11 +84,11 @@ function Wp(t) {
84
84
  e = Math.imul(e ^ t.charCodeAt(i), 16777619) >>> 0, n = Math.imul(n ^ t.charCodeAt(i), 33) >>> 0;
85
85
  return `selection:${e.toString(16)}:${n.toString(16)}`;
86
86
  }
87
- const Nr = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], ft = (t) => typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t), Un = (t) => t === null || ft(t), Td = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(t) && Number.isFinite(Date.parse(t));
87
+ const Nr = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], ft = (t) => typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t), zn = (t) => t === null || ft(t), Td = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(t) && Number.isFinite(Date.parse(t));
88
88
  function qd(t) {
89
89
  if (!t || typeof t != "object") return !1;
90
90
  const e = t;
91
- return Object.keys(t).every((n) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(n)) && Un(e.sessionId) && ft(e.itemId) && Un(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && Un(e.runId) && (e.createdAt === null || Td(e.createdAt));
91
+ return Object.keys(t).every((n) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(n)) && zn(e.sessionId) && ft(e.itemId) && zn(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && zn(e.runId) && (e.createdAt === null || Td(e.createdAt));
92
92
  }
93
93
  function Vp(t, e) {
94
94
  const n = t.messages.find((s) => s.id === e && s.dataType === "run_error");
@@ -196,7 +196,7 @@ function Yp(t) {
196
196
  const e = (i) => {
197
197
  if (!i || typeof i != "object") return !1;
198
198
  const s = i;
199
- return Object.keys(i).every((o) => [...Nr, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context", "duplicateToolCalls"].includes(o)) && (s.duplicateToolCalls === void 0 || Array.isArray(s.duplicateToolCalls) && s.duplicateToolCalls.length <= 5 && s.duplicateToolCalls.every((o) => o && Object.keys(o).every((a) => ["key", "count", "rows", "truncated"].includes(a)) && Un(o.key) && Number.isSafeInteger(o.count) && o.count >= 2 && typeof o.truncated == "boolean" && Array.isArray(o.rows) && o.rows.length >= 1 && o.rows.length <= 5 && o.rows.length <= o.count && o.rows.every((a) => a && Object.keys(a).every((r) => ["itemId", "groupId"].includes(r)) && Un(a.itemId) && Un(a.groupId)))) && (s.context === void 0 || Qp(s.context)) && (s.thinkingSequence === void 0 || Array.isArray(s.thinkingSequence) && s.thinkingSequence.length <= 20 && s.thinkingSequence.every((o) => o === "user" || o === "thinking")) && Un(s.sessionId) && Number.isSafeInteger(s.runtimeItemCount) && s.runtimeItemCount >= 0 && typeof s.welcome == "boolean" && typeof s.truncated == "boolean" && Nr.every((o) => Array.isArray(s[o]) && s[o].length <= 20 && s[o].every(ft));
199
+ return Object.keys(i).every((o) => [...Nr, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context", "duplicateToolCalls"].includes(o)) && (s.duplicateToolCalls === void 0 || Array.isArray(s.duplicateToolCalls) && s.duplicateToolCalls.length <= 5 && s.duplicateToolCalls.every((o) => o && Object.keys(o).every((a) => ["key", "count", "rows", "truncated"].includes(a)) && zn(o.key) && Number.isSafeInteger(o.count) && o.count >= 2 && typeof o.truncated == "boolean" && Array.isArray(o.rows) && o.rows.length >= 1 && o.rows.length <= 5 && o.rows.length <= o.count && o.rows.every((a) => a && Object.keys(a).every((r) => ["itemId", "groupId"].includes(r)) && zn(a.itemId) && zn(a.groupId)))) && (s.context === void 0 || Qp(s.context)) && (s.thinkingSequence === void 0 || Array.isArray(s.thinkingSequence) && s.thinkingSequence.length <= 20 && s.thinkingSequence.every((o) => o === "user" || o === "thinking")) && zn(s.sessionId) && Number.isSafeInteger(s.runtimeItemCount) && s.runtimeItemCount >= 0 && typeof s.welcome == "boolean" && typeof s.truncated == "boolean" && Nr.every((o) => Array.isArray(s[o]) && s[o].length <= 20 && s[o].every(ft));
200
200
  }, n = t;
201
201
  return (n.before === null || e(n.before)) && e(n.current);
202
202
  }
@@ -248,20 +248,20 @@ function Xt(t, e = "runtime_error", n = "runtime") {
248
248
  });
249
249
  }
250
250
  const Yc = 500;
251
- function Fn(t) {
251
+ function $n(t) {
252
252
  const e = t.replace(/\n\s*at\s[\s\S]*$/, "").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g, "[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi, "cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi, "[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi, "[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi, "[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g, "[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi, "$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi, "[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b", "gi"), "[FILE]").replace(/\s+/g, " ").trim();
253
253
  return e.length > Yc ? `${e.slice(0, Yc - 1)}…` : e;
254
254
  }
255
- function Dn(t, e = "runtime") {
256
- const n = Xt(t, "runtime_error", e), i = t !== null && typeof t == "object" && "stack" in t && typeof t.stack == "string" ? Fn(t.stack.slice(0, 4e3).split(`
255
+ function Ln(t, e = "runtime") {
256
+ const n = Xt(t, "runtime_error", e), i = t !== null && typeof t == "object" && "stack" in t && typeof t.stack == "string" ? $n(t.stack.slice(0, 4e3).split(`
257
257
  `).slice(0, 6).join(`
258
258
  `).replace(/\n\s*at\s/g, `
259
259
  frame `)) : void 0;
260
260
  return {
261
261
  ...eo(n.details?.errorNormalization) ? { normalization: n.details.errorNormalization } : {},
262
262
  category: t instanceof Error ? "error" : t === null ? "null" : Array.isArray(t) ? "array" : typeof t,
263
- code: Fn(n.code),
264
- message: Fn(n.message),
263
+ code: $n(n.code),
264
+ message: $n(n.message),
265
265
  ...i ? { stack: i } : {}
266
266
  };
267
267
  }
@@ -1155,7 +1155,7 @@ function ji(t, e) {
1155
1155
  function sl(t) {
1156
1156
  return t.kind === "decision" ? zd(t) : t.kind === "proactiveFeedback" ? `prompt:proactive_suggestion:${t.suggestionId}` : "feature" in t ? `${t.kind}:${t.feature}` : t.kind;
1157
1157
  }
1158
- function Pn(t, e, n) {
1158
+ function Mn(t, e, n) {
1159
1159
  return JSON.stringify(["stage7", t.authorityId, t.generation, e, n]);
1160
1160
  }
1161
1161
  function Gr(t, e, n) {
@@ -1202,7 +1202,7 @@ function Gr(t, e, n) {
1202
1202
  const u = (m, S, _) => {
1203
1203
  const x = m === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
1204
1204
  if (!He(r.profile, x) || Di(i, m) !== !0 || i.features.desiredPreferences[m] === !1 || Object.values(i.interactions.devicePending).some((U) => U.feature === m && (S === "check" || U.action !== "check"))) return;
1205
- const R = Pn(r, "device", _), q = { ...i.interactions.deviceErrors };
1205
+ const R = Mn(r, "device", _), q = { ...i.interactions.deviceErrors };
1206
1206
  delete q[m], a({ deviceErrors: q, devicePending: { ...i.interactions.devicePending, [R]: { feature: m, requestId: _, generation: r.generation, desired: !0, action: S } } }), s.push({ kind: "stage7.device", id: R, input: { authority: r, requestId: _, feature: m, action: S, now: i.features.now } });
1207
1207
  }, l = (m, S) => {
1208
1208
  const _ = S ? i.interactions.promptActions[S.replace(/:ack$/, "")] : void 0, x = { ...i.interactions.openings };
@@ -1233,7 +1233,7 @@ function Gr(t, e, n) {
1233
1233
  S.revision <= _.revision || (Di(i, m) === !0 && (S.permission === "granted" && _.permission !== "granted" || S.snoozedUntil && S.snoozedUntil !== _.snoozedUntil) && l(m, null), a({ deviceFacts: { ...i.interactions.deviceFacts, [m]: S } }));
1234
1234
  }, y = (m, S, _ = !1) => {
1235
1235
  ji(r, m);
1236
- const x = At(r, m), R = Pn(r, "query", S);
1236
+ const x = At(r, m), R = Mn(r, "query", S);
1237
1237
  if (m.kind === "originContext") {
1238
1238
  const z = i.features.queries[x], B = i.features.contextReads[x];
1239
1239
  if (o({ originContextQueries: { ...i.features.originContextQueries, [x]: m } }), !_ && (z?.status === "ready" || z?.status === "error") && B && (i.features.now - B.settledAt < 3e4 || z.error && !z.error.retryable && z.error.code !== "runtime_error")) return;
@@ -1256,7 +1256,7 @@ function Gr(t, e, n) {
1256
1256
  } } }), m.kind === "account" && (i = { ...i, account: { ...i.account, query: ei(i.account.query, { key: x, requestId: Et(S), mode: "replace" }) } }), s.push({ kind: "stage7.query", id: R, input: { authority: r, requestId: S, query: m } });
1257
1257
  }, f = (m, S, _ = !1) => {
1258
1258
  if (ji(r, m), m.kind === "report" && !i.account.query.data?.user?.isSuperuser) throw new Error("Chat reporting requires superuser access.");
1259
- const x = Pn(r, "mutate", S), R = JSON.stringify(m), q = i.features.pending[x];
1259
+ const x = Mn(r, "mutate", S), R = JSON.stringify(m), q = i.features.pending[x];
1260
1260
  if (q) {
1261
1261
  if (q.fingerprint !== R) throw new Error("Request ID was reused with a different payload.");
1262
1262
  if (!_ || q.status !== "error") return;
@@ -1266,7 +1266,7 @@ function Gr(t, e, n) {
1266
1266
  if (m.kind === "preference" && (o({ desiredPreferences: { ...i.features.desiredPreferences, [m.feature]: m.enabled } }), Object.values(i.features.pending).some((U) => U.status === "pending" && U.operation.kind === "preference" && U.operation.feature === m.feature))) {
1267
1267
  const U = i.features.queuedPreferences[m.feature];
1268
1268
  if (U && U.requestId !== S) {
1269
- const P = Pn(r, "mutate", U.requestId), z = { kind: "preference", feature: m.feature, enabled: U.enabled };
1269
+ const P = Mn(r, "mutate", U.requestId), z = { kind: "preference", feature: m.feature, enabled: U.enabled };
1270
1270
  o({ pending: { ...i.features.pending, [P]: {
1271
1271
  requestId: U.requestId,
1272
1272
  effectId: P,
@@ -1348,7 +1348,7 @@ function Gr(t, e, n) {
1348
1348
  f(e.mutation, e.requestId);
1349
1349
  break;
1350
1350
  case "stage7.retry": {
1351
- const m = i.features.pending[Pn(r, "mutate", e.requestId)];
1351
+ const m = i.features.pending[Mn(r, "mutate", e.requestId)];
1352
1352
  if (!m || m.mode !== "mutation") throw new Error("Unknown mutation request.");
1353
1353
  f(m.operation, e.requestId, !0);
1354
1354
  break;
@@ -1489,7 +1489,7 @@ function Gr(t, e, n) {
1489
1489
  if (!_) break;
1490
1490
  const x = { ...i.interactions.devicePending };
1491
1491
  if (delete x[e.effectId], a({ devicePending: x }), e.type === "effect.completed") {
1492
- if (_.action !== "check" && i.interactions.promptActions[_.requestId] && !i.features.pending[Pn(r, "mutate", `${_.requestId}:ack`)]) {
1492
+ if (_.action !== "check" && i.interactions.promptActions[_.requestId] && !i.features.pending[Mn(r, "mutate", `${_.requestId}:ack`)]) {
1493
1493
  const R = i.interactions.promptActions[_.requestId];
1494
1494
  l(R.feature, _.requestId), f({
1495
1495
  kind: "preferenceAcknowledge",
@@ -1636,7 +1636,7 @@ function Gr(t, e, n) {
1636
1636
  ...Object.values(i.interactions.deviceFacts).map((m) => m.snoozedUntil ? Date.parse(m.snoozedUntil) : null)
1637
1637
  ].filter((m) => m !== null && m > i.features.now), k = v.length ? Math.min(...v) : null;
1638
1638
  if (k !== i.features.timerDeadline && !i.features.schedulerError) {
1639
- const m = i.features.timerRevision + 1, S = k === null ? null : Pn(r, "wait", `${m}:${k}`);
1639
+ const m = i.features.timerRevision + 1, S = k === null ? null : Mn(r, "wait", `${m}:${k}`);
1640
1640
  o({ timerId: S, timerDeadline: k, timerRevision: m }), k !== null && S && s.push({ kind: "stage7.wait", id: S, input: { authority: r, deadline: k } });
1641
1641
  }
1642
1642
  return { state: i, effects: s };
@@ -1655,7 +1655,7 @@ function ne(t) {
1655
1655
  function Tt(t) {
1656
1656
  return t == null ? null : ne(t);
1657
1657
  }
1658
- function $n(t) {
1658
+ function Hn(t) {
1659
1659
  if (typeof t != "number" || !Number.isSafeInteger(t) || t < 0) throw new Error("Invalid feature revision.");
1660
1660
  return t;
1661
1661
  }
@@ -1680,23 +1680,23 @@ function Ci(t) {
1680
1680
  return {
1681
1681
  taskNotificationsEnabled: Yo(e.taskNotificationsEnabled),
1682
1682
  tabGroupingEnabled: Yo(e.tabGroupingEnabled),
1683
- preferencesVersion: $n(e.preferencesVersion),
1683
+ preferencesVersion: Hn(e.preferencesVersion),
1684
1684
  scribbleStyleEnabled: Yo(e.scribbleStyleEnabled),
1685
1685
  blockedOrigins: Cs(e.blockedServiceOrigins),
1686
1686
  personalInstructions: Tt(e.personalInstructions),
1687
- securityPolicyVersion: $n(e.securityPolicyVersion)
1687
+ securityPolicyVersion: Hn(e.securityPolicyVersion)
1688
1688
  };
1689
1689
  }
1690
1690
  function $s(t) {
1691
1691
  const e = we(t);
1692
- return { eligibleSince: Fs(e.eligibleSince), revision: $n(e.revision), requestId: Tt(e.requestId), snoozedUntil: Fs(e.snoozedUntil) };
1692
+ return { eligibleSince: Fs(e.eligibleSince), revision: Hn(e.revision), requestId: Tt(e.requestId), snoozedUntil: Fs(e.snoozedUntil) };
1693
1693
  }
1694
1694
  function fh(t) {
1695
1695
  const e = we(t);
1696
1696
  return { notifications: $s(e.notifications), tab_grouping: $s(e.tabGrouping) };
1697
1697
  }
1698
1698
  function ol(t) {
1699
- const e = we(t), n = we(e.request), i = ne(n.category), s = ne(n.action), o = { category: i, action: s, promptKey: ne(n.promptKey), expectedRevision: $n(n.expectedRevision) };
1699
+ const e = we(t), n = we(e.request), i = ne(n.category), s = ne(n.action), o = { category: i, action: s, promptKey: ne(n.promptKey), expectedRevision: Hn(n.expectedRevision) };
1700
1700
  Ca(o);
1701
1701
  const a = ne(e.outcome);
1702
1702
  if (!["resolved", "snoozed", "suppressed"].includes(a)) throw new Error("Invalid decision outcome.");
@@ -1706,7 +1706,7 @@ function ol(t) {
1706
1706
  if (a === "snoozed" && c === null) throw new Error("Missing decision deadline.");
1707
1707
  return {
1708
1708
  decisionKey: ne(e.decisionKey),
1709
- revision: $n(e.revision),
1709
+ revision: Hn(e.revision),
1710
1710
  decidedAt: r,
1711
1711
  request: { ...o, requestId: ne(n.requestId) },
1712
1712
  outcome: a,
@@ -1729,11 +1729,11 @@ function mh(t) {
1729
1729
  if (n.template === "semantic_interaction") return { ...i, condition: { template: n.template, event: Xo(n.event) } };
1730
1730
  if (n.template === "event_sequence") {
1731
1731
  if (!Array.isArray(n.steps)) throw new Error("Invalid proactive sequence.");
1732
- return { ...i, condition: { template: n.template, steps: n.steps.map(Xo), withinSeconds: $n(n.withinSeconds) } };
1732
+ return { ...i, condition: { template: n.template, steps: n.steps.map(Xo), withinSeconds: Hn(n.withinSeconds) } };
1733
1733
  }
1734
1734
  if (n.template === "page_state_after_event") {
1735
1735
  const s = we(n.state);
1736
- return { ...i, condition: { template: n.template, event: Xo(n.event), withinSeconds: $n(n.withinSeconds), state: {
1736
+ return { ...i, condition: { template: n.template, event: Xo(n.event), withinSeconds: Hn(n.withinSeconds), state: {
1737
1737
  urlRegex: ne(s.urlRegex),
1738
1738
  ...s.textRegex == null ? {} : { textRegex: ne(s.textRegex) },
1739
1739
  ...s.roleRegex == null ? {} : { roleRegex: ne(s.roleRegex) },
@@ -3081,7 +3081,7 @@ function Bh(t, e) {
3081
3081
  ${u.textContent?.trim()}`), h = c.closest("[data-canonical-item-key]")?.dataset.canonicalItemKey, g = d ? `${l}:${d.sessionId}:${d.episodeId}` : h ? `${l}:${h}` : l;
3082
3082
  if (!i.has(g)) {
3083
3083
  if (i.size >= 100) return;
3084
- i.add(g), e(a, l, Fn(u.textContent ?? ""), ...d ? [h, d] : h ? [h] : []);
3084
+ i.add(g), e(a, l, $n(u.textContent ?? ""), ...d ? [h, d] : h ? [h] : []);
3085
3085
  }
3086
3086
  }
3087
3087
  }, o = new MutationObserver(s);
@@ -3133,7 +3133,7 @@ function qa(t) {
3133
3133
  return `fnv1a-${(e >>> 0).toString(16).padStart(8, "0")}`;
3134
3134
  }
3135
3135
  function Fh(t, e, n, i, s = {}) {
3136
- const o = !i && e === "conversation_error" && n !== void 0 && t.conversationDiagnostics?.errorMessageFingerprint === qa(Fn(n)) ? t.conversationDiagnostics : void 0;
3136
+ const o = !i && e === "conversation_error" && n !== void 0 && t.conversationDiagnostics?.errorMessageFingerprint === qa($n(n)) ? t.conversationDiagnostics : void 0;
3137
3137
  return {
3138
3138
  sessionId: ye(t.sessionId),
3139
3139
  requestId: ye(o?.httpRequest?.requestId ?? o?.errorRequestId ?? o?.queryRequestId),
@@ -3143,7 +3143,7 @@ function Fh(t, e, n, i, s = {}) {
3143
3143
  builds: { sdk: ri.version, ...s }
3144
3144
  };
3145
3145
  }
3146
- function Hn(t) {
3146
+ function _n(t) {
3147
3147
  if (!t || typeof t != "object") return !1;
3148
3148
  const e = t, n = (i) => Number.isSafeInteger(i) && i >= 0;
3149
3149
  return Object.keys(e).every((i) => [
@@ -3327,8 +3327,8 @@ function tt(t, e) {
3327
3327
  if (!Je(t) || e.authorityId !== t.authority.authorityId || e.generation !== t.authority.generation)
3328
3328
  throw Object.assign(new Error("Conversation authority was retired."), { code: "authority_retired", retryable: !0 });
3329
3329
  }
3330
- function Mn(t, e) {
3331
- const n = Xt(t, "connection_interrupted", "web_transport"), { code: i, message: s } = n, o = t instanceof Error && "detail" in t ? t.detail : t instanceof Error && "details" in t ? t.details : void 0, a = o && typeof o == "object" && "httpRequest" in o ? o.httpRequest : o, r = a && typeof a == "object" ? a : {}, c = r.category ?? r.transportCode, d = r.elapsedMs ?? r.durationMs, u = o && typeof o == "object" && "successfulRequests" in o && typeof o.successfulRequests == "number" ? o.successfulRequests : 0, l = o && typeof o == "object" && "securitySettingsUrl" in o && typeof o.securitySettingsUrl == "string" ? o.securitySettingsUrl : void 0, h = o && typeof o == "object" && "httpRequest" in o && Hn(o.httpRequest) ? o.httpRequest : void 0;
3330
+ function On(t, e) {
3331
+ const n = Xt(t, "connection_interrupted", "web_transport"), { code: i, message: s } = n, o = t instanceof Error && "detail" in t ? t.detail : t instanceof Error && "details" in t ? t.details : void 0, a = o && typeof o == "object" && "httpRequest" in o ? o.httpRequest : o, r = a && typeof a == "object" ? a : {}, c = r.category ?? r.transportCode, d = r.elapsedMs ?? r.durationMs, u = o && typeof o == "object" && "successfulRequests" in o && typeof o.successfulRequests == "number" ? o.successfulRequests : 0, l = o && typeof o == "object" && "securitySettingsUrl" in o && typeof o.securitySettingsUrl == "string" ? o.securitySettingsUrl : void 0, h = o && typeof o == "object" && "httpRequest" in o && _n(o.httpRequest) ? o.httpRequest : void 0;
3332
3332
  return Object.assign(new Error(s), {
3333
3333
  code: i,
3334
3334
  // Keep the actionable public URL without copying arbitrary transport internals into durable errors.
@@ -3355,7 +3355,7 @@ function Jh(t) {
3355
3355
  };
3356
3356
  return e = e.then(u, u), e;
3357
3357
  }, i = (r, c) => {
3358
- throw Je(t) && !(r instanceof Error && "code" in r && ["executor_not_ready", "request_timed_out"].includes(String(r.code))) && t.onError?.(r, c), Mn(r, c);
3358
+ throw Je(t) && !(r instanceof Error && "code" in r && ["executor_not_ready", "request_timed_out"].includes(String(r.code))) && t.onError?.(r, c), On(r, c);
3359
3359
  }, s = () => {
3360
3360
  const { token: r, protocol: c, ...d } = t.http.auth;
3361
3361
  return { ...d, ...t.connectionId() ? { connection_id: t.connectionId() } : {} };
@@ -3467,14 +3467,14 @@ function Jh(t) {
3467
3467
  }).catch((d) => {
3468
3468
  if (r.previousAcceptance === "unissued" && d instanceof Error && "backendRefusal" in d && d.backendRefusal === !0) {
3469
3469
  Je(t) && t.onError?.(d, { operation: r.command.type, requestId: r.command.request_id });
3470
- const u = Mn(d);
3470
+ const u = On(d);
3471
3471
  throw Object.assign(u, { details: { ...u.details, acceptance: "rejected" } });
3472
3472
  }
3473
3473
  if (!c && r.previousAcceptance === "unissued") {
3474
- const u = Mn(d);
3474
+ const u = On(d);
3475
3475
  throw Object.assign(u, { details: { ...u.details, acceptance: "unissued" } });
3476
3476
  }
3477
- if (d instanceof Error && "code" in d && d.code === "403") throw Mn(d);
3477
+ if (d instanceof Error && "code" in d && d.code === "403") throw On(d);
3478
3478
  return i(d, { operation: r.command.type, requestId: r.command.request_id });
3479
3479
  });
3480
3480
  },
@@ -3531,7 +3531,7 @@ function Jh(t) {
3531
3531
  return await t.onUploaded?.(r.source.sourceId, h.sessionId, y), d(), { sessionId: h.sessionId, attachment: y };
3532
3532
  }).catch((d) => {
3533
3533
  if (!c && r.previousAllocation === "unissued") {
3534
- const u = Mn(d);
3534
+ const u = On(d);
3535
3535
  throw Object.assign(u, { details: { ...u.details, allocation: "unissued" } });
3536
3536
  }
3537
3537
  return i(d, { operation: "conversation.upload", requestId: r.submission.userMessageId, ...r.submission.sessionId ? { sessionId: r.submission.sessionId } : {} });
@@ -3562,7 +3562,7 @@ function Jh(t) {
3562
3562
  } }
3563
3563
  ).catch((k) => {
3564
3564
  if (g.length === 0) throw k;
3565
- const m = Mn(k);
3565
+ const m = On(k);
3566
3566
  throw Object.assign(m, { details: { ...m.details, successfulRequests: g.length } });
3567
3567
  });
3568
3568
  if (tt(t, r), v.conversation_id !== r.sessionId) throw new Error("Snapshot conversation identity mismatch.");
@@ -3587,7 +3587,7 @@ function Jh(t) {
3587
3587
  l(), h();
3588
3588
  }
3589
3589
  }).catch((c) => {
3590
- const d = Mn(c, { requestId: r.requestId, sessionId: r.sessionId });
3590
+ const d = On(c, { requestId: r.requestId, sessionId: r.sessionId });
3591
3591
  if (["display_projection_disabled", "409", "connection_interrupted", "request_timed_out", "request_cancelled", "408", "425", "429", "500", "502", "503", "504"].includes(d.code))
3592
3592
  throw Object.assign(d, { code: "history_load_failed", message: "We couldn’t refresh this conversation. Try again.", retryable: !0 });
3593
3593
  if (Nd(d.code)) throw Object.assign(d, { retryable: !0 });
@@ -3912,12 +3912,12 @@ function ir(t, e, n, i) {
3912
3912
  isRetrying: t.isRetrying ?? !1,
3913
3913
  historyRefreshFailure: v === e?.error ? t.historyRefreshFailure ?? null : null,
3914
3914
  conversationDiagnostics: {
3915
- ...v ? { errorMessageFingerprint: qa(Fn(v.message)) } : {},
3915
+ ...v ? { errorMessageFingerprint: qa($n(v.message)) } : {},
3916
3916
  ...u && v && v === u.error && !g ? { failedClientMessageId: u.userMessageId } : {},
3917
3917
  ...typeof v?.details?.requestId == "string" ? { errorRequestId: v.details.requestId } : {},
3918
3918
  ...eo(v?.details?.errorNormalization) ? { errorNormalization: v.details.errorNormalization } : {},
3919
3919
  ...i ? { owner: i } : {},
3920
- ...Hn(v?.details?.httpRequest) ? { httpRequest: v.details.httpRequest } : {},
3920
+ ..._n(v?.details?.httpRequest) ? { httpRequest: v.details.httpRequest } : {},
3921
3921
  queryStatus: e?.status ?? null,
3922
3922
  queryRequestId: e?.requestId ?? null,
3923
3923
  queryUpdatedAt: e?.updatedAt ?? null
@@ -6757,9 +6757,9 @@ class cu {
6757
6757
  upstreamRequestId: q,
6758
6758
  upstreamTraceId: U
6759
6759
  };
6760
- Hn(B) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(B) : console.warn("Product Agent HTTP request failed", B)).catch(() => {
6760
+ _n(B) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(B) : console.warn("Product Agent HTTP request failed", B)).catch(() => {
6761
6761
  });
6762
- const E = Hn(B) ? { httpRequest: B } : void 0;
6762
+ const E = _n(B) ? { httpRequest: B } : void 0;
6763
6763
  if (z !== null) {
6764
6764
  const N = z !== "deadline" && z !== "unexpected_abort";
6765
6765
  throw new L(
@@ -6832,7 +6832,7 @@ function Ti(t, e) {
6832
6832
  if (!it(t) || e.authorityId !== t.authority.authorityId || e.generation !== t.authority.generation)
6833
6833
  throw new Error("Directory authority is no longer current.");
6834
6834
  }
6835
- function Ln(t) {
6835
+ function Nn(t) {
6836
6836
  if (t.origin === null) return t;
6837
6837
  const e = t.origin.trim();
6838
6838
  return { ...t, origin: e.includes("://") ? new URL(e).origin : e.toLowerCase() };
@@ -6864,7 +6864,7 @@ function rf(t) {
6864
6864
  "directory.query": async (i) => {
6865
6865
  try {
6866
6866
  Ti(t, i);
6867
- const s = Ln(i.query), o = { origin: s.origin, ...s.kind !== "all" ? { pinned: s.kind === "pinned" } : {}, cursor: i.cursor, limit: s.limit };
6867
+ const s = Nn(i.query), o = { origin: s.origin, ...s.kind !== "all" ? { pinned: s.kind === "pinned" } : {}, cursor: i.cursor, limit: s.limit };
6868
6868
  let a;
6869
6869
  if (t.http.auth.client_kind === "embed") {
6870
6870
  const r = await t.http.request("/conversations", { ...o, page_url: s.origin ?? t.pageUrl() });
@@ -6973,12 +6973,12 @@ class af {
6973
6973
  }
6974
6974
  open(e, n = "replace", i) {
6975
6975
  if (this.disposed || !it(this.boundary)) return Promise.resolve();
6976
- e = Ln(e);
6976
+ e = Nn(e);
6977
6977
  const s = ke(e);
6978
6978
  return n === "replace" && this.options.runtime.engine.getState().slices.directory.queries[s]?.requestId ? (this.refreshAfterRequest.add(s), Promise.resolve()) : (this.requestPage(e, n, i).catch((o) => this.report(o)), Promise.resolve());
6979
6979
  }
6980
6980
  requestPage(e, n = "replace", i) {
6981
- return e = Ln(e), this.enqueueQuery(e, () => this.readPage(e, n, i, !0));
6981
+ return e = Nn(e), this.enqueueQuery(e, () => this.readPage(e, n, i, !0));
6982
6982
  }
6983
6983
  enqueueQuery(e, n) {
6984
6984
  const i = ke(e), s = this.queryRequests.get(i), o = (async () => (await s?.catch(() => {
@@ -7010,14 +7010,14 @@ class af {
7010
7010
  return this.refreshPages(e, n, () => !0, !0);
7011
7011
  }
7012
7012
  refreshObservedQuery(e) {
7013
- const n = this.options.runtime.engine.getState().slices.directory.queries[ke(Ln(e))];
7013
+ const n = this.options.runtime.engine.getState().slices.directory.queries[ke(Nn(e))];
7014
7014
  return n?.status === "error" && !Ni(n) ? Promise.resolve() : e.kind !== "pinned" && n?.status === "error" && n.mode === "append" ? this.enqueueQuery(e, async () => {
7015
- const i = this.options.runtime.engine.getState().slices.directory.queries[ke(Ln(e))];
7015
+ const i = this.options.runtime.engine.getState().slices.directory.queries[ke(Nn(e))];
7016
7016
  !this.isObserved(e) || i?.status !== "error" || i.mode !== "append" || !Ni(i) || await this.readPage(e, "append", i.cursor);
7017
7017
  }) : this.refreshPages(e, e.kind === "pinned", () => this.isObserved(e));
7018
7018
  }
7019
7019
  refreshPages(e, n, i, s = !1) {
7020
- return e = Ln(e), this.enqueueQuery(e, async () => {
7020
+ return e = Nn(e), this.enqueueQuery(e, async () => {
7021
7021
  if (!i()) return;
7022
7022
  const o = this.options.runtime.engine.getState().slices.directory.queries[ke(e)];
7023
7023
  if (!s && o?.status === "error" && !Ni(o) || (await this.readPage(e, "replace", void 0, s), !n)) return;
@@ -7046,7 +7046,7 @@ class af {
7046
7046
  }
7047
7047
  observedQueryStates() {
7048
7048
  const e = this.options.runtime.engine.getState().slices.directory.queries;
7049
- return this.options.observedQueries().flatMap((n) => e[ke(Ln(n))] ?? []);
7049
+ return this.options.observedQueries().flatMap((n) => e[ke(Nn(n))] ?? []);
7050
7050
  }
7051
7051
  isObserved(e) {
7052
7052
  return !this.disposed && it(this.boundary) && (this.options.enabled?.() ?? !0) && this.observedQueryStates().some((n) => ke(n.query) === ke(e));
@@ -7386,15 +7386,15 @@ class Ae extends EventTarget {
7386
7386
  return;
7387
7387
  }
7388
7388
  if (n.type === "auth.session") {
7389
- const r = a instanceof L ? a : new L("Chat setup failed", "request_failed");
7389
+ const r = a instanceof L ? a : new L("Chat setup failed", "request_failed"), c = this.isInvalidResponse(r);
7390
7390
  this.queueDiagnostic("auth_rejected", {
7391
7391
  stage: "bootstrap",
7392
7392
  failureKind: "permanent",
7393
7393
  httpStatus: /^[45][0-9]{2}$/.test(r.code) ? Number(r.code) : void 0
7394
7394
  }), this.fail(new L(
7395
7395
  r.message,
7396
- r.code,
7397
- r.outcomeUnknown,
7396
+ c ? "invalid_response" : r.code,
7397
+ c ? !1 : r.outcomeUnknown,
7398
7398
  { ...r.detail && typeof r.detail == "object" ? r.detail : {}, stage: "bootstrap" },
7399
7399
  r.backendRefusal
7400
7400
  ), n), this.pause();
@@ -7457,8 +7457,12 @@ class Ae extends EventTarget {
7457
7457
  http(e, n = {}, i, s) {
7458
7458
  return this.httpTransport.request(e, n, i, s);
7459
7459
  }
7460
+ isInvalidResponse(e) {
7461
+ const n = e instanceof L ? e.detail : void 0;
7462
+ return !!(n && typeof n == "object" && "httpRequest" in n && _n(n.httpRequest) && n.httpRequest.category === "invalid_response");
7463
+ }
7460
7464
  isRetryableRead(e) {
7461
- return e instanceof TypeError || e instanceof DOMException && e.name === "AbortError" || e instanceof L && ["request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.code);
7465
+ return this.isInvalidResponse(e) ? !1 : e instanceof TypeError || e instanceof DOMException && e.name === "AbortError" || e instanceof L && ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.code);
7462
7466
  }
7463
7467
  async dispatch(e, n) {
7464
7468
  const { type: i, ...s } = e, o = this.options.auth.client_kind === "embed", a = e.pageUrl ?? e.page?.url ?? this.options.pageUrl(), r = { page_url: a, origin: new URL(a).origin };
@@ -7576,11 +7580,11 @@ class Ae extends EventTarget {
7576
7580
  }), o;
7577
7581
  }
7578
7582
  }
7579
- const la = /* @__PURE__ */ new WeakMap(), zn = (t) => t === null || typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t);
7583
+ const la = /* @__PURE__ */ new WeakMap(), Bn = (t) => t === null || typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t);
7580
7584
  function pf(t) {
7581
7585
  if (!t || typeof t != "object") return !1;
7582
7586
  const e = t;
7583
- return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && zn(e.sessionId) && zn(e.responseItemId) && zn(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
7587
+ return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && Bn(e.sessionId) && Bn(e.responseItemId) && Bn(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
7584
7588
  }
7585
7589
  function hf(t, e, n) {
7586
7590
  if (!pf(n)) return;
@@ -7604,10 +7608,10 @@ function ff(t, e, n, i, s, o, a, r, c = null, d = !1) {
7604
7608
  return {
7605
7609
  capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
7606
7610
  authenticated: s,
7607
- activeClientMessageId: zn(o) ? o : null,
7608
- pendingClientMessageId: zn(a) ? a : null,
7609
- clientUserMessageItemId: u && zn(u.id) ? u.id : null,
7610
- clientResponseItemId: l && zn(l.id) ? l.id : null,
7611
+ activeClientMessageId: Bn(o) ? o : null,
7612
+ pendingClientMessageId: Bn(a) ? a : null,
7613
+ clientUserMessageItemId: u && Bn(u.id) ? u.id : null,
7614
+ clientResponseItemId: l && Bn(l.id) ? l.id : null,
7611
7615
  clientDraftObserved: !!(u && d && c === u.id),
7612
7616
  renderer: gf(t, e, n)
7613
7617
  };
@@ -7829,7 +7833,7 @@ function cr(t, e, n) {
7829
7833
  const s = { ...e, conversation: { ...e.conversation } }, o = { ...t, entities: { ...t.entities, [e.conversation_id]: s } };
7830
7834
  return n ? da(o) : o;
7831
7835
  }
7832
- function Bn(t, e, n) {
7836
+ function jn(t, e, n) {
7833
7837
  let i = t;
7834
7838
  const s = [];
7835
7839
  if (e.type === "directory.authority_replace") {
@@ -8239,7 +8243,7 @@ function Tl(t, e, n) {
8239
8243
  const s = { authorityId: e.authorityId, generation: e.generation };
8240
8244
  for (const [a, r] of Object.entries(n.optimisticEntries)) {
8241
8245
  const c = e.submissions[a];
8242
- c && ((c.cancelled || c.delivery === "failed") && c.delivery !== "accepted" ? i = Bn(i, { ...s, type: "directory.optimistic_remove", clientMessageId: a }).state : c.delivery === "accepted" && c.sessionId && r.sessionId === null && (i = Bn(i, { ...s, type: "directory.optimistic_accept", clientMessageId: a, sessionId: c.sessionId }).state));
8246
+ c && ((c.cancelled || c.delivery === "failed") && c.delivery !== "accepted" ? i = jn(i, { ...s, type: "directory.optimistic_remove", clientMessageId: a }).state : c.delivery === "accepted" && c.sessionId && r.sessionId === null && (i = jn(i, { ...s, type: "directory.optimistic_accept", clientMessageId: a, sessionId: c.sessionId }).state));
8243
8247
  }
8244
8248
  const o = /* @__PURE__ */ new Set();
8245
8249
  for (const a of e.submissionOrder) {
@@ -8247,7 +8251,7 @@ function Tl(t, e, n) {
8247
8251
  if (r.cancelled || r.delivery === "failed" || o.has(r.conversationScopeId)) continue;
8248
8252
  o.add(r.conversationScopeId);
8249
8253
  const c = Object.keys(n.optimisticEntries).some((d) => t.submissions[d]?.conversationScopeId === r.conversationScopeId && !i.optimisticEntries[d]);
8250
- r.sessionId !== null || i.optimisticEntries[a] || t.submissions[a] && !c || (i = Bn(i, { ...s, type: "directory.optimistic_upsert", entry: {
8254
+ r.sessionId !== null || i.optimisticEntries[a] || t.submissions[a] && !c || (i = jn(i, { ...s, type: "directory.optimistic_upsert", entry: {
8251
8255
  id: `optimistic-user-message:${a}`,
8252
8256
  clientMessageId: a,
8253
8257
  sessionId: null,
@@ -8263,7 +8267,7 @@ function Tl(t, e, n) {
8263
8267
  const d = fn(e, n, c), u = fn(t, n, c);
8264
8268
  if (d.activity.phase === u.activity.phase) continue;
8265
8269
  const l = ["submitting", "awaiting_execution", "thinking", "steering", "queued", "stopping"].includes(d.activity.phase);
8266
- i = Bn(i, { ...s, type: "directory.activity_set", sessionId: a, active: l }).state;
8270
+ i = jn(i, { ...s, type: "directory.activity_set", sessionId: a, active: l }).state;
8267
8271
  }
8268
8272
  return i;
8269
8273
  }
@@ -8296,7 +8300,7 @@ class qf {
8296
8300
  return { state: d.state === o.slices.activeUsers ? o : Object.freeze({ revision: o.revision + 1, slices: Object.freeze({ ...o.slices, activeUsers: d.state }) }), effects: d.effects };
8297
8301
  }
8298
8302
  if (Cf(r)) {
8299
- const d = Bn(o.slices.directory, r, o.slices.conversation), u = ia(ea(o.slices.conversation, d.state, r.type === "directory.authority_replace" && r.adoptLocalSubmissions === !0)), l = ta(o.slices.conversation, u.state, d.state, d.state.clients !== o.slices.directory.clients), h = l.state, g = Tl(o.slices.conversation, h, d.state);
8303
+ const d = jn(o.slices.directory, r, o.slices.conversation), u = ia(ea(o.slices.conversation, d.state, r.type === "directory.authority_replace" && r.adoptLocalSubmissions === !0)), l = ta(o.slices.conversation, u.state, d.state, d.state.clients !== o.slices.directory.clients), h = l.state, g = Tl(o.slices.conversation, h, d.state);
8300
8304
  return { state: g === o.slices.directory && h === o.slices.conversation ? o : Object.freeze({
8301
8305
  revision: o.revision + 1,
8302
8306
  slices: Object.freeze({ ...o.slices, directory: g, conversation: h })
@@ -8308,7 +8312,7 @@ class qf {
8308
8312
  for (const [v, k] of Object.entries(d.state.operations)) {
8309
8313
  if (!["runtime.warmup", "attachment.prepare"].includes(k.command.type) || !k.conversationScopeId || k.phase !== "done" || o.slices.conversation.operations[v]?.phase === "done") continue;
8310
8314
  const m = k.result, S = u.selections[k.conversationScopeId];
8311
- m?.sessionId && S?.provisionalId && S.sessionId === null && Object.values(u.clients).includes(k.conversationScopeId) && (u = Bn(u, {
8315
+ m?.sessionId && S?.provisionalId && S.sessionId === null && Object.values(u.clients).includes(k.conversationScopeId) && (u = jn(u, {
8312
8316
  authorityId: d.state.authorityId,
8313
8317
  generation: d.state.generation,
8314
8318
  type: "directory.accepted",
@@ -8320,7 +8324,7 @@ class qf {
8320
8324
  const l = Object.values(d.state.submissions).find((v) => v.delivery === "accepted" && o.slices.conversation.submissions[v.userMessageId]?.delivery !== "accepted");
8321
8325
  if (l) {
8322
8326
  const v = u.selections[l.conversationScopeId];
8323
- !l.cancelled && v?.provisionalId && (u = Bn(u, {
8327
+ !l.cancelled && v?.provisionalId && (u = jn(u, {
8324
8328
  type: "directory.accepted",
8325
8329
  authorityId: d.state.authorityId,
8326
8330
  generation: d.state.generation,
@@ -8395,7 +8399,7 @@ class qf {
8395
8399
  },
8396
8400
  errorAdapter: (o) => {
8397
8401
  const a = Xt(o), r = o !== null && typeof o == "object" ? "details" in o ? o.details : "detail" in o ? o.detail : void 0 : void 0, c = r && typeof r == "object" && "httpRequest" in r ? r.httpRequest : void 0;
8398
- return { ...a, ...Hn(c) ? { details: { ...a.details, httpRequest: c } } : {} };
8402
+ return { ...a, ..._n(c) ? { details: { ...a.details, httpRequest: c } } : {} };
8399
8403
  }
8400
8404
  });
8401
8405
  }
@@ -9394,7 +9398,7 @@ class $a {
9394
9398
  b.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
9395
9399
  return;
9396
9400
  }
9397
- Be("web-sdk.conversation", "Conversation operation failed", { ...b, ...Dn(f) }), f instanceof L && f.backendRefusal && b.operation.startsWith("chat.") ? this.applyAccountSubmissionError(f.code) : this.handleDirectoryTransportError(f);
9401
+ Be("web-sdk.conversation", "Conversation operation failed", { ...b, ...Ln(f) }), f instanceof L && f.backendRefusal && b.operation.startsWith("chat.") ? this.applyAccountSubmissionError(f.code) : this.handleDirectoryTransportError(f);
9398
9402
  }
9399
9403
  })
9400
9404
  });
@@ -9418,7 +9422,7 @@ class $a {
9418
9422
  if (!i()) return;
9419
9423
  w && (b || Object.keys(w.operations).length || Object.keys(w.stops).length) && await this.clientRuntime.engine.dispatch({ ...n, type: "conversation.restore_delivery", checkpoint: w });
9420
9424
  }
9421
- if (this.authenticatedUserId && (this.queuedClientEvents = this.queuedClientEvents.filter((f) => !["chat.user_message", "chat.retry_last_user_message", "run.stop", "runtime.warmup", "session.reset", "attachment.upload_completed"].includes(f.type))), On(this.options.clientId, this.queuedClientEvents), !i()) return;
9425
+ if (this.authenticatedUserId && (this.queuedClientEvents = this.queuedClientEvents.filter((f) => !["chat.user_message", "chat.retry_last_user_message", "run.stop", "runtime.warmup", "session.reset", "attachment.upload_completed"].includes(f.type))), Dn(this.options.clientId, this.queuedClientEvents), !i()) return;
9422
9426
  this.conversationObservation = new Qh({
9423
9427
  authority: n,
9424
9428
  now: () => Date.now(),
@@ -9940,8 +9944,8 @@ class $a {
9940
9944
  errorFingerprint: n,
9941
9945
  ...s ? { renderedError: s } : {},
9942
9946
  ...o ? { historyRefreshFailure: o } : {},
9943
- ...Hn(a) ? { httpRequest: a } : {},
9944
- ...i ? { displayedMessage: Fn(i) } : {}
9947
+ ..._n(a) ? { httpRequest: a } : {},
9948
+ ...i ? { displayedMessage: $n(i) } : {}
9945
9949
  });
9946
9950
  }
9947
9951
  getModel() {
@@ -10428,7 +10432,7 @@ class $a {
10428
10432
  }
10429
10433
  send(e) {
10430
10434
  const n = this.sendNow(ht(e));
10431
- return n || (this.queuedClientEvents.push(e), On(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect()), n;
10435
+ return n || (this.queuedClientEvents.push(e), Dn(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect()), n;
10432
10436
  }
10433
10437
  sendNow(e) {
10434
10438
  if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
@@ -10436,8 +10440,8 @@ class $a {
10436
10440
  const n = this.socket;
10437
10441
  if ((e.type === "tool.result" || e.type === "run.stop") && n instanceof Ae) {
10438
10442
  const i = this.queuedClientEvents.find((s) => "sessionId" in s && s.sessionId === e.sessionId && (e.type === "tool.result" && s.type === "tool.result" && s.callId === e.callId || e.type === "run.stop" && s.type === "run.stop" && s.expectedUserMessageId === e.expectedUserMessageId)) ?? e;
10439
- return this.queuedClientEvents.includes(i) || this.queuedClientEvents.push(i), On(this.options.clientId, this.queuedClientEvents), this.pendingRetainedCommandDeliveries.has(i) || (this.pendingRetainedCommandDeliveries.add(i), n.sendRetainedCommand(ht(i)).then((s) => {
10440
- this.pendingRetainedCommandDeliveries.delete(i), s && (this.queuedClientEvents = this.queuedClientEvents.filter((o) => o !== i), On(this.options.clientId, this.queuedClientEvents));
10443
+ return this.queuedClientEvents.includes(i) || this.queuedClientEvents.push(i), Dn(this.options.clientId, this.queuedClientEvents), this.pendingRetainedCommandDeliveries.has(i) || (this.pendingRetainedCommandDeliveries.add(i), n.sendRetainedCommand(ht(i)).then((s) => {
10444
+ this.pendingRetainedCommandDeliveries.delete(i), s && (this.queuedClientEvents = this.queuedClientEvents.filter((o) => o !== i), Dn(this.options.clientId, this.queuedClientEvents));
10441
10445
  })), !0;
10442
10446
  }
10443
10447
  try {
@@ -10460,7 +10464,7 @@ class $a {
10460
10464
  this.options.backendUrl
10461
10465
  ) });
10462
10466
  }
10463
- if (n.httpRequest && (!Hn(n.httpRequest) || n.httpRequest.sessionId !== null && n.httpRequest.sessionId !== i.sessionId) || n.historyRefreshFailure && (n.historyRefreshFailure.consecutiveFailures < 3 || n.historyRefreshFailure.sessionId !== i.sessionId) || n.renderedError && n.renderedError.sessionId !== i.sessionId || n.uiInvariant && n.uiInvariant.current.sessionId !== i.sessionId) return;
10467
+ if (n.httpRequest && (!_n(n.httpRequest) || n.httpRequest.sessionId !== null && n.httpRequest.sessionId !== i.sessionId) || n.historyRefreshFailure && (n.historyRefreshFailure.consecutiveFailures < 3 || n.historyRefreshFailure.sessionId !== i.sessionId) || n.renderedError && n.renderedError.sessionId !== i.sessionId || n.uiInvariant && n.uiInvariant.current.sessionId !== i.sessionId) return;
10464
10468
  const s = n.historyRefreshFailure?.episodeId ?? (n.renderedError ? `${n.errorFingerprint}:${n.renderedError.itemId}` : void 0) ?? n.errorFingerprint ?? n.clientMessageId ?? (n.previousPhase && n.nextPhase ? `${n.previousPhase}:${n.nextPhase}:${n.reason ?? "unknown"}` : null);
10465
10469
  if (s) {
10466
10470
  const y = `${e}:${s}:${e === "invalid_state_transition" ? n.reason ?? "unknown" : ""}`;
@@ -10701,16 +10705,16 @@ class $a {
10701
10705
  }
10702
10706
  flushQueuedClientEvents() {
10703
10707
  const e = [...this.queuedClientEvents];
10704
- this.queuedClientEvents = this.queuedClientEvents.filter((n) => (n.type === "tool.result" || n.type === "run.stop") && this.socket instanceof Ae), On(this.options.clientId, this.queuedClientEvents);
10708
+ this.queuedClientEvents = this.queuedClientEvents.filter((n) => (n.type === "tool.result" || n.type === "run.stop") && this.socket instanceof Ae), Dn(this.options.clientId, this.queuedClientEvents);
10705
10709
  for (let n = 0; n < e.length; n++)
10706
10710
  if (!this.sendNow(ht(e[n]))) {
10707
10711
  this.queuedClientEvents.unshift(...e.slice(n).filter((i) => !this.queuedClientEvents.includes(i)));
10708
10712
  break;
10709
10713
  }
10710
- On(this.options.clientId, this.queuedClientEvents);
10714
+ Dn(this.options.clientId, this.queuedClientEvents);
10711
10715
  }
10712
10716
  resetForAuthenticationScopeChange() {
10713
- this.resetConversationSelection({ notifyTransport: !1 }), this.queuedClientEvents = [], On(this.options.clientId, this.queuedClientEvents);
10717
+ this.resetConversationSelection({ notifyTransport: !1 }), this.queuedClientEvents = [], Dn(this.options.clientId, this.queuedClientEvents);
10714
10718
  }
10715
10719
  applyAuthenticatedDirectoryIdentity(e) {
10716
10720
  const n = Fl(e);
@@ -10845,6 +10849,10 @@ class $a {
10845
10849
  });
10846
10850
  return;
10847
10851
  }
10852
+ if (e.code === "invalid_response" && e.stage === "bootstrap") {
10853
+ this.stopAuthentication(new L(String(e.message), "connection_failed", !1, { stage: "bootstrap" }));
10854
+ return;
10855
+ }
10848
10856
  if (!this.options.webSocketFactory && (e.code === "unauthorized" || e.code === "401") && e.reason === "invalid_token" && (this.canRefreshInvalidCredential() || this.credentialRecovery !== null)) {
10849
10857
  const n = this.socket;
10850
10858
  if (n instanceof Ae) {
@@ -12339,7 +12347,7 @@ function qy(t) {
12339
12347
  return [];
12340
12348
  }
12341
12349
  }
12342
- function On(t, e) {
12350
+ function Dn(t, e) {
12343
12351
  try {
12344
12352
  const n = e.filter(Ka);
12345
12353
  if (n.length === 0) {
@@ -13544,7 +13552,7 @@ async function lw(t = {}) {
13544
13552
  let vt = 0, en = 0, sc = 0;
13545
13553
  const Pt = /* @__PURE__ */ new Map();
13546
13554
  let tn = null, jt = null;
13547
- const ho = (p) => p === $ ? "widget_composer" : p === m ? "widget_launcher" : p && a.contains(p) ? "widget_control" : p === w.body ? "body" : p === w.documentElement ? "document" : p ? "host_page" : "none", _n = (p, I, C = {}) => {
13555
+ const ho = (p) => p === $ ? "widget_composer" : p === m ? "widget_launcher" : p && a.contains(p) ? "widget_control" : p === w.body ? "body" : p === w.documentElement ? "document" : p ? "host_page" : "none", vn = (p, I, C = {}) => {
13548
13556
  const A = xs(w), j = C.skipIfAlreadyFocused === !0 && A === p;
13549
13557
  j || (C.preventScroll ? p.focus({ preventScroll: !0 }) : p.focus());
13550
13558
  const X = xs(w);
@@ -13569,7 +13577,7 @@ async function lw(t = {}) {
13569
13577
  isThinking: M.getState().isThinking
13570
13578
  }
13571
13579
  ), !j && X === p;
13572
- }, nn = (p) => !$.isConnected || $.disabled || $.readOnly || !r.classList.contains("pluno-pa-widget--open") || e.loginRequired || e.signupRequired || Qn(e.billingStatus) ? !1 : _n($, p, {
13580
+ }, nn = (p) => !$.isConnected || $.disabled || $.readOnly || !r.classList.contains("pluno-pa-widget--open") || e.loginRequired || e.signupRequired || Qn(e.billingStatus) ? !1 : vn($, p, {
13573
13581
  preventScroll: !0,
13574
13582
  skipIfAlreadyFocused: !0
13575
13583
  }), li = () => {
@@ -13706,7 +13714,7 @@ async function lw(t = {}) {
13706
13714
  const fo = new Set(d.openToolGroupKeys);
13707
13715
  let It = null, sn = null, Ue = !1, on = !1, Ft = {
13708
13716
  enabled: !0
13709
- }, rn = 0, mo = null, vn = null, In = null, Qi = null, gi = !1, ve = null, lc = "local";
13717
+ }, rn = 0, mo = null, In = null, Sn = null, Qi = null, gi = !1, ve = null, lc = "local";
13710
13718
  const dc = (p) => di !== null && di !== p.sessionId || pi !== null && pi !== (p.user?.id ?? null) || ui !== void 0 && ui !== p.selectionKey, uc = (p) => Jp(F, p, {
13711
13719
  renderSource: lc,
13712
13720
  guardCreatedAt: ve?.createdAt ?? null,
@@ -13733,8 +13741,8 @@ async function lw(t = {}) {
13733
13741
  }, yp = (p = "jump") => {
13734
13742
  dt(!0, p), St(), Xn(F, () => Ft.enabled), rn = F.scrollTop;
13735
13743
  }, Zi = (p) => {
13736
- mo = p, p === "up" && F.scrollTop < rn - 1 && (gi = !0, dt(!1, "userScroll")), vn !== null && window.clearTimeout(vn), vn = window.setTimeout(() => {
13737
- mo = null, vn = null;
13744
+ mo = p, p === "up" && F.scrollTop < rn - 1 && (gi = !0, dt(!1, "userScroll")), In !== null && window.clearTimeout(In), In = window.setTimeout(() => {
13745
+ mo = null, In = null;
13738
13746
  }, 500);
13739
13747
  };
13740
13748
  $t = () => {
@@ -13842,7 +13850,7 @@ async function lw(t = {}) {
13842
13850
  e.position
13843
13851
  )
13844
13852
  ), dd(r), Ge(), !A && e.layout === "floating" && M.recordWidgetLifecycle("minimized", C), I && es("minimized", C);
13845
- }, Sn = (p, I = {}) => {
13853
+ }, xn = (p, I = {}) => {
13846
13854
  xw(p, {
13847
13855
  debugVersion: rw,
13848
13856
  launcherPosition: l,
@@ -13868,7 +13876,7 @@ async function lw(t = {}) {
13868
13876
  return Gi(), C;
13869
13877
  }
13870
13878
  const I = fi(p);
13871
- return hn(r, I), Gi(), Sn("Applied stored closed launcher position", {
13879
+ return hn(r, I), Gi(), xn("Applied stored closed launcher position", {
13872
13880
  visibleLauncherPosition: I
13873
13881
  }), I;
13874
13882
  }, ts = (p, I) => {
@@ -13881,7 +13889,7 @@ async function lw(t = {}) {
13881
13889
  y: p.y - I.y
13882
13890
  });
13883
13891
  }, Io = () => {
13884
- const p = Nn(g).width;
13892
+ const p = Un(g).width;
13885
13893
  return x.getBoundingClientRect().width || p;
13886
13894
  }, bc = () => {
13887
13895
  if (r.classList.contains("pluno-pa-widget--minimized")) {
@@ -13898,7 +13906,7 @@ async function lw(t = {}) {
13898
13906
  const p = yi();
13899
13907
  if (r.classList.contains("pluno-pa-widget--open") || r.classList.contains("pluno-pa-widget--closing")) {
13900
13908
  Cr(r, g);
13901
- const I = Nn(g);
13909
+ const I = Un(g);
13902
13910
  Pr(
13903
13911
  q,
13904
13912
  Io()
@@ -13912,11 +13920,11 @@ async function lw(t = {}) {
13912
13920
  ),
13913
13921
  I
13914
13922
  );
13915
- ts(C, p), Sn(
13923
+ ts(C, p), xn(
13916
13924
  "Applied open panel position after viewport resize",
13917
13925
  { openPanelPosition: C }
13918
13926
  );
13919
- } else l && Sn(
13927
+ } else l && xn(
13920
13928
  "Applied visible launcher position after viewport resize",
13921
13929
  { visibleLauncherPosition: p }
13922
13930
  );
@@ -13937,16 +13945,16 @@ async function lw(t = {}) {
13937
13945
  l = Rr(
13938
13946
  A,
13939
13947
  C
13940
- ), y = null, hn(r, A), Gi(), Sn("Dragging closed launcher", {
13948
+ ), y = null, hn(r, A), Gi(), xn("Dragging closed launcher", {
13941
13949
  requestedPosition: I
13942
13950
  });
13943
13951
  },
13944
13952
  persist: () => {
13945
- h = !0, Ge(), Sn("Persisted closed launcher drag position");
13953
+ h = !0, Ge(), xn("Persisted closed launcher drag position");
13946
13954
  }
13947
13955
  })) : hn(r, null), Cr(r, g);
13948
13956
  const _c = () => {
13949
- const p = Nn(g), I = fi();
13957
+ const p = Un(g), I = fi();
13950
13958
  return {
13951
13959
  position: zi(
13952
13960
  y ? zs(y, p) : Tr(
@@ -13966,16 +13974,16 @@ async function lw(t = {}) {
13966
13974
  );
13967
13975
  const I = zi(
13968
13976
  p.position,
13969
- Nn(g)
13977
+ Un(g)
13970
13978
  );
13971
13979
  y = Rr(
13972
13980
  I,
13973
- Nn(g)
13981
+ Un(g)
13974
13982
  );
13975
13983
  const C = fi();
13976
13984
  ts(I, C);
13977
13985
  }, _p = (p) => {
13978
- const I = Nn(g), C = zi(
13986
+ const I = Un(g), C = zi(
13979
13987
  p,
13980
13988
  I
13981
13989
  ), A = Hi(r), j = Us(
@@ -14006,35 +14014,35 @@ async function lw(t = {}) {
14006
14014
  setBounds: wp,
14007
14015
  persist: Ge
14008
14016
  }) : () => {
14009
- }, xn = document.createElement("div");
14010
- xn.className = "pluno-pa-widget__account-load-notice", xn.hidden = !0;
14017
+ }, kn = document.createElement("div");
14018
+ kn.className = "pluno-pa-widget__account-load-notice", kn.hidden = !0;
14011
14019
  const bi = document.createElement("div");
14012
14020
  bi.className = "pluno-pa-widget__error";
14013
- const kn = document.createElement("button");
14014
- kn.type = "button", kn.className = "pluno-pa-widget__error-retry";
14021
+ const En = document.createElement("button");
14022
+ En.type = "button", En.className = "pluno-pa-widget__error-retry";
14015
14023
  const vc = wn(), Ic = document.createTextNode("Try again");
14016
- kn.append(vc, Ic), bi.append("Pluno could not load your account. Try again.", kn), Y.after(xn);
14017
- let So = !1, En = !1;
14024
+ En.append(vc, Ic), bi.append("Pluno could not load your account. Try again.", En), Y.after(kn);
14025
+ let So = !1, Cn = !1;
14018
14026
  const xo = () => {
14019
14027
  const p = M.getState().status === "error" && ["unauthorized", "invalid_token", "update_required"].includes(M.getState().lastErrorCode ?? ""), I = !!e.billingStatus && e.billingStatus?.submissionGate?.reason !== "connection_required";
14020
- xn.hidden = p || M.getState().status !== "connected" || !So || I || e.productVariant !== "personal" || Lt(), xn.hidden ? bi.remove() : bi.parentElement !== xn && xn.append(bi), kn.disabled = En, kn.setAttribute("aria-busy", String(En)), vc.hidden = !En, Ic.data = En ? "Trying" : "Try again";
14028
+ kn.hidden = p || M.getState().status !== "connected" || !So || I || e.productVariant !== "personal" || Lt(), kn.hidden ? bi.remove() : bi.parentElement !== kn && kn.append(bi), En.disabled = Cn, En.setAttribute("aria-busy", String(Cn)), vc.hidden = !Cn, Ic.data = Cn ? "Trying" : "Try again";
14021
14029
  }, ko = async () => {
14022
- if (!(En || Ue)) {
14023
- En = !0, xo();
14030
+ if (!(Cn || Ue)) {
14031
+ Cn = !0, xo();
14024
14032
  try {
14025
14033
  await M.refreshAccount(), So = !1;
14026
14034
  } catch (p) {
14027
14035
  So = !0, nt(
14028
14036
  "web-sdk.widget",
14029
14037
  "Failed to refresh billing status",
14030
- Dn(p)
14038
+ Ln(p)
14031
14039
  );
14032
14040
  } finally {
14033
- En = !1, Ue || xo();
14041
+ Cn = !1, Ue || xo();
14034
14042
  }
14035
14043
  }
14036
14044
  };
14037
- kn.addEventListener("click", () => {
14045
+ En.addEventListener("click", () => {
14038
14046
  ko();
14039
14047
  });
14040
14048
  let wi = null;
@@ -14046,7 +14054,7 @@ async function lw(t = {}) {
14046
14054
  nt(
14047
14055
  "web-sdk.widget",
14048
14056
  "Failed to warm Product Agent sandbox",
14049
- Dn(A)
14057
+ Ln(A)
14050
14058
  );
14051
14059
  }));
14052
14060
  }, Ot = (p = "", I = !0, C = !0, A = !0, j = "external_request") => {
@@ -14061,16 +14069,16 @@ async function lw(t = {}) {
14061
14069
  e.position,
14062
14070
  g
14063
14071
  );
14064
- if (ts(pe, ee), Sn("Opening launcher at clamped open panel position", {
14072
+ if (ts(pe, ee), xn("Opening launcher at clamped open panel position", {
14065
14073
  openPanelPosition: pe,
14066
14074
  visibleLauncherPosition: ee
14067
14075
  }), dt(!0, "open"), St(), !X && e.layout === "floating" && M.recordWidgetLifecycle("opened", j), !I) {
14068
- r.classList.add("pluno-pa-widget--open"), X || vo(), v.hidden = !0, p && ($.value = p, Oi($)), Xn(F, () => Ft.enabled), rn = F.scrollTop, C && (_n($, "panel_open_immediate"), $.setSelectionRange($.value.length, $.value.length)), Ge(), es("shown", j), e.onPanelOpenChange?.(!0, j);
14076
+ r.classList.add("pluno-pa-widget--open"), X || vo(), v.hidden = !0, p && ($.value = p, Oi($)), Xn(F, () => Ft.enabled), rn = F.scrollTop, C && (vn($, "panel_open_immediate"), $.setSelectionRange($.value.length, $.value.length)), Ge(), es("shown", j), e.onPanelOpenChange?.(!0, j);
14069
14077
  return;
14070
14078
  }
14071
14079
  const kt = Date.now();
14072
14080
  window.requestAnimationFrame(() => {
14073
- r.classList.add("pluno-pa-widget--open"), X || vo(), p && ($.value = p, Oi($)), Xn(F, () => Ft.enabled), rn = F.scrollTop, C && (_n($, "panel_open_animation", {
14081
+ r.classList.add("pluno-pa-widget--open"), X || vo(), p && ($.value = p, Oi($)), Xn(F, () => Ft.enabled), rn = F.scrollTop, C && (vn($, "panel_open_animation", {
14074
14082
  scheduledAt: kt
14075
14083
  }), $.setSelectionRange($.value.length, $.value.length)), Ge(), es("shown", j), e.onPanelOpenChange?.(!0, j), It = window.setTimeout(() => {
14076
14084
  v.hidden = !0, Xn(F, () => Ft.enabled), rn = F.scrollTop;
@@ -14078,7 +14086,7 @@ async function lw(t = {}) {
14078
14086
  });
14079
14087
  }, Eo = (p = "external_request") => {
14080
14088
  const I = r.classList.contains("pluno-pa-widget--open") || !x.hidden && !r.classList.contains("pluno-pa-widget--closing");
14081
- It !== null && (window.clearTimeout(It), It = null), v.hidden = !1, l && (yi(!1), Sn("Closing launcher at stored position")), r.classList.remove("pluno-pa-widget--open"), r.classList.add("pluno-pa-widget--closing"), at(), Ge(), I && e.layout === "floating" && M.recordWidgetLifecycle("closed", p), e.onPanelOpenChange?.(!1, p), It = window.setTimeout(() => {
14089
+ It !== null && (window.clearTimeout(It), It = null), v.hidden = !1, l && (yi(!1), xn("Closing launcher at stored position")), r.classList.remove("pluno-pa-widget--open"), r.classList.add("pluno-pa-widget--closing"), at(), Ge(), I && e.layout === "floating" && M.recordWidgetLifecycle("closed", p), e.onPanelOpenChange?.(!1, p), It = window.setTimeout(() => {
14082
14090
  x.hidden = !0, P.hidden = !0, y = null, r.classList.remove("pluno-pa-widget--closing");
14083
14091
  }, 220);
14084
14092
  };
@@ -14098,7 +14106,7 @@ async function lw(t = {}) {
14098
14106
  const p = m.value;
14099
14107
  Ot(p, !0, !0, !0, "launcher_input"), m.value = "";
14100
14108
  });
14101
- let _i = null, an = null, ns = null, Cn = null, Dt = null, ze = null;
14109
+ let _i = null, an = null, ns = null, An = null, Dt = null, ze = null;
14102
14110
  const is = (p) => p === m || p === $, kc = (p) => p.composedPath().find(is) ?? null, Sp = (p) => {
14103
14111
  let I = p;
14104
14112
  for (; I; ) {
@@ -14141,7 +14149,7 @@ async function lw(t = {}) {
14141
14149
  Dt !== null && window.clearTimeout(Dt);
14142
14150
  const C = Date.now();
14143
14151
  Dt = window.setTimeout(() => {
14144
- Dt = null, Ht === p && I.isConnected && _n(I, "host_modal_recovery", {
14152
+ Dt = null, Ht === p && I.isConnected && vn(I, "host_modal_recovery", {
14145
14153
  preventScroll: !0,
14146
14154
  scheduledAt: C
14147
14155
  });
@@ -14151,16 +14159,16 @@ async function lw(t = {}) {
14151
14159
  p && Ro(p, I);
14152
14160
  return;
14153
14161
  }
14154
- Ht = p, p !== null ? (Ro(p, I), Cn = window.setInterval(() => {
14162
+ Ht = p, p !== null ? (Ro(p, I), An = window.setInterval(() => {
14155
14163
  const C = Ht;
14156
14164
  if (!C || !xp(C)) {
14157
14165
  vi(null);
14158
14166
  return;
14159
14167
  }
14160
14168
  Ro(C, null);
14161
- }, Kb)) : (Cn !== null && (window.clearInterval(Cn), Cn = null), Dt !== null && (window.clearTimeout(Dt), Dt = null), ns = null);
14169
+ }, Kb)) : (An !== null && (window.clearInterval(An), An = null), Dt !== null && (window.clearTimeout(Dt), Dt = null), ns = null);
14162
14170
  }, kp = () => {
14163
- Cn !== null && (window.clearInterval(Cn), Cn = null), Dt !== null && (window.clearTimeout(Dt), Dt = null), ze !== null && (window.clearTimeout(ze), ze = null);
14171
+ An !== null && (window.clearInterval(An), An = null), Dt !== null && (window.clearTimeout(Dt), Dt = null), ze !== null && (window.clearTimeout(ze), ze = null);
14164
14172
  }, Ec = (p) => {
14165
14173
  const I = kc(p);
14166
14174
  if (!I)
@@ -14228,13 +14236,13 @@ async function lw(t = {}) {
14228
14236
  }), P.addEventListener("click", () => Eo("close_button")), F.addEventListener("wheel", (p) => {
14229
14237
  Zi(p.deltaY < 0 ? "up" : null);
14230
14238
  }), F.addEventListener("pointerdown", (p) => {
14231
- In = p.target === F ? p.clientY : null;
14239
+ Sn = p.target === F ? p.clientY : null;
14232
14240
  }), F.addEventListener("pointermove", (p) => {
14233
- In !== null && p.clientY < In - 1 && Zi("up"), In !== null && (In = p.clientY);
14241
+ Sn !== null && p.clientY < Sn - 1 && Zi("up"), Sn !== null && (Sn = p.clientY);
14234
14242
  }), F.addEventListener("pointerup", () => {
14235
- In = null;
14243
+ Sn = null;
14236
14244
  }), F.addEventListener("pointercancel", () => {
14237
- In = null;
14245
+ Sn = null;
14238
14246
  }), F.addEventListener("touchstart", (p) => {
14239
14247
  Qi = p.touches[0]?.clientY ?? null;
14240
14248
  }), F.addEventListener("touchmove", (p) => {
@@ -14264,7 +14272,7 @@ async function lw(t = {}) {
14264
14272
  const Si = () => {
14265
14273
  const p = M.getState().status;
14266
14274
  return !os && M.getState().lastErrorCode !== "connection_failed" && (p === "idle" || p === "connecting" || p === "reconnecting");
14267
- }, Tc = () => M.getState().status !== "connected", An = () => {
14275
+ }, Tc = () => M.getState().status !== "connected", Rn = () => {
14268
14276
  if (e.productVariant !== "personal") return Tc();
14269
14277
  const p = e.billingStatus?.auth;
14270
14278
  return !p?.user || !p.workspace || Lt();
@@ -14287,20 +14295,20 @@ async function lw(t = {}) {
14287
14295
  // Delivery belongs to an earlier immutable input; only the current composer handoff blocks Send.
14288
14296
  hasPendingMessage: !1
14289
14297
  };
14290
- }, Rn = () => e.productVariant === "personal" ? Si() && !Lt() && !rs() && e.billingStatus?.submissionGate?.allowed === !0 || Xc(qc()) : !To() && !Qn(e.billingStatus) && !rs(), Pc = () => {
14298
+ }, Tn = () => e.productVariant === "personal" ? Si() && !Lt() && !rs() && e.billingStatus?.submissionGate?.allowed === !0 || Xc(qc()) : !To() && !Qn(e.billingStatus) && !rs(), Pc = () => {
14291
14299
  const p = M.getState(), I = !Si() && [...Pt.values()].some((C) => C.revision === en && C.generation === vt);
14292
14300
  return th({
14293
14301
  hasRunningAssistantTurn: I || p.isThinking || p.turnPhase !== null || p.pendingMessageStatus !== null,
14294
14302
  // Retained text already submitted by this revision must not hide Stop behind a disabled Send.
14295
14303
  hasDraftMessage: !I && $.value.trim().length > 0,
14296
14304
  hasPreSubmittedAttachment: ct.length > 0,
14297
- canSubmitMessage: Rn()
14305
+ canSubmitMessage: Tn()
14298
14306
  });
14299
14307
  }, Le = () => {
14300
14308
  const p = Pc();
14301
- ec(Te, p.action === "stop"), Te.disabled = p.disabled, e.productVariant === "personal" && (T && (T.disabled = !Rn()), r.querySelectorAll(".pluno-pa-widget__starter-prompt").forEach((I) => {
14302
- I.disabled = !Rn();
14303
- })), be.disabled = Lt() || An() || e.productVariant !== "personal" && Qn(e.billingStatus);
14309
+ ec(Te, p.action === "stop"), Te.disabled = p.disabled, e.productVariant === "personal" && (T && (T.disabled = !Tn()), r.querySelectorAll(".pluno-pa-widget__starter-prompt").forEach((I) => {
14310
+ I.disabled = !Tn();
14311
+ })), be.disabled = Lt() || Rn() || e.productVariant !== "personal" && Qn(e.billingStatus);
14304
14312
  };
14305
14313
  Vn();
14306
14314
  const qo = () => {
@@ -14322,7 +14330,7 @@ async function lw(t = {}) {
14322
14330
  "web-sdk.widget",
14323
14331
  "Failed to connect Product Agent widget",
14324
14332
  {
14325
- ...Dn(p)
14333
+ ...Ln(p)
14326
14334
  }
14327
14335
  ));
14328
14336
  }
@@ -14363,7 +14371,7 @@ async function lw(t = {}) {
14363
14371
  tn = null, Mc(p);
14364
14372
  }, Oo = () => {
14365
14373
  const p = $.value, I = p.trim(), C = [...ct];
14366
- if (tn !== null || rs() || e.productVariant === "personal" && !Rn() || !I && C.length === 0)
14374
+ if (tn !== null || rs() || e.productVariant === "personal" && !Tn() || !I && C.length === 0)
14367
14375
  return;
14368
14376
  for (const j of C)
14369
14377
  j.id && j.previewUrl && ci.set(j.id, j.previewUrl);
@@ -14396,7 +14404,7 @@ async function lw(t = {}) {
14396
14404
  e.onSignupClick?.();
14397
14405
  return;
14398
14406
  }
14399
- (e.productVariant === "personal" ? !Rn() : To() || Qn(e.billingStatus)) || (on = !0, dt(!0, "send"), St(), Oo());
14407
+ (e.productVariant === "personal" ? !Tn() : To() || Qn(e.billingStatus)) || (on = !0, dt(!0, "send"), St(), Oo());
14400
14408
  });
14401
14409
  let xi = 0;
14402
14410
  const cn = () => {
@@ -14404,7 +14412,7 @@ async function lw(t = {}) {
14404
14412
  }, Ep = () => {
14405
14413
  jt !== null && (window.clearTimeout(jt), jt = null), B.textContent = "", B.hidden = !0;
14406
14414
  }, Do = async (p) => {
14407
- if (!e.attachmentsEnabled || p.length === 0 || e.productVariant === "personal" && An())
14415
+ if (!e.attachmentsEnabled || p.length === 0 || e.productVariant === "personal" && Rn())
14408
14416
  return;
14409
14417
  const I = e_(
14410
14418
  M,
@@ -14417,24 +14425,24 @@ async function lw(t = {}) {
14417
14425
  }
14418
14426
  nn("attachment_added");
14419
14427
  }, Cp = async (p) => {
14420
- await Do(p), !(p.length === 0 || Ht !== null) && _n($, "attachment_picker_completed");
14428
+ await Do(p), !(p.length === 0 || Ht !== null) && vn($, "attachment_picker_completed");
14421
14429
  };
14422
14430
  be.addEventListener("click", () => {
14423
- e.loginRequired || An() || e.productVariant !== "personal" && Qn(e.billingStatus) || Pe.click();
14431
+ e.loginRequired || Rn() || e.productVariant !== "personal" && Qn(e.billingStatus) || Pe.click();
14424
14432
  }), Pe.addEventListener("change", () => {
14425
14433
  const p = Array.from(Pe.files ?? []);
14426
14434
  Pe.value = "", Cp(p).catch((I) => {
14427
14435
  as(
14428
14436
  I instanceof Error ? I.message : "Failed to attach file"
14429
14437
  ), nt("web-sdk.widget", "Attachment failed", {
14430
- ...Dn(I)
14438
+ ...Ln(I)
14431
14439
  });
14432
14440
  });
14433
14441
  }), r.addEventListener("dragenter", (p) => {
14434
- !e.attachmentsEnabled || !ks(p.dataTransfer) || e.loginRequired || An() || (p.preventDefault(), p.stopPropagation(), xi += 1, r.classList.add("pluno-pa-widget--drag-over"));
14442
+ !e.attachmentsEnabled || !ks(p.dataTransfer) || e.loginRequired || Rn() || (p.preventDefault(), p.stopPropagation(), xi += 1, r.classList.add("pluno-pa-widget--drag-over"));
14435
14443
  }), r.addEventListener("dragover", (p) => {
14436
14444
  const I = p.dataTransfer;
14437
- !e.attachmentsEnabled || !ks(I) || e.loginRequired || An() || (p.preventDefault(), p.stopPropagation(), I.dropEffect = "copy");
14445
+ !e.attachmentsEnabled || !ks(I) || e.loginRequired || Rn() || (p.preventDefault(), p.stopPropagation(), I.dropEffect = "copy");
14438
14446
  }), r.addEventListener("dragleave", (p) => {
14439
14447
  ks(p.dataTransfer) && (p.stopPropagation(), xi = Math.max(0, xi - 1), xi === 0 && r.classList.remove("pluno-pa-widget--drag-over"));
14440
14448
  });
@@ -14447,21 +14455,21 @@ async function lw(t = {}) {
14447
14455
  !0
14448
14456
  ), w.addEventListener("drop", cn, !0), w.addEventListener("dragend", cn, !0), w.defaultView?.addEventListener("blur", cn), r.addEventListener("drop", (p) => {
14449
14457
  const I = p.dataTransfer;
14450
- !e.attachmentsEnabled || !ks(I) || e.loginRequired || An() || (p.preventDefault(), p.stopPropagation(), cn(), Do(I.files).catch((C) => {
14458
+ !e.attachmentsEnabled || !ks(I) || e.loginRequired || Rn() || (p.preventDefault(), p.stopPropagation(), cn(), Do(I.files).catch((C) => {
14451
14459
  as(
14452
14460
  C instanceof Error ? C.message : "Failed to attach file"
14453
14461
  ), nt("web-sdk.widget", "Attachment failed", {
14454
- ...Dn(C)
14462
+ ...Ln(C)
14455
14463
  });
14456
14464
  }));
14457
14465
  }), r.addEventListener("paste", (p) => {
14458
14466
  p.stopPropagation();
14459
14467
  const I = p.clipboardData, C = Array.from(I?.files ?? []);
14460
- !e.attachmentsEnabled || C.length === 0 || e.loginRequired || An() || (p.preventDefault(), Do(C).catch((A) => {
14468
+ !e.attachmentsEnabled || C.length === 0 || e.loginRequired || Rn() || (p.preventDefault(), Do(C).catch((A) => {
14461
14469
  as(
14462
14470
  A instanceof Error ? A.message : "Failed to attach file"
14463
14471
  ), nt("web-sdk.widget", "Attachment failed", {
14464
- ...Dn(A)
14472
+ ...Ln(A)
14465
14473
  });
14466
14474
  }));
14467
14475
  }), Te.addEventListener("click", () => {
@@ -14490,7 +14498,7 @@ async function lw(t = {}) {
14490
14498
  e.onLoginClick?.();
14491
14499
  return;
14492
14500
  }
14493
- (e.productVariant === "personal" ? !Rn() : To()) || (on = !0, dt(!0, "send"), St(), Oo(), Ce(M.getState()), Le());
14501
+ (e.productVariant === "personal" ? !Tn() : To()) || (on = !0, dt(!0, "send"), St(), Oo(), Ce(M.getState()), Le());
14494
14502
  }
14495
14503
  }), r.addEventListener("click", (p) => {
14496
14504
  const I = p.target instanceof Element ? p.target : null;
@@ -14591,16 +14599,16 @@ async function lw(t = {}) {
14591
14599
  No();
14592
14600
  };
14593
14601
  No();
14594
- let Tn = null;
14602
+ let qn = null;
14595
14603
  const ds = /* @__PURE__ */ new Map(), zo = /* @__PURE__ */ new Map(), Bo = /* @__PURE__ */ new Map(), Rp = () => $.value.trim().length > 0 || ct.length > 0, zc = (p) => {
14596
14604
  if (e.entrySurface === "extension_widget") {
14597
14605
  const I = e.billingStatus?.auth, C = I ? !!I.user : !!(p.user && !e.loginRequired), A = I ? !!I.workspace : !e.signupRequired;
14598
- return C && A && Tn !== null && Tn > 0;
14606
+ return C && A && qn !== null && qn > 0;
14599
14607
  }
14600
- return Tn !== null && a_(p, Rp());
14608
+ return qn !== null && a_(p, Rp());
14601
14609
  }, Bc = () => {
14602
14610
  const p = zc(M.getState());
14603
- W.hidden = !p, p && Tn !== null && Qu(W, Tn);
14611
+ W.hidden = !p, p && qn !== null && Qu(W, qn);
14604
14612
  }, us = /* @__PURE__ */ new Map(), Tp = async (p, I, C) => {
14605
14613
  const A = us.get(p) ?? /* @__PURE__ */ new Set();
14606
14614
  if (!A.has(I)) {
@@ -14616,7 +14624,7 @@ async function lw(t = {}) {
14616
14624
  const jo = (p = {}) => {
14617
14625
  vt++, Pt.clear(), ic(), tn = null, ve = null, gi = !1, Yi.clear(), on = !0, dt(!0, "newSession"), St(), $e = !1, $t();
14618
14626
  const I = Promise.resolve(M.startNewSession(p));
14619
- return wi = null, fo.clear(), $.value = "", ct = [], li(), Oi($), Ge(), Le(), _n($, "new_chat"), Ce(M.getState()), I;
14627
+ return wi = null, fo.clear(), $.value = "", ct = [], li(), Oi($), Ge(), Le(), vn($, "new_chat"), Ce(M.getState()), I;
14620
14628
  };
14621
14629
  T?.addEventListener("click", () => {
14622
14630
  ln(et("proactive_suggestion"), "run").catch(() => {
@@ -14690,7 +14698,7 @@ async function lw(t = {}) {
14690
14698
  xt.addEventListener("click", () => {
14691
14699
  qp();
14692
14700
  });
14693
- let qn = !1, ki = null, hs = 0, $o = 0;
14701
+ let Pn = !1, ki = null, hs = 0, $o = 0;
14694
14702
  const Ce = (p, I = {}) => {
14695
14703
  dc(p) && (ve = null), lc = I.renderSource ?? "local", r.dataset.conversationGate = e.loginRequired ? "authentication" : e.signupRequired ? "signup" : "none", xo(), r.classList.toggle("pluno-pa-widget--logged-out", e.loginRequired && e.entrySurface === "extension_widget"), N.classList.remove("pluno-pa-widget__access-notice--login-only"), p = { ...p, messages: p.messages.map((Z) => {
14696
14704
  if (!Z.attachments?.some((qe) => qe.id && !qe.fileUrl && ci.has(qe.id))) return Z;
@@ -14726,18 +14734,18 @@ async function lw(t = {}) {
14726
14734
  cs,
14727
14735
  (ki ?? Z.message).replace(new RegExp("(?<=[.!?])\\s+", "g"), `
14728
14736
  `),
14729
- qn ? "Trying" : "Try again",
14737
+ Pn ? "Trying" : "Try again",
14730
14738
  void 0,
14731
14739
  !1,
14732
14740
  void 0
14733
14741
  );
14734
14742
  const qe = N.querySelector(".pluno-pa-widget__login");
14735
- qe.disabled = qn, qe.setAttribute("aria-busy", String(qn)), qn && qe.prepend(wn()), qe.addEventListener("click", () => {
14743
+ qe.disabled = Pn, qe.setAttribute("aria-busy", String(Pn)), Pn && qe.prepend(wn()), qe.addEventListener("click", () => {
14736
14744
  const Ei = ++hs, Up = $o;
14737
- qn = !0, ki = null, Ce(M.getState()), ut().catch((Jc) => {
14745
+ Pn = !0, ki = null, Ce(M.getState()), ut().catch((Jc) => {
14738
14746
  Ei !== hs || Up !== $o || (ki = Jc instanceof Error ? Jc.message : "Close and reopen Pluno to try again.");
14739
14747
  }).finally(() => {
14740
- Ei === hs && (qn = !1, Ue || Ce(M.getState()));
14748
+ Ei === hs && (Pn = !1, Ue || Ce(M.getState()));
14741
14749
  });
14742
14750
  });
14743
14751
  return;
@@ -14785,7 +14793,7 @@ async function lw(t = {}) {
14785
14793
  ps,
14786
14794
  W,
14787
14795
  p,
14788
- Tn,
14796
+ qn,
14789
14797
  zc(p),
14790
14798
  X,
14791
14799
  () => Ft.enabled,
@@ -14796,7 +14804,7 @@ async function lw(t = {}) {
14796
14804
  Ge,
14797
14805
  cs,
14798
14806
  (Z, ut) => {
14799
- if (e.productVariant === "personal" ? !Rn() : Tc())
14807
+ if (e.productVariant === "personal" ? !Tn() : Tc())
14800
14808
  return;
14801
14809
  on = !0, dt(!0, "send"), St();
14802
14810
  const qe = et("morning_report");
@@ -14847,7 +14855,7 @@ async function lw(t = {}) {
14847
14855
  Kc
14848
14856
  );
14849
14857
  const Ho = (p) => {
14850
- Tn = e.entrySurface === "extension_widget" || p.user && !e.loginRequired ? p.activeUsersCount ?? null : null, Bc();
14858
+ qn = e.entrySurface === "extension_widget" || p.user && !e.loginRequired ? p.activeUsersCount ?? null : null, Bc();
14851
14859
  };
14852
14860
  Ho(M.getState());
14853
14861
  const Pp = M.subscribeInteractions((p) => {
@@ -14855,7 +14863,7 @@ async function lw(t = {}) {
14855
14863
  }), Mp = M.subscribeAccount((p) => {
14856
14864
  if (!p && !os) return;
14857
14865
  const I = p?.auth;
14858
- (I?.status !== "error" || I.errorCode !== "browser_session_unavailable" && I.errorCode !== "backend_auth_pending") && (hs += 1, ki = null, qn = !1);
14866
+ (I?.status !== "error" || I.errorCode !== "browser_session_unavailable" && I.errorCode !== "backend_auth_pending") && (hs += 1, ki = null, Pn = !1);
14859
14867
  const C = Lt();
14860
14868
  e.billingStatus = p, n(p), Ho(M.getState()), Vn(), Ce(M.getState(), { skipUnchangedTimeline: !0, renderSource: "account" }), po(), Le(), queueMicrotask(Oc), C && !Lt() && Po();
14861
14869
  });
@@ -14953,7 +14961,7 @@ async function lw(t = {}) {
14953
14961
  ), w.removeEventListener("drop", cn, !0), w.removeEventListener("dragend", cn, !0), w.defaultView?.removeEventListener(
14954
14962
  "blur",
14955
14963
  cn
14956
- ), window.removeEventListener("resize", bc), wc(), vp(), Ip(), jt !== null && window.clearTimeout(jt), lt !== null && (window.clearTimeout(lt), lt = null), fp(), vn !== null && (window.clearTimeout(vn), vn = null), sn !== null && (window.clearTimeout(sn), sn = null), Ji?.clear(), rc && M.destroy(), go?.release(), o.remove());
14964
+ ), window.removeEventListener("resize", bc), wc(), vp(), Ip(), jt !== null && window.clearTimeout(jt), lt !== null && (window.clearTimeout(lt), lt = null), fp(), In !== null && (window.clearTimeout(In), In = null), sn !== null && (window.clearTimeout(sn), sn = null), Ji?.clear(), rc && M.destroy(), go?.release(), o.remove());
14957
14965
  }
14958
14966
  };
14959
14967
  async function Np(p) {
@@ -14969,7 +14977,7 @@ async function lw(t = {}) {
14969
14977
  if (A.select(), A.setSelectionRange(0, p.length), !document.execCommand("copy"))
14970
14978
  throw new Error("Could not copy referral link.");
14971
14979
  } finally {
14972
- A.remove(), C?.isConnected && _n(C, "referral_copy_restore", {
14980
+ A.remove(), C?.isConnected && vn(C, "referral_copy_restore", {
14973
14981
  preventScroll: !0
14974
14982
  });
14975
14983
  }
@@ -15278,7 +15286,7 @@ function mw() {
15278
15286
  )
15279
15287
  };
15280
15288
  }
15281
- function Nn(t = null) {
15289
+ function Un(t = null) {
15282
15290
  return t ? ao(t) : mw();
15283
15291
  }
15284
15292
  function ao(t) {
@@ -15394,7 +15402,7 @@ function vw(t) {
15394
15402
  return t.classList.contains("pluno-pa-widget--scribble") ? ow : sw;
15395
15403
  }
15396
15404
  function Tr(t, e, n, i = null) {
15397
- const s = Hi(t), o = Nn(i), a = {
15405
+ const s = Hi(t), o = Un(i), a = {
15398
15406
  x: n === "bottom-left" ? e.x : e.x + s.width - o.width,
15399
15407
  y: e.y + s.height - o.height
15400
15408
  };
@@ -16542,20 +16550,20 @@ function Yw(t) {
16542
16550
  const i = document.createElement("img");
16543
16551
  return i.src = n, i.alt = "", i.setAttribute("aria-hidden", "true"), i.addEventListener(
16544
16552
  "error",
16545
- () => i.replaceWith(jn(t))
16553
+ () => i.replaceWith(Fn(t))
16546
16554
  ), i;
16547
16555
  }
16548
16556
  if (e === "video" && n) {
16549
16557
  const i = document.createElement("video");
16550
16558
  return i.src = n, i.muted = !0, i.preload = "metadata", i.setAttribute("aria-hidden", "true"), i.addEventListener(
16551
16559
  "error",
16552
- () => i.replaceWith(jn(t))
16560
+ () => i.replaceWith(Fn(t))
16553
16561
  ), i.addEventListener(
16554
16562
  "stalled",
16555
- () => i.replaceWith(jn(t))
16563
+ () => i.replaceWith(Fn(t))
16556
16564
  ), i;
16557
16565
  }
16558
- return jn(t);
16566
+ return Fn(t);
16559
16567
  }
16560
16568
  function Xw(t, e) {
16561
16569
  const n = Xa(t), i = Ys(t);
@@ -16591,18 +16599,18 @@ function Xw(t, e) {
16591
16599
  return;
16592
16600
  }
16593
16601
  s.replaceWith(
16594
- jn(o, "message")
16602
+ Fn(o, "message")
16595
16603
  );
16596
16604
  };
16597
16605
  return s.addEventListener("error", r), s.addEventListener("stalled", r), s;
16598
16606
  }
16599
- return jn(t, "message");
16607
+ return Fn(t, "message");
16600
16608
  }
16601
16609
  function Zw(t, e, n, i, s, o) {
16602
16610
  let a = n;
16603
16611
  const r = n.startsWith("data:") || n.startsWith(`blob:${window.location.origin}/`), c = () => {
16604
16612
  t.isConnected && t.replaceWith(
16605
- jn(e(), "message")
16613
+ Fn(e(), "message")
16606
16614
  );
16607
16615
  }, d = () => {
16608
16616
  const g = Ys(e());
@@ -16647,7 +16655,7 @@ function Zw(t, e, n, i, s, o) {
16647
16655
  };
16648
16656
  l();
16649
16657
  }
16650
- function jn(t, e = "composer") {
16658
+ function Fn(t, e = "composer") {
16651
16659
  if (e === "composer") {
16652
16660
  const o = document.createElement("span");
16653
16661
  return o.className = "pluno-pa-widget__attachment-file", o.textContent = bd(t), o;